mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into strictObjectLiterals
Conflicts: tests/baselines/reference/typeGuardFunction.types
This commit is contained in:
+34
-13
@@ -113,7 +113,7 @@ var languageServiceLibrarySources = [
|
||||
return path.join(serverDirectory, f);
|
||||
}).concat(servicesSources);
|
||||
|
||||
var harnessSources = [
|
||||
var harnessCoreSources = [
|
||||
"harness.ts",
|
||||
"sourceMapRecorder.ts",
|
||||
"harnessLanguageService.ts",
|
||||
@@ -129,7 +129,9 @@ var harnessSources = [
|
||||
"runner.ts"
|
||||
].map(function (f) {
|
||||
return path.join(harnessDirectory, f);
|
||||
}).concat([
|
||||
});
|
||||
|
||||
var harnessSources = harnessCoreSources.concat([
|
||||
"incrementalParser.ts",
|
||||
"jsDocParsing.ts",
|
||||
"services/colorization.ts",
|
||||
@@ -361,7 +363,7 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca
|
||||
/*keepComments*/ true,
|
||||
/*noResolve*/ false,
|
||||
/*stripInternal*/ true,
|
||||
/*callback*/ function () {
|
||||
/*callback*/ function () {
|
||||
jake.cpR(servicesFile, nodePackageFile, {silent: true});
|
||||
|
||||
prependFile(copyright, standaloneDefinitionsFile);
|
||||
@@ -379,12 +381,12 @@ compileFile(serverFile, serverSources,[builtLocalDirectory, copyright].concat(se
|
||||
|
||||
var lsslFile = path.join(builtLocalDirectory, "tslssl.js");
|
||||
compileFile(
|
||||
lsslFile,
|
||||
languageServiceLibrarySources,
|
||||
lsslFile,
|
||||
languageServiceLibrarySources,
|
||||
[builtLocalDirectory, copyright].concat(languageServiceLibrarySources),
|
||||
/*prefixes*/ [copyright],
|
||||
/*useBuiltCompiler*/ true,
|
||||
/*noOutFile*/ false,
|
||||
/*prefixes*/ [copyright],
|
||||
/*useBuiltCompiler*/ true,
|
||||
/*noOutFile*/ false,
|
||||
/*generateDeclarations*/ true);
|
||||
|
||||
// Local target to build the language service server library
|
||||
@@ -488,7 +490,7 @@ var refTest262Baseline = path.join(internalTests, "baselines/test262/reference")
|
||||
desc("Builds the test infrastructure using the built compiler");
|
||||
task("tests", ["local", run].concat(libraryTargets));
|
||||
|
||||
function exec(cmd, completeHandler) {
|
||||
function exec(cmd, completeHandler, errorHandler) {
|
||||
var ex = jake.createExec([cmd], {windowsVerbatimArguments: true});
|
||||
// Add listeners for output and error
|
||||
ex.addListener("stdout", function(output) {
|
||||
@@ -504,8 +506,12 @@ function exec(cmd, completeHandler) {
|
||||
complete();
|
||||
});
|
||||
ex.addListener("error", function(e, status) {
|
||||
fail("Process exited with code " + status);
|
||||
})
|
||||
if(errorHandler) {
|
||||
errorHandler(e, status);
|
||||
} else {
|
||||
fail("Process exited with code " + status);
|
||||
}
|
||||
});
|
||||
|
||||
ex.run();
|
||||
}
|
||||
@@ -562,7 +568,7 @@ task("runtests", ["tests", builtLocalDirectory], function() {
|
||||
colors = process.env.colors || process.env.color
|
||||
colors = colors ? ' --no-colors ' : ' --colors ';
|
||||
tests = tests ? ' -g ' + tests : '';
|
||||
reporter = process.env.reporter || process.env.r || 'dot';
|
||||
reporter = process.env.reporter || process.env.r || 'mocha-fivemat-progress-reporter';
|
||||
// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
|
||||
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
|
||||
var cmd = host + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
|
||||
@@ -717,7 +723,22 @@ task('tsc-instrumented', [loggedIOJsPath, instrumenterJsPath, tscFile], function
|
||||
}, { async: true });
|
||||
|
||||
desc("Updates the sublime plugin's tsserver");
|
||||
task("update-sublime", [serverFile], function() {
|
||||
task("update-sublime", ["local", serverFile], function() {
|
||||
jake.cpR(serverFile, "../TypeScript-Sublime-Plugin/tsserver/");
|
||||
jake.cpR(serverFile + ".map", "../TypeScript-Sublime-Plugin/tsserver/");
|
||||
});
|
||||
|
||||
// if the codebase were free of linter errors we could make jake runtests
|
||||
// run this task automatically
|
||||
desc("Runs tslint on the compiler sources");
|
||||
task("lint", [], function() {
|
||||
function success(f) { return function() { console.log('SUCCESS: No linter errors in ' + f + '\n'); }};
|
||||
function failure(f) { return function() { console.log('FAILURE: Please fix linting errors in ' + f + '\n') }};
|
||||
|
||||
var lintTargets = compilerSources.concat(harnessCoreSources);
|
||||
for(var i in lintTargets) {
|
||||
var f = lintTargets[i];
|
||||
var cmd = 'tslint -f ' + f;
|
||||
exec(cmd, success(f), failure(f));
|
||||
}
|
||||
}, { async: true });
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
[](https://travis-ci.org/Microsoft/TypeScript)
|
||||
[](http://issuestats.com/github/microsoft/typescript)
|
||||
[](http://issuestats.com/github/microsoft/typescript)
|
||||
[](http://badge.fury.io/js/typescript)
|
||||
[](https://npmjs.org/package/typescript)
|
||||
|
||||
|
||||
Vendored
+13
@@ -1184,3 +1184,16 @@ declare type ClassDecorator = <TFunction extends Function>(target: TFunction) =>
|
||||
declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
|
||||
declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
|
||||
declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
|
||||
|
||||
declare type PromiseConstructorLike = new <T>(executor: (resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void) => PromiseLike<T>;
|
||||
|
||||
interface PromiseLike<T> {
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>;
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): PromiseLike<TResult>;
|
||||
}
|
||||
|
||||
Vendored
+14
-11
@@ -1184,6 +1184,19 @@ declare type ClassDecorator = <TFunction extends Function>(target: TFunction) =>
|
||||
declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
|
||||
declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
|
||||
declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
|
||||
|
||||
declare type PromiseConstructorLike = new <T>(executor: (resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void) => PromiseLike<T>;
|
||||
|
||||
interface PromiseLike<T> {
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>;
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): PromiseLike<TResult>;
|
||||
}
|
||||
declare type PropertyKey = string | number | symbol;
|
||||
|
||||
interface Symbol {
|
||||
@@ -4759,17 +4772,6 @@ declare module Reflect {
|
||||
function setPrototypeOf(target: any, proto: any): boolean;
|
||||
}
|
||||
|
||||
interface PromiseLike<T> {
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>;
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): PromiseLike<TResult>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the completion of an asynchronous operation
|
||||
*/
|
||||
@@ -4789,6 +4791,7 @@ interface Promise<T> {
|
||||
* @returns A Promise for the completion of the callback.
|
||||
*/
|
||||
catch(onrejected?: (reason: any) => T | PromiseLike<T>): Promise<T>;
|
||||
catch(onrejected?: (reason: any) => void): Promise<T>;
|
||||
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
Vendored
+50
-64
@@ -1185,6 +1185,19 @@ declare type PropertyDecorator = (target: Object, propertyKey: string | symbol)
|
||||
declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
|
||||
declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
|
||||
|
||||
declare type PromiseConstructorLike = new <T>(executor: (resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void) => PromiseLike<T>;
|
||||
|
||||
interface PromiseLike<T> {
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>;
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): PromiseLike<TResult>;
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
/// IE10 ECMAScript Extensions
|
||||
/////////////////////////////
|
||||
@@ -4755,16 +4768,11 @@ interface CanvasRenderingContext2D {
|
||||
clearRect(x: number, y: number, w: number, h: number): void;
|
||||
clip(fillRule?: string): void;
|
||||
closePath(): void;
|
||||
createImageData(imageDataOrSw: number, sh?: number): ImageData;
|
||||
createImageData(imageDataOrSw: ImageData, sh?: number): ImageData;
|
||||
createImageData(imageDataOrSw: number | ImageData, sh?: number): ImageData;
|
||||
createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient;
|
||||
createPattern(image: HTMLImageElement, repetition: string): CanvasPattern;
|
||||
createPattern(image: HTMLCanvasElement, repetition: string): CanvasPattern;
|
||||
createPattern(image: HTMLVideoElement, repetition: string): CanvasPattern;
|
||||
createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern;
|
||||
createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient;
|
||||
drawImage(image: HTMLImageElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void;
|
||||
drawImage(image: HTMLCanvasElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void;
|
||||
drawImage(image: HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void;
|
||||
drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void;
|
||||
fill(fillRule?: string): void;
|
||||
fillRect(x: number, y: number, w: number, h: number): void;
|
||||
fillText(text: string, x: number, y: number, maxWidth?: number): void;
|
||||
@@ -5922,12 +5930,12 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
|
||||
* @param elementId String that specifies the ID value. Case-insensitive.
|
||||
*/
|
||||
getElementById(elementId: string): HTMLElement;
|
||||
getElementsByClassName(classNames: string): NodeList;
|
||||
getElementsByClassName(classNames: string): NodeListOf<Element>;
|
||||
/**
|
||||
* 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;
|
||||
getElementsByName(elementName: string): NodeListOf<Element>;
|
||||
/**
|
||||
* Retrieves a collection of objects based on the specified element name.
|
||||
* @param name Specifies the name of an element.
|
||||
@@ -6105,8 +6113,8 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
|
||||
getElementsByTagName(tagname: "wbr"): NodeListOf<HTMLElement>;
|
||||
getElementsByTagName(tagname: "x-ms-webview"): NodeListOf<MSHTMLWebViewElement>;
|
||||
getElementsByTagName(tagname: "xmp"): NodeListOf<HTMLBlockElement>;
|
||||
getElementsByTagName(tagname: string): NodeList;
|
||||
getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList;
|
||||
getElementsByTagName(tagname: string): NodeListOf<Element>;
|
||||
getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf<Element>;
|
||||
/**
|
||||
* Returns an object representing the current selection of the document that is loaded into the object displaying a webpage.
|
||||
*/
|
||||
@@ -6379,6 +6387,8 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
|
||||
scrollTop: number;
|
||||
scrollWidth: number;
|
||||
tagName: string;
|
||||
id: string;
|
||||
className: string;
|
||||
getAttribute(name?: string): string;
|
||||
getAttributeNS(namespaceURI: string, localName: string): string;
|
||||
getAttributeNode(name: string): Attr;
|
||||
@@ -6558,8 +6568,8 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
|
||||
getElementsByTagName(name: "wbr"): NodeListOf<HTMLElement>;
|
||||
getElementsByTagName(name: "x-ms-webview"): NodeListOf<MSHTMLWebViewElement>;
|
||||
getElementsByTagName(name: "xmp"): NodeListOf<HTMLBlockElement>;
|
||||
getElementsByTagName(name: string): NodeList;
|
||||
getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList;
|
||||
getElementsByTagName(name: string): NodeListOf<Element>;
|
||||
getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf<Element>;
|
||||
hasAttribute(name: string): boolean;
|
||||
hasAttributeNS(namespaceURI: string, localName: string): boolean;
|
||||
msGetRegionContent(): MSRangeCollection;
|
||||
@@ -6740,7 +6750,7 @@ interface FormData {
|
||||
|
||||
declare var FormData: {
|
||||
prototype: FormData;
|
||||
new(): FormData;
|
||||
new (form?: HTMLFormElement): FormData;
|
||||
}
|
||||
|
||||
interface GainNode extends AudioNode {
|
||||
@@ -7033,8 +7043,7 @@ interface HTMLAreasCollection extends HTMLCollection {
|
||||
/**
|
||||
* Adds an element to the areas, controlRange, or options collection.
|
||||
*/
|
||||
add(element: HTMLElement, before?: HTMLElement): void;
|
||||
add(element: HTMLElement, before?: number): void;
|
||||
add(element: HTMLElement, before?: HTMLElement | number): void;
|
||||
/**
|
||||
* Removes an element from the collection.
|
||||
*/
|
||||
@@ -7478,14 +7487,12 @@ declare var HTMLDocument: {
|
||||
interface HTMLElement extends Element {
|
||||
accessKey: string;
|
||||
children: HTMLCollection;
|
||||
className: string;
|
||||
contentEditable: string;
|
||||
dataset: DOMStringMap;
|
||||
dir: string;
|
||||
draggable: boolean;
|
||||
hidden: boolean;
|
||||
hideFocus: boolean;
|
||||
id: string;
|
||||
innerHTML: string;
|
||||
innerText: string;
|
||||
isContentEditable: boolean;
|
||||
@@ -7572,7 +7579,7 @@ interface HTMLElement extends Element {
|
||||
contains(child: HTMLElement): boolean;
|
||||
dragDrop(): boolean;
|
||||
focus(): void;
|
||||
getElementsByClassName(classNames: string): NodeList;
|
||||
getElementsByClassName(classNames: string): NodeListOf<Element>;
|
||||
insertAdjacentElement(position: string, insertedElement: Element): Element;
|
||||
insertAdjacentHTML(where: string, html: string): void;
|
||||
insertAdjacentText(where: string, text: string): void;
|
||||
@@ -9782,8 +9789,7 @@ interface HTMLSelectElement extends HTMLElement {
|
||||
* @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?: HTMLElement): void;
|
||||
add(element: HTMLElement, before?: number): void;
|
||||
add(element: HTMLElement, before?: HTMLElement | number): void;
|
||||
/**
|
||||
* Returns whether a form will validate when it is submitted, without having to submit it.
|
||||
*/
|
||||
@@ -12385,6 +12391,7 @@ declare var SVGDescElement: {
|
||||
|
||||
interface SVGElement extends Element {
|
||||
id: string;
|
||||
className: any;
|
||||
onclick: (ev: MouseEvent) => any;
|
||||
ondblclick: (ev: MouseEvent) => any;
|
||||
onfocusin: (ev: FocusEvent) => any;
|
||||
@@ -13944,8 +13951,7 @@ interface Screen extends EventTarget {
|
||||
systemXDPI: number;
|
||||
systemYDPI: number;
|
||||
width: number;
|
||||
msLockOrientation(orientations: string): boolean;
|
||||
msLockOrientation(orientations: string[]): boolean;
|
||||
msLockOrientation(orientations: string | string[]): boolean;
|
||||
msUnlockOrientation(): void;
|
||||
addEventListener(type: "MSOrientationChange", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
@@ -14017,8 +14023,7 @@ interface SourceBuffer extends EventTarget {
|
||||
updating: boolean;
|
||||
videoTracks: VideoTrackList;
|
||||
abort(): void;
|
||||
appendBuffer(data: ArrayBuffer): void;
|
||||
appendBuffer(data: ArrayBufferView): void;
|
||||
appendBuffer(data: ArrayBuffer | ArrayBufferView): void;
|
||||
appendStream(stream: MSStream, maxSize?: number): void;
|
||||
remove(start: number, end: number): void;
|
||||
}
|
||||
@@ -14126,33 +14131,18 @@ declare var StyleSheetPageList: {
|
||||
}
|
||||
|
||||
interface SubtleCrypto {
|
||||
decrypt(algorithm: string, key: CryptoKey, data: ArrayBufferView): any;
|
||||
decrypt(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any;
|
||||
deriveBits(algorithm: string, baseKey: CryptoKey, length: number): any;
|
||||
deriveBits(algorithm: Algorithm, baseKey: CryptoKey, length: number): any;
|
||||
deriveKey(algorithm: string, baseKey: CryptoKey, derivedKeyType: string, extractable: boolean, keyUsages: string[]): any;
|
||||
deriveKey(algorithm: string, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: string, extractable: boolean, keyUsages: string[]): any;
|
||||
deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
digest(algorithm: string, data: ArrayBufferView): any;
|
||||
digest(algorithm: Algorithm, data: ArrayBufferView): any;
|
||||
encrypt(algorithm: string, key: CryptoKey, data: ArrayBufferView): any;
|
||||
encrypt(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any;
|
||||
decrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any;
|
||||
deriveBits(algorithm: string | Algorithm, baseKey: CryptoKey, length: number): any;
|
||||
deriveKey(algorithm: string | Algorithm, baseKey: CryptoKey, derivedKeyType: string | Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
digest(algorithm: string | Algorithm, data: ArrayBufferView): any;
|
||||
encrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any;
|
||||
exportKey(format: string, key: CryptoKey): any;
|
||||
generateKey(algorithm: string, extractable: boolean, keyUsages: string[]): any;
|
||||
generateKey(algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
importKey(format: string, keyData: ArrayBufferView, algorithm: string, extractable: boolean, keyUsages: string[]): any;
|
||||
importKey(format: string, keyData: ArrayBufferView, algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
sign(algorithm: string, key: CryptoKey, data: ArrayBufferView): any;
|
||||
sign(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any;
|
||||
unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any;
|
||||
unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any;
|
||||
unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
verify(algorithm: string, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any;
|
||||
verify(algorithm: Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any;
|
||||
wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string): any;
|
||||
wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: Algorithm): any;
|
||||
generateKey(algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
importKey(format: string, keyData: ArrayBufferView, algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
sign(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any;
|
||||
unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | Algorithm, unwrappedKeyAlgorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
verify(algorithm: string | Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any;
|
||||
wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | Algorithm): any;
|
||||
}
|
||||
|
||||
declare var SubtleCrypto: {
|
||||
@@ -14661,11 +14651,8 @@ interface WebGLRenderingContext {
|
||||
blendEquationSeparate(modeRGB: number, modeAlpha: number): void;
|
||||
blendFunc(sfactor: number, dfactor: number): void;
|
||||
blendFuncSeparate(srcRGB: number, dstRGB: number, srcAlpha: number, dstAlpha: number): void;
|
||||
bufferData(target: number, size: number, usage: number): void;
|
||||
bufferData(target: number, size: ArrayBufferView, usage: number): void;
|
||||
bufferData(target: number, size: any, usage: number): void;
|
||||
bufferSubData(target: number, offset: number, data: ArrayBufferView): void;
|
||||
bufferSubData(target: number, offset: number, data: any): void;
|
||||
bufferData(target: number, size: number | ArrayBufferView | ArrayBuffer, usage: number): void;
|
||||
bufferSubData(target: number, offset: number, data: ArrayBufferView | ArrayBuffer): void;
|
||||
checkFramebufferStatus(target: number): number;
|
||||
clear(mask: number): void;
|
||||
clearColor(red: number, green: number, blue: number, alpha: number): void;
|
||||
@@ -15508,8 +15495,7 @@ interface WebSocket extends EventTarget {
|
||||
|
||||
declare var WebSocket: {
|
||||
prototype: WebSocket;
|
||||
new(url: string, protocols?: string): WebSocket;
|
||||
new(url: string, protocols?: any): WebSocket;
|
||||
new(url: string, protocols?: string | string[]): WebSocket;
|
||||
CLOSED: number;
|
||||
CLOSING: number;
|
||||
CONNECTING: number;
|
||||
@@ -15675,6 +15661,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window
|
||||
toolbar: BarProp;
|
||||
top: Window;
|
||||
window: Window;
|
||||
URL: URL;
|
||||
alert(message?: any): void;
|
||||
blur(): void;
|
||||
cancelAnimationFrame(handle: number): void;
|
||||
@@ -16178,7 +16165,7 @@ interface NavigatorStorageUtils {
|
||||
|
||||
interface NodeSelector {
|
||||
querySelector(selectors: string): Element;
|
||||
querySelectorAll(selectors: string): NodeList;
|
||||
querySelectorAll(selectors: string): NodeListOf<Element>;
|
||||
}
|
||||
|
||||
interface RandomSource {
|
||||
@@ -16226,7 +16213,7 @@ interface SVGLocatable {
|
||||
}
|
||||
|
||||
interface SVGStylable {
|
||||
className: SVGAnimatedString;
|
||||
className: any;
|
||||
style: CSSStyleDeclaration;
|
||||
}
|
||||
|
||||
@@ -16313,8 +16300,7 @@ interface EventListenerObject {
|
||||
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
|
||||
|
||||
interface ErrorEventHandler {
|
||||
(event: Event, source?: string, fileno?: number, columnNumber?: number): void;
|
||||
(event: string, source?: string, fileno?: number, columnNumber?: number): void;
|
||||
(message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void;
|
||||
}
|
||||
interface PositionCallback {
|
||||
(position: Position): void;
|
||||
@@ -16490,6 +16476,7 @@ declare var styleMedia: StyleMedia;
|
||||
declare var toolbar: BarProp;
|
||||
declare var top: Window;
|
||||
declare var window: Window;
|
||||
declare var URL: URL;
|
||||
declare function alert(message?: any): void;
|
||||
declare function blur(): void;
|
||||
declare function cancelAnimationFrame(handle: number): void;
|
||||
@@ -16642,7 +16629,6 @@ declare function addEventListener(type: "volumechange", listener: (ev: Event) =>
|
||||
declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
|
||||
/////////////////////////////
|
||||
/// WorkerGlobalScope APIs
|
||||
/////////////////////////////
|
||||
|
||||
Vendored
+38
-64
@@ -3585,16 +3585,11 @@ interface CanvasRenderingContext2D {
|
||||
clearRect(x: number, y: number, w: number, h: number): void;
|
||||
clip(fillRule?: string): void;
|
||||
closePath(): void;
|
||||
createImageData(imageDataOrSw: number, sh?: number): ImageData;
|
||||
createImageData(imageDataOrSw: ImageData, sh?: number): ImageData;
|
||||
createImageData(imageDataOrSw: number | ImageData, sh?: number): ImageData;
|
||||
createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient;
|
||||
createPattern(image: HTMLImageElement, repetition: string): CanvasPattern;
|
||||
createPattern(image: HTMLCanvasElement, repetition: string): CanvasPattern;
|
||||
createPattern(image: HTMLVideoElement, repetition: string): CanvasPattern;
|
||||
createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern;
|
||||
createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient;
|
||||
drawImage(image: HTMLImageElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void;
|
||||
drawImage(image: HTMLCanvasElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void;
|
||||
drawImage(image: HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void;
|
||||
drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void;
|
||||
fill(fillRule?: string): void;
|
||||
fillRect(x: number, y: number, w: number, h: number): void;
|
||||
fillText(text: string, x: number, y: number, maxWidth?: number): void;
|
||||
@@ -4752,12 +4747,12 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
|
||||
* @param elementId String that specifies the ID value. Case-insensitive.
|
||||
*/
|
||||
getElementById(elementId: string): HTMLElement;
|
||||
getElementsByClassName(classNames: string): NodeList;
|
||||
getElementsByClassName(classNames: string): NodeListOf<Element>;
|
||||
/**
|
||||
* 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;
|
||||
getElementsByName(elementName: string): NodeListOf<Element>;
|
||||
/**
|
||||
* Retrieves a collection of objects based on the specified element name.
|
||||
* @param name Specifies the name of an element.
|
||||
@@ -4935,8 +4930,8 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
|
||||
getElementsByTagName(tagname: "wbr"): NodeListOf<HTMLElement>;
|
||||
getElementsByTagName(tagname: "x-ms-webview"): NodeListOf<MSHTMLWebViewElement>;
|
||||
getElementsByTagName(tagname: "xmp"): NodeListOf<HTMLBlockElement>;
|
||||
getElementsByTagName(tagname: string): NodeList;
|
||||
getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList;
|
||||
getElementsByTagName(tagname: string): NodeListOf<Element>;
|
||||
getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf<Element>;
|
||||
/**
|
||||
* Returns an object representing the current selection of the document that is loaded into the object displaying a webpage.
|
||||
*/
|
||||
@@ -5209,6 +5204,8 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
|
||||
scrollTop: number;
|
||||
scrollWidth: number;
|
||||
tagName: string;
|
||||
id: string;
|
||||
className: string;
|
||||
getAttribute(name?: string): string;
|
||||
getAttributeNS(namespaceURI: string, localName: string): string;
|
||||
getAttributeNode(name: string): Attr;
|
||||
@@ -5388,8 +5385,8 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
|
||||
getElementsByTagName(name: "wbr"): NodeListOf<HTMLElement>;
|
||||
getElementsByTagName(name: "x-ms-webview"): NodeListOf<MSHTMLWebViewElement>;
|
||||
getElementsByTagName(name: "xmp"): NodeListOf<HTMLBlockElement>;
|
||||
getElementsByTagName(name: string): NodeList;
|
||||
getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList;
|
||||
getElementsByTagName(name: string): NodeListOf<Element>;
|
||||
getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf<Element>;
|
||||
hasAttribute(name: string): boolean;
|
||||
hasAttributeNS(namespaceURI: string, localName: string): boolean;
|
||||
msGetRegionContent(): MSRangeCollection;
|
||||
@@ -5570,7 +5567,7 @@ interface FormData {
|
||||
|
||||
declare var FormData: {
|
||||
prototype: FormData;
|
||||
new(): FormData;
|
||||
new (form?: HTMLFormElement): FormData;
|
||||
}
|
||||
|
||||
interface GainNode extends AudioNode {
|
||||
@@ -5863,8 +5860,7 @@ interface HTMLAreasCollection extends HTMLCollection {
|
||||
/**
|
||||
* Adds an element to the areas, controlRange, or options collection.
|
||||
*/
|
||||
add(element: HTMLElement, before?: HTMLElement): void;
|
||||
add(element: HTMLElement, before?: number): void;
|
||||
add(element: HTMLElement, before?: HTMLElement | number): void;
|
||||
/**
|
||||
* Removes an element from the collection.
|
||||
*/
|
||||
@@ -6308,14 +6304,12 @@ declare var HTMLDocument: {
|
||||
interface HTMLElement extends Element {
|
||||
accessKey: string;
|
||||
children: HTMLCollection;
|
||||
className: string;
|
||||
contentEditable: string;
|
||||
dataset: DOMStringMap;
|
||||
dir: string;
|
||||
draggable: boolean;
|
||||
hidden: boolean;
|
||||
hideFocus: boolean;
|
||||
id: string;
|
||||
innerHTML: string;
|
||||
innerText: string;
|
||||
isContentEditable: boolean;
|
||||
@@ -6402,7 +6396,7 @@ interface HTMLElement extends Element {
|
||||
contains(child: HTMLElement): boolean;
|
||||
dragDrop(): boolean;
|
||||
focus(): void;
|
||||
getElementsByClassName(classNames: string): NodeList;
|
||||
getElementsByClassName(classNames: string): NodeListOf<Element>;
|
||||
insertAdjacentElement(position: string, insertedElement: Element): Element;
|
||||
insertAdjacentHTML(where: string, html: string): void;
|
||||
insertAdjacentText(where: string, text: string): void;
|
||||
@@ -8612,8 +8606,7 @@ interface HTMLSelectElement extends HTMLElement {
|
||||
* @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?: HTMLElement): void;
|
||||
add(element: HTMLElement, before?: number): void;
|
||||
add(element: HTMLElement, before?: HTMLElement | number): void;
|
||||
/**
|
||||
* Returns whether a form will validate when it is submitted, without having to submit it.
|
||||
*/
|
||||
@@ -11215,6 +11208,7 @@ declare var SVGDescElement: {
|
||||
|
||||
interface SVGElement extends Element {
|
||||
id: string;
|
||||
className: any;
|
||||
onclick: (ev: MouseEvent) => any;
|
||||
ondblclick: (ev: MouseEvent) => any;
|
||||
onfocusin: (ev: FocusEvent) => any;
|
||||
@@ -12774,8 +12768,7 @@ interface Screen extends EventTarget {
|
||||
systemXDPI: number;
|
||||
systemYDPI: number;
|
||||
width: number;
|
||||
msLockOrientation(orientations: string): boolean;
|
||||
msLockOrientation(orientations: string[]): boolean;
|
||||
msLockOrientation(orientations: string | string[]): boolean;
|
||||
msUnlockOrientation(): void;
|
||||
addEventListener(type: "MSOrientationChange", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
@@ -12847,8 +12840,7 @@ interface SourceBuffer extends EventTarget {
|
||||
updating: boolean;
|
||||
videoTracks: VideoTrackList;
|
||||
abort(): void;
|
||||
appendBuffer(data: ArrayBuffer): void;
|
||||
appendBuffer(data: ArrayBufferView): void;
|
||||
appendBuffer(data: ArrayBuffer | ArrayBufferView): void;
|
||||
appendStream(stream: MSStream, maxSize?: number): void;
|
||||
remove(start: number, end: number): void;
|
||||
}
|
||||
@@ -12956,33 +12948,18 @@ declare var StyleSheetPageList: {
|
||||
}
|
||||
|
||||
interface SubtleCrypto {
|
||||
decrypt(algorithm: string, key: CryptoKey, data: ArrayBufferView): any;
|
||||
decrypt(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any;
|
||||
deriveBits(algorithm: string, baseKey: CryptoKey, length: number): any;
|
||||
deriveBits(algorithm: Algorithm, baseKey: CryptoKey, length: number): any;
|
||||
deriveKey(algorithm: string, baseKey: CryptoKey, derivedKeyType: string, extractable: boolean, keyUsages: string[]): any;
|
||||
deriveKey(algorithm: string, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: string, extractable: boolean, keyUsages: string[]): any;
|
||||
deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
digest(algorithm: string, data: ArrayBufferView): any;
|
||||
digest(algorithm: Algorithm, data: ArrayBufferView): any;
|
||||
encrypt(algorithm: string, key: CryptoKey, data: ArrayBufferView): any;
|
||||
encrypt(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any;
|
||||
decrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any;
|
||||
deriveBits(algorithm: string | Algorithm, baseKey: CryptoKey, length: number): any;
|
||||
deriveKey(algorithm: string | Algorithm, baseKey: CryptoKey, derivedKeyType: string | Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
digest(algorithm: string | Algorithm, data: ArrayBufferView): any;
|
||||
encrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any;
|
||||
exportKey(format: string, key: CryptoKey): any;
|
||||
generateKey(algorithm: string, extractable: boolean, keyUsages: string[]): any;
|
||||
generateKey(algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
importKey(format: string, keyData: ArrayBufferView, algorithm: string, extractable: boolean, keyUsages: string[]): any;
|
||||
importKey(format: string, keyData: ArrayBufferView, algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
sign(algorithm: string, key: CryptoKey, data: ArrayBufferView): any;
|
||||
sign(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any;
|
||||
unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any;
|
||||
unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any;
|
||||
unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
verify(algorithm: string, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any;
|
||||
verify(algorithm: Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any;
|
||||
wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string): any;
|
||||
wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: Algorithm): any;
|
||||
generateKey(algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
importKey(format: string, keyData: ArrayBufferView, algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
sign(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any;
|
||||
unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | Algorithm, unwrappedKeyAlgorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
verify(algorithm: string | Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any;
|
||||
wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | Algorithm): any;
|
||||
}
|
||||
|
||||
declare var SubtleCrypto: {
|
||||
@@ -13491,11 +13468,8 @@ interface WebGLRenderingContext {
|
||||
blendEquationSeparate(modeRGB: number, modeAlpha: number): void;
|
||||
blendFunc(sfactor: number, dfactor: number): void;
|
||||
blendFuncSeparate(srcRGB: number, dstRGB: number, srcAlpha: number, dstAlpha: number): void;
|
||||
bufferData(target: number, size: number, usage: number): void;
|
||||
bufferData(target: number, size: ArrayBufferView, usage: number): void;
|
||||
bufferData(target: number, size: any, usage: number): void;
|
||||
bufferSubData(target: number, offset: number, data: ArrayBufferView): void;
|
||||
bufferSubData(target: number, offset: number, data: any): void;
|
||||
bufferData(target: number, size: number | ArrayBufferView | ArrayBuffer, usage: number): void;
|
||||
bufferSubData(target: number, offset: number, data: ArrayBufferView | ArrayBuffer): void;
|
||||
checkFramebufferStatus(target: number): number;
|
||||
clear(mask: number): void;
|
||||
clearColor(red: number, green: number, blue: number, alpha: number): void;
|
||||
@@ -14338,8 +14312,7 @@ interface WebSocket extends EventTarget {
|
||||
|
||||
declare var WebSocket: {
|
||||
prototype: WebSocket;
|
||||
new(url: string, protocols?: string): WebSocket;
|
||||
new(url: string, protocols?: any): WebSocket;
|
||||
new(url: string, protocols?: string | string[]): WebSocket;
|
||||
CLOSED: number;
|
||||
CLOSING: number;
|
||||
CONNECTING: number;
|
||||
@@ -14505,6 +14478,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window
|
||||
toolbar: BarProp;
|
||||
top: Window;
|
||||
window: Window;
|
||||
URL: URL;
|
||||
alert(message?: any): void;
|
||||
blur(): void;
|
||||
cancelAnimationFrame(handle: number): void;
|
||||
@@ -15008,7 +14982,7 @@ interface NavigatorStorageUtils {
|
||||
|
||||
interface NodeSelector {
|
||||
querySelector(selectors: string): Element;
|
||||
querySelectorAll(selectors: string): NodeList;
|
||||
querySelectorAll(selectors: string): NodeListOf<Element>;
|
||||
}
|
||||
|
||||
interface RandomSource {
|
||||
@@ -15056,7 +15030,7 @@ interface SVGLocatable {
|
||||
}
|
||||
|
||||
interface SVGStylable {
|
||||
className: SVGAnimatedString;
|
||||
className: any;
|
||||
style: CSSStyleDeclaration;
|
||||
}
|
||||
|
||||
@@ -15143,8 +15117,7 @@ interface EventListenerObject {
|
||||
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
|
||||
|
||||
interface ErrorEventHandler {
|
||||
(event: Event, source?: string, fileno?: number, columnNumber?: number): void;
|
||||
(event: string, source?: string, fileno?: number, columnNumber?: number): void;
|
||||
(message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void;
|
||||
}
|
||||
interface PositionCallback {
|
||||
(position: Position): void;
|
||||
@@ -15320,6 +15293,7 @@ declare var styleMedia: StyleMedia;
|
||||
declare var toolbar: BarProp;
|
||||
declare var top: Window;
|
||||
declare var window: Window;
|
||||
declare var URL: URL;
|
||||
declare function alert(message?: any): void;
|
||||
declare function blur(): void;
|
||||
declare function cancelAnimationFrame(handle: number): void;
|
||||
@@ -15471,4 +15445,4 @@ declare function addEventListener(type: "unload", listener: (ev: Event) => any,
|
||||
declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
Vendored
+52
-76
@@ -1184,6 +1184,19 @@ declare type ClassDecorator = <TFunction extends Function>(target: TFunction) =>
|
||||
declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
|
||||
declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
|
||||
declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
|
||||
|
||||
declare type PromiseConstructorLike = new <T>(executor: (resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void) => PromiseLike<T>;
|
||||
|
||||
interface PromiseLike<T> {
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>;
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): PromiseLike<TResult>;
|
||||
}
|
||||
declare type PropertyKey = string | number | symbol;
|
||||
|
||||
interface Symbol {
|
||||
@@ -4759,17 +4772,6 @@ declare module Reflect {
|
||||
function setPrototypeOf(target: any, proto: any): boolean;
|
||||
}
|
||||
|
||||
interface PromiseLike<T> {
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
* @param onrejected The callback to execute when the Promise is rejected.
|
||||
* @returns A Promise for the completion of which ever callback is executed.
|
||||
*/
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>;
|
||||
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): PromiseLike<TResult>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the completion of an asynchronous operation
|
||||
*/
|
||||
@@ -4789,6 +4791,7 @@ interface Promise<T> {
|
||||
* @returns A Promise for the completion of the callback.
|
||||
*/
|
||||
catch(onrejected?: (reason: any) => T | PromiseLike<T>): Promise<T>;
|
||||
catch(onrejected?: (reason: any) => void): Promise<T>;
|
||||
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
@@ -6137,16 +6140,11 @@ interface CanvasRenderingContext2D {
|
||||
clearRect(x: number, y: number, w: number, h: number): void;
|
||||
clip(fillRule?: string): void;
|
||||
closePath(): void;
|
||||
createImageData(imageDataOrSw: number, sh?: number): ImageData;
|
||||
createImageData(imageDataOrSw: ImageData, sh?: number): ImageData;
|
||||
createImageData(imageDataOrSw: number | ImageData, sh?: number): ImageData;
|
||||
createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient;
|
||||
createPattern(image: HTMLImageElement, repetition: string): CanvasPattern;
|
||||
createPattern(image: HTMLCanvasElement, repetition: string): CanvasPattern;
|
||||
createPattern(image: HTMLVideoElement, repetition: string): CanvasPattern;
|
||||
createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern;
|
||||
createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient;
|
||||
drawImage(image: HTMLImageElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void;
|
||||
drawImage(image: HTMLCanvasElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void;
|
||||
drawImage(image: HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void;
|
||||
drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void;
|
||||
fill(fillRule?: string): void;
|
||||
fillRect(x: number, y: number, w: number, h: number): void;
|
||||
fillText(text: string, x: number, y: number, maxWidth?: number): void;
|
||||
@@ -7304,12 +7302,12 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
|
||||
* @param elementId String that specifies the ID value. Case-insensitive.
|
||||
*/
|
||||
getElementById(elementId: string): HTMLElement;
|
||||
getElementsByClassName(classNames: string): NodeList;
|
||||
getElementsByClassName(classNames: string): NodeListOf<Element>;
|
||||
/**
|
||||
* 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;
|
||||
getElementsByName(elementName: string): NodeListOf<Element>;
|
||||
/**
|
||||
* Retrieves a collection of objects based on the specified element name.
|
||||
* @param name Specifies the name of an element.
|
||||
@@ -7487,8 +7485,8 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
|
||||
getElementsByTagName(tagname: "wbr"): NodeListOf<HTMLElement>;
|
||||
getElementsByTagName(tagname: "x-ms-webview"): NodeListOf<MSHTMLWebViewElement>;
|
||||
getElementsByTagName(tagname: "xmp"): NodeListOf<HTMLBlockElement>;
|
||||
getElementsByTagName(tagname: string): NodeList;
|
||||
getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList;
|
||||
getElementsByTagName(tagname: string): NodeListOf<Element>;
|
||||
getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf<Element>;
|
||||
/**
|
||||
* Returns an object representing the current selection of the document that is loaded into the object displaying a webpage.
|
||||
*/
|
||||
@@ -7761,6 +7759,8 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
|
||||
scrollTop: number;
|
||||
scrollWidth: number;
|
||||
tagName: string;
|
||||
id: string;
|
||||
className: string;
|
||||
getAttribute(name?: string): string;
|
||||
getAttributeNS(namespaceURI: string, localName: string): string;
|
||||
getAttributeNode(name: string): Attr;
|
||||
@@ -7940,8 +7940,8 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
|
||||
getElementsByTagName(name: "wbr"): NodeListOf<HTMLElement>;
|
||||
getElementsByTagName(name: "x-ms-webview"): NodeListOf<MSHTMLWebViewElement>;
|
||||
getElementsByTagName(name: "xmp"): NodeListOf<HTMLBlockElement>;
|
||||
getElementsByTagName(name: string): NodeList;
|
||||
getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList;
|
||||
getElementsByTagName(name: string): NodeListOf<Element>;
|
||||
getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf<Element>;
|
||||
hasAttribute(name: string): boolean;
|
||||
hasAttributeNS(namespaceURI: string, localName: string): boolean;
|
||||
msGetRegionContent(): MSRangeCollection;
|
||||
@@ -8122,7 +8122,7 @@ interface FormData {
|
||||
|
||||
declare var FormData: {
|
||||
prototype: FormData;
|
||||
new(): FormData;
|
||||
new (form?: HTMLFormElement): FormData;
|
||||
}
|
||||
|
||||
interface GainNode extends AudioNode {
|
||||
@@ -8415,8 +8415,7 @@ interface HTMLAreasCollection extends HTMLCollection {
|
||||
/**
|
||||
* Adds an element to the areas, controlRange, or options collection.
|
||||
*/
|
||||
add(element: HTMLElement, before?: HTMLElement): void;
|
||||
add(element: HTMLElement, before?: number): void;
|
||||
add(element: HTMLElement, before?: HTMLElement | number): void;
|
||||
/**
|
||||
* Removes an element from the collection.
|
||||
*/
|
||||
@@ -8860,14 +8859,12 @@ declare var HTMLDocument: {
|
||||
interface HTMLElement extends Element {
|
||||
accessKey: string;
|
||||
children: HTMLCollection;
|
||||
className: string;
|
||||
contentEditable: string;
|
||||
dataset: DOMStringMap;
|
||||
dir: string;
|
||||
draggable: boolean;
|
||||
hidden: boolean;
|
||||
hideFocus: boolean;
|
||||
id: string;
|
||||
innerHTML: string;
|
||||
innerText: string;
|
||||
isContentEditable: boolean;
|
||||
@@ -8954,7 +8951,7 @@ interface HTMLElement extends Element {
|
||||
contains(child: HTMLElement): boolean;
|
||||
dragDrop(): boolean;
|
||||
focus(): void;
|
||||
getElementsByClassName(classNames: string): NodeList;
|
||||
getElementsByClassName(classNames: string): NodeListOf<Element>;
|
||||
insertAdjacentElement(position: string, insertedElement: Element): Element;
|
||||
insertAdjacentHTML(where: string, html: string): void;
|
||||
insertAdjacentText(where: string, text: string): void;
|
||||
@@ -11164,8 +11161,7 @@ interface HTMLSelectElement extends HTMLElement {
|
||||
* @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?: HTMLElement): void;
|
||||
add(element: HTMLElement, before?: number): void;
|
||||
add(element: HTMLElement, before?: HTMLElement | number): void;
|
||||
/**
|
||||
* Returns whether a form will validate when it is submitted, without having to submit it.
|
||||
*/
|
||||
@@ -13767,6 +13763,7 @@ declare var SVGDescElement: {
|
||||
|
||||
interface SVGElement extends Element {
|
||||
id: string;
|
||||
className: any;
|
||||
onclick: (ev: MouseEvent) => any;
|
||||
ondblclick: (ev: MouseEvent) => any;
|
||||
onfocusin: (ev: FocusEvent) => any;
|
||||
@@ -15326,8 +15323,7 @@ interface Screen extends EventTarget {
|
||||
systemXDPI: number;
|
||||
systemYDPI: number;
|
||||
width: number;
|
||||
msLockOrientation(orientations: string): boolean;
|
||||
msLockOrientation(orientations: string[]): boolean;
|
||||
msLockOrientation(orientations: string | string[]): boolean;
|
||||
msUnlockOrientation(): void;
|
||||
addEventListener(type: "MSOrientationChange", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
@@ -15399,8 +15395,7 @@ interface SourceBuffer extends EventTarget {
|
||||
updating: boolean;
|
||||
videoTracks: VideoTrackList;
|
||||
abort(): void;
|
||||
appendBuffer(data: ArrayBuffer): void;
|
||||
appendBuffer(data: ArrayBufferView): void;
|
||||
appendBuffer(data: ArrayBuffer | ArrayBufferView): void;
|
||||
appendStream(stream: MSStream, maxSize?: number): void;
|
||||
remove(start: number, end: number): void;
|
||||
}
|
||||
@@ -15508,33 +15503,18 @@ declare var StyleSheetPageList: {
|
||||
}
|
||||
|
||||
interface SubtleCrypto {
|
||||
decrypt(algorithm: string, key: CryptoKey, data: ArrayBufferView): any;
|
||||
decrypt(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any;
|
||||
deriveBits(algorithm: string, baseKey: CryptoKey, length: number): any;
|
||||
deriveBits(algorithm: Algorithm, baseKey: CryptoKey, length: number): any;
|
||||
deriveKey(algorithm: string, baseKey: CryptoKey, derivedKeyType: string, extractable: boolean, keyUsages: string[]): any;
|
||||
deriveKey(algorithm: string, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: string, extractable: boolean, keyUsages: string[]): any;
|
||||
deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
digest(algorithm: string, data: ArrayBufferView): any;
|
||||
digest(algorithm: Algorithm, data: ArrayBufferView): any;
|
||||
encrypt(algorithm: string, key: CryptoKey, data: ArrayBufferView): any;
|
||||
encrypt(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any;
|
||||
decrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any;
|
||||
deriveBits(algorithm: string | Algorithm, baseKey: CryptoKey, length: number): any;
|
||||
deriveKey(algorithm: string | Algorithm, baseKey: CryptoKey, derivedKeyType: string | Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
digest(algorithm: string | Algorithm, data: ArrayBufferView): any;
|
||||
encrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any;
|
||||
exportKey(format: string, key: CryptoKey): any;
|
||||
generateKey(algorithm: string, extractable: boolean, keyUsages: string[]): any;
|
||||
generateKey(algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
importKey(format: string, keyData: ArrayBufferView, algorithm: string, extractable: boolean, keyUsages: string[]): any;
|
||||
importKey(format: string, keyData: ArrayBufferView, algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
sign(algorithm: string, key: CryptoKey, data: ArrayBufferView): any;
|
||||
sign(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any;
|
||||
unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any;
|
||||
unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any;
|
||||
unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
verify(algorithm: string, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any;
|
||||
verify(algorithm: Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any;
|
||||
wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string): any;
|
||||
wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: Algorithm): any;
|
||||
generateKey(algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
importKey(format: string, keyData: ArrayBufferView, algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
sign(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any;
|
||||
unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | Algorithm, unwrappedKeyAlgorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any;
|
||||
verify(algorithm: string | Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any;
|
||||
wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | Algorithm): any;
|
||||
}
|
||||
|
||||
declare var SubtleCrypto: {
|
||||
@@ -16043,11 +16023,8 @@ interface WebGLRenderingContext {
|
||||
blendEquationSeparate(modeRGB: number, modeAlpha: number): void;
|
||||
blendFunc(sfactor: number, dfactor: number): void;
|
||||
blendFuncSeparate(srcRGB: number, dstRGB: number, srcAlpha: number, dstAlpha: number): void;
|
||||
bufferData(target: number, size: number, usage: number): void;
|
||||
bufferData(target: number, size: ArrayBufferView, usage: number): void;
|
||||
bufferData(target: number, size: any, usage: number): void;
|
||||
bufferSubData(target: number, offset: number, data: ArrayBufferView): void;
|
||||
bufferSubData(target: number, offset: number, data: any): void;
|
||||
bufferData(target: number, size: number | ArrayBufferView | ArrayBuffer, usage: number): void;
|
||||
bufferSubData(target: number, offset: number, data: ArrayBufferView | ArrayBuffer): void;
|
||||
checkFramebufferStatus(target: number): number;
|
||||
clear(mask: number): void;
|
||||
clearColor(red: number, green: number, blue: number, alpha: number): void;
|
||||
@@ -16890,8 +16867,7 @@ interface WebSocket extends EventTarget {
|
||||
|
||||
declare var WebSocket: {
|
||||
prototype: WebSocket;
|
||||
new(url: string, protocols?: string): WebSocket;
|
||||
new(url: string, protocols?: any): WebSocket;
|
||||
new(url: string, protocols?: string | string[]): WebSocket;
|
||||
CLOSED: number;
|
||||
CLOSING: number;
|
||||
CONNECTING: number;
|
||||
@@ -17057,6 +17033,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window
|
||||
toolbar: BarProp;
|
||||
top: Window;
|
||||
window: Window;
|
||||
URL: URL;
|
||||
alert(message?: any): void;
|
||||
blur(): void;
|
||||
cancelAnimationFrame(handle: number): void;
|
||||
@@ -17560,7 +17537,7 @@ interface NavigatorStorageUtils {
|
||||
|
||||
interface NodeSelector {
|
||||
querySelector(selectors: string): Element;
|
||||
querySelectorAll(selectors: string): NodeList;
|
||||
querySelectorAll(selectors: string): NodeListOf<Element>;
|
||||
}
|
||||
|
||||
interface RandomSource {
|
||||
@@ -17608,7 +17585,7 @@ interface SVGLocatable {
|
||||
}
|
||||
|
||||
interface SVGStylable {
|
||||
className: SVGAnimatedString;
|
||||
className: any;
|
||||
style: CSSStyleDeclaration;
|
||||
}
|
||||
|
||||
@@ -17695,8 +17672,7 @@ interface EventListenerObject {
|
||||
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
|
||||
|
||||
interface ErrorEventHandler {
|
||||
(event: Event, source?: string, fileno?: number, columnNumber?: number): void;
|
||||
(event: string, source?: string, fileno?: number, columnNumber?: number): void;
|
||||
(message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void;
|
||||
}
|
||||
interface PositionCallback {
|
||||
(position: Position): void;
|
||||
@@ -17872,6 +17848,7 @@ declare var styleMedia: StyleMedia;
|
||||
declare var toolbar: BarProp;
|
||||
declare var top: Window;
|
||||
declare var window: Window;
|
||||
declare var URL: URL;
|
||||
declare function alert(message?: any): void;
|
||||
declare function blur(): void;
|
||||
declare function cancelAnimationFrame(handle: number): void;
|
||||
@@ -18023,8 +18000,7 @@ declare function addEventListener(type: "unload", listener: (ev: Event) => any,
|
||||
declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
interface DOMTokenList {
|
||||
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;interface DOMTokenList {
|
||||
[Symbol.iterator](): IterableIterator<string>;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+2
-4
@@ -3064,8 +3064,7 @@ interface WebSocket extends EventTarget {
|
||||
|
||||
declare var WebSocket: {
|
||||
prototype: WebSocket;
|
||||
new(url: string, protocols?: string): WebSocket;
|
||||
new(url: string, protocols?: any): WebSocket;
|
||||
new(url: string, protocols?: string | string[]): WebSocket;
|
||||
CLOSED: number;
|
||||
CLOSING: number;
|
||||
CONNECTING: number;
|
||||
@@ -3300,8 +3299,7 @@ interface EventListenerObject {
|
||||
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
|
||||
|
||||
interface ErrorEventHandler {
|
||||
(event: Event, source?: string, fileno?: number, columnNumber?: number): void;
|
||||
(event: string, source?: string, fileno?: number, columnNumber?: number): void;
|
||||
(event: Event | string, source?: string, fileno?: number, columnNumber?: number): void;
|
||||
}
|
||||
interface PositionCallback {
|
||||
(position: Position): void;
|
||||
|
||||
+5849
-3900
File diff suppressed because it is too large
Load Diff
+8028
-5324
File diff suppressed because it is too large
Load Diff
Vendored
+381
-287
@@ -54,250 +54,265 @@ declare module "typescript" {
|
||||
SemicolonToken = 22,
|
||||
CommaToken = 23,
|
||||
LessThanToken = 24,
|
||||
GreaterThanToken = 25,
|
||||
LessThanEqualsToken = 26,
|
||||
GreaterThanEqualsToken = 27,
|
||||
EqualsEqualsToken = 28,
|
||||
ExclamationEqualsToken = 29,
|
||||
EqualsEqualsEqualsToken = 30,
|
||||
ExclamationEqualsEqualsToken = 31,
|
||||
EqualsGreaterThanToken = 32,
|
||||
PlusToken = 33,
|
||||
MinusToken = 34,
|
||||
AsteriskToken = 35,
|
||||
SlashToken = 36,
|
||||
PercentToken = 37,
|
||||
PlusPlusToken = 38,
|
||||
MinusMinusToken = 39,
|
||||
LessThanLessThanToken = 40,
|
||||
GreaterThanGreaterThanToken = 41,
|
||||
GreaterThanGreaterThanGreaterThanToken = 42,
|
||||
AmpersandToken = 43,
|
||||
BarToken = 44,
|
||||
CaretToken = 45,
|
||||
ExclamationToken = 46,
|
||||
TildeToken = 47,
|
||||
AmpersandAmpersandToken = 48,
|
||||
BarBarToken = 49,
|
||||
QuestionToken = 50,
|
||||
ColonToken = 51,
|
||||
AtToken = 52,
|
||||
EqualsToken = 53,
|
||||
PlusEqualsToken = 54,
|
||||
MinusEqualsToken = 55,
|
||||
AsteriskEqualsToken = 56,
|
||||
SlashEqualsToken = 57,
|
||||
PercentEqualsToken = 58,
|
||||
LessThanLessThanEqualsToken = 59,
|
||||
GreaterThanGreaterThanEqualsToken = 60,
|
||||
GreaterThanGreaterThanGreaterThanEqualsToken = 61,
|
||||
AmpersandEqualsToken = 62,
|
||||
BarEqualsToken = 63,
|
||||
CaretEqualsToken = 64,
|
||||
Identifier = 65,
|
||||
BreakKeyword = 66,
|
||||
CaseKeyword = 67,
|
||||
CatchKeyword = 68,
|
||||
ClassKeyword = 69,
|
||||
ConstKeyword = 70,
|
||||
ContinueKeyword = 71,
|
||||
DebuggerKeyword = 72,
|
||||
DefaultKeyword = 73,
|
||||
DeleteKeyword = 74,
|
||||
DoKeyword = 75,
|
||||
ElseKeyword = 76,
|
||||
EnumKeyword = 77,
|
||||
ExportKeyword = 78,
|
||||
ExtendsKeyword = 79,
|
||||
FalseKeyword = 80,
|
||||
FinallyKeyword = 81,
|
||||
ForKeyword = 82,
|
||||
FunctionKeyword = 83,
|
||||
IfKeyword = 84,
|
||||
ImportKeyword = 85,
|
||||
InKeyword = 86,
|
||||
InstanceOfKeyword = 87,
|
||||
NewKeyword = 88,
|
||||
NullKeyword = 89,
|
||||
ReturnKeyword = 90,
|
||||
SuperKeyword = 91,
|
||||
SwitchKeyword = 92,
|
||||
ThisKeyword = 93,
|
||||
ThrowKeyword = 94,
|
||||
TrueKeyword = 95,
|
||||
TryKeyword = 96,
|
||||
TypeOfKeyword = 97,
|
||||
VarKeyword = 98,
|
||||
VoidKeyword = 99,
|
||||
WhileKeyword = 100,
|
||||
WithKeyword = 101,
|
||||
ImplementsKeyword = 102,
|
||||
InterfaceKeyword = 103,
|
||||
LetKeyword = 104,
|
||||
PackageKeyword = 105,
|
||||
PrivateKeyword = 106,
|
||||
ProtectedKeyword = 107,
|
||||
PublicKeyword = 108,
|
||||
StaticKeyword = 109,
|
||||
YieldKeyword = 110,
|
||||
AsKeyword = 111,
|
||||
AnyKeyword = 112,
|
||||
BooleanKeyword = 113,
|
||||
ConstructorKeyword = 114,
|
||||
DeclareKeyword = 115,
|
||||
GetKeyword = 116,
|
||||
IsKeyword = 117,
|
||||
ModuleKeyword = 118,
|
||||
NamespaceKeyword = 119,
|
||||
RequireKeyword = 120,
|
||||
NumberKeyword = 121,
|
||||
SetKeyword = 122,
|
||||
StringKeyword = 123,
|
||||
SymbolKeyword = 124,
|
||||
TypeKeyword = 125,
|
||||
FromKeyword = 126,
|
||||
OfKeyword = 127,
|
||||
QualifiedName = 128,
|
||||
ComputedPropertyName = 129,
|
||||
TypeParameter = 130,
|
||||
Parameter = 131,
|
||||
Decorator = 132,
|
||||
PropertySignature = 133,
|
||||
PropertyDeclaration = 134,
|
||||
MethodSignature = 135,
|
||||
MethodDeclaration = 136,
|
||||
Constructor = 137,
|
||||
GetAccessor = 138,
|
||||
SetAccessor = 139,
|
||||
CallSignature = 140,
|
||||
ConstructSignature = 141,
|
||||
IndexSignature = 142,
|
||||
TypePredicate = 143,
|
||||
TypeReference = 144,
|
||||
FunctionType = 145,
|
||||
ConstructorType = 146,
|
||||
TypeQuery = 147,
|
||||
TypeLiteral = 148,
|
||||
ArrayType = 149,
|
||||
TupleType = 150,
|
||||
UnionType = 151,
|
||||
ParenthesizedType = 152,
|
||||
ObjectBindingPattern = 153,
|
||||
ArrayBindingPattern = 154,
|
||||
BindingElement = 155,
|
||||
ArrayLiteralExpression = 156,
|
||||
ObjectLiteralExpression = 157,
|
||||
PropertyAccessExpression = 158,
|
||||
ElementAccessExpression = 159,
|
||||
CallExpression = 160,
|
||||
NewExpression = 161,
|
||||
TaggedTemplateExpression = 162,
|
||||
TypeAssertionExpression = 163,
|
||||
ParenthesizedExpression = 164,
|
||||
FunctionExpression = 165,
|
||||
ArrowFunction = 166,
|
||||
DeleteExpression = 167,
|
||||
TypeOfExpression = 168,
|
||||
VoidExpression = 169,
|
||||
PrefixUnaryExpression = 170,
|
||||
PostfixUnaryExpression = 171,
|
||||
BinaryExpression = 172,
|
||||
ConditionalExpression = 173,
|
||||
TemplateExpression = 174,
|
||||
YieldExpression = 175,
|
||||
SpreadElementExpression = 176,
|
||||
ClassExpression = 177,
|
||||
OmittedExpression = 178,
|
||||
ExpressionWithTypeArguments = 179,
|
||||
TemplateSpan = 180,
|
||||
SemicolonClassElement = 181,
|
||||
Block = 182,
|
||||
VariableStatement = 183,
|
||||
EmptyStatement = 184,
|
||||
ExpressionStatement = 185,
|
||||
IfStatement = 186,
|
||||
DoStatement = 187,
|
||||
WhileStatement = 188,
|
||||
ForStatement = 189,
|
||||
ForInStatement = 190,
|
||||
ForOfStatement = 191,
|
||||
ContinueStatement = 192,
|
||||
BreakStatement = 193,
|
||||
ReturnStatement = 194,
|
||||
WithStatement = 195,
|
||||
SwitchStatement = 196,
|
||||
LabeledStatement = 197,
|
||||
ThrowStatement = 198,
|
||||
TryStatement = 199,
|
||||
DebuggerStatement = 200,
|
||||
VariableDeclaration = 201,
|
||||
VariableDeclarationList = 202,
|
||||
FunctionDeclaration = 203,
|
||||
ClassDeclaration = 204,
|
||||
InterfaceDeclaration = 205,
|
||||
TypeAliasDeclaration = 206,
|
||||
EnumDeclaration = 207,
|
||||
ModuleDeclaration = 208,
|
||||
ModuleBlock = 209,
|
||||
CaseBlock = 210,
|
||||
ImportEqualsDeclaration = 211,
|
||||
ImportDeclaration = 212,
|
||||
ImportClause = 213,
|
||||
NamespaceImport = 214,
|
||||
NamedImports = 215,
|
||||
ImportSpecifier = 216,
|
||||
ExportAssignment = 217,
|
||||
ExportDeclaration = 218,
|
||||
NamedExports = 219,
|
||||
ExportSpecifier = 220,
|
||||
MissingDeclaration = 221,
|
||||
ExternalModuleReference = 222,
|
||||
CaseClause = 223,
|
||||
DefaultClause = 224,
|
||||
HeritageClause = 225,
|
||||
CatchClause = 226,
|
||||
PropertyAssignment = 227,
|
||||
ShorthandPropertyAssignment = 228,
|
||||
EnumMember = 229,
|
||||
SourceFile = 230,
|
||||
JSDocTypeExpression = 231,
|
||||
JSDocAllType = 232,
|
||||
JSDocUnknownType = 233,
|
||||
JSDocArrayType = 234,
|
||||
JSDocUnionType = 235,
|
||||
JSDocTupleType = 236,
|
||||
JSDocNullableType = 237,
|
||||
JSDocNonNullableType = 238,
|
||||
JSDocRecordType = 239,
|
||||
JSDocRecordMember = 240,
|
||||
JSDocTypeReference = 241,
|
||||
JSDocOptionalType = 242,
|
||||
JSDocFunctionType = 243,
|
||||
JSDocVariadicType = 244,
|
||||
JSDocConstructorType = 245,
|
||||
JSDocThisType = 246,
|
||||
JSDocComment = 247,
|
||||
JSDocTag = 248,
|
||||
JSDocParameterTag = 249,
|
||||
JSDocReturnTag = 250,
|
||||
JSDocTypeTag = 251,
|
||||
JSDocTemplateTag = 252,
|
||||
SyntaxList = 253,
|
||||
Count = 254,
|
||||
FirstAssignment = 53,
|
||||
LastAssignment = 64,
|
||||
FirstReservedWord = 66,
|
||||
LastReservedWord = 101,
|
||||
FirstKeyword = 66,
|
||||
LastKeyword = 127,
|
||||
FirstFutureReservedWord = 102,
|
||||
LastFutureReservedWord = 110,
|
||||
FirstTypeNode = 144,
|
||||
LastTypeNode = 152,
|
||||
LessThanSlashToken = 25,
|
||||
GreaterThanToken = 26,
|
||||
LessThanEqualsToken = 27,
|
||||
GreaterThanEqualsToken = 28,
|
||||
EqualsEqualsToken = 29,
|
||||
ExclamationEqualsToken = 30,
|
||||
EqualsEqualsEqualsToken = 31,
|
||||
ExclamationEqualsEqualsToken = 32,
|
||||
EqualsGreaterThanToken = 33,
|
||||
PlusToken = 34,
|
||||
MinusToken = 35,
|
||||
AsteriskToken = 36,
|
||||
SlashToken = 37,
|
||||
PercentToken = 38,
|
||||
PlusPlusToken = 39,
|
||||
MinusMinusToken = 40,
|
||||
LessThanLessThanToken = 41,
|
||||
GreaterThanGreaterThanToken = 42,
|
||||
GreaterThanGreaterThanGreaterThanToken = 43,
|
||||
AmpersandToken = 44,
|
||||
BarToken = 45,
|
||||
CaretToken = 46,
|
||||
ExclamationToken = 47,
|
||||
TildeToken = 48,
|
||||
AmpersandAmpersandToken = 49,
|
||||
BarBarToken = 50,
|
||||
QuestionToken = 51,
|
||||
ColonToken = 52,
|
||||
AtToken = 53,
|
||||
EqualsToken = 54,
|
||||
PlusEqualsToken = 55,
|
||||
MinusEqualsToken = 56,
|
||||
AsteriskEqualsToken = 57,
|
||||
SlashEqualsToken = 58,
|
||||
PercentEqualsToken = 59,
|
||||
LessThanLessThanEqualsToken = 60,
|
||||
GreaterThanGreaterThanEqualsToken = 61,
|
||||
GreaterThanGreaterThanGreaterThanEqualsToken = 62,
|
||||
AmpersandEqualsToken = 63,
|
||||
BarEqualsToken = 64,
|
||||
CaretEqualsToken = 65,
|
||||
Identifier = 66,
|
||||
BreakKeyword = 67,
|
||||
CaseKeyword = 68,
|
||||
CatchKeyword = 69,
|
||||
ClassKeyword = 70,
|
||||
ConstKeyword = 71,
|
||||
ContinueKeyword = 72,
|
||||
DebuggerKeyword = 73,
|
||||
DefaultKeyword = 74,
|
||||
DeleteKeyword = 75,
|
||||
DoKeyword = 76,
|
||||
ElseKeyword = 77,
|
||||
EnumKeyword = 78,
|
||||
ExportKeyword = 79,
|
||||
ExtendsKeyword = 80,
|
||||
FalseKeyword = 81,
|
||||
FinallyKeyword = 82,
|
||||
ForKeyword = 83,
|
||||
FunctionKeyword = 84,
|
||||
IfKeyword = 85,
|
||||
ImportKeyword = 86,
|
||||
InKeyword = 87,
|
||||
InstanceOfKeyword = 88,
|
||||
NewKeyword = 89,
|
||||
NullKeyword = 90,
|
||||
ReturnKeyword = 91,
|
||||
SuperKeyword = 92,
|
||||
SwitchKeyword = 93,
|
||||
ThisKeyword = 94,
|
||||
ThrowKeyword = 95,
|
||||
TrueKeyword = 96,
|
||||
TryKeyword = 97,
|
||||
TypeOfKeyword = 98,
|
||||
VarKeyword = 99,
|
||||
VoidKeyword = 100,
|
||||
WhileKeyword = 101,
|
||||
WithKeyword = 102,
|
||||
ImplementsKeyword = 103,
|
||||
InterfaceKeyword = 104,
|
||||
LetKeyword = 105,
|
||||
PackageKeyword = 106,
|
||||
PrivateKeyword = 107,
|
||||
ProtectedKeyword = 108,
|
||||
PublicKeyword = 109,
|
||||
StaticKeyword = 110,
|
||||
YieldKeyword = 111,
|
||||
AbstractKeyword = 112,
|
||||
AsKeyword = 113,
|
||||
AnyKeyword = 114,
|
||||
AsyncKeyword = 115,
|
||||
AwaitKeyword = 116,
|
||||
BooleanKeyword = 117,
|
||||
ConstructorKeyword = 118,
|
||||
DeclareKeyword = 119,
|
||||
GetKeyword = 120,
|
||||
IsKeyword = 121,
|
||||
ModuleKeyword = 122,
|
||||
NamespaceKeyword = 123,
|
||||
RequireKeyword = 124,
|
||||
NumberKeyword = 125,
|
||||
SetKeyword = 126,
|
||||
StringKeyword = 127,
|
||||
SymbolKeyword = 128,
|
||||
TypeKeyword = 129,
|
||||
FromKeyword = 130,
|
||||
OfKeyword = 131,
|
||||
QualifiedName = 132,
|
||||
ComputedPropertyName = 133,
|
||||
TypeParameter = 134,
|
||||
Parameter = 135,
|
||||
Decorator = 136,
|
||||
PropertySignature = 137,
|
||||
PropertyDeclaration = 138,
|
||||
MethodSignature = 139,
|
||||
MethodDeclaration = 140,
|
||||
Constructor = 141,
|
||||
GetAccessor = 142,
|
||||
SetAccessor = 143,
|
||||
CallSignature = 144,
|
||||
ConstructSignature = 145,
|
||||
IndexSignature = 146,
|
||||
TypePredicate = 147,
|
||||
TypeReference = 148,
|
||||
FunctionType = 149,
|
||||
ConstructorType = 150,
|
||||
TypeQuery = 151,
|
||||
TypeLiteral = 152,
|
||||
ArrayType = 153,
|
||||
TupleType = 154,
|
||||
UnionType = 155,
|
||||
IntersectionType = 156,
|
||||
ParenthesizedType = 157,
|
||||
ObjectBindingPattern = 158,
|
||||
ArrayBindingPattern = 159,
|
||||
BindingElement = 160,
|
||||
ArrayLiteralExpression = 161,
|
||||
ObjectLiteralExpression = 162,
|
||||
PropertyAccessExpression = 163,
|
||||
ElementAccessExpression = 164,
|
||||
CallExpression = 165,
|
||||
NewExpression = 166,
|
||||
TaggedTemplateExpression = 167,
|
||||
TypeAssertionExpression = 168,
|
||||
ParenthesizedExpression = 169,
|
||||
FunctionExpression = 170,
|
||||
ArrowFunction = 171,
|
||||
DeleteExpression = 172,
|
||||
TypeOfExpression = 173,
|
||||
VoidExpression = 174,
|
||||
AwaitExpression = 175,
|
||||
PrefixUnaryExpression = 176,
|
||||
PostfixUnaryExpression = 177,
|
||||
BinaryExpression = 178,
|
||||
ConditionalExpression = 179,
|
||||
TemplateExpression = 180,
|
||||
YieldExpression = 181,
|
||||
SpreadElementExpression = 182,
|
||||
ClassExpression = 183,
|
||||
OmittedExpression = 184,
|
||||
ExpressionWithTypeArguments = 185,
|
||||
AsExpression = 186,
|
||||
TemplateSpan = 187,
|
||||
SemicolonClassElement = 188,
|
||||
Block = 189,
|
||||
VariableStatement = 190,
|
||||
EmptyStatement = 191,
|
||||
ExpressionStatement = 192,
|
||||
IfStatement = 193,
|
||||
DoStatement = 194,
|
||||
WhileStatement = 195,
|
||||
ForStatement = 196,
|
||||
ForInStatement = 197,
|
||||
ForOfStatement = 198,
|
||||
ContinueStatement = 199,
|
||||
BreakStatement = 200,
|
||||
ReturnStatement = 201,
|
||||
WithStatement = 202,
|
||||
SwitchStatement = 203,
|
||||
LabeledStatement = 204,
|
||||
ThrowStatement = 205,
|
||||
TryStatement = 206,
|
||||
DebuggerStatement = 207,
|
||||
VariableDeclaration = 208,
|
||||
VariableDeclarationList = 209,
|
||||
FunctionDeclaration = 210,
|
||||
ClassDeclaration = 211,
|
||||
InterfaceDeclaration = 212,
|
||||
TypeAliasDeclaration = 213,
|
||||
EnumDeclaration = 214,
|
||||
ModuleDeclaration = 215,
|
||||
ModuleBlock = 216,
|
||||
CaseBlock = 217,
|
||||
ImportEqualsDeclaration = 218,
|
||||
ImportDeclaration = 219,
|
||||
ImportClause = 220,
|
||||
NamespaceImport = 221,
|
||||
NamedImports = 222,
|
||||
ImportSpecifier = 223,
|
||||
ExportAssignment = 224,
|
||||
ExportDeclaration = 225,
|
||||
NamedExports = 226,
|
||||
ExportSpecifier = 227,
|
||||
MissingDeclaration = 228,
|
||||
ExternalModuleReference = 229,
|
||||
JsxElement = 230,
|
||||
JsxSelfClosingElement = 231,
|
||||
JsxOpeningElement = 232,
|
||||
JsxText = 233,
|
||||
JsxClosingElement = 234,
|
||||
JsxAttribute = 235,
|
||||
JsxSpreadAttribute = 236,
|
||||
JsxExpression = 237,
|
||||
CaseClause = 238,
|
||||
DefaultClause = 239,
|
||||
HeritageClause = 240,
|
||||
CatchClause = 241,
|
||||
PropertyAssignment = 242,
|
||||
ShorthandPropertyAssignment = 243,
|
||||
EnumMember = 244,
|
||||
SourceFile = 245,
|
||||
JSDocTypeExpression = 246,
|
||||
JSDocAllType = 247,
|
||||
JSDocUnknownType = 248,
|
||||
JSDocArrayType = 249,
|
||||
JSDocUnionType = 250,
|
||||
JSDocTupleType = 251,
|
||||
JSDocNullableType = 252,
|
||||
JSDocNonNullableType = 253,
|
||||
JSDocRecordType = 254,
|
||||
JSDocRecordMember = 255,
|
||||
JSDocTypeReference = 256,
|
||||
JSDocOptionalType = 257,
|
||||
JSDocFunctionType = 258,
|
||||
JSDocVariadicType = 259,
|
||||
JSDocConstructorType = 260,
|
||||
JSDocThisType = 261,
|
||||
JSDocComment = 262,
|
||||
JSDocTag = 263,
|
||||
JSDocParameterTag = 264,
|
||||
JSDocReturnTag = 265,
|
||||
JSDocTypeTag = 266,
|
||||
JSDocTemplateTag = 267,
|
||||
SyntaxList = 268,
|
||||
Count = 269,
|
||||
FirstAssignment = 54,
|
||||
LastAssignment = 65,
|
||||
FirstReservedWord = 67,
|
||||
LastReservedWord = 102,
|
||||
FirstKeyword = 67,
|
||||
LastKeyword = 131,
|
||||
FirstFutureReservedWord = 103,
|
||||
LastFutureReservedWord = 111,
|
||||
FirstTypeNode = 148,
|
||||
LastTypeNode = 157,
|
||||
FirstPunctuation = 14,
|
||||
LastPunctuation = 64,
|
||||
LastPunctuation = 65,
|
||||
FirstToken = 0,
|
||||
LastToken = 127,
|
||||
LastToken = 131,
|
||||
FirstTriviaToken = 2,
|
||||
LastTriviaToken = 6,
|
||||
FirstLiteralToken = 7,
|
||||
@@ -305,8 +320,8 @@ declare module "typescript" {
|
||||
FirstTemplateToken = 10,
|
||||
LastTemplateToken = 13,
|
||||
FirstBinaryOperator = 24,
|
||||
LastBinaryOperator = 64,
|
||||
FirstNode = 128,
|
||||
LastBinaryOperator = 65,
|
||||
FirstNode = 132,
|
||||
}
|
||||
const enum NodeFlags {
|
||||
Export = 1,
|
||||
@@ -315,18 +330,28 @@ declare module "typescript" {
|
||||
Private = 32,
|
||||
Protected = 64,
|
||||
Static = 128,
|
||||
Default = 256,
|
||||
MultiLine = 512,
|
||||
Synthetic = 1024,
|
||||
DeclarationFile = 2048,
|
||||
Let = 4096,
|
||||
Const = 8192,
|
||||
OctalLiteral = 16384,
|
||||
Namespace = 32768,
|
||||
ExportContext = 65536,
|
||||
Modifier = 499,
|
||||
Abstract = 256,
|
||||
Async = 512,
|
||||
Default = 1024,
|
||||
MultiLine = 2048,
|
||||
Synthetic = 4096,
|
||||
DeclarationFile = 8192,
|
||||
Let = 16384,
|
||||
Const = 32768,
|
||||
OctalLiteral = 65536,
|
||||
Namespace = 131072,
|
||||
ExportContext = 262144,
|
||||
Modifier = 2035,
|
||||
AccessibilityModifier = 112,
|
||||
BlockScoped = 12288,
|
||||
BlockScoped = 49152,
|
||||
}
|
||||
const enum JsxFlags {
|
||||
None = 0,
|
||||
IntrinsicNamedElement = 1,
|
||||
IntrinsicIndexedElement = 2,
|
||||
ClassElement = 4,
|
||||
UnknownElement = 8,
|
||||
IntrinsicElement = 3,
|
||||
}
|
||||
interface Node extends TextRange {
|
||||
kind: SyntaxKind;
|
||||
@@ -483,9 +508,13 @@ declare module "typescript" {
|
||||
interface TupleTypeNode extends TypeNode {
|
||||
elementTypes: NodeArray<TypeNode>;
|
||||
}
|
||||
interface UnionTypeNode extends TypeNode {
|
||||
interface UnionOrIntersectionTypeNode extends TypeNode {
|
||||
types: NodeArray<TypeNode>;
|
||||
}
|
||||
interface UnionTypeNode extends UnionOrIntersectionTypeNode {
|
||||
}
|
||||
interface IntersectionTypeNode extends UnionOrIntersectionTypeNode {
|
||||
}
|
||||
interface ParenthesizedTypeNode extends TypeNode {
|
||||
type: TypeNode;
|
||||
}
|
||||
@@ -528,6 +557,9 @@ declare module "typescript" {
|
||||
interface VoidExpression extends UnaryExpression {
|
||||
expression: UnaryExpression;
|
||||
}
|
||||
interface AwaitExpression extends UnaryExpression {
|
||||
expression: UnaryExpression;
|
||||
}
|
||||
interface YieldExpression extends Expression {
|
||||
asteriskToken?: Node;
|
||||
expression?: Expression;
|
||||
@@ -601,10 +633,46 @@ declare module "typescript" {
|
||||
template: LiteralExpression | TemplateExpression;
|
||||
}
|
||||
type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator;
|
||||
interface AsExpression extends Expression {
|
||||
expression: Expression;
|
||||
type: TypeNode;
|
||||
}
|
||||
interface TypeAssertion extends UnaryExpression {
|
||||
type: TypeNode;
|
||||
expression: UnaryExpression;
|
||||
}
|
||||
type AssertionExpression = TypeAssertion | AsExpression;
|
||||
interface JsxElement extends PrimaryExpression {
|
||||
openingElement: JsxOpeningElement;
|
||||
children: NodeArray<JsxChild>;
|
||||
closingElement: JsxClosingElement;
|
||||
}
|
||||
interface JsxOpeningElement extends Expression {
|
||||
_openingElementBrand?: any;
|
||||
tagName: EntityName;
|
||||
attributes: NodeArray<JsxAttribute | JsxSpreadAttribute>;
|
||||
}
|
||||
interface JsxSelfClosingElement extends PrimaryExpression, JsxOpeningElement {
|
||||
_selfClosingElementBrand?: any;
|
||||
}
|
||||
type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement;
|
||||
interface JsxAttribute extends Node {
|
||||
name: Identifier;
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface JsxSpreadAttribute extends Node {
|
||||
expression: Expression;
|
||||
}
|
||||
interface JsxClosingElement extends Node {
|
||||
tagName: EntityName;
|
||||
}
|
||||
interface JsxExpression extends Expression {
|
||||
expression?: Expression;
|
||||
}
|
||||
interface JsxText extends Node {
|
||||
_jsxTextExpressionBrand: any;
|
||||
}
|
||||
type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement;
|
||||
interface Statement extends Node {
|
||||
_statementBrand: any;
|
||||
}
|
||||
@@ -859,6 +927,7 @@ declare module "typescript" {
|
||||
}[];
|
||||
moduleName: string;
|
||||
referencedFiles: FileReference[];
|
||||
languageVariant: LanguageVariant;
|
||||
/**
|
||||
* lib.d.ts should have a reference comment like
|
||||
*
|
||||
@@ -881,6 +950,13 @@ declare module "typescript" {
|
||||
interface WriteFileCallback {
|
||||
(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
}
|
||||
class OperationCanceledException {
|
||||
}
|
||||
interface CancellationToken {
|
||||
isCancellationRequested(): boolean;
|
||||
/** @throws OperationCanceledException if isCancellationRequested is true */
|
||||
throwIfCancellationRequested(): void;
|
||||
}
|
||||
interface Program extends ScriptReferenceHost {
|
||||
/**
|
||||
* Get a list of files in the program
|
||||
@@ -896,12 +972,12 @@ declare module "typescript" {
|
||||
* used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the JavaScript and declaration files.
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
|
||||
getOptionsDiagnostics(): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult;
|
||||
getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
/**
|
||||
* Gets a type checker that can be used to semantically analyze source fils in the program.
|
||||
*/
|
||||
@@ -976,6 +1052,8 @@ declare module "typescript" {
|
||||
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
|
||||
getAliasedSymbol(symbol: Symbol): Symbol;
|
||||
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
|
||||
getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type;
|
||||
getJsxIntrinsicTagNames(): Symbol[];
|
||||
}
|
||||
interface SymbolDisplayBuilder {
|
||||
buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
@@ -1053,7 +1131,7 @@ declare module "typescript" {
|
||||
Merged = 33554432,
|
||||
Transient = 67108864,
|
||||
Prototype = 134217728,
|
||||
UnionProperty = 268435456,
|
||||
SyntheticProperty = 268435456,
|
||||
Optional = 536870912,
|
||||
ExportStar = 1073741824,
|
||||
Enum = 384,
|
||||
@@ -1069,8 +1147,8 @@ declare module "typescript" {
|
||||
PropertyExcludes = 107455,
|
||||
EnumMemberExcludes = 107455,
|
||||
FunctionExcludes = 106927,
|
||||
ClassExcludes = 899583,
|
||||
InterfaceExcludes = 792992,
|
||||
ClassExcludes = 899519,
|
||||
InterfaceExcludes = 792960,
|
||||
RegularEnumExcludes = 899327,
|
||||
ConstEnumExcludes = 899967,
|
||||
ValueModuleExcludes = 106639,
|
||||
@@ -1116,13 +1194,16 @@ declare module "typescript" {
|
||||
Reference = 4096,
|
||||
Tuple = 8192,
|
||||
Union = 16384,
|
||||
Anonymous = 32768,
|
||||
Instantiated = 65536,
|
||||
ObjectLiteral = 262144,
|
||||
ESSymbol = 2097152,
|
||||
Intersection = 32768,
|
||||
Anonymous = 65536,
|
||||
Instantiated = 131072,
|
||||
ObjectLiteral = 524288,
|
||||
ESSymbol = 4194304,
|
||||
StringLike = 258,
|
||||
NumberLike = 132,
|
||||
ObjectType = 48128,
|
||||
ObjectType = 80896,
|
||||
UnionOrIntersection = 49152,
|
||||
StructuredType = 130048,
|
||||
}
|
||||
interface Type {
|
||||
flags: TypeFlags;
|
||||
@@ -1157,9 +1238,13 @@ declare module "typescript" {
|
||||
elementTypes: Type[];
|
||||
baseArrayType: TypeReference;
|
||||
}
|
||||
interface UnionType extends Type {
|
||||
interface UnionOrIntersectionType extends Type {
|
||||
types: Type[];
|
||||
}
|
||||
interface UnionType extends UnionOrIntersectionType {
|
||||
}
|
||||
interface IntersectionType extends UnionOrIntersectionType {
|
||||
}
|
||||
interface TypeParameter extends Type {
|
||||
constraint: Type;
|
||||
}
|
||||
@@ -1216,6 +1301,7 @@ declare module "typescript" {
|
||||
help?: boolean;
|
||||
inlineSourceMap?: boolean;
|
||||
inlineSources?: boolean;
|
||||
jsx?: JsxEmit;
|
||||
listFiles?: boolean;
|
||||
locale?: string;
|
||||
mapRoot?: string;
|
||||
@@ -1242,6 +1328,7 @@ declare module "typescript" {
|
||||
watch?: boolean;
|
||||
isolatedModules?: boolean;
|
||||
experimentalDecorators?: boolean;
|
||||
experimentalAsyncFunctions?: boolean;
|
||||
emitDecoratorMetadata?: boolean;
|
||||
[option: string]: string | number | boolean;
|
||||
}
|
||||
@@ -1252,6 +1339,11 @@ declare module "typescript" {
|
||||
UMD = 3,
|
||||
System = 4,
|
||||
}
|
||||
const enum JsxEmit {
|
||||
None = 0,
|
||||
Preserve = 1,
|
||||
React = 2,
|
||||
}
|
||||
const enum NewLineKind {
|
||||
CarriageReturnLineFeed = 0,
|
||||
LineFeed = 1,
|
||||
@@ -1266,18 +1358,18 @@ declare module "typescript" {
|
||||
ES6 = 2,
|
||||
Latest = 2,
|
||||
}
|
||||
const enum LanguageVariant {
|
||||
Standard = 0,
|
||||
JSX = 1,
|
||||
}
|
||||
interface ParsedCommandLine {
|
||||
options: CompilerOptions;
|
||||
fileNames: string[];
|
||||
errors: Diagnostic[];
|
||||
}
|
||||
interface CancellationToken {
|
||||
isCancellationRequested(): boolean;
|
||||
}
|
||||
interface CompilerHost {
|
||||
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
getCancellationToken?(): CancellationToken;
|
||||
writeFile: WriteFileCallback;
|
||||
getCurrentDirectory(): string;
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
@@ -1336,10 +1428,14 @@ declare module "typescript" {
|
||||
reScanGreaterToken(): SyntaxKind;
|
||||
reScanSlashToken(): SyntaxKind;
|
||||
reScanTemplateToken(): SyntaxKind;
|
||||
scanJsxIdentifier(): SyntaxKind;
|
||||
reScanJsxToken(): SyntaxKind;
|
||||
scanJsxToken(): SyntaxKind;
|
||||
scan(): SyntaxKind;
|
||||
setText(text: string, start?: number, length?: number): void;
|
||||
setOnError(onError: ErrorCallback): void;
|
||||
setScriptTarget(scriptTarget: ScriptTarget): void;
|
||||
setLanguageVariant(variant: LanguageVariant): void;
|
||||
setTextPos(textPos: number): void;
|
||||
lookAhead<T>(callback: () => T): T;
|
||||
tryScan<T>(callback: () => T): T;
|
||||
@@ -1397,7 +1493,7 @@ declare module "typescript" {
|
||||
const version: string;
|
||||
function findConfigFile(searchPath: string): string;
|
||||
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
|
||||
function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile): Diagnostic[];
|
||||
function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
|
||||
}
|
||||
@@ -1495,6 +1591,8 @@ declare module "typescript" {
|
||||
* not happen and the entire document will be re - parsed.
|
||||
*/
|
||||
getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange;
|
||||
/** Releases all resources held by this script snapshot */
|
||||
dispose?(): void;
|
||||
}
|
||||
module ScriptSnapshot {
|
||||
function fromString(text: string): IScriptSnapshot;
|
||||
@@ -1504,6 +1602,9 @@ declare module "typescript" {
|
||||
importedFiles: FileReference[];
|
||||
isLibFile: boolean;
|
||||
}
|
||||
interface HostCancellationToken {
|
||||
isCancellationRequested(): boolean;
|
||||
}
|
||||
interface LanguageServiceHost {
|
||||
getCompilationSettings(): CompilerOptions;
|
||||
getNewLine?(): string;
|
||||
@@ -1512,7 +1613,7 @@ declare module "typescript" {
|
||||
getScriptVersion(fileName: string): string;
|
||||
getScriptSnapshot(fileName: string): IScriptSnapshot;
|
||||
getLocalizedDiagnosticMessages?(): any;
|
||||
getCancellationToken?(): CancellationToken;
|
||||
getCancellationToken?(): HostCancellationToken;
|
||||
getCurrentDirectory(): string;
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
log?(s: string): void;
|
||||
@@ -1892,6 +1993,7 @@ declare module "typescript" {
|
||||
const scriptElement: string;
|
||||
const moduleElement: string;
|
||||
const classElement: string;
|
||||
const localClassElement: string;
|
||||
const interfaceElement: string;
|
||||
const typeElement: string;
|
||||
const enumElement: string;
|
||||
@@ -1923,6 +2025,7 @@ declare module "typescript" {
|
||||
const exportedModifier: string;
|
||||
const ambientModifier: string;
|
||||
const staticModifier: string;
|
||||
const abstractModifier: string;
|
||||
}
|
||||
class ClassificationTypeNames {
|
||||
static comment: string;
|
||||
@@ -1968,15 +2071,6 @@ declare module "typescript" {
|
||||
}
|
||||
function displayPartsToString(displayParts: SymbolDisplayPart[]): string;
|
||||
function getDefaultCompilerOptions(): CompilerOptions;
|
||||
class OperationCanceledException {
|
||||
}
|
||||
class CancellationTokenObject {
|
||||
private cancellationToken;
|
||||
static None: CancellationTokenObject;
|
||||
constructor(cancellationToken: CancellationToken);
|
||||
isCancellationRequested(): boolean;
|
||||
throwIfCancellationRequested(): void;
|
||||
}
|
||||
function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string;
|
||||
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
|
||||
let disableIncrementalParsing: boolean;
|
||||
@@ -1986,7 +2080,7 @@ declare module "typescript" {
|
||||
function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService;
|
||||
function createClassifier(): Classifier;
|
||||
/**
|
||||
* Get the path of the default library file (lib.d.ts) as distributed with the typescript
|
||||
* Get the path of the default library files (lib.d.ts) as distributed with the typescript
|
||||
* node package.
|
||||
* The functionality is not supported if the ts module is consumed outside of a node module.
|
||||
*/
|
||||
|
||||
+8587
-5870
File diff suppressed because it is too large
Load Diff
Vendored
+381
-287
@@ -54,250 +54,265 @@ declare namespace ts {
|
||||
SemicolonToken = 22,
|
||||
CommaToken = 23,
|
||||
LessThanToken = 24,
|
||||
GreaterThanToken = 25,
|
||||
LessThanEqualsToken = 26,
|
||||
GreaterThanEqualsToken = 27,
|
||||
EqualsEqualsToken = 28,
|
||||
ExclamationEqualsToken = 29,
|
||||
EqualsEqualsEqualsToken = 30,
|
||||
ExclamationEqualsEqualsToken = 31,
|
||||
EqualsGreaterThanToken = 32,
|
||||
PlusToken = 33,
|
||||
MinusToken = 34,
|
||||
AsteriskToken = 35,
|
||||
SlashToken = 36,
|
||||
PercentToken = 37,
|
||||
PlusPlusToken = 38,
|
||||
MinusMinusToken = 39,
|
||||
LessThanLessThanToken = 40,
|
||||
GreaterThanGreaterThanToken = 41,
|
||||
GreaterThanGreaterThanGreaterThanToken = 42,
|
||||
AmpersandToken = 43,
|
||||
BarToken = 44,
|
||||
CaretToken = 45,
|
||||
ExclamationToken = 46,
|
||||
TildeToken = 47,
|
||||
AmpersandAmpersandToken = 48,
|
||||
BarBarToken = 49,
|
||||
QuestionToken = 50,
|
||||
ColonToken = 51,
|
||||
AtToken = 52,
|
||||
EqualsToken = 53,
|
||||
PlusEqualsToken = 54,
|
||||
MinusEqualsToken = 55,
|
||||
AsteriskEqualsToken = 56,
|
||||
SlashEqualsToken = 57,
|
||||
PercentEqualsToken = 58,
|
||||
LessThanLessThanEqualsToken = 59,
|
||||
GreaterThanGreaterThanEqualsToken = 60,
|
||||
GreaterThanGreaterThanGreaterThanEqualsToken = 61,
|
||||
AmpersandEqualsToken = 62,
|
||||
BarEqualsToken = 63,
|
||||
CaretEqualsToken = 64,
|
||||
Identifier = 65,
|
||||
BreakKeyword = 66,
|
||||
CaseKeyword = 67,
|
||||
CatchKeyword = 68,
|
||||
ClassKeyword = 69,
|
||||
ConstKeyword = 70,
|
||||
ContinueKeyword = 71,
|
||||
DebuggerKeyword = 72,
|
||||
DefaultKeyword = 73,
|
||||
DeleteKeyword = 74,
|
||||
DoKeyword = 75,
|
||||
ElseKeyword = 76,
|
||||
EnumKeyword = 77,
|
||||
ExportKeyword = 78,
|
||||
ExtendsKeyword = 79,
|
||||
FalseKeyword = 80,
|
||||
FinallyKeyword = 81,
|
||||
ForKeyword = 82,
|
||||
FunctionKeyword = 83,
|
||||
IfKeyword = 84,
|
||||
ImportKeyword = 85,
|
||||
InKeyword = 86,
|
||||
InstanceOfKeyword = 87,
|
||||
NewKeyword = 88,
|
||||
NullKeyword = 89,
|
||||
ReturnKeyword = 90,
|
||||
SuperKeyword = 91,
|
||||
SwitchKeyword = 92,
|
||||
ThisKeyword = 93,
|
||||
ThrowKeyword = 94,
|
||||
TrueKeyword = 95,
|
||||
TryKeyword = 96,
|
||||
TypeOfKeyword = 97,
|
||||
VarKeyword = 98,
|
||||
VoidKeyword = 99,
|
||||
WhileKeyword = 100,
|
||||
WithKeyword = 101,
|
||||
ImplementsKeyword = 102,
|
||||
InterfaceKeyword = 103,
|
||||
LetKeyword = 104,
|
||||
PackageKeyword = 105,
|
||||
PrivateKeyword = 106,
|
||||
ProtectedKeyword = 107,
|
||||
PublicKeyword = 108,
|
||||
StaticKeyword = 109,
|
||||
YieldKeyword = 110,
|
||||
AsKeyword = 111,
|
||||
AnyKeyword = 112,
|
||||
BooleanKeyword = 113,
|
||||
ConstructorKeyword = 114,
|
||||
DeclareKeyword = 115,
|
||||
GetKeyword = 116,
|
||||
IsKeyword = 117,
|
||||
ModuleKeyword = 118,
|
||||
NamespaceKeyword = 119,
|
||||
RequireKeyword = 120,
|
||||
NumberKeyword = 121,
|
||||
SetKeyword = 122,
|
||||
StringKeyword = 123,
|
||||
SymbolKeyword = 124,
|
||||
TypeKeyword = 125,
|
||||
FromKeyword = 126,
|
||||
OfKeyword = 127,
|
||||
QualifiedName = 128,
|
||||
ComputedPropertyName = 129,
|
||||
TypeParameter = 130,
|
||||
Parameter = 131,
|
||||
Decorator = 132,
|
||||
PropertySignature = 133,
|
||||
PropertyDeclaration = 134,
|
||||
MethodSignature = 135,
|
||||
MethodDeclaration = 136,
|
||||
Constructor = 137,
|
||||
GetAccessor = 138,
|
||||
SetAccessor = 139,
|
||||
CallSignature = 140,
|
||||
ConstructSignature = 141,
|
||||
IndexSignature = 142,
|
||||
TypePredicate = 143,
|
||||
TypeReference = 144,
|
||||
FunctionType = 145,
|
||||
ConstructorType = 146,
|
||||
TypeQuery = 147,
|
||||
TypeLiteral = 148,
|
||||
ArrayType = 149,
|
||||
TupleType = 150,
|
||||
UnionType = 151,
|
||||
ParenthesizedType = 152,
|
||||
ObjectBindingPattern = 153,
|
||||
ArrayBindingPattern = 154,
|
||||
BindingElement = 155,
|
||||
ArrayLiteralExpression = 156,
|
||||
ObjectLiteralExpression = 157,
|
||||
PropertyAccessExpression = 158,
|
||||
ElementAccessExpression = 159,
|
||||
CallExpression = 160,
|
||||
NewExpression = 161,
|
||||
TaggedTemplateExpression = 162,
|
||||
TypeAssertionExpression = 163,
|
||||
ParenthesizedExpression = 164,
|
||||
FunctionExpression = 165,
|
||||
ArrowFunction = 166,
|
||||
DeleteExpression = 167,
|
||||
TypeOfExpression = 168,
|
||||
VoidExpression = 169,
|
||||
PrefixUnaryExpression = 170,
|
||||
PostfixUnaryExpression = 171,
|
||||
BinaryExpression = 172,
|
||||
ConditionalExpression = 173,
|
||||
TemplateExpression = 174,
|
||||
YieldExpression = 175,
|
||||
SpreadElementExpression = 176,
|
||||
ClassExpression = 177,
|
||||
OmittedExpression = 178,
|
||||
ExpressionWithTypeArguments = 179,
|
||||
TemplateSpan = 180,
|
||||
SemicolonClassElement = 181,
|
||||
Block = 182,
|
||||
VariableStatement = 183,
|
||||
EmptyStatement = 184,
|
||||
ExpressionStatement = 185,
|
||||
IfStatement = 186,
|
||||
DoStatement = 187,
|
||||
WhileStatement = 188,
|
||||
ForStatement = 189,
|
||||
ForInStatement = 190,
|
||||
ForOfStatement = 191,
|
||||
ContinueStatement = 192,
|
||||
BreakStatement = 193,
|
||||
ReturnStatement = 194,
|
||||
WithStatement = 195,
|
||||
SwitchStatement = 196,
|
||||
LabeledStatement = 197,
|
||||
ThrowStatement = 198,
|
||||
TryStatement = 199,
|
||||
DebuggerStatement = 200,
|
||||
VariableDeclaration = 201,
|
||||
VariableDeclarationList = 202,
|
||||
FunctionDeclaration = 203,
|
||||
ClassDeclaration = 204,
|
||||
InterfaceDeclaration = 205,
|
||||
TypeAliasDeclaration = 206,
|
||||
EnumDeclaration = 207,
|
||||
ModuleDeclaration = 208,
|
||||
ModuleBlock = 209,
|
||||
CaseBlock = 210,
|
||||
ImportEqualsDeclaration = 211,
|
||||
ImportDeclaration = 212,
|
||||
ImportClause = 213,
|
||||
NamespaceImport = 214,
|
||||
NamedImports = 215,
|
||||
ImportSpecifier = 216,
|
||||
ExportAssignment = 217,
|
||||
ExportDeclaration = 218,
|
||||
NamedExports = 219,
|
||||
ExportSpecifier = 220,
|
||||
MissingDeclaration = 221,
|
||||
ExternalModuleReference = 222,
|
||||
CaseClause = 223,
|
||||
DefaultClause = 224,
|
||||
HeritageClause = 225,
|
||||
CatchClause = 226,
|
||||
PropertyAssignment = 227,
|
||||
ShorthandPropertyAssignment = 228,
|
||||
EnumMember = 229,
|
||||
SourceFile = 230,
|
||||
JSDocTypeExpression = 231,
|
||||
JSDocAllType = 232,
|
||||
JSDocUnknownType = 233,
|
||||
JSDocArrayType = 234,
|
||||
JSDocUnionType = 235,
|
||||
JSDocTupleType = 236,
|
||||
JSDocNullableType = 237,
|
||||
JSDocNonNullableType = 238,
|
||||
JSDocRecordType = 239,
|
||||
JSDocRecordMember = 240,
|
||||
JSDocTypeReference = 241,
|
||||
JSDocOptionalType = 242,
|
||||
JSDocFunctionType = 243,
|
||||
JSDocVariadicType = 244,
|
||||
JSDocConstructorType = 245,
|
||||
JSDocThisType = 246,
|
||||
JSDocComment = 247,
|
||||
JSDocTag = 248,
|
||||
JSDocParameterTag = 249,
|
||||
JSDocReturnTag = 250,
|
||||
JSDocTypeTag = 251,
|
||||
JSDocTemplateTag = 252,
|
||||
SyntaxList = 253,
|
||||
Count = 254,
|
||||
FirstAssignment = 53,
|
||||
LastAssignment = 64,
|
||||
FirstReservedWord = 66,
|
||||
LastReservedWord = 101,
|
||||
FirstKeyword = 66,
|
||||
LastKeyword = 127,
|
||||
FirstFutureReservedWord = 102,
|
||||
LastFutureReservedWord = 110,
|
||||
FirstTypeNode = 144,
|
||||
LastTypeNode = 152,
|
||||
LessThanSlashToken = 25,
|
||||
GreaterThanToken = 26,
|
||||
LessThanEqualsToken = 27,
|
||||
GreaterThanEqualsToken = 28,
|
||||
EqualsEqualsToken = 29,
|
||||
ExclamationEqualsToken = 30,
|
||||
EqualsEqualsEqualsToken = 31,
|
||||
ExclamationEqualsEqualsToken = 32,
|
||||
EqualsGreaterThanToken = 33,
|
||||
PlusToken = 34,
|
||||
MinusToken = 35,
|
||||
AsteriskToken = 36,
|
||||
SlashToken = 37,
|
||||
PercentToken = 38,
|
||||
PlusPlusToken = 39,
|
||||
MinusMinusToken = 40,
|
||||
LessThanLessThanToken = 41,
|
||||
GreaterThanGreaterThanToken = 42,
|
||||
GreaterThanGreaterThanGreaterThanToken = 43,
|
||||
AmpersandToken = 44,
|
||||
BarToken = 45,
|
||||
CaretToken = 46,
|
||||
ExclamationToken = 47,
|
||||
TildeToken = 48,
|
||||
AmpersandAmpersandToken = 49,
|
||||
BarBarToken = 50,
|
||||
QuestionToken = 51,
|
||||
ColonToken = 52,
|
||||
AtToken = 53,
|
||||
EqualsToken = 54,
|
||||
PlusEqualsToken = 55,
|
||||
MinusEqualsToken = 56,
|
||||
AsteriskEqualsToken = 57,
|
||||
SlashEqualsToken = 58,
|
||||
PercentEqualsToken = 59,
|
||||
LessThanLessThanEqualsToken = 60,
|
||||
GreaterThanGreaterThanEqualsToken = 61,
|
||||
GreaterThanGreaterThanGreaterThanEqualsToken = 62,
|
||||
AmpersandEqualsToken = 63,
|
||||
BarEqualsToken = 64,
|
||||
CaretEqualsToken = 65,
|
||||
Identifier = 66,
|
||||
BreakKeyword = 67,
|
||||
CaseKeyword = 68,
|
||||
CatchKeyword = 69,
|
||||
ClassKeyword = 70,
|
||||
ConstKeyword = 71,
|
||||
ContinueKeyword = 72,
|
||||
DebuggerKeyword = 73,
|
||||
DefaultKeyword = 74,
|
||||
DeleteKeyword = 75,
|
||||
DoKeyword = 76,
|
||||
ElseKeyword = 77,
|
||||
EnumKeyword = 78,
|
||||
ExportKeyword = 79,
|
||||
ExtendsKeyword = 80,
|
||||
FalseKeyword = 81,
|
||||
FinallyKeyword = 82,
|
||||
ForKeyword = 83,
|
||||
FunctionKeyword = 84,
|
||||
IfKeyword = 85,
|
||||
ImportKeyword = 86,
|
||||
InKeyword = 87,
|
||||
InstanceOfKeyword = 88,
|
||||
NewKeyword = 89,
|
||||
NullKeyword = 90,
|
||||
ReturnKeyword = 91,
|
||||
SuperKeyword = 92,
|
||||
SwitchKeyword = 93,
|
||||
ThisKeyword = 94,
|
||||
ThrowKeyword = 95,
|
||||
TrueKeyword = 96,
|
||||
TryKeyword = 97,
|
||||
TypeOfKeyword = 98,
|
||||
VarKeyword = 99,
|
||||
VoidKeyword = 100,
|
||||
WhileKeyword = 101,
|
||||
WithKeyword = 102,
|
||||
ImplementsKeyword = 103,
|
||||
InterfaceKeyword = 104,
|
||||
LetKeyword = 105,
|
||||
PackageKeyword = 106,
|
||||
PrivateKeyword = 107,
|
||||
ProtectedKeyword = 108,
|
||||
PublicKeyword = 109,
|
||||
StaticKeyword = 110,
|
||||
YieldKeyword = 111,
|
||||
AbstractKeyword = 112,
|
||||
AsKeyword = 113,
|
||||
AnyKeyword = 114,
|
||||
AsyncKeyword = 115,
|
||||
AwaitKeyword = 116,
|
||||
BooleanKeyword = 117,
|
||||
ConstructorKeyword = 118,
|
||||
DeclareKeyword = 119,
|
||||
GetKeyword = 120,
|
||||
IsKeyword = 121,
|
||||
ModuleKeyword = 122,
|
||||
NamespaceKeyword = 123,
|
||||
RequireKeyword = 124,
|
||||
NumberKeyword = 125,
|
||||
SetKeyword = 126,
|
||||
StringKeyword = 127,
|
||||
SymbolKeyword = 128,
|
||||
TypeKeyword = 129,
|
||||
FromKeyword = 130,
|
||||
OfKeyword = 131,
|
||||
QualifiedName = 132,
|
||||
ComputedPropertyName = 133,
|
||||
TypeParameter = 134,
|
||||
Parameter = 135,
|
||||
Decorator = 136,
|
||||
PropertySignature = 137,
|
||||
PropertyDeclaration = 138,
|
||||
MethodSignature = 139,
|
||||
MethodDeclaration = 140,
|
||||
Constructor = 141,
|
||||
GetAccessor = 142,
|
||||
SetAccessor = 143,
|
||||
CallSignature = 144,
|
||||
ConstructSignature = 145,
|
||||
IndexSignature = 146,
|
||||
TypePredicate = 147,
|
||||
TypeReference = 148,
|
||||
FunctionType = 149,
|
||||
ConstructorType = 150,
|
||||
TypeQuery = 151,
|
||||
TypeLiteral = 152,
|
||||
ArrayType = 153,
|
||||
TupleType = 154,
|
||||
UnionType = 155,
|
||||
IntersectionType = 156,
|
||||
ParenthesizedType = 157,
|
||||
ObjectBindingPattern = 158,
|
||||
ArrayBindingPattern = 159,
|
||||
BindingElement = 160,
|
||||
ArrayLiteralExpression = 161,
|
||||
ObjectLiteralExpression = 162,
|
||||
PropertyAccessExpression = 163,
|
||||
ElementAccessExpression = 164,
|
||||
CallExpression = 165,
|
||||
NewExpression = 166,
|
||||
TaggedTemplateExpression = 167,
|
||||
TypeAssertionExpression = 168,
|
||||
ParenthesizedExpression = 169,
|
||||
FunctionExpression = 170,
|
||||
ArrowFunction = 171,
|
||||
DeleteExpression = 172,
|
||||
TypeOfExpression = 173,
|
||||
VoidExpression = 174,
|
||||
AwaitExpression = 175,
|
||||
PrefixUnaryExpression = 176,
|
||||
PostfixUnaryExpression = 177,
|
||||
BinaryExpression = 178,
|
||||
ConditionalExpression = 179,
|
||||
TemplateExpression = 180,
|
||||
YieldExpression = 181,
|
||||
SpreadElementExpression = 182,
|
||||
ClassExpression = 183,
|
||||
OmittedExpression = 184,
|
||||
ExpressionWithTypeArguments = 185,
|
||||
AsExpression = 186,
|
||||
TemplateSpan = 187,
|
||||
SemicolonClassElement = 188,
|
||||
Block = 189,
|
||||
VariableStatement = 190,
|
||||
EmptyStatement = 191,
|
||||
ExpressionStatement = 192,
|
||||
IfStatement = 193,
|
||||
DoStatement = 194,
|
||||
WhileStatement = 195,
|
||||
ForStatement = 196,
|
||||
ForInStatement = 197,
|
||||
ForOfStatement = 198,
|
||||
ContinueStatement = 199,
|
||||
BreakStatement = 200,
|
||||
ReturnStatement = 201,
|
||||
WithStatement = 202,
|
||||
SwitchStatement = 203,
|
||||
LabeledStatement = 204,
|
||||
ThrowStatement = 205,
|
||||
TryStatement = 206,
|
||||
DebuggerStatement = 207,
|
||||
VariableDeclaration = 208,
|
||||
VariableDeclarationList = 209,
|
||||
FunctionDeclaration = 210,
|
||||
ClassDeclaration = 211,
|
||||
InterfaceDeclaration = 212,
|
||||
TypeAliasDeclaration = 213,
|
||||
EnumDeclaration = 214,
|
||||
ModuleDeclaration = 215,
|
||||
ModuleBlock = 216,
|
||||
CaseBlock = 217,
|
||||
ImportEqualsDeclaration = 218,
|
||||
ImportDeclaration = 219,
|
||||
ImportClause = 220,
|
||||
NamespaceImport = 221,
|
||||
NamedImports = 222,
|
||||
ImportSpecifier = 223,
|
||||
ExportAssignment = 224,
|
||||
ExportDeclaration = 225,
|
||||
NamedExports = 226,
|
||||
ExportSpecifier = 227,
|
||||
MissingDeclaration = 228,
|
||||
ExternalModuleReference = 229,
|
||||
JsxElement = 230,
|
||||
JsxSelfClosingElement = 231,
|
||||
JsxOpeningElement = 232,
|
||||
JsxText = 233,
|
||||
JsxClosingElement = 234,
|
||||
JsxAttribute = 235,
|
||||
JsxSpreadAttribute = 236,
|
||||
JsxExpression = 237,
|
||||
CaseClause = 238,
|
||||
DefaultClause = 239,
|
||||
HeritageClause = 240,
|
||||
CatchClause = 241,
|
||||
PropertyAssignment = 242,
|
||||
ShorthandPropertyAssignment = 243,
|
||||
EnumMember = 244,
|
||||
SourceFile = 245,
|
||||
JSDocTypeExpression = 246,
|
||||
JSDocAllType = 247,
|
||||
JSDocUnknownType = 248,
|
||||
JSDocArrayType = 249,
|
||||
JSDocUnionType = 250,
|
||||
JSDocTupleType = 251,
|
||||
JSDocNullableType = 252,
|
||||
JSDocNonNullableType = 253,
|
||||
JSDocRecordType = 254,
|
||||
JSDocRecordMember = 255,
|
||||
JSDocTypeReference = 256,
|
||||
JSDocOptionalType = 257,
|
||||
JSDocFunctionType = 258,
|
||||
JSDocVariadicType = 259,
|
||||
JSDocConstructorType = 260,
|
||||
JSDocThisType = 261,
|
||||
JSDocComment = 262,
|
||||
JSDocTag = 263,
|
||||
JSDocParameterTag = 264,
|
||||
JSDocReturnTag = 265,
|
||||
JSDocTypeTag = 266,
|
||||
JSDocTemplateTag = 267,
|
||||
SyntaxList = 268,
|
||||
Count = 269,
|
||||
FirstAssignment = 54,
|
||||
LastAssignment = 65,
|
||||
FirstReservedWord = 67,
|
||||
LastReservedWord = 102,
|
||||
FirstKeyword = 67,
|
||||
LastKeyword = 131,
|
||||
FirstFutureReservedWord = 103,
|
||||
LastFutureReservedWord = 111,
|
||||
FirstTypeNode = 148,
|
||||
LastTypeNode = 157,
|
||||
FirstPunctuation = 14,
|
||||
LastPunctuation = 64,
|
||||
LastPunctuation = 65,
|
||||
FirstToken = 0,
|
||||
LastToken = 127,
|
||||
LastToken = 131,
|
||||
FirstTriviaToken = 2,
|
||||
LastTriviaToken = 6,
|
||||
FirstLiteralToken = 7,
|
||||
@@ -305,8 +320,8 @@ declare namespace ts {
|
||||
FirstTemplateToken = 10,
|
||||
LastTemplateToken = 13,
|
||||
FirstBinaryOperator = 24,
|
||||
LastBinaryOperator = 64,
|
||||
FirstNode = 128,
|
||||
LastBinaryOperator = 65,
|
||||
FirstNode = 132,
|
||||
}
|
||||
const enum NodeFlags {
|
||||
Export = 1,
|
||||
@@ -315,18 +330,28 @@ declare namespace ts {
|
||||
Private = 32,
|
||||
Protected = 64,
|
||||
Static = 128,
|
||||
Default = 256,
|
||||
MultiLine = 512,
|
||||
Synthetic = 1024,
|
||||
DeclarationFile = 2048,
|
||||
Let = 4096,
|
||||
Const = 8192,
|
||||
OctalLiteral = 16384,
|
||||
Namespace = 32768,
|
||||
ExportContext = 65536,
|
||||
Modifier = 499,
|
||||
Abstract = 256,
|
||||
Async = 512,
|
||||
Default = 1024,
|
||||
MultiLine = 2048,
|
||||
Synthetic = 4096,
|
||||
DeclarationFile = 8192,
|
||||
Let = 16384,
|
||||
Const = 32768,
|
||||
OctalLiteral = 65536,
|
||||
Namespace = 131072,
|
||||
ExportContext = 262144,
|
||||
Modifier = 2035,
|
||||
AccessibilityModifier = 112,
|
||||
BlockScoped = 12288,
|
||||
BlockScoped = 49152,
|
||||
}
|
||||
const enum JsxFlags {
|
||||
None = 0,
|
||||
IntrinsicNamedElement = 1,
|
||||
IntrinsicIndexedElement = 2,
|
||||
ClassElement = 4,
|
||||
UnknownElement = 8,
|
||||
IntrinsicElement = 3,
|
||||
}
|
||||
interface Node extends TextRange {
|
||||
kind: SyntaxKind;
|
||||
@@ -483,9 +508,13 @@ declare namespace ts {
|
||||
interface TupleTypeNode extends TypeNode {
|
||||
elementTypes: NodeArray<TypeNode>;
|
||||
}
|
||||
interface UnionTypeNode extends TypeNode {
|
||||
interface UnionOrIntersectionTypeNode extends TypeNode {
|
||||
types: NodeArray<TypeNode>;
|
||||
}
|
||||
interface UnionTypeNode extends UnionOrIntersectionTypeNode {
|
||||
}
|
||||
interface IntersectionTypeNode extends UnionOrIntersectionTypeNode {
|
||||
}
|
||||
interface ParenthesizedTypeNode extends TypeNode {
|
||||
type: TypeNode;
|
||||
}
|
||||
@@ -528,6 +557,9 @@ declare namespace ts {
|
||||
interface VoidExpression extends UnaryExpression {
|
||||
expression: UnaryExpression;
|
||||
}
|
||||
interface AwaitExpression extends UnaryExpression {
|
||||
expression: UnaryExpression;
|
||||
}
|
||||
interface YieldExpression extends Expression {
|
||||
asteriskToken?: Node;
|
||||
expression?: Expression;
|
||||
@@ -601,10 +633,46 @@ declare namespace ts {
|
||||
template: LiteralExpression | TemplateExpression;
|
||||
}
|
||||
type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator;
|
||||
interface AsExpression extends Expression {
|
||||
expression: Expression;
|
||||
type: TypeNode;
|
||||
}
|
||||
interface TypeAssertion extends UnaryExpression {
|
||||
type: TypeNode;
|
||||
expression: UnaryExpression;
|
||||
}
|
||||
type AssertionExpression = TypeAssertion | AsExpression;
|
||||
interface JsxElement extends PrimaryExpression {
|
||||
openingElement: JsxOpeningElement;
|
||||
children: NodeArray<JsxChild>;
|
||||
closingElement: JsxClosingElement;
|
||||
}
|
||||
interface JsxOpeningElement extends Expression {
|
||||
_openingElementBrand?: any;
|
||||
tagName: EntityName;
|
||||
attributes: NodeArray<JsxAttribute | JsxSpreadAttribute>;
|
||||
}
|
||||
interface JsxSelfClosingElement extends PrimaryExpression, JsxOpeningElement {
|
||||
_selfClosingElementBrand?: any;
|
||||
}
|
||||
type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement;
|
||||
interface JsxAttribute extends Node {
|
||||
name: Identifier;
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface JsxSpreadAttribute extends Node {
|
||||
expression: Expression;
|
||||
}
|
||||
interface JsxClosingElement extends Node {
|
||||
tagName: EntityName;
|
||||
}
|
||||
interface JsxExpression extends Expression {
|
||||
expression?: Expression;
|
||||
}
|
||||
interface JsxText extends Node {
|
||||
_jsxTextExpressionBrand: any;
|
||||
}
|
||||
type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement;
|
||||
interface Statement extends Node {
|
||||
_statementBrand: any;
|
||||
}
|
||||
@@ -859,6 +927,7 @@ declare namespace ts {
|
||||
}[];
|
||||
moduleName: string;
|
||||
referencedFiles: FileReference[];
|
||||
languageVariant: LanguageVariant;
|
||||
/**
|
||||
* lib.d.ts should have a reference comment like
|
||||
*
|
||||
@@ -881,6 +950,13 @@ declare namespace ts {
|
||||
interface WriteFileCallback {
|
||||
(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
}
|
||||
class OperationCanceledException {
|
||||
}
|
||||
interface CancellationToken {
|
||||
isCancellationRequested(): boolean;
|
||||
/** @throws OperationCanceledException if isCancellationRequested is true */
|
||||
throwIfCancellationRequested(): void;
|
||||
}
|
||||
interface Program extends ScriptReferenceHost {
|
||||
/**
|
||||
* Get a list of files in the program
|
||||
@@ -896,12 +972,12 @@ declare namespace ts {
|
||||
* used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter
|
||||
* will be invoked when writing the JavaScript and declaration files.
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
|
||||
getOptionsDiagnostics(): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult;
|
||||
getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
/**
|
||||
* Gets a type checker that can be used to semantically analyze source fils in the program.
|
||||
*/
|
||||
@@ -976,6 +1052,8 @@ declare namespace ts {
|
||||
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
|
||||
getAliasedSymbol(symbol: Symbol): Symbol;
|
||||
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
|
||||
getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type;
|
||||
getJsxIntrinsicTagNames(): Symbol[];
|
||||
}
|
||||
interface SymbolDisplayBuilder {
|
||||
buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
@@ -1053,7 +1131,7 @@ declare namespace ts {
|
||||
Merged = 33554432,
|
||||
Transient = 67108864,
|
||||
Prototype = 134217728,
|
||||
UnionProperty = 268435456,
|
||||
SyntheticProperty = 268435456,
|
||||
Optional = 536870912,
|
||||
ExportStar = 1073741824,
|
||||
Enum = 384,
|
||||
@@ -1069,8 +1147,8 @@ declare namespace ts {
|
||||
PropertyExcludes = 107455,
|
||||
EnumMemberExcludes = 107455,
|
||||
FunctionExcludes = 106927,
|
||||
ClassExcludes = 899583,
|
||||
InterfaceExcludes = 792992,
|
||||
ClassExcludes = 899519,
|
||||
InterfaceExcludes = 792960,
|
||||
RegularEnumExcludes = 899327,
|
||||
ConstEnumExcludes = 899967,
|
||||
ValueModuleExcludes = 106639,
|
||||
@@ -1116,13 +1194,16 @@ declare namespace ts {
|
||||
Reference = 4096,
|
||||
Tuple = 8192,
|
||||
Union = 16384,
|
||||
Anonymous = 32768,
|
||||
Instantiated = 65536,
|
||||
ObjectLiteral = 262144,
|
||||
ESSymbol = 2097152,
|
||||
Intersection = 32768,
|
||||
Anonymous = 65536,
|
||||
Instantiated = 131072,
|
||||
ObjectLiteral = 524288,
|
||||
ESSymbol = 4194304,
|
||||
StringLike = 258,
|
||||
NumberLike = 132,
|
||||
ObjectType = 48128,
|
||||
ObjectType = 80896,
|
||||
UnionOrIntersection = 49152,
|
||||
StructuredType = 130048,
|
||||
}
|
||||
interface Type {
|
||||
flags: TypeFlags;
|
||||
@@ -1157,9 +1238,13 @@ declare namespace ts {
|
||||
elementTypes: Type[];
|
||||
baseArrayType: TypeReference;
|
||||
}
|
||||
interface UnionType extends Type {
|
||||
interface UnionOrIntersectionType extends Type {
|
||||
types: Type[];
|
||||
}
|
||||
interface UnionType extends UnionOrIntersectionType {
|
||||
}
|
||||
interface IntersectionType extends UnionOrIntersectionType {
|
||||
}
|
||||
interface TypeParameter extends Type {
|
||||
constraint: Type;
|
||||
}
|
||||
@@ -1216,6 +1301,7 @@ declare namespace ts {
|
||||
help?: boolean;
|
||||
inlineSourceMap?: boolean;
|
||||
inlineSources?: boolean;
|
||||
jsx?: JsxEmit;
|
||||
listFiles?: boolean;
|
||||
locale?: string;
|
||||
mapRoot?: string;
|
||||
@@ -1242,6 +1328,7 @@ declare namespace ts {
|
||||
watch?: boolean;
|
||||
isolatedModules?: boolean;
|
||||
experimentalDecorators?: boolean;
|
||||
experimentalAsyncFunctions?: boolean;
|
||||
emitDecoratorMetadata?: boolean;
|
||||
[option: string]: string | number | boolean;
|
||||
}
|
||||
@@ -1252,6 +1339,11 @@ declare namespace ts {
|
||||
UMD = 3,
|
||||
System = 4,
|
||||
}
|
||||
const enum JsxEmit {
|
||||
None = 0,
|
||||
Preserve = 1,
|
||||
React = 2,
|
||||
}
|
||||
const enum NewLineKind {
|
||||
CarriageReturnLineFeed = 0,
|
||||
LineFeed = 1,
|
||||
@@ -1266,18 +1358,18 @@ declare namespace ts {
|
||||
ES6 = 2,
|
||||
Latest = 2,
|
||||
}
|
||||
const enum LanguageVariant {
|
||||
Standard = 0,
|
||||
JSX = 1,
|
||||
}
|
||||
interface ParsedCommandLine {
|
||||
options: CompilerOptions;
|
||||
fileNames: string[];
|
||||
errors: Diagnostic[];
|
||||
}
|
||||
interface CancellationToken {
|
||||
isCancellationRequested(): boolean;
|
||||
}
|
||||
interface CompilerHost {
|
||||
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
getCancellationToken?(): CancellationToken;
|
||||
writeFile: WriteFileCallback;
|
||||
getCurrentDirectory(): string;
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
@@ -1336,10 +1428,14 @@ declare namespace ts {
|
||||
reScanGreaterToken(): SyntaxKind;
|
||||
reScanSlashToken(): SyntaxKind;
|
||||
reScanTemplateToken(): SyntaxKind;
|
||||
scanJsxIdentifier(): SyntaxKind;
|
||||
reScanJsxToken(): SyntaxKind;
|
||||
scanJsxToken(): SyntaxKind;
|
||||
scan(): SyntaxKind;
|
||||
setText(text: string, start?: number, length?: number): void;
|
||||
setOnError(onError: ErrorCallback): void;
|
||||
setScriptTarget(scriptTarget: ScriptTarget): void;
|
||||
setLanguageVariant(variant: LanguageVariant): void;
|
||||
setTextPos(textPos: number): void;
|
||||
lookAhead<T>(callback: () => T): T;
|
||||
tryScan<T>(callback: () => T): T;
|
||||
@@ -1397,7 +1493,7 @@ declare namespace ts {
|
||||
const version: string;
|
||||
function findConfigFile(searchPath: string): string;
|
||||
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
|
||||
function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile): Diagnostic[];
|
||||
function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
|
||||
}
|
||||
@@ -1495,6 +1591,8 @@ declare namespace ts {
|
||||
* not happen and the entire document will be re - parsed.
|
||||
*/
|
||||
getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange;
|
||||
/** Releases all resources held by this script snapshot */
|
||||
dispose?(): void;
|
||||
}
|
||||
module ScriptSnapshot {
|
||||
function fromString(text: string): IScriptSnapshot;
|
||||
@@ -1504,6 +1602,9 @@ declare namespace ts {
|
||||
importedFiles: FileReference[];
|
||||
isLibFile: boolean;
|
||||
}
|
||||
interface HostCancellationToken {
|
||||
isCancellationRequested(): boolean;
|
||||
}
|
||||
interface LanguageServiceHost {
|
||||
getCompilationSettings(): CompilerOptions;
|
||||
getNewLine?(): string;
|
||||
@@ -1512,7 +1613,7 @@ declare namespace ts {
|
||||
getScriptVersion(fileName: string): string;
|
||||
getScriptSnapshot(fileName: string): IScriptSnapshot;
|
||||
getLocalizedDiagnosticMessages?(): any;
|
||||
getCancellationToken?(): CancellationToken;
|
||||
getCancellationToken?(): HostCancellationToken;
|
||||
getCurrentDirectory(): string;
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
log?(s: string): void;
|
||||
@@ -1892,6 +1993,7 @@ declare namespace ts {
|
||||
const scriptElement: string;
|
||||
const moduleElement: string;
|
||||
const classElement: string;
|
||||
const localClassElement: string;
|
||||
const interfaceElement: string;
|
||||
const typeElement: string;
|
||||
const enumElement: string;
|
||||
@@ -1923,6 +2025,7 @@ declare namespace ts {
|
||||
const exportedModifier: string;
|
||||
const ambientModifier: string;
|
||||
const staticModifier: string;
|
||||
const abstractModifier: string;
|
||||
}
|
||||
class ClassificationTypeNames {
|
||||
static comment: string;
|
||||
@@ -1968,15 +2071,6 @@ declare namespace ts {
|
||||
}
|
||||
function displayPartsToString(displayParts: SymbolDisplayPart[]): string;
|
||||
function getDefaultCompilerOptions(): CompilerOptions;
|
||||
class OperationCanceledException {
|
||||
}
|
||||
class CancellationTokenObject {
|
||||
private cancellationToken;
|
||||
static None: CancellationTokenObject;
|
||||
constructor(cancellationToken: CancellationToken);
|
||||
isCancellationRequested(): boolean;
|
||||
throwIfCancellationRequested(): void;
|
||||
}
|
||||
function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string;
|
||||
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
|
||||
let disableIncrementalParsing: boolean;
|
||||
@@ -1986,7 +2080,7 @@ declare namespace ts {
|
||||
function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService;
|
||||
function createClassifier(): Classifier;
|
||||
/**
|
||||
* Get the path of the default library file (lib.d.ts) as distributed with the typescript
|
||||
* Get the path of the default library files (lib.d.ts) as distributed with the typescript
|
||||
* node package.
|
||||
* The functionality is not supported if the ts module is consumed outside of a node module.
|
||||
*/
|
||||
|
||||
+8587
-5870
File diff suppressed because it is too large
Load Diff
+3
-1
@@ -33,7 +33,9 @@
|
||||
"mocha": "latest",
|
||||
"chai": "latest",
|
||||
"browserify": "latest",
|
||||
"istanbul": "latest"
|
||||
"istanbul": "latest",
|
||||
"mocha-fivemat-progress-reporter": "latest",
|
||||
"tslint": "latest"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jake runtests"
|
||||
|
||||
@@ -74,7 +74,7 @@ fs.readFile('src/compiler/diagnosticInformationMap.generated.ts', 'utf-8', (err,
|
||||
console.log('Consumed ' + allSrc.length + ' characters of source');
|
||||
|
||||
let count = 0;
|
||||
console.log('== List of errors not used in source ==')
|
||||
console.log('== List of errors not used in source ==');
|
||||
for (let errName of errorNames) {
|
||||
if (allSrc.indexOf(errName) < 0) {
|
||||
console.log(errName);
|
||||
@@ -84,4 +84,3 @@ fs.readFile('src/compiler/diagnosticInformationMap.generated.ts', 'utf-8', (err,
|
||||
console.log(count + ' of ' + errorNames.length + ' errors are not used in source');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+34
-34
@@ -11,7 +11,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getModuleInstanceState(node: Node): ModuleInstanceState {
|
||||
// A module is uninstantiated if it contains only
|
||||
// A module is uninstantiated if it contains only
|
||||
// 1. interface declarations, type alias declarations
|
||||
if (node.kind === SyntaxKind.InterfaceDeclaration || node.kind === SyntaxKind.TypeAliasDeclaration) {
|
||||
return ModuleInstanceState.NonInstantiated;
|
||||
@@ -53,7 +53,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
const enum ContainerFlags {
|
||||
// The current node is not a container, and no container manipulation should happen before
|
||||
// The current node is not a container, and no container manipulation should happen before
|
||||
// recursing into it.
|
||||
None = 0,
|
||||
|
||||
@@ -90,13 +90,13 @@ namespace ts {
|
||||
let lastContainer: Node;
|
||||
|
||||
// If this file is an external module, then it is automatically in strict-mode according to
|
||||
// ES6. If it is not an external module, then we'll determine if it is in strict mode or
|
||||
// ES6. If it is not an external module, then we'll determine if it is in strict mode or
|
||||
// not depending on if we see "use strict" in certain places (or if we hit a class/namespace).
|
||||
let inStrictMode = !!file.externalModuleIndicator;
|
||||
|
||||
let symbolCount = 0;
|
||||
let Symbol = objectAllocator.getSymbolConstructor();
|
||||
let classifiableNames: Map<string> = {};
|
||||
let classifiableNames: Map<string> = {};
|
||||
|
||||
if (!file.locals) {
|
||||
bind(file);
|
||||
@@ -179,7 +179,7 @@ namespace ts {
|
||||
* @param parent - node's parent declaration.
|
||||
* @param node - The declaration to be added to the symbol table
|
||||
* @param includes - The SymbolFlags that node has in addition to its declaration type (eg: export, ambient, etc.)
|
||||
* @param excludes - The flags which node cannot be declared alongside in a symbol table. Used to report forbidden declarations.
|
||||
* @param excludes - The flags which node cannot be declared alongside in a symbol table. Used to report forbidden declarations.
|
||||
*/
|
||||
function declareSymbol(symbolTable: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol {
|
||||
Debug.assert(!hasDynamicName(node));
|
||||
@@ -192,13 +192,13 @@ namespace ts {
|
||||
|
||||
// Check and see if the symbol table already has a symbol with this name. If not,
|
||||
// create a new symbol with this name and add it to the table. Note that we don't
|
||||
// give the new symbol any flags *yet*. This ensures that it will not conflict
|
||||
// give the new symbol any flags *yet*. This ensures that it will not conflict
|
||||
// with the 'excludes' flags we pass in.
|
||||
//
|
||||
// If we do get an existing symbol, see if it conflicts with the new symbol we're
|
||||
// creating. For example, a 'var' symbol and a 'class' symbol will conflict within
|
||||
// the same symbol table. If we have a conflict, report the issue on each
|
||||
// declaration we have for this symbol, and then create a new symbol for this
|
||||
// the same symbol table. If we have a conflict, report the issue on each
|
||||
// declaration we have for this symbol, and then create a new symbol for this
|
||||
// declaration.
|
||||
//
|
||||
// If we created a new symbol, either because we didn't have a symbol with this name
|
||||
@@ -259,7 +259,7 @@ namespace ts {
|
||||
// ExportType, or ExportContainer flag, and an associated export symbol with all the correct flags set
|
||||
// on it. There are 2 main reasons:
|
||||
//
|
||||
// 1. We treat locals and exports of the same name as mutually exclusive within a container.
|
||||
// 1. We treat locals and exports of the same name as mutually exclusive within a container.
|
||||
// That means the binder will issue a Duplicate Identifier error if you mix locals and exports
|
||||
// with the same name in the same container.
|
||||
// TODO: Make this a more specific error and decouple it from the exclusion logic.
|
||||
@@ -282,11 +282,11 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
// All container nodes are kept on a linked list in declaration order. This list is used by
|
||||
// the getLocalNameOfContainer function in the type checker to validate that the local name
|
||||
// All container nodes are kept on a linked list in declaration order. This list is used by
|
||||
// the getLocalNameOfContainer function in the type checker to validate that the local name
|
||||
// used for a container is unique.
|
||||
function bindChildren(node: Node) {
|
||||
// Before we recurse into a node's chilren, we first save the existing parent, container
|
||||
// Before we recurse into a node's chilren, we first save the existing parent, container
|
||||
// and block-container. Then after we pop out of processing the children, we restore
|
||||
// these saved values.
|
||||
let saveParent = parent;
|
||||
@@ -295,16 +295,16 @@ namespace ts {
|
||||
|
||||
// This node will now be set as the parent of all of its children as we recurse into them.
|
||||
parent = node;
|
||||
|
||||
|
||||
// Depending on what kind of node this is, we may have to adjust the current container
|
||||
// and block-container. If the current node is a container, then it is automatically
|
||||
// considered the current block-container as well. Also, for containers that we know
|
||||
// may contain locals, we proactively initialize the .locals field. We do this because
|
||||
// it's highly likely that the .locals will be needed to place some child in (for example,
|
||||
// a parameter, or variable declaration).
|
||||
//
|
||||
//
|
||||
// However, we do not proactively create the .locals for block-containers because it's
|
||||
// totally normal and common for block-containers to never actually have a block-scoped
|
||||
// totally normal and common for block-containers to never actually have a block-scoped
|
||||
// variable in them. We don't want to end up allocating an object for every 'block' we
|
||||
// run into when most of them won't be necessary.
|
||||
//
|
||||
@@ -345,7 +345,7 @@ namespace ts {
|
||||
case SyntaxKind.TypeLiteral:
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
return ContainerFlags.IsContainer;
|
||||
|
||||
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
case SyntaxKind.IndexSignature:
|
||||
@@ -373,7 +373,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.Block:
|
||||
// do not treat blocks directly inside a function as a block-scoped-container.
|
||||
// Locals that reside in this block should go to the function locals. Othewise 'x'
|
||||
// Locals that reside in this block should go to the function locals. Othewise 'x'
|
||||
// would not appear to be a redeclaration of a block scoped local in the following
|
||||
// example:
|
||||
//
|
||||
@@ -386,7 +386,7 @@ namespace ts {
|
||||
// the block, then there would be no collision.
|
||||
//
|
||||
// By not creating a new block-scoped-container here, we ensure that both 'var x'
|
||||
// and 'let x' go into the Function-container's locals, and we do get a collision
|
||||
// and 'let x' go into the Function-container's locals, and we do get a collision
|
||||
// conflict.
|
||||
return isFunctionLike(node.parent) ? ContainerFlags.None : ContainerFlags.IsBlockScopedContainer;
|
||||
}
|
||||
@@ -484,7 +484,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function hasExportDeclarations(node: ModuleDeclaration | SourceFile): boolean {
|
||||
var body = node.kind === SyntaxKind.SourceFile ? node : (<ModuleDeclaration>node).body;
|
||||
let body = node.kind === SyntaxKind.SourceFile ? node : (<ModuleDeclaration>node).body;
|
||||
if (body.kind === SyntaxKind.SourceFile || body.kind === SyntaxKind.ModuleBlock) {
|
||||
for (let stat of (<Block>body).statements) {
|
||||
if (stat.kind === SyntaxKind.ExportDeclaration || stat.kind === SyntaxKind.ExportAssignment) {
|
||||
@@ -536,8 +536,8 @@ namespace ts {
|
||||
// For a given function symbol "<...>(...) => T" we want to generate a symbol identical
|
||||
// to the one we would get for: { <...>(...): T }
|
||||
//
|
||||
// We do that by making an anonymous type literal symbol, and then setting the function
|
||||
// symbol as its sole member. To the rest of the system, this symbol will be indistinguishable
|
||||
// We do that by making an anonymous type literal symbol, and then setting the function
|
||||
// symbol as its sole member. To the rest of the system, this symbol will be indistinguishable
|
||||
// from an actual type literal symbol you would have gotten had you used the long form.
|
||||
let symbol = createSymbol(SymbolFlags.Signature, getDeclarationName(node));
|
||||
addDeclarationToSymbol(symbol, node, SymbolFlags.Signature);
|
||||
@@ -638,7 +638,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getStrictModeIdentifierMessage(node: Node) {
|
||||
// Provide specialized messages to help the user understand why we think they're in
|
||||
// Provide specialized messages to help the user understand why we think they're in
|
||||
// strict mode.
|
||||
if (getContainingClass(node)) {
|
||||
return Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode;
|
||||
@@ -696,7 +696,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getStrictModeEvalOrArgumentsMessage(node: Node) {
|
||||
// Provide specialized messages to help the user understand why we think they're in
|
||||
// Provide specialized messages to help the user understand why we think they're in
|
||||
// strict mode.
|
||||
if (getContainingClass(node)) {
|
||||
return Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode;
|
||||
@@ -760,24 +760,24 @@ namespace ts {
|
||||
function bind(node: Node) {
|
||||
node.parent = parent;
|
||||
|
||||
var savedInStrictMode = inStrictMode;
|
||||
let savedInStrictMode = inStrictMode;
|
||||
if (!savedInStrictMode) {
|
||||
updateStrictMode(node);
|
||||
}
|
||||
|
||||
// First we bind declaration nodes to a symbol if possible. We'll both create a symbol
|
||||
// and then potentially add the symbol to an appropriate symbol table. Possible
|
||||
// and then potentially add the symbol to an appropriate symbol table. Possible
|
||||
// destination symbol tables are:
|
||||
//
|
||||
//
|
||||
// 1) The 'exports' table of the current container's symbol.
|
||||
// 2) The 'members' table of the current container's symbol.
|
||||
// 3) The 'locals' table of the current container.
|
||||
//
|
||||
// However, not all symbols will end up in any of these tables. 'Anonymous' symbols
|
||||
// However, not all symbols will end up in any of these tables. 'Anonymous' symbols
|
||||
// (like TypeLiterals for example) will not be put in any table.
|
||||
bindWorker(node);
|
||||
|
||||
// Then we recurse into the children of the node to bind them as well. For certain
|
||||
// Then we recurse into the children of the node to bind them as well. For certain
|
||||
// symbols we do specialized work when we recurse. For example, we'll keep track of
|
||||
// the current 'container' node when it changes. This helps us know which symbol table
|
||||
// a local should go into for example.
|
||||
@@ -817,7 +817,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Should be called only on prologue directives (isPrologueDirective(node) should be true)
|
||||
function isUseStrictPrologueDirective(node: ExpressionStatement): boolean {
|
||||
let nodeText = getTextOfNodeFromSourceText(file.text, node.expression);
|
||||
@@ -972,9 +972,9 @@ namespace ts {
|
||||
let symbol = node.symbol;
|
||||
|
||||
// TypeScript 1.0 spec (April 2014): 8.4
|
||||
// Every class automatically contains a static property member named 'prototype', the
|
||||
// Every class automatically contains a static property member named 'prototype', the
|
||||
// type of which is an instantiation of the class type with type Any supplied as a type
|
||||
// argument for each type parameter. It is an error to explicitly declare a static
|
||||
// argument for each type parameter. It is an error to explicitly declare a static
|
||||
// property member with the name 'prototype'.
|
||||
//
|
||||
// Note: we check for this here because this class may be merging into a module. The
|
||||
@@ -1000,7 +1000,7 @@ namespace ts {
|
||||
|
||||
function bindVariableDeclarationOrBindingElement(node: VariableDeclaration | BindingElement) {
|
||||
if (inStrictMode) {
|
||||
checkStrictModeEvalOrArguments(node, node.name)
|
||||
checkStrictModeEvalOrArguments(node, node.name);
|
||||
}
|
||||
|
||||
if (!isBindingPattern(node.name)) {
|
||||
@@ -1039,7 +1039,7 @@ namespace ts {
|
||||
declareSymbolAndAddToSymbolTable(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes);
|
||||
}
|
||||
|
||||
// If this is a property-parameter, then also declare the property symbol into the
|
||||
// If this is a property-parameter, then also declare the property symbol into the
|
||||
// containing class.
|
||||
if (node.flags & NodeFlags.AccessibilityModifier &&
|
||||
node.parent.kind === SyntaxKind.Constructor &&
|
||||
@@ -1056,4 +1056,4 @@ namespace ts {
|
||||
: declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+514
-517
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace ts {
|
||||
/* @internal */
|
||||
export var optionDeclarations: CommandLineOption[] = [
|
||||
export let optionDeclarations: CommandLineOption[] = [
|
||||
{
|
||||
name: "charset",
|
||||
type: "string",
|
||||
@@ -222,11 +222,11 @@ namespace ts {
|
||||
];
|
||||
|
||||
export function parseCommandLine(commandLine: string[]): ParsedCommandLine {
|
||||
var options: CompilerOptions = {};
|
||||
var fileNames: string[] = [];
|
||||
var errors: Diagnostic[] = [];
|
||||
var shortOptionNames: Map<string> = {};
|
||||
var optionNameMap: Map<CommandLineOption> = {};
|
||||
let options: CompilerOptions = {};
|
||||
let fileNames: string[] = [];
|
||||
let errors: Diagnostic[] = [];
|
||||
let shortOptionNames: Map<string> = {};
|
||||
let optionNameMap: Map<CommandLineOption> = {};
|
||||
|
||||
forEach(optionDeclarations, option => {
|
||||
optionNameMap[option.name.toLowerCase()] = option;
|
||||
@@ -242,9 +242,9 @@ namespace ts {
|
||||
};
|
||||
|
||||
function parseStrings(args: string[]) {
|
||||
var i = 0;
|
||||
let i = 0;
|
||||
while (i < args.length) {
|
||||
var s = args[i++];
|
||||
let s = args[i++];
|
||||
if (s.charCodeAt(0) === CharacterCodes.at) {
|
||||
parseResponseFile(s.slice(1));
|
||||
}
|
||||
@@ -257,7 +257,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (hasProperty(optionNameMap, s)) {
|
||||
var opt = optionNameMap[s];
|
||||
let opt = optionNameMap[s];
|
||||
|
||||
// Check to see if no argument was provided (e.g. "--locale" is the last command-line argument).
|
||||
if (!args[i] && opt.type !== "boolean") {
|
||||
@@ -276,8 +276,8 @@ namespace ts {
|
||||
break;
|
||||
// If not a primitive, the possible types are specified in what is effectively a map of options.
|
||||
default:
|
||||
var map = <Map<number>>opt.type;
|
||||
var key = (args[i++] || "").toLowerCase();
|
||||
let map = <Map<number>>opt.type;
|
||||
let key = (args[i++] || "").toLowerCase();
|
||||
if (hasProperty(map, key)) {
|
||||
options[opt.name] = map[key];
|
||||
}
|
||||
@@ -297,19 +297,19 @@ namespace ts {
|
||||
}
|
||||
|
||||
function parseResponseFile(fileName: string) {
|
||||
var text = sys.readFile(fileName);
|
||||
let text = sys.readFile(fileName);
|
||||
|
||||
if (!text) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.File_0_not_found, fileName));
|
||||
return;
|
||||
}
|
||||
|
||||
var args: string[] = [];
|
||||
var pos = 0;
|
||||
let args: string[] = [];
|
||||
let pos = 0;
|
||||
while (true) {
|
||||
while (pos < text.length && text.charCodeAt(pos) <= CharacterCodes.space) pos++;
|
||||
if (pos >= text.length) break;
|
||||
var start = pos;
|
||||
let start = pos;
|
||||
if (text.charCodeAt(start) === CharacterCodes.doubleQuote) {
|
||||
pos++;
|
||||
while (pos < text.length && text.charCodeAt(pos) !== CharacterCodes.doubleQuote) pos++;
|
||||
@@ -335,8 +335,9 @@ namespace ts {
|
||||
* @param fileName The path to the config file
|
||||
*/
|
||||
export function readConfigFile(fileName: string): { config?: any; error?: Diagnostic } {
|
||||
let text = '';
|
||||
try {
|
||||
var text = sys.readFile(fileName);
|
||||
text = sys.readFile(fileName);
|
||||
}
|
||||
catch (e) {
|
||||
return { error: createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) };
|
||||
@@ -362,10 +363,10 @@ namespace ts {
|
||||
* Parse the contents of a config file (tsconfig.json).
|
||||
* @param json The contents of the config file to parse
|
||||
* @param basePath A root directory to resolve relative path entries in the config
|
||||
* file to. e.g. outDir
|
||||
* file to. e.g. outDir
|
||||
*/
|
||||
export function parseConfigFile(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine {
|
||||
var errors: Diagnostic[] = [];
|
||||
let errors: Diagnostic[] = [];
|
||||
|
||||
return {
|
||||
options: getCompilerOptions(),
|
||||
@@ -374,22 +375,22 @@ namespace ts {
|
||||
};
|
||||
|
||||
function getCompilerOptions(): CompilerOptions {
|
||||
var options: CompilerOptions = {};
|
||||
var optionNameMap: Map<CommandLineOption> = {};
|
||||
let options: CompilerOptions = {};
|
||||
let optionNameMap: Map<CommandLineOption> = {};
|
||||
forEach(optionDeclarations, option => {
|
||||
optionNameMap[option.name] = option;
|
||||
});
|
||||
var jsonOptions = json["compilerOptions"];
|
||||
let jsonOptions = json["compilerOptions"];
|
||||
if (jsonOptions) {
|
||||
for (var id in jsonOptions) {
|
||||
for (let id in jsonOptions) {
|
||||
if (hasProperty(optionNameMap, id)) {
|
||||
var opt = optionNameMap[id];
|
||||
var optType = opt.type;
|
||||
var value = jsonOptions[id];
|
||||
var expectedType = typeof optType === "string" ? optType : "string";
|
||||
let opt = optionNameMap[id];
|
||||
let optType = opt.type;
|
||||
let value = jsonOptions[id];
|
||||
let expectedType = typeof optType === "string" ? optType : "string";
|
||||
if (typeof value === expectedType) {
|
||||
if (typeof optType !== "string") {
|
||||
var key = value.toLowerCase();
|
||||
let key = value.toLowerCase();
|
||||
if (hasProperty(optType, key)) {
|
||||
value = optType[key];
|
||||
}
|
||||
@@ -424,7 +425,7 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
let exclude = json["exclude"] instanceof Array ? map(<string[]>json["exclude"], normalizeSlashes) : undefined;
|
||||
let sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude));
|
||||
let sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude));
|
||||
for (let i = 0; i < sysFiles.length; i++) {
|
||||
let name = sysFiles[i];
|
||||
if (fileExtensionIs(name, ".d.ts")) {
|
||||
@@ -435,7 +436,7 @@ namespace ts {
|
||||
}
|
||||
else if (fileExtensionIs(name, ".ts")) {
|
||||
if (!contains(sysFiles, name + "x")) {
|
||||
fileNames.push(name)
|
||||
fileNames.push(name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
+11
-11
@@ -25,7 +25,7 @@ namespace ts {
|
||||
contains,
|
||||
remove,
|
||||
forEachValue: forEachValueInMap
|
||||
}
|
||||
};
|
||||
|
||||
function set(fileName: string, value: T) {
|
||||
files[normalizeKey(fileName)] = value;
|
||||
@@ -170,7 +170,7 @@ namespace ts {
|
||||
to.push(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function rangeEquals<T>(array1: T[], array2: T[], pos: number, end: number) {
|
||||
while (pos < end) {
|
||||
@@ -372,7 +372,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
let text = getLocaleSpecificMessage(message.key);
|
||||
|
||||
|
||||
if (arguments.length > 4) {
|
||||
text = formatStringFromArgs(text, arguments, 4);
|
||||
}
|
||||
@@ -542,7 +542,7 @@ namespace ts {
|
||||
else {
|
||||
// A part may be an empty string (which is 'falsy') if the path had consecutive slashes,
|
||||
// e.g. "path//file.ts". Drop these before re-joining the parts.
|
||||
if(part) {
|
||||
if (part) {
|
||||
normalized.push(part);
|
||||
}
|
||||
}
|
||||
@@ -600,20 +600,20 @@ namespace ts {
|
||||
|
||||
function getNormalizedPathComponentsOfUrl(url: string) {
|
||||
// Get root length of http://www.website.com/folder1/foler2/
|
||||
// In this example the root is: http://www.website.com/
|
||||
// In this example the root is: http://www.website.com/
|
||||
// normalized path components should be ["http://www.website.com/", "folder1", "folder2"]
|
||||
|
||||
let urlLength = url.length;
|
||||
// Initial root length is http:// part
|
||||
let rootLength = url.indexOf("://") + "://".length;
|
||||
while (rootLength < urlLength) {
|
||||
// Consume all immediate slashes in the protocol
|
||||
// Consume all immediate slashes in the protocol
|
||||
// eg.initial rootlength is just file:// but it needs to consume another "/" in file:///
|
||||
if (url.charCodeAt(rootLength) === CharacterCodes.slash) {
|
||||
rootLength++;
|
||||
}
|
||||
else {
|
||||
// non slash character means we continue proceeding to next component of root search
|
||||
// non slash character means we continue proceeding to next component of root search
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -626,15 +626,15 @@ namespace ts {
|
||||
// Find the index of "/" after website.com so the root can be http://www.website.com/ (from existing http://)
|
||||
let indexOfNextSlash = url.indexOf(directorySeparator, rootLength);
|
||||
if (indexOfNextSlash !== -1) {
|
||||
// Found the "/" after the website.com so the root is length of http://www.website.com/
|
||||
// Found the "/" after the website.com so the root is length of http://www.website.com/
|
||||
// and get components afetr the root normally like any other folder components
|
||||
rootLength = indexOfNextSlash + 1;
|
||||
return normalizedPathComponents(url, rootLength);
|
||||
}
|
||||
else {
|
||||
// Can't find the host assume the rest of the string as component
|
||||
// Can't find the host assume the rest of the string as component
|
||||
// but make sure we append "/" to it as root is not joined using "/"
|
||||
// eg. if url passed in was http://website.com we want to use root as [http://website.com/]
|
||||
// eg. if url passed in was http://website.com we want to use root as [http://website.com/]
|
||||
// so that other path manipulations will be correct and it can be merged with relative paths correctly
|
||||
return [url + directorySeparator];
|
||||
}
|
||||
@@ -774,7 +774,7 @@ namespace ts {
|
||||
getSymbolConstructor: () => <any>Symbol,
|
||||
getTypeConstructor: () => <any>Type,
|
||||
getSignatureConstructor: () => <any>Signature
|
||||
}
|
||||
};
|
||||
|
||||
export const enum AssertionLevel {
|
||||
None = 0,
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace ts {
|
||||
moduleElementDeclarationEmitInfo,
|
||||
synchronousDeclarationOutput: writer.getText(),
|
||||
referencePathsOutput,
|
||||
}
|
||||
};
|
||||
|
||||
function hasInternalAnnotation(range: CommentRange) {
|
||||
let text = currentSourceFile.text;
|
||||
@@ -188,7 +188,7 @@ namespace ts {
|
||||
if (!moduleElementEmitInfo && asynchronousSubModuleDeclarationEmitInfo) {
|
||||
moduleElementEmitInfo = forEach(asynchronousSubModuleDeclarationEmitInfo, declEmitInfo => declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined);
|
||||
}
|
||||
|
||||
|
||||
// If the alias was marked as not visible when we saw its declaration, we would have saved the aliasEmitInfo, but if we haven't yet visited the alias declaration
|
||||
// then we don't need to write it at this point. We will write it when we actually see its declaration
|
||||
// Eg.
|
||||
@@ -198,7 +198,7 @@ namespace ts {
|
||||
// we would write alias foo declaration when we visit it since it would now be marked as visible
|
||||
if (moduleElementEmitInfo) {
|
||||
if (moduleElementEmitInfo.node.kind === SyntaxKind.ImportDeclaration) {
|
||||
// we have to create asynchronous output only after we have collected complete information
|
||||
// we have to create asynchronous output only after we have collected complete information
|
||||
// because it is possible to enable multiple bindings as asynchronously visible
|
||||
moduleElementEmitInfo.isVisible = true;
|
||||
}
|
||||
@@ -353,6 +353,21 @@ namespace ts {
|
||||
return emitEntityName(<Identifier>type);
|
||||
case SyntaxKind.QualifiedName:
|
||||
return emitEntityName(<QualifiedName>type);
|
||||
case SyntaxKind.TypePredicate:
|
||||
return emitTypePredicate(<TypePredicateNode>type);
|
||||
}
|
||||
|
||||
function writeEntityName(entityName: EntityName | Expression) {
|
||||
if (entityName.kind === SyntaxKind.Identifier) {
|
||||
writeTextOfNode(currentSourceFile, entityName);
|
||||
}
|
||||
else {
|
||||
let left = entityName.kind === SyntaxKind.QualifiedName ? (<QualifiedName>entityName).left : (<PropertyAccessExpression>entityName).expression;
|
||||
let right = entityName.kind === SyntaxKind.QualifiedName ? (<QualifiedName>entityName).right : (<PropertyAccessExpression>entityName).name;
|
||||
writeEntityName(left);
|
||||
write(".");
|
||||
writeTextOfNode(currentSourceFile, right);
|
||||
}
|
||||
}
|
||||
|
||||
function emitEntityName(entityName: EntityName | PropertyAccessExpression) {
|
||||
@@ -362,19 +377,6 @@ namespace ts {
|
||||
|
||||
handleSymbolAccessibilityError(visibilityResult);
|
||||
writeEntityName(entityName);
|
||||
|
||||
function writeEntityName(entityName: EntityName | Expression) {
|
||||
if (entityName.kind === SyntaxKind.Identifier) {
|
||||
writeTextOfNode(currentSourceFile, entityName);
|
||||
}
|
||||
else {
|
||||
let left = entityName.kind === SyntaxKind.QualifiedName ? (<QualifiedName>entityName).left : (<PropertyAccessExpression>entityName).expression;
|
||||
let right = entityName.kind === SyntaxKind.QualifiedName ? (<QualifiedName>entityName).right : (<PropertyAccessExpression>entityName).name;
|
||||
writeEntityName(left);
|
||||
write(".");
|
||||
writeTextOfNode(currentSourceFile, right);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function emitExpressionWithTypeArguments(node: ExpressionWithTypeArguments) {
|
||||
@@ -398,6 +400,12 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function emitTypePredicate(type: TypePredicateNode) {
|
||||
writeTextOfNode(currentSourceFile, type.parameterName);
|
||||
write(" is ");
|
||||
emitType(type.type);
|
||||
}
|
||||
|
||||
function emitTypeQuery(type: TypeQueryNode) {
|
||||
write("typeof ");
|
||||
emitEntityName(type.exprName);
|
||||
@@ -600,7 +608,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function writeImportEqualsDeclaration(node: ImportEqualsDeclaration) {
|
||||
// note usage of writer. methods instead of aliases created, just to make sure we are using
|
||||
// note usage of writer. methods instead of aliases created, just to make sure we are using
|
||||
// correct writer especially to handle asynchronous alias writing
|
||||
emitJsDocComments(node);
|
||||
if (node.flags & NodeFlags.Export) {
|
||||
@@ -642,7 +650,7 @@ namespace ts {
|
||||
|
||||
function writeImportDeclaration(node: ImportDeclaration) {
|
||||
if (!node.importClause && !(node.flags & NodeFlags.Export)) {
|
||||
// do not write non-exported import declarations that don't have import clauses
|
||||
// do not write non-exported import declarations that don't have import clauses
|
||||
return;
|
||||
}
|
||||
emitJsDocComments(node);
|
||||
@@ -764,7 +772,7 @@ namespace ts {
|
||||
emitJsDocComments(node);
|
||||
emitModuleElementDeclarationFlags(node);
|
||||
if (isConst(node)) {
|
||||
write("const ")
|
||||
write("const ");
|
||||
}
|
||||
write("enum ");
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
@@ -1343,7 +1351,7 @@ namespace ts {
|
||||
|
||||
return {
|
||||
diagnosticMessage,
|
||||
errorNode: <Node>node.name || node,
|
||||
errorNode: <Node>node.name || node
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1517,7 +1525,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function emitNode(node: Node) {
|
||||
@@ -1565,7 +1573,7 @@ namespace ts {
|
||||
? referencedFile.fileName // Declaration file, use declaration file name
|
||||
: shouldEmitToOwnFile(referencedFile, compilerOptions)
|
||||
? getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file
|
||||
: removeFileExtension(compilerOptions.out) + ".d.ts";// Global out file
|
||||
: removeFileExtension(compilerOptions.out) + ".d.ts"; // Global out file
|
||||
|
||||
declFileName = getRelativePathToDirectoryOrUrl(
|
||||
getDirectoryPath(normalizeSlashes(jsFilePath)),
|
||||
@@ -1577,7 +1585,7 @@ namespace ts {
|
||||
referencePathsOutput += "/// <reference path=\"" + declFileName + "\" />" + newLine;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* @internal */
|
||||
export function writeDeclarationFile(jsFilePath: string, sourceFile: SourceFile, host: EmitHost, resolver: EmitResolver, diagnostics: Diagnostic[]) {
|
||||
let emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile);
|
||||
@@ -1604,4 +1612,4 @@ namespace ts {
|
||||
return declarationOutput;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,7 +407,7 @@ namespace ts {
|
||||
Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: DiagnosticCategory.Error, key: "Classes containing abstract methods must be marked abstract." },
|
||||
Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." },
|
||||
All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." },
|
||||
Constructor_objects_of_abstract_type_cannot_be_assigned_to_constructor_objects_of_non_abstract_type: { code: 2517, category: DiagnosticCategory.Error, key: "Constructor objects of abstract type cannot be assigned to constructor objects of non-abstract type" },
|
||||
Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: DiagnosticCategory.Error, key: "Cannot assign an abstract constructor type to a non-abstract constructor type." },
|
||||
Only_an_ambient_class_can_be_merged_with_an_interface: { code: 2518, category: DiagnosticCategory.Error, key: "Only an ambient class can be merged with an interface." },
|
||||
Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." },
|
||||
Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." },
|
||||
|
||||
@@ -1617,7 +1617,7 @@
|
||||
"category": "Error",
|
||||
"code": 2516
|
||||
},
|
||||
"Constructor objects of abstract type cannot be assigned to constructor objects of non-abstract type": {
|
||||
"Cannot assign an abstract constructor type to a non-abstract constructor type.": {
|
||||
"category": "Error",
|
||||
"code":2517
|
||||
},
|
||||
|
||||
+395
-162
File diff suppressed because it is too large
Load Diff
+92
-86
@@ -410,7 +410,7 @@ namespace ts {
|
||||
export function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile {
|
||||
return IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
|
||||
}
|
||||
|
||||
|
||||
/* @internal */
|
||||
export function parseIsolatedJSDocComment(content: string, start?: number, length?: number) {
|
||||
return Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length);
|
||||
@@ -585,7 +585,7 @@ namespace ts {
|
||||
fixupParentReferences(sourceFile);
|
||||
}
|
||||
|
||||
// If this is a javascript file, proactively see if we can get JSDoc comments for
|
||||
// If this is a javascript file, proactively see if we can get JSDoc comments for
|
||||
// relevant nodes in the file. We'll use these to provide typing informaion if they're
|
||||
// available.
|
||||
if (isJavaScript(fileName)) {
|
||||
@@ -685,17 +685,17 @@ namespace ts {
|
||||
function setDecoratorContext(val: boolean) {
|
||||
setContextFlag(val, ParserContextFlags.Decorator);
|
||||
}
|
||||
|
||||
|
||||
function setAwaitContext(val: boolean) {
|
||||
setContextFlag(val, ParserContextFlags.Await);
|
||||
}
|
||||
|
||||
|
||||
function doOutsideOfContext<T>(context: ParserContextFlags, func: () => T): T {
|
||||
// contextFlagsToClear will contain only the context flags that are
|
||||
// contextFlagsToClear will contain only the context flags that are
|
||||
// currently set that we need to temporarily clear
|
||||
// We don't just blindly reset to the previous flags to ensure
|
||||
// that we do not mutate cached flags for the incremental
|
||||
// parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and
|
||||
// parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and
|
||||
// HasAggregatedChildData).
|
||||
let contextFlagsToClear = context & contextFlags;
|
||||
if (contextFlagsToClear) {
|
||||
@@ -710,13 +710,13 @@ namespace ts {
|
||||
// no need to do anything special as we are not in any of the requested contexts
|
||||
return func();
|
||||
}
|
||||
|
||||
|
||||
function doInsideOfContext<T>(context: ParserContextFlags, func: () => T): T {
|
||||
// contextFlagsToSet will contain only the context flags that
|
||||
// are not currently set that we need to temporarily enable.
|
||||
// We don't just blindly reset to the previous flags to ensure
|
||||
// that we do not mutate cached flags for the incremental
|
||||
// parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and
|
||||
// parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and
|
||||
// HasAggregatedChildData).
|
||||
let contextFlagsToSet = context & ~contextFlags;
|
||||
if (contextFlagsToSet) {
|
||||
@@ -727,11 +727,11 @@ namespace ts {
|
||||
setContextFlag(false, contextFlagsToSet);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// no need to do anything special as we are already in all of the requested contexts
|
||||
return func();
|
||||
}
|
||||
|
||||
|
||||
function allowInAnd<T>(func: () => T): T {
|
||||
return doOutsideOfContext(ParserContextFlags.DisallowIn, func);
|
||||
}
|
||||
@@ -739,7 +739,7 @@ namespace ts {
|
||||
function disallowInAnd<T>(func: () => T): T {
|
||||
return doInsideOfContext(ParserContextFlags.DisallowIn, func);
|
||||
}
|
||||
|
||||
|
||||
function doInYieldContext<T>(func: () => T): T {
|
||||
return doInsideOfContext(ParserContextFlags.Yield, func);
|
||||
}
|
||||
@@ -751,23 +751,23 @@ namespace ts {
|
||||
function doInDecoratorContext<T>(func: () => T): T {
|
||||
return doInsideOfContext(ParserContextFlags.Decorator, func);
|
||||
}
|
||||
|
||||
|
||||
function doInAwaitContext<T>(func: () => T): T {
|
||||
return doInsideOfContext(ParserContextFlags.Await, func);
|
||||
}
|
||||
|
||||
|
||||
function doOutsideOfAwaitContext<T>(func: () => T): T {
|
||||
return doOutsideOfContext(ParserContextFlags.Await, func);
|
||||
}
|
||||
|
||||
|
||||
function doInYieldAndAwaitContext<T>(func: () => T): T {
|
||||
return doInsideOfContext(ParserContextFlags.Yield | ParserContextFlags.Await, func);
|
||||
}
|
||||
|
||||
|
||||
function doOutsideOfYieldAndAwaitContext<T>(func: () => T): T {
|
||||
return doOutsideOfContext(ParserContextFlags.Yield | ParserContextFlags.Await, func);
|
||||
}
|
||||
|
||||
|
||||
function inContext(flags: ParserContextFlags) {
|
||||
return (contextFlags & flags) !== 0;
|
||||
}
|
||||
@@ -787,7 +787,7 @@ namespace ts {
|
||||
function inAwaitContext() {
|
||||
return inContext(ParserContextFlags.Await);
|
||||
}
|
||||
|
||||
|
||||
function parseErrorAtCurrentToken(message: DiagnosticMessage, arg0?: any): void {
|
||||
let start = scanner.getTokenPos();
|
||||
let length = scanner.getTextPos() - start;
|
||||
@@ -843,7 +843,7 @@ namespace ts {
|
||||
function scanJsxIdentifier(): SyntaxKind {
|
||||
return token = scanner.scanJsxIdentifier();
|
||||
}
|
||||
|
||||
|
||||
function speculationHelper<T>(callback: () => T, isLookAhead: boolean): T {
|
||||
// Keep track of the state we'll need to rollback to if lookahead fails (or if the
|
||||
// caller asked us to always reset our state).
|
||||
@@ -903,7 +903,7 @@ namespace ts {
|
||||
if (token === SyntaxKind.YieldKeyword && inYieldContext()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// If we have a 'await' keyword, and we're in the [Await] context, then 'await' is
|
||||
// considered a keyword and is not an identifier.
|
||||
if (token === SyntaxKind.AwaitKeyword && inAwaitContext()) {
|
||||
@@ -1102,7 +1102,7 @@ namespace ts {
|
||||
function parseContextualModifier(t: SyntaxKind): boolean {
|
||||
return token === t && tryParse(nextTokenCanFollowModifier);
|
||||
}
|
||||
|
||||
|
||||
function nextTokenCanFollowModifier() {
|
||||
if (token === SyntaxKind.ConstKeyword) {
|
||||
// 'const' is only a modifier if followed by 'enum'.
|
||||
@@ -1121,7 +1121,7 @@ namespace ts {
|
||||
nextToken();
|
||||
return canFollowModifier();
|
||||
}
|
||||
|
||||
|
||||
function parseAnyContextualModifier(): boolean {
|
||||
return isModifier(token) && tryParse(nextTokenCanFollowModifier);
|
||||
}
|
||||
@@ -1229,7 +1229,7 @@ namespace ts {
|
||||
// if we see "extends {}" then only treat the {} as what we're extending (and not
|
||||
// the class body) if we have:
|
||||
//
|
||||
// extends {} {
|
||||
// extends {} {
|
||||
// extends {},
|
||||
// extends {} extends
|
||||
// extends {} implements
|
||||
@@ -1844,7 +1844,7 @@ namespace ts {
|
||||
do {
|
||||
templateSpans.push(parseTemplateSpan());
|
||||
}
|
||||
while (lastOrUndefined(templateSpans).literal.kind === SyntaxKind.TemplateMiddle)
|
||||
while (lastOrUndefined(templateSpans).literal.kind === SyntaxKind.TemplateMiddle);
|
||||
|
||||
templateSpans.end = getNodeEnd();
|
||||
template.templateSpans = templateSpans;
|
||||
@@ -1859,7 +1859,7 @@ namespace ts {
|
||||
let literal: LiteralExpression;
|
||||
|
||||
if (token === SyntaxKind.CloseBraceToken) {
|
||||
reScanTemplateToken()
|
||||
reScanTemplateToken();
|
||||
literal = parseLiteralNode();
|
||||
}
|
||||
else {
|
||||
@@ -2019,7 +2019,7 @@ namespace ts {
|
||||
// ambient contexts.
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
|
||||
function parseBindingElementInitializer(inParameter: boolean) {
|
||||
return inParameter ? parseParameterInitializer() : parseNonParameterInitializer();
|
||||
}
|
||||
@@ -2027,7 +2027,7 @@ namespace ts {
|
||||
function parseParameterInitializer() {
|
||||
return parseInitializer(/*inParameter*/ true);
|
||||
}
|
||||
|
||||
|
||||
function fillSignature(
|
||||
returnToken: SyntaxKind,
|
||||
yieldContext: boolean,
|
||||
@@ -2065,15 +2065,15 @@ namespace ts {
|
||||
if (parseExpected(SyntaxKind.OpenParenToken)) {
|
||||
let savedYieldContext = inYieldContext();
|
||||
let savedAwaitContext = inAwaitContext();
|
||||
|
||||
|
||||
setYieldContext(yieldContext);
|
||||
setAwaitContext(awaitContext);
|
||||
|
||||
|
||||
let result = parseDelimitedList(ParsingContext.Parameters, parseParameter);
|
||||
|
||||
|
||||
setYieldContext(savedYieldContext);
|
||||
setAwaitContext(savedAwaitContext);
|
||||
|
||||
|
||||
if (!parseExpected(SyntaxKind.CloseParenToken) && requireCompleteParameterList) {
|
||||
// Caller insisted that we had to end with a ) We didn't. So just return
|
||||
// undefined here.
|
||||
@@ -2088,7 +2088,7 @@ namespace ts {
|
||||
// then just return an empty set of parameters.
|
||||
return requireCompleteParameterList ? undefined : createMissingList<ParameterDeclaration>();
|
||||
}
|
||||
|
||||
|
||||
function parseTypeMemberSemicolon() {
|
||||
// We allow type members to be separated by commas or (possibly ASI) semicolons.
|
||||
// First check if it was a comma. If so, we're done with the member.
|
||||
@@ -2180,7 +2180,7 @@ namespace ts {
|
||||
node.parameters = parseBracketedList(ParsingContext.Parameters, parseParameter, SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken);
|
||||
node.type = parseTypeAnnotation();
|
||||
parseTypeMemberSemicolon();
|
||||
return finishNode(node)
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parsePropertyOrMethodSignature(): Declaration {
|
||||
@@ -2471,7 +2471,7 @@ namespace ts {
|
||||
|
||||
function parseType(): TypeNode {
|
||||
// The rules about 'yield' only apply to actual code/expression contexts. They don't
|
||||
// apply to 'type' contexts. So we disable these parameters here before moving on.
|
||||
// apply to 'type' contexts. So we disable these parameters here before moving on.
|
||||
return doOutsideOfContext(ParserContextFlags.TypeExcludesFlags, parseTypeWorker);
|
||||
}
|
||||
|
||||
@@ -2559,7 +2559,7 @@ namespace ts {
|
||||
token !== SyntaxKind.AtToken &&
|
||||
isStartOfExpression();
|
||||
}
|
||||
|
||||
|
||||
function allowInAndParseExpression(): Expression {
|
||||
return allowInAnd(parseExpression);
|
||||
}
|
||||
@@ -2748,7 +2748,7 @@ namespace ts {
|
||||
// It's definitely not a parenthesized arrow function expression.
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
// If we definitely have an arrow function, then we can just parse one, not requiring a
|
||||
// following => or { token. Otherwise, we *might* have an arrow function. Try to parse
|
||||
// it out, but don't allow any ambiguity, and return 'undefined' if this could be an
|
||||
@@ -2761,12 +2761,12 @@ namespace ts {
|
||||
// Didn't appear to actually be a parenthesized arrow function. Just bail out.
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
let isAsync = !!(arrowFunction.flags & NodeFlags.Async);
|
||||
|
||||
// If we have an arrow, then try to parse the body. Even if not, try to parse if we
|
||||
// have an opening brace, just in case we're in an error state.
|
||||
var lastToken = token;
|
||||
let lastToken = token;
|
||||
arrowFunction.equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken, /*reportAtCurrentPosition*/false, Diagnostics._0_expected, "=>");
|
||||
arrowFunction.body = (lastToken === SyntaxKind.EqualsGreaterThanToken || lastToken === SyntaxKind.OpenBraceToken)
|
||||
? parseArrowFunctionExpressionBody(isAsync)
|
||||
@@ -2804,7 +2804,7 @@ namespace ts {
|
||||
return Tristate.False;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let first = token;
|
||||
let second = nextToken();
|
||||
|
||||
@@ -2892,7 +2892,7 @@ namespace ts {
|
||||
if (isArrowFunctionInJsx) {
|
||||
return Tristate.True;
|
||||
}
|
||||
|
||||
|
||||
return Tristate.False;
|
||||
}
|
||||
|
||||
@@ -2909,7 +2909,7 @@ namespace ts {
|
||||
let node = <ArrowFunction>createNode(SyntaxKind.ArrowFunction);
|
||||
setModifiers(node, parseModifiersForArrowFunction());
|
||||
let isAsync = !!(node.flags & NodeFlags.Async);
|
||||
|
||||
|
||||
// Arrow functions are never generators.
|
||||
//
|
||||
// If we're speculatively parsing a signature for a parenthesized arrow function, then
|
||||
@@ -2966,7 +2966,7 @@ namespace ts {
|
||||
// Note: even when 'ignoreMissingOpenBrace' is passed as true, parseBody will still error.
|
||||
return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ true);
|
||||
}
|
||||
|
||||
|
||||
return isAsync
|
||||
? doInAwaitContext(parseAssignmentExpressionOrHigher)
|
||||
: doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
|
||||
@@ -3133,7 +3133,7 @@ namespace ts {
|
||||
node.expression = parseUnaryExpressionOrHigher();
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
|
||||
function isAwaitExpression(): boolean {
|
||||
if (token === SyntaxKind.AwaitKeyword) {
|
||||
if (inAwaitContext()) {
|
||||
@@ -3158,7 +3158,7 @@ namespace ts {
|
||||
if (isAwaitExpression()) {
|
||||
return parseAwaitExpression();
|
||||
}
|
||||
|
||||
|
||||
switch (token) {
|
||||
case SyntaxKind.PlusToken:
|
||||
case SyntaxKind.MinusToken:
|
||||
@@ -3177,7 +3177,7 @@ namespace ts {
|
||||
if (sourceFile.languageVariant !== LanguageVariant.JSX) {
|
||||
return parseTypeAssertion();
|
||||
}
|
||||
if(lookAhead(nextTokenIsIdentifierOrKeyword)) {
|
||||
if (lookAhead(nextTokenIsIdentifierOrKeyword)) {
|
||||
return parseJsxElementOrSelfClosingElement();
|
||||
}
|
||||
// Fall through
|
||||
@@ -3295,7 +3295,7 @@ namespace ts {
|
||||
|
||||
function parseSuperExpression(): MemberExpression {
|
||||
let expression = parseTokenNode<PrimaryExpression>();
|
||||
if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.DotToken) {
|
||||
if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.DotToken || token === SyntaxKind.OpenBracketToken) {
|
||||
return expression;
|
||||
}
|
||||
|
||||
@@ -3307,7 +3307,7 @@ namespace ts {
|
||||
node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true);
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
|
||||
function parseJsxElementOrSelfClosingElement(): JsxElement|JsxSelfClosingElement {
|
||||
let opening = parseJsxOpeningOrSelfClosingElement();
|
||||
if (opening.kind === SyntaxKind.JsxOpeningElement) {
|
||||
@@ -3349,7 +3349,7 @@ namespace ts {
|
||||
let saveParsingContext = parsingContext;
|
||||
parsingContext |= 1 << ParsingContext.JsxChildren;
|
||||
|
||||
while(true) {
|
||||
while (true) {
|
||||
token = scanner.reScanJsxToken();
|
||||
if (token === SyntaxKind.LessThanSlashToken) {
|
||||
break;
|
||||
@@ -3367,7 +3367,7 @@ namespace ts {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
function parseJsxOpeningOrSelfClosingElement(): JsxOpeningElement|JsxSelfClosingElement {
|
||||
let fullStart = scanner.getStartPos();
|
||||
|
||||
@@ -3392,7 +3392,7 @@ namespace ts {
|
||||
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
|
||||
function parseJsxElementName(): EntityName {
|
||||
scanJsxIdentifier();
|
||||
let elementName: EntityName = parseIdentifierName();
|
||||
@@ -3477,7 +3477,7 @@ namespace ts {
|
||||
continue;
|
||||
}
|
||||
|
||||
// when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName
|
||||
// when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName
|
||||
if (!inDecoratorContext() && parseOptional(SyntaxKind.OpenBracketToken)) {
|
||||
let indexedAccess = <ElementAccessExpression>createNode(SyntaxKind.ElementAccessExpression, expression.pos);
|
||||
indexedAccess.expression = expression;
|
||||
@@ -3599,7 +3599,7 @@ namespace ts {
|
||||
case SyntaxKind.CommaToken: // foo<x>,
|
||||
case SyntaxKind.OpenBraceToken: // foo<x> {
|
||||
// We don't want to treat these as type arguments. Otherwise we'll parse this
|
||||
// as an invocation expression. Instead, we want to parse out the expression
|
||||
// as an invocation expression. Instead, we want to parse out the expression
|
||||
// in isolation from the type arguments.
|
||||
|
||||
default:
|
||||
@@ -3627,7 +3627,7 @@ namespace ts {
|
||||
case SyntaxKind.OpenBraceToken:
|
||||
return parseObjectLiteralExpression();
|
||||
case SyntaxKind.AsyncKeyword:
|
||||
// Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher.
|
||||
// Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher.
|
||||
// If we encounter `async [no LineTerminator here] function` then this is an async
|
||||
// function; otherwise, its an identifier.
|
||||
if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) {
|
||||
@@ -3759,12 +3759,12 @@ namespace ts {
|
||||
if (saveDecoratorContext) {
|
||||
setDecoratorContext(false);
|
||||
}
|
||||
|
||||
|
||||
let node = <FunctionExpression>createNode(SyntaxKind.FunctionExpression);
|
||||
setModifiers(node, parseModifiers());
|
||||
parseExpected(SyntaxKind.FunctionKeyword);
|
||||
node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken);
|
||||
|
||||
|
||||
let isGenerator = !!node.asteriskToken;
|
||||
let isAsync = !!(node.flags & NodeFlags.Async);
|
||||
node.name =
|
||||
@@ -3772,14 +3772,14 @@ namespace ts {
|
||||
isGenerator ? doInYieldContext(parseOptionalIdentifier) :
|
||||
isAsync ? doInAwaitContext(parseOptionalIdentifier) :
|
||||
parseOptionalIdentifier();
|
||||
|
||||
|
||||
fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node);
|
||||
node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false);
|
||||
|
||||
|
||||
if (saveDecoratorContext) {
|
||||
setDecoratorContext(true);
|
||||
}
|
||||
|
||||
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
@@ -3815,11 +3815,11 @@ namespace ts {
|
||||
function parseFunctionBlock(allowYield: boolean, allowAwait: boolean, ignoreMissingOpenBrace: boolean, diagnosticMessage?: DiagnosticMessage): Block {
|
||||
let savedYieldContext = inYieldContext();
|
||||
setYieldContext(allowYield);
|
||||
|
||||
|
||||
let savedAwaitContext = inAwaitContext();
|
||||
setAwaitContext(allowAwait);
|
||||
|
||||
// We may be in a [Decorator] context when parsing a function expression or
|
||||
// We may be in a [Decorator] context when parsing a function expression or
|
||||
// arrow function. The body of the function is not in [Decorator] context.
|
||||
let saveDecoratorContext = inDecoratorContext();
|
||||
if (saveDecoratorContext) {
|
||||
@@ -4081,7 +4081,7 @@ namespace ts {
|
||||
nextToken();
|
||||
return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak();
|
||||
}
|
||||
|
||||
|
||||
function nextTokenIsFunctionKeywordOnSameLine() {
|
||||
nextToken();
|
||||
return token === SyntaxKind.FunctionKeyword && !scanner.hasPrecedingLineBreak();
|
||||
@@ -4150,7 +4150,7 @@ namespace ts {
|
||||
return true;
|
||||
}
|
||||
continue;
|
||||
|
||||
|
||||
case SyntaxKind.PublicKeyword:
|
||||
case SyntaxKind.PrivateKeyword:
|
||||
case SyntaxKind.ProtectedKeyword:
|
||||
@@ -4229,7 +4229,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function isLetDeclaration() {
|
||||
// In ES6 'let' always starts a lexical declaration if followed by an identifier or {
|
||||
// In ES6 'let' always starts a lexical declaration if followed by an identifier or {
|
||||
// or [.
|
||||
return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring);
|
||||
}
|
||||
@@ -4335,7 +4335,7 @@ namespace ts {
|
||||
default:
|
||||
if (decorators || modifiers) {
|
||||
// We reached this point because we encountered decorators and/or modifiers and assumed a declaration
|
||||
// would follow. For recovery and error reporting purposes, return an incomplete declaration.
|
||||
// would follow. For recovery and error reporting purposes, return an incomplete declaration.
|
||||
let node = <Statement>createMissingNode(SyntaxKind.MissingDeclaration, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected);
|
||||
node.pos = fullStart;
|
||||
node.decorators = decorators;
|
||||
@@ -4550,7 +4550,7 @@ namespace ts {
|
||||
function parsePropertyOrMethodDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ClassElement {
|
||||
let asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken);
|
||||
let name = parsePropertyName();
|
||||
|
||||
|
||||
// Note: this is not legal as per the grammar. But we allow it in the parser and
|
||||
// report an error in the grammar checker.
|
||||
let questionToken = parseOptionalToken(SyntaxKind.QuestionToken);
|
||||
@@ -4694,7 +4694,7 @@ namespace ts {
|
||||
modifiers = <ModifiersArray>[];
|
||||
modifiers.pos = modifierStart;
|
||||
}
|
||||
|
||||
|
||||
flags |= modifierToFlag(modifierKind);
|
||||
modifiers.push(finishNode(createNode(modifierKind, modifierStart)));
|
||||
}
|
||||
@@ -4719,7 +4719,7 @@ namespace ts {
|
||||
modifiers.flags = flags;
|
||||
modifiers.end = scanner.getStartPos();
|
||||
}
|
||||
|
||||
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
@@ -4779,9 +4779,9 @@ namespace ts {
|
||||
function parseClassDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ClassDeclaration {
|
||||
return <ClassDeclaration>parseClassDeclarationOrExpression(fullStart, decorators, modifiers, SyntaxKind.ClassDeclaration);
|
||||
}
|
||||
|
||||
|
||||
function parseClassDeclarationOrExpression(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray, kind: SyntaxKind): ClassLikeDeclaration {
|
||||
var node = <ClassLikeDeclaration>createNode(kind, fullStart);
|
||||
let node = <ClassLikeDeclaration>createNode(kind, fullStart);
|
||||
node.decorators = decorators;
|
||||
setModifiers(node, modifiers);
|
||||
parseExpected(SyntaxKind.ClassKeyword);
|
||||
@@ -4791,7 +4791,7 @@ namespace ts {
|
||||
|
||||
if (parseExpected(SyntaxKind.OpenBraceToken)) {
|
||||
// ClassTail[Yield,Await] : (Modified) See 14.5
|
||||
// ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt }
|
||||
// ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt }
|
||||
node.members = parseClassMembers();
|
||||
parseExpected(SyntaxKind.CloseBraceToken);
|
||||
}
|
||||
@@ -5008,7 +5008,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function parseImportClause(identifier: Identifier, fullStart: number) {
|
||||
//ImportClause:
|
||||
// ImportClause:
|
||||
// ImportedDefaultBinding
|
||||
// NameSpaceImport
|
||||
// NamedImports
|
||||
@@ -5135,7 +5135,12 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
node.exportClause = parseNamedImportsOrExports(SyntaxKind.NamedExports);
|
||||
if (parseOptional(SyntaxKind.FromKeyword)) {
|
||||
|
||||
// It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios,
|
||||
// the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`)
|
||||
// If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect.
|
||||
if (token === SyntaxKind.FromKeyword || (token === SyntaxKind.StringLiteral && !scanner.hasPrecedingLineBreak())) {
|
||||
parseExpected(SyntaxKind.FromKeyword)
|
||||
node.moduleSpecifier = parseModuleSpecifier();
|
||||
}
|
||||
}
|
||||
@@ -5301,7 +5306,7 @@ namespace ts {
|
||||
/* @internal */
|
||||
export function parseJSDocTypeExpression(start: number, length: number): JSDocTypeExpression {
|
||||
scanner.setText(sourceText, start, length);
|
||||
|
||||
|
||||
// Prime the first token for us to start processing.
|
||||
token = nextToken();
|
||||
|
||||
@@ -5316,15 +5321,15 @@ namespace ts {
|
||||
}
|
||||
|
||||
function parseJSDocTopLevelType(): JSDocType {
|
||||
var type = parseJSDocType();
|
||||
let type = parseJSDocType();
|
||||
if (token === SyntaxKind.BarToken) {
|
||||
var unionType = <JSDocUnionType>createNode(SyntaxKind.JSDocUnionType, type.pos);
|
||||
let unionType = <JSDocUnionType>createNode(SyntaxKind.JSDocUnionType, type.pos);
|
||||
unionType.types = parseJSDocTypeList(type);
|
||||
type = finishNode(unionType);
|
||||
}
|
||||
|
||||
if (token === SyntaxKind.EqualsToken) {
|
||||
var optionalType = <JSDocOptionalType>createNode(SyntaxKind.JSDocOptionalType, type.pos);
|
||||
let optionalType = <JSDocOptionalType>createNode(SyntaxKind.JSDocOptionalType, type.pos);
|
||||
nextToken();
|
||||
optionalType.type = type;
|
||||
type = finishNode(optionalType);
|
||||
@@ -5638,9 +5643,9 @@ namespace ts {
|
||||
|
||||
let tags: NodeArray<JSDocTag>;
|
||||
let pos: number;
|
||||
|
||||
// NOTE(cyrusn): This is essentially a handwritten scanner for JSDocComments. I
|
||||
// considered using an actual Scanner, but this would complicate things. The
|
||||
|
||||
// NOTE(cyrusn): This is essentially a handwritten scanner for JSDocComments. I
|
||||
// considered using an actual Scanner, but this would complicate things. The
|
||||
// scanner would need to know it was in a Doc Comment. Otherwise, it would then
|
||||
// produce comments *inside* the doc comment. In the end it was just easier to
|
||||
// write a simple scanner rather than go that route.
|
||||
@@ -5655,13 +5660,13 @@ namespace ts {
|
||||
let canParseTag = true;
|
||||
let seenAsterisk = true;
|
||||
|
||||
for (pos = start + "/**".length; pos < end;) {
|
||||
for (pos = start + "/**".length; pos < end; ) {
|
||||
let ch = content.charCodeAt(pos);
|
||||
pos++;
|
||||
|
||||
if (ch === CharacterCodes.at && canParseTag) {
|
||||
parseTag();
|
||||
|
||||
|
||||
// Once we parse out a tag, we cannot keep parsing out tags on this line.
|
||||
canParseTag = false;
|
||||
continue;
|
||||
@@ -5927,7 +5932,7 @@ namespace ts {
|
||||
if (sourceFile.statements.length === 0) {
|
||||
// If we don't have any statements in the current source file, then there's no real
|
||||
// way to incrementally parse. So just do a full parse instead.
|
||||
return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setNodeParents*/ true)
|
||||
return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setNodeParents*/ true);
|
||||
}
|
||||
|
||||
// Make sure we're not trying to incrementally update a source file more than once. Once
|
||||
@@ -5991,7 +5996,7 @@ namespace ts {
|
||||
// inconsistent tree. Setting the parents on the new tree should be very fast. We
|
||||
// will immediately bail out of walking any subtrees when we can see that their parents
|
||||
// are already correct.
|
||||
let result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /* setParentNode */ true)
|
||||
let result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /* setParentNode */ true);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -6006,8 +6011,9 @@ namespace ts {
|
||||
return;
|
||||
|
||||
function visitNode(node: IncrementalNode) {
|
||||
let text = '';
|
||||
if (aggressiveChecks && shouldCheckNode(node)) {
|
||||
var text = oldText.substring(node.pos, node.end);
|
||||
text = oldText.substring(node.pos, node.end);
|
||||
}
|
||||
|
||||
// Ditch any existing LS children we may have created. This way we can avoid
|
||||
@@ -6357,17 +6363,17 @@ namespace ts {
|
||||
|
||||
interface IncrementalElement extends TextRange {
|
||||
parent?: Node;
|
||||
intersectsChange: boolean
|
||||
intersectsChange: boolean;
|
||||
length?: number;
|
||||
_children: Node[];
|
||||
}
|
||||
|
||||
export interface IncrementalNode extends Node, IncrementalElement {
|
||||
hasBeenIncrementallyParsed: boolean
|
||||
hasBeenIncrementallyParsed: boolean;
|
||||
}
|
||||
|
||||
interface IncrementalNodeArray extends NodeArray<IncrementalNode>, IncrementalElement {
|
||||
length: number
|
||||
length: number;
|
||||
}
|
||||
|
||||
// Allows finding nodes in the source file at a certain position in an efficient manner.
|
||||
|
||||
+19
-19
@@ -11,12 +11,12 @@ namespace ts {
|
||||
export const version = "1.5.3";
|
||||
|
||||
export function findConfigFile(searchPath: string): string {
|
||||
var fileName = "tsconfig.json";
|
||||
let fileName = "tsconfig.json";
|
||||
while (true) {
|
||||
if (sys.fileExists(fileName)) {
|
||||
return fileName;
|
||||
}
|
||||
var parentPath = getDirectoryPath(searchPath);
|
||||
let parentPath = getDirectoryPath(searchPath);
|
||||
if (parentPath === searchPath) {
|
||||
break;
|
||||
}
|
||||
@@ -35,7 +35,7 @@ namespace ts {
|
||||
// otherwise use toLowerCase as a canonical form.
|
||||
return sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
// returned by CScript sys environment
|
||||
let unsupportedFileEncodingErrorCode = -2147024809;
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace ts {
|
||||
|
||||
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) {
|
||||
try {
|
||||
var start = new Date().getTime();
|
||||
let start = new Date().getTime();
|
||||
ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName)));
|
||||
sys.writeFile(fileName, data, writeByteOrderMark);
|
||||
ioWriteTime += new Date().getTime() - start;
|
||||
@@ -239,8 +239,8 @@ namespace ts {
|
||||
|
||||
function emitWorker(program: Program, sourceFile: SourceFile, writeFileCallback: WriteFileCallback, cancellationToken: CancellationToken): EmitResult {
|
||||
// If the noEmitOnError flag is set, then check if we have any errors so far. If so,
|
||||
// immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we
|
||||
// get any preEmit diagnostics, not just the ones
|
||||
// immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we
|
||||
// get any preEmit diagnostics, not just the ones
|
||||
if (options.noEmitOnError && getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken).length > 0) {
|
||||
return { diagnostics: [], sourceMaps: undefined, emitSkipped: true };
|
||||
}
|
||||
@@ -311,14 +311,14 @@ namespace ts {
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof OperationCanceledException) {
|
||||
// We were canceled while performing the operation. Because our type checker
|
||||
// We were canceled while performing the operation. Because our type checker
|
||||
// might be a bad state, we need to throw it away.
|
||||
//
|
||||
// Note: we are overly agressive here. We do not actually *have* to throw away
|
||||
// the "noDiagnosticsTypeChecker". However, for simplicity, i'd like to keep
|
||||
// the lifetimes of these two TypeCheckers the same. Also, we generally only
|
||||
// cancel when the user has made a change anyways. And, in that case, we (the
|
||||
// program instance) will get thrown away anyways. So trying to keep one of
|
||||
// program instance) will get thrown away anyways. So trying to keep one of
|
||||
// these type checkers alive doesn't serve much purpose.
|
||||
noDiagnosticsTypeChecker = undefined;
|
||||
diagnosticsProducingTypeChecker = undefined;
|
||||
@@ -341,16 +341,16 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
|
||||
function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
|
||||
return runWithCancellationToken(() => {
|
||||
if (!isDeclarationFile(sourceFile)) {
|
||||
let resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken);
|
||||
// Don't actually write any files since we're just getting diagnostics.
|
||||
var writeFile: WriteFileCallback = () => { };
|
||||
let writeFile: WriteFileCallback = () => { };
|
||||
return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function getOptionsDiagnostics(): Diagnostic[] {
|
||||
let allDiagnostics: Diagnostic[] = [];
|
||||
@@ -396,7 +396,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
var nonTsFile: SourceFile = options.allowNonTsExtensions && findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd);
|
||||
let nonTsFile: SourceFile = options.allowNonTsExtensions && findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd);
|
||||
if (!nonTsFile) {
|
||||
if (options.allowNonTsExtensions) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
@@ -496,7 +496,7 @@ namespace ts {
|
||||
let moduleNameText = (<LiteralExpression>moduleNameExpr).text;
|
||||
if (moduleNameText) {
|
||||
let searchPath = basePath;
|
||||
let searchName: string;
|
||||
let searchName: string;
|
||||
while (true) {
|
||||
searchName = normalizePath(combinePaths(searchPath, moduleNameText));
|
||||
if (forEach(supportedExtensions, extension => findModuleSourceFile(searchName + extension, moduleNameExpr))) {
|
||||
@@ -513,7 +513,7 @@ namespace ts {
|
||||
}
|
||||
else if (node.kind === SyntaxKind.ModuleDeclaration && (<ModuleDeclaration>node).name.kind === SyntaxKind.StringLiteral && (node.flags & NodeFlags.Ambient || isDeclarationFile(file))) {
|
||||
// TypeScript 1.0 spec (April 2014): 12.1.6
|
||||
// An AmbientExternalModuleDeclaration declares an external module.
|
||||
// An AmbientExternalModuleDeclaration declares an external module.
|
||||
// This type of declaration is permitted only in the global module.
|
||||
// The StringLiteral must specify a top - level external module name.
|
||||
// Relative external module names are not permitted
|
||||
@@ -525,7 +525,7 @@ namespace ts {
|
||||
let moduleName = nameLiteral.text;
|
||||
if (moduleName) {
|
||||
// TypeScript 1.0 spec (April 2014): 12.1.6
|
||||
// An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules
|
||||
// An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules
|
||||
// only through top - level external module names. Relative external module names are not permitted.
|
||||
let searchName = normalizePath(combinePaths(basePath, moduleName));
|
||||
forEach(supportedExtensions, extension => findModuleSourceFile(searchName + extension, nameLiteral));
|
||||
@@ -664,7 +664,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && !options.module) {
|
||||
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
|
||||
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
|
||||
let span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
|
||||
diagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided));
|
||||
}
|
||||
@@ -691,7 +691,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== directorySeparator) {
|
||||
// Make sure directory path ends with directory separator so this string can directly
|
||||
// Make sure directory path ends with directory separator so this string can directly
|
||||
// used to replace with "" to get the relative path of the source file and the relative path doesn't
|
||||
// start with / making it rooted path
|
||||
commonSourceDirectory += directorySeparator;
|
||||
@@ -707,12 +707,12 @@ namespace ts {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (options.emitDecoratorMetadata &&
|
||||
!options.experimentalDecorators) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified));
|
||||
}
|
||||
|
||||
|
||||
if (options.experimentalAsyncFunctions &&
|
||||
options.target !== ScriptTarget.ES6) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower));
|
||||
|
||||
+153
-153
@@ -32,13 +32,13 @@ namespace ts {
|
||||
setScriptTarget(scriptTarget: ScriptTarget): void;
|
||||
setLanguageVariant(variant: LanguageVariant): void;
|
||||
setTextPos(textPos: number): void;
|
||||
// Invokes the provided callback then unconditionally restores the scanner to the state it
|
||||
// Invokes the provided callback then unconditionally restores the scanner to the state it
|
||||
// was in immediately prior to invoking the callback. The result of invoking the callback
|
||||
// is returned from this function.
|
||||
lookAhead<T>(callback: () => T): T;
|
||||
|
||||
// Invokes the provided callback. If the callback returns something falsy, then it restores
|
||||
// the scanner to the state it was in immediately prior to invoking the callback. If the
|
||||
// the scanner to the state it was in immediately prior to invoking the callback. If the
|
||||
// callback returns something truthy, then the scanner state is not rolled back. The result
|
||||
// of invoking the callback is returned from this function.
|
||||
tryScan<T>(callback: () => T): T;
|
||||
@@ -275,7 +275,7 @@ namespace ts {
|
||||
return textToToken[s];
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
/* @internal */
|
||||
export function computeLineStarts(text: string): number[] {
|
||||
let result: number[] = new Array();
|
||||
let pos = 0;
|
||||
@@ -307,22 +307,22 @@ namespace ts {
|
||||
return computePositionOfLineAndCharacter(getLineStarts(sourceFile), line, character);
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
/* @internal */
|
||||
export function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number {
|
||||
Debug.assert(line >= 0 && line < lineStarts.length);
|
||||
return lineStarts[line] + character;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
/* @internal */
|
||||
export function getLineStarts(sourceFile: SourceFile): number[] {
|
||||
return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text));
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
/* @internal */
|
||||
export function computeLineAndCharacterOfPosition(lineStarts: number[], position: number) {
|
||||
let lineNumber = binarySearch(lineStarts, position);
|
||||
if (lineNumber < 0) {
|
||||
// If the actual position was not found,
|
||||
// If the actual position was not found,
|
||||
// the binary search returns the negative value of the next line start
|
||||
// e.g. if the line starts at [5, 10, 23, 80] and the position requested was 20
|
||||
// then the search will return -2
|
||||
@@ -355,125 +355,125 @@ namespace ts {
|
||||
ch === CharacterCodes.mathematicalSpace ||
|
||||
ch === CharacterCodes.ideographicSpace ||
|
||||
ch === CharacterCodes.byteOrderMark;
|
||||
}
|
||||
}
|
||||
|
||||
export function isLineBreak(ch: number): boolean {
|
||||
// ES5 7.3:
|
||||
// The ECMAScript line terminator characters are listed in Table 3.
|
||||
// Table 3: Line Terminator Characters
|
||||
// Code Unit Value Name Formal Name
|
||||
// \u000A Line Feed <LF>
|
||||
// \u000D Carriage Return <CR>
|
||||
// \u2028 Line separator <LS>
|
||||
// \u2029 Paragraph separator <PS>
|
||||
// Only the characters in Table 3 are treated as line terminators. Other new line or line
|
||||
// breaking characters are treated as white space but not as line terminators.
|
||||
export function isLineBreak(ch: number): boolean {
|
||||
// ES5 7.3:
|
||||
// The ECMAScript line terminator characters are listed in Table 3.
|
||||
// Table 3: Line Terminator Characters
|
||||
// Code Unit Value Name Formal Name
|
||||
// \u000A Line Feed <LF>
|
||||
// \u000D Carriage Return <CR>
|
||||
// \u2028 Line separator <LS>
|
||||
// \u2029 Paragraph separator <PS>
|
||||
// Only the characters in Table 3 are treated as line terminators. Other new line or line
|
||||
// breaking characters are treated as white space but not as line terminators.
|
||||
|
||||
return ch === CharacterCodes.lineFeed ||
|
||||
ch === CharacterCodes.carriageReturn ||
|
||||
ch === CharacterCodes.lineSeparator ||
|
||||
ch === CharacterCodes.paragraphSeparator;
|
||||
}
|
||||
return ch === CharacterCodes.lineFeed ||
|
||||
ch === CharacterCodes.carriageReturn ||
|
||||
ch === CharacterCodes.lineSeparator ||
|
||||
ch === CharacterCodes.paragraphSeparator;
|
||||
}
|
||||
|
||||
function isDigit(ch: number): boolean {
|
||||
return ch >= CharacterCodes._0 && ch <= CharacterCodes._9;
|
||||
}
|
||||
function isDigit(ch: number): boolean {
|
||||
return ch >= CharacterCodes._0 && ch <= CharacterCodes._9;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function isOctalDigit(ch: number): boolean {
|
||||
return ch >= CharacterCodes._0 && ch <= CharacterCodes._7;
|
||||
}
|
||||
/* @internal */
|
||||
export function isOctalDigit(ch: number): boolean {
|
||||
return ch >= CharacterCodes._0 && ch <= CharacterCodes._7;
|
||||
}
|
||||
|
||||
export function couldStartTrivia(text: string, pos: number): boolean {
|
||||
// Keep in sync with skipTrivia
|
||||
let ch = text.charCodeAt(pos);
|
||||
switch (ch) {
|
||||
case CharacterCodes.carriageReturn:
|
||||
case CharacterCodes.lineFeed:
|
||||
case CharacterCodes.tab:
|
||||
case CharacterCodes.verticalTab:
|
||||
case CharacterCodes.formFeed:
|
||||
case CharacterCodes.space:
|
||||
case CharacterCodes.slash:
|
||||
// starts of normal trivia
|
||||
case CharacterCodes.lessThan:
|
||||
case CharacterCodes.equals:
|
||||
case CharacterCodes.greaterThan:
|
||||
// Starts of conflict marker trivia
|
||||
return true;
|
||||
default:
|
||||
return ch > CharacterCodes.maxAsciiCharacter;
|
||||
}
|
||||
}
|
||||
export function couldStartTrivia(text: string, pos: number): boolean {
|
||||
// Keep in sync with skipTrivia
|
||||
let ch = text.charCodeAt(pos);
|
||||
switch (ch) {
|
||||
case CharacterCodes.carriageReturn:
|
||||
case CharacterCodes.lineFeed:
|
||||
case CharacterCodes.tab:
|
||||
case CharacterCodes.verticalTab:
|
||||
case CharacterCodes.formFeed:
|
||||
case CharacterCodes.space:
|
||||
case CharacterCodes.slash:
|
||||
// starts of normal trivia
|
||||
case CharacterCodes.lessThan:
|
||||
case CharacterCodes.equals:
|
||||
case CharacterCodes.greaterThan:
|
||||
// Starts of conflict marker trivia
|
||||
return true;
|
||||
default:
|
||||
return ch > CharacterCodes.maxAsciiCharacter;
|
||||
}
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function skipTrivia(text: string, pos: number, stopAfterLineBreak?: boolean): number {
|
||||
// Keep in sync with couldStartTrivia
|
||||
while (true) {
|
||||
let ch = text.charCodeAt(pos);
|
||||
switch (ch) {
|
||||
case CharacterCodes.carriageReturn:
|
||||
if (text.charCodeAt(pos + 1) === CharacterCodes.lineFeed) {
|
||||
pos++;
|
||||
}
|
||||
case CharacterCodes.lineFeed:
|
||||
pos++;
|
||||
if (stopAfterLineBreak) {
|
||||
return pos;
|
||||
}
|
||||
continue;
|
||||
case CharacterCodes.tab:
|
||||
case CharacterCodes.verticalTab:
|
||||
case CharacterCodes.formFeed:
|
||||
case CharacterCodes.space:
|
||||
pos++;
|
||||
continue;
|
||||
case CharacterCodes.slash:
|
||||
if (text.charCodeAt(pos + 1) === CharacterCodes.slash) {
|
||||
pos += 2;
|
||||
while (pos < text.length) {
|
||||
if (isLineBreak(text.charCodeAt(pos))) {
|
||||
break;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (text.charCodeAt(pos + 1) === CharacterCodes.asterisk) {
|
||||
pos += 2;
|
||||
while (pos < text.length) {
|
||||
if (text.charCodeAt(pos) === CharacterCodes.asterisk && text.charCodeAt(pos + 1) === CharacterCodes.slash) {
|
||||
pos += 2;
|
||||
break;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
/* @internal */
|
||||
export function skipTrivia(text: string, pos: number, stopAfterLineBreak?: boolean): number {
|
||||
// Keep in sync with couldStartTrivia
|
||||
while (true) {
|
||||
let ch = text.charCodeAt(pos);
|
||||
switch (ch) {
|
||||
case CharacterCodes.carriageReturn:
|
||||
if (text.charCodeAt(pos + 1) === CharacterCodes.lineFeed) {
|
||||
pos++;
|
||||
}
|
||||
case CharacterCodes.lineFeed:
|
||||
pos++;
|
||||
if (stopAfterLineBreak) {
|
||||
return pos;
|
||||
}
|
||||
continue;
|
||||
case CharacterCodes.tab:
|
||||
case CharacterCodes.verticalTab:
|
||||
case CharacterCodes.formFeed:
|
||||
case CharacterCodes.space:
|
||||
pos++;
|
||||
continue;
|
||||
case CharacterCodes.slash:
|
||||
if (text.charCodeAt(pos + 1) === CharacterCodes.slash) {
|
||||
pos += 2;
|
||||
while (pos < text.length) {
|
||||
if (isLineBreak(text.charCodeAt(pos))) {
|
||||
break;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (text.charCodeAt(pos + 1) === CharacterCodes.asterisk) {
|
||||
pos += 2;
|
||||
while (pos < text.length) {
|
||||
if (text.charCodeAt(pos) === CharacterCodes.asterisk && text.charCodeAt(pos + 1) === CharacterCodes.slash) {
|
||||
pos += 2;
|
||||
break;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
||||
case CharacterCodes.lessThan:
|
||||
case CharacterCodes.equals:
|
||||
case CharacterCodes.greaterThan:
|
||||
if (isConflictMarkerTrivia(text, pos)) {
|
||||
pos = scanConflictMarkerTrivia(text, pos);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case CharacterCodes.lessThan:
|
||||
case CharacterCodes.equals:
|
||||
case CharacterCodes.greaterThan:
|
||||
if (isConflictMarkerTrivia(text, pos)) {
|
||||
pos = scanConflictMarkerTrivia(text, pos);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (ch > CharacterCodes.maxAsciiCharacter && (isWhiteSpace(ch) || isLineBreak(ch))) {
|
||||
pos++;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
default:
|
||||
if (ch > CharacterCodes.maxAsciiCharacter && (isWhiteSpace(ch) || isLineBreak(ch))) {
|
||||
pos++;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
|
||||
// All conflict markers consist of the same character repeated seven times. If it is
|
||||
// a <<<<<<< or >>>>>>> marker then it is also followd by a space.
|
||||
// All conflict markers consist of the same character repeated seven times. If it is
|
||||
// a <<<<<<< or >>>>>>> marker then it is also followd by a space.
|
||||
let mergeConflictMarkerLength = "<<<<<<<".length;
|
||||
|
||||
function isConflictMarkerTrivia(text: string, pos: number) {
|
||||
@@ -528,12 +528,12 @@ namespace ts {
|
||||
return pos;
|
||||
}
|
||||
|
||||
// Extract comments from the given source text starting at the given position. If trailing is
|
||||
// false, whitespace is skipped until the first line break and comments between that location
|
||||
// and the next token are returned.If trailing is true, comments occurring between the given
|
||||
// position and the next line break are returned.The return value is an array containing a
|
||||
// TextRange for each comment. Single-line comment ranges include the beginning '//' characters
|
||||
// but not the ending line break. Multi - line comment ranges include the beginning '/* and
|
||||
// Extract comments from the given source text starting at the given position. If trailing is
|
||||
// false, whitespace is skipped until the first line break and comments between that location
|
||||
// and the next token are returned.If trailing is true, comments occurring between the given
|
||||
// position and the next line break are returned.The return value is an array containing a
|
||||
// TextRange for each comment. Single-line comment ranges include the beginning '//' characters
|
||||
// but not the ending line break. Multi - line comment ranges include the beginning '/* and
|
||||
// ending '*/' characters.The return value is undefined if no comments were found.
|
||||
function getCommentRanges(text: string, pos: number, trailing: boolean): CommentRange[] {
|
||||
let result: CommentRange[];
|
||||
@@ -629,9 +629,9 @@ namespace ts {
|
||||
ch >= CharacterCodes._0 && ch <= CharacterCodes._9 || ch === CharacterCodes.$ || ch === CharacterCodes._ ||
|
||||
ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierPart(ch, languageVersion);
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
// Creates a scanner over a (possibly unspecified) range of a piece of text.
|
||||
|
||||
/* @internal */
|
||||
// Creates a scanner over a (possibly unspecified) range of a piece of text.
|
||||
export function createScanner(languageVersion: ScriptTarget,
|
||||
skipTrivia: boolean,
|
||||
languageVariant = LanguageVariant.Standard,
|
||||
@@ -640,16 +640,16 @@ namespace ts {
|
||||
start?: number,
|
||||
length?: number): Scanner {
|
||||
// Current position (end position of text of current token)
|
||||
let pos: number;
|
||||
let pos: number;
|
||||
|
||||
// end of text
|
||||
let end: number;
|
||||
let end: number;
|
||||
|
||||
// Start position of whitespace before current token
|
||||
let startPos: number;
|
||||
let startPos: number;
|
||||
|
||||
// Start position of text of current token
|
||||
let tokenPos: number;
|
||||
let tokenPos: number;
|
||||
|
||||
let token: SyntaxKind;
|
||||
let tokenValue: string;
|
||||
@@ -735,7 +735,7 @@ namespace ts {
|
||||
}
|
||||
return +(text.substring(start, pos));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Scans the given number of hexadecimal digits in the text,
|
||||
* returning -1 if the given number is unavailable.
|
||||
@@ -743,7 +743,7 @@ namespace ts {
|
||||
function scanExactNumberOfHexDigits(count: number): number {
|
||||
return scanHexDigits(/*minCount*/ count, /*scanAsManyAsPossible*/ false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Scans as many hexadecimal digits as are available in the text,
|
||||
* returning -1 if the given number of digits was unavailable.
|
||||
@@ -821,7 +821,7 @@ namespace ts {
|
||||
|
||||
pos++;
|
||||
let start = pos;
|
||||
let contents = ""
|
||||
let contents = "";
|
||||
let resultingToken: SyntaxKind;
|
||||
|
||||
while (true) {
|
||||
@@ -916,13 +916,13 @@ namespace ts {
|
||||
pos++;
|
||||
return scanExtendedUnicodeEscape();
|
||||
}
|
||||
|
||||
|
||||
// '\uDDDD'
|
||||
return scanHexadecimalEscape(/*numDigits*/ 4)
|
||||
|
||||
return scanHexadecimalEscape(/*numDigits*/ 4);
|
||||
|
||||
case CharacterCodes.x:
|
||||
// '\xDD'
|
||||
return scanHexadecimalEscape(/*numDigits*/ 2)
|
||||
return scanHexadecimalEscape(/*numDigits*/ 2);
|
||||
|
||||
// when encountering a LineContinuation (i.e. a backslash and a line terminator sequence),
|
||||
// the line terminator is interpreted to be "the empty code unit sequence".
|
||||
@@ -934,31 +934,31 @@ namespace ts {
|
||||
case CharacterCodes.lineFeed:
|
||||
case CharacterCodes.lineSeparator:
|
||||
case CharacterCodes.paragraphSeparator:
|
||||
return ""
|
||||
return "";
|
||||
default:
|
||||
return String.fromCharCode(ch);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function scanHexadecimalEscape(numDigits: number): string {
|
||||
let escapedValue = scanExactNumberOfHexDigits(numDigits);
|
||||
|
||||
|
||||
if (escapedValue >= 0) {
|
||||
return String.fromCharCode(escapedValue);
|
||||
}
|
||||
else {
|
||||
error(Diagnostics.Hexadecimal_digit_expected);
|
||||
return ""
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function scanExtendedUnicodeEscape(): string {
|
||||
let escapedValue = scanMinimumNumberOfHexDigits(1);
|
||||
let isInvalidExtendedEscape = false;
|
||||
|
||||
// Validate the value of the digit
|
||||
if (escapedValue < 0) {
|
||||
error(Diagnostics.Hexadecimal_digit_expected)
|
||||
error(Diagnostics.Hexadecimal_digit_expected);
|
||||
isInvalidExtendedEscape = true;
|
||||
}
|
||||
else if (escapedValue > 0x10FFFF) {
|
||||
@@ -985,18 +985,18 @@ namespace ts {
|
||||
|
||||
return utf16EncodeAsString(escapedValue);
|
||||
}
|
||||
|
||||
|
||||
// Derived from the 10.1.1 UTF16Encoding of the ES6 Spec.
|
||||
function utf16EncodeAsString(codePoint: number): string {
|
||||
Debug.assert(0x0 <= codePoint && codePoint <= 0x10FFFF);
|
||||
|
||||
|
||||
if (codePoint <= 65535) {
|
||||
return String.fromCharCode(codePoint);
|
||||
}
|
||||
|
||||
|
||||
let codeUnit1 = Math.floor((codePoint - 65536) / 1024) + 0xD800;
|
||||
let codeUnit2 = ((codePoint - 65536) % 1024) + 0xDC00;
|
||||
|
||||
|
||||
return String.fromCharCode(codeUnit1, codeUnit2);
|
||||
}
|
||||
|
||||
@@ -1058,7 +1058,7 @@ namespace ts {
|
||||
let value = 0;
|
||||
// For counting number of digits; Valid binaryIntegerLiteral must have at least one binary digit following B or b.
|
||||
// Similarly valid octalIntegerLiteral must have at least one octal digit following o or O.
|
||||
let numberOfDigits = 0;
|
||||
let numberOfDigits = 0;
|
||||
while (true) {
|
||||
let ch = text.charCodeAt(pos);
|
||||
let valueOfCh = ch - CharacterCodes._0;
|
||||
@@ -1132,7 +1132,7 @@ namespace ts {
|
||||
tokenValue = scanString();
|
||||
return token = SyntaxKind.StringLiteral;
|
||||
case CharacterCodes.backtick:
|
||||
return token = scanTemplateAndSetTokenValue()
|
||||
return token = scanTemplateAndSetTokenValue();
|
||||
case CharacterCodes.percent:
|
||||
if (text.charCodeAt(pos + 1) === CharacterCodes.equals) {
|
||||
return pos += 2, token = SyntaxKind.PercentEqualsToken;
|
||||
@@ -1444,14 +1444,14 @@ namespace ts {
|
||||
// regex. Report error and return what we have so far.
|
||||
if (p >= end) {
|
||||
tokenIsUnterminated = true;
|
||||
error(Diagnostics.Unterminated_regular_expression_literal)
|
||||
error(Diagnostics.Unterminated_regular_expression_literal);
|
||||
break;
|
||||
}
|
||||
|
||||
let ch = text.charCodeAt(p);
|
||||
if (isLineBreak(ch)) {
|
||||
tokenIsUnterminated = true;
|
||||
error(Diagnostics.Unterminated_regular_expression_literal)
|
||||
error(Diagnostics.Unterminated_regular_expression_literal);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1543,7 +1543,7 @@ namespace ts {
|
||||
let ch = text.charCodeAt(pos);
|
||||
if (ch === CharacterCodes.minus || ((firstCharPosition === pos) ? isIdentifierStart(ch) : isIdentifierPart(ch))) {
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
@@ -1552,7 +1552,7 @@ namespace ts {
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
function speculationHelper<T>(callback: () => T, isLookahead: boolean): T {
|
||||
let savePos = pos;
|
||||
let saveStartPos = startPos;
|
||||
|
||||
+35
-25
@@ -29,6 +29,9 @@ namespace ts {
|
||||
declare var process: any;
|
||||
declare var global: any;
|
||||
declare var __filename: string;
|
||||
declare var Buffer: {
|
||||
new (str: string, encoding ?: string): any;
|
||||
}
|
||||
|
||||
declare class Enumerator {
|
||||
public atEnd(): boolean;
|
||||
@@ -41,16 +44,16 @@ namespace ts {
|
||||
|
||||
function getWScriptSystem(): System {
|
||||
|
||||
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||
let fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||
|
||||
var fileStream = new ActiveXObject("ADODB.Stream");
|
||||
let fileStream = new ActiveXObject("ADODB.Stream");
|
||||
fileStream.Type = 2 /*text*/;
|
||||
|
||||
var binaryStream = new ActiveXObject("ADODB.Stream");
|
||||
let binaryStream = new ActiveXObject("ADODB.Stream");
|
||||
binaryStream.Type = 1 /*binary*/;
|
||||
|
||||
var args: string[] = [];
|
||||
for (var i = 0; i < WScript.Arguments.length; i++) {
|
||||
let args: string[] = [];
|
||||
for (let i = 0; i < WScript.Arguments.length; i++) {
|
||||
args[i] = WScript.Arguments.Item(i);
|
||||
}
|
||||
|
||||
@@ -68,7 +71,7 @@ namespace ts {
|
||||
// Load file and read the first two bytes into a string with no interpretation
|
||||
fileStream.Charset = "x-ansi";
|
||||
fileStream.LoadFromFile(fileName);
|
||||
var bom = fileStream.ReadText(2) || "";
|
||||
let bom = fileStream.ReadText(2) || "";
|
||||
// Position must be at 0 before encoding can be changed
|
||||
fileStream.Position = 0;
|
||||
// [0xFF,0xFE] and [0xFE,0xFF] mean utf-16 (little or big endian), otherwise default to utf-8
|
||||
@@ -114,28 +117,28 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getNames(collection: any): string[]{
|
||||
var result: string[] = [];
|
||||
for (var e = new Enumerator(collection); !e.atEnd(); e.moveNext()) {
|
||||
let result: string[] = [];
|
||||
for (let e = new Enumerator(collection); !e.atEnd(); e.moveNext()) {
|
||||
result.push(e.item().Name);
|
||||
}
|
||||
return result.sort();
|
||||
}
|
||||
|
||||
function readDirectory(path: string, extension?: string, exclude?: string[]): string[] {
|
||||
var result: string[] = [];
|
||||
let result: string[] = [];
|
||||
exclude = map(exclude, s => getCanonicalPath(combinePaths(path, s)));
|
||||
visitDirectory(path);
|
||||
return result;
|
||||
function visitDirectory(path: string) {
|
||||
var folder = fso.GetFolder(path || ".");
|
||||
var files = getNames(folder.files);
|
||||
let folder = fso.GetFolder(path || ".");
|
||||
let files = getNames(folder.files);
|
||||
for (let current of files) {
|
||||
let name = combinePaths(path, current);
|
||||
if ((!extension || fileExtensionIs(name, extension)) && !contains(exclude, getCanonicalPath(name))) {
|
||||
result.push(name);
|
||||
}
|
||||
}
|
||||
var subfolders = getNames(folder.subfolders);
|
||||
let subfolders = getNames(folder.subfolders);
|
||||
for (let current of subfolders) {
|
||||
let name = combinePaths(path, current);
|
||||
if (!contains(exclude, getCanonicalPath(name))) {
|
||||
@@ -197,14 +200,14 @@ namespace ts {
|
||||
if (!_fs.existsSync(fileName)) {
|
||||
return undefined;
|
||||
}
|
||||
var buffer = _fs.readFileSync(fileName);
|
||||
var len = buffer.length;
|
||||
let buffer = _fs.readFileSync(fileName);
|
||||
let len = buffer.length;
|
||||
if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) {
|
||||
// Big endian UTF-16 byte order mark detected. Since big endian is not supported by node.js,
|
||||
// flip all byte pairs and treat as little endian.
|
||||
len &= ~1;
|
||||
for (var i = 0; i < len; i += 2) {
|
||||
var temp = buffer[i];
|
||||
for (let i = 0; i < len; i += 2) {
|
||||
let temp = buffer[i];
|
||||
buffer[i] = buffer[i + 1];
|
||||
buffer[i + 1] = temp;
|
||||
}
|
||||
@@ -236,17 +239,17 @@ namespace ts {
|
||||
}
|
||||
|
||||
function readDirectory(path: string, extension?: string, exclude?: string[]): string[] {
|
||||
var result: string[] = [];
|
||||
let result: string[] = [];
|
||||
exclude = map(exclude, s => getCanonicalPath(combinePaths(path, s)));
|
||||
visitDirectory(path);
|
||||
return result;
|
||||
function visitDirectory(path: string) {
|
||||
var files = _fs.readdirSync(path || ".").sort();
|
||||
var directories: string[] = [];
|
||||
let files = _fs.readdirSync(path || ".").sort();
|
||||
let directories: string[] = [];
|
||||
for (let current of files) {
|
||||
var name = combinePaths(path, current);
|
||||
let name = combinePaths(path, current);
|
||||
if (!contains(exclude, getCanonicalPath(name))) {
|
||||
var stat = _fs.statSync(name);
|
||||
let stat = _fs.statSync(name);
|
||||
if (stat.isFile()) {
|
||||
if (!extension || fileExtensionIs(name, extension)) {
|
||||
result.push(name);
|
||||
@@ -267,10 +270,17 @@ namespace ts {
|
||||
args: process.argv.slice(2),
|
||||
newLine: _os.EOL,
|
||||
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
|
||||
write(s: string): void {
|
||||
write(s: string): void {
|
||||
var buffer = new Buffer(s, 'utf8');
|
||||
var offset: number = 0;
|
||||
var toWrite: number = buffer.length;
|
||||
var written = 0;
|
||||
// 1 is a standard descriptor for stdout
|
||||
_fs.writeSync(1, s);
|
||||
},
|
||||
while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) {
|
||||
offset += written;
|
||||
toWrite -= written;
|
||||
}
|
||||
},
|
||||
readFile,
|
||||
writeFile,
|
||||
watchFile: (fileName, callback) => {
|
||||
@@ -331,4 +341,4 @@ namespace ts {
|
||||
return undefined; // Unsupported host
|
||||
}
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
||||
+54
-53
@@ -11,15 +11,15 @@ namespace ts {
|
||||
* and if it is, attempts to set the appropriate language.
|
||||
*/
|
||||
function validateLocaleAndSetLanguage(locale: string, errors: Diagnostic[]): boolean {
|
||||
var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase());
|
||||
let matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase());
|
||||
|
||||
if (!matchResult) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.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];
|
||||
let language = matchResult[1];
|
||||
let territory = matchResult[3];
|
||||
|
||||
// First try the entire locale, then fall back to just language if that's all we have.
|
||||
if (!trySetLanguageAndTerritory(language, territory, errors) &&
|
||||
@@ -33,10 +33,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
function trySetLanguageAndTerritory(language: string, territory: string, errors: Diagnostic[]): boolean {
|
||||
var compilerFilePath = normalizePath(sys.getExecutingFilePath());
|
||||
var containingDirectoryPath = getDirectoryPath(compilerFilePath);
|
||||
let compilerFilePath = normalizePath(sys.getExecutingFilePath());
|
||||
let containingDirectoryPath = getDirectoryPath(compilerFilePath);
|
||||
|
||||
var filePath = combinePaths(containingDirectoryPath, language);
|
||||
let filePath = combinePaths(containingDirectoryPath, language);
|
||||
|
||||
if (territory) {
|
||||
filePath = filePath + "-" + territory;
|
||||
@@ -49,8 +49,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
// TODO: Add codePage support for readFile?
|
||||
let fileContents = '';
|
||||
try {
|
||||
var fileContents = sys.readFile(filePath);
|
||||
fileContents = sys.readFile(filePath);
|
||||
}
|
||||
catch (e) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Unable_to_open_file_0, filePath));
|
||||
@@ -68,7 +69,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function countLines(program: Program): number {
|
||||
var count = 0;
|
||||
let count = 0;
|
||||
forEach(program.getSourceFiles(), file => {
|
||||
count += getLineStarts(file).length;
|
||||
});
|
||||
@@ -76,27 +77,27 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getDiagnosticText(message: DiagnosticMessage, ...args: any[]): string {
|
||||
var diagnostic = createCompilerDiagnostic.apply(undefined, arguments);
|
||||
let diagnostic = createCompilerDiagnostic.apply(undefined, arguments);
|
||||
return <string>diagnostic.messageText;
|
||||
}
|
||||
|
||||
function reportDiagnostic(diagnostic: Diagnostic) {
|
||||
var output = "";
|
||||
|
||||
let output = "";
|
||||
|
||||
if (diagnostic.file) {
|
||||
var loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
|
||||
let loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
|
||||
|
||||
output += `${ diagnostic.file.fileName }(${ loc.line + 1 },${ loc.character + 1 }): `;
|
||||
}
|
||||
|
||||
var category = DiagnosticCategory[diagnostic.category].toLowerCase();
|
||||
let category = DiagnosticCategory[diagnostic.category].toLowerCase();
|
||||
output += `${ category } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }${ sys.newLine }`;
|
||||
|
||||
sys.write(output);
|
||||
}
|
||||
|
||||
function reportDiagnostics(diagnostics: Diagnostic[]) {
|
||||
for (var i = 0; i < diagnostics.length; i++) {
|
||||
for (let i = 0; i < diagnostics.length; i++) {
|
||||
reportDiagnostic(diagnostics[i]);
|
||||
}
|
||||
}
|
||||
@@ -133,15 +134,15 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function executeCommandLine(args: string[]): void {
|
||||
var commandLine = parseCommandLine(args);
|
||||
var configFileName: string; // Configuration file name (if any)
|
||||
var configFileWatcher: FileWatcher; // Configuration file watcher
|
||||
var cachedProgram: Program; // Program cached from last compilation
|
||||
var rootFileNames: string[]; // Root fileNames for compilation
|
||||
var compilerOptions: CompilerOptions; // Compiler options for compilation
|
||||
var compilerHost: CompilerHost; // Compiler host
|
||||
var hostGetSourceFile: typeof compilerHost.getSourceFile; // getSourceFile method from default host
|
||||
var timerHandle: number; // Handle for 0.25s wait timer
|
||||
let commandLine = parseCommandLine(args);
|
||||
let configFileName: string; // Configuration file name (if any)
|
||||
let configFileWatcher: FileWatcher; // Configuration file watcher
|
||||
let cachedProgram: Program; // Program cached from last compilation
|
||||
let rootFileNames: string[]; // Root fileNames for compilation
|
||||
let compilerOptions: CompilerOptions; // Compiler options for compilation
|
||||
let compilerHost: CompilerHost; // Compiler host
|
||||
let hostGetSourceFile: typeof compilerHost.getSourceFile; // getSourceFile method from default host
|
||||
let timerHandle: number; // Handle for 0.25s wait timer
|
||||
|
||||
if (commandLine.options.locale) {
|
||||
if (!isJSONSupported()) {
|
||||
@@ -181,7 +182,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else if (commandLine.fileNames.length === 0 && isJSONSupported()) {
|
||||
var searchPath = normalizePath(sys.getCurrentDirectory());
|
||||
let searchPath = normalizePath(sys.getCurrentDirectory());
|
||||
configFileName = findConfigFile(searchPath);
|
||||
}
|
||||
|
||||
@@ -247,14 +248,14 @@ namespace ts {
|
||||
function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError ?: (message: string) => void) {
|
||||
// Return existing SourceFile object if one is available
|
||||
if (cachedProgram) {
|
||||
var sourceFile = cachedProgram.getSourceFile(fileName);
|
||||
let sourceFile = cachedProgram.getSourceFile(fileName);
|
||||
// A modified source file has no watcher and should not be reused
|
||||
if (sourceFile && sourceFile.fileWatcher) {
|
||||
return sourceFile;
|
||||
}
|
||||
}
|
||||
// Use default host function
|
||||
var sourceFile = hostGetSourceFile(fileName, languageVersion, onError);
|
||||
let sourceFile = hostGetSourceFile(fileName, languageVersion, onError);
|
||||
if (sourceFile && compilerOptions.watch) {
|
||||
// Attach a file watcher
|
||||
sourceFile.fileWatcher = sys.watchFile(sourceFile.fileName, () => sourceFileChanged(sourceFile));
|
||||
@@ -265,7 +266,7 @@ namespace ts {
|
||||
// Change cached program to the given program
|
||||
function setCachedProgram(program: Program) {
|
||||
if (cachedProgram) {
|
||||
var newSourceFiles = program ? program.getSourceFiles() : undefined;
|
||||
let newSourceFiles = program ? program.getSourceFiles() : undefined;
|
||||
forEach(cachedProgram.getSourceFiles(), sourceFile => {
|
||||
if (!(newSourceFiles && contains(newSourceFiles, sourceFile))) {
|
||||
if (sourceFile.fileWatcher) {
|
||||
@@ -316,8 +317,8 @@ namespace ts {
|
||||
checkTime = 0;
|
||||
emitTime = 0;
|
||||
|
||||
var program = createProgram(fileNames, compilerOptions, compilerHost);
|
||||
var exitStatus = compileProgram();
|
||||
let program = createProgram(fileNames, compilerOptions, compilerHost);
|
||||
let exitStatus = compileProgram();
|
||||
|
||||
if (compilerOptions.listFiles) {
|
||||
forEach(program.getSourceFiles(), file => {
|
||||
@@ -326,7 +327,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (compilerOptions.diagnostics) {
|
||||
var memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1;
|
||||
let memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1;
|
||||
reportCountStatistic("Files", program.getSourceFiles().length);
|
||||
reportCountStatistic("Lines", countLines(program));
|
||||
reportCountStatistic("Nodes", program.getNodeCount());
|
||||
@@ -354,18 +355,18 @@ namespace ts {
|
||||
return { program, exitStatus };
|
||||
|
||||
function compileProgram(): ExitStatus {
|
||||
// First get any syntactic errors.
|
||||
var diagnostics = program.getSyntacticDiagnostics();
|
||||
// First get any syntactic errors.
|
||||
let diagnostics = program.getSyntacticDiagnostics();
|
||||
reportDiagnostics(diagnostics);
|
||||
|
||||
// If we didn't have any syntactic errors, then also try getting the global and
|
||||
// If we didn't have any syntactic errors, then also try getting the global and
|
||||
// semantic errors.
|
||||
if (diagnostics.length === 0) {
|
||||
var diagnostics = program.getGlobalDiagnostics();
|
||||
let diagnostics = program.getGlobalDiagnostics();
|
||||
reportDiagnostics(diagnostics);
|
||||
|
||||
if (diagnostics.length === 0) {
|
||||
var diagnostics = program.getSemanticDiagnostics();
|
||||
let diagnostics = program.getSemanticDiagnostics();
|
||||
reportDiagnostics(diagnostics);
|
||||
}
|
||||
}
|
||||
@@ -378,7 +379,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Otherwise, emit and report any errors we ran into.
|
||||
var emitOutput = program.emit();
|
||||
let emitOutput = program.emit();
|
||||
reportDiagnostics(emitOutput.diagnostics);
|
||||
|
||||
// If the emitter didn't emit anything, then pass that value along.
|
||||
@@ -401,22 +402,22 @@ namespace ts {
|
||||
}
|
||||
|
||||
function printHelp() {
|
||||
var output = "";
|
||||
let output = "";
|
||||
|
||||
// We want to align our "syntax" and "examples" commands to a certain margin.
|
||||
var syntaxLength = getDiagnosticText(Diagnostics.Syntax_Colon_0, "").length;
|
||||
var examplesLength = getDiagnosticText(Diagnostics.Examples_Colon_0, "").length;
|
||||
var marginLength = Math.max(syntaxLength, examplesLength);
|
||||
let syntaxLength = getDiagnosticText(Diagnostics.Syntax_Colon_0, "").length;
|
||||
let examplesLength = getDiagnosticText(Diagnostics.Examples_Colon_0, "").length;
|
||||
let marginLength = Math.max(syntaxLength, examplesLength);
|
||||
|
||||
// Build up the syntactic skeleton.
|
||||
var syntax = makePadding(marginLength - syntaxLength);
|
||||
let syntax = makePadding(marginLength - syntaxLength);
|
||||
syntax += "tsc [" + getDiagnosticText(Diagnostics.options) + "] [" + getDiagnosticText(Diagnostics.file) + " ...]";
|
||||
|
||||
output += getDiagnosticText(Diagnostics.Syntax_Colon_0, syntax);
|
||||
output += sys.newLine + sys.newLine;
|
||||
|
||||
// Build up the list of examples.
|
||||
var padding = makePadding(marginLength);
|
||||
let padding = makePadding(marginLength);
|
||||
output += getDiagnosticText(Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + sys.newLine;
|
||||
output += padding + "tsc --out file.js file.ts" + sys.newLine;
|
||||
output += padding + "tsc @args.txt" + sys.newLine;
|
||||
@@ -425,17 +426,17 @@ namespace ts {
|
||||
output += getDiagnosticText(Diagnostics.Options_Colon) + sys.newLine;
|
||||
|
||||
// Sort our options by their names, (e.g. "--noImplicitAny" comes before "--watch")
|
||||
var optsList = filter(optionDeclarations.slice(), v => !v.experimental);
|
||||
let optsList = filter(optionDeclarations.slice(), v => !v.experimental);
|
||||
optsList.sort((a, b) => compareValues<string>(a.name.toLowerCase(), b.name.toLowerCase()));
|
||||
|
||||
// We want our descriptions to align at the same column in our output,
|
||||
// so we keep track of the longest option usage string.
|
||||
var marginLength = 0;
|
||||
var usageColumn: string[] = []; // Things like "-d, --declaration" go in here.
|
||||
var descriptionColumn: string[] = [];
|
||||
marginLength = 0;
|
||||
let usageColumn: string[] = []; // Things like "-d, --declaration" go in here.
|
||||
let descriptionColumn: string[] = [];
|
||||
|
||||
for (var i = 0; i < optsList.length; i++) {
|
||||
var option = optsList[i];
|
||||
for (let i = 0; i < optsList.length; i++) {
|
||||
let option = optsList[i];
|
||||
|
||||
// If an option lacks a description,
|
||||
// it is not officially supported.
|
||||
@@ -443,7 +444,7 @@ namespace ts {
|
||||
continue;
|
||||
}
|
||||
|
||||
var usageText = " ";
|
||||
let usageText = " ";
|
||||
if (option.shortName) {
|
||||
usageText += "-" + option.shortName;
|
||||
usageText += getParamType(option);
|
||||
@@ -461,15 +462,15 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Special case that can't fit in the loop.
|
||||
var usageText = " @<" + getDiagnosticText(Diagnostics.file) + ">";
|
||||
let usageText = " @<" + getDiagnosticText(Diagnostics.file) + ">";
|
||||
usageColumn.push(usageText);
|
||||
descriptionColumn.push(getDiagnosticText(Diagnostics.Insert_command_line_options_and_files_from_a_file));
|
||||
marginLength = Math.max(usageText.length, marginLength);
|
||||
|
||||
// Print out each row, aligning all the descriptions on the same column.
|
||||
for (var i = 0; i < usageColumn.length; i++) {
|
||||
var usage = usageColumn[i];
|
||||
var description = descriptionColumn[i];
|
||||
for (let i = 0; i < usageColumn.length; i++) {
|
||||
let usage = usageColumn[i];
|
||||
let description = descriptionColumn[i];
|
||||
output += usage + makePadding(marginLength - usage.length + 2) + description + sys.newLine;
|
||||
}
|
||||
|
||||
|
||||
+53
-31
@@ -273,7 +273,7 @@ namespace ts {
|
||||
// Module references
|
||||
ExternalModuleReference,
|
||||
|
||||
//JSX
|
||||
// JSX
|
||||
JsxElement,
|
||||
JsxSelfClosingElement,
|
||||
JsxOpeningElement,
|
||||
@@ -405,10 +405,10 @@ namespace ts {
|
||||
|
||||
// Context flags set directly by the parser.
|
||||
ParserGeneratedFlags = DisallowIn | Yield | Decorator | ThisNodeHasError | Await,
|
||||
|
||||
|
||||
// Exclude these flags when parsing a Type
|
||||
TypeExcludesFlags = Yield | Await,
|
||||
|
||||
TypeExcludesFlags = Yield | Await,
|
||||
|
||||
// Context flags computed by aggregating child flags upwards.
|
||||
|
||||
// Used during incremental parsing to determine if this node or any of its children had an
|
||||
@@ -1055,7 +1055,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export interface ModuleBlock extends Node, Statement {
|
||||
statements: NodeArray<Statement>
|
||||
statements: NodeArray<Statement>;
|
||||
}
|
||||
|
||||
export interface ImportEqualsDeclaration extends Declaration, Statement {
|
||||
@@ -1171,7 +1171,7 @@ namespace ts {
|
||||
|
||||
export interface JSDocTypeReference extends JSDocType {
|
||||
name: EntityName;
|
||||
typeArguments: NodeArray<JSDocType>
|
||||
typeArguments: NodeArray<JSDocType>;
|
||||
}
|
||||
|
||||
export interface JSDocOptionalType extends JSDocType {
|
||||
@@ -1196,8 +1196,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
export interface JSDocRecordMember extends PropertyDeclaration {
|
||||
name: Identifier | LiteralExpression,
|
||||
type?: JSDocType
|
||||
name: Identifier | LiteralExpression;
|
||||
type?: JSDocType;
|
||||
}
|
||||
|
||||
export interface JSDocComment extends Node {
|
||||
@@ -1294,7 +1294,7 @@ namespace ts {
|
||||
|
||||
export interface CancellationToken {
|
||||
isCancellationRequested(): boolean;
|
||||
|
||||
|
||||
/** @throws OperationCanceledException if isCancellationRequested is true */
|
||||
throwIfCancellationRequested(): void;
|
||||
}
|
||||
@@ -1323,7 +1323,7 @@ namespace ts {
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
|
||||
/**
|
||||
/**
|
||||
* Gets a type checker that can be used to semantically analyze source fils in the program.
|
||||
*/
|
||||
getTypeChecker(): TypeChecker;
|
||||
@@ -1344,15 +1344,15 @@ namespace ts {
|
||||
|
||||
export interface SourceMapSpan {
|
||||
/** Line number in the .js file. */
|
||||
emittedLine: number;
|
||||
emittedLine: number;
|
||||
/** Column number in the .js file. */
|
||||
emittedColumn: number;
|
||||
emittedColumn: number;
|
||||
/** Line number in the .ts file. */
|
||||
sourceLine: number;
|
||||
sourceLine: number;
|
||||
/** Column number in the .ts file. */
|
||||
sourceColumn: number;
|
||||
sourceColumn: number;
|
||||
/** Optional name (index into names array) associated with this span. */
|
||||
nameIndex?: number;
|
||||
nameIndex?: number;
|
||||
/** .ts file (index into sources array) associated with this span */
|
||||
sourceIndex: number;
|
||||
}
|
||||
@@ -1506,7 +1506,7 @@ namespace ts {
|
||||
NotAccessible,
|
||||
CannotBeNamed
|
||||
}
|
||||
|
||||
|
||||
export interface TypePredicate {
|
||||
parameterName: string;
|
||||
parameterIndex: number;
|
||||
@@ -1526,7 +1526,28 @@ namespace ts {
|
||||
|
||||
/* @internal */
|
||||
export interface SymbolAccessiblityResult extends SymbolVisibilityResult {
|
||||
errorModuleName?: string // If the symbol is not visible from module, module's name
|
||||
errorModuleName?: string; // If the symbol is not visible from module, module's name
|
||||
}
|
||||
|
||||
/** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator
|
||||
* metadata */
|
||||
/* @internal */
|
||||
export enum TypeReferenceSerializationKind {
|
||||
Unknown, // The TypeReferenceNode could not be resolved. The type name
|
||||
// should be emitted using a safe fallback.
|
||||
TypeWithConstructSignatureAndValue, // The TypeReferenceNode resolves to a type with a constructor
|
||||
// function that can be reached at runtime (e.g. a `class`
|
||||
// declaration or a `var` declaration for the static side
|
||||
// of a type, such as the global `Promise` type in lib.d.ts).
|
||||
VoidType, // The TypeReferenceNode resolves to a Void-like type.
|
||||
NumberLikeType, // The TypeReferenceNode resolves to a Number-like type.
|
||||
StringLikeType, // The TypeReferenceNode resolves to a String-like type.
|
||||
BooleanType, // The TypeReferenceNode resolves to a Boolean-like type.
|
||||
ArrayLikeType, // The TypeReferenceNode resolves to an Array-like type.
|
||||
ESSymbolType, // The TypeReferenceNode resolves to the ESSymbol type.
|
||||
TypeWithCallSignature, // The TypeReferenceNode resolves to a Function type or a type
|
||||
// with call signatures.
|
||||
ObjectType, // The TypeReferenceNode resolves to any other type.
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -1552,9 +1573,7 @@ namespace ts {
|
||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
|
||||
getBlockScopedVariableId(node: Identifier): number;
|
||||
getReferencedValueDeclaration(reference: Identifier): Declaration;
|
||||
serializeTypeOfNode(node: Node): string | string[];
|
||||
serializeParameterTypesOfNode(node: Node): (string | string[])[];
|
||||
serializeReturnTypeOfNode(node: Node): string | string[];
|
||||
getTypeReferenceSerializationKind(node: TypeReferenceNode): TypeReferenceSerializationKind;
|
||||
}
|
||||
|
||||
export const enum SymbolFlags {
|
||||
@@ -1637,7 +1656,7 @@ namespace ts {
|
||||
Export = ExportNamespace | ExportType | ExportValue,
|
||||
|
||||
/* @internal */
|
||||
// The set of things we consider semantically classifiable. Used to speed up the LS during
|
||||
// The set of things we consider semantically classifiable. Used to speed up the LS during
|
||||
// classification.
|
||||
Classifiable = Class | Enum | TypeAlias | Interface | TypeParameter | Module,
|
||||
}
|
||||
@@ -1657,7 +1676,7 @@ namespace ts {
|
||||
/* @internal */ constEnumOnlyModule?: boolean; // True if module contains only const enums or other modules with only const enums
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
/* @internal */
|
||||
export interface SymbolLinks {
|
||||
target?: Symbol; // Resolved (non-alias) target of an alias
|
||||
type?: Type; // Type of value symbol
|
||||
@@ -1672,14 +1691,14 @@ namespace ts {
|
||||
isNestedRedeclaration?: boolean; // True if symbol is block scoped redeclaration
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
/* @internal */
|
||||
export interface TransientSymbol extends Symbol, SymbolLinks { }
|
||||
|
||||
export interface SymbolTable {
|
||||
[index: string]: Symbol;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
/* @internal */
|
||||
export const enum NodeCheckFlags {
|
||||
TypeChecked = 0x00000001, // Node has been type checked
|
||||
LexicalThis = 0x00000002, // Lexical 'this' reference
|
||||
@@ -1701,7 +1720,7 @@ namespace ts {
|
||||
LexicalModuleMergesWithClass= 0x00008000, // Instantiated lexical module declaration is merged with a previous class declaration.
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
/* @internal */
|
||||
export interface NodeLinks {
|
||||
resolvedType?: Type; // Cached type of type node
|
||||
resolvedAwaitedType?: Type; // Cached awaited type of type node
|
||||
@@ -1750,17 +1769,17 @@ namespace ts {
|
||||
ContainsObjectLiteral = 0x00400000, // Type is or contains object literal type
|
||||
ESSymbol = 0x00800000, // Type of symbol primitive introduced in ES6
|
||||
|
||||
/* @internal */
|
||||
/* @internal */
|
||||
Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null,
|
||||
/* @internal */
|
||||
/* @internal */
|
||||
Primitive = String | Number | Boolean | ESSymbol | Void | Undefined | Null | StringLiteral | Enum,
|
||||
StringLike = String | StringLiteral,
|
||||
NumberLike = Number | Enum,
|
||||
ObjectType = Class | Interface | Reference | Tuple | Anonymous,
|
||||
UnionOrIntersection = Union | Intersection,
|
||||
UnionOrIntersection = Union | Intersection,
|
||||
StructuredType = ObjectType | Union | Intersection,
|
||||
/* @internal */
|
||||
RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral
|
||||
/* @internal */
|
||||
RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral
|
||||
}
|
||||
|
||||
// Properties common to all types
|
||||
@@ -1770,7 +1789,7 @@ namespace ts {
|
||||
symbol?: Symbol; // Symbol associated with type (if any)
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
/* @internal */
|
||||
// Intrinsic types (TypeFlags.Intrinsic)
|
||||
export interface IntrinsicType extends Type {
|
||||
intrinsicName: string; // Name of intrinsic type
|
||||
@@ -1903,6 +1922,9 @@ namespace ts {
|
||||
/* @internal */
|
||||
export interface TypeMapper {
|
||||
(t: TypeParameter): Type;
|
||||
context?: InferenceContext; // The inference context this mapper was created from.
|
||||
// Only inference mappers have this set (in createInferenceMapper).
|
||||
// The identity mapper and regular instantiation mappers do not need it.
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
|
||||
+89
-72
@@ -3,9 +3,9 @@
|
||||
/* @internal */
|
||||
namespace ts {
|
||||
export interface ReferencePathMatchResult {
|
||||
fileReference?: FileReference
|
||||
diagnosticMessage?: DiagnosticMessage
|
||||
isNoDefaultLib?: boolean
|
||||
fileReference?: FileReference;
|
||||
diagnosticMessage?: DiagnosticMessage;
|
||||
isNoDefaultLib?: boolean;
|
||||
}
|
||||
|
||||
export interface SynthesizedNode extends Node {
|
||||
@@ -16,9 +16,11 @@ namespace ts {
|
||||
|
||||
export function getDeclarationOfKind(symbol: Symbol, kind: SyntaxKind): Declaration {
|
||||
let declarations = symbol.declarations;
|
||||
for (let declaration of declarations) {
|
||||
if (declaration.kind === kind) {
|
||||
return declaration;
|
||||
if (declarations) {
|
||||
for (let declaration of declarations) {
|
||||
if (declaration.kind === kind) {
|
||||
return declaration;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +72,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function releaseStringWriter(writer: StringSymbolWriter) {
|
||||
writer.clear()
|
||||
writer.clear();
|
||||
stringWriters.push(writer);
|
||||
}
|
||||
|
||||
@@ -81,7 +83,7 @@ namespace ts {
|
||||
// Returns true if this node contains a parse error anywhere underneath it.
|
||||
export function containsParseError(node: Node): boolean {
|
||||
aggregateChildData(node);
|
||||
return (node.parserContextFlags & ParserContextFlags.ThisNodeOrAnySubNodesHasError) !== 0
|
||||
return (node.parserContextFlags & ParserContextFlags.ThisNodeOrAnySubNodesHasError) !== 0;
|
||||
}
|
||||
|
||||
function aggregateChildData(node: Node): void {
|
||||
@@ -92,7 +94,7 @@ namespace ts {
|
||||
let thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & ParserContextFlags.ThisNodeHasError) !== 0) ||
|
||||
forEachChild(node, containsParseError);
|
||||
|
||||
// If so, mark ourselves accordingly.
|
||||
// If so, mark ourselves accordingly.
|
||||
if (thisNodeOrAnySubNodesHasError) {
|
||||
node.parserContextFlags |= ParserContextFlags.ThisNodeOrAnySubNodesHasError;
|
||||
}
|
||||
@@ -129,13 +131,13 @@ namespace ts {
|
||||
|
||||
// Returns true if this node is missing from the actual source code. 'missing' is different
|
||||
// from 'undefined/defined'. When a node is undefined (which can happen for optional nodes
|
||||
// in the tree), it is definitel missing. HOwever, a node may be defined, but still be
|
||||
// in the tree), it is definitel missing. HOwever, a node may be defined, but still be
|
||||
// missing. This happens whenever the parser knows it needs to parse something, but can't
|
||||
// get anything in the source code that it expects at that location. For example:
|
||||
//
|
||||
// let a: ;
|
||||
//
|
||||
// Here, the Type in the Type-Annotation is not-optional (as there is a colon in the source
|
||||
// Here, the Type in the Type-Annotation is not-optional (as there is a colon in the source
|
||||
// code). So the parser will attempt to parse out a type, and will create an actual node.
|
||||
// However, this node will be 'missing' in the sense that no actual source-code/tokens are
|
||||
// contained within it.
|
||||
@@ -166,7 +168,7 @@ namespace ts {
|
||||
return getTokenPosOfNode(node, sourceFile);
|
||||
}
|
||||
|
||||
return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end);
|
||||
return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end);
|
||||
}
|
||||
|
||||
export function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node, includeTrivia = false): string {
|
||||
@@ -211,7 +213,7 @@ namespace ts {
|
||||
isCatchClauseVariableDeclaration(declaration);
|
||||
}
|
||||
|
||||
// Gets the nearest enclosing block scope container that has the provided node
|
||||
// Gets the nearest enclosing block scope container that has the provided node
|
||||
// as a descendant, that is not the provided node.
|
||||
export function getEnclosingBlockScopeContainer(node: Node): Node {
|
||||
let current = node.parent;
|
||||
@@ -307,7 +309,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (errorNode === undefined) {
|
||||
// If we don't have a better node, then just set the error on the first token of
|
||||
// If we don't have a better node, then just set the error on the first token of
|
||||
// construct.
|
||||
return getSpanOfTokenAtPosition(sourceFile, node.pos);
|
||||
}
|
||||
@@ -339,10 +341,10 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
// Returns the node flags for this node and all relevant parent nodes. This is done so that
|
||||
// Returns the node flags for this node and all relevant parent nodes. This is done so that
|
||||
// nodes like variable declarations and binding elements can returned a view of their flags
|
||||
// that includes the modifiers from their container. i.e. flags like export/declare aren't
|
||||
// stored on the variable declaration directly, but on the containing variable statement
|
||||
// stored on the variable declaration directly, but on the containing variable statement
|
||||
// (if it has one). Similarly, flags for let/const are store on the variable declaration
|
||||
// list. By calling this function, all those flags are combined so that the client can treat
|
||||
// the node as if it actually had those flags.
|
||||
@@ -406,7 +408,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export let fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)('|")(.+?)\2.*?\/>/
|
||||
export let fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
|
||||
|
||||
export function isTypeNode(node: Node): boolean {
|
||||
if (SyntaxKind.FirstTypeNode <= node.kind && node.kind <= SyntaxKind.LastTypeNode) {
|
||||
@@ -566,7 +568,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function isVariableLike(node: Node): boolean {
|
||||
export function isVariableLike(node: Node): node is VariableLikeDeclaration {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.BindingElement:
|
||||
@@ -662,7 +664,7 @@ namespace ts {
|
||||
node = node.parent;
|
||||
break;
|
||||
case SyntaxKind.Decorator:
|
||||
// Decorators are always applied outside of the body of a class or method.
|
||||
// Decorators are always applied outside of the body of a class or method.
|
||||
if (node.parent.kind === SyntaxKind.Parameter && isClassElement(node.parent.parent)) {
|
||||
// If the decorator's parent is a Parameter, we resolve the this container from
|
||||
// the grandparent class declaration.
|
||||
@@ -717,7 +719,7 @@ namespace ts {
|
||||
node = node.parent;
|
||||
break;
|
||||
case SyntaxKind.Decorator:
|
||||
// Decorators are always applied outside of the body of a class or method.
|
||||
// Decorators are always applied outside of the body of a class or method.
|
||||
if (node.parent.kind === SyntaxKind.Parameter && isClassElement(node.parent.parent)) {
|
||||
// If the decorator's parent is a Parameter, we resolve the this container from
|
||||
// the grandparent class declaration.
|
||||
@@ -746,14 +748,14 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function getEntityNameFromTypeNode(node: TypeNode): EntityName | Expression {
|
||||
if (node) {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.TypeReference:
|
||||
return (<TypeReferenceNode>node).typeName;
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return (<ExpressionWithTypeArguments>node).expression
|
||||
return (<ExpressionWithTypeArguments>node).expression;
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.QualifiedName:
|
||||
return (<EntityName><Node>node);
|
||||
@@ -767,7 +769,7 @@ namespace ts {
|
||||
if (node.kind === SyntaxKind.TaggedTemplateExpression) {
|
||||
return (<TaggedTemplateExpression>node).tag;
|
||||
}
|
||||
|
||||
|
||||
// Will either be a CallExpression, NewExpression, or Decorator.
|
||||
return (<CallExpression | Decorator>node).expression;
|
||||
}
|
||||
@@ -949,7 +951,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean) {
|
||||
let moduleState = getModuleInstanceState(node)
|
||||
let moduleState = getModuleInstanceState(node);
|
||||
return moduleState === ModuleInstanceState.Instantiated ||
|
||||
(preserveConstEnums && moduleState === ModuleInstanceState.ConstEnumOnly);
|
||||
}
|
||||
@@ -1031,7 +1033,7 @@ namespace ts {
|
||||
|
||||
export function getCorrespondingJSDocParameterTag(parameter: ParameterDeclaration): JSDocParameterTag {
|
||||
if (parameter.name && parameter.name.kind === SyntaxKind.Identifier) {
|
||||
// If it's a parameter, see if the parent has a jsdoc comment with an @param
|
||||
// If it's a parameter, see if the parent has a jsdoc comment with an @param
|
||||
// annotation.
|
||||
let parameterName = (<Identifier>parameter.name).text;
|
||||
|
||||
@@ -1301,7 +1303,7 @@ namespace ts {
|
||||
if (isNoDefaultLibRegEx.exec(comment)) {
|
||||
return {
|
||||
isNoDefaultLib: true
|
||||
}
|
||||
};
|
||||
}
|
||||
else {
|
||||
let matchResult = fullTripleSlashReferencePathRegEx.exec(comment);
|
||||
@@ -1417,7 +1419,7 @@ namespace ts {
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
export function nodeStartsNewLexicalEnvironment(n: Node): boolean {
|
||||
return isFunctionLike(n) || n.kind === SyntaxKind.ModuleDeclaration || n.kind === SyntaxKind.SourceFile;
|
||||
}
|
||||
@@ -1433,7 +1435,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function createSynthesizedNodeArray(): NodeArray<any> {
|
||||
var array = <NodeArray<any>>[];
|
||||
let array = <NodeArray<any>>[];
|
||||
array.pos = -1;
|
||||
array.end = -1;
|
||||
return array;
|
||||
@@ -1517,7 +1519,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// This consists of the first 19 unprintable ASCII characters, canonical escapes, lineSeparator,
|
||||
// paragraphSeparator, and nextLine. The latter three are just desirable to suppress new lines in
|
||||
// the language service. These characters should be escaped when printing, and if any characters are added,
|
||||
@@ -1704,6 +1706,10 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
export function getSetAccessorTypeAnnotationNode(accessor: AccessorDeclaration): TypeNode {
|
||||
return accessor && accessor.parameters.length > 0 && accessor.parameters[0].type;
|
||||
}
|
||||
|
||||
export function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean {
|
||||
if (!isDeclarationFile(sourceFile)) {
|
||||
if ((isExternalModule(sourceFile) || !compilerOptions.out)) {
|
||||
@@ -1969,12 +1975,23 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function isRightSideOfQualifiedNameOrPropertyAccess(node: Node) {
|
||||
return (node.parent.kind === SyntaxKind.QualifiedName && (<QualifiedName>node.parent).right === node) ||
|
||||
(node.parent.kind === SyntaxKind.PropertyAccessExpression && (<PropertyAccessExpression>node.parent).name === node);
|
||||
}
|
||||
|
||||
export function isEmptyObjectLiteralOrArrayLiteral(expression: Node): boolean {
|
||||
let kind = expression.kind;
|
||||
if (kind === SyntaxKind.ObjectLiteralExpression) {
|
||||
return (<ObjectLiteralExpression>expression).properties.length === 0;
|
||||
}
|
||||
if (kind === SyntaxKind.ArrayLiteralExpression) {
|
||||
return (<ArrayLiteralExpression>expression).elements.length === 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function getLocalSymbolForExportDefault(symbol: Symbol) {
|
||||
return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & NodeFlags.Default) ? symbol.valueDeclaration.localSymbol : undefined;
|
||||
}
|
||||
@@ -1988,7 +2005,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace each instance of non-ascii characters by one, two, three, or four escape sequences
|
||||
* Replace each instance of non-ascii characters by one, two, three, or four escape sequences
|
||||
* representing the UTF-8 encoding of the character, and return the expanded char code list.
|
||||
*/
|
||||
function getExpandedCharCodes(input: string): number[] {
|
||||
@@ -2031,7 +2048,7 @@ namespace ts {
|
||||
* Converts a string to a base-64 encoded ASCII string.
|
||||
*/
|
||||
export function convertToBase64(input: string): string {
|
||||
var result = "";
|
||||
let result = "";
|
||||
let charCodes = getExpandedCharCodes(input);
|
||||
let i = 0;
|
||||
let length = charCodes.length;
|
||||
@@ -2073,7 +2090,7 @@ namespace ts {
|
||||
return lineFeed;
|
||||
}
|
||||
else if (sys) {
|
||||
return sys.newLine
|
||||
return sys.newLine;
|
||||
}
|
||||
return carriageReturnLineFeed;
|
||||
}
|
||||
@@ -2085,11 +2102,11 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function textSpanEnd(span: TextSpan) {
|
||||
return span.start + span.length
|
||||
return span.start + span.length;
|
||||
}
|
||||
|
||||
export function textSpanIsEmpty(span: TextSpan) {
|
||||
return span.length === 0
|
||||
return span.length === 0;
|
||||
}
|
||||
|
||||
export function textSpanContainsPosition(span: TextSpan, position: number) {
|
||||
@@ -2117,7 +2134,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan) {
|
||||
return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start
|
||||
return other.start <= textSpanEnd(span) && textSpanEnd(other) >= span.start;
|
||||
}
|
||||
|
||||
export function textSpanIntersectsWith(span: TextSpan, start: number, length: number) {
|
||||
@@ -2178,10 +2195,10 @@ namespace ts {
|
||||
export let unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0);
|
||||
|
||||
/**
|
||||
* Called to merge all the changes that occurred across several versions of a script snapshot
|
||||
* Called to merge all the changes that occurred across several versions of a script snapshot
|
||||
* into a single change. i.e. if a user keeps making successive edits to a script we will
|
||||
* have a text change from V1 to V2, V2 to V3, ..., Vn.
|
||||
*
|
||||
* have a text change from V1 to V2, V2 to V3, ..., Vn.
|
||||
*
|
||||
* This function will then merge those changes into a single change range valid between V1 and
|
||||
* Vn.
|
||||
*/
|
||||
@@ -2212,17 +2229,17 @@ namespace ts {
|
||||
//
|
||||
// 0 10 20 30 40 50 60 70 80 90 100
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
// | /
|
||||
// | /----
|
||||
// T1 | /----
|
||||
// | /----
|
||||
// | /----
|
||||
// | /
|
||||
// | /----
|
||||
// T1 | /----
|
||||
// | /----
|
||||
// | /----
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
// | \
|
||||
// | \
|
||||
// T2 | \
|
||||
// | \
|
||||
// | \
|
||||
// | \
|
||||
// | \
|
||||
// T2 | \
|
||||
// | \
|
||||
// | \
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// Merging these turns out to not be too difficult. First, determining the new start of the change is trivial
|
||||
@@ -2230,17 +2247,17 @@ namespace ts {
|
||||
//
|
||||
// 0 10 20 30 40 50 60 70 80 90 100
|
||||
// ------------------------------------------------------------*------------------------------------------
|
||||
// | /
|
||||
// | /----
|
||||
// T1 | /----
|
||||
// | /----
|
||||
// | /----
|
||||
// | /
|
||||
// | /----
|
||||
// T1 | /----
|
||||
// | /----
|
||||
// | /----
|
||||
// ----------------------------------------$-------------------$------------------------------------------
|
||||
// . | \
|
||||
// . | \
|
||||
// T2 . | \
|
||||
// . | \
|
||||
// . | \
|
||||
// . | \
|
||||
// . | \
|
||||
// T2 . | \
|
||||
// . | \
|
||||
// . | \
|
||||
// ----------------------------------------------------------------------*--------------------------------
|
||||
//
|
||||
// (Note the dots represent the newly inferrred start.
|
||||
@@ -2251,22 +2268,22 @@ namespace ts {
|
||||
//
|
||||
// 0 10 20 30 40 50 60 70 80 90 100
|
||||
// --------------------------------------------------------------------------------*----------------------
|
||||
// | /
|
||||
// | /----
|
||||
// T1 | /----
|
||||
// | /----
|
||||
// | /----
|
||||
// | /
|
||||
// | /----
|
||||
// T1 | /----
|
||||
// | /----
|
||||
// | /----
|
||||
// ------------------------------------------------------------$------------------------------------------
|
||||
// . | \
|
||||
// . | \
|
||||
// T2 . | \
|
||||
// . | \
|
||||
// . | \
|
||||
// . | \
|
||||
// . | \
|
||||
// T2 . | \
|
||||
// . | \
|
||||
// . | \
|
||||
// ----------------------------------------------------------------------*--------------------------------
|
||||
//
|
||||
// In other words (in this case), we're recognizing that the second edit happened after where the first edit
|
||||
// ended with a delta of 20 characters (60 - 40). Thus, if we go back in time to where the first edit started
|
||||
// that's the same as if we started at char 80 instead of 60.
|
||||
// that's the same as if we started at char 80 instead of 60.
|
||||
//
|
||||
// As it so happens, the same logic applies if the second edit precedes the first edit. In that case rahter
|
||||
// than pusing the first edit forward to match the second, we'll push the second edit forward to match the
|
||||
@@ -2276,7 +2293,7 @@ namespace ts {
|
||||
// semantics: { { start: 10, length: 70 }, newLength: 60 }
|
||||
//
|
||||
// The math then works out as follows.
|
||||
// If we have { oldStart1, oldEnd1, newEnd1 } and { oldStart2, oldEnd2, newEnd2 } then we can compute the
|
||||
// If we have { oldStart1, oldEnd1, newEnd1 } and { oldStart2, oldEnd2, newEnd2 } then we can compute the
|
||||
// final result like so:
|
||||
//
|
||||
// {
|
||||
|
||||
@@ -10,6 +10,7 @@ const enum CompilerTestType {
|
||||
|
||||
class CompilerBaselineRunner extends RunnerBase {
|
||||
private basePath = 'tests/cases';
|
||||
private testSuiteName: string;
|
||||
private errors: boolean;
|
||||
private emit: boolean;
|
||||
private decl: boolean;
|
||||
@@ -24,43 +25,43 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
this.decl = true;
|
||||
this.output = true;
|
||||
if (testType === CompilerTestType.Conformance) {
|
||||
this.basePath += '/conformance';
|
||||
this.testSuiteName = 'conformance';
|
||||
}
|
||||
else if (testType === CompilerTestType.Regressions) {
|
||||
this.basePath += '/compiler';
|
||||
this.testSuiteName = 'compiler';
|
||||
}
|
||||
else if (testType === CompilerTestType.Test262) {
|
||||
this.basePath += '/test262';
|
||||
this.testSuiteName = 'test262';
|
||||
} else {
|
||||
this.basePath += '/compiler'; // default to this for historical reasons
|
||||
this.testSuiteName = 'compiler'; // default to this for historical reasons
|
||||
}
|
||||
this.basePath += '/' + this.testSuiteName;
|
||||
}
|
||||
|
||||
public checkTestCodeOutput(fileName: string) {
|
||||
describe('compiler tests for ' + fileName, () => {
|
||||
// Mocha holds onto the closure environment of the describe callback even after the test is done.
|
||||
// Everything declared here should be cleared out in the "after" callback.
|
||||
var justName: string;
|
||||
var content: string;
|
||||
var testCaseContent: { settings: Harness.TestCaseParser.CompilerSetting[]; testUnitData: Harness.TestCaseParser.TestUnitData[]; }
|
||||
let justName: string;
|
||||
let content: string;
|
||||
let testCaseContent: { settings: Harness.TestCaseParser.CompilerSetting[]; testUnitData: Harness.TestCaseParser.TestUnitData[]; };
|
||||
|
||||
var units: Harness.TestCaseParser.TestUnitData[];
|
||||
var tcSettings: Harness.TestCaseParser.CompilerSetting[];
|
||||
var createNewInstance: boolean;
|
||||
let units: Harness.TestCaseParser.TestUnitData[];
|
||||
let tcSettings: Harness.TestCaseParser.CompilerSetting[];
|
||||
|
||||
var lastUnit: Harness.TestCaseParser.TestUnitData;
|
||||
var rootDir: string;
|
||||
let lastUnit: Harness.TestCaseParser.TestUnitData;
|
||||
let rootDir: string;
|
||||
|
||||
var result: Harness.Compiler.CompilerResult;
|
||||
var program: ts.Program;
|
||||
var options: ts.CompilerOptions;
|
||||
let result: Harness.Compiler.CompilerResult;
|
||||
let program: ts.Program;
|
||||
let options: ts.CompilerOptions;
|
||||
// equivalent to the files that will be passed on the command line
|
||||
var toBeCompiled: { unitName: string; content: string }[];
|
||||
let toBeCompiled: { unitName: string; content: string }[];
|
||||
// equivalent to other files on the file system not directly passed to the compiler (ie things that are referenced by other files)
|
||||
var otherFiles: { unitName: string; content: string }[];
|
||||
var harnessCompiler: Harness.Compiler.HarnessCompiler;
|
||||
let otherFiles: { unitName: string; content: string }[];
|
||||
let harnessCompiler: Harness.Compiler.HarnessCompiler;
|
||||
|
||||
var createNewInstance = false;
|
||||
let createNewInstance = false;
|
||||
|
||||
before(() => {
|
||||
justName = fileName.replace(/^.*[\\\/]/, ''); // strips the fileName from the path.
|
||||
@@ -100,10 +101,10 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
/* The compiler doesn't handle certain flags flipping during a single compilation setting. Tests on these flags will need
|
||||
/* The compiler doesn't handle certain flags flipping during a single compilation setting. Tests on these flags will need
|
||||
a fresh compiler instance for themselves and then create a fresh one for the next test. Would be nice to get dev fixes
|
||||
eventually to remove this limitation. */
|
||||
for (var i = 0; i < tcSettings.length; ++i) {
|
||||
for (let i = 0; i < tcSettings.length; ++i) {
|
||||
// noImplicitAny is passed to getCompiler, but target is just passed in the settings blob to setCompilerSettings
|
||||
if (!createNewInstance && (tcSettings[i].flag == "noimplicitany" || tcSettings[i].flag === 'target')) {
|
||||
harnessCompiler = Harness.Compiler.getCompiler();
|
||||
@@ -160,7 +161,7 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
it('Correct sourcemap content for ' + fileName, () => {
|
||||
if (options.sourceMap || options.inlineSourceMap) {
|
||||
Harness.Baseline.runBaseline('Correct sourcemap content for ' + fileName, justName.replace(/\.tsx?$/, '.sourcemap.txt'), () => {
|
||||
var record = result.getSourceMapRecord();
|
||||
let record = result.getSourceMapRecord();
|
||||
if (options.noEmitOnError && result.errors.length !== 0 && record === undefined) {
|
||||
// Because of the noEmitOnError option no files are created. We need to return null because baselining isn't required.
|
||||
return null;
|
||||
@@ -178,18 +179,18 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
|
||||
// check js output
|
||||
Harness.Baseline.runBaseline('Correct JS output for ' + fileName, justName.replace(/\.tsx?/, '.js'), () => {
|
||||
var tsCode = '';
|
||||
var tsSources = otherFiles.concat(toBeCompiled);
|
||||
let tsCode = '';
|
||||
let tsSources = otherFiles.concat(toBeCompiled);
|
||||
if (tsSources.length > 1) {
|
||||
tsCode += '//// [' + fileName + '] ////\r\n\r\n';
|
||||
}
|
||||
for (var i = 0; i < tsSources.length; i++) {
|
||||
for (let i = 0; i < tsSources.length; i++) {
|
||||
tsCode += '//// [' + Harness.Path.getFileName(tsSources[i].unitName) + ']\r\n';
|
||||
tsCode += tsSources[i].content + (i < (tsSources.length - 1) ? '\r\n' : '');
|
||||
}
|
||||
|
||||
var jsCode = '';
|
||||
for (var i = 0; i < result.files.length; i++) {
|
||||
let jsCode = '';
|
||||
for (let i = 0; i < result.files.length; i++) {
|
||||
jsCode += '//// [' + Harness.Path.getFileName(result.files[i].fileName) + ']\r\n';
|
||||
jsCode += getByteOrderMarkText(result.files[i]);
|
||||
jsCode += result.files[i].code;
|
||||
@@ -197,14 +198,14 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
|
||||
if (result.declFilesCode.length > 0) {
|
||||
jsCode += '\r\n\r\n';
|
||||
for (var i = 0; i < result.declFilesCode.length; i++) {
|
||||
for (let i = 0; i < result.declFilesCode.length; i++) {
|
||||
jsCode += '//// [' + Harness.Path.getFileName(result.declFilesCode[i].fileName) + ']\r\n';
|
||||
jsCode += getByteOrderMarkText(result.declFilesCode[i]);
|
||||
jsCode += result.declFilesCode[i].code;
|
||||
}
|
||||
}
|
||||
|
||||
var declFileCompilationResult = harnessCompiler.compileDeclarationFiles(toBeCompiled, otherFiles, result, function (settings) {
|
||||
let declFileCompilationResult = harnessCompiler.compileDeclarationFiles(toBeCompiled, otherFiles, result, function (settings) {
|
||||
harnessCompiler.setCompilerSettings(tcSettings);
|
||||
}, options);
|
||||
|
||||
@@ -242,8 +243,8 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
return null;
|
||||
}
|
||||
|
||||
var sourceMapCode = '';
|
||||
for (var i = 0; i < result.sourceMaps.length; i++) {
|
||||
let sourceMapCode = '';
|
||||
for (let i = 0; i < result.sourceMaps.length; i++) {
|
||||
sourceMapCode += '//// [' + Harness.Path.getFileName(result.sourceMaps[i].fileName) + ']\r\n';
|
||||
sourceMapCode += getByteOrderMarkText(result.sourceMaps[i]);
|
||||
sourceMapCode += result.sourceMaps[i].code;
|
||||
@@ -261,19 +262,19 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
|
||||
// NEWTODO: Type baselines
|
||||
if (result.errors.length === 0) {
|
||||
// The full walker simulates the types that you would get from doing a full
|
||||
// The full walker simulates the types that you would get from doing a full
|
||||
// compile. The pull walker simulates the types you get when you just do
|
||||
// a type query for a random node (like how the LS would do it). Most of the
|
||||
// time, these will be the same. However, occasionally, they can be different.
|
||||
// Specifically, when the compiler internally depends on symbol IDs to order
|
||||
// things, then we may see different results because symbols can be created in a
|
||||
// things, then we may see different results because symbols can be created in a
|
||||
// different order with 'pull' operations, and thus can produce slightly differing
|
||||
// output.
|
||||
//
|
||||
// For example, with a full type check, we may see a type outputed as: number | string
|
||||
// But with a pull type check, we may see it as: string | number
|
||||
//
|
||||
// These types are equivalent, but depend on what order the compiler observed
|
||||
// These types are equivalent, but depend on what order the compiler observed
|
||||
// certain parts of the program.
|
||||
|
||||
let allFiles = toBeCompiled.concat(otherFiles).filter(file => !!program.getSourceFile(file.unitName));
|
||||
@@ -291,7 +292,7 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
|
||||
// Produce baselines. The first gives the types for all expressions.
|
||||
// The second gives symbols for all identifiers.
|
||||
var e1: Error, e2: Error;
|
||||
let e1: Error, e2: Error;
|
||||
try {
|
||||
checkBaseLines(/*isSymbolBaseLine:*/ false);
|
||||
}
|
||||
@@ -333,20 +334,20 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
let typeMap: { [fileName: string]: { [lineNum: number]: string[]; } } = {};
|
||||
|
||||
allFiles.forEach(file => {
|
||||
var codeLines = file.content.split('\n');
|
||||
let codeLines = file.content.split('\n');
|
||||
typeWriterResults[file.unitName].forEach(result => {
|
||||
if (isSymbolBaseline && !result.symbol) {
|
||||
return;
|
||||
}
|
||||
|
||||
var typeOrSymbolString = isSymbolBaseline ? result.symbol : result.type;
|
||||
var formattedLine = result.sourceText.replace(/\r?\n/g, "") + " : " + typeOrSymbolString;
|
||||
let typeOrSymbolString = isSymbolBaseline ? result.symbol : result.type;
|
||||
let formattedLine = result.sourceText.replace(/\r?\n/g, "") + " : " + typeOrSymbolString;
|
||||
if (!typeMap[file.unitName]) {
|
||||
typeMap[file.unitName] = {};
|
||||
}
|
||||
|
||||
var typeInfo = [formattedLine];
|
||||
var existingTypeInfo = typeMap[file.unitName][result.line];
|
||||
let typeInfo = [formattedLine];
|
||||
let existingTypeInfo = typeMap[file.unitName][result.line];
|
||||
if (existingTypeInfo) {
|
||||
typeInfo = existingTypeInfo.concat(typeInfo);
|
||||
}
|
||||
@@ -354,11 +355,11 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
});
|
||||
|
||||
typeLines.push('=== ' + file.unitName + ' ===\r\n');
|
||||
for (var i = 0; i < codeLines.length; i++) {
|
||||
var currentCodeLine = codeLines[i];
|
||||
for (let i = 0; i < codeLines.length; i++) {
|
||||
let currentCodeLine = codeLines[i];
|
||||
typeLines.push(currentCodeLine + '\r\n');
|
||||
if (typeMap[file.unitName]) {
|
||||
var typeInfo = typeMap[file.unitName][i];
|
||||
let typeInfo = typeMap[file.unitName][i];
|
||||
if (typeInfo) {
|
||||
typeInfo.forEach(ty => {
|
||||
typeLines.push('>' + ty + '\r\n');
|
||||
@@ -384,25 +385,27 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
public initializeTests() {
|
||||
describe("Setup compiler for compiler baselines", () => {
|
||||
var harnessCompiler = Harness.Compiler.getCompiler();
|
||||
this.parseOptions();
|
||||
});
|
||||
|
||||
// this will set up a series of describe/it blocks to run between the setup and cleanup phases
|
||||
if (this.tests.length === 0) {
|
||||
var testFiles = this.enumerateFiles(this.basePath, /\.tsx?$/, { recursive: true });
|
||||
testFiles.forEach(fn => {
|
||||
fn = fn.replace(/\\/g, "/");
|
||||
this.checkTestCodeOutput(fn);
|
||||
describe(this.testSuiteName + ' tests', () => {
|
||||
describe("Setup compiler for compiler baselines", () => {
|
||||
let harnessCompiler = Harness.Compiler.getCompiler();
|
||||
this.parseOptions();
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.tests.forEach(test => this.checkTestCodeOutput(test));
|
||||
}
|
||||
|
||||
describe("Cleanup after compiler baselines", () => {
|
||||
var harnessCompiler = Harness.Compiler.getCompiler();
|
||||
// this will set up a series of describe/it blocks to run between the setup and cleanup phases
|
||||
if (this.tests.length === 0) {
|
||||
let testFiles = this.enumerateFiles(this.basePath, /\.tsx?$/, { recursive: true });
|
||||
testFiles.forEach(fn => {
|
||||
fn = fn.replace(/\\/g, "/");
|
||||
this.checkTestCodeOutput(fn);
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.tests.forEach(test => this.checkTestCodeOutput(test));
|
||||
}
|
||||
|
||||
describe("Cleanup after compiler baselines", () => {
|
||||
let harnessCompiler = Harness.Compiler.getCompiler();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -413,8 +416,8 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
this.decl = false;
|
||||
this.output = false;
|
||||
|
||||
var opts = this.options.split(',');
|
||||
for (var i = 0; i < opts.length; i++) {
|
||||
let opts = this.options.split(',');
|
||||
for (let i = 0; i < opts.length; i++) {
|
||||
switch (opts[i]) {
|
||||
case 'error':
|
||||
this.errors = true;
|
||||
@@ -434,4 +437,4 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+420
-370
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
||||
///<reference path='harness.ts'/>
|
||||
///<reference path='runnerbase.ts' />
|
||||
|
||||
const enum FourSlashTestType {
|
||||
const enum FourSlashTestType {
|
||||
Native,
|
||||
Shims,
|
||||
Server
|
||||
@@ -35,70 +35,72 @@ class FourSlashRunner extends RunnerBase {
|
||||
this.tests = this.enumerateFiles(this.basePath, /\.ts/i, { recursive: false });
|
||||
}
|
||||
|
||||
describe(this.testSuiteName + ' tests', () => {
|
||||
this.tests.forEach((fn: string) => {
|
||||
describe(fn, () => {
|
||||
fn = ts.normalizeSlashes(fn);
|
||||
var justName = fn.replace(/^.*[\\\/]/, '');
|
||||
describe(fn, () => {
|
||||
fn = ts.normalizeSlashes(fn);
|
||||
let justName = fn.replace(/^.*[\\\/]/, '');
|
||||
|
||||
// Convert to relative path
|
||||
var testIndex = fn.indexOf('tests/');
|
||||
if (testIndex >= 0) fn = fn.substr(testIndex);
|
||||
// Convert to relative path
|
||||
let testIndex = fn.indexOf('tests/');
|
||||
if (testIndex >= 0) fn = fn.substr(testIndex);
|
||||
|
||||
if (justName && !justName.match(/fourslash\.ts$/i) && !justName.match(/\.d\.ts$/i)) {
|
||||
it(this.testSuiteName + ' test ' + justName + ' runs correctly',() => {
|
||||
FourSlash.runFourSlashTest(this.basePath, this.testType, fn);
|
||||
});
|
||||
}
|
||||
if (justName && !justName.match(/fourslash\.ts$/i) && !justName.match(/\.d\.ts$/i)) {
|
||||
it(this.testSuiteName + ' test ' + justName + ' runs correctly', () => {
|
||||
FourSlash.runFourSlashTest(this.basePath, this.testType, fn);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Generate Tao XML', () => {
|
||||
var invalidReasons: any = {};
|
||||
FourSlash.xmlData.forEach(xml => {
|
||||
if (xml.invalidReason !== null) {
|
||||
invalidReasons[xml.invalidReason] = (invalidReasons[xml.invalidReason] || 0) + 1;
|
||||
describe('Generate Tao XML', () => {
|
||||
let invalidReasons: any = {};
|
||||
FourSlash.xmlData.forEach(xml => {
|
||||
if (xml.invalidReason !== null) {
|
||||
invalidReasons[xml.invalidReason] = (invalidReasons[xml.invalidReason] || 0) + 1;
|
||||
}
|
||||
});
|
||||
let invalidReport: { reason: string; count: number }[] = [];
|
||||
for (let reason in invalidReasons) {
|
||||
if (invalidReasons.hasOwnProperty(reason)) {
|
||||
invalidReport.push({ reason: reason, count: invalidReasons[reason] });
|
||||
}
|
||||
}
|
||||
});
|
||||
var invalidReport: { reason: string; count: number }[] = [];
|
||||
for (var reason in invalidReasons) {
|
||||
if (invalidReasons.hasOwnProperty(reason)) {
|
||||
invalidReport.push({ reason: reason, count: invalidReasons[reason] });
|
||||
}
|
||||
}
|
||||
invalidReport.sort((lhs, rhs) => lhs.count > rhs.count ? -1 : lhs.count === rhs.count ? 0 : 1);
|
||||
invalidReport.sort((lhs, rhs) => lhs.count > rhs.count ? -1 : lhs.count === rhs.count ? 0 : 1);
|
||||
|
||||
var lines: string[] = [];
|
||||
lines.push('<!-- Blocked Test Report');
|
||||
invalidReport.forEach((reasonAndCount) => {
|
||||
lines.push(reasonAndCount.count + ' tests blocked by ' + reasonAndCount.reason);
|
||||
let lines: string[] = [];
|
||||
lines.push('<!-- Blocked Test Report');
|
||||
invalidReport.forEach((reasonAndCount) => {
|
||||
lines.push(reasonAndCount.count + ' tests blocked by ' + reasonAndCount.reason);
|
||||
});
|
||||
lines.push('-->');
|
||||
lines.push('<TaoTest xmlns="http://microsoft.com/schemas/VSLanguages/TAO">');
|
||||
lines.push(' <InitTest>');
|
||||
lines.push(' <StartTarget />');
|
||||
lines.push(' </InitTest>');
|
||||
lines.push(' <ScenarioList>');
|
||||
FourSlash.xmlData.forEach(xml => {
|
||||
if (xml.invalidReason !== null) {
|
||||
lines.push('<!-- Skipped ' + xml.originalName + ', reason: ' + xml.invalidReason + ' -->');
|
||||
} else {
|
||||
lines.push(' <Scenario Name="' + xml.originalName + '">');
|
||||
xml.actions.forEach(action => {
|
||||
lines.push(' ' + action);
|
||||
});
|
||||
lines.push(' </Scenario>');
|
||||
}
|
||||
});
|
||||
lines.push(' </ScenarioList>');
|
||||
lines.push(' <CleanupScenario>');
|
||||
lines.push(' <CloseAllDocuments />');
|
||||
lines.push(' <CleanupCreatedFiles />');
|
||||
lines.push(' </CleanupScenario>');
|
||||
lines.push(' <CleanupTest>');
|
||||
lines.push(' <CloseTarget />');
|
||||
lines.push(' </CleanupTest>');
|
||||
lines.push('</TaoTest>');
|
||||
Harness.IO.writeFile('built/local/fourslash.xml', lines.join('\r\n'));
|
||||
});
|
||||
lines.push('-->');
|
||||
lines.push('<TaoTest xmlns="http://microsoft.com/schemas/VSLanguages/TAO">');
|
||||
lines.push(' <InitTest>');
|
||||
lines.push(' <StartTarget />');
|
||||
lines.push(' </InitTest>');
|
||||
lines.push(' <ScenarioList>');
|
||||
FourSlash.xmlData.forEach(xml => {
|
||||
if (xml.invalidReason !== null) {
|
||||
lines.push('<!-- Skipped ' + xml.originalName + ', reason: ' + xml.invalidReason + ' -->');
|
||||
} else {
|
||||
lines.push(' <Scenario Name="' + xml.originalName + '">');
|
||||
xml.actions.forEach(action => {
|
||||
lines.push(' ' + action);
|
||||
});
|
||||
lines.push(' </Scenario>');
|
||||
}
|
||||
});
|
||||
lines.push(' </ScenarioList>');
|
||||
lines.push(' <CleanupScenario>');
|
||||
lines.push(' <CloseAllDocuments />');
|
||||
lines.push(' <CleanupCreatedFiles />');
|
||||
lines.push(' </CleanupScenario>');
|
||||
lines.push(' <CleanupTest>');
|
||||
lines.push(' <CloseTarget />');
|
||||
lines.push(' </CleanupTest>');
|
||||
lines.push('</TaoTest>');
|
||||
Harness.IO.writeFile('built/local/fourslash.xml', lines.join('\r\n'));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -108,4 +110,4 @@ class GeneratedFourslashRunner extends FourSlashRunner {
|
||||
super(testType);
|
||||
this.basePath += '/generated/';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+170
-175
@@ -33,8 +33,6 @@ declare var __dirname: string; // Node-specific
|
||||
var global = <any>Function("return this").call(null);
|
||||
|
||||
module Utils {
|
||||
var global = <any>Function("return this").call(null);
|
||||
|
||||
// Setup some globals based on the current environment
|
||||
export const enum ExecutionEnvironment {
|
||||
Node,
|
||||
@@ -54,17 +52,17 @@ module Utils {
|
||||
}
|
||||
}
|
||||
|
||||
export var currentExecutionEnvironment = getExecutionEnvironment();
|
||||
export let currentExecutionEnvironment = getExecutionEnvironment();
|
||||
|
||||
export function evalFile(fileContents: string, fileName: string, nodeContext?: any) {
|
||||
var environment = getExecutionEnvironment();
|
||||
let environment = getExecutionEnvironment();
|
||||
switch (environment) {
|
||||
case ExecutionEnvironment.CScript:
|
||||
case ExecutionEnvironment.Browser:
|
||||
eval(fileContents);
|
||||
break;
|
||||
case ExecutionEnvironment.Node:
|
||||
var vm = require('vm');
|
||||
let vm = require('vm');
|
||||
if (nodeContext) {
|
||||
vm.runInNewContext(fileContents, nodeContext, fileName);
|
||||
} else {
|
||||
@@ -81,7 +79,7 @@ module Utils {
|
||||
// Split up the input file by line
|
||||
// Note: IE JS engine incorrectly handles consecutive delimiters here when using RegExp split, so
|
||||
// we have to use string-based splitting instead and try to figure out the delimiting chars
|
||||
var lines = content.split('\r\n');
|
||||
let lines = content.split('\r\n');
|
||||
if (lines.length === 1) {
|
||||
lines = content.split('\n');
|
||||
|
||||
@@ -98,8 +96,9 @@ module Utils {
|
||||
path = "tests/" + path;
|
||||
}
|
||||
|
||||
let content: string = undefined;
|
||||
try {
|
||||
var content = ts.sys.readFile(Harness.userSpecifiedRoot + path);
|
||||
content = ts.sys.readFile(Harness.userSpecifiedRoot + path);
|
||||
}
|
||||
catch (err) {
|
||||
return undefined;
|
||||
@@ -109,11 +108,11 @@ module Utils {
|
||||
}
|
||||
|
||||
export function memoize<T extends Function>(f: T): T {
|
||||
var cache: { [idx: string]: any } = {};
|
||||
let cache: { [idx: string]: any } = {};
|
||||
|
||||
return <any>(function () {
|
||||
var key = Array.prototype.join.call(arguments);
|
||||
var cachedResult = cache[key];
|
||||
let key = Array.prototype.join.call(arguments);
|
||||
let cachedResult = cache[key];
|
||||
if (cachedResult) {
|
||||
return cachedResult;
|
||||
} else {
|
||||
@@ -140,7 +139,7 @@ module Utils {
|
||||
});
|
||||
|
||||
// Make sure each of the children is in order.
|
||||
var currentPos = 0;
|
||||
let currentPos = 0;
|
||||
ts.forEachChild(node,
|
||||
child => {
|
||||
assert.isFalse(child.pos < currentPos, "child.pos < currentPos");
|
||||
@@ -151,22 +150,22 @@ module Utils {
|
||||
assert.isFalse(array.end > node.end, "array.end > node.end");
|
||||
assert.isFalse(array.pos < currentPos, "array.pos < currentPos");
|
||||
|
||||
for (var i = 0, n = array.length; i < n; i++) {
|
||||
for (let i = 0, n = array.length; i < n; i++) {
|
||||
assert.isFalse(array[i].pos < currentPos, "array[i].pos < currentPos");
|
||||
currentPos = array[i].end
|
||||
currentPos = array[i].end;
|
||||
}
|
||||
|
||||
currentPos = array.end;
|
||||
});
|
||||
|
||||
var childNodesAndArrays: any[] = [];
|
||||
ts.forEachChild(node, child => { childNodesAndArrays.push(child) }, array => { childNodesAndArrays.push(array) });
|
||||
let childNodesAndArrays: any[] = [];
|
||||
ts.forEachChild(node, child => { childNodesAndArrays.push(child); }, array => { childNodesAndArrays.push(array); });
|
||||
|
||||
for (var childName in node) {
|
||||
for (let childName in node) {
|
||||
if (childName === "parent" || childName === "nextContainer" || childName === "modifiers" || childName === "externalModuleIndicator") {
|
||||
continue;
|
||||
}
|
||||
var child = (<any>node)[childName];
|
||||
let child = (<any>node)[childName];
|
||||
if (isNodeOrArray(child)) {
|
||||
assert.isFalse(childNodesAndArrays.indexOf(child) < 0,
|
||||
"Missing child when forEach'ing over node: " + (<any>ts).SyntaxKind[node.kind] + "-" + childName);
|
||||
@@ -194,7 +193,7 @@ module Utils {
|
||||
}
|
||||
|
||||
export function sourceFileToJSON(file: ts.Node): string {
|
||||
return JSON.stringify(file,(k, v) => {
|
||||
return JSON.stringify(file, (k, v) => {
|
||||
return isNodeOrArray(v) ? serializeNode(v) : v;
|
||||
}, " ");
|
||||
|
||||
@@ -203,7 +202,7 @@ module Utils {
|
||||
return k;
|
||||
}
|
||||
|
||||
return (<any>ts).SyntaxKind[k]
|
||||
return (<any>ts).SyntaxKind[k];
|
||||
}
|
||||
|
||||
function getFlagName(flags: any, f: number): any {
|
||||
@@ -211,7 +210,7 @@ module Utils {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var result = "";
|
||||
let result = "";
|
||||
ts.forEach(Object.getOwnPropertyNames(flags), (v: any) => {
|
||||
if (isFinite(v)) {
|
||||
v = +v;
|
||||
@@ -234,7 +233,7 @@ module Utils {
|
||||
function getParserContextFlagName(f: number) { return getFlagName((<any>ts).ParserContextFlags, f); }
|
||||
|
||||
function serializeNode(n: ts.Node): any {
|
||||
var o: any = { kind: getKindName(n.kind) };
|
||||
let o: any = { kind: getKindName(n.kind) };
|
||||
if (ts.containsParseError(n)) {
|
||||
o.containsParseError = true;
|
||||
}
|
||||
@@ -268,7 +267,7 @@ module Utils {
|
||||
// Clear the flag that are produced by aggregating child values.. That is ephemeral
|
||||
// data we don't care about in the dump. We only care what the parser set directly
|
||||
// on the ast.
|
||||
var value = n.parserContextFlags & ts.ParserContextFlags.ParserGeneratedFlags;
|
||||
let value = n.parserContextFlags & ts.ParserContextFlags.ParserGeneratedFlags;
|
||||
if (value) {
|
||||
o[propertyName] = getParserContextFlagName(value);
|
||||
}
|
||||
@@ -313,9 +312,9 @@ module Utils {
|
||||
|
||||
assert.equal(array1.length, array2.length, "array1.length !== array2.length");
|
||||
|
||||
for (var i = 0, n = array1.length; i < n; i++) {
|
||||
var d1 = array1[i];
|
||||
var d2 = array2[i];
|
||||
for (let i = 0, n = array1.length; i < n; i++) {
|
||||
let d1 = array1[i];
|
||||
let d2 = array2[i];
|
||||
|
||||
assert.equal(d1.start, d2.start, "d1.start !== d2.start");
|
||||
assert.equal(d1.length, d2.length, "d1.length !== d2.length");
|
||||
@@ -346,14 +345,14 @@ module Utils {
|
||||
|
||||
ts.forEachChild(node1,
|
||||
child1 => {
|
||||
var childName = findChildName(node1, child1);
|
||||
var child2: ts.Node = (<any>node2)[childName];
|
||||
let childName = findChildName(node1, child1);
|
||||
let child2: ts.Node = (<any>node2)[childName];
|
||||
|
||||
assertStructuralEquals(child1, child2);
|
||||
},
|
||||
(array1: ts.NodeArray<ts.Node>) => {
|
||||
var childName = findChildName(node1, array1);
|
||||
var array2: ts.NodeArray<ts.Node> = (<any>node2)[childName];
|
||||
let childName = findChildName(node1, array1);
|
||||
let array2: ts.NodeArray<ts.Node> = (<any>node2)[childName];
|
||||
|
||||
assertArrayStructuralEquals(array1, array2);
|
||||
});
|
||||
@@ -370,13 +369,13 @@ module Utils {
|
||||
assert.equal(array1.end, array2.end, "array1.end !== array2.end");
|
||||
assert.equal(array1.length, array2.length, "array1.length !== array2.length");
|
||||
|
||||
for (var i = 0, n = array1.length; i < n; i++) {
|
||||
for (let i = 0, n = array1.length; i < n; i++) {
|
||||
assertStructuralEquals(array1[i], array2[i]);
|
||||
}
|
||||
}
|
||||
|
||||
function findChildName(parent: any, child: any) {
|
||||
for (var name in parent) {
|
||||
for (let name in parent) {
|
||||
if (parent.hasOwnProperty(name) && parent[name] === child) {
|
||||
return name;
|
||||
}
|
||||
@@ -393,8 +392,8 @@ module Harness.Path {
|
||||
|
||||
export function filePath(fullPath: string) {
|
||||
fullPath = ts.normalizeSlashes(fullPath);
|
||||
var components = fullPath.split("/");
|
||||
var path: string[] = components.slice(0, components.length - 1);
|
||||
let components = fullPath.split("/");
|
||||
let path: string[] = components.slice(0, components.length - 1);
|
||||
return path.join("/") + "/";
|
||||
}
|
||||
}
|
||||
@@ -422,19 +421,19 @@ module Harness {
|
||||
}
|
||||
|
||||
export module CScript {
|
||||
var fso: any;
|
||||
let fso: any;
|
||||
if (global.ActiveXObject) {
|
||||
fso = new global.ActiveXObject("Scripting.FileSystemObject");
|
||||
} else {
|
||||
fso = {};
|
||||
}
|
||||
|
||||
export var readFile: typeof IO.readFile = ts.sys.readFile;
|
||||
export var writeFile: typeof IO.writeFile = ts.sys.writeFile;
|
||||
export var directoryName: typeof IO.directoryName = fso.GetParentFolderName;
|
||||
export var directoryExists: typeof IO.directoryExists = fso.FolderExists;
|
||||
export var fileExists: typeof IO.fileExists = fso.FileExists;
|
||||
export var log: typeof IO.log = global.WScript && global.WScript.StdOut.WriteLine;
|
||||
export let readFile: typeof IO.readFile = ts.sys.readFile;
|
||||
export let writeFile: typeof IO.writeFile = ts.sys.writeFile;
|
||||
export let directoryName: typeof IO.directoryName = fso.GetParentFolderName;
|
||||
export let directoryExists: typeof IO.directoryExists = fso.FolderExists;
|
||||
export let fileExists: typeof IO.fileExists = fso.FileExists;
|
||||
export let log: typeof IO.log = global.WScript && global.WScript.StdOut.WriteLine;
|
||||
|
||||
export function createDirectory(path: string) {
|
||||
if (directoryExists(path)) {
|
||||
@@ -448,11 +447,11 @@ module Harness {
|
||||
}
|
||||
}
|
||||
|
||||
export var listFiles: typeof IO.listFiles = (path, spec?, options?) => {
|
||||
export let listFiles: typeof IO.listFiles = (path, spec?, options?) => {
|
||||
options = options || <{ recursive?: boolean; }>{};
|
||||
function filesInFolder(folder: any, root: string): string[] {
|
||||
var paths: string[] = [];
|
||||
var fc: any;
|
||||
let paths: string[] = [];
|
||||
let fc: any;
|
||||
|
||||
if (options.recursive) {
|
||||
fc = new Enumerator(folder.subfolders);
|
||||
@@ -473,17 +472,16 @@ module Harness {
|
||||
return paths;
|
||||
}
|
||||
|
||||
var folder: any = fso.GetFolder(path);
|
||||
var paths: string[] = [];
|
||||
let folder: any = fso.GetFolder(path);
|
||||
let paths: string[] = [];
|
||||
|
||||
return filesInFolder(folder, path);
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export module Node {
|
||||
declare var require: any;
|
||||
var fs: any, pathModule: any;
|
||||
declare let require: any;
|
||||
let fs: any, pathModule: any;
|
||||
if (require) {
|
||||
fs = require('fs');
|
||||
pathModule = require('path');
|
||||
@@ -491,10 +489,10 @@ module Harness {
|
||||
fs = pathModule = {};
|
||||
}
|
||||
|
||||
export var readFile: typeof IO.readFile = ts.sys.readFile;
|
||||
export var writeFile: typeof IO.writeFile = ts.sys.writeFile;
|
||||
export var fileExists: typeof IO.fileExists = fs.existsSync;
|
||||
export var log: typeof IO.log = console.log;
|
||||
export let readFile: typeof IO.readFile = ts.sys.readFile;
|
||||
export let writeFile: typeof IO.writeFile = ts.sys.writeFile;
|
||||
export let fileExists: typeof IO.fileExists = fs.existsSync;
|
||||
export let log: typeof IO.log = console.log;
|
||||
|
||||
export function createDirectory(path: string) {
|
||||
if (!directoryExists(path)) {
|
||||
@@ -514,7 +512,7 @@ module Harness {
|
||||
}
|
||||
|
||||
export function directoryName(path: string) {
|
||||
var dirPath = pathModule.dirname(path);
|
||||
let dirPath = pathModule.dirname(path);
|
||||
|
||||
// Node will just continue to repeat the root path, rather than return null
|
||||
if (dirPath === path) {
|
||||
@@ -524,16 +522,16 @@ module Harness {
|
||||
}
|
||||
}
|
||||
|
||||
export var listFiles: typeof IO.listFiles = (path, spec?, options?) => {
|
||||
export let listFiles: typeof IO.listFiles = (path, spec?, options?) => {
|
||||
options = options || <{ recursive?: boolean; }>{};
|
||||
|
||||
function filesInFolder(folder: string): string[] {
|
||||
var paths: string[] = [];
|
||||
let paths: string[] = [];
|
||||
|
||||
var files = fs.readdirSync(folder);
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
var pathToFile = pathModule.join(folder, files[i]);
|
||||
var stat = fs.statSync(pathToFile);
|
||||
let files = fs.readdirSync(folder);
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
let pathToFile = pathModule.join(folder, files[i]);
|
||||
let stat = fs.statSync(pathToFile);
|
||||
if (options.recursive && stat.isDirectory()) {
|
||||
paths = paths.concat(filesInFolder(pathToFile));
|
||||
}
|
||||
@@ -546,23 +544,23 @@ module Harness {
|
||||
}
|
||||
|
||||
return filesInFolder(path);
|
||||
}
|
||||
};
|
||||
|
||||
export var getMemoryUsage: typeof IO.getMemoryUsage = () => {
|
||||
export let getMemoryUsage: typeof IO.getMemoryUsage = () => {
|
||||
if (global.gc) {
|
||||
global.gc();
|
||||
}
|
||||
return process.memoryUsage().heapUsed;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export module Network {
|
||||
var serverRoot = "http://localhost:8888/";
|
||||
let serverRoot = "http://localhost:8888/";
|
||||
|
||||
// Unused?
|
||||
var newLine = '\r\n';
|
||||
var currentDirectory = () => '';
|
||||
var supportsCodePage = () => false;
|
||||
let newLine = '\r\n';
|
||||
let currentDirectory = () => '';
|
||||
let supportsCodePage = () => false;
|
||||
|
||||
module Http {
|
||||
function waitForXHR(xhr: XMLHttpRequest) {
|
||||
@@ -572,7 +570,7 @@ module Harness {
|
||||
|
||||
/// Ask the server to use node's path.resolve to resolve the given path
|
||||
function getResolvedPathFromServer(path: string) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
let xhr = new XMLHttpRequest();
|
||||
try {
|
||||
xhr.open("GET", path + "?resolve", false);
|
||||
xhr.send();
|
||||
@@ -591,7 +589,7 @@ module Harness {
|
||||
|
||||
/// Ask the server for the contents of the file at the given URL via a simple GET request
|
||||
export function getFileFromServerSync(url: string): XHRResponse {
|
||||
var xhr = new XMLHttpRequest();
|
||||
let xhr = new XMLHttpRequest();
|
||||
try {
|
||||
xhr.open("GET", url, false);
|
||||
xhr.send();
|
||||
@@ -605,10 +603,10 @@ module Harness {
|
||||
|
||||
/// Submit a POST request to the server to do the given action (ex WRITE, DELETE) on the provided URL
|
||||
export function writeToServerSync(url: string, action: string, contents?: string): XHRResponse {
|
||||
var xhr = new XMLHttpRequest();
|
||||
let xhr = new XMLHttpRequest();
|
||||
try {
|
||||
var action = '?action=' + action;
|
||||
xhr.open('POST', url + action, false);
|
||||
let actionMsg = '?action=' + action;
|
||||
xhr.open('POST', url + actionMsg, false);
|
||||
xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
|
||||
xhr.send(contents);
|
||||
}
|
||||
@@ -633,7 +631,7 @@ module Harness {
|
||||
}
|
||||
|
||||
function directoryNameImpl(path: string) {
|
||||
var dirPath = path;
|
||||
let dirPath = path;
|
||||
// root of the server
|
||||
if (dirPath.match(/localhost:\d+$/) || dirPath.match(/localhost:\d+\/$/)) {
|
||||
dirPath = null;
|
||||
@@ -646,22 +644,22 @@ module Harness {
|
||||
if (dirPath.match(/.*\/$/)) {
|
||||
dirPath = dirPath.substring(0, dirPath.length - 2);
|
||||
}
|
||||
var dirPath = dirPath.substring(0, dirPath.lastIndexOf('/'));
|
||||
dirPath = dirPath.substring(0, dirPath.lastIndexOf('/'));
|
||||
}
|
||||
|
||||
return dirPath;
|
||||
}
|
||||
export var directoryName: typeof IO.directoryName = Utils.memoize(directoryNameImpl);
|
||||
export let directoryName: typeof IO.directoryName = Utils.memoize(directoryNameImpl);
|
||||
|
||||
export function fileExists(path: string): boolean {
|
||||
var response = Http.getFileFromServerSync(serverRoot + path);
|
||||
let response = Http.getFileFromServerSync(serverRoot + path);
|
||||
return response.status === 200;
|
||||
}
|
||||
|
||||
export function _listFilesImpl(path: string, spec?: RegExp, options?: any) {
|
||||
var response = Http.getFileFromServerSync(serverRoot + path);
|
||||
let response = Http.getFileFromServerSync(serverRoot + path);
|
||||
if (response.status === 200) {
|
||||
var results = response.responseText.split(',');
|
||||
let results = response.responseText.split(',');
|
||||
if (spec) {
|
||||
return results.filter(file => spec.test(file));
|
||||
} else {
|
||||
@@ -672,12 +670,12 @@ module Harness {
|
||||
return [''];
|
||||
}
|
||||
};
|
||||
export var listFiles = Utils.memoize(_listFilesImpl);
|
||||
export let listFiles = Utils.memoize(_listFilesImpl);
|
||||
|
||||
export var log = console.log;
|
||||
export let log = console.log;
|
||||
|
||||
export function readFile(file: string) {
|
||||
var response = Http.getFileFromServerSync(serverRoot + file);
|
||||
let response = Http.getFileFromServerSync(serverRoot + file);
|
||||
if (response.status === 200) {
|
||||
return response.responseText;
|
||||
} else {
|
||||
@@ -706,9 +704,9 @@ module Harness {
|
||||
}
|
||||
|
||||
module Harness {
|
||||
var tcServicesFileName = "typescriptServices.js";
|
||||
let tcServicesFileName = "typescriptServices.js";
|
||||
|
||||
export var libFolder: string;
|
||||
export let libFolder: string;
|
||||
switch (Utils.getExecutionEnvironment()) {
|
||||
case Utils.ExecutionEnvironment.CScript:
|
||||
libFolder = "built/local/";
|
||||
@@ -725,7 +723,7 @@ module Harness {
|
||||
default:
|
||||
throw new Error('Unknown context');
|
||||
}
|
||||
export var tcServicesFile = IO.readFile(tcServicesFileName);
|
||||
export let tcServicesFile = IO.readFile(tcServicesFileName);
|
||||
|
||||
export interface SourceMapEmitterCallback {
|
||||
(emittedFile: string, emittedLine: number, emittedColumn: number, sourceFile: string, sourceLine: number, sourceColumn: number, sourceName: string): void;
|
||||
@@ -777,7 +775,7 @@ module Harness {
|
||||
|
||||
/** create file gets the whole path to create, so this works as expected with the --out parameter */
|
||||
public writeFile(s: string, contents: string, writeByteOrderMark: boolean): void {
|
||||
var writer: ITextWriter;
|
||||
let writer: ITextWriter;
|
||||
if (this.fileCollection[s]) {
|
||||
writer = <ITextWriter>this.fileCollection[s];
|
||||
}
|
||||
@@ -795,10 +793,10 @@ module Harness {
|
||||
public reset() { this.fileCollection = {}; }
|
||||
|
||||
public toArray(): { fileName: string; file: WriterAggregator; }[] {
|
||||
var result: { fileName: string; file: WriterAggregator; }[] = [];
|
||||
for (var p in this.fileCollection) {
|
||||
let result: { fileName: string; file: WriterAggregator; }[] = [];
|
||||
for (let p in this.fileCollection) {
|
||||
if (this.fileCollection.hasOwnProperty(p)) {
|
||||
var current = <Harness.Compiler.WriterAggregator>this.fileCollection[p];
|
||||
let current = <Harness.Compiler.WriterAggregator>this.fileCollection[p];
|
||||
if (current.lines.length > 0) {
|
||||
if (p.indexOf('.d.ts') !== -1) { current.lines.unshift(['////[', Path.getFileName(p), ']'].join('')); }
|
||||
result.push({ fileName: p, file: this.fileCollection[p] });
|
||||
@@ -813,11 +811,11 @@ module Harness {
|
||||
fileName: string,
|
||||
sourceText: string,
|
||||
languageVersion: ts.ScriptTarget) {
|
||||
// We'll only assert invariants outside of light mode.
|
||||
// We'll only assert inletiants outside of light mode.
|
||||
const shouldAssertInvariants = !Harness.lightMode;
|
||||
|
||||
// Only set the parent nodes if we're asserting invariants. We don't need them otherwise.
|
||||
var result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ shouldAssertInvariants);
|
||||
// Only set the parent nodes if we're asserting inletiants. We don't need them otherwise.
|
||||
let result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ shouldAssertInvariants);
|
||||
|
||||
if (shouldAssertInvariants) {
|
||||
Utils.assertInvariants(result, /*parent:*/ undefined);
|
||||
@@ -829,13 +827,13 @@ module Harness {
|
||||
const carriageReturnLineFeed = "\r\n";
|
||||
const lineFeed = "\n";
|
||||
|
||||
export var defaultLibFileName = 'lib.d.ts';
|
||||
export var defaultLibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest);
|
||||
export var defaultES6LibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest);
|
||||
export let defaultLibFileName = 'lib.d.ts';
|
||||
export let defaultLibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest);
|
||||
export let defaultES6LibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest);
|
||||
|
||||
// Cache these between executions so we don't have to re-parse them for every test
|
||||
export var fourslashFileName = 'fourslash.ts';
|
||||
export var fourslashSourceFile: ts.SourceFile;
|
||||
export let fourslashFileName = 'fourslash.ts';
|
||||
export let fourslashSourceFile: ts.SourceFile;
|
||||
|
||||
export function getCanonicalFileName(fileName: string): string {
|
||||
return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
|
||||
@@ -855,13 +853,13 @@ module Harness {
|
||||
return useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
|
||||
}
|
||||
|
||||
var filemap: { [fileName: string]: ts.SourceFile; } = {};
|
||||
var getCurrentDirectory = currentDirectory === undefined ? ts.sys.getCurrentDirectory : () => currentDirectory;
|
||||
let filemap: { [fileName: string]: ts.SourceFile; } = {};
|
||||
let getCurrentDirectory = currentDirectory === undefined ? ts.sys.getCurrentDirectory : () => currentDirectory;
|
||||
|
||||
// Register input files
|
||||
function register(file: { unitName: string; content: string; }) {
|
||||
if (file.content !== undefined) {
|
||||
var fileName = ts.normalizePath(file.unitName);
|
||||
let fileName = ts.normalizePath(file.unitName);
|
||||
filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget);
|
||||
}
|
||||
};
|
||||
@@ -880,11 +878,11 @@ module Harness {
|
||||
return filemap[getCanonicalFileName(fn)];
|
||||
}
|
||||
else if (currentDirectory) {
|
||||
var canonicalAbsolutePath = getCanonicalFileName(ts.getNormalizedAbsolutePath(fn, currentDirectory));
|
||||
let canonicalAbsolutePath = getCanonicalFileName(ts.getNormalizedAbsolutePath(fn, currentDirectory));
|
||||
return Object.prototype.hasOwnProperty.call(filemap, getCanonicalFileName(canonicalAbsolutePath)) ? filemap[canonicalAbsolutePath] : undefined;
|
||||
}
|
||||
else if (fn === fourslashFileName) {
|
||||
var tsFn = 'tests/cases/fourslash/' + fourslashFileName;
|
||||
let tsFn = 'tests/cases/fourslash/' + fourslashFileName;
|
||||
fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants(tsFn, Harness.IO.readFile(tsFn), scriptTarget);
|
||||
return fourslashSourceFile;
|
||||
}
|
||||
@@ -980,27 +978,27 @@ module Harness {
|
||||
|
||||
// Files from built\local that are requested by test "@includeBuiltFiles" to be in the context.
|
||||
// Treat them as library files, so include them in build, but not in baselines.
|
||||
var includeBuiltFiles: { unitName: string; content: string }[] = [];
|
||||
let includeBuiltFiles: { unitName: string; content: string }[] = [];
|
||||
|
||||
var useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames;
|
||||
let useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames;
|
||||
this.settings.forEach(setCompilerOptionForSetting);
|
||||
|
||||
var fileOutputs: GeneratedFile[] = [];
|
||||
let fileOutputs: GeneratedFile[] = [];
|
||||
|
||||
var programFiles = inputFiles.concat(includeBuiltFiles).map(file => file.unitName);
|
||||
let programFiles = inputFiles.concat(includeBuiltFiles).map(file => file.unitName);
|
||||
|
||||
var compilerHost = createCompilerHost(
|
||||
let compilerHost = createCompilerHost(
|
||||
inputFiles.concat(includeBuiltFiles).concat(otherFiles),
|
||||
(fn, contents, writeByteOrderMark) => fileOutputs.push({ fileName: fn, code: contents, writeByteOrderMark: writeByteOrderMark }),
|
||||
options.target, useCaseSensitiveFileNames, currentDirectory, options.newLine);
|
||||
var program = ts.createProgram(programFiles, options, compilerHost);
|
||||
let program = ts.createProgram(programFiles, options, compilerHost);
|
||||
|
||||
var emitResult = program.emit();
|
||||
let emitResult = program.emit();
|
||||
|
||||
var errors = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
||||
let errors = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
||||
this.lastErrors = errors;
|
||||
|
||||
var result = new CompilerResult(fileOutputs, errors, program, ts.sys.getCurrentDirectory(), emitResult.sourceMaps);
|
||||
let result = new CompilerResult(fileOutputs, errors, program, ts.sys.getCurrentDirectory(), emitResult.sourceMaps);
|
||||
onComplete(result, program);
|
||||
|
||||
// reset what newline means in case the last test changed it
|
||||
@@ -1193,12 +1191,12 @@ module Harness {
|
||||
throw new Error('There were no errors and declFiles generated did not match number of js files generated');
|
||||
}
|
||||
|
||||
let declInputFiles: { unitName: string; content: string }[] = [];
|
||||
let declOtherFiles: { unitName: string; content: string }[] = [];
|
||||
let declResult: Harness.Compiler.CompilerResult;
|
||||
|
||||
// if the .d.ts is non-empty, confirm it compiles correctly as well
|
||||
if (options.declaration && result.errors.length === 0 && result.declFilesCode.length > 0) {
|
||||
var declInputFiles: { unitName: string; content: string }[] = [];
|
||||
var declOtherFiles: { unitName: string; content: string }[] = [];
|
||||
var declResult: Harness.Compiler.CompilerResult;
|
||||
|
||||
ts.forEach(inputFiles, file => addDtsFile(file, declInputFiles));
|
||||
ts.forEach(otherFiles, file => addDtsFile(file, declOtherFiles));
|
||||
this.compileFiles(declInputFiles, declOtherFiles, function (compileResult) { declResult = compileResult; },
|
||||
@@ -1212,20 +1210,20 @@ module Harness {
|
||||
dtsFiles.push(file);
|
||||
}
|
||||
else if (isTS(file.unitName)) {
|
||||
var declFile = findResultCodeFile(file.unitName);
|
||||
let declFile = findResultCodeFile(file.unitName);
|
||||
if (!findUnit(declFile.fileName, declInputFiles) && !findUnit(declFile.fileName, declOtherFiles)) {
|
||||
dtsFiles.push({ unitName: declFile.fileName, content: declFile.code });
|
||||
}
|
||||
}
|
||||
|
||||
function findResultCodeFile(fileName: string) {
|
||||
var sourceFile = result.program.getSourceFile(fileName);
|
||||
let sourceFile = result.program.getSourceFile(fileName);
|
||||
assert(sourceFile, "Program has no source file with name '" + fileName + "'");
|
||||
// Is this file going to be emitted separately
|
||||
var sourceFileName: string;
|
||||
let sourceFileName: string;
|
||||
if (ts.isExternalModule(sourceFile) || !options.out) {
|
||||
if (options.outDir) {
|
||||
var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, result.currentDirectoryForProgram);
|
||||
let sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, result.currentDirectoryForProgram);
|
||||
sourceFilePath = sourceFilePath.replace(result.program.getCommonSourceDirectory(), "");
|
||||
sourceFileName = ts.combinePaths(options.outDir, sourceFilePath);
|
||||
}
|
||||
@@ -1238,7 +1236,7 @@ module Harness {
|
||||
sourceFileName = options.out;
|
||||
}
|
||||
|
||||
var dTsFileName = ts.removeFileExtension(sourceFileName) + ".d.ts";
|
||||
let dTsFileName = ts.removeFileExtension(sourceFileName) + ".d.ts";
|
||||
|
||||
return ts.forEach(result.declFilesCode, declFile => declFile.fileName === dTsFileName ? declFile : undefined);
|
||||
}
|
||||
@@ -1251,7 +1249,7 @@ module Harness {
|
||||
}
|
||||
|
||||
function normalizeLineEndings(text: string, lineEnding: string): string {
|
||||
var normalized = text.replace(/\r\n?/g, '\n');
|
||||
let normalized = text.replace(/\r\n?/g, '\n');
|
||||
if (lineEnding !== '\n') {
|
||||
normalized = normalized.replace(/\n/g, lineEnding);
|
||||
}
|
||||
@@ -1260,10 +1258,10 @@ module Harness {
|
||||
|
||||
export function minimalDiagnosticsToString(diagnostics: ts.Diagnostic[]) {
|
||||
// This is basically copied from tsc.ts's reportError to replicate what tsc does
|
||||
var errorOutput = "";
|
||||
let errorOutput = "";
|
||||
ts.forEach(diagnostics, diagnostic => {
|
||||
if (diagnostic.file) {
|
||||
var lineAndCharacter = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
let lineAndCharacter = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
errorOutput += diagnostic.file.fileName + "(" + (lineAndCharacter.line + 1) + "," + (lineAndCharacter.character + 1) + "): ";
|
||||
}
|
||||
|
||||
@@ -1275,14 +1273,14 @@ module Harness {
|
||||
|
||||
export function getErrorBaseline(inputFiles: { unitName: string; content: string }[], diagnostics: ts.Diagnostic[]) {
|
||||
diagnostics.sort(ts.compareDiagnostics);
|
||||
var outputLines: string[] = [];
|
||||
let outputLines: string[] = [];
|
||||
// Count up all the errors we find so we don't miss any
|
||||
var totalErrorsReported = 0;
|
||||
let totalErrorsReported = 0;
|
||||
|
||||
function outputErrorText(error: ts.Diagnostic) {
|
||||
var message = ts.flattenDiagnosticMessageText(error.messageText, ts.sys.newLine);
|
||||
let message = ts.flattenDiagnosticMessageText(error.messageText, ts.sys.newLine);
|
||||
|
||||
var errLines = RunnerBase.removeFullPaths(message)
|
||||
let errLines = RunnerBase.removeFullPaths(message)
|
||||
.split('\n')
|
||||
.map(s => s.length > 0 && s.charAt(s.length - 1) === '\r' ? s.substr(0, s.length - 1) : s)
|
||||
.filter(s => s.length > 0)
|
||||
@@ -1293,14 +1291,14 @@ module Harness {
|
||||
}
|
||||
|
||||
// Report global errors
|
||||
var globalErrors = diagnostics.filter(err => !err.file);
|
||||
let globalErrors = diagnostics.filter(err => !err.file);
|
||||
globalErrors.forEach(outputErrorText);
|
||||
|
||||
// 'merge' the lines of each input file with any errors associated with it
|
||||
inputFiles.filter(f => f.content !== undefined).forEach(inputFile => {
|
||||
// Filter down to the errors in the file
|
||||
var fileErrors = diagnostics.filter(e => {
|
||||
var errFn = e.file;
|
||||
let fileErrors = diagnostics.filter(e => {
|
||||
let errFn = e.file;
|
||||
return errFn && errFn.fileName === inputFile.unitName;
|
||||
});
|
||||
|
||||
@@ -1309,13 +1307,13 @@ module Harness {
|
||||
outputLines.push('==== ' + inputFile.unitName + ' (' + fileErrors.length + ' errors) ====');
|
||||
|
||||
// Make sure we emit something for every error
|
||||
var markedErrorCount = 0;
|
||||
let markedErrorCount = 0;
|
||||
// For each line, emit the line followed by any error squiggles matching this line
|
||||
// Note: IE JS engine incorrectly handles consecutive delimiters here when using RegExp split, so
|
||||
// we have to string-based splitting instead and try to figure out the delimiting chars
|
||||
|
||||
var lineStarts = ts.computeLineStarts(inputFile.content);
|
||||
var lines = inputFile.content.split('\n');
|
||||
let lineStarts = ts.computeLineStarts(inputFile.content);
|
||||
let lines = inputFile.content.split('\n');
|
||||
if (lines.length === 1) {
|
||||
lines = lines[0].split("\r");
|
||||
}
|
||||
@@ -1325,8 +1323,8 @@ module Harness {
|
||||
line = line.substr(0, line.length - 1);
|
||||
}
|
||||
|
||||
var thisLineStart = lineStarts[lineIndex];
|
||||
var nextLineStart: number;
|
||||
let thisLineStart = lineStarts[lineIndex];
|
||||
let nextLineStart: number;
|
||||
// On the last line of the file, fake the next line start number so that we handle errors on the last character of the file correctly
|
||||
if (lineIndex === lines.length - 1) {
|
||||
nextLineStart = inputFile.content.length;
|
||||
@@ -1340,11 +1338,11 @@ module Harness {
|
||||
let end = ts.textSpanEnd(err);
|
||||
if ((end >= thisLineStart) && ((err.start < nextLineStart) || (lineIndex === lines.length - 1))) {
|
||||
// How many characters from the start of this line the error starts at (could be positive or negative)
|
||||
var relativeOffset = err.start - thisLineStart;
|
||||
let relativeOffset = err.start - thisLineStart;
|
||||
// How many characters of the error are on this line (might be longer than this line in reality)
|
||||
var length = (end - err.start) - Math.max(0, thisLineStart - err.start);
|
||||
let length = (end - err.start) - Math.max(0, thisLineStart - err.start);
|
||||
// Calculate the start of the squiggle
|
||||
var squiggleStart = Math.max(0, relativeOffset);
|
||||
let squiggleStart = Math.max(0, relativeOffset);
|
||||
// TODO/REVIEW: this doesn't work quite right in the browser if a multi file test has files whose names are just the right length relative to one another
|
||||
outputLines.push(' ' + line.substr(0, squiggleStart).replace(/[^\s]/g, ' ') + new Array(Math.min(length, line.length - squiggleStart) + 1).join('~'));
|
||||
|
||||
@@ -1364,11 +1362,11 @@ module Harness {
|
||||
assert.equal(markedErrorCount, fileErrors.length, 'count of errors in ' + inputFile.unitName);
|
||||
});
|
||||
|
||||
var numLibraryDiagnostics = ts.countWhere(diagnostics, diagnostic => {
|
||||
let numLibraryDiagnostics = ts.countWhere(diagnostics, diagnostic => {
|
||||
return diagnostic.file && (isLibraryFile(diagnostic.file.fileName) || isBuiltFile(diagnostic.file.fileName));
|
||||
});
|
||||
|
||||
var numTest262HarnessDiagnostics = ts.countWhere(diagnostics, diagnostic => {
|
||||
let numTest262HarnessDiagnostics = ts.countWhere(diagnostics, diagnostic => {
|
||||
// Count an error generated from tests262-harness folder.This should only apply for test262
|
||||
return diagnostic.file && diagnostic.file.fileName.indexOf("test262-harness") >= 0;
|
||||
});
|
||||
@@ -1385,7 +1383,7 @@ module Harness {
|
||||
outputFiles.sort((a, b) => cleanName(a.fileName).localeCompare(cleanName(b.fileName)));
|
||||
|
||||
// Emit them
|
||||
var result = '';
|
||||
let result = '';
|
||||
for (let outputFile of outputFiles) {
|
||||
// Some extra spacing if this isn't the first file
|
||||
if (result.length) {
|
||||
@@ -1401,13 +1399,13 @@ module Harness {
|
||||
return result;
|
||||
|
||||
function cleanName(fn: string) {
|
||||
var lastSlash = ts.normalizeSlashes(fn).lastIndexOf('/');
|
||||
let lastSlash = ts.normalizeSlashes(fn).lastIndexOf('/');
|
||||
return fn.substr(lastSlash + 1).toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
/** The harness' compiler instance used when tests are actually run. Reseting or changing settings of this compiler instance must be done within a test case (i.e., describe/it) */
|
||||
var harnessCompiler: HarnessCompiler;
|
||||
let harnessCompiler: HarnessCompiler;
|
||||
|
||||
/** Returns the singleton harness compiler instance for generating and running tests.
|
||||
If required a fresh compiler instance will be created, otherwise the existing singleton will be re-used.
|
||||
@@ -1420,8 +1418,6 @@ module Harness {
|
||||
export function compileString(code: string, unitName: string, callback: (result: CompilerResult) => void) {
|
||||
// NEWTODO: Re-implement 'compileString'
|
||||
throw new Error('compileString NYI');
|
||||
//var harnessCompiler = Harness.Compiler.getCompiler(Harness.Compiler.CompilerInstance.RunTime);
|
||||
//harnessCompiler.compileString(code, unitName, callback);
|
||||
}
|
||||
|
||||
export interface GeneratedFile {
|
||||
@@ -1513,10 +1509,10 @@ module Harness {
|
||||
}
|
||||
|
||||
// Regex for parsing options in the format "@Alpha: Value of any sort"
|
||||
var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines
|
||||
let optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines
|
||||
|
||||
// List of allowed metadata names
|
||||
var fileMetadataNames = ["filename", "comments", "declaration", "module",
|
||||
let fileMetadataNames = ["filename", "comments", "declaration", "module",
|
||||
"nolib", "sourcemap", "target", "out", "outdir", "noemithelpers", "noemitonerror",
|
||||
"noimplicitany", "noresolve", "newline", "normalizenewline", "emitbom",
|
||||
"errortruncation", "usecasesensitivefilenames", "preserveconstenums",
|
||||
@@ -1527,9 +1523,9 @@ module Harness {
|
||||
|
||||
function extractCompilerSettings(content: string): CompilerSetting[] {
|
||||
|
||||
var opts: CompilerSetting[] = [];
|
||||
let opts: CompilerSetting[] = [];
|
||||
|
||||
var match: RegExpExecArray;
|
||||
let match: RegExpExecArray;
|
||||
while ((match = optionRegex.exec(content)) != null) {
|
||||
opts.push({ flag: match[1], value: match[2] });
|
||||
}
|
||||
@@ -1539,26 +1535,26 @@ module Harness {
|
||||
|
||||
/** Given a test file containing // @FileName directives, return an array of named units of code to be added to an existing compiler instance */
|
||||
export function makeUnitsFromTest(code: string, fileName: string): { settings: CompilerSetting[]; testUnitData: TestUnitData[]; } {
|
||||
var settings = extractCompilerSettings(code);
|
||||
let settings = extractCompilerSettings(code);
|
||||
|
||||
// List of all the subfiles we've parsed out
|
||||
var testUnitData: TestUnitData[] = [];
|
||||
let testUnitData: TestUnitData[] = [];
|
||||
|
||||
var lines = Utils.splitContentByNewlines(code);
|
||||
let lines = Utils.splitContentByNewlines(code);
|
||||
|
||||
// Stuff related to the subfile we're parsing
|
||||
var currentFileContent: string = null;
|
||||
var currentFileOptions: any = {};
|
||||
var currentFileName: any = null;
|
||||
var refs: string[] = [];
|
||||
let currentFileContent: string = null;
|
||||
let currentFileOptions: any = {};
|
||||
let currentFileName: any = null;
|
||||
let refs: string[] = [];
|
||||
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var line = lines[i];
|
||||
var testMetaData = optionRegex.exec(line);
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
let line = lines[i];
|
||||
let testMetaData = optionRegex.exec(line);
|
||||
if (testMetaData) {
|
||||
// Comment line, check for global/file @options and record them
|
||||
optionRegex.lastIndex = 0;
|
||||
var metaDataName = testMetaData[1].toLowerCase();
|
||||
let metaDataName = testMetaData[1].toLowerCase();
|
||||
if (metaDataName === "filename") {
|
||||
currentFileOptions[testMetaData[1]] = testMetaData[2];
|
||||
} else {
|
||||
@@ -1568,8 +1564,7 @@ module Harness {
|
||||
// New metadata statement after having collected some code to go with the previous metadata
|
||||
if (currentFileName) {
|
||||
// Store result file
|
||||
var newTestFile =
|
||||
{
|
||||
let newTestFile = {
|
||||
content: currentFileContent,
|
||||
name: currentFileName,
|
||||
fileOptions: currentFileOptions,
|
||||
@@ -1604,7 +1599,7 @@ module Harness {
|
||||
currentFileName = testUnitData.length > 0 ? currentFileName : Path.getFileName(fileName);
|
||||
|
||||
// EOF, push whatever remains
|
||||
var newTestFile2 = {
|
||||
let newTestFile2 = {
|
||||
content: currentFileContent || '',
|
||||
name: currentFileName,
|
||||
fileOptions: currentFileOptions,
|
||||
@@ -1651,7 +1646,7 @@ module Harness {
|
||||
}
|
||||
}
|
||||
|
||||
var fileCache: { [idx: string]: boolean } = {};
|
||||
let fileCache: { [idx: string]: boolean } = {};
|
||||
function generateActual(actualFileName: string, generateContent: () => string): string {
|
||||
// For now this is written using TypeScript, because sys is not available when running old test cases.
|
||||
// But we need to move to sys once we have
|
||||
@@ -1662,7 +1657,7 @@ module Harness {
|
||||
return;
|
||||
}
|
||||
|
||||
var parentDirectory = IO.directoryName(dirName);
|
||||
let parentDirectory = IO.directoryName(dirName);
|
||||
if (parentDirectory != "") {
|
||||
createDirectoryStructure(parentDirectory);
|
||||
}
|
||||
@@ -1678,7 +1673,7 @@ module Harness {
|
||||
IO.deleteFile(actualFileName);
|
||||
}
|
||||
|
||||
var actual = generateContent();
|
||||
let actual = generateContent();
|
||||
|
||||
if (actual === undefined) {
|
||||
throw new Error('The generated content was "undefined". Return "null" if no baselining is required."');
|
||||
@@ -1701,13 +1696,13 @@ module Harness {
|
||||
return;
|
||||
}
|
||||
|
||||
var refFileName = referencePath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder);
|
||||
let refFileName = referencePath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder);
|
||||
|
||||
if (actual === null) {
|
||||
actual = '<no content>';
|
||||
}
|
||||
|
||||
var expected = '<no content>';
|
||||
let expected = '<no content>';
|
||||
if (IO.fileExists(refFileName)) {
|
||||
expected = IO.readFile(refFileName);
|
||||
}
|
||||
@@ -1716,10 +1711,10 @@ module Harness {
|
||||
}
|
||||
|
||||
function writeComparison(expected: string, actual: string, relativeFileName: string, actualFileName: string, descriptionForDescribe: string) {
|
||||
var encoded_actual = (new Buffer(actual)).toString('utf8')
|
||||
let encoded_actual = (new Buffer(actual)).toString('utf8');
|
||||
if (expected != encoded_actual) {
|
||||
// Overwrite & issue error
|
||||
var errMsg = 'The baseline file ' + relativeFileName + ' has changed';
|
||||
let errMsg = 'The baseline file ' + relativeFileName + ' has changed';
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
}
|
||||
@@ -1731,17 +1726,17 @@ module Harness {
|
||||
runImmediately = false,
|
||||
opts?: BaselineOptions): void {
|
||||
|
||||
var actual = <string>undefined;
|
||||
var actualFileName = localPath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder);
|
||||
let actual = <string>undefined;
|
||||
let actualFileName = localPath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder);
|
||||
|
||||
if (runImmediately) {
|
||||
actual = generateActual(actualFileName, generateContent);
|
||||
var comparison = compareToBaseline(actual, relativeFileName, opts);
|
||||
let comparison = compareToBaseline(actual, relativeFileName, opts);
|
||||
writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName, descriptionForDescribe);
|
||||
} else {
|
||||
actual = generateActual(actualFileName, generateContent);
|
||||
|
||||
var comparison = compareToBaseline(actual, relativeFileName, opts);
|
||||
let comparison = compareToBaseline(actual, relativeFileName, opts);
|
||||
writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName, descriptionForDescribe);
|
||||
}
|
||||
}
|
||||
@@ -1756,11 +1751,11 @@ module Harness {
|
||||
}
|
||||
|
||||
export function getDefaultLibraryFile(): { unitName: string, content: string } {
|
||||
var libFile = Harness.userSpecifiedRoot + Harness.libFolder + "/" + "lib.d.ts";
|
||||
let libFile = Harness.userSpecifiedRoot + Harness.libFolder + "/" + "lib.d.ts";
|
||||
return {
|
||||
unitName: libFile,
|
||||
content: IO.readFile(libFile)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (Error) (<any>Error).stackTraceLimit = 1;
|
||||
|
||||
@@ -26,9 +26,9 @@ module Harness.LanguageService {
|
||||
|
||||
public editContent(start: number, end: number, newText: string): void {
|
||||
// Apply edits
|
||||
var prefix = this.content.substring(0, start);
|
||||
var middle = newText;
|
||||
var suffix = this.content.substring(end);
|
||||
let prefix = this.content.substring(0, start);
|
||||
let middle = newText;
|
||||
let suffix = this.content.substring(end);
|
||||
this.setContent(prefix + middle + suffix);
|
||||
|
||||
// Store edit range + new length of script
|
||||
@@ -48,10 +48,10 @@ module Harness.LanguageService {
|
||||
return ts.unchangedTextChangeRange;
|
||||
}
|
||||
|
||||
var initialEditRangeIndex = this.editRanges.length - (this.version - startVersion);
|
||||
var lastEditRangeIndex = this.editRanges.length - (this.version - endVersion);
|
||||
let initialEditRangeIndex = this.editRanges.length - (this.version - startVersion);
|
||||
let lastEditRangeIndex = this.editRanges.length - (this.version - endVersion);
|
||||
|
||||
var entries = this.editRanges.slice(initialEditRangeIndex, lastEditRangeIndex);
|
||||
let entries = this.editRanges.slice(initialEditRangeIndex, lastEditRangeIndex);
|
||||
return ts.collapseTextChangeRangesAcrossMultipleVersions(entries.map(e => e.textChangeRange));
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,7 @@ module Harness.LanguageService {
|
||||
}
|
||||
|
||||
public getChangeRange(oldScript: ts.IScriptSnapshot): ts.TextChangeRange {
|
||||
var oldShim = <ScriptSnapshot>oldScript;
|
||||
let oldShim = <ScriptSnapshot>oldScript;
|
||||
return this.scriptInfo.getTextChangeRangeBetweenVersions(oldShim.version, this.version);
|
||||
}
|
||||
}
|
||||
@@ -92,9 +92,9 @@ module Harness.LanguageService {
|
||||
}
|
||||
|
||||
public getChangeRange(oldScript: ts.ScriptSnapshotShim): string {
|
||||
var oldShim = <ScriptSnapshotProxy>oldScript;
|
||||
let oldShim = <ScriptSnapshotProxy>oldScript;
|
||||
|
||||
var range = this.scriptSnapshot.getChangeRange(oldShim.scriptSnapshot);
|
||||
let range = this.scriptSnapshot.getChangeRange(oldShim.scriptSnapshot);
|
||||
if (range === null) {
|
||||
return null;
|
||||
}
|
||||
@@ -130,8 +130,8 @@ module Harness.LanguageService {
|
||||
}
|
||||
|
||||
public getFilenames(): string[] {
|
||||
var fileNames: string[] = [];
|
||||
ts.forEachKey(this.fileNameToScript,(fileName) => { fileNames.push(fileName); });
|
||||
let fileNames: string[] = [];
|
||||
ts.forEachKey(this.fileNameToScript, (fileName) => { fileNames.push(fileName); });
|
||||
return fileNames;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ module Harness.LanguageService {
|
||||
}
|
||||
|
||||
public editScript(fileName: string, start: number, end: number, newText: string) {
|
||||
var script = this.getScriptInfo(fileName);
|
||||
let script = this.getScriptInfo(fileName);
|
||||
if (script !== null) {
|
||||
script.editContent(start, end, newText);
|
||||
return;
|
||||
@@ -161,7 +161,7 @@ module Harness.LanguageService {
|
||||
* @param col 0 based index
|
||||
*/
|
||||
public positionToLineAndCharacter(fileName: string, position: number): ts.LineAndCharacter {
|
||||
var script: ScriptInfo = this.fileNameToScript[fileName];
|
||||
let script: ScriptInfo = this.fileNameToScript[fileName];
|
||||
assert.isNotNull(script);
|
||||
|
||||
return ts.computeLineAndCharacterOfPosition(script.lineMap, position);
|
||||
@@ -176,11 +176,11 @@ module Harness.LanguageService {
|
||||
getDefaultLibFileName(): string { return ""; }
|
||||
getScriptFileNames(): string[] { return this.getFilenames(); }
|
||||
getScriptSnapshot(fileName: string): ts.IScriptSnapshot {
|
||||
var script = this.getScriptInfo(fileName);
|
||||
let script = this.getScriptInfo(fileName);
|
||||
return script ? new ScriptSnapshot(script) : undefined;
|
||||
}
|
||||
getScriptVersion(fileName: string): string {
|
||||
var script = this.getScriptInfo(fileName);
|
||||
let script = this.getScriptInfo(fileName);
|
||||
return script ? script.version.toString() : undefined;
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ module Harness.LanguageService {
|
||||
getDefaultLibFileName(): string { return this.nativeHost.getDefaultLibFileName(); }
|
||||
getScriptFileNames(): string { return JSON.stringify(this.nativeHost.getScriptFileNames()); }
|
||||
getScriptSnapshot(fileName: string): ts.ScriptSnapshotShim {
|
||||
var nativeScriptSnapshot = this.nativeHost.getScriptSnapshot(fileName);
|
||||
let nativeScriptSnapshot = this.nativeHost.getScriptSnapshot(fileName);
|
||||
return nativeScriptSnapshot && new ScriptSnapshotProxy(nativeScriptSnapshot);
|
||||
}
|
||||
getScriptVersion(fileName: string): string { return this.nativeHost.getScriptVersion(fileName); }
|
||||
@@ -242,13 +242,13 @@ module Harness.LanguageService {
|
||||
throw new Error("NYI");
|
||||
}
|
||||
getClassificationsForLine(text: string, lexState: ts.EndOfLineState, classifyKeywordsInGenerics?: boolean): ts.ClassificationResult {
|
||||
var result = this.shim.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics).split('\n');
|
||||
var entries: ts.ClassificationInfo[] = [];
|
||||
var i = 0;
|
||||
var position = 0;
|
||||
let result = this.shim.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics).split('\n');
|
||||
let entries: ts.ClassificationInfo[] = [];
|
||||
let i = 0;
|
||||
let position = 0;
|
||||
|
||||
for (; i < result.length - 1; i += 2) {
|
||||
var t = entries[i / 2] = {
|
||||
let t = entries[i / 2] = {
|
||||
length: parseInt(result[i]),
|
||||
classification: parseInt(result[i + 1])
|
||||
};
|
||||
@@ -256,7 +256,7 @@ module Harness.LanguageService {
|
||||
assert.isTrue(t.length > 0, "Result length should be greater than 0, got :" + t.length);
|
||||
position += t.length;
|
||||
}
|
||||
var finalLexState = parseInt(result[result.length - 1]);
|
||||
let finalLexState = parseInt(result[result.length - 1]);
|
||||
|
||||
assert.equal(position, text.length, "Expected cumulative length of all entries to match the length of the source. expected: " + text.length + ", but got: " + position);
|
||||
|
||||
@@ -268,7 +268,7 @@ module Harness.LanguageService {
|
||||
}
|
||||
|
||||
function unwrapJSONCallResult(result: string): any {
|
||||
var parsedResult = JSON.parse(result);
|
||||
let parsedResult = JSON.parse(result);
|
||||
if (parsedResult.error) {
|
||||
throw new Error("Language Service Shim Error: " + JSON.stringify(parsedResult.error));
|
||||
}
|
||||
@@ -282,7 +282,7 @@ module Harness.LanguageService {
|
||||
constructor(private shim: ts.LanguageServiceShim) {
|
||||
}
|
||||
private unwrappJSONCallResult(result: string): any {
|
||||
var parsedResult = JSON.parse(result);
|
||||
let parsedResult = JSON.parse(result);
|
||||
if (parsedResult.error) {
|
||||
throw new Error("Language Service Shim Error: " + JSON.stringify(parsedResult.error));
|
||||
}
|
||||
@@ -404,16 +404,16 @@ module Harness.LanguageService {
|
||||
getLanguageService(): ts.LanguageService { return new LanguageServiceShimProxy(this.factory.createLanguageServiceShim(this.host)); }
|
||||
getClassifier(): ts.Classifier { return new ClassifierShimProxy(this.factory.createClassifierShim(this.host)); }
|
||||
getPreProcessedFileInfo(fileName: string, fileContents: string): ts.PreProcessedFileInfo {
|
||||
var shimResult: {
|
||||
let shimResult: {
|
||||
referencedFiles: ts.IFileReference[];
|
||||
importedFiles: ts.IFileReference[];
|
||||
isLibFile: boolean;
|
||||
};
|
||||
|
||||
var coreServicesShim = this.factory.createCoreServicesShim(this.host);
|
||||
let coreServicesShim = this.factory.createCoreServicesShim(this.host);
|
||||
shimResult = unwrapJSONCallResult(coreServicesShim.getPreProcessedFileInfo(fileName, ts.ScriptSnapshot.fromString(fileContents)));
|
||||
|
||||
var convertResult: ts.PreProcessedFileInfo = {
|
||||
let convertResult: ts.PreProcessedFileInfo = {
|
||||
referencedFiles: [],
|
||||
importedFiles: [],
|
||||
isLibFile: shimResult.isLibFile
|
||||
@@ -496,7 +496,7 @@ module Harness.LanguageService {
|
||||
fileName = Harness.Compiler.defaultLibFileName;
|
||||
}
|
||||
|
||||
var snapshot = this.host.getScriptSnapshot(fileName);
|
||||
let snapshot = this.host.getScriptSnapshot(fileName);
|
||||
return snapshot && snapshot.getText(0, snapshot.getLength());
|
||||
}
|
||||
|
||||
@@ -574,13 +574,13 @@ module Harness.LanguageService {
|
||||
private client: ts.server.SessionClient;
|
||||
constructor(cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) {
|
||||
// This is the main host that tests use to direct tests
|
||||
var clientHost = new SessionClientHost(cancellationToken, options);
|
||||
var client = new ts.server.SessionClient(clientHost);
|
||||
let clientHost = new SessionClientHost(cancellationToken, options);
|
||||
let client = new ts.server.SessionClient(clientHost);
|
||||
|
||||
// This host is just a proxy for the clientHost, it uses the client
|
||||
// host to answer server queries about files on disk
|
||||
var serverHost = new SessionServerHost(clientHost);
|
||||
var server = new ts.server.Session(serverHost, Buffer.byteLength, process.hrtime, serverHost);
|
||||
let serverHost = new SessionServerHost(clientHost);
|
||||
let server = new ts.server.Session(serverHost, Buffer.byteLength, process.hrtime, serverHost);
|
||||
|
||||
// Fake the connection between the client and the server
|
||||
serverHost.writeMessage = client.onMessage.bind(client);
|
||||
|
||||
+19
-19
@@ -71,9 +71,9 @@ interface PlaybackControl {
|
||||
}
|
||||
|
||||
module Playback {
|
||||
var recordLog: IOLog = undefined;
|
||||
var replayLog: IOLog = undefined;
|
||||
var recordLogFileNameBase = '';
|
||||
let recordLog: IOLog = undefined;
|
||||
let replayLog: IOLog = undefined;
|
||||
let recordLogFileNameBase = '';
|
||||
|
||||
interface Memoized<T> {
|
||||
(s: string): T;
|
||||
@@ -81,8 +81,8 @@ module Playback {
|
||||
}
|
||||
|
||||
function memoize<T>(func: (s: string) => T): Memoized<T> {
|
||||
var lookup: { [s: string]: T } = {};
|
||||
var run: Memoized<T> = <Memoized<T>>((s: string) => {
|
||||
let lookup: { [s: string]: T } = {};
|
||||
let run: Memoized<T> = <Memoized<T>>((s: string) => {
|
||||
if (lookup.hasOwnProperty(s)) return lookup[s];
|
||||
return lookup[s] = func(s);
|
||||
});
|
||||
@@ -162,10 +162,10 @@ module Playback {
|
||||
}
|
||||
|
||||
function findResultByFields<T>(logArray: { result?: T }[], expectedFields: {}, defaultValue?: T): T {
|
||||
var predicate = (entry: { result?: T }) => {
|
||||
let predicate = (entry: { result?: T }) => {
|
||||
return Object.getOwnPropertyNames(expectedFields).every((name) => (<any>entry)[name] === (<any>expectedFields)[name]);
|
||||
};
|
||||
var results = logArray.filter(entry => predicate(entry));
|
||||
let results = logArray.filter(entry => predicate(entry));
|
||||
if (results.length === 0) {
|
||||
if (defaultValue !== undefined) {
|
||||
return defaultValue;
|
||||
@@ -177,17 +177,17 @@ module Playback {
|
||||
}
|
||||
|
||||
function findResultByPath<T>(wrapper: { resolvePath(s: string): string }, logArray: { path: string; result?: T }[], expectedPath: string, defaultValue?: T): T {
|
||||
var normalizedName = ts.normalizeSlashes(expectedPath).toLowerCase();
|
||||
let normalizedName = ts.normalizeSlashes(expectedPath).toLowerCase();
|
||||
// Try to find the result through normal fileName
|
||||
for (var i = 0; i < logArray.length; i++) {
|
||||
for (let i = 0; i < logArray.length; i++) {
|
||||
if (ts.normalizeSlashes(logArray[i].path).toLowerCase() === normalizedName) {
|
||||
return logArray[i].result;
|
||||
}
|
||||
}
|
||||
// Fallback, try to resolve the target paths as well
|
||||
if (replayLog.pathsResolved.length > 0) {
|
||||
var normalizedResolvedName = wrapper.resolvePath(expectedPath).toLowerCase();
|
||||
for (var i = 0; i < logArray.length; i++) {
|
||||
let normalizedResolvedName = wrapper.resolvePath(expectedPath).toLowerCase();
|
||||
for (let i = 0; i < logArray.length; i++) {
|
||||
if (wrapper.resolvePath(logArray[i].path).toLowerCase() === normalizedResolvedName) {
|
||||
return logArray[i].result;
|
||||
}
|
||||
@@ -201,9 +201,9 @@ module Playback {
|
||||
}
|
||||
}
|
||||
|
||||
var pathEquivCache: any = {};
|
||||
let pathEquivCache: any = {};
|
||||
function pathsAreEquivalent(left: string, right: string, wrapper: { resolvePath(s: string): string }) {
|
||||
var key = left + '-~~-' + right;
|
||||
let key = left + '-~~-' + right;
|
||||
function areSame(a: string, b: string) {
|
||||
return ts.normalizeSlashes(a).toLowerCase() === ts.normalizeSlashes(b).toLowerCase();
|
||||
}
|
||||
@@ -220,11 +220,11 @@ module Playback {
|
||||
}
|
||||
|
||||
function noOpReplay(name: string) {
|
||||
//console.log("Swallowed write operation during replay: " + name);
|
||||
// console.log("Swallowed write operation during replay: " + name);
|
||||
}
|
||||
|
||||
export function wrapSystem(underlying: ts.System): PlaybackSystem {
|
||||
var wrapper: PlaybackSystem = <any>{};
|
||||
let wrapper: PlaybackSystem = <any>{};
|
||||
initWrapper(wrapper, underlying);
|
||||
|
||||
wrapper.startReplayFromFile = logFn => {
|
||||
@@ -232,8 +232,8 @@ module Playback {
|
||||
};
|
||||
wrapper.endRecord = () => {
|
||||
if (recordLog !== undefined) {
|
||||
var i = 0;
|
||||
var fn = () => recordLogFileNameBase + i + '.json';
|
||||
let i = 0;
|
||||
let fn = () => recordLogFileNameBase + i + '.json';
|
||||
while (underlying.fileExists(fn())) i++;
|
||||
underlying.writeFile(fn(), JSON.stringify(recordLog));
|
||||
recordLog = undefined;
|
||||
@@ -290,8 +290,8 @@ module Playback {
|
||||
|
||||
wrapper.readFile = recordReplay(wrapper.readFile, underlying)(
|
||||
(path) => {
|
||||
var result = underlying.readFile(path);
|
||||
var logEntry = { path: path, codepage: 0, result: { contents: result, codepage: 0 } };
|
||||
let result = underlying.readFile(path);
|
||||
let logEntry = { path: path, codepage: 0, result: { contents: result, codepage: 0 } };
|
||||
recordLog.filesRead.push(logEntry);
|
||||
return result;
|
||||
},
|
||||
|
||||
+135
-130
@@ -46,7 +46,7 @@ interface BatchCompileProjectTestCaseResult extends CompileProjectFilesResult {
|
||||
class ProjectRunner extends RunnerBase {
|
||||
public initializeTests() {
|
||||
if (this.tests.length === 0) {
|
||||
var testFiles = this.enumerateFiles("tests/cases/project", /\.json$/, { recursive: true });
|
||||
let testFiles = this.enumerateFiles("tests/cases/project", /\.json$/, { recursive: true });
|
||||
testFiles.forEach(fn => {
|
||||
fn = fn.replace(/\\/g, "/");
|
||||
this.runProjectTestCase(fn);
|
||||
@@ -58,10 +58,11 @@ class ProjectRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
private runProjectTestCase(testCaseFileName: string) {
|
||||
var testCase: ProjectRunnerTestCase;
|
||||
let testCase: ProjectRunnerTestCase;
|
||||
|
||||
let testFileText: string = null;
|
||||
try {
|
||||
var testFileText = ts.sys.readFile(testCaseFileName);
|
||||
testFileText = ts.sys.readFile(testCaseFileName);
|
||||
}
|
||||
catch (e) {
|
||||
assert(false, "Unable to open testcase file: " + testCaseFileName + ": " + e.message);
|
||||
@@ -73,7 +74,7 @@ class ProjectRunner extends RunnerBase {
|
||||
catch (e) {
|
||||
assert(false, "Testcase: " + testCaseFileName + " does not contain valid json format: " + e.message);
|
||||
}
|
||||
var testCaseJustName = testCaseFileName.replace(/^.*[\\\/]/, '').replace(/\.json/, "");
|
||||
let testCaseJustName = testCaseFileName.replace(/^.*[\\\/]/, '').replace(/\.json/, "");
|
||||
|
||||
function moduleNameToString(moduleKind: ts.ModuleKind) {
|
||||
return moduleKind === ts.ModuleKind.AMD
|
||||
@@ -89,7 +90,7 @@ class ProjectRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
// When test case output goes to tests/baselines/local/projectOutput/testCaseName/moduleKind/
|
||||
// We have these two separate locations because when comparing baselines the baseline verifier will delete the existing file
|
||||
// We have these two separate locations because when comparing baselines the baseline verifier will delete the existing file
|
||||
// so even if it was created by compiler in that location, the file will be deleted by verified before we can read it
|
||||
// so lets keep these two locations separate
|
||||
function getProjectOutputFolder(fileName: string, moduleKind: ts.ModuleKind) {
|
||||
@@ -97,9 +98,9 @@ class ProjectRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
function cleanProjectUrl(url: string) {
|
||||
var diskProjectPath = ts.normalizeSlashes(ts.sys.resolvePath(testCase.projectRoot));
|
||||
var projectRootUrl = "file:///" + diskProjectPath;
|
||||
var normalizedProjectRoot = ts.normalizeSlashes(testCase.projectRoot);
|
||||
let diskProjectPath = ts.normalizeSlashes(ts.sys.resolvePath(testCase.projectRoot));
|
||||
let projectRootUrl = "file:///" + diskProjectPath;
|
||||
let normalizedProjectRoot = ts.normalizeSlashes(testCase.projectRoot);
|
||||
diskProjectPath = diskProjectPath.substr(0, diskProjectPath.lastIndexOf(normalizedProjectRoot));
|
||||
projectRootUrl = projectRootUrl.substr(0, projectRootUrl.lastIndexOf(normalizedProjectRoot));
|
||||
if (url && url.length) {
|
||||
@@ -124,21 +125,21 @@ class ProjectRunner extends RunnerBase {
|
||||
return ts.sys.resolvePath(testCase.projectRoot);
|
||||
}
|
||||
|
||||
function compileProjectFiles(moduleKind: ts.ModuleKind, getInputFiles: ()=> string[],
|
||||
function compileProjectFiles(moduleKind: ts.ModuleKind, getInputFiles: () => string[],
|
||||
getSourceFileText: (fileName: string) => string,
|
||||
writeFile: (fileName: string, data: string, writeByteOrderMark: boolean) => void): CompileProjectFilesResult {
|
||||
|
||||
var program = ts.createProgram(getInputFiles(), createCompilerOptions(), createCompilerHost());
|
||||
var errors = ts.getPreEmitDiagnostics(program);
|
||||
let program = ts.createProgram(getInputFiles(), createCompilerOptions(), createCompilerHost());
|
||||
let errors = ts.getPreEmitDiagnostics(program);
|
||||
|
||||
var emitResult = program.emit();
|
||||
let emitResult = program.emit();
|
||||
errors = ts.concatenate(errors, emitResult.diagnostics);
|
||||
var sourceMapData = emitResult.sourceMaps;
|
||||
let sourceMapData = emitResult.sourceMaps;
|
||||
|
||||
// Clean up source map data that will be used in baselining
|
||||
if (sourceMapData) {
|
||||
for (var i = 0; i < sourceMapData.length; i++) {
|
||||
for (var j = 0; j < sourceMapData[i].sourceMapSources.length; j++) {
|
||||
for (let i = 0; i < sourceMapData.length; i++) {
|
||||
for (let j = 0; j < sourceMapData[i].sourceMapSources.length; j++) {
|
||||
sourceMapData[i].sourceMapSources[j] = cleanProjectUrl(sourceMapData[i].sourceMapSources[j]);
|
||||
}
|
||||
sourceMapData[i].jsSourceMappingURL = cleanProjectUrl(sourceMapData[i].jsSourceMappingURL);
|
||||
@@ -168,12 +169,12 @@ class ProjectRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
function getSourceFile(fileName: string, languageVersion: ts.ScriptTarget): ts.SourceFile {
|
||||
var sourceFile: ts.SourceFile = undefined;
|
||||
let sourceFile: ts.SourceFile = undefined;
|
||||
if (fileName === Harness.Compiler.defaultLibFileName) {
|
||||
sourceFile = languageVersion === ts.ScriptTarget.ES6 ? Harness.Compiler.defaultES6LibSourceFile : Harness.Compiler.defaultLibSourceFile;
|
||||
}
|
||||
else {
|
||||
var text = getSourceFileText(fileName);
|
||||
let text = getSourceFileText(fileName);
|
||||
if (text !== undefined) {
|
||||
sourceFile = Harness.Compiler.createSourceFileAndAssertInvariants(fileName, text, languageVersion);
|
||||
}
|
||||
@@ -194,13 +195,13 @@ class ProjectRunner extends RunnerBase {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function batchCompilerProjectTestCase(moduleKind: ts.ModuleKind): BatchCompileProjectTestCaseResult{
|
||||
var nonSubfolderDiskFiles = 0;
|
||||
let nonSubfolderDiskFiles = 0;
|
||||
|
||||
var outputFiles: BatchCompileProjectTestCaseEmittedFile[] = [];
|
||||
let outputFiles: BatchCompileProjectTestCaseEmittedFile[] = [];
|
||||
|
||||
var projectCompilerResult = compileProjectFiles(moduleKind, () => testCase.inputFiles, getSourceFileText, writeFile);
|
||||
let projectCompilerResult = compileProjectFiles(moduleKind, () => testCase.inputFiles, getSourceFileText, writeFile);
|
||||
return {
|
||||
moduleKind,
|
||||
program: projectCompilerResult.program,
|
||||
@@ -211,8 +212,9 @@ class ProjectRunner extends RunnerBase {
|
||||
};
|
||||
|
||||
function getSourceFileText(fileName: string): string {
|
||||
let text: string = undefined;
|
||||
try {
|
||||
var text = ts.sys.readFile(ts.isRootedDiskPath(fileName)
|
||||
text = ts.sys.readFile(ts.isRootedDiskPath(fileName)
|
||||
? fileName
|
||||
: ts.normalizeSlashes(testCase.projectRoot) + "/" + ts.normalizeSlashes(fileName));
|
||||
}
|
||||
@@ -223,14 +225,14 @@ class ProjectRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean) {
|
||||
var diskFileName = ts.isRootedDiskPath(fileName)
|
||||
let diskFileName = ts.isRootedDiskPath(fileName)
|
||||
? fileName
|
||||
: ts.normalizeSlashes(testCase.projectRoot) + "/" + ts.normalizeSlashes(fileName);
|
||||
|
||||
var diskRelativeName = ts.getRelativePathToDirectoryOrUrl(testCase.projectRoot, diskFileName,
|
||||
let diskRelativeName = ts.getRelativePathToDirectoryOrUrl(testCase.projectRoot, diskFileName,
|
||||
getCurrentDirectory(), Harness.Compiler.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
|
||||
if (ts.isRootedDiskPath(diskRelativeName) || diskRelativeName.substr(0, 3) === "../") {
|
||||
// If the generated output file resides in the parent folder or is rooted path,
|
||||
// If the generated output file resides in the parent folder or is rooted path,
|
||||
// we need to instead create files that can live in the project reference folder
|
||||
// but make sure extension of these files matches with the fileName the compiler asked to write
|
||||
diskRelativeName = "diskFile" + nonSubfolderDiskFiles++ +
|
||||
@@ -240,22 +242,22 @@ class ProjectRunner extends RunnerBase {
|
||||
|
||||
if (Harness.Compiler.isJS(fileName)) {
|
||||
// Make sure if there is URl we have it cleaned up
|
||||
var indexOfSourceMapUrl = data.lastIndexOf("//# sourceMappingURL=");
|
||||
let indexOfSourceMapUrl = data.lastIndexOf("//# sourceMappingURL=");
|
||||
if (indexOfSourceMapUrl !== -1) {
|
||||
data = data.substring(0, indexOfSourceMapUrl + 21) + cleanProjectUrl(data.substring(indexOfSourceMapUrl + 21));
|
||||
}
|
||||
}
|
||||
else if (Harness.Compiler.isJSMap(fileName)) {
|
||||
// Make sure sources list is cleaned
|
||||
var sourceMapData = JSON.parse(data);
|
||||
for (var i = 0; i < sourceMapData.sources.length; i++) {
|
||||
let sourceMapData = JSON.parse(data);
|
||||
for (let i = 0; i < sourceMapData.sources.length; i++) {
|
||||
sourceMapData.sources[i] = cleanProjectUrl(sourceMapData.sources[i]);
|
||||
}
|
||||
sourceMapData.sourceRoot = cleanProjectUrl(sourceMapData.sourceRoot);
|
||||
data = JSON.stringify(sourceMapData);
|
||||
}
|
||||
|
||||
var outputFilePath = getProjectOutputFolder(diskRelativeName, moduleKind);
|
||||
let outputFilePath = getProjectOutputFolder(diskRelativeName, moduleKind);
|
||||
// Actual writing of file as in tc.ts
|
||||
function ensureDirectoryStructure(directoryname: string) {
|
||||
if (directoryname) {
|
||||
@@ -273,36 +275,37 @@ class ProjectRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
function compileCompileDTsFiles(compilerResult: BatchCompileProjectTestCaseResult) {
|
||||
var allInputFiles: { emittedFileName: string; code: string; }[] = [];
|
||||
var compilerOptions = compilerResult.program.getCompilerOptions();
|
||||
let allInputFiles: { emittedFileName: string; code: string; }[] = [];
|
||||
let compilerOptions = compilerResult.program.getCompilerOptions();
|
||||
|
||||
ts.forEach(compilerResult.program.getSourceFiles(), sourceFile => {
|
||||
if (Harness.Compiler.isDTS(sourceFile.fileName)) {
|
||||
allInputFiles.unshift({ emittedFileName: sourceFile.fileName, code: sourceFile.text });
|
||||
}
|
||||
else if (ts.shouldEmitToOwnFile(sourceFile, compilerResult.program.getCompilerOptions())) {
|
||||
let emitOutputFilePathWithoutExtension: string = undefined;
|
||||
if (compilerOptions.outDir) {
|
||||
var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, compilerResult.program.getCurrentDirectory());
|
||||
let sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, compilerResult.program.getCurrentDirectory());
|
||||
sourceFilePath = sourceFilePath.replace(compilerResult.program.getCommonSourceDirectory(), "");
|
||||
var emitOutputFilePathWithoutExtension = ts.removeFileExtension(ts.combinePaths(compilerOptions.outDir, sourceFilePath));
|
||||
emitOutputFilePathWithoutExtension = ts.removeFileExtension(ts.combinePaths(compilerOptions.outDir, sourceFilePath));
|
||||
}
|
||||
else {
|
||||
var emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName);
|
||||
emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName);
|
||||
}
|
||||
|
||||
var outputDtsFileName = emitOutputFilePathWithoutExtension + ".d.ts";
|
||||
let outputDtsFileName = emitOutputFilePathWithoutExtension + ".d.ts";
|
||||
allInputFiles.unshift(findOutpuDtsFile(outputDtsFileName));
|
||||
}
|
||||
else {
|
||||
var outputDtsFileName = ts.removeFileExtension(compilerOptions.out) + ".d.ts";
|
||||
var outputDtsFile = findOutpuDtsFile(outputDtsFileName);
|
||||
let outputDtsFileName = ts.removeFileExtension(compilerOptions.out) + ".d.ts";
|
||||
let outputDtsFile = findOutpuDtsFile(outputDtsFileName);
|
||||
if (!ts.contains(allInputFiles, outputDtsFile)) {
|
||||
allInputFiles.unshift(outputDtsFile);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return compileProjectFiles(compilerResult.moduleKind,getInputFiles, getSourceFileText, writeFile);
|
||||
return compileProjectFiles(compilerResult.moduleKind, getInputFiles, getSourceFileText, writeFile);
|
||||
|
||||
function findOutpuDtsFile(fileName: string) {
|
||||
return ts.forEach(compilerResult.outputFiles, outputFile => outputFile.emittedFileName === fileName ? outputFile : undefined);
|
||||
@@ -319,7 +322,7 @@ class ProjectRunner extends RunnerBase {
|
||||
}
|
||||
|
||||
function getErrorsBaseline(compilerResult: CompileProjectFilesResult) {
|
||||
var inputFiles = ts.map(ts.filter(compilerResult.program.getSourceFiles(),
|
||||
let inputFiles = ts.map(ts.filter(compilerResult.program.getSourceFiles(),
|
||||
sourceFile => sourceFile.fileName !== "lib.d.ts"),
|
||||
sourceFile => {
|
||||
return { unitName: sourceFile.fileName, content: sourceFile.text };
|
||||
@@ -328,110 +331,112 @@ class ProjectRunner extends RunnerBase {
|
||||
return Harness.Compiler.getErrorBaseline(inputFiles, compilerResult.errors);
|
||||
}
|
||||
|
||||
var name = 'Compiling project for ' + testCase.scenario + ': testcase ' + testCaseFileName;
|
||||
let name = 'Compiling project for ' + testCase.scenario + ': testcase ' + testCaseFileName;
|
||||
|
||||
describe(name, () => {
|
||||
function verifyCompilerResults(moduleKind: ts.ModuleKind) {
|
||||
function getCompilerResolutionInfo() {
|
||||
var resolutionInfo: ProjectRunnerTestCaseResolutionInfo = {
|
||||
scenario: testCase.scenario,
|
||||
projectRoot: testCase.projectRoot,
|
||||
inputFiles: testCase.inputFiles,
|
||||
out: testCase.out,
|
||||
outDir: testCase.outDir,
|
||||
sourceMap: testCase.sourceMap,
|
||||
mapRoot: testCase.mapRoot,
|
||||
resolveMapRoot: testCase.resolveMapRoot,
|
||||
sourceRoot: testCase.sourceRoot,
|
||||
resolveSourceRoot: testCase.resolveSourceRoot,
|
||||
declaration: testCase.declaration,
|
||||
baselineCheck: testCase.baselineCheck,
|
||||
runTest: testCase.runTest,
|
||||
bug: testCase.bug,
|
||||
rootDir: testCase.rootDir,
|
||||
resolvedInputFiles: ts.map(compilerResult.program.getSourceFiles(), inputFile => inputFile.fileName),
|
||||
emittedFiles: ts.map(compilerResult.outputFiles, outputFile => outputFile.emittedFileName)
|
||||
};
|
||||
describe('Projects tests', () => {
|
||||
describe(name, () => {
|
||||
function verifyCompilerResults(moduleKind: ts.ModuleKind) {
|
||||
let compilerResult: BatchCompileProjectTestCaseResult;
|
||||
|
||||
return resolutionInfo;
|
||||
}
|
||||
function getCompilerResolutionInfo() {
|
||||
let resolutionInfo: ProjectRunnerTestCaseResolutionInfo = {
|
||||
scenario: testCase.scenario,
|
||||
projectRoot: testCase.projectRoot,
|
||||
inputFiles: testCase.inputFiles,
|
||||
out: testCase.out,
|
||||
outDir: testCase.outDir,
|
||||
sourceMap: testCase.sourceMap,
|
||||
mapRoot: testCase.mapRoot,
|
||||
resolveMapRoot: testCase.resolveMapRoot,
|
||||
sourceRoot: testCase.sourceRoot,
|
||||
resolveSourceRoot: testCase.resolveSourceRoot,
|
||||
declaration: testCase.declaration,
|
||||
baselineCheck: testCase.baselineCheck,
|
||||
runTest: testCase.runTest,
|
||||
bug: testCase.bug,
|
||||
rootDir: testCase.rootDir,
|
||||
resolvedInputFiles: ts.map(compilerResult.program.getSourceFiles(), inputFile => inputFile.fileName),
|
||||
emittedFiles: ts.map(compilerResult.outputFiles, outputFile => outputFile.emittedFileName)
|
||||
};
|
||||
|
||||
var compilerResult: BatchCompileProjectTestCaseResult;
|
||||
return resolutionInfo;
|
||||
}
|
||||
|
||||
it(name + ": " + moduleNameToString(moduleKind) , () => {
|
||||
// Compile using node
|
||||
compilerResult = batchCompilerProjectTestCase(moduleKind);
|
||||
});
|
||||
|
||||
it('Resolution information of (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => {
|
||||
Harness.Baseline.runBaseline('Resolution information of (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.json', () => {
|
||||
return JSON.stringify(getCompilerResolutionInfo(), undefined, " ");
|
||||
it(name + ": " + moduleNameToString(moduleKind) , () => {
|
||||
// Compile using node
|
||||
compilerResult = batchCompilerProjectTestCase(moduleKind);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('Errors for (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => {
|
||||
if (compilerResult.errors.length) {
|
||||
Harness.Baseline.runBaseline('Errors for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.errors.txt', () => {
|
||||
return getErrorsBaseline(compilerResult);
|
||||
it('Resolution information of (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => {
|
||||
Harness.Baseline.runBaseline('Resolution information of (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.json', () => {
|
||||
return JSON.stringify(getCompilerResolutionInfo(), undefined, " ");
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('Baseline of emitted result (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => {
|
||||
if (testCase.baselineCheck) {
|
||||
ts.forEach(compilerResult.outputFiles, outputFile => {
|
||||
|
||||
Harness.Baseline.runBaseline('Baseline of emitted result (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + outputFile.fileName, () => {
|
||||
try {
|
||||
return ts.sys.readFile(getProjectOutputFolder(outputFile.fileName, compilerResult.moduleKind));
|
||||
}
|
||||
catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
it('SourceMapRecord for (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => {
|
||||
if (compilerResult.sourceMapData) {
|
||||
Harness.Baseline.runBaseline('SourceMapRecord for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.sourcemap.txt', () => {
|
||||
return Harness.SourceMapRecoder.getSourceMapRecord(compilerResult.sourceMapData, compilerResult.program,
|
||||
ts.filter(compilerResult.outputFiles, outputFile => Harness.Compiler.isJS(outputFile.emittedFileName)));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Verify that all the generated .d.ts files compile
|
||||
|
||||
it('Errors in generated Dts files for (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => {
|
||||
if (!compilerResult.errors.length && testCase.declaration) {
|
||||
var dTsCompileResult = compileCompileDTsFiles(compilerResult);
|
||||
if (dTsCompileResult.errors.length) {
|
||||
Harness.Baseline.runBaseline('Errors in generated Dts files for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.dts.errors.txt', () => {
|
||||
return getErrorsBaseline(dTsCompileResult);
|
||||
it('Errors for (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => {
|
||||
if (compilerResult.errors.length) {
|
||||
Harness.Baseline.runBaseline('Errors for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.errors.txt', () => {
|
||||
return getErrorsBaseline(compilerResult);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('Baseline of emitted result (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => {
|
||||
if (testCase.baselineCheck) {
|
||||
ts.forEach(compilerResult.outputFiles, outputFile => {
|
||||
|
||||
Harness.Baseline.runBaseline('Baseline of emitted result (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + outputFile.fileName, () => {
|
||||
try {
|
||||
return ts.sys.readFile(getProjectOutputFolder(outputFile.fileName, compilerResult.moduleKind));
|
||||
}
|
||||
catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
it('SourceMapRecord for (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => {
|
||||
if (compilerResult.sourceMapData) {
|
||||
Harness.Baseline.runBaseline('SourceMapRecord for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.sourcemap.txt', () => {
|
||||
return Harness.SourceMapRecoder.getSourceMapRecord(compilerResult.sourceMapData, compilerResult.program,
|
||||
ts.filter(compilerResult.outputFiles, outputFile => Harness.Compiler.isJS(outputFile.emittedFileName)));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Verify that all the generated .d.ts files compile
|
||||
|
||||
it('Errors in generated Dts files for (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => {
|
||||
if (!compilerResult.errors.length && testCase.declaration) {
|
||||
let dTsCompileResult = compileCompileDTsFiles(compilerResult);
|
||||
if (dTsCompileResult.errors.length) {
|
||||
Harness.Baseline.runBaseline('Errors in generated Dts files for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.dts.errors.txt', () => {
|
||||
return getErrorsBaseline(dTsCompileResult);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
after(() => {
|
||||
compilerResult = undefined;
|
||||
});
|
||||
}
|
||||
|
||||
verifyCompilerResults(ts.ModuleKind.CommonJS);
|
||||
verifyCompilerResults(ts.ModuleKind.AMD);
|
||||
|
||||
after(() => {
|
||||
compilerResult = undefined;
|
||||
// Mocha holds onto the closure environment of the describe callback even after the test is done.
|
||||
// Therefore we have to clean out large objects after the test is done.
|
||||
testCase = undefined;
|
||||
testFileText = undefined;
|
||||
testCaseJustName = undefined;
|
||||
});
|
||||
}
|
||||
|
||||
verifyCompilerResults(ts.ModuleKind.CommonJS);
|
||||
verifyCompilerResults(ts.ModuleKind.AMD);
|
||||
|
||||
after(() => {
|
||||
// Mocha holds onto the closure environment of the describe callback even after the test is done.
|
||||
// Therefore we have to clean out large objects after the test is done.
|
||||
testCase = undefined;
|
||||
testFileText = undefined;
|
||||
testCaseJustName = undefined;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-11
@@ -1,6 +1,6 @@
|
||||
//
|
||||
// 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
|
||||
@@ -20,26 +20,26 @@
|
||||
/// <reference path='rwcRunner.ts' />
|
||||
/// <reference path='harness.ts' />
|
||||
|
||||
let runners: RunnerBase[] = [];
|
||||
let iterations: number = 1;
|
||||
|
||||
function runTests(runners: RunnerBase[]) {
|
||||
for (var i = iterations; i > 0; i--) {
|
||||
for (var j = 0; j < runners.length; j++) {
|
||||
for (let i = iterations; i > 0; i--) {
|
||||
for (let j = 0; j < runners.length; j++) {
|
||||
runners[j].initializeTests();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var runners: RunnerBase[] = [];
|
||||
var iterations: number = 1;
|
||||
|
||||
// users can define tests to run in mytest.config that will override cmd line args, otherwise use cmd line args (test.config), otherwise no options
|
||||
var mytestconfig = 'mytest.config';
|
||||
var testconfig = 'test.config';
|
||||
var testConfigFile =
|
||||
let mytestconfig = 'mytest.config';
|
||||
let testconfig = 'test.config';
|
||||
let testConfigFile =
|
||||
Harness.IO.fileExists(mytestconfig) ? Harness.IO.readFile(mytestconfig) :
|
||||
(Harness.IO.fileExists(testconfig) ? Harness.IO.readFile(testconfig) : '');
|
||||
|
||||
if (testConfigFile !== '') {
|
||||
var testConfig = JSON.parse(testConfigFile);
|
||||
let testConfig = JSON.parse(testConfigFile);
|
||||
if (testConfig.light) {
|
||||
Harness.lightMode = true;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ if (runners.length === 0) {
|
||||
runners.push(new FourSlashRunner(FourSlashTestType.Native));
|
||||
runners.push(new FourSlashRunner(FourSlashTestType.Shims));
|
||||
runners.push(new FourSlashRunner(FourSlashTestType.Server));
|
||||
//runners.push(new GeneratedFourslashRunner());
|
||||
// runners.push(new GeneratedFourslashRunner());
|
||||
}
|
||||
|
||||
ts.sys.newLine = '\r\n';
|
||||
|
||||
@@ -24,17 +24,17 @@ class RunnerBase {
|
||||
|
||||
/** Replaces instances of full paths with fileNames only */
|
||||
static removeFullPaths(path: string) {
|
||||
var fixedPath = path;
|
||||
let fixedPath = path;
|
||||
|
||||
// full paths either start with a drive letter or / for *nix, shouldn't have \ in the path at this point
|
||||
var fullPath = /(\w+:|\/)?([\w+\-\.]|\/)*\.tsx?/g;
|
||||
var fullPathList = fixedPath.match(fullPath);
|
||||
let fullPath = /(\w+:|\/)?([\w+\-\.]|\/)*\.tsx?/g;
|
||||
let fullPathList = fixedPath.match(fullPath);
|
||||
if (fullPathList) {
|
||||
fullPathList.forEach((match: string) => fixedPath = fixedPath.replace(match, Harness.Path.getFileName(match)));
|
||||
}
|
||||
|
||||
// when running in the browser the 'full path' is the host name, shows up in error baselines
|
||||
var localHost = /http:\/localhost:\d+/g;
|
||||
let localHost = /http:\/localhost:\d+/g;
|
||||
fixedPath = fixedPath.replace(localHost, '');
|
||||
return fixedPath;
|
||||
}
|
||||
|
||||
+28
-27
@@ -5,9 +5,9 @@
|
||||
|
||||
module RWC {
|
||||
function runWithIOLog(ioLog: IOLog, fn: () => void) {
|
||||
var oldSys = ts.sys;
|
||||
let oldSys = ts.sys;
|
||||
|
||||
var wrappedSys = Playback.wrapSystem(ts.sys);
|
||||
let wrappedSys = Playback.wrapSystem(ts.sys);
|
||||
wrappedSys.startReplayFromData(ioLog);
|
||||
ts.sys = wrappedSys;
|
||||
|
||||
@@ -21,17 +21,17 @@ module RWC {
|
||||
|
||||
export function runRWCTest(jsonPath: string) {
|
||||
describe("Testing a RWC project: " + jsonPath, () => {
|
||||
var inputFiles: { unitName: string; content: string; }[] = [];
|
||||
var otherFiles: { unitName: string; content: string; }[] = [];
|
||||
var compilerResult: Harness.Compiler.CompilerResult;
|
||||
var compilerOptions: ts.CompilerOptions;
|
||||
var baselineOpts: Harness.Baseline.BaselineOptions = {
|
||||
let inputFiles: { unitName: string; content: string; }[] = [];
|
||||
let otherFiles: { unitName: string; content: string; }[] = [];
|
||||
let compilerResult: Harness.Compiler.CompilerResult;
|
||||
let compilerOptions: ts.CompilerOptions;
|
||||
let baselineOpts: Harness.Baseline.BaselineOptions = {
|
||||
Subfolder: 'rwc',
|
||||
Baselinefolder: 'internal/baselines'
|
||||
};
|
||||
var baseName = /(.*)\/(.*).json/.exec(ts.normalizeSlashes(jsonPath))[2];
|
||||
var currentDirectory: string;
|
||||
var useCustomLibraryFile: boolean;
|
||||
let baseName = /(.*)\/(.*).json/.exec(ts.normalizeSlashes(jsonPath))[2];
|
||||
let currentDirectory: string;
|
||||
let useCustomLibraryFile: boolean;
|
||||
|
||||
after(() => {
|
||||
// Mocha holds onto the closure environment of the describe callback even after the test is done.
|
||||
@@ -50,10 +50,10 @@ module RWC {
|
||||
});
|
||||
|
||||
it('can compile', () => {
|
||||
var harnessCompiler = Harness.Compiler.getCompiler();
|
||||
var opts: ts.ParsedCommandLine;
|
||||
let harnessCompiler = Harness.Compiler.getCompiler();
|
||||
let opts: ts.ParsedCommandLine;
|
||||
|
||||
var ioLog: IOLog = JSON.parse(Harness.IO.readFile(jsonPath));
|
||||
let ioLog: IOLog = JSON.parse(Harness.IO.readFile(jsonPath));
|
||||
currentDirectory = ioLog.currentDirectory;
|
||||
useCustomLibraryFile = ioLog.useCustomLibraryFile;
|
||||
runWithIOLog(ioLog, () => {
|
||||
@@ -77,7 +77,7 @@ module RWC {
|
||||
for (let fileRead of ioLog.filesRead) {
|
||||
// Check if the file is already added into the set of input files.
|
||||
var resolvedPath = ts.normalizeSlashes(ts.sys.resolvePath(fileRead.path));
|
||||
var inInputList = ts.forEach(inputFiles, inputFile => inputFile.unitName === resolvedPath);
|
||||
let inInputList = ts.forEach(inputFiles, inputFile => inputFile.unitName === resolvedPath);
|
||||
|
||||
if (!Harness.isLibraryFile(fileRead.path)) {
|
||||
if (inInputList) {
|
||||
@@ -117,12 +117,13 @@ module RWC {
|
||||
});
|
||||
|
||||
function getHarnessCompilerInputUnit(fileName: string) {
|
||||
var unitName = ts.normalizeSlashes(ts.sys.resolvePath(fileName));
|
||||
let unitName = ts.normalizeSlashes(ts.sys.resolvePath(fileName));
|
||||
let content: string = null;
|
||||
try {
|
||||
var content = ts.sys.readFile(unitName);
|
||||
content = ts.sys.readFile(unitName);
|
||||
}
|
||||
catch (e) {
|
||||
// Leave content undefined.
|
||||
content = ts.sys.readFile(fileName);
|
||||
}
|
||||
return { unitName, content };
|
||||
}
|
||||
@@ -155,13 +156,13 @@ module RWC {
|
||||
}, false, baselineOpts);
|
||||
});
|
||||
|
||||
//it('has correct source map record', () => {
|
||||
// if (compilerOptions.sourceMap) {
|
||||
// Harness.Baseline.runBaseline('has correct source map record', baseName + '.sourcemap.txt', () => {
|
||||
// return compilerResult.getSourceMapRecord();
|
||||
// }, false, baselineOpts);
|
||||
// }
|
||||
//});
|
||||
/*it('has correct source map record', () => {
|
||||
if (compilerOptions.sourceMap) {
|
||||
Harness.Baseline.runBaseline('has correct source map record', baseName + '.sourcemap.txt', () => {
|
||||
return compilerResult.getSourceMapRecord();
|
||||
}, false, baselineOpts);
|
||||
}
|
||||
});*/
|
||||
|
||||
it('has the expected errors', () => {
|
||||
Harness.Baseline.runBaseline('has the expected errors', baseName + '.errors.txt', () => {
|
||||
@@ -178,7 +179,7 @@ module RWC {
|
||||
it('has the expected errors in generated declaration files', () => {
|
||||
if (compilerOptions.declaration && !compilerResult.errors.length) {
|
||||
Harness.Baseline.runBaseline('has the expected errors in generated declaration files', baseName + '.dts.errors.txt', () => {
|
||||
var declFileCompilationResult = Harness.Compiler.getCompiler().compileDeclarationFiles(inputFiles, otherFiles, compilerResult,
|
||||
let declFileCompilationResult = Harness.Compiler.getCompiler().compileDeclarationFiles(inputFiles, otherFiles, compilerResult,
|
||||
/*settingscallback*/ undefined, compilerOptions, currentDirectory);
|
||||
if (declFileCompilationResult.declResult.errors.length === 0) {
|
||||
return null;
|
||||
@@ -204,8 +205,8 @@ class RWCRunner extends RunnerBase {
|
||||
*/
|
||||
public initializeTests(): void {
|
||||
// Read in and evaluate the test list
|
||||
var testList = Harness.IO.listFiles(RWCRunner.sourcePath, /.+\.json$/);
|
||||
for (var i = 0; i < testList.length; i++) {
|
||||
let testList = Harness.IO.listFiles(RWCRunner.sourcePath, /.+\.json$/);
|
||||
for (let i = 0; i < testList.length; i++) {
|
||||
this.runTest(testList[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//
|
||||
// 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
|
||||
@@ -23,12 +23,12 @@ module Harness.SourceMapRecoder {
|
||||
}
|
||||
|
||||
module SourceMapDecoder {
|
||||
var sourceMapMappings: string;
|
||||
var sourceMapNames: string[];
|
||||
var decodingIndex: number;
|
||||
var prevNameIndex: number;
|
||||
var decodeOfEncodedMapping: ts.SourceMapSpan;
|
||||
var errorDecodeOfEncodedMapping: string;
|
||||
let sourceMapMappings: string;
|
||||
let sourceMapNames: string[];
|
||||
let decodingIndex: number;
|
||||
let prevNameIndex: number;
|
||||
let decodeOfEncodedMapping: ts.SourceMapSpan;
|
||||
let errorDecodeOfEncodedMapping: string;
|
||||
|
||||
export function initializeSourceMapDecoding(sourceMapData: ts.SourceMapData) {
|
||||
sourceMapMappings = sourceMapData.sourceMapMappings;
|
||||
@@ -82,9 +82,9 @@ module Harness.SourceMapRecoder {
|
||||
return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(sourceMapMappings.charAt(decodingIndex));
|
||||
}
|
||||
|
||||
var moreDigits = true;
|
||||
var shiftCount = 0;
|
||||
var value = 0;
|
||||
let moreDigits = true;
|
||||
let shiftCount = 0;
|
||||
let value = 0;
|
||||
|
||||
for (; moreDigits; decodingIndex++) {
|
||||
if (createErrorIfCondition(decodingIndex >= sourceMapMappings.length, "Error in decoding base64VLQFormatDecode, past the mapping string")) {
|
||||
@@ -92,7 +92,7 @@ module Harness.SourceMapRecoder {
|
||||
}
|
||||
|
||||
// 6 digit number
|
||||
var currentByte = base64FormatDecode();
|
||||
let currentByte = base64FormatDecode();
|
||||
|
||||
// If msb is set, we still have more bits to continue
|
||||
moreDigits = (currentByte & 32) !== 0;
|
||||
@@ -143,7 +143,7 @@ module Harness.SourceMapRecoder {
|
||||
return { error: errorDecodeOfEncodedMapping, sourceMapSpan: decodeOfEncodedMapping };
|
||||
}
|
||||
|
||||
// 2. Relative sourceIndex
|
||||
// 2. Relative sourceIndex
|
||||
decodeOfEncodedMapping.sourceIndex += base64VLQFormatDecode();
|
||||
// Incorrect sourceIndex dont support this map
|
||||
if (createErrorIfCondition(decodeOfEncodedMapping.sourceIndex < 0, "Invalid sourceIndex found")) {
|
||||
@@ -165,7 +165,7 @@ module Harness.SourceMapRecoder {
|
||||
return { error: errorDecodeOfEncodedMapping, sourceMapSpan: decodeOfEncodedMapping };
|
||||
}
|
||||
|
||||
// 4. Relative sourceColumn 0 based
|
||||
// 4. Relative sourceColumn 0 based
|
||||
decodeOfEncodedMapping.sourceColumn += base64VLQFormatDecode();
|
||||
// Incorrect sourceColumn dont support this map
|
||||
if (createErrorIfCondition(decodeOfEncodedMapping.sourceColumn < 1, "Invalid sourceLine found")) {
|
||||
@@ -203,19 +203,19 @@ module Harness.SourceMapRecoder {
|
||||
}
|
||||
|
||||
module SourceMapSpanWriter {
|
||||
var sourceMapRecoder: Compiler.WriterAggregator;
|
||||
var sourceMapSources: string[];
|
||||
var sourceMapNames: string[];
|
||||
let sourceMapRecoder: Compiler.WriterAggregator;
|
||||
let sourceMapSources: string[];
|
||||
let sourceMapNames: string[];
|
||||
|
||||
var jsFile: Compiler.GeneratedFile;
|
||||
var jsLineMap: number[];
|
||||
var tsCode: string;
|
||||
var tsLineMap: number[];
|
||||
let jsFile: Compiler.GeneratedFile;
|
||||
let jsLineMap: number[];
|
||||
let tsCode: string;
|
||||
let tsLineMap: number[];
|
||||
|
||||
var spansOnSingleLine: SourceMapSpanWithDecodeErrors[];
|
||||
var prevWrittenSourcePos: number;
|
||||
var prevWrittenJsLine: number;
|
||||
var spanMarkerContinues: boolean;
|
||||
let spansOnSingleLine: SourceMapSpanWithDecodeErrors[];
|
||||
let prevWrittenSourcePos: number;
|
||||
let prevWrittenJsLine: number;
|
||||
let spanMarkerContinues: boolean;
|
||||
|
||||
export function intializeSourceMapSpanWriter(sourceMapRecordWriter: Compiler.WriterAggregator, sourceMapData: ts.SourceMapData, currentJsFile: Compiler.GeneratedFile) {
|
||||
sourceMapRecoder = sourceMapRecordWriter;
|
||||
@@ -244,7 +244,7 @@ module Harness.SourceMapRecoder {
|
||||
}
|
||||
|
||||
function getSourceMapSpanString(mapEntry: ts.SourceMapSpan, getAbsentNameIndex?: boolean) {
|
||||
var mapString = "Emitted(" + mapEntry.emittedLine + ", " + mapEntry.emittedColumn + ") Source(" + mapEntry.sourceLine + ", " + mapEntry.sourceColumn + ") + SourceIndex(" + mapEntry.sourceIndex + ")";
|
||||
let mapString = "Emitted(" + mapEntry.emittedLine + ", " + mapEntry.emittedColumn + ") Source(" + mapEntry.sourceLine + ", " + mapEntry.sourceColumn + ") + SourceIndex(" + mapEntry.sourceIndex + ")";
|
||||
if (mapEntry.nameIndex >= 0 && mapEntry.nameIndex < sourceMapNames.length) {
|
||||
mapString += " name (" + sourceMapNames[mapEntry.nameIndex] + ")";
|
||||
}
|
||||
@@ -259,8 +259,8 @@ module Harness.SourceMapRecoder {
|
||||
|
||||
export function recordSourceMapSpan(sourceMapSpan: ts.SourceMapSpan) {
|
||||
// verify the decoded span is same as the new span
|
||||
var decodeResult = SourceMapDecoder.decodeNextEncodedSourceMapSpan();
|
||||
var decodedErrors: string[];
|
||||
let decodeResult = SourceMapDecoder.decodeNextEncodedSourceMapSpan();
|
||||
let decodedErrors: string[];
|
||||
if (decodeResult.error
|
||||
|| decodeResult.sourceMapSpan.emittedLine !== sourceMapSpan.emittedLine
|
||||
|| decodeResult.sourceMapSpan.emittedColumn !== sourceMapSpan.emittedColumn
|
||||
@@ -278,7 +278,7 @@ module Harness.SourceMapRecoder {
|
||||
}
|
||||
|
||||
if (spansOnSingleLine.length && spansOnSingleLine[0].sourceMapSpan.emittedLine !== sourceMapSpan.emittedLine) {
|
||||
// On different line from the one that we have been recording till now,
|
||||
// On different line from the one that we have been recording till now,
|
||||
writeRecordedSpans();
|
||||
spansOnSingleLine = [{ sourceMapSpan: sourceMapSpan, decodeErrors: decodedErrors }];
|
||||
}
|
||||
@@ -317,8 +317,8 @@ module Harness.SourceMapRecoder {
|
||||
}
|
||||
|
||||
function getTextOfLine(line: number, lineMap: number[], code: string) {
|
||||
var startPos = lineMap[line];
|
||||
var endPos = lineMap[line + 1];
|
||||
let startPos = lineMap[line];
|
||||
let endPos = lineMap[line + 1];
|
||||
return code.substring(startPos, endPos);
|
||||
}
|
||||
|
||||
@@ -329,14 +329,16 @@ module Harness.SourceMapRecoder {
|
||||
}
|
||||
|
||||
function writeRecordedSpans() {
|
||||
let markerIds: string[] = [];
|
||||
|
||||
function getMarkerId(markerIndex: number) {
|
||||
var markerId = "";
|
||||
let markerId = "";
|
||||
if (spanMarkerContinues) {
|
||||
assert.isTrue(markerIndex === 0);
|
||||
markerId = "1->";
|
||||
}
|
||||
else {
|
||||
var markerId = "" + (markerIndex + 1);
|
||||
markerId = "" + (markerIndex + 1);
|
||||
if (markerId.length < 2) {
|
||||
markerId = markerId + " ";
|
||||
}
|
||||
@@ -345,10 +347,10 @@ module Harness.SourceMapRecoder {
|
||||
return markerId;
|
||||
}
|
||||
|
||||
var prevEmittedCol: number;
|
||||
let prevEmittedCol: number;
|
||||
function iterateSpans(fn: (currentSpan: SourceMapSpanWithDecodeErrors, index: number) => void) {
|
||||
prevEmittedCol = 1;
|
||||
for (var i = 0; i < spansOnSingleLine.length; i++) {
|
||||
for (let i = 0; i < spansOnSingleLine.length; i++) {
|
||||
fn(spansOnSingleLine[i], i);
|
||||
prevEmittedCol = spansOnSingleLine[i].sourceMapSpan.emittedColumn;
|
||||
}
|
||||
@@ -356,18 +358,18 @@ module Harness.SourceMapRecoder {
|
||||
|
||||
function writeSourceMapIndent(indentLength: number, indentPrefix: string) {
|
||||
sourceMapRecoder.Write(indentPrefix);
|
||||
for (var i = 1; i < indentLength; i++) {
|
||||
for (let i = 1; i < indentLength; i++) {
|
||||
sourceMapRecoder.Write(" ");
|
||||
}
|
||||
}
|
||||
|
||||
function writeSourceMapMarker(currentSpan: SourceMapSpanWithDecodeErrors, index: number, endColumn = currentSpan.sourceMapSpan.emittedColumn, endContinues?: boolean) {
|
||||
var markerId = getMarkerId(index);
|
||||
let markerId = getMarkerId(index);
|
||||
markerIds.push(markerId);
|
||||
|
||||
writeSourceMapIndent(prevEmittedCol, markerId);
|
||||
|
||||
for (var i = prevEmittedCol; i < endColumn; i++) {
|
||||
for (let i = prevEmittedCol; i < endColumn; i++) {
|
||||
sourceMapRecoder.Write("^");
|
||||
}
|
||||
if (endContinues) {
|
||||
@@ -378,8 +380,8 @@ module Harness.SourceMapRecoder {
|
||||
}
|
||||
|
||||
function writeSourceMapSourceText(currentSpan: SourceMapSpanWithDecodeErrors, index: number) {
|
||||
var sourcePos = tsLineMap[currentSpan.sourceMapSpan.sourceLine - 1] + (currentSpan.sourceMapSpan.sourceColumn - 1);
|
||||
var sourceText = "";
|
||||
let sourcePos = tsLineMap[currentSpan.sourceMapSpan.sourceLine - 1] + (currentSpan.sourceMapSpan.sourceColumn - 1);
|
||||
let sourceText = "";
|
||||
if (prevWrittenSourcePos < sourcePos) {
|
||||
// Position that goes forward, get text
|
||||
sourceText = tsCode.substring(prevWrittenSourcePos, sourcePos);
|
||||
@@ -387,14 +389,14 @@ module Harness.SourceMapRecoder {
|
||||
|
||||
if (currentSpan.decodeErrors) {
|
||||
// If there are decode errors, write
|
||||
for (var i = 0; i < currentSpan.decodeErrors.length; i++) {
|
||||
for (let i = 0; i < currentSpan.decodeErrors.length; i++) {
|
||||
writeSourceMapIndent(prevEmittedCol, markerIds[index]);
|
||||
sourceMapRecoder.WriteLine(currentSpan.decodeErrors[i]);
|
||||
}
|
||||
}
|
||||
|
||||
var tsCodeLineMap = ts.computeLineStarts(sourceText);
|
||||
for (var i = 0; i < tsCodeLineMap.length; i++) {
|
||||
let tsCodeLineMap = ts.computeLineStarts(sourceText);
|
||||
for (let i = 0; i < tsCodeLineMap.length; i++) {
|
||||
writeSourceMapIndent(prevEmittedCol, i === 0 ? markerIds[index] : " >");
|
||||
sourceMapRecoder.Write(getTextOfLine(i, tsCodeLineMap, sourceText));
|
||||
if (i === tsCodeLineMap.length - 1) {
|
||||
@@ -410,16 +412,15 @@ module Harness.SourceMapRecoder {
|
||||
}
|
||||
|
||||
if (spansOnSingleLine.length) {
|
||||
var currentJsLine = spansOnSingleLine[0].sourceMapSpan.emittedLine;
|
||||
let currentJsLine = spansOnSingleLine[0].sourceMapSpan.emittedLine;
|
||||
|
||||
// Write js line
|
||||
writeJsFileLines(currentJsLine);
|
||||
|
||||
// Emit markers
|
||||
var markerIds: string[] = [];
|
||||
iterateSpans(writeSourceMapMarker);
|
||||
|
||||
var jsFileText = getTextOfLine(currentJsLine, jsLineMap, jsFile.code);
|
||||
let jsFileText = getTextOfLine(currentJsLine, jsLineMap, jsFile.code);
|
||||
if (prevEmittedCol < jsFileText.length) {
|
||||
// There is remaining text on this line that will be part of next source span so write marker that continues
|
||||
writeSourceMapMarker(undefined, spansOnSingleLine.length, /*endColumn*/ jsFileText.length, /*endContinues*/ true);
|
||||
@@ -437,16 +438,16 @@ module Harness.SourceMapRecoder {
|
||||
}
|
||||
|
||||
export function getSourceMapRecord(sourceMapDataList: ts.SourceMapData[], program: ts.Program, jsFiles: Compiler.GeneratedFile[]) {
|
||||
var sourceMapRecoder = new Compiler.WriterAggregator();
|
||||
let sourceMapRecoder = new Compiler.WriterAggregator();
|
||||
|
||||
for (var i = 0; i < sourceMapDataList.length; i++) {
|
||||
var sourceMapData = sourceMapDataList[i];
|
||||
var prevSourceFile: ts.SourceFile = null;
|
||||
for (let i = 0; i < sourceMapDataList.length; i++) {
|
||||
let sourceMapData = sourceMapDataList[i];
|
||||
let prevSourceFile: ts.SourceFile = null;
|
||||
|
||||
SourceMapSpanWriter.intializeSourceMapSpanWriter(sourceMapRecoder, sourceMapData, jsFiles[i]);
|
||||
for (var j = 0; j < sourceMapData.sourceMapDecodedMappings.length; j++) {
|
||||
var decodedSourceMapping = sourceMapData.sourceMapDecodedMappings[j];
|
||||
var currentSourceFile = program.getSourceFile(sourceMapData.inputSourceFileNames[decodedSourceMapping.sourceIndex]);
|
||||
for (let j = 0; j < sourceMapData.sourceMapDecodedMappings.length; j++) {
|
||||
let decodedSourceMapping = sourceMapData.sourceMapDecodedMappings[j];
|
||||
let currentSourceFile = program.getSourceFile(sourceMapData.inputSourceFileNames[decodedSourceMapping.sourceIndex]);
|
||||
if (currentSourceFile !== prevSourceFile) {
|
||||
SourceMapSpanWriter.recordNewSourceFileSpan(decodedSourceMapping, currentSourceFile.text);
|
||||
prevSourceFile = currentSourceFile;
|
||||
@@ -455,7 +456,7 @@ module Harness.SourceMapRecoder {
|
||||
SourceMapSpanWriter.recordSourceMapSpan(decodedSourceMapping);
|
||||
}
|
||||
}
|
||||
SourceMapSpanWriter.close();// If the last spans werent emitted, emit them
|
||||
SourceMapSpanWriter.close(); // If the last spans werent emitted, emit them
|
||||
}
|
||||
sourceMapRecoder.Close();
|
||||
return sourceMapRecoder.lines.join('\r\n');
|
||||
|
||||
@@ -27,7 +27,7 @@ class Test262BaselineRunner extends RunnerBase {
|
||||
describe('test262 test for ' + filePath, () => {
|
||||
// Mocha holds onto the closure environment of the describe callback even after the test is done.
|
||||
// Everything declared here should be cleared out in the "after" callback.
|
||||
var testState: {
|
||||
let testState: {
|
||||
filename: string;
|
||||
compilerResult: Harness.Compiler.CompilerResult;
|
||||
inputFiles: { unitName: string; content: string }[];
|
||||
@@ -35,11 +35,11 @@ class Test262BaselineRunner extends RunnerBase {
|
||||
};
|
||||
|
||||
before(() => {
|
||||
var content = Harness.IO.readFile(filePath);
|
||||
var testFilename = ts.removeFileExtension(filePath).replace(/\//g, '_') + ".test";
|
||||
var testCaseContent = Harness.TestCaseParser.makeUnitsFromTest(content, testFilename);
|
||||
let content = Harness.IO.readFile(filePath);
|
||||
let testFilename = ts.removeFileExtension(filePath).replace(/\//g, '_') + ".test";
|
||||
let testCaseContent = Harness.TestCaseParser.makeUnitsFromTest(content, testFilename);
|
||||
|
||||
var inputFiles = testCaseContent.testUnitData.map(unit => {
|
||||
let inputFiles = testCaseContent.testUnitData.map(unit => {
|
||||
return { unitName: Test262BaselineRunner.getTestFilePath(unit.name), content: unit.content };
|
||||
});
|
||||
|
||||
@@ -63,14 +63,14 @@ class Test262BaselineRunner extends RunnerBase {
|
||||
|
||||
it('has the expected emitted code', () => {
|
||||
Harness.Baseline.runBaseline('has the expected emitted code', testState.filename + '.output.js', () => {
|
||||
var files = testState.compilerResult.files.filter(f=> f.fileName !== Test262BaselineRunner.helpersFilePath);
|
||||
let files = testState.compilerResult.files.filter(f => f.fileName !== Test262BaselineRunner.helpersFilePath);
|
||||
return Harness.Compiler.collateOutputs(files);
|
||||
}, false, Test262BaselineRunner.baselineOptions);
|
||||
});
|
||||
|
||||
it('has the expected errors', () => {
|
||||
Harness.Baseline.runBaseline('has the expected errors', testState.filename + '.errors.txt', () => {
|
||||
var errors = testState.compilerResult.errors;
|
||||
let errors = testState.compilerResult.errors;
|
||||
if (errors.length === 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -79,14 +79,14 @@ class Test262BaselineRunner extends RunnerBase {
|
||||
}, false, Test262BaselineRunner.baselineOptions);
|
||||
});
|
||||
|
||||
it('satisfies invariants', () => {
|
||||
var sourceFile = testState.program.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename));
|
||||
it('satisfies inletiants', () => {
|
||||
let sourceFile = testState.program.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename));
|
||||
Utils.assertInvariants(sourceFile, /*parent:*/ undefined);
|
||||
});
|
||||
|
||||
it('has the expected AST',() => {
|
||||
Harness.Baseline.runBaseline('has the expected AST', testState.filename + '.AST.txt',() => {
|
||||
var sourceFile = testState.program.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename));
|
||||
it('has the expected AST', () => {
|
||||
Harness.Baseline.runBaseline('has the expected AST', testState.filename + '.AST.txt', () => {
|
||||
let sourceFile = testState.program.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename));
|
||||
return Utils.sourceFileToJSON(sourceFile);
|
||||
}, false, Test262BaselineRunner.baselineOptions);
|
||||
});
|
||||
@@ -96,7 +96,7 @@ class Test262BaselineRunner extends RunnerBase {
|
||||
public initializeTests() {
|
||||
// this will set up a series of describe/it blocks to run between the setup and cleanup phases
|
||||
if (this.tests.length === 0) {
|
||||
var testFiles = this.enumerateFiles(Test262BaselineRunner.basePath, Test262BaselineRunner.testFileExtensionRegex, { recursive: true });
|
||||
let testFiles = this.enumerateFiles(Test262BaselineRunner.basePath, Test262BaselineRunner.testFileExtensionRegex, { recursive: true });
|
||||
testFiles.forEach(fn => {
|
||||
this.runTest(ts.normalizePath(fn));
|
||||
});
|
||||
@@ -105,4 +105,4 @@ class Test262BaselineRunner extends RunnerBase {
|
||||
this.tests.forEach(test => this.runTest(test));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-11
@@ -13,7 +13,7 @@ class TypeWriterWalker {
|
||||
private checker: ts.TypeChecker;
|
||||
|
||||
constructor(private program: ts.Program, fullTypeCheck: boolean) {
|
||||
// Consider getting both the diagnostics checker and the non-diagnostics checker to verify
|
||||
// Consider getting both the diagnostics checker and the non-diagnostics checker to verify
|
||||
// they are consistent.
|
||||
this.checker = fullTypeCheck
|
||||
? program.getDiagnosticsProducingTypeChecker()
|
||||
@@ -21,7 +21,7 @@ class TypeWriterWalker {
|
||||
}
|
||||
|
||||
public getTypeAndSymbols(fileName: string): TypeWriterResult[] {
|
||||
var sourceFile = this.program.getSourceFile(fileName);
|
||||
let sourceFile = this.program.getSourceFile(fileName);
|
||||
this.currentSourceFile = sourceFile;
|
||||
this.results = [];
|
||||
this.visitNode(sourceFile);
|
||||
@@ -37,19 +37,19 @@ class TypeWriterWalker {
|
||||
}
|
||||
|
||||
private logTypeAndSymbol(node: ts.Node): void {
|
||||
var actualPos = ts.skipTrivia(this.currentSourceFile.text, node.pos);
|
||||
var lineAndCharacter = this.currentSourceFile.getLineAndCharacterOfPosition(actualPos);
|
||||
var sourceText = ts.getTextOfNodeFromSourceText(this.currentSourceFile.text, node);
|
||||
let actualPos = ts.skipTrivia(this.currentSourceFile.text, node.pos);
|
||||
let lineAndCharacter = this.currentSourceFile.getLineAndCharacterOfPosition(actualPos);
|
||||
let sourceText = ts.getTextOfNodeFromSourceText(this.currentSourceFile.text, node);
|
||||
|
||||
// Workaround to ensure we output 'C' instead of 'typeof C' for base class expressions
|
||||
// var type = this.checker.getTypeAtLocation(node);
|
||||
var type = node.parent && ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent) && this.checker.getTypeAtLocation(node.parent) || this.checker.getTypeAtLocation(node);
|
||||
// let type = this.checker.getTypeAtLocation(node);
|
||||
let type = node.parent && ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent) && this.checker.getTypeAtLocation(node.parent) || this.checker.getTypeAtLocation(node);
|
||||
|
||||
ts.Debug.assert(type !== undefined, "type doesn't exist");
|
||||
var symbol = this.checker.getSymbolAtLocation(node);
|
||||
let symbol = this.checker.getSymbolAtLocation(node);
|
||||
|
||||
var typeString = this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation);
|
||||
var symbolString: string;
|
||||
let typeString = this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation);
|
||||
let symbolString: string;
|
||||
if (symbol) {
|
||||
symbolString = "Symbol(" + this.checker.symbolToString(symbol, node.parent);
|
||||
if (symbol.declarations) {
|
||||
@@ -57,7 +57,7 @@ class TypeWriterWalker {
|
||||
symbolString += ", ";
|
||||
let declSourceFile = declaration.getSourceFile();
|
||||
let declLineAndCharacter = declSourceFile.getLineAndCharacterOfPosition(declaration.pos);
|
||||
symbolString += `Decl(${ ts.getBaseFileName(declSourceFile.fileName) }, ${ declLineAndCharacter.line }, ${ declLineAndCharacter.character })`
|
||||
symbolString += `Decl(${ ts.getBaseFileName(declSourceFile.fileName) }, ${ declLineAndCharacter.line }, ${ declLineAndCharacter.character })`;
|
||||
}
|
||||
}
|
||||
symbolString += ")";
|
||||
|
||||
Vendored
+16
-13
@@ -2254,12 +2254,12 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
|
||||
* @param elementId String that specifies the ID value. Case-insensitive.
|
||||
*/
|
||||
getElementById(elementId: string): HTMLElement;
|
||||
getElementsByClassName(classNames: string): NodeList;
|
||||
getElementsByClassName(classNames: string): NodeListOf<Element>;
|
||||
/**
|
||||
* 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;
|
||||
getElementsByName(elementName: string): NodeListOf<Element>;
|
||||
/**
|
||||
* Retrieves a collection of objects based on the specified element name.
|
||||
* @param name Specifies the name of an element.
|
||||
@@ -2437,8 +2437,8 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
|
||||
getElementsByTagName(tagname: "wbr"): NodeListOf<HTMLElement>;
|
||||
getElementsByTagName(tagname: "x-ms-webview"): NodeListOf<MSHTMLWebViewElement>;
|
||||
getElementsByTagName(tagname: "xmp"): NodeListOf<HTMLBlockElement>;
|
||||
getElementsByTagName(tagname: string): NodeList;
|
||||
getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList;
|
||||
getElementsByTagName(tagname: string): NodeListOf<Element>;
|
||||
getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf<Element>;
|
||||
/**
|
||||
* Returns an object representing the current selection of the document that is loaded into the object displaying a webpage.
|
||||
*/
|
||||
@@ -2711,6 +2711,8 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
|
||||
scrollTop: number;
|
||||
scrollWidth: number;
|
||||
tagName: string;
|
||||
id: string;
|
||||
className: string;
|
||||
getAttribute(name?: string): string;
|
||||
getAttributeNS(namespaceURI: string, localName: string): string;
|
||||
getAttributeNode(name: string): Attr;
|
||||
@@ -2890,8 +2892,8 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
|
||||
getElementsByTagName(name: "wbr"): NodeListOf<HTMLElement>;
|
||||
getElementsByTagName(name: "x-ms-webview"): NodeListOf<MSHTMLWebViewElement>;
|
||||
getElementsByTagName(name: "xmp"): NodeListOf<HTMLBlockElement>;
|
||||
getElementsByTagName(name: string): NodeList;
|
||||
getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList;
|
||||
getElementsByTagName(name: string): NodeListOf<Element>;
|
||||
getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf<Element>;
|
||||
hasAttribute(name: string): boolean;
|
||||
hasAttributeNS(namespaceURI: string, localName: string): boolean;
|
||||
msGetRegionContent(): MSRangeCollection;
|
||||
@@ -3072,7 +3074,7 @@ interface FormData {
|
||||
|
||||
declare var FormData: {
|
||||
prototype: FormData;
|
||||
new(): FormData;
|
||||
new (form?: HTMLFormElement): FormData;
|
||||
}
|
||||
|
||||
interface GainNode extends AudioNode {
|
||||
@@ -3809,14 +3811,12 @@ declare var HTMLDocument: {
|
||||
interface HTMLElement extends Element {
|
||||
accessKey: string;
|
||||
children: HTMLCollection;
|
||||
className: string;
|
||||
contentEditable: string;
|
||||
dataset: DOMStringMap;
|
||||
dir: string;
|
||||
draggable: boolean;
|
||||
hidden: boolean;
|
||||
hideFocus: boolean;
|
||||
id: string;
|
||||
innerHTML: string;
|
||||
innerText: string;
|
||||
isContentEditable: boolean;
|
||||
@@ -3903,7 +3903,7 @@ interface HTMLElement extends Element {
|
||||
contains(child: HTMLElement): boolean;
|
||||
dragDrop(): boolean;
|
||||
focus(): void;
|
||||
getElementsByClassName(classNames: string): NodeList;
|
||||
getElementsByClassName(classNames: string): NodeListOf<Element>;
|
||||
insertAdjacentElement(position: string, insertedElement: Element): Element;
|
||||
insertAdjacentHTML(where: string, html: string): void;
|
||||
insertAdjacentText(where: string, text: string): void;
|
||||
@@ -8715,6 +8715,7 @@ declare var SVGDescElement: {
|
||||
|
||||
interface SVGElement extends Element {
|
||||
id: string;
|
||||
className: any;
|
||||
onclick: (ev: MouseEvent) => any;
|
||||
ondblclick: (ev: MouseEvent) => any;
|
||||
onfocusin: (ev: FocusEvent) => any;
|
||||
@@ -11984,6 +11985,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window
|
||||
toolbar: BarProp;
|
||||
top: Window;
|
||||
window: Window;
|
||||
URL: URL;
|
||||
alert(message?: any): void;
|
||||
blur(): void;
|
||||
cancelAnimationFrame(handle: number): void;
|
||||
@@ -12487,7 +12489,7 @@ interface NavigatorStorageUtils {
|
||||
|
||||
interface NodeSelector {
|
||||
querySelector(selectors: string): Element;
|
||||
querySelectorAll(selectors: string): NodeList;
|
||||
querySelectorAll(selectors: string): NodeListOf<Element>;
|
||||
}
|
||||
|
||||
interface RandomSource {
|
||||
@@ -12535,7 +12537,7 @@ interface SVGLocatable {
|
||||
}
|
||||
|
||||
interface SVGStylable {
|
||||
className: SVGAnimatedString;
|
||||
className: any;
|
||||
style: CSSStyleDeclaration;
|
||||
}
|
||||
|
||||
@@ -12622,7 +12624,7 @@ interface EventListenerObject {
|
||||
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
|
||||
|
||||
interface ErrorEventHandler {
|
||||
(event: Event | string, source?: string, fileno?: number, columnNumber?: number): void;
|
||||
(message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void;
|
||||
}
|
||||
interface PositionCallback {
|
||||
(position: Position): void;
|
||||
@@ -12798,6 +12800,7 @@ declare var styleMedia: StyleMedia;
|
||||
declare var toolbar: BarProp;
|
||||
declare var top: Window;
|
||||
declare var window: Window;
|
||||
declare var URL: URL;
|
||||
declare function alert(message?: any): void;
|
||||
declare function blur(): void;
|
||||
declare function cancelAnimationFrame(handle: number): void;
|
||||
|
||||
+122
-136
@@ -839,6 +839,127 @@ namespace ts.server {
|
||||
exit() {
|
||||
}
|
||||
|
||||
private handlers : Map<(request: protocol.Request) => {response?: any, responseRequired?: boolean}> = {
|
||||
[CommandNames.Exit]: () => {
|
||||
this.exit();
|
||||
return { responseRequired: false};
|
||||
},
|
||||
[CommandNames.Definition]: (request: protocol.Request) => {
|
||||
var defArgs = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
return {response: this.getDefinition(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true};
|
||||
},
|
||||
[CommandNames.TypeDefinition]: (request: protocol.Request) => {
|
||||
var defArgs = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
return {response: this.getTypeDefinition(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true};
|
||||
},
|
||||
[CommandNames.References]: (request: protocol.Request) => {
|
||||
var defArgs = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
return {response: this.getReferences(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true};
|
||||
},
|
||||
[CommandNames.Rename]: (request: protocol.Request) => {
|
||||
var renameArgs = <protocol.RenameRequestArgs>request.arguments;
|
||||
return {response: this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings), responseRequired: true}
|
||||
},
|
||||
[CommandNames.Open]: (request: protocol.Request) => {
|
||||
var openArgs = <protocol.OpenRequestArgs>request.arguments;
|
||||
this.openClientFile(openArgs.file);
|
||||
return {responseRequired: false}
|
||||
},
|
||||
[CommandNames.Quickinfo]: (request: protocol.Request) => {
|
||||
var quickinfoArgs = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
return {response: this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file), responseRequired: true};
|
||||
},
|
||||
[CommandNames.Format]: (request: protocol.Request) => {
|
||||
var formatArgs = <protocol.FormatRequestArgs>request.arguments;
|
||||
return {response: this.getFormattingEditsForRange(formatArgs.line, formatArgs.offset, formatArgs.endLine, formatArgs.endOffset, formatArgs.file), responseRequired: true};
|
||||
},
|
||||
[CommandNames.Formatonkey]: (request: protocol.Request) => {
|
||||
var formatOnKeyArgs = <protocol.FormatOnKeyRequestArgs>request.arguments;
|
||||
return {response: this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file), responseRequired: true};
|
||||
},
|
||||
[CommandNames.Completions]: (request: protocol.Request) => {
|
||||
var completionsArgs = <protocol.CompletionsRequestArgs>request.arguments;
|
||||
return {response: this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file), responseRequired: true}
|
||||
},
|
||||
[CommandNames.CompletionDetails]: (request: protocol.Request) => {
|
||||
var completionDetailsArgs = <protocol.CompletionDetailsRequestArgs>request.arguments;
|
||||
return {response: this.getCompletionEntryDetails(completionDetailsArgs.line,completionDetailsArgs.offset,
|
||||
completionDetailsArgs.entryNames,completionDetailsArgs.file), responseRequired: true}
|
||||
},
|
||||
[CommandNames.SignatureHelp]: (request: protocol.Request) => {
|
||||
var signatureHelpArgs = <protocol.SignatureHelpRequestArgs>request.arguments;
|
||||
return {response: this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file), responseRequired: true}
|
||||
},
|
||||
[CommandNames.Geterr]: (request: protocol.Request) => {
|
||||
var geterrArgs = <protocol.GeterrRequestArgs>request.arguments;
|
||||
return {response: this.getDiagnostics(geterrArgs.delay, geterrArgs.files), responseRequired: false};
|
||||
},
|
||||
[CommandNames.Change]: (request: protocol.Request) => {
|
||||
var changeArgs = <protocol.ChangeRequestArgs>request.arguments;
|
||||
this.change(changeArgs.line, changeArgs.offset, changeArgs.endLine, changeArgs.endOffset,
|
||||
changeArgs.insertString, changeArgs.file);
|
||||
return {responseRequired: false}
|
||||
},
|
||||
[CommandNames.Configure]: (request: protocol.Request) => {
|
||||
var configureArgs = <protocol.ConfigureRequestArguments>request.arguments;
|
||||
this.projectService.setHostConfiguration(configureArgs);
|
||||
this.output(undefined, CommandNames.Configure, request.seq);
|
||||
return {responseRequired: false}
|
||||
},
|
||||
[CommandNames.Reload]: (request: protocol.Request) => {
|
||||
var reloadArgs = <protocol.ReloadRequestArgs>request.arguments;
|
||||
this.reload(reloadArgs.file, reloadArgs.tmpfile, request.seq);
|
||||
return {responseRequired: false}
|
||||
},
|
||||
[CommandNames.Saveto]: (request: protocol.Request) => {
|
||||
var savetoArgs = <protocol.SavetoRequestArgs>request.arguments;
|
||||
this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile);
|
||||
return {responseRequired: false}
|
||||
},
|
||||
[CommandNames.Close]: (request: protocol.Request) => {
|
||||
var closeArgs = <protocol.FileRequestArgs>request.arguments;
|
||||
this.closeClientFile(closeArgs.file);
|
||||
return {responseRequired: false};
|
||||
},
|
||||
[CommandNames.Navto]: (request: protocol.Request) => {
|
||||
var navtoArgs = <protocol.NavtoRequestArgs>request.arguments;
|
||||
return {response: this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount), responseRequired: true};
|
||||
},
|
||||
[CommandNames.Brace]: (request: protocol.Request) => {
|
||||
var braceArguments = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
return {response: this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file), responseRequired: true};
|
||||
},
|
||||
[CommandNames.NavBar]: (request: protocol.Request) => {
|
||||
var navBarArgs = <protocol.FileRequestArgs>request.arguments;
|
||||
return {response: this.getNavigationBarItems(navBarArgs.file), responseRequired: true};
|
||||
},
|
||||
[CommandNames.Occurrences]: (request: protocol.Request) => {
|
||||
var { line, offset, file: fileName } = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
return {response: this.getOccurrences(line, offset, fileName), responseRequired: true};
|
||||
},
|
||||
[CommandNames.ProjectInfo]: (request: protocol.Request) => {
|
||||
var { file, needFileNameList } = <protocol.ProjectInfoRequestArgs>request.arguments;
|
||||
return {response: this.getProjectInfo(file, needFileNameList), responseRequired: true};
|
||||
},
|
||||
};
|
||||
addProtocolHandler(command: string, handler: (request: protocol.Request) => {response?: any, responseRequired: boolean}) {
|
||||
if (this.handlers[command]) {
|
||||
throw new Error(`Protocol handler already exists for command "${command}"`);
|
||||
}
|
||||
this.handlers[command] = handler;
|
||||
}
|
||||
|
||||
executeCommand(request: protocol.Request) : {response?: any, responseRequired?: boolean} {
|
||||
var handler = this.handlers[request.command];
|
||||
if (handler) {
|
||||
return handler(request);
|
||||
} else {
|
||||
this.projectService.log("Unrecognized JSON command: " + JSON.stringify(request));
|
||||
this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command);
|
||||
return {responseRequired: false};
|
||||
}
|
||||
}
|
||||
|
||||
onMessage(message: string) {
|
||||
if (this.logger.isVerbose()) {
|
||||
this.logger.info("request: " + message);
|
||||
@@ -846,142 +967,7 @@ namespace ts.server {
|
||||
}
|
||||
try {
|
||||
var request = <protocol.Request>JSON.parse(message);
|
||||
var response: any;
|
||||
var errorMessage: string;
|
||||
var responseRequired = true;
|
||||
switch (request.command) {
|
||||
case CommandNames.Exit: {
|
||||
this.exit();
|
||||
responseRequired = false;
|
||||
break;
|
||||
}
|
||||
case CommandNames.Definition: {
|
||||
var defArgs = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
response = this.getDefinition(defArgs.line, defArgs.offset, defArgs.file);
|
||||
break;
|
||||
}
|
||||
case CommandNames.TypeDefinition: {
|
||||
var defArgs = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
response = this.getTypeDefinition(defArgs.line, defArgs.offset, defArgs.file);
|
||||
break;
|
||||
}
|
||||
case CommandNames.References: {
|
||||
var refArgs = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
response = this.getReferences(refArgs.line, refArgs.offset, refArgs.file);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Rename: {
|
||||
var renameArgs = <protocol.RenameRequestArgs>request.arguments;
|
||||
response = this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Open: {
|
||||
var openArgs = <protocol.OpenRequestArgs>request.arguments;
|
||||
this.openClientFile(openArgs.file);
|
||||
responseRequired = false;
|
||||
break;
|
||||
}
|
||||
case CommandNames.Quickinfo: {
|
||||
var quickinfoArgs = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
response = this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Format: {
|
||||
var formatArgs = <protocol.FormatRequestArgs>request.arguments;
|
||||
response = this.getFormattingEditsForRange(formatArgs.line, formatArgs.offset, formatArgs.endLine, formatArgs.endOffset, formatArgs.file);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Formatonkey: {
|
||||
var formatOnKeyArgs = <protocol.FormatOnKeyRequestArgs>request.arguments;
|
||||
response = this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Completions: {
|
||||
var completionsArgs = <protocol.CompletionsRequestArgs>request.arguments;
|
||||
response = this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file);
|
||||
break;
|
||||
}
|
||||
case CommandNames.CompletionDetails: {
|
||||
var completionDetailsArgs = <protocol.CompletionDetailsRequestArgs>request.arguments;
|
||||
response =
|
||||
this.getCompletionEntryDetails(completionDetailsArgs.line,completionDetailsArgs.offset,
|
||||
completionDetailsArgs.entryNames,completionDetailsArgs.file);
|
||||
break;
|
||||
}
|
||||
case CommandNames.SignatureHelp: {
|
||||
var signatureHelpArgs = <protocol.SignatureHelpRequestArgs>request.arguments;
|
||||
response = this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Geterr: {
|
||||
var geterrArgs = <protocol.GeterrRequestArgs>request.arguments;
|
||||
response = this.getDiagnostics(geterrArgs.delay, geterrArgs.files);
|
||||
responseRequired = false;
|
||||
break;
|
||||
}
|
||||
case CommandNames.Change: {
|
||||
var changeArgs = <protocol.ChangeRequestArgs>request.arguments;
|
||||
this.change(changeArgs.line, changeArgs.offset, changeArgs.endLine, changeArgs.endOffset,
|
||||
changeArgs.insertString, changeArgs.file);
|
||||
responseRequired = false;
|
||||
break;
|
||||
}
|
||||
case CommandNames.Configure: {
|
||||
var configureArgs = <protocol.ConfigureRequestArguments>request.arguments;
|
||||
this.projectService.setHostConfiguration(configureArgs);
|
||||
this.output(undefined, CommandNames.Configure, request.seq);
|
||||
responseRequired = false;
|
||||
break;
|
||||
}
|
||||
case CommandNames.Reload: {
|
||||
var reloadArgs = <protocol.ReloadRequestArgs>request.arguments;
|
||||
this.reload(reloadArgs.file, reloadArgs.tmpfile, request.seq);
|
||||
responseRequired = false;
|
||||
break;
|
||||
}
|
||||
case CommandNames.Saveto: {
|
||||
var savetoArgs = <protocol.SavetoRequestArgs>request.arguments;
|
||||
this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile);
|
||||
responseRequired = false;
|
||||
break;
|
||||
}
|
||||
case CommandNames.Close: {
|
||||
var closeArgs = <protocol.FileRequestArgs>request.arguments;
|
||||
this.closeClientFile(closeArgs.file);
|
||||
responseRequired = false;
|
||||
break;
|
||||
}
|
||||
case CommandNames.Navto: {
|
||||
var navtoArgs = <protocol.NavtoRequestArgs>request.arguments;
|
||||
response = this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Brace: {
|
||||
var braceArguments = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
response = this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file);
|
||||
break;
|
||||
}
|
||||
case CommandNames.NavBar: {
|
||||
var navBarArgs = <protocol.FileRequestArgs>request.arguments;
|
||||
response = this.getNavigationBarItems(navBarArgs.file);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Occurrences: {
|
||||
var { line, offset, file: fileName } = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
response = this.getOccurrences(line, offset, fileName);
|
||||
break;
|
||||
}
|
||||
case CommandNames.ProjectInfo: {
|
||||
var { file, needFileNameList } = <protocol.ProjectInfoRequestArgs>request.arguments;
|
||||
response = this.getProjectInfo(file, needFileNameList);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
this.projectService.log("Unrecognized JSON command: " + message);
|
||||
this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command);
|
||||
break;
|
||||
}
|
||||
}
|
||||
var {response, responseRequired} = this.executeCommand(request);
|
||||
|
||||
if (this.logger.isVerbose()) {
|
||||
var elapsed = this.hrtime(start);
|
||||
|
||||
@@ -480,6 +480,8 @@ namespace ts.formatting {
|
||||
case SyntaxKind.CloseBraceToken:
|
||||
case SyntaxKind.OpenBracketToken:
|
||||
case SyntaxKind.CloseBracketToken:
|
||||
case SyntaxKind.OpenParenToken:
|
||||
case SyntaxKind.CloseParenToken:
|
||||
case SyntaxKind.ElseKeyword:
|
||||
case SyntaxKind.WhileKeyword:
|
||||
case SyntaxKind.AtToken:
|
||||
@@ -644,7 +646,7 @@ namespace ts.formatting {
|
||||
// consume list start token
|
||||
startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line;
|
||||
let indentation =
|
||||
computeIndentation(tokenInfo.token, startLine, Constants.Unknown, parent, parentDynamicIndentation, startLine);
|
||||
computeIndentation(tokenInfo.token, startLine, Constants.Unknown, parent, parentDynamicIndentation, parentStartLine);
|
||||
|
||||
listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation.indentation, indentation.delta);
|
||||
consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation);
|
||||
|
||||
@@ -228,7 +228,7 @@ namespace ts.NavigationBar {
|
||||
|
||||
function merge(target: ts.NavigationBarItem, source: ts.NavigationBarItem) {
|
||||
// First, add any spans in the source to the target.
|
||||
target.spans.push.apply(target.spans, source.spans);
|
||||
addRange(target.spans, source.spans);
|
||||
|
||||
if (source.childItems) {
|
||||
if (!target.childItems) {
|
||||
@@ -465,7 +465,7 @@ namespace ts.NavigationBar {
|
||||
// are not properties will be filtered out later by createChildItem.
|
||||
let nodes: Node[] = removeDynamicallyNamedProperties(node);
|
||||
if (constructor) {
|
||||
nodes.push.apply(nodes, filter(constructor.parameters, p => !isBindingPattern(p.name)));
|
||||
addRange(nodes, filter(constructor.parameters, p => !isBindingPattern(p.name)));
|
||||
}
|
||||
|
||||
childItems = getItemsWorker(sortNodes(nodes), createChildItem);
|
||||
|
||||
+216
-129
@@ -91,6 +91,9 @@ namespace ts {
|
||||
* not happen and the entire document will be re - parsed.
|
||||
*/
|
||||
getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange;
|
||||
|
||||
/** Releases all resources held by this script snapshot */
|
||||
dispose?(): void;
|
||||
}
|
||||
|
||||
export module ScriptSnapshot {
|
||||
@@ -345,7 +348,7 @@ namespace ts {
|
||||
ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), jsDocCommentTextRange => {
|
||||
let cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration);
|
||||
if (cleanedParamJsDocComment) {
|
||||
jsDocCommentParts.push.apply(jsDocCommentParts, cleanedParamJsDocComment);
|
||||
addRange(jsDocCommentParts, cleanedParamJsDocComment);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -365,7 +368,7 @@ namespace ts {
|
||||
declaration.kind === SyntaxKind.VariableDeclaration ? declaration.parent.parent : declaration, sourceFileOfDeclaration), jsDocCommentTextRange => {
|
||||
let cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration);
|
||||
if (cleanedJsDocComment) {
|
||||
jsDocCommentParts.push.apply(jsDocCommentParts, cleanedJsDocComment);
|
||||
addRange(jsDocCommentParts, cleanedJsDocComment);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1431,6 +1434,9 @@ namespace ts {
|
||||
// class X {}
|
||||
export const classElement = "class";
|
||||
|
||||
// var x = class X {}
|
||||
export const localClassElement = "local class";
|
||||
|
||||
// interface Y {}
|
||||
export const interfaceElement = "interface";
|
||||
|
||||
@@ -1863,6 +1869,16 @@ namespace ts {
|
||||
// after incremental parsing nameTable might not be up-to-date
|
||||
// drop it so it can be lazily recreated later
|
||||
newSourceFile.nameTable = undefined;
|
||||
|
||||
// dispose all resources held by old script snapshot
|
||||
if (sourceFile !== newSourceFile && sourceFile.scriptSnapshot) {
|
||||
if (sourceFile.scriptSnapshot.dispose) {
|
||||
sourceFile.scriptSnapshot.dispose();
|
||||
}
|
||||
|
||||
sourceFile.scriptSnapshot = undefined;
|
||||
}
|
||||
|
||||
return newSourceFile;
|
||||
}
|
||||
}
|
||||
@@ -2802,18 +2818,15 @@ namespace ts {
|
||||
program.getGlobalDiagnostics(cancellationToken));
|
||||
}
|
||||
|
||||
/// Completion
|
||||
function getCompletionEntryDisplayNameForSymbol(symbol: Symbol, target: ScriptTarget, performCharacterChecks: boolean): string {
|
||||
let displayName = symbol.getName();
|
||||
if (displayName) {
|
||||
// If this is the default export, get the name of the declaration if it exists
|
||||
if (displayName === "default") {
|
||||
let localSymbol = getLocalSymbolForExportDefault(symbol);
|
||||
if (localSymbol && localSymbol.name) {
|
||||
displayName = symbol.valueDeclaration.localSymbol.name;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get the name to be display in completion from a given symbol.
|
||||
*
|
||||
* @return undefined if the name is of external module otherwise a name with striped of any quote
|
||||
*/
|
||||
function getCompletionEntryDisplayNameForSymbol(symbol: Symbol, target: ScriptTarget, performCharacterChecks: boolean, location: Node): string {
|
||||
let displayName: string = getDeclaredName(program.getTypeChecker(), symbol, location);
|
||||
|
||||
if (displayName) {
|
||||
let firstCharCode = displayName.charCodeAt(0);
|
||||
// First check of the displayName is not external module; if it is an external module, it is not valid entry
|
||||
if ((symbol.flags & SymbolFlags.Namespace) && (firstCharCode === CharacterCodes.singleQuote || firstCharCode === CharacterCodes.doubleQuote)) {
|
||||
@@ -2826,37 +2839,38 @@ namespace ts {
|
||||
return getCompletionEntryDisplayName(displayName, target, performCharacterChecks);
|
||||
}
|
||||
|
||||
function getCompletionEntryDisplayName(displayName: string, target: ScriptTarget, performCharacterChecks: boolean): string {
|
||||
if (!displayName) {
|
||||
/**
|
||||
* Get a displayName from a given for completion list, performing any necessary quotes stripping
|
||||
* and checking whether the name is valid identifier name.
|
||||
*/
|
||||
function getCompletionEntryDisplayName(name: string, target: ScriptTarget, performCharacterChecks: boolean): string {
|
||||
if (!name) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let firstCharCode = displayName.charCodeAt(0);
|
||||
if (displayName.length >= 2 &&
|
||||
firstCharCode === displayName.charCodeAt(displayName.length - 1) &&
|
||||
(firstCharCode === CharacterCodes.singleQuote || firstCharCode === CharacterCodes.doubleQuote)) {
|
||||
// If the user entered name for the symbol was quoted, removing the quotes is not enough, as the name could be an
|
||||
// invalid identifier name. We need to check if whatever was inside the quotes is actually a valid identifier name.
|
||||
displayName = displayName.substring(1, displayName.length - 1);
|
||||
}
|
||||
name = stripQuotes(name);
|
||||
|
||||
if (!displayName) {
|
||||
if (!name) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// If the user entered name for the symbol was quoted, removing the quotes is not enough, as the name could be an
|
||||
// invalid identifier name. We need to check if whatever was inside the quotes is actually a valid identifier name.
|
||||
// e.g "b a" is valid quoted name but when we strip off the quotes, it is invalid.
|
||||
// We, thus, need to check if whatever was inside the quotes is actually a valid identifier name.
|
||||
if (performCharacterChecks) {
|
||||
if (!isIdentifierStart(displayName.charCodeAt(0), target)) {
|
||||
if (!isIdentifierStart(name.charCodeAt(0), target)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
for (let i = 1, n = displayName.length; i < n; i++) {
|
||||
if (!isIdentifierPart(displayName.charCodeAt(i), target)) {
|
||||
for (let i = 1, n = name.length; i < n; i++) {
|
||||
if (!isIdentifierPart(name.charCodeAt(i), target)) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return unescapeIdentifier(displayName);
|
||||
return name;
|
||||
}
|
||||
|
||||
function getCompletionData(fileName: string, position: number) {
|
||||
@@ -3017,17 +3031,17 @@ namespace ts {
|
||||
|
||||
function tryGetGlobalSymbols(): boolean {
|
||||
let objectLikeContainer: ObjectLiteralExpression | BindingPattern;
|
||||
let importClause: ImportClause;
|
||||
let namedImportsOrExports: NamedImportsOrExports;
|
||||
let jsxContainer: JsxOpeningLikeElement;
|
||||
|
||||
if (objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken)) {
|
||||
return tryGetObjectLikeCompletionSymbols(objectLikeContainer);
|
||||
}
|
||||
|
||||
if (importClause = <ImportClause>getAncestor(contextToken, SyntaxKind.ImportClause)) {
|
||||
if (namedImportsOrExports = tryGetNamedImportsOrExportsForCompletion(contextToken)) {
|
||||
// cursor is in an import clause
|
||||
// try to show exported member for imported module
|
||||
return tryGetImportClauseCompletionSymbols(importClause);
|
||||
return tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports);
|
||||
}
|
||||
|
||||
if (jsxContainer = tryGetContainingJsxElement(contextToken)) {
|
||||
@@ -3037,7 +3051,7 @@ namespace ts {
|
||||
attrsType = typeChecker.getJsxElementAttributesType(<JsxOpeningLikeElement>jsxContainer);
|
||||
|
||||
if (attrsType) {
|
||||
symbols = filterJsxAttributes((<JsxOpeningLikeElement>jsxContainer).attributes, typeChecker.getPropertiesOfType(attrsType));
|
||||
symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), (<JsxOpeningLikeElement>jsxContainer).attributes);
|
||||
isMemberCompletion = true;
|
||||
isNewIdentifierLocation = false;
|
||||
return true;
|
||||
@@ -3106,24 +3120,12 @@ namespace ts {
|
||||
function isCompletionListBlocker(contextToken: Node): boolean {
|
||||
let start = new Date().getTime();
|
||||
let result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) ||
|
||||
isIdentifierDefinitionLocation(contextToken) ||
|
||||
isSolelyIdentifierDefinitionLocation(contextToken) ||
|
||||
isDotOfNumericLiteral(contextToken);
|
||||
log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start));
|
||||
return result;
|
||||
}
|
||||
|
||||
function shouldShowCompletionsInImportsClause(node: Node): boolean {
|
||||
if (node) {
|
||||
// import {|
|
||||
// import {a,|
|
||||
if (node.kind === SyntaxKind.OpenBraceToken || node.kind === SyntaxKind.CommaToken) {
|
||||
return node.parent.kind === SyntaxKind.NamedImports;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function isNewIdentifierDefinitionLocation(previousToken: Node): boolean {
|
||||
if (previousToken) {
|
||||
let containingNodeKind = previousToken.parent.kind;
|
||||
@@ -3235,8 +3237,19 @@ namespace ts {
|
||||
// We are *only* completing on properties from the type being destructured.
|
||||
isNewIdentifierLocation = false;
|
||||
|
||||
typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer);
|
||||
existingMembers = (<BindingPattern>objectLikeContainer).elements;
|
||||
let rootDeclaration = getRootDeclaration(objectLikeContainer.parent);
|
||||
if (isVariableLike(rootDeclaration)) {
|
||||
// We don't want to complete using the type acquired by the shape
|
||||
// of the binding pattern; we are only interested in types acquired
|
||||
// through type declaration or inference.
|
||||
if (rootDeclaration.initializer || rootDeclaration.type) {
|
||||
typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer);
|
||||
existingMembers = (<BindingPattern>objectLikeContainer).elements;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Debug.fail("Root declaration is not variable-like.")
|
||||
}
|
||||
}
|
||||
else {
|
||||
Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind);
|
||||
@@ -3255,38 +3268,42 @@ namespace ts {
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggregates relevant symbols for completion in import clauses; for instance,
|
||||
* Aggregates relevant symbols for completion in import clauses and export clauses
|
||||
* whose declarations have a module specifier; for instance, symbols will be aggregated for
|
||||
*
|
||||
* import { $ } from "moduleName";
|
||||
* import { | } from "moduleName";
|
||||
* export { a as foo, | } from "moduleName";
|
||||
*
|
||||
* but not for
|
||||
*
|
||||
* export { | };
|
||||
*
|
||||
* Relevant symbols are stored in the captured 'symbols' variable.
|
||||
*
|
||||
* @returns true if 'symbols' was successfully populated; false otherwise.
|
||||
*/
|
||||
function tryGetImportClauseCompletionSymbols(importClause: ImportClause): boolean {
|
||||
// cursor is in import clause
|
||||
// try to show exported member for imported module
|
||||
if (shouldShowCompletionsInImportsClause(contextToken)) {
|
||||
isMemberCompletion = true;
|
||||
isNewIdentifierLocation = false;
|
||||
function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports: NamedImportsOrExports): boolean {
|
||||
let declarationKind = namedImportsOrExports.kind === SyntaxKind.NamedImports ?
|
||||
SyntaxKind.ImportDeclaration :
|
||||
SyntaxKind.ExportDeclaration;
|
||||
let importOrExportDeclaration = <ImportDeclaration | ExportDeclaration>getAncestor(namedImportsOrExports, declarationKind);
|
||||
let moduleSpecifier = importOrExportDeclaration.moduleSpecifier;
|
||||
|
||||
let importDeclaration = <ImportDeclaration>importClause.parent;
|
||||
Debug.assert(importDeclaration !== undefined && importDeclaration.kind === SyntaxKind.ImportDeclaration);
|
||||
|
||||
let exports: Symbol[];
|
||||
let moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importDeclaration.moduleSpecifier);
|
||||
if (moduleSpecifierSymbol) {
|
||||
exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol);
|
||||
}
|
||||
|
||||
//let exports = typeInfoResolver.getExportsOfImportDeclaration(importDeclaration);
|
||||
symbols = exports ? filterModuleExports(exports, importDeclaration) : emptyArray;
|
||||
if (!moduleSpecifier) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
isMemberCompletion = false;
|
||||
isNewIdentifierLocation = true;
|
||||
|
||||
isMemberCompletion = true;
|
||||
isNewIdentifierLocation = false;
|
||||
|
||||
let exports: Symbol[];
|
||||
let moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importOrExportDeclaration.moduleSpecifier);
|
||||
if (moduleSpecifierSymbol) {
|
||||
exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol);
|
||||
}
|
||||
|
||||
symbols = exports ? filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements) : emptyArray;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3310,6 +3327,26 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the containing list of named imports or exports of a context token,
|
||||
* on the condition that one exists and that the context implies completion should be given.
|
||||
*/
|
||||
function tryGetNamedImportsOrExportsForCompletion(contextToken: Node): NamedImportsOrExports {
|
||||
if (contextToken) {
|
||||
switch (contextToken.kind) {
|
||||
case SyntaxKind.OpenBraceToken: // import { |
|
||||
case SyntaxKind.CommaToken: // import { a as 0, |
|
||||
switch (contextToken.parent.kind) {
|
||||
case SyntaxKind.NamedImports:
|
||||
case SyntaxKind.NamedExports:
|
||||
return <NamedImportsOrExports>contextToken.parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function tryGetContainingJsxElement(contextToken: Node): JsxOpeningLikeElement {
|
||||
if (contextToken) {
|
||||
let parent = contextToken.parent;
|
||||
@@ -3357,7 +3394,10 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function isIdentifierDefinitionLocation(contextToken: Node): boolean {
|
||||
/**
|
||||
* @returns true if we are certain that the currently edited location must define a new location; false otherwise.
|
||||
*/
|
||||
function isSolelyIdentifierDefinitionLocation(contextToken: Node): boolean {
|
||||
let containingNodeKind = contextToken.parent.kind;
|
||||
switch (contextToken.kind) {
|
||||
case SyntaxKind.CommaToken:
|
||||
@@ -3414,6 +3454,11 @@ namespace ts {
|
||||
case SyntaxKind.ProtectedKeyword:
|
||||
return containingNodeKind === SyntaxKind.Parameter;
|
||||
|
||||
case SyntaxKind.AsKeyword:
|
||||
containingNodeKind === SyntaxKind.ImportSpecifier ||
|
||||
containingNodeKind === SyntaxKind.ExportSpecifier ||
|
||||
containingNodeKind === SyntaxKind.NamespaceImport;
|
||||
|
||||
case SyntaxKind.ClassKeyword:
|
||||
case SyntaxKind.EnumKeyword:
|
||||
case SyntaxKind.InterfaceKeyword:
|
||||
@@ -3455,28 +3500,41 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function filterModuleExports(exports: Symbol[], importDeclaration: ImportDeclaration): Symbol[] {
|
||||
let exisingImports: Map<boolean> = {};
|
||||
/**
|
||||
* Filters out completion suggestions for named imports or exports.
|
||||
*
|
||||
* @param exportsOfModule The list of symbols which a module exposes.
|
||||
* @param namedImportsOrExports The list of existing import/export specifiers in the import/export clause.
|
||||
*
|
||||
* @returns Symbols to be suggested at an import/export clause, barring those whose named imports/exports
|
||||
* do not occur at the current position and have not otherwise been typed.
|
||||
*/
|
||||
function filterNamedImportOrExportCompletionItems(exportsOfModule: Symbol[], namedImportsOrExports: ImportOrExportSpecifier[]): Symbol[] {
|
||||
let exisingImportsOrExports: Map<boolean> = {};
|
||||
|
||||
if (!importDeclaration.importClause) {
|
||||
return exports;
|
||||
for (let element of namedImportsOrExports) {
|
||||
// If this is the current item we are editing right now, do not filter it out
|
||||
if (element.getStart() <= position && position <= element.getEnd()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let name = element.propertyName || element.name;
|
||||
exisingImportsOrExports[name.text] = true;
|
||||
}
|
||||
|
||||
if (importDeclaration.importClause.namedBindings &&
|
||||
importDeclaration.importClause.namedBindings.kind === SyntaxKind.NamedImports) {
|
||||
|
||||
forEach((<NamedImports>importDeclaration.importClause.namedBindings).elements, el => {
|
||||
let name = el.propertyName || el.name;
|
||||
exisingImports[name.text] = true;
|
||||
});
|
||||
if (isEmpty(exisingImportsOrExports)) {
|
||||
return exportsOfModule;
|
||||
}
|
||||
|
||||
if (isEmpty(exisingImports)) {
|
||||
return exports;
|
||||
}
|
||||
return filter(exports, e => !lookUp(exisingImports, e.name));
|
||||
return filter(exportsOfModule, e => !lookUp(exisingImportsOrExports, e.name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters out completion suggestions for named imports or exports.
|
||||
*
|
||||
* @returns Symbols to be suggested in an object binding pattern or object literal expression, barring those whose declarations
|
||||
* do not occur at the current position and have not otherwise been typed.
|
||||
*/
|
||||
function filterObjectMembersList(contextualMemberSymbols: Symbol[], existingMembers: Declaration[]): Symbol[] {
|
||||
if (!existingMembers || existingMembers.length === 0) {
|
||||
return contextualMemberSymbols;
|
||||
@@ -3511,32 +3569,32 @@ namespace ts {
|
||||
existingMemberNames[existingName] = true;
|
||||
}
|
||||
|
||||
let filteredMembers: Symbol[] = [];
|
||||
forEach(contextualMemberSymbols, s => {
|
||||
if (!existingMemberNames[s.name]) {
|
||||
filteredMembers.push(s);
|
||||
return filter(contextualMemberSymbols, m => !lookUp(existingMemberNames, m.name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters out completion suggestions from 'symbols' according to existing JSX attributes.
|
||||
*
|
||||
* @returns Symbols to be suggested in a JSX element, barring those whose attributes
|
||||
* do not occur at the current position and have not otherwise been typed.
|
||||
*/
|
||||
function filterJsxAttributes(symbols: Symbol[], attributes: NodeArray<JsxAttribute | JsxSpreadAttribute>): Symbol[] {
|
||||
let seenNames: Map<boolean> = {};
|
||||
for (let attr of attributes) {
|
||||
// If this is the current item we are editing right now, do not filter it out
|
||||
if (attr.getStart() <= position && position <= attr.getEnd()) {
|
||||
continue;
|
||||
}
|
||||
});
|
||||
|
||||
return filteredMembers;
|
||||
if (attr.kind === SyntaxKind.JsxAttribute) {
|
||||
seenNames[(<JsxAttribute>attr).name.text] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return filter(symbols, a => !lookUp(seenNames, a.name));
|
||||
}
|
||||
}
|
||||
|
||||
function filterJsxAttributes(attributes: NodeArray<JsxAttribute|JsxSpreadAttribute>, symbols: Symbol[]): Symbol[] {
|
||||
let seenNames: Map<boolean> = {};
|
||||
for(let attr of attributes) {
|
||||
if(attr.kind === SyntaxKind.JsxAttribute) {
|
||||
seenNames[(<JsxAttribute>attr).name.text] = true;
|
||||
}
|
||||
}
|
||||
let result: Symbol[] = [];
|
||||
for(let sym of symbols) {
|
||||
if(!seenNames[sym.name]) {
|
||||
result.push(sym);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function getCompletionsAtPosition(fileName: string, position: number): CompletionInfo {
|
||||
synchronizeHostData();
|
||||
@@ -3599,7 +3657,7 @@ namespace ts {
|
||||
// Try to get a valid display name for this symbol, if we could not find one, then ignore it.
|
||||
// We would like to only show things that can be added after a dot, so for instance numeric properties can
|
||||
// not be accessed with a dot (a.1 <- invalid)
|
||||
let displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, /*performCharacterChecks:*/ true);
|
||||
let displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, /*performCharacterChecks:*/ true, location);
|
||||
if (!displayName) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -3656,7 +3714,7 @@ namespace ts {
|
||||
// We don't need to perform character checks here because we're only comparing the
|
||||
// name against 'entryName' (which is known to be good), not building a new
|
||||
// completion entry.
|
||||
let symbol = forEach(symbols, s => getCompletionEntryDisplayNameForSymbol(s, target, /*performCharacterChecks:*/ false) === entryName ? s : undefined);
|
||||
let symbol = forEach(symbols, s => getCompletionEntryDisplayNameForSymbol(s, target, /*performCharacterChecks:*/ false, location) === entryName ? s : undefined);
|
||||
|
||||
if (symbol) {
|
||||
let { displayParts, documentation, symbolKind } = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location, location, SemanticMeaning.All);
|
||||
@@ -3689,7 +3747,8 @@ namespace ts {
|
||||
function getSymbolKind(symbol: Symbol, location: Node): string {
|
||||
let flags = symbol.getFlags();
|
||||
|
||||
if (flags & SymbolFlags.Class) return ScriptElementKind.classElement;
|
||||
if (flags & SymbolFlags.Class) return getDeclarationOfKind(symbol, SyntaxKind.ClassExpression) ?
|
||||
ScriptElementKind.localClassElement : ScriptElementKind.classElement;
|
||||
if (flags & SymbolFlags.Enum) return ScriptElementKind.enumElement;
|
||||
if (flags & SymbolFlags.TypeAlias) return ScriptElementKind.typeElement;
|
||||
if (flags & SymbolFlags.Interface) return ScriptElementKind.interfaceElement;
|
||||
@@ -3857,7 +3916,7 @@ namespace ts {
|
||||
displayParts.push(spacePart());
|
||||
}
|
||||
if (!(type.flags & TypeFlags.Anonymous)) {
|
||||
displayParts.push.apply(displayParts, symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments));
|
||||
addRange(displayParts, symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments));
|
||||
}
|
||||
addSignatureDisplayParts(signature, allSignatures, TypeFormatFlags.WriteArrowStyleSignature);
|
||||
break;
|
||||
@@ -3898,7 +3957,16 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
if (symbolFlags & SymbolFlags.Class && !hasAddedSymbolInfo) {
|
||||
displayParts.push(keywordPart(SyntaxKind.ClassKeyword));
|
||||
if (getDeclarationOfKind(symbol, SyntaxKind.ClassExpression)) {
|
||||
// Special case for class expressions because we would like to indicate that
|
||||
// the class name is local to the class body (similar to function expression)
|
||||
// (local class) class <className>
|
||||
pushTypePart(ScriptElementKind.localClassElement);
|
||||
}
|
||||
else {
|
||||
// Class declaration has name which is not local.
|
||||
displayParts.push(keywordPart(SyntaxKind.ClassKeyword));
|
||||
}
|
||||
displayParts.push(spacePart());
|
||||
addFullSymbolName(symbol);
|
||||
writeTypeParametersOfSymbol(symbol, sourceFile);
|
||||
@@ -3918,7 +3986,7 @@ namespace ts {
|
||||
displayParts.push(spacePart());
|
||||
displayParts.push(operatorPart(SyntaxKind.EqualsToken));
|
||||
displayParts.push(spacePart());
|
||||
displayParts.push.apply(displayParts, typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration));
|
||||
addRange(displayParts, typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration));
|
||||
}
|
||||
if (symbolFlags & SymbolFlags.Enum) {
|
||||
addNewLineIfDisplayPartsExist();
|
||||
@@ -3964,7 +4032,7 @@ namespace ts {
|
||||
else if (signatureDeclaration.kind !== SyntaxKind.CallSignature && signatureDeclaration.name) {
|
||||
addFullSymbolName(signatureDeclaration.symbol);
|
||||
}
|
||||
displayParts.push.apply(displayParts, signatureToDisplayParts(typeChecker, signature, sourceFile, TypeFormatFlags.WriteTypeArgumentsOfSignature));
|
||||
addRange(displayParts, signatureToDisplayParts(typeChecker, signature, sourceFile, TypeFormatFlags.WriteTypeArgumentsOfSignature));
|
||||
}
|
||||
}
|
||||
if (symbolFlags & SymbolFlags.EnumMember) {
|
||||
@@ -4025,10 +4093,10 @@ namespace ts {
|
||||
let typeParameterParts = mapToDisplayParts(writer => {
|
||||
typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(<TypeParameter>type, writer, enclosingDeclaration);
|
||||
});
|
||||
displayParts.push.apply(displayParts, typeParameterParts);
|
||||
addRange(displayParts, typeParameterParts);
|
||||
}
|
||||
else {
|
||||
displayParts.push.apply(displayParts, typeToDisplayParts(typeChecker, type, enclosingDeclaration));
|
||||
addRange(displayParts, typeToDisplayParts(typeChecker, type, enclosingDeclaration));
|
||||
}
|
||||
}
|
||||
else if (symbolFlags & SymbolFlags.Function ||
|
||||
@@ -4062,7 +4130,7 @@ namespace ts {
|
||||
function addFullSymbolName(symbol: Symbol, enclosingDeclaration?: Node) {
|
||||
let fullSymbolDisplayParts = symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, /*meaning*/ undefined,
|
||||
SymbolFormatFlags.WriteTypeParametersOrArguments | SymbolFormatFlags.UseOnlyExternalAliasing);
|
||||
displayParts.push.apply(displayParts, fullSymbolDisplayParts);
|
||||
addRange(displayParts, fullSymbolDisplayParts);
|
||||
}
|
||||
|
||||
function addPrefixForAnyFunctionOrVar(symbol: Symbol, symbolKind: string) {
|
||||
@@ -4092,7 +4160,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function addSignatureDisplayParts(signature: Signature, allSignatures: Signature[], flags?: TypeFormatFlags) {
|
||||
displayParts.push.apply(displayParts, signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | TypeFormatFlags.WriteTypeArgumentsOfSignature));
|
||||
addRange(displayParts, signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | TypeFormatFlags.WriteTypeArgumentsOfSignature));
|
||||
if (allSignatures.length > 1) {
|
||||
displayParts.push(spacePart());
|
||||
displayParts.push(punctuationPart(SyntaxKind.OpenParenToken));
|
||||
@@ -4109,7 +4177,7 @@ namespace ts {
|
||||
let typeParameterParts = mapToDisplayParts(writer => {
|
||||
typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration);
|
||||
});
|
||||
displayParts.push.apply(displayParts, typeParameterParts);
|
||||
addRange(displayParts, typeParameterParts);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4527,6 +4595,7 @@ namespace ts {
|
||||
if (hasKind(node.parent, SyntaxKind.GetAccessor) || hasKind(node.parent, SyntaxKind.SetAccessor)) {
|
||||
return getGetAndSetOccurrences(<AccessorDeclaration>node.parent);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (isModifier(node.kind) && node.parent &&
|
||||
(isDeclaration(node.parent) || node.parent.kind === SyntaxKind.VariableStatement)) {
|
||||
@@ -4662,12 +4731,13 @@ namespace ts {
|
||||
// Make sure we only highlight the keyword when it makes sense to do so.
|
||||
if (isAccessibilityModifier(modifier)) {
|
||||
if (!(container.kind === SyntaxKind.ClassDeclaration ||
|
||||
container.kind === SyntaxKind.ClassExpression ||
|
||||
(declaration.kind === SyntaxKind.Parameter && hasKind(container, SyntaxKind.Constructor)))) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
else if (modifier === SyntaxKind.StaticKeyword) {
|
||||
if (container.kind !== SyntaxKind.ClassDeclaration) {
|
||||
if (!(container.kind === SyntaxKind.ClassDeclaration || container.kind === SyntaxKind.ClassExpression)) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
@@ -4676,6 +4746,11 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
else if (modifier === SyntaxKind.AbstractKeyword) {
|
||||
if (!(container.kind === SyntaxKind.ClassDeclaration || declaration.kind === SyntaxKind.ClassDeclaration)) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// unsupported modifier
|
||||
return undefined;
|
||||
@@ -4688,19 +4763,26 @@ namespace ts {
|
||||
switch (container.kind) {
|
||||
case SyntaxKind.ModuleBlock:
|
||||
case SyntaxKind.SourceFile:
|
||||
nodes = (<Block>container).statements;
|
||||
// Container is either a class declaration or the declaration is a classDeclaration
|
||||
if (modifierFlag & NodeFlags.Abstract) {
|
||||
nodes = (<Node[]>(<ClassDeclaration>declaration).members).concat(declaration);
|
||||
}
|
||||
else {
|
||||
nodes = (<Block>container).statements;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.Constructor:
|
||||
nodes = (<Node[]>(<ConstructorDeclaration>container).parameters).concat(
|
||||
(<ClassDeclaration>container.parent).members);
|
||||
break;
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
nodes = (<ClassDeclaration>container).members;
|
||||
case SyntaxKind.ClassExpression:
|
||||
nodes = (<ClassLikeDeclaration>container).members;
|
||||
|
||||
// If we're an accessibility modifier, we're in an instance member and should search
|
||||
// the constructor's parameter list for instance members as well.
|
||||
if (modifierFlag & NodeFlags.AccessibilityModifier) {
|
||||
let constructor = forEach((<ClassDeclaration>container).members, member => {
|
||||
let constructor = forEach((<ClassLikeDeclaration>container).members, member => {
|
||||
return member.kind === SyntaxKind.Constructor && <ConstructorDeclaration>member;
|
||||
});
|
||||
|
||||
@@ -4708,6 +4790,9 @@ namespace ts {
|
||||
nodes = nodes.concat(constructor.parameters);
|
||||
}
|
||||
}
|
||||
else if (modifierFlag & NodeFlags.Abstract) {
|
||||
nodes = nodes.concat(container);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Debug.fail("Invalid container kind.")
|
||||
@@ -4735,6 +4820,8 @@ namespace ts {
|
||||
return NodeFlags.Export;
|
||||
case SyntaxKind.DeclareKeyword:
|
||||
return NodeFlags.Ambient;
|
||||
case SyntaxKind.AbstractKeyword:
|
||||
return NodeFlags.Abstract;
|
||||
default:
|
||||
Debug.fail();
|
||||
}
|
||||
@@ -5104,7 +5191,7 @@ namespace ts {
|
||||
|
||||
// Get the text to search for.
|
||||
// Note: if this is an external module symbol, the name doesn't include quotes.
|
||||
let declaredName = getDeclaredName(typeChecker, symbol, node);
|
||||
let declaredName = stripQuotes(getDeclaredName(typeChecker, symbol, node));
|
||||
|
||||
// Try to get the smallest valid scope that we can limit our search to;
|
||||
// otherwise we'll need to search globally (i.e. include each file).
|
||||
@@ -5181,10 +5268,10 @@ namespace ts {
|
||||
* a reference to a symbol can occur anywhere.
|
||||
*/
|
||||
function getSymbolScope(symbol: Symbol): Node {
|
||||
// If this is the symbol of a function expression, then named references
|
||||
// are limited to its own scope.
|
||||
// If this is the symbol of a named function expression or named class expression,
|
||||
// then named references are limited to its own scope.
|
||||
let valueDeclaration = symbol.valueDeclaration;
|
||||
if (valueDeclaration && valueDeclaration.kind === SyntaxKind.FunctionExpression) {
|
||||
if (valueDeclaration && (valueDeclaration.kind === SyntaxKind.FunctionExpression || valueDeclaration.kind === SyntaxKind.ClassExpression)) {
|
||||
return valueDeclaration;
|
||||
}
|
||||
|
||||
@@ -5623,7 +5710,7 @@ namespace ts {
|
||||
// type to the search set
|
||||
if (isNameOfPropertyAssignment(location)) {
|
||||
forEach(getPropertySymbolsFromContextualType(location), contextualSymbol => {
|
||||
result.push.apply(result, typeChecker.getRootSymbols(contextualSymbol));
|
||||
addRange(result, typeChecker.getRootSymbols(contextualSymbol));
|
||||
});
|
||||
|
||||
/* Because in short-hand property assignment, location has two meaning : property name and as value of the property
|
||||
@@ -6555,7 +6642,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
return ClassificationType.text;
|
||||
return ClassificationType.identifier;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6855,7 +6942,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
let displayName = getDeclaredName(typeChecker, symbol, node);
|
||||
let displayName = stripQuotes(getDeclaredName(typeChecker, symbol, node));
|
||||
let kind = getSymbolKind(symbol, node);
|
||||
if (kind) {
|
||||
return {
|
||||
|
||||
+30
-4
@@ -34,6 +34,9 @@ namespace ts {
|
||||
* Or undefined value if there was no change.
|
||||
*/
|
||||
getChangeRange(oldSnapshot: ScriptSnapshotShim): string;
|
||||
|
||||
/** Releases all resources held by this script snapshot */
|
||||
dispose?(): void;
|
||||
}
|
||||
|
||||
export interface Logger {
|
||||
@@ -61,8 +64,13 @@ namespace ts {
|
||||
|
||||
/** Public interface of the the of a config service shim instance.*/
|
||||
export interface CoreServicesShimHost extends Logger {
|
||||
/** Returns a JSON-encoded value of the type: string[] */
|
||||
readDirectory(rootDir: string, extension: string): string;
|
||||
/**
|
||||
* Returns a JSON-encoded value of the type: string[]
|
||||
*
|
||||
* @param exclude A JSON encoded string[] containing the paths to exclude
|
||||
* when enumerating the directory.
|
||||
*/
|
||||
readDirectory(rootDir: string, extension: string, exclude?: string): string;
|
||||
}
|
||||
|
||||
///
|
||||
@@ -243,6 +251,14 @@ namespace ts {
|
||||
return createTextChangeRange(
|
||||
createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength);
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
// if scriptSnapshotShim is a COM object then property check becomes method call with no arguments
|
||||
// 'in' does not have this effect
|
||||
if ("dispose" in this.scriptSnapshotShim) {
|
||||
this.scriptSnapshotShim.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class LanguageServiceShimHostAdapter implements LanguageServiceHost {
|
||||
@@ -375,8 +391,18 @@ namespace ts {
|
||||
constructor(private shimHost: CoreServicesShimHost) {
|
||||
}
|
||||
|
||||
public readDirectory(rootDir: string, extension: string): string[] {
|
||||
var encoded = this.shimHost.readDirectory(rootDir, extension);
|
||||
public readDirectory(rootDir: string, extension: string, exclude: string[]): string[] {
|
||||
// Wrap the API changes for 1.5 release. This try/catch
|
||||
// should be removed once TypeScript 1.5 has shipped.
|
||||
// Also consider removing the optional designation for
|
||||
// the exclude param at this time.
|
||||
var encoded: string;
|
||||
try {
|
||||
encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude));
|
||||
}
|
||||
catch (e) {
|
||||
encoded = this.shimHost.readDirectory(rootDir, extension);
|
||||
}
|
||||
return JSON.parse(encoded);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -550,7 +550,7 @@ namespace ts.SignatureHelp {
|
||||
let suffixDisplayParts: SymbolDisplayPart[] = [];
|
||||
|
||||
if (callTargetDisplayParts) {
|
||||
prefixDisplayParts.push.apply(prefixDisplayParts, callTargetDisplayParts);
|
||||
addRange(prefixDisplayParts, callTargetDisplayParts);
|
||||
}
|
||||
|
||||
if (isTypeParameterList) {
|
||||
@@ -560,12 +560,12 @@ namespace ts.SignatureHelp {
|
||||
suffixDisplayParts.push(punctuationPart(SyntaxKind.GreaterThanToken));
|
||||
let parameterParts = mapToDisplayParts(writer =>
|
||||
typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation));
|
||||
suffixDisplayParts.push.apply(suffixDisplayParts, parameterParts);
|
||||
addRange(suffixDisplayParts, parameterParts);
|
||||
}
|
||||
else {
|
||||
let typeParameterParts = mapToDisplayParts(writer =>
|
||||
typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation));
|
||||
prefixDisplayParts.push.apply(prefixDisplayParts, typeParameterParts);
|
||||
addRange(prefixDisplayParts, typeParameterParts);
|
||||
prefixDisplayParts.push(punctuationPart(SyntaxKind.OpenParenToken));
|
||||
|
||||
let parameters = candidateSignature.parameters;
|
||||
@@ -575,7 +575,7 @@ namespace ts.SignatureHelp {
|
||||
|
||||
let returnTypeParts = mapToDisplayParts(writer =>
|
||||
typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation));
|
||||
suffixDisplayParts.push.apply(suffixDisplayParts, returnTypeParts);
|
||||
addRange(suffixDisplayParts, returnTypeParts);
|
||||
|
||||
return {
|
||||
isVariadic: candidateSignature.hasRestParameter,
|
||||
|
||||
@@ -667,7 +667,7 @@ namespace ts {
|
||||
|
||||
let name = typeChecker.symbolToString(localExportDefaultSymbol || symbol);
|
||||
|
||||
return stripQuotes(name);
|
||||
return name;
|
||||
}
|
||||
|
||||
export function isImportOrExportSpecifierName(location: Node): boolean {
|
||||
@@ -676,9 +676,16 @@ namespace ts {
|
||||
(<ImportOrExportSpecifier>location.parent).propertyName === location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip off existed single quotes or double quotes from a given string
|
||||
*
|
||||
* @return non-quoted string
|
||||
*/
|
||||
export function stripQuotes(name: string) {
|
||||
let length = name.length;
|
||||
if (length >= 2 && name.charCodeAt(0) === CharacterCodes.doubleQuote && name.charCodeAt(length - 1) === CharacterCodes.doubleQuote) {
|
||||
if (length >= 2 &&
|
||||
name.charCodeAt(0) === name.charCodeAt(length - 1) &&
|
||||
(name.charCodeAt(0) === CharacterCodes.doubleQuote || name.charCodeAt(0) === CharacterCodes.singleQuote)) {
|
||||
return name.substring(1, length - 1);
|
||||
};
|
||||
return name;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(13,12): error TS2493: Tuple type '[string, number]' with length '2' cannot be assigned to tuple with length '3'.
|
||||
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(14,12): error TS2460: Type 'StrNum' has no property '2'.
|
||||
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(15,5): error TS2461: Type '{ 0: string; 1: number; }' is not an array type.
|
||||
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(15,12): error TS2460: Type '{ 0: string; 1: number; }' has no property '2'.
|
||||
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(16,5): error TS2322: Type '[string, number]' is not assignable to type '[number, number, number]'.
|
||||
Types of property '0' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
@@ -46,7 +47,7 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(30,5): error
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts (18 errors) ====
|
||||
==== tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts (19 errors) ====
|
||||
interface StrNum extends Array<string|number> {
|
||||
0: string;
|
||||
1: number;
|
||||
@@ -68,6 +69,8 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(30,5): error
|
||||
var [g, h, i] = z;
|
||||
~~~~~~~~~
|
||||
!!! error TS2461: Type '{ 0: string; 1: number; }' is not an array type.
|
||||
~
|
||||
!!! error TS2460: Type '{ 0: string; 1: number; }' has no property '2'.
|
||||
var j1: [number, number, number] = x;
|
||||
~~
|
||||
!!! error TS2322: Type '[string, number]' is not assignable to type '[number, number, number]'.
|
||||
|
||||
@@ -70,6 +70,7 @@ var p6 = ({ a }) => { };
|
||||
|
||||
var p7 = ({ a: { b } }) => { };
|
||||
>p7 : Symbol(p7, Decl(arrowFunctionExpressions.ts, 21, 3))
|
||||
>a : Symbol(a)
|
||||
>b : Symbol(b, Decl(arrowFunctionExpressions.ts, 21, 16))
|
||||
|
||||
var p8 = ({ a = 1 }) => { };
|
||||
@@ -78,6 +79,7 @@ var p8 = ({ a = 1 }) => { };
|
||||
|
||||
var p9 = ({ a: { b = 1 } = { b: 1 } }) => { };
|
||||
>p9 : Symbol(p9, Decl(arrowFunctionExpressions.ts, 23, 3))
|
||||
>a : Symbol(a)
|
||||
>b : Symbol(b, Decl(arrowFunctionExpressions.ts, 23, 16))
|
||||
>b : Symbol(b, Decl(arrowFunctionExpressions.ts, 23, 28))
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractClinterfaceAssignability.ts(23,1): error TS2322: Type 'typeof A' is not assignable to type 'IConstructor'.
|
||||
Cannot assign an abstract constructor type to a non-abstract constructor type.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractClinterfaceAssignability.ts (1 errors) ====
|
||||
interface I {
|
||||
x: number;
|
||||
}
|
||||
|
||||
interface IConstructor {
|
||||
new (): I;
|
||||
|
||||
y: number;
|
||||
prototype: I;
|
||||
}
|
||||
|
||||
var I: IConstructor;
|
||||
|
||||
abstract class A {
|
||||
x: number;
|
||||
static y: number;
|
||||
}
|
||||
|
||||
var AA: typeof A;
|
||||
AA = I;
|
||||
|
||||
var AAA: typeof I;
|
||||
AAA = A;
|
||||
~~~
|
||||
!!! error TS2322: Type 'typeof A' is not assignable to type 'IConstructor'.
|
||||
!!! error TS2322: Cannot assign an abstract constructor type to a non-abstract constructor type.
|
||||
@@ -0,0 +1,36 @@
|
||||
//// [classAbstractClinterfaceAssignability.ts]
|
||||
interface I {
|
||||
x: number;
|
||||
}
|
||||
|
||||
interface IConstructor {
|
||||
new (): I;
|
||||
|
||||
y: number;
|
||||
prototype: I;
|
||||
}
|
||||
|
||||
var I: IConstructor;
|
||||
|
||||
abstract class A {
|
||||
x: number;
|
||||
static y: number;
|
||||
}
|
||||
|
||||
var AA: typeof A;
|
||||
AA = I;
|
||||
|
||||
var AAA: typeof I;
|
||||
AAA = A;
|
||||
|
||||
//// [classAbstractClinterfaceAssignability.js]
|
||||
var I;
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
return A;
|
||||
})();
|
||||
var AA;
|
||||
AA = I;
|
||||
var AAA;
|
||||
AAA = A;
|
||||
@@ -0,0 +1,30 @@
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructorAssignability.ts(8,5): error TS2322: Type 'typeof B' is not assignable to type 'typeof A'.
|
||||
Cannot assign an abstract constructor type to a non-abstract constructor type.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructorAssignability.ts(10,5): error TS2322: Type 'typeof B' is not assignable to type 'typeof C'.
|
||||
Cannot assign an abstract constructor type to a non-abstract constructor type.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructorAssignability.ts(13,1): error TS2511: Cannot create an instance of the abstract class 'B'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructorAssignability.ts (3 errors) ====
|
||||
|
||||
class A {}
|
||||
|
||||
abstract class B extends A {}
|
||||
|
||||
class C extends B {}
|
||||
|
||||
var AA : typeof A = B;
|
||||
~~
|
||||
!!! error TS2322: Type 'typeof B' is not assignable to type 'typeof A'.
|
||||
!!! error TS2322: Cannot assign an abstract constructor type to a non-abstract constructor type.
|
||||
var BB : typeof B = A;
|
||||
var CC : typeof C = B;
|
||||
~~
|
||||
!!! error TS2322: Type 'typeof B' is not assignable to type 'typeof C'.
|
||||
!!! error TS2322: Cannot assign an abstract constructor type to a non-abstract constructor type.
|
||||
|
||||
new AA;
|
||||
new BB;
|
||||
~~~~~~
|
||||
!!! error TS2511: Cannot create an instance of the abstract class 'B'.
|
||||
new CC;
|
||||
@@ -0,0 +1,47 @@
|
||||
//// [classAbstractConstructorAssignability.ts]
|
||||
|
||||
class A {}
|
||||
|
||||
abstract class B extends A {}
|
||||
|
||||
class C extends B {}
|
||||
|
||||
var AA : typeof A = B;
|
||||
var BB : typeof B = A;
|
||||
var CC : typeof C = B;
|
||||
|
||||
new AA;
|
||||
new BB;
|
||||
new CC;
|
||||
|
||||
//// [classAbstractConstructorAssignability.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
return A;
|
||||
})();
|
||||
var B = (function (_super) {
|
||||
__extends(B, _super);
|
||||
function B() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return B;
|
||||
})(A);
|
||||
var C = (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return C;
|
||||
})(B);
|
||||
var AA = B;
|
||||
var BB = A;
|
||||
var CC = B;
|
||||
new AA;
|
||||
new BB;
|
||||
new CC;
|
||||
@@ -0,0 +1,22 @@
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractExtends.ts(10,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'B'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractExtends.ts (1 errors) ====
|
||||
|
||||
class A {
|
||||
foo() {}
|
||||
}
|
||||
|
||||
abstract class B extends A {
|
||||
abstract bar();
|
||||
}
|
||||
|
||||
class C extends B { }
|
||||
~
|
||||
!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'B'.
|
||||
|
||||
abstract class D extends B {}
|
||||
|
||||
class E extends B {
|
||||
bar() {}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
//// [classAbstractExtends.ts]
|
||||
|
||||
class A {
|
||||
foo() {}
|
||||
}
|
||||
|
||||
abstract class B extends A {
|
||||
abstract bar();
|
||||
}
|
||||
|
||||
class C extends B { }
|
||||
|
||||
abstract class D extends B {}
|
||||
|
||||
class E extends B {
|
||||
bar() {}
|
||||
}
|
||||
|
||||
//// [classAbstractExtends.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
A.prototype.foo = function () { };
|
||||
return A;
|
||||
})();
|
||||
var B = (function (_super) {
|
||||
__extends(B, _super);
|
||||
function B() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return B;
|
||||
})(A);
|
||||
var C = (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return C;
|
||||
})(B);
|
||||
var D = (function (_super) {
|
||||
__extends(D, _super);
|
||||
function D() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return D;
|
||||
})(B);
|
||||
var E = (function (_super) {
|
||||
__extends(E, _super);
|
||||
function E() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
E.prototype.bar = function () { };
|
||||
return E;
|
||||
})(B);
|
||||
@@ -0,0 +1,28 @@
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractFactoryFunction.ts(10,12): error TS2511: Cannot create an instance of the abstract class 'B'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractFactoryFunction.ts(14,6): error TS2345: Argument of type 'typeof B' is not assignable to parameter of type 'typeof A'.
|
||||
Cannot assign an abstract constructor type to a non-abstract constructor type.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractFactoryFunction.ts (2 errors) ====
|
||||
|
||||
class A {}
|
||||
abstract class B extends A {}
|
||||
|
||||
function NewA(Factory: typeof A) {
|
||||
return new A;
|
||||
}
|
||||
|
||||
function NewB(Factory: typeof B) {
|
||||
return new B;
|
||||
~~~~~
|
||||
!!! error TS2511: Cannot create an instance of the abstract class 'B'.
|
||||
}
|
||||
|
||||
NewA(A);
|
||||
NewA(B);
|
||||
~
|
||||
!!! error TS2345: Argument of type 'typeof B' is not assignable to parameter of type 'typeof A'.
|
||||
!!! error TS2345: Cannot assign an abstract constructor type to a non-abstract constructor type.
|
||||
|
||||
NewB(A);
|
||||
NewB(B);
|
||||
@@ -0,0 +1,47 @@
|
||||
//// [classAbstractFactoryFunction.ts]
|
||||
|
||||
class A {}
|
||||
abstract class B extends A {}
|
||||
|
||||
function NewA(Factory: typeof A) {
|
||||
return new A;
|
||||
}
|
||||
|
||||
function NewB(Factory: typeof B) {
|
||||
return new B;
|
||||
}
|
||||
|
||||
NewA(A);
|
||||
NewA(B);
|
||||
|
||||
NewB(A);
|
||||
NewB(B);
|
||||
|
||||
//// [classAbstractFactoryFunction.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
return A;
|
||||
})();
|
||||
var B = (function (_super) {
|
||||
__extends(B, _super);
|
||||
function B() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return B;
|
||||
})(A);
|
||||
function NewA(Factory) {
|
||||
return new A;
|
||||
}
|
||||
function NewB(Factory) {
|
||||
return new B;
|
||||
}
|
||||
NewA(A);
|
||||
NewA(B);
|
||||
NewB(A);
|
||||
NewB(B);
|
||||
@@ -1,10 +1,14 @@
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(8,1): error TS2511: Cannot create an instance of the abstract class 'A'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(9,1): error TS2511: Cannot create an instance of the abstract class 'A'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(11,1): error TS2511: Cannot create an instance of the abstract class 'C'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(12,1): error TS2511: Cannot create an instance of the abstract class 'A'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(13,1): error TS2511: Cannot create an instance of the abstract class 'A'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(15,1): error TS2511: Cannot create an instance of the abstract class 'C'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts (3 errors) ====
|
||||
|
||||
//
|
||||
// Calling new with (non)abstract classes.
|
||||
//
|
||||
|
||||
abstract class A {}
|
||||
|
||||
class B extends A {}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
//// [classAbstractInstantiations1.ts]
|
||||
|
||||
//
|
||||
// Calling new with (non)abstract classes.
|
||||
//
|
||||
|
||||
abstract class A {}
|
||||
|
||||
class B extends A {}
|
||||
@@ -21,6 +25,9 @@ c = new B;
|
||||
|
||||
|
||||
//// [classAbstractInstantiations1.js]
|
||||
//
|
||||
// Calling new with (non)abstract classes.
|
||||
//
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(10,1): error TS2511: Cannot create an instance of the abstract class 'B'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(13,5): error TS2322: Type 'typeof B' is not assignable to type 'typeof A'.
|
||||
Cannot assign an abstract constructor type to a non-abstract constructor type.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(17,5): error TS2511: Cannot create an instance of the abstract class 'B'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(21,1): error TS2511: Cannot create an instance of the abstract class 'B'.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(26,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'B'.
|
||||
@@ -7,7 +9,7 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(50,5): error TS1244: Abstract methods can only appear within an abstract class.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts (7 errors) ====
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts (8 errors) ====
|
||||
class A {
|
||||
// ...
|
||||
}
|
||||
@@ -23,6 +25,9 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst
|
||||
|
||||
var BB: typeof B = B;
|
||||
var AA: typeof A = BB; // error, AA is not of abstract type.
|
||||
~~
|
||||
!!! error TS2322: Type 'typeof B' is not assignable to type 'typeof A'.
|
||||
!!! error TS2322: Cannot assign an abstract constructor type to a non-abstract constructor type.
|
||||
new AA;
|
||||
|
||||
function constructB(Factory : typeof B) {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts(2,5): error TS1244: Abstract methods can only appear within an abstract class.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts(6,5): error TS1244: Abstract methods can only appear within an abstract class.
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts(6,5): error TS1245: Method 'foo' cannot have an implementation because it is marked abstract.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts (3 errors) ====
|
||||
class A {
|
||||
abstract foo();
|
||||
~~~~~~~~
|
||||
!!! error TS1244: Abstract methods can only appear within an abstract class.
|
||||
}
|
||||
|
||||
class B {
|
||||
abstract foo() {}
|
||||
~~~~~~~~
|
||||
!!! error TS1244: Abstract methods can only appear within an abstract class.
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1245: Method 'foo' cannot have an implementation because it is marked abstract.
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
//// [classAbstractMethodInNonAbstractClass.ts]
|
||||
class A {
|
||||
abstract foo();
|
||||
}
|
||||
|
||||
class B {
|
||||
abstract foo() {}
|
||||
}
|
||||
|
||||
//// [classAbstractMethodInNonAbstractClass.js]
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
return A;
|
||||
})();
|
||||
var B = (function () {
|
||||
function B() {
|
||||
}
|
||||
B.prototype.foo = function () { };
|
||||
return B;
|
||||
})();
|
||||
@@ -0,0 +1,29 @@
|
||||
tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverrideWithAbstract.ts(19,7): error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'foo' from class 'BB'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverrideWithAbstract.ts (1 errors) ====
|
||||
class A {
|
||||
foo() {}
|
||||
}
|
||||
|
||||
abstract class B extends A {
|
||||
abstract foo();
|
||||
}
|
||||
|
||||
abstract class AA {
|
||||
foo() {}
|
||||
abstract bar();
|
||||
}
|
||||
|
||||
abstract class BB extends AA {
|
||||
abstract foo();
|
||||
bar () {}
|
||||
}
|
||||
|
||||
class CC extends BB {} // error
|
||||
~~
|
||||
!!! error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'foo' from class 'BB'.
|
||||
|
||||
class DD extends BB {
|
||||
foo() {}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
//// [classAbstractOverrideWithAbstract.ts]
|
||||
class A {
|
||||
foo() {}
|
||||
}
|
||||
|
||||
abstract class B extends A {
|
||||
abstract foo();
|
||||
}
|
||||
|
||||
abstract class AA {
|
||||
foo() {}
|
||||
abstract bar();
|
||||
}
|
||||
|
||||
abstract class BB extends AA {
|
||||
abstract foo();
|
||||
bar () {}
|
||||
}
|
||||
|
||||
class CC extends BB {} // error
|
||||
|
||||
class DD extends BB {
|
||||
foo() {}
|
||||
}
|
||||
|
||||
//// [classAbstractOverrideWithAbstract.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
A.prototype.foo = function () { };
|
||||
return A;
|
||||
})();
|
||||
var B = (function (_super) {
|
||||
__extends(B, _super);
|
||||
function B() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return B;
|
||||
})(A);
|
||||
var AA = (function () {
|
||||
function AA() {
|
||||
}
|
||||
AA.prototype.foo = function () { };
|
||||
return AA;
|
||||
})();
|
||||
var BB = (function (_super) {
|
||||
__extends(BB, _super);
|
||||
function BB() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
BB.prototype.bar = function () { };
|
||||
return BB;
|
||||
})(AA);
|
||||
var CC = (function (_super) {
|
||||
__extends(CC, _super);
|
||||
function CC() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return CC;
|
||||
})(BB); // error
|
||||
var DD = (function (_super) {
|
||||
__extends(DD, _super);
|
||||
function DD() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
DD.prototype.foo = function () { };
|
||||
return DD;
|
||||
})(BB);
|
||||
@@ -26,6 +26,19 @@ export function fooWithSingleOverload(a: any) {
|
||||
return a;
|
||||
}
|
||||
|
||||
export function fooWithTypePredicate(a: any): a is number {
|
||||
return true;
|
||||
}
|
||||
export function fooWithTypePredicateAndMulitpleParams(a: any, b: any, c: any): a is number {
|
||||
return true;
|
||||
}
|
||||
export function fooWithTypeTypePredicateAndGeneric<T>(a: any): a is T {
|
||||
return true;
|
||||
}
|
||||
export function fooWithTypeTypePredicateAndRestParam(a: any, ...rest): a is number {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** This comment should appear for nonExportedFoo*/
|
||||
function nonExportedFoo() {
|
||||
}
|
||||
@@ -92,6 +105,26 @@ function fooWithSingleOverload(a) {
|
||||
return a;
|
||||
}
|
||||
exports.fooWithSingleOverload = fooWithSingleOverload;
|
||||
function fooWithTypePredicate(a) {
|
||||
return true;
|
||||
}
|
||||
exports.fooWithTypePredicate = fooWithTypePredicate;
|
||||
function fooWithTypePredicateAndMulitpleParams(a, b, c) {
|
||||
return true;
|
||||
}
|
||||
exports.fooWithTypePredicateAndMulitpleParams = fooWithTypePredicateAndMulitpleParams;
|
||||
function fooWithTypeTypePredicateAndGeneric(a) {
|
||||
return true;
|
||||
}
|
||||
exports.fooWithTypeTypePredicateAndGeneric = fooWithTypeTypePredicateAndGeneric;
|
||||
function fooWithTypeTypePredicateAndRestParam(a) {
|
||||
var rest = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
rest[_i - 1] = arguments[_i];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
exports.fooWithTypeTypePredicateAndRestParam = fooWithTypeTypePredicateAndRestParam;
|
||||
/** This comment should appear for nonExportedFoo*/
|
||||
function nonExportedFoo() {
|
||||
}
|
||||
@@ -144,6 +177,10 @@ export declare function fooWithRestParameters(a: string, ...rests: string[]): st
|
||||
export declare function fooWithOverloads(a: string): string;
|
||||
export declare function fooWithOverloads(a: number): number;
|
||||
export declare function fooWithSingleOverload(a: string): string;
|
||||
export declare function fooWithTypePredicate(a: any): a is number;
|
||||
export declare function fooWithTypePredicateAndMulitpleParams(a: any, b: any, c: any): a is number;
|
||||
export declare function fooWithTypeTypePredicateAndGeneric<T>(a: any): a is T;
|
||||
export declare function fooWithTypeTypePredicateAndRestParam(a: any, ...rest: any[]): a is number;
|
||||
//// [declFileFunctions_1.d.ts]
|
||||
/** This comment should appear for foo*/
|
||||
declare function globalfoo(): void;
|
||||
|
||||
@@ -57,49 +57,83 @@ export function fooWithSingleOverload(a: any) {
|
||||
>a : Symbol(a, Decl(declFileFunctions_0.ts, 21, 38))
|
||||
}
|
||||
|
||||
export function fooWithTypePredicate(a: any): a is number {
|
||||
>fooWithTypePredicate : Symbol(fooWithTypePredicate, Decl(declFileFunctions_0.ts, 23, 1))
|
||||
>a : Symbol(a, Decl(declFileFunctions_0.ts, 25, 37))
|
||||
>a : Symbol(a, Decl(declFileFunctions_0.ts, 25, 37))
|
||||
|
||||
return true;
|
||||
}
|
||||
export function fooWithTypePredicateAndMulitpleParams(a: any, b: any, c: any): a is number {
|
||||
>fooWithTypePredicateAndMulitpleParams : Symbol(fooWithTypePredicateAndMulitpleParams, Decl(declFileFunctions_0.ts, 27, 1))
|
||||
>a : Symbol(a, Decl(declFileFunctions_0.ts, 28, 54))
|
||||
>b : Symbol(b, Decl(declFileFunctions_0.ts, 28, 61))
|
||||
>c : Symbol(c, Decl(declFileFunctions_0.ts, 28, 69))
|
||||
>a : Symbol(a, Decl(declFileFunctions_0.ts, 28, 54))
|
||||
|
||||
return true;
|
||||
}
|
||||
export function fooWithTypeTypePredicateAndGeneric<T>(a: any): a is T {
|
||||
>fooWithTypeTypePredicateAndGeneric : Symbol(fooWithTypeTypePredicateAndGeneric, Decl(declFileFunctions_0.ts, 30, 1))
|
||||
>T : Symbol(T, Decl(declFileFunctions_0.ts, 31, 51))
|
||||
>a : Symbol(a, Decl(declFileFunctions_0.ts, 31, 54))
|
||||
>a : Symbol(a, Decl(declFileFunctions_0.ts, 31, 54))
|
||||
>T : Symbol(T, Decl(declFileFunctions_0.ts, 31, 51))
|
||||
|
||||
return true;
|
||||
}
|
||||
export function fooWithTypeTypePredicateAndRestParam(a: any, ...rest): a is number {
|
||||
>fooWithTypeTypePredicateAndRestParam : Symbol(fooWithTypeTypePredicateAndRestParam, Decl(declFileFunctions_0.ts, 33, 1))
|
||||
>a : Symbol(a, Decl(declFileFunctions_0.ts, 34, 53))
|
||||
>rest : Symbol(rest, Decl(declFileFunctions_0.ts, 34, 60))
|
||||
>a : Symbol(a, Decl(declFileFunctions_0.ts, 34, 53))
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** This comment should appear for nonExportedFoo*/
|
||||
function nonExportedFoo() {
|
||||
>nonExportedFoo : Symbol(nonExportedFoo, Decl(declFileFunctions_0.ts, 23, 1))
|
||||
>nonExportedFoo : Symbol(nonExportedFoo, Decl(declFileFunctions_0.ts, 36, 1))
|
||||
}
|
||||
/** This is comment for function signature*/
|
||||
function nonExportedFooWithParameters(/** this is comment about a*/a: string,
|
||||
>nonExportedFooWithParameters : Symbol(nonExportedFooWithParameters, Decl(declFileFunctions_0.ts, 27, 1))
|
||||
>a : Symbol(a, Decl(declFileFunctions_0.ts, 29, 38))
|
||||
>nonExportedFooWithParameters : Symbol(nonExportedFooWithParameters, Decl(declFileFunctions_0.ts, 40, 1))
|
||||
>a : Symbol(a, Decl(declFileFunctions_0.ts, 42, 38))
|
||||
|
||||
/** this is comment for b*/
|
||||
b: number) {
|
||||
>b : Symbol(b, Decl(declFileFunctions_0.ts, 29, 77))
|
||||
>b : Symbol(b, Decl(declFileFunctions_0.ts, 42, 77))
|
||||
|
||||
var d = a;
|
||||
>d : Symbol(d, Decl(declFileFunctions_0.ts, 32, 7))
|
||||
>a : Symbol(a, Decl(declFileFunctions_0.ts, 29, 38))
|
||||
>d : Symbol(d, Decl(declFileFunctions_0.ts, 45, 7))
|
||||
>a : Symbol(a, Decl(declFileFunctions_0.ts, 42, 38))
|
||||
}
|
||||
function nonExportedFooWithRestParameters(a: string, ...rests: string[]) {
|
||||
>nonExportedFooWithRestParameters : Symbol(nonExportedFooWithRestParameters, Decl(declFileFunctions_0.ts, 33, 1))
|
||||
>a : Symbol(a, Decl(declFileFunctions_0.ts, 34, 42))
|
||||
>rests : Symbol(rests, Decl(declFileFunctions_0.ts, 34, 52))
|
||||
>nonExportedFooWithRestParameters : Symbol(nonExportedFooWithRestParameters, Decl(declFileFunctions_0.ts, 46, 1))
|
||||
>a : Symbol(a, Decl(declFileFunctions_0.ts, 47, 42))
|
||||
>rests : Symbol(rests, Decl(declFileFunctions_0.ts, 47, 52))
|
||||
|
||||
return a + rests.join("");
|
||||
>a : Symbol(a, Decl(declFileFunctions_0.ts, 34, 42))
|
||||
>a : Symbol(a, Decl(declFileFunctions_0.ts, 47, 42))
|
||||
>rests.join : Symbol(Array.join, Decl(lib.d.ts, 1035, 31))
|
||||
>rests : Symbol(rests, Decl(declFileFunctions_0.ts, 34, 52))
|
||||
>rests : Symbol(rests, Decl(declFileFunctions_0.ts, 47, 52))
|
||||
>join : Symbol(Array.join, Decl(lib.d.ts, 1035, 31))
|
||||
}
|
||||
|
||||
function nonExportedFooWithOverloads(a: string): string;
|
||||
>nonExportedFooWithOverloads : Symbol(nonExportedFooWithOverloads, Decl(declFileFunctions_0.ts, 36, 1), Decl(declFileFunctions_0.ts, 38, 56), Decl(declFileFunctions_0.ts, 39, 56))
|
||||
>a : Symbol(a, Decl(declFileFunctions_0.ts, 38, 37))
|
||||
>nonExportedFooWithOverloads : Symbol(nonExportedFooWithOverloads, Decl(declFileFunctions_0.ts, 49, 1), Decl(declFileFunctions_0.ts, 51, 56), Decl(declFileFunctions_0.ts, 52, 56))
|
||||
>a : Symbol(a, Decl(declFileFunctions_0.ts, 51, 37))
|
||||
|
||||
function nonExportedFooWithOverloads(a: number): number;
|
||||
>nonExportedFooWithOverloads : Symbol(nonExportedFooWithOverloads, Decl(declFileFunctions_0.ts, 36, 1), Decl(declFileFunctions_0.ts, 38, 56), Decl(declFileFunctions_0.ts, 39, 56))
|
||||
>a : Symbol(a, Decl(declFileFunctions_0.ts, 39, 37))
|
||||
>nonExportedFooWithOverloads : Symbol(nonExportedFooWithOverloads, Decl(declFileFunctions_0.ts, 49, 1), Decl(declFileFunctions_0.ts, 51, 56), Decl(declFileFunctions_0.ts, 52, 56))
|
||||
>a : Symbol(a, Decl(declFileFunctions_0.ts, 52, 37))
|
||||
|
||||
function nonExportedFooWithOverloads(a: any): any {
|
||||
>nonExportedFooWithOverloads : Symbol(nonExportedFooWithOverloads, Decl(declFileFunctions_0.ts, 36, 1), Decl(declFileFunctions_0.ts, 38, 56), Decl(declFileFunctions_0.ts, 39, 56))
|
||||
>a : Symbol(a, Decl(declFileFunctions_0.ts, 40, 37))
|
||||
>nonExportedFooWithOverloads : Symbol(nonExportedFooWithOverloads, Decl(declFileFunctions_0.ts, 49, 1), Decl(declFileFunctions_0.ts, 51, 56), Decl(declFileFunctions_0.ts, 52, 56))
|
||||
>a : Symbol(a, Decl(declFileFunctions_0.ts, 53, 37))
|
||||
|
||||
return a;
|
||||
>a : Symbol(a, Decl(declFileFunctions_0.ts, 40, 37))
|
||||
>a : Symbol(a, Decl(declFileFunctions_0.ts, 53, 37))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/declFileFunctions_1.ts ===
|
||||
|
||||
@@ -60,6 +60,44 @@ export function fooWithSingleOverload(a: any) {
|
||||
>a : any
|
||||
}
|
||||
|
||||
export function fooWithTypePredicate(a: any): a is number {
|
||||
>fooWithTypePredicate : (a: any) => a is number
|
||||
>a : any
|
||||
>a : any
|
||||
|
||||
return true;
|
||||
>true : boolean
|
||||
}
|
||||
export function fooWithTypePredicateAndMulitpleParams(a: any, b: any, c: any): a is number {
|
||||
>fooWithTypePredicateAndMulitpleParams : (a: any, b: any, c: any) => a is number
|
||||
>a : any
|
||||
>b : any
|
||||
>c : any
|
||||
>a : any
|
||||
|
||||
return true;
|
||||
>true : boolean
|
||||
}
|
||||
export function fooWithTypeTypePredicateAndGeneric<T>(a: any): a is T {
|
||||
>fooWithTypeTypePredicateAndGeneric : <T>(a: any) => a is T
|
||||
>T : T
|
||||
>a : any
|
||||
>a : any
|
||||
>T : T
|
||||
|
||||
return true;
|
||||
>true : boolean
|
||||
}
|
||||
export function fooWithTypeTypePredicateAndRestParam(a: any, ...rest): a is number {
|
||||
>fooWithTypeTypePredicateAndRestParam : (a: any, ...rest: any[]) => a is number
|
||||
>a : any
|
||||
>rest : any[]
|
||||
>a : any
|
||||
|
||||
return true;
|
||||
>true : boolean
|
||||
}
|
||||
|
||||
/** This comment should appear for nonExportedFoo*/
|
||||
function nonExportedFoo() {
|
||||
>nonExportedFoo : () => void
|
||||
|
||||
@@ -23,6 +23,7 @@ function bar({a1, b1, c1}: { a1: number, b1: boolean, c1: string }): void { }
|
||||
function baz({a2, b2: {b1, c1}}: { a2: number, b2: { b1: boolean, c1: string } }): void { }
|
||||
>baz : Symbol(baz, Decl(declarationEmitDestructuring1.ts, 2, 77))
|
||||
>a2 : Symbol(a2, Decl(declarationEmitDestructuring1.ts, 3, 14))
|
||||
>b2 : Symbol(b2, Decl(declarationEmitDestructuring1.ts, 3, 46))
|
||||
>b1 : Symbol(b1, Decl(declarationEmitDestructuring1.ts, 3, 23))
|
||||
>c1 : Symbol(c1, Decl(declarationEmitDestructuring1.ts, 3, 26))
|
||||
>a2 : Symbol(a2, Decl(declarationEmitDestructuring1.ts, 3, 34))
|
||||
|
||||
@@ -17,6 +17,7 @@ var [a2, [b2, { x12, y12: c2 }]=["abc", { x12: 10, y12: false }]] = [1, ["hello"
|
||||
>a2 : Symbol(a2, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 5))
|
||||
>b2 : Symbol(b2, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 10))
|
||||
>x12 : Symbol(x12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 15))
|
||||
>y12 : Symbol(y12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 91))
|
||||
>c2 : Symbol(c2, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 20))
|
||||
>x12 : Symbol(x12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 41))
|
||||
>y12 : Symbol(y12, Decl(declarationEmitDestructuringArrayPattern2.ts, 5, 50))
|
||||
|
||||
@@ -21,24 +21,33 @@ var { x6, y6 } = { x6: 5, y6: "hello" };
|
||||
>y6 : Symbol(y6, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 4, 25))
|
||||
|
||||
var { x7: a1 } = { x7: 5, y7: "hello" };
|
||||
>x7 : Symbol(x7, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 5, 18))
|
||||
>a1 : Symbol(a1, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 5, 5))
|
||||
>x7 : Symbol(x7, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 5, 18))
|
||||
>y7 : Symbol(y7, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 5, 25))
|
||||
|
||||
var { y8: b1 } = { x8: 5, y8: "hello" };
|
||||
>y8 : Symbol(y8, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 6, 25))
|
||||
>b1 : Symbol(b1, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 6, 5))
|
||||
>x8 : Symbol(x8, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 6, 18))
|
||||
>y8 : Symbol(y8, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 6, 25))
|
||||
|
||||
var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" };
|
||||
>x9 : Symbol(x9, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 26))
|
||||
>a2 : Symbol(a2, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 5))
|
||||
>y9 : Symbol(y9, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 33))
|
||||
>b2 : Symbol(b2, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 13))
|
||||
>x9 : Symbol(x9, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 26))
|
||||
>y9 : Symbol(y9, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 7, 33))
|
||||
|
||||
var { a: x11, b: { a: y11, b: { a: z11 }}} = { a: 1, b: { a: "hello", b: { a: true } } };
|
||||
>a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 46))
|
||||
>x11 : Symbol(x11, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 5))
|
||||
>b : Symbol(b, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 52))
|
||||
>a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 57))
|
||||
>y11 : Symbol(y11, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 18))
|
||||
>b : Symbol(b, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 69))
|
||||
>a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 74))
|
||||
>z11 : Symbol(z11, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 31))
|
||||
>a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 46))
|
||||
>b : Symbol(b, Decl(declarationEmitDestructuringObjectLiteralPattern.ts, 9, 52))
|
||||
|
||||
@@ -21,17 +21,21 @@ var { x6, y6 } = { x6: 5, y6: "hello" };
|
||||
>y6 : Symbol(y6, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 4, 25))
|
||||
|
||||
var { x7: a1 } = { x7: 5, y7: "hello" };
|
||||
>x7 : Symbol(x7, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 5, 18))
|
||||
>a1 : Symbol(a1, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 5, 5))
|
||||
>x7 : Symbol(x7, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 5, 18))
|
||||
>y7 : Symbol(y7, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 5, 25))
|
||||
|
||||
var { y8: b1 } = { x8: 5, y8: "hello" };
|
||||
>y8 : Symbol(y8, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 6, 25))
|
||||
>b1 : Symbol(b1, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 6, 5))
|
||||
>x8 : Symbol(x8, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 6, 18))
|
||||
>y8 : Symbol(y8, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 6, 25))
|
||||
|
||||
var { x9: a2, y9: b2 } = { x9: 5, y9: "hello" };
|
||||
>x9 : Symbol(x9, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 26))
|
||||
>a2 : Symbol(a2, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 5))
|
||||
>y9 : Symbol(y9, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 33))
|
||||
>b2 : Symbol(b2, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 13))
|
||||
>x9 : Symbol(x9, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 26))
|
||||
>y9 : Symbol(y9, Decl(declarationEmitDestructuringObjectLiteralPattern1.ts, 7, 33))
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
=== tests/cases/compiler/declarationEmitDestructuringObjectLiteralPattern2.ts ===
|
||||
|
||||
var { a: x11, b: { a: y11, b: { a: z11 }}} = { a: 1, b: { a: "hello", b: { a: true } } };
|
||||
>a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern2.ts, 1, 46))
|
||||
>x11 : Symbol(x11, Decl(declarationEmitDestructuringObjectLiteralPattern2.ts, 1, 5))
|
||||
>b : Symbol(b, Decl(declarationEmitDestructuringObjectLiteralPattern2.ts, 1, 52))
|
||||
>a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern2.ts, 1, 57))
|
||||
>y11 : Symbol(y11, Decl(declarationEmitDestructuringObjectLiteralPattern2.ts, 1, 18))
|
||||
>b : Symbol(b, Decl(declarationEmitDestructuringObjectLiteralPattern2.ts, 1, 69))
|
||||
>a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern2.ts, 1, 74))
|
||||
>z11 : Symbol(z11, Decl(declarationEmitDestructuringObjectLiteralPattern2.ts, 1, 31))
|
||||
>a : Symbol(a, Decl(declarationEmitDestructuringObjectLiteralPattern2.ts, 1, 46))
|
||||
>b : Symbol(b, Decl(declarationEmitDestructuringObjectLiteralPattern2.ts, 1, 52))
|
||||
|
||||
@@ -19,6 +19,7 @@ var { b1, } = { b1:1, };
|
||||
>b1 : Symbol(b1, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 11, 15))
|
||||
|
||||
var { b2: { b21 } = { b21: "string" } } = { b2: { b21: "world" } };
|
||||
>b2 : Symbol(b2, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 12, 44))
|
||||
>b21 : Symbol(b21, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 12, 11))
|
||||
>b21 : Symbol(b21, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 12, 21))
|
||||
>b2 : Symbol(b2, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 12, 44))
|
||||
@@ -32,6 +33,7 @@ var {b4 = 1}: any = { b4: 100000 };
|
||||
>b4 : Symbol(b4, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 14, 21))
|
||||
|
||||
var {b5: { b52 } } = { b5: { b52 } };
|
||||
>b5 : Symbol(b5, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 15, 23))
|
||||
>b52 : Symbol(b52, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 15, 10))
|
||||
>b5 : Symbol(b5, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 15, 23))
|
||||
>b52 : Symbol(b52, Decl(destructuringObjectBindingPatternAndAssignment1ES5.ts, 15, 29))
|
||||
|
||||
@@ -19,6 +19,7 @@ var { b1, } = { b1:1, };
|
||||
>b1 : Symbol(b1, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 11, 15))
|
||||
|
||||
var { b2: { b21 } = { b21: "string" } } = { b2: { b21: "world" } };
|
||||
>b2 : Symbol(b2, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 12, 44))
|
||||
>b21 : Symbol(b21, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 12, 11))
|
||||
>b21 : Symbol(b21, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 12, 21))
|
||||
>b2 : Symbol(b2, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 12, 44))
|
||||
@@ -32,6 +33,7 @@ var {b4 = 1}: any = { b4: 100000 };
|
||||
>b4 : Symbol(b4, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 14, 21))
|
||||
|
||||
var {b5: { b52 } } = { b5: { b52 } };
|
||||
>b5 : Symbol(b5, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 15, 23))
|
||||
>b52 : Symbol(b52, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 15, 10))
|
||||
>b5 : Symbol(b5, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 15, 23))
|
||||
>b52 : Symbol(b52, Decl(destructuringObjectBindingPatternAndAssignment1ES6.ts, 15, 29))
|
||||
|
||||
@@ -1,16 +1,8 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5.ts(32,4): error TS2345: Argument of type '[string, number, number]' is not assignable to parameter of type '[undefined, null, undefined]'.
|
||||
Types of property '0' are incompatible.
|
||||
Type 'string' is not assignable to type 'undefined'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5.ts(33,4): error TS2345: Argument of type '[[string], number, [[boolean, boolean]]]' is not assignable to parameter of type '[[undefined], undefined, [[undefined, undefined]]]'.
|
||||
Types of property '0' are incompatible.
|
||||
Type '[string]' is not assignable to type '[undefined]'.
|
||||
Types of property '0' are incompatible.
|
||||
Type 'string' is not assignable to type 'undefined'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5.ts(62,10): error TS2393: Duplicate function implementation.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5.ts(63,10): error TS2393: Duplicate function implementation.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5.ts (4 errors) ====
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5.ts (2 errors) ====
|
||||
// A parameter declaration may specify either an identifier or a binding pattern.
|
||||
// The identifiers specified in parameter declarations and binding patterns
|
||||
// in a parameter list must be unique within that parameter list.
|
||||
@@ -43,17 +35,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5.
|
||||
b2("string", { x: 200, y: "string" });
|
||||
b2("string", { x: 200, y: true });
|
||||
b6(["string", 1, 2]); // Shouldn't be an error
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '[string, number, number]' is not assignable to parameter of type '[undefined, null, undefined]'.
|
||||
!!! error TS2345: Types of property '0' are incompatible.
|
||||
!!! error TS2345: Type 'string' is not assignable to type 'undefined'.
|
||||
b7([["string"], 1, [[true, false]]]); // Shouldn't be an error
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '[[string], number, [[boolean, boolean]]]' is not assignable to parameter of type '[[undefined], undefined, [[undefined, undefined]]]'.
|
||||
!!! error TS2345: Types of property '0' are incompatible.
|
||||
!!! error TS2345: Type '[string]' is not assignable to type '[undefined]'.
|
||||
!!! error TS2345: Types of property '0' are incompatible.
|
||||
!!! error TS2345: Type 'string' is not assignable to type 'undefined'.
|
||||
|
||||
|
||||
// If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3)
|
||||
|
||||
@@ -17,6 +17,7 @@ var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [["hello"]], true];
|
||||
// The type T associated with a destructuring variable declaration is determined as follows:
|
||||
// Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression.
|
||||
var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } };
|
||||
>b1 : Symbol(b1, Decl(destructuringVariableDeclaration1ES5.ts, 7, 44))
|
||||
>b11 : Symbol(b11, Decl(destructuringVariableDeclaration1ES5.ts, 7, 11))
|
||||
>b11 : Symbol(b11, Decl(destructuringVariableDeclaration1ES5.ts, 7, 21))
|
||||
>b1 : Symbol(b1, Decl(destructuringVariableDeclaration1ES5.ts, 7, 44))
|
||||
@@ -74,6 +75,7 @@ var [d3, d4] = [1, "string", ...temp1];
|
||||
|
||||
// Combining both forms of destructuring,
|
||||
var {e: [e1, e2, e3 = { b1: 1000, b4: 200 }]} = { e: [1, 2, { b1: 4, b4: 0 }] };
|
||||
>e : Symbol(e, Decl(destructuringVariableDeclaration1ES5.ts, 31, 49))
|
||||
>e1 : Symbol(e1, Decl(destructuringVariableDeclaration1ES5.ts, 31, 9))
|
||||
>e2 : Symbol(e2, Decl(destructuringVariableDeclaration1ES5.ts, 31, 12))
|
||||
>e3 : Symbol(e3, Decl(destructuringVariableDeclaration1ES5.ts, 31, 16))
|
||||
@@ -84,8 +86,10 @@ var {e: [e1, e2, e3 = { b1: 1000, b4: 200 }]} = { e: [1, 2, { b1: 4, b4: 0 }] };
|
||||
>b4 : Symbol(b4, Decl(destructuringVariableDeclaration1ES5.ts, 31, 68))
|
||||
|
||||
var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] };
|
||||
>f : Symbol(f, Decl(destructuringVariableDeclaration1ES5.ts, 32, 41))
|
||||
>f1 : Symbol(f1, Decl(destructuringVariableDeclaration1ES5.ts, 32, 9))
|
||||
>f2 : Symbol(f2, Decl(destructuringVariableDeclaration1ES5.ts, 32, 12))
|
||||
>f3 : Symbol(f3, Decl(destructuringVariableDeclaration1ES5.ts, 32, 53))
|
||||
>f4 : Symbol(f4, Decl(destructuringVariableDeclaration1ES5.ts, 32, 18))
|
||||
>f5 : Symbol(f5, Decl(destructuringVariableDeclaration1ES5.ts, 32, 26))
|
||||
>f : Symbol(f, Decl(destructuringVariableDeclaration1ES5.ts, 32, 41))
|
||||
@@ -96,6 +100,7 @@ var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] };
|
||||
// an initializer expression, the type of the initializer expression is required to be assignable
|
||||
// to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element.
|
||||
var {g: {g1 = [undefined, null]}}: { g: { g1: any[] } } = { g: { g1: [1, 2] } };
|
||||
>g : Symbol(g, Decl(destructuringVariableDeclaration1ES5.ts, 37, 36))
|
||||
>g1 : Symbol(g1, Decl(destructuringVariableDeclaration1ES5.ts, 37, 9))
|
||||
>undefined : Symbol(undefined)
|
||||
>g : Symbol(g, Decl(destructuringVariableDeclaration1ES5.ts, 37, 36))
|
||||
@@ -104,6 +109,7 @@ var {g: {g1 = [undefined, null]}}: { g: { g1: any[] } } = { g: { g1: [1, 2] } };
|
||||
>g1 : Symbol(g1, Decl(destructuringVariableDeclaration1ES5.ts, 37, 64))
|
||||
|
||||
var {h: {h1 = [undefined, null]}}: { h: { h1: number[] } } = { h: { h1: [1, 2] } };
|
||||
>h : Symbol(h, Decl(destructuringVariableDeclaration1ES5.ts, 38, 36))
|
||||
>h1 : Symbol(h1, Decl(destructuringVariableDeclaration1ES5.ts, 38, 9))
|
||||
>undefined : Symbol(undefined)
|
||||
>h : Symbol(h, Decl(destructuringVariableDeclaration1ES5.ts, 38, 36))
|
||||
|
||||
@@ -17,6 +17,7 @@ var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [["hello"]], true];
|
||||
// The type T associated with a destructuring variable declaration is determined as follows:
|
||||
// Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression.
|
||||
var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } };
|
||||
>b1 : Symbol(b1, Decl(destructuringVariableDeclaration1ES6.ts, 7, 44))
|
||||
>b11 : Symbol(b11, Decl(destructuringVariableDeclaration1ES6.ts, 7, 11))
|
||||
>b11 : Symbol(b11, Decl(destructuringVariableDeclaration1ES6.ts, 7, 21))
|
||||
>b1 : Symbol(b1, Decl(destructuringVariableDeclaration1ES6.ts, 7, 44))
|
||||
@@ -74,6 +75,7 @@ var [d3, d4] = [1, "string", ...temp1];
|
||||
|
||||
// Combining both forms of destructuring,
|
||||
var {e: [e1, e2, e3 = { b1: 1000, b4: 200 }]} = { e: [1, 2, { b1: 4, b4: 0 }] };
|
||||
>e : Symbol(e, Decl(destructuringVariableDeclaration1ES6.ts, 31, 49))
|
||||
>e1 : Symbol(e1, Decl(destructuringVariableDeclaration1ES6.ts, 31, 9))
|
||||
>e2 : Symbol(e2, Decl(destructuringVariableDeclaration1ES6.ts, 31, 12))
|
||||
>e3 : Symbol(e3, Decl(destructuringVariableDeclaration1ES6.ts, 31, 16))
|
||||
@@ -84,8 +86,10 @@ var {e: [e1, e2, e3 = { b1: 1000, b4: 200 }]} = { e: [1, 2, { b1: 4, b4: 0 }] };
|
||||
>b4 : Symbol(b4, Decl(destructuringVariableDeclaration1ES6.ts, 31, 68))
|
||||
|
||||
var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] };
|
||||
>f : Symbol(f, Decl(destructuringVariableDeclaration1ES6.ts, 32, 41))
|
||||
>f1 : Symbol(f1, Decl(destructuringVariableDeclaration1ES6.ts, 32, 9))
|
||||
>f2 : Symbol(f2, Decl(destructuringVariableDeclaration1ES6.ts, 32, 12))
|
||||
>f3 : Symbol(f3, Decl(destructuringVariableDeclaration1ES6.ts, 32, 53))
|
||||
>f4 : Symbol(f4, Decl(destructuringVariableDeclaration1ES6.ts, 32, 18))
|
||||
>f5 : Symbol(f5, Decl(destructuringVariableDeclaration1ES6.ts, 32, 26))
|
||||
>f : Symbol(f, Decl(destructuringVariableDeclaration1ES6.ts, 32, 41))
|
||||
@@ -96,6 +100,7 @@ var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] };
|
||||
// an initializer expression, the type of the initializer expression is required to be assignable
|
||||
// to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element.
|
||||
var {g: {g1 = [undefined, null]}}: { g: { g1: any[] } } = { g: { g1: [1, 2] } };
|
||||
>g : Symbol(g, Decl(destructuringVariableDeclaration1ES6.ts, 37, 36))
|
||||
>g1 : Symbol(g1, Decl(destructuringVariableDeclaration1ES6.ts, 37, 9))
|
||||
>undefined : Symbol(undefined)
|
||||
>g : Symbol(g, Decl(destructuringVariableDeclaration1ES6.ts, 37, 36))
|
||||
@@ -104,6 +109,7 @@ var {g: {g1 = [undefined, null]}}: { g: { g1: any[] } } = { g: { g1: [1, 2] } };
|
||||
>g1 : Symbol(g1, Decl(destructuringVariableDeclaration1ES6.ts, 37, 64))
|
||||
|
||||
var {h: {h1 = [undefined, null]}}: { h: { h1: number[] } } = { h: { h1: [1, 2] } };
|
||||
>h : Symbol(h, Decl(destructuringVariableDeclaration1ES6.ts, 38, 36))
|
||||
>h1 : Symbol(h1, Decl(destructuringVariableDeclaration1ES6.ts, 38, 9))
|
||||
>undefined : Symbol(undefined)
|
||||
>h : Symbol(h, Decl(destructuringVariableDeclaration1ES6.ts, 38, 36))
|
||||
|
||||
@@ -12,6 +12,7 @@ let [baz] = [];
|
||||
>baz : Symbol(baz, Decl(downlevelLetConst12.ts, 6, 5))
|
||||
|
||||
let {a: baz2} = { a: 1 };
|
||||
>a : Symbol(a, Decl(downlevelLetConst12.ts, 7, 17))
|
||||
>baz2 : Symbol(baz2, Decl(downlevelLetConst12.ts, 7, 5))
|
||||
>a : Symbol(a, Decl(downlevelLetConst12.ts, 7, 17))
|
||||
|
||||
@@ -19,6 +20,7 @@ const [baz3] = []
|
||||
>baz3 : Symbol(baz3, Decl(downlevelLetConst12.ts, 9, 7))
|
||||
|
||||
const {a: baz4} = { a: 1 };
|
||||
>a : Symbol(a, Decl(downlevelLetConst12.ts, 10, 19))
|
||||
>baz4 : Symbol(baz4, Decl(downlevelLetConst12.ts, 10, 7))
|
||||
>a : Symbol(a, Decl(downlevelLetConst12.ts, 10, 19))
|
||||
|
||||
|
||||
@@ -16,10 +16,12 @@ export const [bar2] = [2];
|
||||
>bar2 : Symbol(bar2, Decl(downlevelLetConst13.ts, 7, 14))
|
||||
|
||||
export let {a: bar3} = { a: 1 };
|
||||
>a : Symbol(a, Decl(downlevelLetConst13.ts, 8, 24))
|
||||
>bar3 : Symbol(bar3, Decl(downlevelLetConst13.ts, 8, 12))
|
||||
>a : Symbol(a, Decl(downlevelLetConst13.ts, 8, 24))
|
||||
|
||||
export const {a: bar4} = { a: 1 };
|
||||
>a : Symbol(a, Decl(downlevelLetConst13.ts, 9, 26))
|
||||
>bar4 : Symbol(bar4, Decl(downlevelLetConst13.ts, 9, 14))
|
||||
>a : Symbol(a, Decl(downlevelLetConst13.ts, 9, 26))
|
||||
|
||||
@@ -39,10 +41,12 @@ export module M {
|
||||
>bar6 : Symbol(bar6, Decl(downlevelLetConst13.ts, 15, 18))
|
||||
|
||||
export let {a: bar7} = { a: 1 };
|
||||
>a : Symbol(a, Decl(downlevelLetConst13.ts, 16, 28))
|
||||
>bar7 : Symbol(bar7, Decl(downlevelLetConst13.ts, 16, 16))
|
||||
>a : Symbol(a, Decl(downlevelLetConst13.ts, 16, 28))
|
||||
|
||||
export const {a: bar8} = { a: 1 };
|
||||
>a : Symbol(a, Decl(downlevelLetConst13.ts, 17, 30))
|
||||
>bar8 : Symbol(bar8, Decl(downlevelLetConst13.ts, 17, 18))
|
||||
>a : Symbol(a, Decl(downlevelLetConst13.ts, 17, 30))
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ var z0, z1, z2, z3;
|
||||
>z1 : Symbol(z1, Decl(downlevelLetConst14.ts, 11, 9))
|
||||
|
||||
let {a: z2} = { a: 1 };
|
||||
>a : Symbol(a, Decl(downlevelLetConst14.ts, 13, 19))
|
||||
>z2 : Symbol(z2, Decl(downlevelLetConst14.ts, 13, 9))
|
||||
>a : Symbol(a, Decl(downlevelLetConst14.ts, 13, 19))
|
||||
|
||||
@@ -43,6 +44,7 @@ var z0, z1, z2, z3;
|
||||
>z2 : Symbol(z2, Decl(downlevelLetConst14.ts, 13, 9))
|
||||
|
||||
let {a: z3} = { a: 1 };
|
||||
>a : Symbol(a, Decl(downlevelLetConst14.ts, 15, 19))
|
||||
>z3 : Symbol(z3, Decl(downlevelLetConst14.ts, 15, 9))
|
||||
>a : Symbol(a, Decl(downlevelLetConst14.ts, 15, 19))
|
||||
|
||||
@@ -86,6 +88,7 @@ var y = true;
|
||||
>y : Symbol(y, Decl(downlevelLetConst14.ts, 29, 11))
|
||||
|
||||
let {a: z6} = {a: 1}
|
||||
>a : Symbol(a, Decl(downlevelLetConst14.ts, 30, 23))
|
||||
>z6 : Symbol(z6, Decl(downlevelLetConst14.ts, 30, 13))
|
||||
>a : Symbol(a, Decl(downlevelLetConst14.ts, 30, 23))
|
||||
|
||||
@@ -129,6 +132,7 @@ var z5 = 1;
|
||||
>_z : Symbol(_z, Decl(downlevelLetConst14.ts, 46, 11))
|
||||
|
||||
let {a: _z5} = { a: 1 };
|
||||
>a : Symbol(a, Decl(downlevelLetConst14.ts, 47, 24))
|
||||
>_z5 : Symbol(_z5, Decl(downlevelLetConst14.ts, 47, 13))
|
||||
>a : Symbol(a, Decl(downlevelLetConst14.ts, 47, 24))
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ var z0, z1, z2, z3;
|
||||
>z0 : Symbol(z0, Decl(downlevelLetConst15.ts, 9, 11))
|
||||
|
||||
const [{a: z1}] = [{a: 1}]
|
||||
>a : Symbol(a, Decl(downlevelLetConst15.ts, 11, 24))
|
||||
>z1 : Symbol(z1, Decl(downlevelLetConst15.ts, 11, 12))
|
||||
>a : Symbol(a, Decl(downlevelLetConst15.ts, 11, 24))
|
||||
|
||||
@@ -36,6 +37,7 @@ var z0, z1, z2, z3;
|
||||
>z1 : Symbol(z1, Decl(downlevelLetConst15.ts, 11, 12))
|
||||
|
||||
const {a: z2} = { a: 1 };
|
||||
>a : Symbol(a, Decl(downlevelLetConst15.ts, 13, 21))
|
||||
>z2 : Symbol(z2, Decl(downlevelLetConst15.ts, 13, 11))
|
||||
>a : Symbol(a, Decl(downlevelLetConst15.ts, 13, 21))
|
||||
|
||||
@@ -44,6 +46,8 @@ var z0, z1, z2, z3;
|
||||
>z2 : Symbol(z2, Decl(downlevelLetConst15.ts, 13, 11))
|
||||
|
||||
const {a: {b: z3}} = { a: {b: 1} };
|
||||
>a : Symbol(a, Decl(downlevelLetConst15.ts, 15, 26))
|
||||
>b : Symbol(b, Decl(downlevelLetConst15.ts, 15, 31))
|
||||
>z3 : Symbol(z3, Decl(downlevelLetConst15.ts, 15, 15))
|
||||
>a : Symbol(a, Decl(downlevelLetConst15.ts, 15, 26))
|
||||
>b : Symbol(b, Decl(downlevelLetConst15.ts, 15, 31))
|
||||
@@ -88,6 +92,7 @@ var y = true;
|
||||
>y : Symbol(y, Decl(downlevelLetConst15.ts, 29, 13))
|
||||
|
||||
const {a: z6} = { a: 1 }
|
||||
>a : Symbol(a, Decl(downlevelLetConst15.ts, 30, 25))
|
||||
>z6 : Symbol(z6, Decl(downlevelLetConst15.ts, 30, 15))
|
||||
>a : Symbol(a, Decl(downlevelLetConst15.ts, 30, 25))
|
||||
|
||||
@@ -131,6 +136,7 @@ var z5 = 1;
|
||||
>_z : Symbol(_z, Decl(downlevelLetConst15.ts, 46, 13))
|
||||
|
||||
const {a: _z5} = { a: 1 };
|
||||
>a : Symbol(a, Decl(downlevelLetConst15.ts, 47, 26))
|
||||
>_z5 : Symbol(_z5, Decl(downlevelLetConst15.ts, 47, 15))
|
||||
>a : Symbol(a, Decl(downlevelLetConst15.ts, 47, 26))
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ var p6 = ({ a }) => { };
|
||||
|
||||
var p7 = ({ a: { b } }) => { };
|
||||
>p7 : Symbol(p7, Decl(emitArrowFunctionES6.ts, 15, 3))
|
||||
>a : Symbol(a)
|
||||
>b : Symbol(b, Decl(emitArrowFunctionES6.ts, 15, 16))
|
||||
|
||||
var p8 = ({ a = 1 }) => { };
|
||||
@@ -64,6 +65,7 @@ var p8 = ({ a = 1 }) => { };
|
||||
|
||||
var p9 = ({ a: { b = 1 } = { b: 1 } }) => { };
|
||||
>p9 : Symbol(p9, Decl(emitArrowFunctionES6.ts, 17, 3))
|
||||
>a : Symbol(a)
|
||||
>b : Symbol(b, Decl(emitArrowFunctionES6.ts, 17, 16))
|
||||
>b : Symbol(b, Decl(emitArrowFunctionES6.ts, 17, 28))
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ function f() {
|
||||
>f : Symbol(f, Decl(emitArrowFunctionWhenUsingArguments18_ES6.ts, 0, 0))
|
||||
|
||||
var { arguments: args } = { arguments };
|
||||
>arguments : Symbol(arguments, Decl(emitArrowFunctionWhenUsingArguments18_ES6.ts, 2, 31))
|
||||
>args : Symbol(args, Decl(emitArrowFunctionWhenUsingArguments18_ES6.ts, 2, 9))
|
||||
>arguments : Symbol(arguments, Decl(emitArrowFunctionWhenUsingArguments18_ES6.ts, 2, 31))
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
function f([]) {
|
||||
var x, y, z;
|
||||
var x, y, z;
|
||||
}
|
||||
|
||||
//// [emptyArrayBindingPatternParameter01.js]
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
function f([]) {
|
||||
>f : Symbol(f, Decl(emptyArrayBindingPatternParameter01.ts, 0, 0))
|
||||
|
||||
var x, y, z;
|
||||
>x : Symbol(x, Decl(emptyArrayBindingPatternParameter01.ts, 3, 4))
|
||||
>y : Symbol(y, Decl(emptyArrayBindingPatternParameter01.ts, 3, 7))
|
||||
>z : Symbol(z, Decl(emptyArrayBindingPatternParameter01.ts, 3, 10))
|
||||
var x, y, z;
|
||||
>x : Symbol(x, Decl(emptyArrayBindingPatternParameter01.ts, 3, 7))
|
||||
>y : Symbol(y, Decl(emptyArrayBindingPatternParameter01.ts, 3, 10))
|
||||
>z : Symbol(z, Decl(emptyArrayBindingPatternParameter01.ts, 3, 13))
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
function f([]) {
|
||||
>f : ([]: any[]) => void
|
||||
|
||||
var x, y, z;
|
||||
var x, y, z;
|
||||
>x : any
|
||||
>y : any
|
||||
>z : any
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
//// [emptyAssignmentPatterns01_ES5.ts]
|
||||
|
||||
var a: any;
|
||||
|
||||
({} = a);
|
||||
([] = a);
|
||||
|
||||
//// [emptyAssignmentPatterns01_ES5.js]
|
||||
var a;
|
||||
(a);
|
||||
(a);
|
||||
@@ -0,0 +1,11 @@
|
||||
=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES5.ts ===
|
||||
|
||||
var a: any;
|
||||
>a : Symbol(a, Decl(emptyAssignmentPatterns01_ES5.ts, 1, 3))
|
||||
|
||||
({} = a);
|
||||
>a : Symbol(a, Decl(emptyAssignmentPatterns01_ES5.ts, 1, 3))
|
||||
|
||||
([] = a);
|
||||
>a : Symbol(a, Decl(emptyAssignmentPatterns01_ES5.ts, 1, 3))
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES5.ts ===
|
||||
|
||||
var a: any;
|
||||
>a : any
|
||||
|
||||
({} = a);
|
||||
>({} = a) : any
|
||||
>{} = a : any
|
||||
>{} : {}
|
||||
>a : any
|
||||
|
||||
([] = a);
|
||||
>([] = a) : any
|
||||
>[] = a : any
|
||||
>[] : undefined[]
|
||||
>a : any
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
//// [emptyAssignmentPatterns01_ES6.ts]
|
||||
|
||||
var a: any;
|
||||
|
||||
({} = a);
|
||||
([] = a);
|
||||
|
||||
//// [emptyAssignmentPatterns01_ES6.js]
|
||||
var a;
|
||||
({} = a);
|
||||
([] = a);
|
||||
@@ -0,0 +1,11 @@
|
||||
=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES6.ts ===
|
||||
|
||||
var a: any;
|
||||
>a : Symbol(a, Decl(emptyAssignmentPatterns01_ES6.ts, 1, 3))
|
||||
|
||||
({} = a);
|
||||
>a : Symbol(a, Decl(emptyAssignmentPatterns01_ES6.ts, 1, 3))
|
||||
|
||||
([] = a);
|
||||
>a : Symbol(a, Decl(emptyAssignmentPatterns01_ES6.ts, 1, 3))
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns01_ES6.ts ===
|
||||
|
||||
var a: any;
|
||||
>a : any
|
||||
|
||||
({} = a);
|
||||
>({} = a) : any
|
||||
>{} = a : any
|
||||
>{} : {}
|
||||
>a : any
|
||||
|
||||
([] = a);
|
||||
>([] = a) : any
|
||||
>[] = a : any
|
||||
>[] : undefined[]
|
||||
>a : any
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [emptyAssignmentPatterns02_ES5.ts]
|
||||
|
||||
var a: any;
|
||||
let x, y, z, a1, a2, a3;
|
||||
|
||||
({} = { x, y, z } = a);
|
||||
([] = [ a1, a2, a3] = a);
|
||||
|
||||
//// [emptyAssignmentPatterns02_ES5.js]
|
||||
var a;
|
||||
var x, y, z, a1, a2, a3;
|
||||
((x = a.x, y = a.y, z = a.z, a));
|
||||
((a1 = a[0], a2 = a[1], a3 = a[2], a));
|
||||
@@ -0,0 +1,25 @@
|
||||
=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES5.ts ===
|
||||
|
||||
var a: any;
|
||||
>a : Symbol(a, Decl(emptyAssignmentPatterns02_ES5.ts, 1, 3))
|
||||
|
||||
let x, y, z, a1, a2, a3;
|
||||
>x : Symbol(x, Decl(emptyAssignmentPatterns02_ES5.ts, 2, 3))
|
||||
>y : Symbol(y, Decl(emptyAssignmentPatterns02_ES5.ts, 2, 6))
|
||||
>z : Symbol(z, Decl(emptyAssignmentPatterns02_ES5.ts, 2, 9))
|
||||
>a1 : Symbol(a1, Decl(emptyAssignmentPatterns02_ES5.ts, 2, 12))
|
||||
>a2 : Symbol(a2, Decl(emptyAssignmentPatterns02_ES5.ts, 2, 16))
|
||||
>a3 : Symbol(a3, Decl(emptyAssignmentPatterns02_ES5.ts, 2, 20))
|
||||
|
||||
({} = { x, y, z } = a);
|
||||
>x : Symbol(x, Decl(emptyAssignmentPatterns02_ES5.ts, 4, 7))
|
||||
>y : Symbol(y, Decl(emptyAssignmentPatterns02_ES5.ts, 4, 10))
|
||||
>z : Symbol(z, Decl(emptyAssignmentPatterns02_ES5.ts, 4, 13))
|
||||
>a : Symbol(a, Decl(emptyAssignmentPatterns02_ES5.ts, 1, 3))
|
||||
|
||||
([] = [ a1, a2, a3] = a);
|
||||
>a1 : Symbol(a1, Decl(emptyAssignmentPatterns02_ES5.ts, 2, 12))
|
||||
>a2 : Symbol(a2, Decl(emptyAssignmentPatterns02_ES5.ts, 2, 16))
|
||||
>a3 : Symbol(a3, Decl(emptyAssignmentPatterns02_ES5.ts, 2, 20))
|
||||
>a : Symbol(a, Decl(emptyAssignmentPatterns02_ES5.ts, 1, 3))
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
=== tests/cases/conformance/es6/destructuring/emptyAssignmentPatterns02_ES5.ts ===
|
||||
|
||||
var a: any;
|
||||
>a : any
|
||||
|
||||
let x, y, z, a1, a2, a3;
|
||||
>x : any
|
||||
>y : any
|
||||
>z : any
|
||||
>a1 : any
|
||||
>a2 : any
|
||||
>a3 : any
|
||||
|
||||
({} = { x, y, z } = a);
|
||||
>({} = { x, y, z } = a) : any
|
||||
>{} = { x, y, z } = a : any
|
||||
>{} : {}
|
||||
>{ x, y, z } = a : any
|
||||
>{ x, y, z } : { x: any; y: any; z: any; }
|
||||
>x : any
|
||||
>y : any
|
||||
>z : any
|
||||
>a : any
|
||||
|
||||
([] = [ a1, a2, a3] = a);
|
||||
>([] = [ a1, a2, a3] = a) : any
|
||||
>[] = [ a1, a2, a3] = a : any
|
||||
>[] : undefined[]
|
||||
>[ a1, a2, a3] = a : any
|
||||
>[ a1, a2, a3] : [any, any, any]
|
||||
>a1 : any
|
||||
>a2 : any
|
||||
>a3 : any
|
||||
>a : any
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user