mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into includes_glob
This commit is contained in:
@@ -41,7 +41,9 @@ tests/cases/**/*.js.map
|
||||
scripts/debug.bat
|
||||
scripts/run.bat
|
||||
scripts/word2md.js
|
||||
scripts/buildProtocol.js
|
||||
scripts/ior.js
|
||||
scripts/buildProtocol.js
|
||||
scripts/*.js.map
|
||||
scripts/typings/
|
||||
coverage/
|
||||
|
||||
@@ -183,5 +183,3 @@ jake baseline-accept
|
||||
```
|
||||
|
||||
to establish the new baselines as the desired behavior. This will change the files in `tests\baselines\reference`, which should be included as part of your commit. It's important to carefully validate changes in the baselines.
|
||||
|
||||
**Note** that `baseline-accept` should only be run after a full test run! Accepting baselines after running a subset of tests will delete baseline files for the tests that didn't run.
|
||||
|
||||
+54
-13
@@ -70,13 +70,15 @@ var compilerSources = [
|
||||
"visitor.ts",
|
||||
"transformers/destructuring.ts",
|
||||
"transformers/ts.ts",
|
||||
"transformers/module/es6.ts",
|
||||
"transformers/module/es2015.ts",
|
||||
"transformers/module/system.ts",
|
||||
"transformers/module/module.ts",
|
||||
"transformers/jsx.ts",
|
||||
"transformers/es7.ts",
|
||||
"transformers/es2017.ts",
|
||||
"transformers/es2016.ts",
|
||||
"transformers/es2015.ts",
|
||||
"transformers/generators.ts",
|
||||
"transformers/es6.ts",
|
||||
"transformers/es5.ts",
|
||||
"transformer.ts",
|
||||
"sourcemap.ts",
|
||||
"comments.ts",
|
||||
@@ -104,13 +106,15 @@ var servicesSources = [
|
||||
"visitor.ts",
|
||||
"transformers/destructuring.ts",
|
||||
"transformers/ts.ts",
|
||||
"transformers/module/es6.ts",
|
||||
"transformers/module/es2015.ts",
|
||||
"transformers/module/system.ts",
|
||||
"transformers/module/module.ts",
|
||||
"transformers/jsx.ts",
|
||||
"transformers/es7.ts",
|
||||
"transformers/es2017.ts",
|
||||
"transformers/es2016.ts",
|
||||
"transformers/es2015.ts",
|
||||
"transformers/generators.ts",
|
||||
"transformers/es6.ts",
|
||||
"transformers/es5.ts",
|
||||
"transformer.ts",
|
||||
"sourcemap.ts",
|
||||
"comments.ts",
|
||||
@@ -174,7 +178,7 @@ var serverCoreSources = [
|
||||
"lsHost.ts",
|
||||
"project.ts",
|
||||
"editorServices.ts",
|
||||
"protocol.d.ts",
|
||||
"protocol.ts",
|
||||
"session.ts",
|
||||
"server.ts"
|
||||
].map(function (f) {
|
||||
@@ -198,14 +202,13 @@ var typingsInstallerSources = [
|
||||
var serverSources = serverCoreSources.concat(servicesSources);
|
||||
|
||||
var languageServiceLibrarySources = [
|
||||
"protocol.d.ts",
|
||||
"protocol.ts",
|
||||
"utilities.ts",
|
||||
"scriptVersionCache.ts",
|
||||
"scriptInfo.ts",
|
||||
"lsHost.ts",
|
||||
"project.ts",
|
||||
"editorServices.ts",
|
||||
"protocol.d.ts",
|
||||
"session.ts",
|
||||
|
||||
].map(function (f) {
|
||||
@@ -259,7 +262,7 @@ var harnessSources = harnessCoreSources.concat([
|
||||
].map(function (f) {
|
||||
return path.join(unittestsDirectory, f);
|
||||
})).concat([
|
||||
"protocol.d.ts",
|
||||
"protocol.ts",
|
||||
"utilities.ts",
|
||||
"scriptVersionCache.ts",
|
||||
"scriptInfo.ts",
|
||||
@@ -267,7 +270,6 @@ var harnessSources = harnessCoreSources.concat([
|
||||
"project.ts",
|
||||
"typingsCache.ts",
|
||||
"editorServices.ts",
|
||||
"protocol.d.ts",
|
||||
"session.ts",
|
||||
].map(function (f) {
|
||||
return path.join(serverDirectory, f);
|
||||
@@ -355,6 +357,7 @@ function concatenateFiles(destinationFile, sourceFiles) {
|
||||
if (!fs.existsSync(sourceFiles[i])) {
|
||||
fail(sourceFiles[i] + " does not exist!");
|
||||
}
|
||||
fs.appendFileSync(temp, "\n\n");
|
||||
fs.appendFileSync(temp, fs.readFileSync(sourceFiles[i]));
|
||||
}
|
||||
// Move the file to the final destination
|
||||
@@ -445,6 +448,8 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
|
||||
options += " --stripInternal";
|
||||
}
|
||||
|
||||
options += " --target es5 --noUnusedLocals --noUnusedParameters";
|
||||
|
||||
var cmd = host + " " + compilerPath + " " + options + " ";
|
||||
cmd = cmd + sources.join(" ");
|
||||
console.log(cmd + "\n");
|
||||
@@ -518,6 +523,40 @@ compileFile(processDiagnosticMessagesJs,
|
||||
[],
|
||||
/*useBuiltCompiler*/ false);
|
||||
|
||||
var buildProtocolTs = path.join(scriptsDirectory, "buildProtocol.ts");
|
||||
var buildProtocolJs = path.join(scriptsDirectory, "buildProtocol.js");
|
||||
var buildProtocolDts = path.join(builtLocalDirectory, "protocol.d.ts");
|
||||
var typescriptServicesDts = path.join(builtLocalDirectory, "typescriptServices.d.ts");
|
||||
|
||||
file(buildProtocolTs);
|
||||
|
||||
compileFile(buildProtocolJs,
|
||||
[buildProtocolTs],
|
||||
[buildProtocolTs],
|
||||
[],
|
||||
/*useBuiltCompiler*/ false,
|
||||
{noOutFile: true});
|
||||
|
||||
file(buildProtocolDts, [buildProtocolTs, buildProtocolJs, typescriptServicesDts], function() {
|
||||
|
||||
var protocolTs = path.join(serverDirectory, "protocol.ts");
|
||||
|
||||
var cmd = host + " " + buildProtocolJs + " "+ protocolTs + " " + typescriptServicesDts + " " + buildProtocolDts;
|
||||
console.log(cmd);
|
||||
var ex = jake.createExec([cmd]);
|
||||
// Add listeners for output and error
|
||||
ex.addListener("stdout", function (output) {
|
||||
process.stdout.write(output);
|
||||
});
|
||||
ex.addListener("stderr", function (error) {
|
||||
process.stderr.write(error);
|
||||
});
|
||||
ex.addListener("cmdEnd", function () {
|
||||
complete();
|
||||
});
|
||||
ex.run();
|
||||
}, { async: true })
|
||||
|
||||
// The generated diagnostics map; built for the compiler and for the 'generate-diagnostics' task
|
||||
file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson], function () {
|
||||
var cmd = host + " " + processDiagnosticMessagesJs + " " + diagnosticMessagesJson;
|
||||
@@ -655,6 +694,8 @@ compileFile(
|
||||
inlineSourceMap: true
|
||||
});
|
||||
|
||||
file(typescriptServicesDts, [servicesFile]);
|
||||
|
||||
var cancellationTokenFile = path.join(builtLocalDirectory, "cancellationToken.js");
|
||||
compileFile(cancellationTokenFile, cancellationTokenSources, [builtLocalDirectory].concat(cancellationTokenSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { outDir: builtLocalDirectory, noOutFile: true });
|
||||
|
||||
@@ -689,7 +730,7 @@ task("build-fold-end", [], function () {
|
||||
|
||||
// Local target to build the compiler and services
|
||||
desc("Builds the full compiler and services");
|
||||
task("local", ["build-fold-start", "generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile, builtGeneratedDiagnosticMessagesJSON, "lssl", "build-fold-end"]);
|
||||
task("local", ["build-fold-start", "generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile, buildProtocolDts, builtGeneratedDiagnosticMessagesJSON, "lssl", "build-fold-end"]);
|
||||
|
||||
// Local target to build only tsc.js
|
||||
desc("Builds only the compiler");
|
||||
@@ -745,7 +786,7 @@ task("generate-spec", [specMd]);
|
||||
// Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory
|
||||
desc("Makes a new LKG out of the built js files");
|
||||
task("LKG", ["clean", "release", "local"].concat(libraryTargets), function () {
|
||||
var expectedFiles = [tscFile, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, tsserverLibraryFile, tsserverLibraryDefinitionFile, cancellationTokenFile, typingsInstallerFile].concat(libraryTargets);
|
||||
var expectedFiles = [tscFile, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, tsserverLibraryFile, tsserverLibraryDefinitionFile, cancellationTokenFile, typingsInstallerFile, buildProtocolDts].concat(libraryTargets);
|
||||
var missingFiles = expectedFiles.filter(function (f) {
|
||||
return !fs.existsSync(f);
|
||||
});
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
<!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript -->
|
||||
<!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->
|
||||
|
||||
**TypeScript Version:** 1.8.0 / nightly (2.0.0-dev.201xxxxx)
|
||||
**TypeScript Version:** 2.0.3 / nightly (2.1.0-dev.201xxxxx)
|
||||
|
||||
**Code**
|
||||
|
||||
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Set up NVM
|
||||
export NVM_DIR="/home/dotnet-bot/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
||||
|
||||
nvm install $1
|
||||
|
||||
npm uninstall typescript
|
||||
npm uninstall tslint
|
||||
npm install
|
||||
npm update
|
||||
npm test
|
||||
@@ -39,3 +39,5 @@ function createCancellationToken(args) {
|
||||
};
|
||||
}
|
||||
module.exports = createCancellationToken;
|
||||
|
||||
//# sourceMappingURL=cancellationToken.js.map
|
||||
|
||||
Vendored
+227
-189
@@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
/// ECMAScript APIs
|
||||
/////////////////////////////
|
||||
@@ -260,6 +264,9 @@ interface Function {
|
||||
*/
|
||||
bind(this: Function, thisArg: any, ...argArray: any[]): any;
|
||||
|
||||
/** Returns a string representation of a function. */
|
||||
toString(): string;
|
||||
|
||||
prototype: any;
|
||||
readonly length: number;
|
||||
|
||||
@@ -1216,6 +1223,30 @@ interface Array<T> {
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void;
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map<U>(this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U];
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map<U>(this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U];
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map<U>(this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U];
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map<U>(this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U];
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
@@ -4122,6 +4153,8 @@ interface Date {
|
||||
*/
|
||||
toLocaleTimeString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
/// IE DOM APIs
|
||||
@@ -11660,11 +11693,12 @@ declare var HashChangeEvent: {
|
||||
interface History {
|
||||
readonly length: number;
|
||||
readonly state: any;
|
||||
back(distance?: any): void;
|
||||
forward(distance?: any): void;
|
||||
go(delta?: any): void;
|
||||
pushState(statedata: any, title?: string, url?: string): void;
|
||||
replaceState(statedata: any, title?: string, url?: string): void;
|
||||
scrollRestoration: ScrollRestoration;
|
||||
back(): void;
|
||||
forward(): void;
|
||||
go(delta?: number): void;
|
||||
pushState(data: any, title: string, url?: string | null): void;
|
||||
replaceState(data: any, title: string, url?: string | null): void;
|
||||
}
|
||||
|
||||
declare var History: {
|
||||
@@ -17236,7 +17270,6 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window
|
||||
addEventListener(type: "waiting", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "wheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
[index: number]: Window;
|
||||
}
|
||||
|
||||
declare var Window: {
|
||||
@@ -17267,7 +17300,7 @@ declare var XMLDocument: {
|
||||
}
|
||||
|
||||
interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
|
||||
onreadystatechange: (this: this, ev: ProgressEvent) => any;
|
||||
onreadystatechange: (this: this, ev: Event) => any;
|
||||
readonly readyState: number;
|
||||
readonly response: any;
|
||||
readonly responseText: string;
|
||||
@@ -17294,13 +17327,13 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
|
||||
readonly LOADING: number;
|
||||
readonly OPENED: number;
|
||||
readonly UNSENT: number;
|
||||
addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "abort", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "load", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadend", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadstart", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "readystatechange", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "readystatechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "timeout", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
@@ -17641,183 +17674,183 @@ interface NavigatorUserMedia {
|
||||
}
|
||||
|
||||
interface NodeSelector {
|
||||
querySelector(selectors: "a"): HTMLAnchorElement;
|
||||
querySelector(selectors: "abbr"): HTMLElement;
|
||||
querySelector(selectors: "acronym"): HTMLElement;
|
||||
querySelector(selectors: "address"): HTMLElement;
|
||||
querySelector(selectors: "applet"): HTMLAppletElement;
|
||||
querySelector(selectors: "area"): HTMLAreaElement;
|
||||
querySelector(selectors: "article"): HTMLElement;
|
||||
querySelector(selectors: "aside"): HTMLElement;
|
||||
querySelector(selectors: "audio"): HTMLAudioElement;
|
||||
querySelector(selectors: "b"): HTMLElement;
|
||||
querySelector(selectors: "base"): HTMLBaseElement;
|
||||
querySelector(selectors: "basefont"): HTMLBaseFontElement;
|
||||
querySelector(selectors: "bdo"): HTMLElement;
|
||||
querySelector(selectors: "big"): HTMLElement;
|
||||
querySelector(selectors: "blockquote"): HTMLQuoteElement;
|
||||
querySelector(selectors: "body"): HTMLBodyElement;
|
||||
querySelector(selectors: "br"): HTMLBRElement;
|
||||
querySelector(selectors: "button"): HTMLButtonElement;
|
||||
querySelector(selectors: "canvas"): HTMLCanvasElement;
|
||||
querySelector(selectors: "caption"): HTMLTableCaptionElement;
|
||||
querySelector(selectors: "center"): HTMLElement;
|
||||
querySelector(selectors: "circle"): SVGCircleElement;
|
||||
querySelector(selectors: "cite"): HTMLElement;
|
||||
querySelector(selectors: "clippath"): SVGClipPathElement;
|
||||
querySelector(selectors: "code"): HTMLElement;
|
||||
querySelector(selectors: "col"): HTMLTableColElement;
|
||||
querySelector(selectors: "colgroup"): HTMLTableColElement;
|
||||
querySelector(selectors: "datalist"): HTMLDataListElement;
|
||||
querySelector(selectors: "dd"): HTMLElement;
|
||||
querySelector(selectors: "defs"): SVGDefsElement;
|
||||
querySelector(selectors: "del"): HTMLModElement;
|
||||
querySelector(selectors: "desc"): SVGDescElement;
|
||||
querySelector(selectors: "dfn"): HTMLElement;
|
||||
querySelector(selectors: "dir"): HTMLDirectoryElement;
|
||||
querySelector(selectors: "div"): HTMLDivElement;
|
||||
querySelector(selectors: "dl"): HTMLDListElement;
|
||||
querySelector(selectors: "dt"): HTMLElement;
|
||||
querySelector(selectors: "ellipse"): SVGEllipseElement;
|
||||
querySelector(selectors: "em"): HTMLElement;
|
||||
querySelector(selectors: "embed"): HTMLEmbedElement;
|
||||
querySelector(selectors: "feblend"): SVGFEBlendElement;
|
||||
querySelector(selectors: "fecolormatrix"): SVGFEColorMatrixElement;
|
||||
querySelector(selectors: "fecomponenttransfer"): SVGFEComponentTransferElement;
|
||||
querySelector(selectors: "fecomposite"): SVGFECompositeElement;
|
||||
querySelector(selectors: "feconvolvematrix"): SVGFEConvolveMatrixElement;
|
||||
querySelector(selectors: "fediffuselighting"): SVGFEDiffuseLightingElement;
|
||||
querySelector(selectors: "fedisplacementmap"): SVGFEDisplacementMapElement;
|
||||
querySelector(selectors: "fedistantlight"): SVGFEDistantLightElement;
|
||||
querySelector(selectors: "feflood"): SVGFEFloodElement;
|
||||
querySelector(selectors: "fefunca"): SVGFEFuncAElement;
|
||||
querySelector(selectors: "fefuncb"): SVGFEFuncBElement;
|
||||
querySelector(selectors: "fefuncg"): SVGFEFuncGElement;
|
||||
querySelector(selectors: "fefuncr"): SVGFEFuncRElement;
|
||||
querySelector(selectors: "fegaussianblur"): SVGFEGaussianBlurElement;
|
||||
querySelector(selectors: "feimage"): SVGFEImageElement;
|
||||
querySelector(selectors: "femerge"): SVGFEMergeElement;
|
||||
querySelector(selectors: "femergenode"): SVGFEMergeNodeElement;
|
||||
querySelector(selectors: "femorphology"): SVGFEMorphologyElement;
|
||||
querySelector(selectors: "feoffset"): SVGFEOffsetElement;
|
||||
querySelector(selectors: "fepointlight"): SVGFEPointLightElement;
|
||||
querySelector(selectors: "fespecularlighting"): SVGFESpecularLightingElement;
|
||||
querySelector(selectors: "fespotlight"): SVGFESpotLightElement;
|
||||
querySelector(selectors: "fetile"): SVGFETileElement;
|
||||
querySelector(selectors: "feturbulence"): SVGFETurbulenceElement;
|
||||
querySelector(selectors: "fieldset"): HTMLFieldSetElement;
|
||||
querySelector(selectors: "figcaption"): HTMLElement;
|
||||
querySelector(selectors: "figure"): HTMLElement;
|
||||
querySelector(selectors: "filter"): SVGFilterElement;
|
||||
querySelector(selectors: "font"): HTMLFontElement;
|
||||
querySelector(selectors: "footer"): HTMLElement;
|
||||
querySelector(selectors: "foreignobject"): SVGForeignObjectElement;
|
||||
querySelector(selectors: "form"): HTMLFormElement;
|
||||
querySelector(selectors: "frame"): HTMLFrameElement;
|
||||
querySelector(selectors: "frameset"): HTMLFrameSetElement;
|
||||
querySelector(selectors: "g"): SVGGElement;
|
||||
querySelector(selectors: "h1"): HTMLHeadingElement;
|
||||
querySelector(selectors: "h2"): HTMLHeadingElement;
|
||||
querySelector(selectors: "h3"): HTMLHeadingElement;
|
||||
querySelector(selectors: "h4"): HTMLHeadingElement;
|
||||
querySelector(selectors: "h5"): HTMLHeadingElement;
|
||||
querySelector(selectors: "h6"): HTMLHeadingElement;
|
||||
querySelector(selectors: "head"): HTMLHeadElement;
|
||||
querySelector(selectors: "header"): HTMLElement;
|
||||
querySelector(selectors: "hgroup"): HTMLElement;
|
||||
querySelector(selectors: "hr"): HTMLHRElement;
|
||||
querySelector(selectors: "html"): HTMLHtmlElement;
|
||||
querySelector(selectors: "i"): HTMLElement;
|
||||
querySelector(selectors: "iframe"): HTMLIFrameElement;
|
||||
querySelector(selectors: "image"): SVGImageElement;
|
||||
querySelector(selectors: "img"): HTMLImageElement;
|
||||
querySelector(selectors: "input"): HTMLInputElement;
|
||||
querySelector(selectors: "ins"): HTMLModElement;
|
||||
querySelector(selectors: "isindex"): HTMLUnknownElement;
|
||||
querySelector(selectors: "kbd"): HTMLElement;
|
||||
querySelector(selectors: "keygen"): HTMLElement;
|
||||
querySelector(selectors: "label"): HTMLLabelElement;
|
||||
querySelector(selectors: "legend"): HTMLLegendElement;
|
||||
querySelector(selectors: "li"): HTMLLIElement;
|
||||
querySelector(selectors: "line"): SVGLineElement;
|
||||
querySelector(selectors: "lineargradient"): SVGLinearGradientElement;
|
||||
querySelector(selectors: "link"): HTMLLinkElement;
|
||||
querySelector(selectors: "listing"): HTMLPreElement;
|
||||
querySelector(selectors: "map"): HTMLMapElement;
|
||||
querySelector(selectors: "mark"): HTMLElement;
|
||||
querySelector(selectors: "marker"): SVGMarkerElement;
|
||||
querySelector(selectors: "marquee"): HTMLMarqueeElement;
|
||||
querySelector(selectors: "mask"): SVGMaskElement;
|
||||
querySelector(selectors: "menu"): HTMLMenuElement;
|
||||
querySelector(selectors: "meta"): HTMLMetaElement;
|
||||
querySelector(selectors: "metadata"): SVGMetadataElement;
|
||||
querySelector(selectors: "meter"): HTMLMeterElement;
|
||||
querySelector(selectors: "nav"): HTMLElement;
|
||||
querySelector(selectors: "nextid"): HTMLUnknownElement;
|
||||
querySelector(selectors: "nobr"): HTMLElement;
|
||||
querySelector(selectors: "noframes"): HTMLElement;
|
||||
querySelector(selectors: "noscript"): HTMLElement;
|
||||
querySelector(selectors: "object"): HTMLObjectElement;
|
||||
querySelector(selectors: "ol"): HTMLOListElement;
|
||||
querySelector(selectors: "optgroup"): HTMLOptGroupElement;
|
||||
querySelector(selectors: "option"): HTMLOptionElement;
|
||||
querySelector(selectors: "p"): HTMLParagraphElement;
|
||||
querySelector(selectors: "param"): HTMLParamElement;
|
||||
querySelector(selectors: "path"): SVGPathElement;
|
||||
querySelector(selectors: "pattern"): SVGPatternElement;
|
||||
querySelector(selectors: "picture"): HTMLPictureElement;
|
||||
querySelector(selectors: "plaintext"): HTMLElement;
|
||||
querySelector(selectors: "polygon"): SVGPolygonElement;
|
||||
querySelector(selectors: "polyline"): SVGPolylineElement;
|
||||
querySelector(selectors: "pre"): HTMLPreElement;
|
||||
querySelector(selectors: "progress"): HTMLProgressElement;
|
||||
querySelector(selectors: "q"): HTMLQuoteElement;
|
||||
querySelector(selectors: "radialgradient"): SVGRadialGradientElement;
|
||||
querySelector(selectors: "rect"): SVGRectElement;
|
||||
querySelector(selectors: "rt"): HTMLElement;
|
||||
querySelector(selectors: "ruby"): HTMLElement;
|
||||
querySelector(selectors: "s"): HTMLElement;
|
||||
querySelector(selectors: "samp"): HTMLElement;
|
||||
querySelector(selectors: "script"): HTMLScriptElement;
|
||||
querySelector(selectors: "section"): HTMLElement;
|
||||
querySelector(selectors: "select"): HTMLSelectElement;
|
||||
querySelector(selectors: "small"): HTMLElement;
|
||||
querySelector(selectors: "source"): HTMLSourceElement;
|
||||
querySelector(selectors: "span"): HTMLSpanElement;
|
||||
querySelector(selectors: "stop"): SVGStopElement;
|
||||
querySelector(selectors: "strike"): HTMLElement;
|
||||
querySelector(selectors: "strong"): HTMLElement;
|
||||
querySelector(selectors: "style"): HTMLStyleElement;
|
||||
querySelector(selectors: "sub"): HTMLElement;
|
||||
querySelector(selectors: "sup"): HTMLElement;
|
||||
querySelector(selectors: "svg"): SVGSVGElement;
|
||||
querySelector(selectors: "switch"): SVGSwitchElement;
|
||||
querySelector(selectors: "symbol"): SVGSymbolElement;
|
||||
querySelector(selectors: "table"): HTMLTableElement;
|
||||
querySelector(selectors: "tbody"): HTMLTableSectionElement;
|
||||
querySelector(selectors: "td"): HTMLTableDataCellElement;
|
||||
querySelector(selectors: "template"): HTMLTemplateElement;
|
||||
querySelector(selectors: "text"): SVGTextElement;
|
||||
querySelector(selectors: "textpath"): SVGTextPathElement;
|
||||
querySelector(selectors: "textarea"): HTMLTextAreaElement;
|
||||
querySelector(selectors: "tfoot"): HTMLTableSectionElement;
|
||||
querySelector(selectors: "th"): HTMLTableHeaderCellElement;
|
||||
querySelector(selectors: "thead"): HTMLTableSectionElement;
|
||||
querySelector(selectors: "title"): HTMLTitleElement;
|
||||
querySelector(selectors: "tr"): HTMLTableRowElement;
|
||||
querySelector(selectors: "track"): HTMLTrackElement;
|
||||
querySelector(selectors: "tspan"): SVGTSpanElement;
|
||||
querySelector(selectors: "tt"): HTMLElement;
|
||||
querySelector(selectors: "u"): HTMLElement;
|
||||
querySelector(selectors: "ul"): HTMLUListElement;
|
||||
querySelector(selectors: "use"): SVGUseElement;
|
||||
querySelector(selectors: "var"): HTMLElement;
|
||||
querySelector(selectors: "video"): HTMLVideoElement;
|
||||
querySelector(selectors: "view"): SVGViewElement;
|
||||
querySelector(selectors: "wbr"): HTMLElement;
|
||||
querySelector(selectors: "x-ms-webview"): MSHTMLWebViewElement;
|
||||
querySelector(selectors: "xmp"): HTMLPreElement;
|
||||
querySelector(selectors: string): Element;
|
||||
querySelector(selectors: "a"): HTMLAnchorElement | null;
|
||||
querySelector(selectors: "abbr"): HTMLElement | null;
|
||||
querySelector(selectors: "acronym"): HTMLElement | null;
|
||||
querySelector(selectors: "address"): HTMLElement | null;
|
||||
querySelector(selectors: "applet"): HTMLAppletElement | null;
|
||||
querySelector(selectors: "area"): HTMLAreaElement | null;
|
||||
querySelector(selectors: "article"): HTMLElement | null;
|
||||
querySelector(selectors: "aside"): HTMLElement | null;
|
||||
querySelector(selectors: "audio"): HTMLAudioElement | null;
|
||||
querySelector(selectors: "b"): HTMLElement | null;
|
||||
querySelector(selectors: "base"): HTMLBaseElement | null;
|
||||
querySelector(selectors: "basefont"): HTMLBaseFontElement | null;
|
||||
querySelector(selectors: "bdo"): HTMLElement | null;
|
||||
querySelector(selectors: "big"): HTMLElement | null;
|
||||
querySelector(selectors: "blockquote"): HTMLQuoteElement | null;
|
||||
querySelector(selectors: "body"): HTMLBodyElement | null;
|
||||
querySelector(selectors: "br"): HTMLBRElement | null;
|
||||
querySelector(selectors: "button"): HTMLButtonElement | null;
|
||||
querySelector(selectors: "canvas"): HTMLCanvasElement | null;
|
||||
querySelector(selectors: "caption"): HTMLTableCaptionElement | null;
|
||||
querySelector(selectors: "center"): HTMLElement | null;
|
||||
querySelector(selectors: "circle"): SVGCircleElement | null;
|
||||
querySelector(selectors: "cite"): HTMLElement | null;
|
||||
querySelector(selectors: "clippath"): SVGClipPathElement | null;
|
||||
querySelector(selectors: "code"): HTMLElement | null;
|
||||
querySelector(selectors: "col"): HTMLTableColElement | null;
|
||||
querySelector(selectors: "colgroup"): HTMLTableColElement | null;
|
||||
querySelector(selectors: "datalist"): HTMLDataListElement | null;
|
||||
querySelector(selectors: "dd"): HTMLElement | null;
|
||||
querySelector(selectors: "defs"): SVGDefsElement | null;
|
||||
querySelector(selectors: "del"): HTMLModElement | null;
|
||||
querySelector(selectors: "desc"): SVGDescElement | null;
|
||||
querySelector(selectors: "dfn"): HTMLElement | null;
|
||||
querySelector(selectors: "dir"): HTMLDirectoryElement | null;
|
||||
querySelector(selectors: "div"): HTMLDivElement | null;
|
||||
querySelector(selectors: "dl"): HTMLDListElement | null;
|
||||
querySelector(selectors: "dt"): HTMLElement | null;
|
||||
querySelector(selectors: "ellipse"): SVGEllipseElement | null;
|
||||
querySelector(selectors: "em"): HTMLElement | null;
|
||||
querySelector(selectors: "embed"): HTMLEmbedElement | null;
|
||||
querySelector(selectors: "feblend"): SVGFEBlendElement | null;
|
||||
querySelector(selectors: "fecolormatrix"): SVGFEColorMatrixElement | null;
|
||||
querySelector(selectors: "fecomponenttransfer"): SVGFEComponentTransferElement | null;
|
||||
querySelector(selectors: "fecomposite"): SVGFECompositeElement | null;
|
||||
querySelector(selectors: "feconvolvematrix"): SVGFEConvolveMatrixElement | null;
|
||||
querySelector(selectors: "fediffuselighting"): SVGFEDiffuseLightingElement | null;
|
||||
querySelector(selectors: "fedisplacementmap"): SVGFEDisplacementMapElement | null;
|
||||
querySelector(selectors: "fedistantlight"): SVGFEDistantLightElement | null;
|
||||
querySelector(selectors: "feflood"): SVGFEFloodElement | null;
|
||||
querySelector(selectors: "fefunca"): SVGFEFuncAElement | null;
|
||||
querySelector(selectors: "fefuncb"): SVGFEFuncBElement | null;
|
||||
querySelector(selectors: "fefuncg"): SVGFEFuncGElement | null;
|
||||
querySelector(selectors: "fefuncr"): SVGFEFuncRElement | null;
|
||||
querySelector(selectors: "fegaussianblur"): SVGFEGaussianBlurElement | null;
|
||||
querySelector(selectors: "feimage"): SVGFEImageElement | null;
|
||||
querySelector(selectors: "femerge"): SVGFEMergeElement | null;
|
||||
querySelector(selectors: "femergenode"): SVGFEMergeNodeElement | null;
|
||||
querySelector(selectors: "femorphology"): SVGFEMorphologyElement | null;
|
||||
querySelector(selectors: "feoffset"): SVGFEOffsetElement | null;
|
||||
querySelector(selectors: "fepointlight"): SVGFEPointLightElement | null;
|
||||
querySelector(selectors: "fespecularlighting"): SVGFESpecularLightingElement | null;
|
||||
querySelector(selectors: "fespotlight"): SVGFESpotLightElement | null;
|
||||
querySelector(selectors: "fetile"): SVGFETileElement | null;
|
||||
querySelector(selectors: "feturbulence"): SVGFETurbulenceElement | null;
|
||||
querySelector(selectors: "fieldset"): HTMLFieldSetElement | null;
|
||||
querySelector(selectors: "figcaption"): HTMLElement | null;
|
||||
querySelector(selectors: "figure"): HTMLElement | null;
|
||||
querySelector(selectors: "filter"): SVGFilterElement | null;
|
||||
querySelector(selectors: "font"): HTMLFontElement | null;
|
||||
querySelector(selectors: "footer"): HTMLElement | null;
|
||||
querySelector(selectors: "foreignobject"): SVGForeignObjectElement | null;
|
||||
querySelector(selectors: "form"): HTMLFormElement | null;
|
||||
querySelector(selectors: "frame"): HTMLFrameElement | null;
|
||||
querySelector(selectors: "frameset"): HTMLFrameSetElement | null;
|
||||
querySelector(selectors: "g"): SVGGElement | null;
|
||||
querySelector(selectors: "h1"): HTMLHeadingElement | null;
|
||||
querySelector(selectors: "h2"): HTMLHeadingElement | null;
|
||||
querySelector(selectors: "h3"): HTMLHeadingElement | null;
|
||||
querySelector(selectors: "h4"): HTMLHeadingElement | null;
|
||||
querySelector(selectors: "h5"): HTMLHeadingElement | null;
|
||||
querySelector(selectors: "h6"): HTMLHeadingElement | null;
|
||||
querySelector(selectors: "head"): HTMLHeadElement | null;
|
||||
querySelector(selectors: "header"): HTMLElement | null;
|
||||
querySelector(selectors: "hgroup"): HTMLElement | null;
|
||||
querySelector(selectors: "hr"): HTMLHRElement | null;
|
||||
querySelector(selectors: "html"): HTMLHtmlElement | null;
|
||||
querySelector(selectors: "i"): HTMLElement | null;
|
||||
querySelector(selectors: "iframe"): HTMLIFrameElement | null;
|
||||
querySelector(selectors: "image"): SVGImageElement | null;
|
||||
querySelector(selectors: "img"): HTMLImageElement | null;
|
||||
querySelector(selectors: "input"): HTMLInputElement | null;
|
||||
querySelector(selectors: "ins"): HTMLModElement | null;
|
||||
querySelector(selectors: "isindex"): HTMLUnknownElement | null;
|
||||
querySelector(selectors: "kbd"): HTMLElement | null;
|
||||
querySelector(selectors: "keygen"): HTMLElement | null;
|
||||
querySelector(selectors: "label"): HTMLLabelElement | null;
|
||||
querySelector(selectors: "legend"): HTMLLegendElement | null;
|
||||
querySelector(selectors: "li"): HTMLLIElement | null;
|
||||
querySelector(selectors: "line"): SVGLineElement | null;
|
||||
querySelector(selectors: "lineargradient"): SVGLinearGradientElement | null;
|
||||
querySelector(selectors: "link"): HTMLLinkElement | null;
|
||||
querySelector(selectors: "listing"): HTMLPreElement | null;
|
||||
querySelector(selectors: "map"): HTMLMapElement | null;
|
||||
querySelector(selectors: "mark"): HTMLElement | null;
|
||||
querySelector(selectors: "marker"): SVGMarkerElement | null;
|
||||
querySelector(selectors: "marquee"): HTMLMarqueeElement | null;
|
||||
querySelector(selectors: "mask"): SVGMaskElement | null;
|
||||
querySelector(selectors: "menu"): HTMLMenuElement | null;
|
||||
querySelector(selectors: "meta"): HTMLMetaElement | null;
|
||||
querySelector(selectors: "metadata"): SVGMetadataElement | null;
|
||||
querySelector(selectors: "meter"): HTMLMeterElement | null;
|
||||
querySelector(selectors: "nav"): HTMLElement | null;
|
||||
querySelector(selectors: "nextid"): HTMLUnknownElement | null;
|
||||
querySelector(selectors: "nobr"): HTMLElement | null;
|
||||
querySelector(selectors: "noframes"): HTMLElement | null;
|
||||
querySelector(selectors: "noscript"): HTMLElement | null;
|
||||
querySelector(selectors: "object"): HTMLObjectElement | null;
|
||||
querySelector(selectors: "ol"): HTMLOListElement | null;
|
||||
querySelector(selectors: "optgroup"): HTMLOptGroupElement | null;
|
||||
querySelector(selectors: "option"): HTMLOptionElement | null;
|
||||
querySelector(selectors: "p"): HTMLParagraphElement | null;
|
||||
querySelector(selectors: "param"): HTMLParamElement | null;
|
||||
querySelector(selectors: "path"): SVGPathElement | null;
|
||||
querySelector(selectors: "pattern"): SVGPatternElement | null;
|
||||
querySelector(selectors: "picture"): HTMLPictureElement | null;
|
||||
querySelector(selectors: "plaintext"): HTMLElement | null;
|
||||
querySelector(selectors: "polygon"): SVGPolygonElement | null;
|
||||
querySelector(selectors: "polyline"): SVGPolylineElement | null;
|
||||
querySelector(selectors: "pre"): HTMLPreElement | null;
|
||||
querySelector(selectors: "progress"): HTMLProgressElement | null;
|
||||
querySelector(selectors: "q"): HTMLQuoteElement | null;
|
||||
querySelector(selectors: "radialgradient"): SVGRadialGradientElement | null;
|
||||
querySelector(selectors: "rect"): SVGRectElement | null;
|
||||
querySelector(selectors: "rt"): HTMLElement | null;
|
||||
querySelector(selectors: "ruby"): HTMLElement | null;
|
||||
querySelector(selectors: "s"): HTMLElement | null;
|
||||
querySelector(selectors: "samp"): HTMLElement | null;
|
||||
querySelector(selectors: "script"): HTMLScriptElement | null;
|
||||
querySelector(selectors: "section"): HTMLElement | null;
|
||||
querySelector(selectors: "select"): HTMLSelectElement | null;
|
||||
querySelector(selectors: "small"): HTMLElement | null;
|
||||
querySelector(selectors: "source"): HTMLSourceElement | null;
|
||||
querySelector(selectors: "span"): HTMLSpanElement | null;
|
||||
querySelector(selectors: "stop"): SVGStopElement | null;
|
||||
querySelector(selectors: "strike"): HTMLElement | null;
|
||||
querySelector(selectors: "strong"): HTMLElement | null;
|
||||
querySelector(selectors: "style"): HTMLStyleElement | null;
|
||||
querySelector(selectors: "sub"): HTMLElement | null;
|
||||
querySelector(selectors: "sup"): HTMLElement | null;
|
||||
querySelector(selectors: "svg"): SVGSVGElement | null;
|
||||
querySelector(selectors: "switch"): SVGSwitchElement | null;
|
||||
querySelector(selectors: "symbol"): SVGSymbolElement | null;
|
||||
querySelector(selectors: "table"): HTMLTableElement | null;
|
||||
querySelector(selectors: "tbody"): HTMLTableSectionElement | null;
|
||||
querySelector(selectors: "td"): HTMLTableDataCellElement | null;
|
||||
querySelector(selectors: "template"): HTMLTemplateElement | null;
|
||||
querySelector(selectors: "text"): SVGTextElement | null;
|
||||
querySelector(selectors: "textpath"): SVGTextPathElement | null;
|
||||
querySelector(selectors: "textarea"): HTMLTextAreaElement | null;
|
||||
querySelector(selectors: "tfoot"): HTMLTableSectionElement | null;
|
||||
querySelector(selectors: "th"): HTMLTableHeaderCellElement | null;
|
||||
querySelector(selectors: "thead"): HTMLTableSectionElement | null;
|
||||
querySelector(selectors: "title"): HTMLTitleElement | null;
|
||||
querySelector(selectors: "tr"): HTMLTableRowElement | null;
|
||||
querySelector(selectors: "track"): HTMLTrackElement | null;
|
||||
querySelector(selectors: "tspan"): SVGTSpanElement | null;
|
||||
querySelector(selectors: "tt"): HTMLElement | null;
|
||||
querySelector(selectors: "u"): HTMLElement | null;
|
||||
querySelector(selectors: "ul"): HTMLUListElement | null;
|
||||
querySelector(selectors: "use"): SVGUseElement | null;
|
||||
querySelector(selectors: "var"): HTMLElement | null;
|
||||
querySelector(selectors: "video"): HTMLVideoElement | null;
|
||||
querySelector(selectors: "view"): SVGViewElement | null;
|
||||
querySelector(selectors: "wbr"): HTMLElement | null;
|
||||
querySelector(selectors: "x-ms-webview"): MSHTMLWebViewElement | null;
|
||||
querySelector(selectors: "xmp"): HTMLPreElement | null;
|
||||
querySelector(selectors: string): Element | null;
|
||||
querySelectorAll(selectors: "a"): NodeListOf<HTMLAnchorElement>;
|
||||
querySelectorAll(selectors: "abbr"): NodeListOf<HTMLElement>;
|
||||
querySelectorAll(selectors: "acronym"): NodeListOf<HTMLElement>;
|
||||
@@ -18747,11 +18780,16 @@ type ScrollLogicalPosition = "start" | "center" | "end" | "nearest";
|
||||
type IDBValidKey = number | string | Date | IDBArrayKey;
|
||||
type BufferSource = ArrayBuffer | ArrayBufferView;
|
||||
type MouseWheelEvent = WheelEvent;
|
||||
type ScrollRestoration = "auto" | "manual";
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
/// WorkerGlobalScope APIs
|
||||
/////////////////////////////
|
||||
// These are only available in a Web Worker
|
||||
declare function importScripts(...urls: string[]): void;
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
|
||||
Vendored
+195
-190
@@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
/// IE DOM APIs
|
||||
@@ -7552,11 +7556,12 @@ declare var HashChangeEvent: {
|
||||
interface History {
|
||||
readonly length: number;
|
||||
readonly state: any;
|
||||
back(distance?: any): void;
|
||||
forward(distance?: any): void;
|
||||
go(delta?: any): void;
|
||||
pushState(statedata: any, title?: string, url?: string): void;
|
||||
replaceState(statedata: any, title?: string, url?: string): void;
|
||||
scrollRestoration: ScrollRestoration;
|
||||
back(): void;
|
||||
forward(): void;
|
||||
go(delta?: number): void;
|
||||
pushState(data: any, title: string, url?: string | null): void;
|
||||
replaceState(data: any, title: string, url?: string | null): void;
|
||||
}
|
||||
|
||||
declare var History: {
|
||||
@@ -13128,7 +13133,6 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window
|
||||
addEventListener(type: "waiting", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "wheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
[index: number]: Window;
|
||||
}
|
||||
|
||||
declare var Window: {
|
||||
@@ -13159,7 +13163,7 @@ declare var XMLDocument: {
|
||||
}
|
||||
|
||||
interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
|
||||
onreadystatechange: (this: this, ev: ProgressEvent) => any;
|
||||
onreadystatechange: (this: this, ev: Event) => any;
|
||||
readonly readyState: number;
|
||||
readonly response: any;
|
||||
readonly responseText: string;
|
||||
@@ -13186,13 +13190,13 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
|
||||
readonly LOADING: number;
|
||||
readonly OPENED: number;
|
||||
readonly UNSENT: number;
|
||||
addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "abort", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "load", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadend", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadstart", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "readystatechange", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "readystatechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "timeout", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
@@ -13533,183 +13537,183 @@ interface NavigatorUserMedia {
|
||||
}
|
||||
|
||||
interface NodeSelector {
|
||||
querySelector(selectors: "a"): HTMLAnchorElement;
|
||||
querySelector(selectors: "abbr"): HTMLElement;
|
||||
querySelector(selectors: "acronym"): HTMLElement;
|
||||
querySelector(selectors: "address"): HTMLElement;
|
||||
querySelector(selectors: "applet"): HTMLAppletElement;
|
||||
querySelector(selectors: "area"): HTMLAreaElement;
|
||||
querySelector(selectors: "article"): HTMLElement;
|
||||
querySelector(selectors: "aside"): HTMLElement;
|
||||
querySelector(selectors: "audio"): HTMLAudioElement;
|
||||
querySelector(selectors: "b"): HTMLElement;
|
||||
querySelector(selectors: "base"): HTMLBaseElement;
|
||||
querySelector(selectors: "basefont"): HTMLBaseFontElement;
|
||||
querySelector(selectors: "bdo"): HTMLElement;
|
||||
querySelector(selectors: "big"): HTMLElement;
|
||||
querySelector(selectors: "blockquote"): HTMLQuoteElement;
|
||||
querySelector(selectors: "body"): HTMLBodyElement;
|
||||
querySelector(selectors: "br"): HTMLBRElement;
|
||||
querySelector(selectors: "button"): HTMLButtonElement;
|
||||
querySelector(selectors: "canvas"): HTMLCanvasElement;
|
||||
querySelector(selectors: "caption"): HTMLTableCaptionElement;
|
||||
querySelector(selectors: "center"): HTMLElement;
|
||||
querySelector(selectors: "circle"): SVGCircleElement;
|
||||
querySelector(selectors: "cite"): HTMLElement;
|
||||
querySelector(selectors: "clippath"): SVGClipPathElement;
|
||||
querySelector(selectors: "code"): HTMLElement;
|
||||
querySelector(selectors: "col"): HTMLTableColElement;
|
||||
querySelector(selectors: "colgroup"): HTMLTableColElement;
|
||||
querySelector(selectors: "datalist"): HTMLDataListElement;
|
||||
querySelector(selectors: "dd"): HTMLElement;
|
||||
querySelector(selectors: "defs"): SVGDefsElement;
|
||||
querySelector(selectors: "del"): HTMLModElement;
|
||||
querySelector(selectors: "desc"): SVGDescElement;
|
||||
querySelector(selectors: "dfn"): HTMLElement;
|
||||
querySelector(selectors: "dir"): HTMLDirectoryElement;
|
||||
querySelector(selectors: "div"): HTMLDivElement;
|
||||
querySelector(selectors: "dl"): HTMLDListElement;
|
||||
querySelector(selectors: "dt"): HTMLElement;
|
||||
querySelector(selectors: "ellipse"): SVGEllipseElement;
|
||||
querySelector(selectors: "em"): HTMLElement;
|
||||
querySelector(selectors: "embed"): HTMLEmbedElement;
|
||||
querySelector(selectors: "feblend"): SVGFEBlendElement;
|
||||
querySelector(selectors: "fecolormatrix"): SVGFEColorMatrixElement;
|
||||
querySelector(selectors: "fecomponenttransfer"): SVGFEComponentTransferElement;
|
||||
querySelector(selectors: "fecomposite"): SVGFECompositeElement;
|
||||
querySelector(selectors: "feconvolvematrix"): SVGFEConvolveMatrixElement;
|
||||
querySelector(selectors: "fediffuselighting"): SVGFEDiffuseLightingElement;
|
||||
querySelector(selectors: "fedisplacementmap"): SVGFEDisplacementMapElement;
|
||||
querySelector(selectors: "fedistantlight"): SVGFEDistantLightElement;
|
||||
querySelector(selectors: "feflood"): SVGFEFloodElement;
|
||||
querySelector(selectors: "fefunca"): SVGFEFuncAElement;
|
||||
querySelector(selectors: "fefuncb"): SVGFEFuncBElement;
|
||||
querySelector(selectors: "fefuncg"): SVGFEFuncGElement;
|
||||
querySelector(selectors: "fefuncr"): SVGFEFuncRElement;
|
||||
querySelector(selectors: "fegaussianblur"): SVGFEGaussianBlurElement;
|
||||
querySelector(selectors: "feimage"): SVGFEImageElement;
|
||||
querySelector(selectors: "femerge"): SVGFEMergeElement;
|
||||
querySelector(selectors: "femergenode"): SVGFEMergeNodeElement;
|
||||
querySelector(selectors: "femorphology"): SVGFEMorphologyElement;
|
||||
querySelector(selectors: "feoffset"): SVGFEOffsetElement;
|
||||
querySelector(selectors: "fepointlight"): SVGFEPointLightElement;
|
||||
querySelector(selectors: "fespecularlighting"): SVGFESpecularLightingElement;
|
||||
querySelector(selectors: "fespotlight"): SVGFESpotLightElement;
|
||||
querySelector(selectors: "fetile"): SVGFETileElement;
|
||||
querySelector(selectors: "feturbulence"): SVGFETurbulenceElement;
|
||||
querySelector(selectors: "fieldset"): HTMLFieldSetElement;
|
||||
querySelector(selectors: "figcaption"): HTMLElement;
|
||||
querySelector(selectors: "figure"): HTMLElement;
|
||||
querySelector(selectors: "filter"): SVGFilterElement;
|
||||
querySelector(selectors: "font"): HTMLFontElement;
|
||||
querySelector(selectors: "footer"): HTMLElement;
|
||||
querySelector(selectors: "foreignobject"): SVGForeignObjectElement;
|
||||
querySelector(selectors: "form"): HTMLFormElement;
|
||||
querySelector(selectors: "frame"): HTMLFrameElement;
|
||||
querySelector(selectors: "frameset"): HTMLFrameSetElement;
|
||||
querySelector(selectors: "g"): SVGGElement;
|
||||
querySelector(selectors: "h1"): HTMLHeadingElement;
|
||||
querySelector(selectors: "h2"): HTMLHeadingElement;
|
||||
querySelector(selectors: "h3"): HTMLHeadingElement;
|
||||
querySelector(selectors: "h4"): HTMLHeadingElement;
|
||||
querySelector(selectors: "h5"): HTMLHeadingElement;
|
||||
querySelector(selectors: "h6"): HTMLHeadingElement;
|
||||
querySelector(selectors: "head"): HTMLHeadElement;
|
||||
querySelector(selectors: "header"): HTMLElement;
|
||||
querySelector(selectors: "hgroup"): HTMLElement;
|
||||
querySelector(selectors: "hr"): HTMLHRElement;
|
||||
querySelector(selectors: "html"): HTMLHtmlElement;
|
||||
querySelector(selectors: "i"): HTMLElement;
|
||||
querySelector(selectors: "iframe"): HTMLIFrameElement;
|
||||
querySelector(selectors: "image"): SVGImageElement;
|
||||
querySelector(selectors: "img"): HTMLImageElement;
|
||||
querySelector(selectors: "input"): HTMLInputElement;
|
||||
querySelector(selectors: "ins"): HTMLModElement;
|
||||
querySelector(selectors: "isindex"): HTMLUnknownElement;
|
||||
querySelector(selectors: "kbd"): HTMLElement;
|
||||
querySelector(selectors: "keygen"): HTMLElement;
|
||||
querySelector(selectors: "label"): HTMLLabelElement;
|
||||
querySelector(selectors: "legend"): HTMLLegendElement;
|
||||
querySelector(selectors: "li"): HTMLLIElement;
|
||||
querySelector(selectors: "line"): SVGLineElement;
|
||||
querySelector(selectors: "lineargradient"): SVGLinearGradientElement;
|
||||
querySelector(selectors: "link"): HTMLLinkElement;
|
||||
querySelector(selectors: "listing"): HTMLPreElement;
|
||||
querySelector(selectors: "map"): HTMLMapElement;
|
||||
querySelector(selectors: "mark"): HTMLElement;
|
||||
querySelector(selectors: "marker"): SVGMarkerElement;
|
||||
querySelector(selectors: "marquee"): HTMLMarqueeElement;
|
||||
querySelector(selectors: "mask"): SVGMaskElement;
|
||||
querySelector(selectors: "menu"): HTMLMenuElement;
|
||||
querySelector(selectors: "meta"): HTMLMetaElement;
|
||||
querySelector(selectors: "metadata"): SVGMetadataElement;
|
||||
querySelector(selectors: "meter"): HTMLMeterElement;
|
||||
querySelector(selectors: "nav"): HTMLElement;
|
||||
querySelector(selectors: "nextid"): HTMLUnknownElement;
|
||||
querySelector(selectors: "nobr"): HTMLElement;
|
||||
querySelector(selectors: "noframes"): HTMLElement;
|
||||
querySelector(selectors: "noscript"): HTMLElement;
|
||||
querySelector(selectors: "object"): HTMLObjectElement;
|
||||
querySelector(selectors: "ol"): HTMLOListElement;
|
||||
querySelector(selectors: "optgroup"): HTMLOptGroupElement;
|
||||
querySelector(selectors: "option"): HTMLOptionElement;
|
||||
querySelector(selectors: "p"): HTMLParagraphElement;
|
||||
querySelector(selectors: "param"): HTMLParamElement;
|
||||
querySelector(selectors: "path"): SVGPathElement;
|
||||
querySelector(selectors: "pattern"): SVGPatternElement;
|
||||
querySelector(selectors: "picture"): HTMLPictureElement;
|
||||
querySelector(selectors: "plaintext"): HTMLElement;
|
||||
querySelector(selectors: "polygon"): SVGPolygonElement;
|
||||
querySelector(selectors: "polyline"): SVGPolylineElement;
|
||||
querySelector(selectors: "pre"): HTMLPreElement;
|
||||
querySelector(selectors: "progress"): HTMLProgressElement;
|
||||
querySelector(selectors: "q"): HTMLQuoteElement;
|
||||
querySelector(selectors: "radialgradient"): SVGRadialGradientElement;
|
||||
querySelector(selectors: "rect"): SVGRectElement;
|
||||
querySelector(selectors: "rt"): HTMLElement;
|
||||
querySelector(selectors: "ruby"): HTMLElement;
|
||||
querySelector(selectors: "s"): HTMLElement;
|
||||
querySelector(selectors: "samp"): HTMLElement;
|
||||
querySelector(selectors: "script"): HTMLScriptElement;
|
||||
querySelector(selectors: "section"): HTMLElement;
|
||||
querySelector(selectors: "select"): HTMLSelectElement;
|
||||
querySelector(selectors: "small"): HTMLElement;
|
||||
querySelector(selectors: "source"): HTMLSourceElement;
|
||||
querySelector(selectors: "span"): HTMLSpanElement;
|
||||
querySelector(selectors: "stop"): SVGStopElement;
|
||||
querySelector(selectors: "strike"): HTMLElement;
|
||||
querySelector(selectors: "strong"): HTMLElement;
|
||||
querySelector(selectors: "style"): HTMLStyleElement;
|
||||
querySelector(selectors: "sub"): HTMLElement;
|
||||
querySelector(selectors: "sup"): HTMLElement;
|
||||
querySelector(selectors: "svg"): SVGSVGElement;
|
||||
querySelector(selectors: "switch"): SVGSwitchElement;
|
||||
querySelector(selectors: "symbol"): SVGSymbolElement;
|
||||
querySelector(selectors: "table"): HTMLTableElement;
|
||||
querySelector(selectors: "tbody"): HTMLTableSectionElement;
|
||||
querySelector(selectors: "td"): HTMLTableDataCellElement;
|
||||
querySelector(selectors: "template"): HTMLTemplateElement;
|
||||
querySelector(selectors: "text"): SVGTextElement;
|
||||
querySelector(selectors: "textpath"): SVGTextPathElement;
|
||||
querySelector(selectors: "textarea"): HTMLTextAreaElement;
|
||||
querySelector(selectors: "tfoot"): HTMLTableSectionElement;
|
||||
querySelector(selectors: "th"): HTMLTableHeaderCellElement;
|
||||
querySelector(selectors: "thead"): HTMLTableSectionElement;
|
||||
querySelector(selectors: "title"): HTMLTitleElement;
|
||||
querySelector(selectors: "tr"): HTMLTableRowElement;
|
||||
querySelector(selectors: "track"): HTMLTrackElement;
|
||||
querySelector(selectors: "tspan"): SVGTSpanElement;
|
||||
querySelector(selectors: "tt"): HTMLElement;
|
||||
querySelector(selectors: "u"): HTMLElement;
|
||||
querySelector(selectors: "ul"): HTMLUListElement;
|
||||
querySelector(selectors: "use"): SVGUseElement;
|
||||
querySelector(selectors: "var"): HTMLElement;
|
||||
querySelector(selectors: "video"): HTMLVideoElement;
|
||||
querySelector(selectors: "view"): SVGViewElement;
|
||||
querySelector(selectors: "wbr"): HTMLElement;
|
||||
querySelector(selectors: "x-ms-webview"): MSHTMLWebViewElement;
|
||||
querySelector(selectors: "xmp"): HTMLPreElement;
|
||||
querySelector(selectors: string): Element;
|
||||
querySelector(selectors: "a"): HTMLAnchorElement | null;
|
||||
querySelector(selectors: "abbr"): HTMLElement | null;
|
||||
querySelector(selectors: "acronym"): HTMLElement | null;
|
||||
querySelector(selectors: "address"): HTMLElement | null;
|
||||
querySelector(selectors: "applet"): HTMLAppletElement | null;
|
||||
querySelector(selectors: "area"): HTMLAreaElement | null;
|
||||
querySelector(selectors: "article"): HTMLElement | null;
|
||||
querySelector(selectors: "aside"): HTMLElement | null;
|
||||
querySelector(selectors: "audio"): HTMLAudioElement | null;
|
||||
querySelector(selectors: "b"): HTMLElement | null;
|
||||
querySelector(selectors: "base"): HTMLBaseElement | null;
|
||||
querySelector(selectors: "basefont"): HTMLBaseFontElement | null;
|
||||
querySelector(selectors: "bdo"): HTMLElement | null;
|
||||
querySelector(selectors: "big"): HTMLElement | null;
|
||||
querySelector(selectors: "blockquote"): HTMLQuoteElement | null;
|
||||
querySelector(selectors: "body"): HTMLBodyElement | null;
|
||||
querySelector(selectors: "br"): HTMLBRElement | null;
|
||||
querySelector(selectors: "button"): HTMLButtonElement | null;
|
||||
querySelector(selectors: "canvas"): HTMLCanvasElement | null;
|
||||
querySelector(selectors: "caption"): HTMLTableCaptionElement | null;
|
||||
querySelector(selectors: "center"): HTMLElement | null;
|
||||
querySelector(selectors: "circle"): SVGCircleElement | null;
|
||||
querySelector(selectors: "cite"): HTMLElement | null;
|
||||
querySelector(selectors: "clippath"): SVGClipPathElement | null;
|
||||
querySelector(selectors: "code"): HTMLElement | null;
|
||||
querySelector(selectors: "col"): HTMLTableColElement | null;
|
||||
querySelector(selectors: "colgroup"): HTMLTableColElement | null;
|
||||
querySelector(selectors: "datalist"): HTMLDataListElement | null;
|
||||
querySelector(selectors: "dd"): HTMLElement | null;
|
||||
querySelector(selectors: "defs"): SVGDefsElement | null;
|
||||
querySelector(selectors: "del"): HTMLModElement | null;
|
||||
querySelector(selectors: "desc"): SVGDescElement | null;
|
||||
querySelector(selectors: "dfn"): HTMLElement | null;
|
||||
querySelector(selectors: "dir"): HTMLDirectoryElement | null;
|
||||
querySelector(selectors: "div"): HTMLDivElement | null;
|
||||
querySelector(selectors: "dl"): HTMLDListElement | null;
|
||||
querySelector(selectors: "dt"): HTMLElement | null;
|
||||
querySelector(selectors: "ellipse"): SVGEllipseElement | null;
|
||||
querySelector(selectors: "em"): HTMLElement | null;
|
||||
querySelector(selectors: "embed"): HTMLEmbedElement | null;
|
||||
querySelector(selectors: "feblend"): SVGFEBlendElement | null;
|
||||
querySelector(selectors: "fecolormatrix"): SVGFEColorMatrixElement | null;
|
||||
querySelector(selectors: "fecomponenttransfer"): SVGFEComponentTransferElement | null;
|
||||
querySelector(selectors: "fecomposite"): SVGFECompositeElement | null;
|
||||
querySelector(selectors: "feconvolvematrix"): SVGFEConvolveMatrixElement | null;
|
||||
querySelector(selectors: "fediffuselighting"): SVGFEDiffuseLightingElement | null;
|
||||
querySelector(selectors: "fedisplacementmap"): SVGFEDisplacementMapElement | null;
|
||||
querySelector(selectors: "fedistantlight"): SVGFEDistantLightElement | null;
|
||||
querySelector(selectors: "feflood"): SVGFEFloodElement | null;
|
||||
querySelector(selectors: "fefunca"): SVGFEFuncAElement | null;
|
||||
querySelector(selectors: "fefuncb"): SVGFEFuncBElement | null;
|
||||
querySelector(selectors: "fefuncg"): SVGFEFuncGElement | null;
|
||||
querySelector(selectors: "fefuncr"): SVGFEFuncRElement | null;
|
||||
querySelector(selectors: "fegaussianblur"): SVGFEGaussianBlurElement | null;
|
||||
querySelector(selectors: "feimage"): SVGFEImageElement | null;
|
||||
querySelector(selectors: "femerge"): SVGFEMergeElement | null;
|
||||
querySelector(selectors: "femergenode"): SVGFEMergeNodeElement | null;
|
||||
querySelector(selectors: "femorphology"): SVGFEMorphologyElement | null;
|
||||
querySelector(selectors: "feoffset"): SVGFEOffsetElement | null;
|
||||
querySelector(selectors: "fepointlight"): SVGFEPointLightElement | null;
|
||||
querySelector(selectors: "fespecularlighting"): SVGFESpecularLightingElement | null;
|
||||
querySelector(selectors: "fespotlight"): SVGFESpotLightElement | null;
|
||||
querySelector(selectors: "fetile"): SVGFETileElement | null;
|
||||
querySelector(selectors: "feturbulence"): SVGFETurbulenceElement | null;
|
||||
querySelector(selectors: "fieldset"): HTMLFieldSetElement | null;
|
||||
querySelector(selectors: "figcaption"): HTMLElement | null;
|
||||
querySelector(selectors: "figure"): HTMLElement | null;
|
||||
querySelector(selectors: "filter"): SVGFilterElement | null;
|
||||
querySelector(selectors: "font"): HTMLFontElement | null;
|
||||
querySelector(selectors: "footer"): HTMLElement | null;
|
||||
querySelector(selectors: "foreignobject"): SVGForeignObjectElement | null;
|
||||
querySelector(selectors: "form"): HTMLFormElement | null;
|
||||
querySelector(selectors: "frame"): HTMLFrameElement | null;
|
||||
querySelector(selectors: "frameset"): HTMLFrameSetElement | null;
|
||||
querySelector(selectors: "g"): SVGGElement | null;
|
||||
querySelector(selectors: "h1"): HTMLHeadingElement | null;
|
||||
querySelector(selectors: "h2"): HTMLHeadingElement | null;
|
||||
querySelector(selectors: "h3"): HTMLHeadingElement | null;
|
||||
querySelector(selectors: "h4"): HTMLHeadingElement | null;
|
||||
querySelector(selectors: "h5"): HTMLHeadingElement | null;
|
||||
querySelector(selectors: "h6"): HTMLHeadingElement | null;
|
||||
querySelector(selectors: "head"): HTMLHeadElement | null;
|
||||
querySelector(selectors: "header"): HTMLElement | null;
|
||||
querySelector(selectors: "hgroup"): HTMLElement | null;
|
||||
querySelector(selectors: "hr"): HTMLHRElement | null;
|
||||
querySelector(selectors: "html"): HTMLHtmlElement | null;
|
||||
querySelector(selectors: "i"): HTMLElement | null;
|
||||
querySelector(selectors: "iframe"): HTMLIFrameElement | null;
|
||||
querySelector(selectors: "image"): SVGImageElement | null;
|
||||
querySelector(selectors: "img"): HTMLImageElement | null;
|
||||
querySelector(selectors: "input"): HTMLInputElement | null;
|
||||
querySelector(selectors: "ins"): HTMLModElement | null;
|
||||
querySelector(selectors: "isindex"): HTMLUnknownElement | null;
|
||||
querySelector(selectors: "kbd"): HTMLElement | null;
|
||||
querySelector(selectors: "keygen"): HTMLElement | null;
|
||||
querySelector(selectors: "label"): HTMLLabelElement | null;
|
||||
querySelector(selectors: "legend"): HTMLLegendElement | null;
|
||||
querySelector(selectors: "li"): HTMLLIElement | null;
|
||||
querySelector(selectors: "line"): SVGLineElement | null;
|
||||
querySelector(selectors: "lineargradient"): SVGLinearGradientElement | null;
|
||||
querySelector(selectors: "link"): HTMLLinkElement | null;
|
||||
querySelector(selectors: "listing"): HTMLPreElement | null;
|
||||
querySelector(selectors: "map"): HTMLMapElement | null;
|
||||
querySelector(selectors: "mark"): HTMLElement | null;
|
||||
querySelector(selectors: "marker"): SVGMarkerElement | null;
|
||||
querySelector(selectors: "marquee"): HTMLMarqueeElement | null;
|
||||
querySelector(selectors: "mask"): SVGMaskElement | null;
|
||||
querySelector(selectors: "menu"): HTMLMenuElement | null;
|
||||
querySelector(selectors: "meta"): HTMLMetaElement | null;
|
||||
querySelector(selectors: "metadata"): SVGMetadataElement | null;
|
||||
querySelector(selectors: "meter"): HTMLMeterElement | null;
|
||||
querySelector(selectors: "nav"): HTMLElement | null;
|
||||
querySelector(selectors: "nextid"): HTMLUnknownElement | null;
|
||||
querySelector(selectors: "nobr"): HTMLElement | null;
|
||||
querySelector(selectors: "noframes"): HTMLElement | null;
|
||||
querySelector(selectors: "noscript"): HTMLElement | null;
|
||||
querySelector(selectors: "object"): HTMLObjectElement | null;
|
||||
querySelector(selectors: "ol"): HTMLOListElement | null;
|
||||
querySelector(selectors: "optgroup"): HTMLOptGroupElement | null;
|
||||
querySelector(selectors: "option"): HTMLOptionElement | null;
|
||||
querySelector(selectors: "p"): HTMLParagraphElement | null;
|
||||
querySelector(selectors: "param"): HTMLParamElement | null;
|
||||
querySelector(selectors: "path"): SVGPathElement | null;
|
||||
querySelector(selectors: "pattern"): SVGPatternElement | null;
|
||||
querySelector(selectors: "picture"): HTMLPictureElement | null;
|
||||
querySelector(selectors: "plaintext"): HTMLElement | null;
|
||||
querySelector(selectors: "polygon"): SVGPolygonElement | null;
|
||||
querySelector(selectors: "polyline"): SVGPolylineElement | null;
|
||||
querySelector(selectors: "pre"): HTMLPreElement | null;
|
||||
querySelector(selectors: "progress"): HTMLProgressElement | null;
|
||||
querySelector(selectors: "q"): HTMLQuoteElement | null;
|
||||
querySelector(selectors: "radialgradient"): SVGRadialGradientElement | null;
|
||||
querySelector(selectors: "rect"): SVGRectElement | null;
|
||||
querySelector(selectors: "rt"): HTMLElement | null;
|
||||
querySelector(selectors: "ruby"): HTMLElement | null;
|
||||
querySelector(selectors: "s"): HTMLElement | null;
|
||||
querySelector(selectors: "samp"): HTMLElement | null;
|
||||
querySelector(selectors: "script"): HTMLScriptElement | null;
|
||||
querySelector(selectors: "section"): HTMLElement | null;
|
||||
querySelector(selectors: "select"): HTMLSelectElement | null;
|
||||
querySelector(selectors: "small"): HTMLElement | null;
|
||||
querySelector(selectors: "source"): HTMLSourceElement | null;
|
||||
querySelector(selectors: "span"): HTMLSpanElement | null;
|
||||
querySelector(selectors: "stop"): SVGStopElement | null;
|
||||
querySelector(selectors: "strike"): HTMLElement | null;
|
||||
querySelector(selectors: "strong"): HTMLElement | null;
|
||||
querySelector(selectors: "style"): HTMLStyleElement | null;
|
||||
querySelector(selectors: "sub"): HTMLElement | null;
|
||||
querySelector(selectors: "sup"): HTMLElement | null;
|
||||
querySelector(selectors: "svg"): SVGSVGElement | null;
|
||||
querySelector(selectors: "switch"): SVGSwitchElement | null;
|
||||
querySelector(selectors: "symbol"): SVGSymbolElement | null;
|
||||
querySelector(selectors: "table"): HTMLTableElement | null;
|
||||
querySelector(selectors: "tbody"): HTMLTableSectionElement | null;
|
||||
querySelector(selectors: "td"): HTMLTableDataCellElement | null;
|
||||
querySelector(selectors: "template"): HTMLTemplateElement | null;
|
||||
querySelector(selectors: "text"): SVGTextElement | null;
|
||||
querySelector(selectors: "textpath"): SVGTextPathElement | null;
|
||||
querySelector(selectors: "textarea"): HTMLTextAreaElement | null;
|
||||
querySelector(selectors: "tfoot"): HTMLTableSectionElement | null;
|
||||
querySelector(selectors: "th"): HTMLTableHeaderCellElement | null;
|
||||
querySelector(selectors: "thead"): HTMLTableSectionElement | null;
|
||||
querySelector(selectors: "title"): HTMLTitleElement | null;
|
||||
querySelector(selectors: "tr"): HTMLTableRowElement | null;
|
||||
querySelector(selectors: "track"): HTMLTrackElement | null;
|
||||
querySelector(selectors: "tspan"): SVGTSpanElement | null;
|
||||
querySelector(selectors: "tt"): HTMLElement | null;
|
||||
querySelector(selectors: "u"): HTMLElement | null;
|
||||
querySelector(selectors: "ul"): HTMLUListElement | null;
|
||||
querySelector(selectors: "use"): SVGUseElement | null;
|
||||
querySelector(selectors: "var"): HTMLElement | null;
|
||||
querySelector(selectors: "video"): HTMLVideoElement | null;
|
||||
querySelector(selectors: "view"): SVGViewElement | null;
|
||||
querySelector(selectors: "wbr"): HTMLElement | null;
|
||||
querySelector(selectors: "x-ms-webview"): MSHTMLWebViewElement | null;
|
||||
querySelector(selectors: "xmp"): HTMLPreElement | null;
|
||||
querySelector(selectors: string): Element | null;
|
||||
querySelectorAll(selectors: "a"): NodeListOf<HTMLAnchorElement>;
|
||||
querySelectorAll(selectors: "abbr"): NodeListOf<HTMLElement>;
|
||||
querySelectorAll(selectors: "acronym"): NodeListOf<HTMLElement>;
|
||||
@@ -14638,4 +14642,5 @@ type ScrollBehavior = "auto" | "instant" | "smooth";
|
||||
type ScrollLogicalPosition = "start" | "center" | "end" | "nearest";
|
||||
type IDBValidKey = number | string | Date | IDBArrayKey;
|
||||
type BufferSource = ArrayBuffer | ArrayBufferView;
|
||||
type MouseWheelEvent = WheelEvent;
|
||||
type MouseWheelEvent = WheelEvent;
|
||||
type ScrollRestoration = "auto" | "manual";
|
||||
Vendored
+4
@@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
/// <reference path="lib.dom.d.ts" />
|
||||
|
||||
interface DOMTokenList {
|
||||
|
||||
Vendored
+4
@@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
interface Map<K, V> {
|
||||
clear(): void;
|
||||
delete(key: K): boolean;
|
||||
|
||||
Vendored
+5
-1
@@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
declare type PropertyKey = string | number | symbol;
|
||||
|
||||
interface Array<T> {
|
||||
@@ -217,7 +221,7 @@ interface NumberConstructor {
|
||||
|
||||
/**
|
||||
* Returns true if passed value is finite.
|
||||
* Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a
|
||||
* Unlike the global isFinite, Number.isFinite doesn't forcibly convert the parameter to a
|
||||
* number. Only finite values of the type number, result in true.
|
||||
* @param number A numeric value.
|
||||
*/
|
||||
|
||||
Vendored
+4
@@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
/// <reference path="lib.es2015.core.d.ts" />
|
||||
/// <reference path="lib.es2015.collection.d.ts" />
|
||||
/// <reference path="lib.es2015.generator.d.ts" />
|
||||
|
||||
Vendored
+4
@@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
interface GeneratorFunction extends Function { }
|
||||
|
||||
interface GeneratorFunctionConstructor {
|
||||
|
||||
Vendored
+4
@@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
/// <reference path="lib.es2015.symbol.d.ts" />
|
||||
|
||||
interface SymbolConstructor {
|
||||
|
||||
Vendored
+4
@@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
/**
|
||||
* Represents the completion of an asynchronous operation
|
||||
*/
|
||||
|
||||
Vendored
+4
@@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
interface ProxyHandler<T> {
|
||||
getPrototypeOf? (target: T): any;
|
||||
setPrototypeOf? (target: T, v: any): boolean;
|
||||
|
||||
Vendored
+4
@@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
declare namespace Reflect {
|
||||
function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
|
||||
function construct(target: Function, argumentsList: ArrayLike<any>, newTarget?: any): any;
|
||||
|
||||
Vendored
+4
@@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
interface Symbol {
|
||||
/** Returns a string representation of an object. */
|
||||
toString(): string;
|
||||
|
||||
Vendored
+4
@@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
/// <reference path="lib.es2015.symbol.d.ts" />
|
||||
|
||||
interface SymbolConstructor {
|
||||
|
||||
Vendored
+4
@@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
interface Array<T> {
|
||||
/**
|
||||
* Determines whether an array includes a certain element, returning true or false as appropriate.
|
||||
|
||||
Vendored
+4
@@ -13,6 +13,10 @@ See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
/// <reference path="lib.es2015.d.ts" />
|
||||
/// <reference path="lib.es2016.array.include.d.ts" />
|
||||
Vendored
+4
@@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
/// <reference path="lib.es2016.d.ts" />
|
||||
/// <reference path="lib.es2017.object.d.ts" />
|
||||
/// <reference path="lib.es2017.sharedmemory.d.ts" />
|
||||
Vendored
+4
@@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
interface ObjectConstructor {
|
||||
/**
|
||||
* Returns an array of values of the enumerable properties of an object
|
||||
|
||||
Vendored
+4
@@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
/// <reference path="lib.es2015.symbol.d.ts" />
|
||||
/// <reference path="lib.es2015.symbol.wellknown.d.ts" />
|
||||
|
||||
|
||||
Vendored
+31
@@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
/// ECMAScript APIs
|
||||
/////////////////////////////
|
||||
@@ -260,6 +264,9 @@ interface Function {
|
||||
*/
|
||||
bind(this: Function, thisArg: any, ...argArray: any[]): any;
|
||||
|
||||
/** Returns a string representation of a function. */
|
||||
toString(): string;
|
||||
|
||||
prototype: any;
|
||||
readonly length: number;
|
||||
|
||||
@@ -1216,6 +1223,30 @@ interface Array<T> {
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void;
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map<U>(this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U];
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map<U>(this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U];
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map<U>(this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U];
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map<U>(this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U];
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
|
||||
Vendored
+254
-196
@@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
/// ECMAScript APIs
|
||||
/////////////////////////////
|
||||
@@ -260,6 +264,9 @@ interface Function {
|
||||
*/
|
||||
bind(this: Function, thisArg: any, ...argArray: any[]): any;
|
||||
|
||||
/** Returns a string representation of a function. */
|
||||
toString(): string;
|
||||
|
||||
prototype: any;
|
||||
readonly length: number;
|
||||
|
||||
@@ -1216,6 +1223,30 @@ interface Array<T> {
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void;
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map<U>(this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U];
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map<U>(this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U];
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map<U>(this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U];
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
map<U>(this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U];
|
||||
/**
|
||||
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
|
||||
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
||||
@@ -4122,6 +4153,8 @@ interface Date {
|
||||
*/
|
||||
toLocaleTimeString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string;
|
||||
}
|
||||
|
||||
|
||||
declare type PropertyKey = string | number | symbol;
|
||||
|
||||
interface Array<T> {
|
||||
@@ -4325,7 +4358,7 @@ interface NumberConstructor {
|
||||
|
||||
/**
|
||||
* Returns true if passed value is finite.
|
||||
* Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a
|
||||
* Unlike the global isFinite, Number.isFinite doesn't forcibly convert the parameter to a
|
||||
* number. Only finite values of the type number, result in true.
|
||||
* @param number A numeric value.
|
||||
*/
|
||||
@@ -4646,6 +4679,8 @@ interface StringConstructor {
|
||||
*/
|
||||
raw(template: TemplateStringsArray, ...substitutions: any[]): string;
|
||||
}
|
||||
|
||||
|
||||
interface Map<K, V> {
|
||||
clear(): void;
|
||||
delete(key: K): boolean;
|
||||
@@ -4718,6 +4753,8 @@ interface WeakSetConstructor {
|
||||
readonly prototype: WeakSet<any>;
|
||||
}
|
||||
declare var WeakSet: WeakSetConstructor;
|
||||
|
||||
|
||||
interface GeneratorFunction extends Function { }
|
||||
|
||||
interface GeneratorFunctionConstructor {
|
||||
@@ -4730,6 +4767,8 @@ interface GeneratorFunctionConstructor {
|
||||
readonly prototype: GeneratorFunction;
|
||||
}
|
||||
declare var GeneratorFunction: GeneratorFunctionConstructor;
|
||||
|
||||
|
||||
/// <reference path="lib.es2015.symbol.d.ts" />
|
||||
|
||||
interface SymbolConstructor {
|
||||
@@ -5174,7 +5213,9 @@ interface Float64ArrayConstructor {
|
||||
* @param thisArg Value of 'this' used to invoke the mapfn.
|
||||
*/
|
||||
from(arrayLike: Iterable<number>, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array;
|
||||
}/**
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the completion of an asynchronous operation
|
||||
*/
|
||||
interface Promise<T> {
|
||||
@@ -5427,7 +5468,9 @@ interface PromiseConstructor {
|
||||
resolve(): Promise<void>;
|
||||
}
|
||||
|
||||
declare var Promise: PromiseConstructor;interface ProxyHandler<T> {
|
||||
declare var Promise: PromiseConstructor;
|
||||
|
||||
interface ProxyHandler<T> {
|
||||
getPrototypeOf? (target: T): any;
|
||||
setPrototypeOf? (target: T, v: any): boolean;
|
||||
isExtensible? (target: T): boolean;
|
||||
@@ -5448,7 +5491,9 @@ interface ProxyConstructor {
|
||||
revocable<T>(target: T, handler: ProxyHandler<T>): { proxy: T; revoke: () => void; };
|
||||
new <T>(target: T, handler: ProxyHandler<T>): T
|
||||
}
|
||||
declare var Proxy: ProxyConstructor;declare namespace Reflect {
|
||||
declare var Proxy: ProxyConstructor;
|
||||
|
||||
declare namespace Reflect {
|
||||
function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
|
||||
function construct(target: Function, argumentsList: ArrayLike<any>, newTarget?: any): any;
|
||||
function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
|
||||
@@ -5462,7 +5507,9 @@ declare var Proxy: ProxyConstructor;declare namespace Reflect {
|
||||
function preventExtensions(target: any): boolean;
|
||||
function set(target: any, propertyKey: PropertyKey, value: any, receiver?: any): boolean;
|
||||
function setPrototypeOf(target: any, proto: any): boolean;
|
||||
}interface Symbol {
|
||||
}
|
||||
|
||||
interface Symbol {
|
||||
/** Returns a string representation of an object. */
|
||||
toString(): string;
|
||||
|
||||
@@ -5497,7 +5544,9 @@ interface SymbolConstructor {
|
||||
keyFor(sym: symbol): string | undefined;
|
||||
}
|
||||
|
||||
declare var Symbol: SymbolConstructor;/// <reference path="lib.es2015.symbol.d.ts" />
|
||||
declare var Symbol: SymbolConstructor;
|
||||
|
||||
/// <reference path="lib.es2015.symbol.d.ts" />
|
||||
|
||||
interface SymbolConstructor {
|
||||
/**
|
||||
@@ -5823,7 +5872,9 @@ interface Float32Array {
|
||||
*/
|
||||
interface Float64Array {
|
||||
readonly [Symbol.toStringTag]: "Float64Array";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
/// IE DOM APIs
|
||||
/////////////////////////////
|
||||
@@ -13361,11 +13412,12 @@ declare var HashChangeEvent: {
|
||||
interface History {
|
||||
readonly length: number;
|
||||
readonly state: any;
|
||||
back(distance?: any): void;
|
||||
forward(distance?: any): void;
|
||||
go(delta?: any): void;
|
||||
pushState(statedata: any, title?: string, url?: string): void;
|
||||
replaceState(statedata: any, title?: string, url?: string): void;
|
||||
scrollRestoration: ScrollRestoration;
|
||||
back(): void;
|
||||
forward(): void;
|
||||
go(delta?: number): void;
|
||||
pushState(data: any, title: string, url?: string | null): void;
|
||||
replaceState(data: any, title: string, url?: string | null): void;
|
||||
}
|
||||
|
||||
declare var History: {
|
||||
@@ -18937,7 +18989,6 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window
|
||||
addEventListener(type: "waiting", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "wheel", listener: (this: this, ev: WheelEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
[index: number]: Window;
|
||||
}
|
||||
|
||||
declare var Window: {
|
||||
@@ -18968,7 +19019,7 @@ declare var XMLDocument: {
|
||||
}
|
||||
|
||||
interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
|
||||
onreadystatechange: (this: this, ev: ProgressEvent) => any;
|
||||
onreadystatechange: (this: this, ev: Event) => any;
|
||||
readonly readyState: number;
|
||||
readonly response: any;
|
||||
readonly responseText: string;
|
||||
@@ -18995,13 +19046,13 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
|
||||
readonly LOADING: number;
|
||||
readonly OPENED: number;
|
||||
readonly UNSENT: number;
|
||||
addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "abort", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "load", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadend", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadstart", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "readystatechange", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "readystatechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "timeout", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
@@ -19342,183 +19393,183 @@ interface NavigatorUserMedia {
|
||||
}
|
||||
|
||||
interface NodeSelector {
|
||||
querySelector(selectors: "a"): HTMLAnchorElement;
|
||||
querySelector(selectors: "abbr"): HTMLElement;
|
||||
querySelector(selectors: "acronym"): HTMLElement;
|
||||
querySelector(selectors: "address"): HTMLElement;
|
||||
querySelector(selectors: "applet"): HTMLAppletElement;
|
||||
querySelector(selectors: "area"): HTMLAreaElement;
|
||||
querySelector(selectors: "article"): HTMLElement;
|
||||
querySelector(selectors: "aside"): HTMLElement;
|
||||
querySelector(selectors: "audio"): HTMLAudioElement;
|
||||
querySelector(selectors: "b"): HTMLElement;
|
||||
querySelector(selectors: "base"): HTMLBaseElement;
|
||||
querySelector(selectors: "basefont"): HTMLBaseFontElement;
|
||||
querySelector(selectors: "bdo"): HTMLElement;
|
||||
querySelector(selectors: "big"): HTMLElement;
|
||||
querySelector(selectors: "blockquote"): HTMLQuoteElement;
|
||||
querySelector(selectors: "body"): HTMLBodyElement;
|
||||
querySelector(selectors: "br"): HTMLBRElement;
|
||||
querySelector(selectors: "button"): HTMLButtonElement;
|
||||
querySelector(selectors: "canvas"): HTMLCanvasElement;
|
||||
querySelector(selectors: "caption"): HTMLTableCaptionElement;
|
||||
querySelector(selectors: "center"): HTMLElement;
|
||||
querySelector(selectors: "circle"): SVGCircleElement;
|
||||
querySelector(selectors: "cite"): HTMLElement;
|
||||
querySelector(selectors: "clippath"): SVGClipPathElement;
|
||||
querySelector(selectors: "code"): HTMLElement;
|
||||
querySelector(selectors: "col"): HTMLTableColElement;
|
||||
querySelector(selectors: "colgroup"): HTMLTableColElement;
|
||||
querySelector(selectors: "datalist"): HTMLDataListElement;
|
||||
querySelector(selectors: "dd"): HTMLElement;
|
||||
querySelector(selectors: "defs"): SVGDefsElement;
|
||||
querySelector(selectors: "del"): HTMLModElement;
|
||||
querySelector(selectors: "desc"): SVGDescElement;
|
||||
querySelector(selectors: "dfn"): HTMLElement;
|
||||
querySelector(selectors: "dir"): HTMLDirectoryElement;
|
||||
querySelector(selectors: "div"): HTMLDivElement;
|
||||
querySelector(selectors: "dl"): HTMLDListElement;
|
||||
querySelector(selectors: "dt"): HTMLElement;
|
||||
querySelector(selectors: "ellipse"): SVGEllipseElement;
|
||||
querySelector(selectors: "em"): HTMLElement;
|
||||
querySelector(selectors: "embed"): HTMLEmbedElement;
|
||||
querySelector(selectors: "feblend"): SVGFEBlendElement;
|
||||
querySelector(selectors: "fecolormatrix"): SVGFEColorMatrixElement;
|
||||
querySelector(selectors: "fecomponenttransfer"): SVGFEComponentTransferElement;
|
||||
querySelector(selectors: "fecomposite"): SVGFECompositeElement;
|
||||
querySelector(selectors: "feconvolvematrix"): SVGFEConvolveMatrixElement;
|
||||
querySelector(selectors: "fediffuselighting"): SVGFEDiffuseLightingElement;
|
||||
querySelector(selectors: "fedisplacementmap"): SVGFEDisplacementMapElement;
|
||||
querySelector(selectors: "fedistantlight"): SVGFEDistantLightElement;
|
||||
querySelector(selectors: "feflood"): SVGFEFloodElement;
|
||||
querySelector(selectors: "fefunca"): SVGFEFuncAElement;
|
||||
querySelector(selectors: "fefuncb"): SVGFEFuncBElement;
|
||||
querySelector(selectors: "fefuncg"): SVGFEFuncGElement;
|
||||
querySelector(selectors: "fefuncr"): SVGFEFuncRElement;
|
||||
querySelector(selectors: "fegaussianblur"): SVGFEGaussianBlurElement;
|
||||
querySelector(selectors: "feimage"): SVGFEImageElement;
|
||||
querySelector(selectors: "femerge"): SVGFEMergeElement;
|
||||
querySelector(selectors: "femergenode"): SVGFEMergeNodeElement;
|
||||
querySelector(selectors: "femorphology"): SVGFEMorphologyElement;
|
||||
querySelector(selectors: "feoffset"): SVGFEOffsetElement;
|
||||
querySelector(selectors: "fepointlight"): SVGFEPointLightElement;
|
||||
querySelector(selectors: "fespecularlighting"): SVGFESpecularLightingElement;
|
||||
querySelector(selectors: "fespotlight"): SVGFESpotLightElement;
|
||||
querySelector(selectors: "fetile"): SVGFETileElement;
|
||||
querySelector(selectors: "feturbulence"): SVGFETurbulenceElement;
|
||||
querySelector(selectors: "fieldset"): HTMLFieldSetElement;
|
||||
querySelector(selectors: "figcaption"): HTMLElement;
|
||||
querySelector(selectors: "figure"): HTMLElement;
|
||||
querySelector(selectors: "filter"): SVGFilterElement;
|
||||
querySelector(selectors: "font"): HTMLFontElement;
|
||||
querySelector(selectors: "footer"): HTMLElement;
|
||||
querySelector(selectors: "foreignobject"): SVGForeignObjectElement;
|
||||
querySelector(selectors: "form"): HTMLFormElement;
|
||||
querySelector(selectors: "frame"): HTMLFrameElement;
|
||||
querySelector(selectors: "frameset"): HTMLFrameSetElement;
|
||||
querySelector(selectors: "g"): SVGGElement;
|
||||
querySelector(selectors: "h1"): HTMLHeadingElement;
|
||||
querySelector(selectors: "h2"): HTMLHeadingElement;
|
||||
querySelector(selectors: "h3"): HTMLHeadingElement;
|
||||
querySelector(selectors: "h4"): HTMLHeadingElement;
|
||||
querySelector(selectors: "h5"): HTMLHeadingElement;
|
||||
querySelector(selectors: "h6"): HTMLHeadingElement;
|
||||
querySelector(selectors: "head"): HTMLHeadElement;
|
||||
querySelector(selectors: "header"): HTMLElement;
|
||||
querySelector(selectors: "hgroup"): HTMLElement;
|
||||
querySelector(selectors: "hr"): HTMLHRElement;
|
||||
querySelector(selectors: "html"): HTMLHtmlElement;
|
||||
querySelector(selectors: "i"): HTMLElement;
|
||||
querySelector(selectors: "iframe"): HTMLIFrameElement;
|
||||
querySelector(selectors: "image"): SVGImageElement;
|
||||
querySelector(selectors: "img"): HTMLImageElement;
|
||||
querySelector(selectors: "input"): HTMLInputElement;
|
||||
querySelector(selectors: "ins"): HTMLModElement;
|
||||
querySelector(selectors: "isindex"): HTMLUnknownElement;
|
||||
querySelector(selectors: "kbd"): HTMLElement;
|
||||
querySelector(selectors: "keygen"): HTMLElement;
|
||||
querySelector(selectors: "label"): HTMLLabelElement;
|
||||
querySelector(selectors: "legend"): HTMLLegendElement;
|
||||
querySelector(selectors: "li"): HTMLLIElement;
|
||||
querySelector(selectors: "line"): SVGLineElement;
|
||||
querySelector(selectors: "lineargradient"): SVGLinearGradientElement;
|
||||
querySelector(selectors: "link"): HTMLLinkElement;
|
||||
querySelector(selectors: "listing"): HTMLPreElement;
|
||||
querySelector(selectors: "map"): HTMLMapElement;
|
||||
querySelector(selectors: "mark"): HTMLElement;
|
||||
querySelector(selectors: "marker"): SVGMarkerElement;
|
||||
querySelector(selectors: "marquee"): HTMLMarqueeElement;
|
||||
querySelector(selectors: "mask"): SVGMaskElement;
|
||||
querySelector(selectors: "menu"): HTMLMenuElement;
|
||||
querySelector(selectors: "meta"): HTMLMetaElement;
|
||||
querySelector(selectors: "metadata"): SVGMetadataElement;
|
||||
querySelector(selectors: "meter"): HTMLMeterElement;
|
||||
querySelector(selectors: "nav"): HTMLElement;
|
||||
querySelector(selectors: "nextid"): HTMLUnknownElement;
|
||||
querySelector(selectors: "nobr"): HTMLElement;
|
||||
querySelector(selectors: "noframes"): HTMLElement;
|
||||
querySelector(selectors: "noscript"): HTMLElement;
|
||||
querySelector(selectors: "object"): HTMLObjectElement;
|
||||
querySelector(selectors: "ol"): HTMLOListElement;
|
||||
querySelector(selectors: "optgroup"): HTMLOptGroupElement;
|
||||
querySelector(selectors: "option"): HTMLOptionElement;
|
||||
querySelector(selectors: "p"): HTMLParagraphElement;
|
||||
querySelector(selectors: "param"): HTMLParamElement;
|
||||
querySelector(selectors: "path"): SVGPathElement;
|
||||
querySelector(selectors: "pattern"): SVGPatternElement;
|
||||
querySelector(selectors: "picture"): HTMLPictureElement;
|
||||
querySelector(selectors: "plaintext"): HTMLElement;
|
||||
querySelector(selectors: "polygon"): SVGPolygonElement;
|
||||
querySelector(selectors: "polyline"): SVGPolylineElement;
|
||||
querySelector(selectors: "pre"): HTMLPreElement;
|
||||
querySelector(selectors: "progress"): HTMLProgressElement;
|
||||
querySelector(selectors: "q"): HTMLQuoteElement;
|
||||
querySelector(selectors: "radialgradient"): SVGRadialGradientElement;
|
||||
querySelector(selectors: "rect"): SVGRectElement;
|
||||
querySelector(selectors: "rt"): HTMLElement;
|
||||
querySelector(selectors: "ruby"): HTMLElement;
|
||||
querySelector(selectors: "s"): HTMLElement;
|
||||
querySelector(selectors: "samp"): HTMLElement;
|
||||
querySelector(selectors: "script"): HTMLScriptElement;
|
||||
querySelector(selectors: "section"): HTMLElement;
|
||||
querySelector(selectors: "select"): HTMLSelectElement;
|
||||
querySelector(selectors: "small"): HTMLElement;
|
||||
querySelector(selectors: "source"): HTMLSourceElement;
|
||||
querySelector(selectors: "span"): HTMLSpanElement;
|
||||
querySelector(selectors: "stop"): SVGStopElement;
|
||||
querySelector(selectors: "strike"): HTMLElement;
|
||||
querySelector(selectors: "strong"): HTMLElement;
|
||||
querySelector(selectors: "style"): HTMLStyleElement;
|
||||
querySelector(selectors: "sub"): HTMLElement;
|
||||
querySelector(selectors: "sup"): HTMLElement;
|
||||
querySelector(selectors: "svg"): SVGSVGElement;
|
||||
querySelector(selectors: "switch"): SVGSwitchElement;
|
||||
querySelector(selectors: "symbol"): SVGSymbolElement;
|
||||
querySelector(selectors: "table"): HTMLTableElement;
|
||||
querySelector(selectors: "tbody"): HTMLTableSectionElement;
|
||||
querySelector(selectors: "td"): HTMLTableDataCellElement;
|
||||
querySelector(selectors: "template"): HTMLTemplateElement;
|
||||
querySelector(selectors: "text"): SVGTextElement;
|
||||
querySelector(selectors: "textpath"): SVGTextPathElement;
|
||||
querySelector(selectors: "textarea"): HTMLTextAreaElement;
|
||||
querySelector(selectors: "tfoot"): HTMLTableSectionElement;
|
||||
querySelector(selectors: "th"): HTMLTableHeaderCellElement;
|
||||
querySelector(selectors: "thead"): HTMLTableSectionElement;
|
||||
querySelector(selectors: "title"): HTMLTitleElement;
|
||||
querySelector(selectors: "tr"): HTMLTableRowElement;
|
||||
querySelector(selectors: "track"): HTMLTrackElement;
|
||||
querySelector(selectors: "tspan"): SVGTSpanElement;
|
||||
querySelector(selectors: "tt"): HTMLElement;
|
||||
querySelector(selectors: "u"): HTMLElement;
|
||||
querySelector(selectors: "ul"): HTMLUListElement;
|
||||
querySelector(selectors: "use"): SVGUseElement;
|
||||
querySelector(selectors: "var"): HTMLElement;
|
||||
querySelector(selectors: "video"): HTMLVideoElement;
|
||||
querySelector(selectors: "view"): SVGViewElement;
|
||||
querySelector(selectors: "wbr"): HTMLElement;
|
||||
querySelector(selectors: "x-ms-webview"): MSHTMLWebViewElement;
|
||||
querySelector(selectors: "xmp"): HTMLPreElement;
|
||||
querySelector(selectors: string): Element;
|
||||
querySelector(selectors: "a"): HTMLAnchorElement | null;
|
||||
querySelector(selectors: "abbr"): HTMLElement | null;
|
||||
querySelector(selectors: "acronym"): HTMLElement | null;
|
||||
querySelector(selectors: "address"): HTMLElement | null;
|
||||
querySelector(selectors: "applet"): HTMLAppletElement | null;
|
||||
querySelector(selectors: "area"): HTMLAreaElement | null;
|
||||
querySelector(selectors: "article"): HTMLElement | null;
|
||||
querySelector(selectors: "aside"): HTMLElement | null;
|
||||
querySelector(selectors: "audio"): HTMLAudioElement | null;
|
||||
querySelector(selectors: "b"): HTMLElement | null;
|
||||
querySelector(selectors: "base"): HTMLBaseElement | null;
|
||||
querySelector(selectors: "basefont"): HTMLBaseFontElement | null;
|
||||
querySelector(selectors: "bdo"): HTMLElement | null;
|
||||
querySelector(selectors: "big"): HTMLElement | null;
|
||||
querySelector(selectors: "blockquote"): HTMLQuoteElement | null;
|
||||
querySelector(selectors: "body"): HTMLBodyElement | null;
|
||||
querySelector(selectors: "br"): HTMLBRElement | null;
|
||||
querySelector(selectors: "button"): HTMLButtonElement | null;
|
||||
querySelector(selectors: "canvas"): HTMLCanvasElement | null;
|
||||
querySelector(selectors: "caption"): HTMLTableCaptionElement | null;
|
||||
querySelector(selectors: "center"): HTMLElement | null;
|
||||
querySelector(selectors: "circle"): SVGCircleElement | null;
|
||||
querySelector(selectors: "cite"): HTMLElement | null;
|
||||
querySelector(selectors: "clippath"): SVGClipPathElement | null;
|
||||
querySelector(selectors: "code"): HTMLElement | null;
|
||||
querySelector(selectors: "col"): HTMLTableColElement | null;
|
||||
querySelector(selectors: "colgroup"): HTMLTableColElement | null;
|
||||
querySelector(selectors: "datalist"): HTMLDataListElement | null;
|
||||
querySelector(selectors: "dd"): HTMLElement | null;
|
||||
querySelector(selectors: "defs"): SVGDefsElement | null;
|
||||
querySelector(selectors: "del"): HTMLModElement | null;
|
||||
querySelector(selectors: "desc"): SVGDescElement | null;
|
||||
querySelector(selectors: "dfn"): HTMLElement | null;
|
||||
querySelector(selectors: "dir"): HTMLDirectoryElement | null;
|
||||
querySelector(selectors: "div"): HTMLDivElement | null;
|
||||
querySelector(selectors: "dl"): HTMLDListElement | null;
|
||||
querySelector(selectors: "dt"): HTMLElement | null;
|
||||
querySelector(selectors: "ellipse"): SVGEllipseElement | null;
|
||||
querySelector(selectors: "em"): HTMLElement | null;
|
||||
querySelector(selectors: "embed"): HTMLEmbedElement | null;
|
||||
querySelector(selectors: "feblend"): SVGFEBlendElement | null;
|
||||
querySelector(selectors: "fecolormatrix"): SVGFEColorMatrixElement | null;
|
||||
querySelector(selectors: "fecomponenttransfer"): SVGFEComponentTransferElement | null;
|
||||
querySelector(selectors: "fecomposite"): SVGFECompositeElement | null;
|
||||
querySelector(selectors: "feconvolvematrix"): SVGFEConvolveMatrixElement | null;
|
||||
querySelector(selectors: "fediffuselighting"): SVGFEDiffuseLightingElement | null;
|
||||
querySelector(selectors: "fedisplacementmap"): SVGFEDisplacementMapElement | null;
|
||||
querySelector(selectors: "fedistantlight"): SVGFEDistantLightElement | null;
|
||||
querySelector(selectors: "feflood"): SVGFEFloodElement | null;
|
||||
querySelector(selectors: "fefunca"): SVGFEFuncAElement | null;
|
||||
querySelector(selectors: "fefuncb"): SVGFEFuncBElement | null;
|
||||
querySelector(selectors: "fefuncg"): SVGFEFuncGElement | null;
|
||||
querySelector(selectors: "fefuncr"): SVGFEFuncRElement | null;
|
||||
querySelector(selectors: "fegaussianblur"): SVGFEGaussianBlurElement | null;
|
||||
querySelector(selectors: "feimage"): SVGFEImageElement | null;
|
||||
querySelector(selectors: "femerge"): SVGFEMergeElement | null;
|
||||
querySelector(selectors: "femergenode"): SVGFEMergeNodeElement | null;
|
||||
querySelector(selectors: "femorphology"): SVGFEMorphologyElement | null;
|
||||
querySelector(selectors: "feoffset"): SVGFEOffsetElement | null;
|
||||
querySelector(selectors: "fepointlight"): SVGFEPointLightElement | null;
|
||||
querySelector(selectors: "fespecularlighting"): SVGFESpecularLightingElement | null;
|
||||
querySelector(selectors: "fespotlight"): SVGFESpotLightElement | null;
|
||||
querySelector(selectors: "fetile"): SVGFETileElement | null;
|
||||
querySelector(selectors: "feturbulence"): SVGFETurbulenceElement | null;
|
||||
querySelector(selectors: "fieldset"): HTMLFieldSetElement | null;
|
||||
querySelector(selectors: "figcaption"): HTMLElement | null;
|
||||
querySelector(selectors: "figure"): HTMLElement | null;
|
||||
querySelector(selectors: "filter"): SVGFilterElement | null;
|
||||
querySelector(selectors: "font"): HTMLFontElement | null;
|
||||
querySelector(selectors: "footer"): HTMLElement | null;
|
||||
querySelector(selectors: "foreignobject"): SVGForeignObjectElement | null;
|
||||
querySelector(selectors: "form"): HTMLFormElement | null;
|
||||
querySelector(selectors: "frame"): HTMLFrameElement | null;
|
||||
querySelector(selectors: "frameset"): HTMLFrameSetElement | null;
|
||||
querySelector(selectors: "g"): SVGGElement | null;
|
||||
querySelector(selectors: "h1"): HTMLHeadingElement | null;
|
||||
querySelector(selectors: "h2"): HTMLHeadingElement | null;
|
||||
querySelector(selectors: "h3"): HTMLHeadingElement | null;
|
||||
querySelector(selectors: "h4"): HTMLHeadingElement | null;
|
||||
querySelector(selectors: "h5"): HTMLHeadingElement | null;
|
||||
querySelector(selectors: "h6"): HTMLHeadingElement | null;
|
||||
querySelector(selectors: "head"): HTMLHeadElement | null;
|
||||
querySelector(selectors: "header"): HTMLElement | null;
|
||||
querySelector(selectors: "hgroup"): HTMLElement | null;
|
||||
querySelector(selectors: "hr"): HTMLHRElement | null;
|
||||
querySelector(selectors: "html"): HTMLHtmlElement | null;
|
||||
querySelector(selectors: "i"): HTMLElement | null;
|
||||
querySelector(selectors: "iframe"): HTMLIFrameElement | null;
|
||||
querySelector(selectors: "image"): SVGImageElement | null;
|
||||
querySelector(selectors: "img"): HTMLImageElement | null;
|
||||
querySelector(selectors: "input"): HTMLInputElement | null;
|
||||
querySelector(selectors: "ins"): HTMLModElement | null;
|
||||
querySelector(selectors: "isindex"): HTMLUnknownElement | null;
|
||||
querySelector(selectors: "kbd"): HTMLElement | null;
|
||||
querySelector(selectors: "keygen"): HTMLElement | null;
|
||||
querySelector(selectors: "label"): HTMLLabelElement | null;
|
||||
querySelector(selectors: "legend"): HTMLLegendElement | null;
|
||||
querySelector(selectors: "li"): HTMLLIElement | null;
|
||||
querySelector(selectors: "line"): SVGLineElement | null;
|
||||
querySelector(selectors: "lineargradient"): SVGLinearGradientElement | null;
|
||||
querySelector(selectors: "link"): HTMLLinkElement | null;
|
||||
querySelector(selectors: "listing"): HTMLPreElement | null;
|
||||
querySelector(selectors: "map"): HTMLMapElement | null;
|
||||
querySelector(selectors: "mark"): HTMLElement | null;
|
||||
querySelector(selectors: "marker"): SVGMarkerElement | null;
|
||||
querySelector(selectors: "marquee"): HTMLMarqueeElement | null;
|
||||
querySelector(selectors: "mask"): SVGMaskElement | null;
|
||||
querySelector(selectors: "menu"): HTMLMenuElement | null;
|
||||
querySelector(selectors: "meta"): HTMLMetaElement | null;
|
||||
querySelector(selectors: "metadata"): SVGMetadataElement | null;
|
||||
querySelector(selectors: "meter"): HTMLMeterElement | null;
|
||||
querySelector(selectors: "nav"): HTMLElement | null;
|
||||
querySelector(selectors: "nextid"): HTMLUnknownElement | null;
|
||||
querySelector(selectors: "nobr"): HTMLElement | null;
|
||||
querySelector(selectors: "noframes"): HTMLElement | null;
|
||||
querySelector(selectors: "noscript"): HTMLElement | null;
|
||||
querySelector(selectors: "object"): HTMLObjectElement | null;
|
||||
querySelector(selectors: "ol"): HTMLOListElement | null;
|
||||
querySelector(selectors: "optgroup"): HTMLOptGroupElement | null;
|
||||
querySelector(selectors: "option"): HTMLOptionElement | null;
|
||||
querySelector(selectors: "p"): HTMLParagraphElement | null;
|
||||
querySelector(selectors: "param"): HTMLParamElement | null;
|
||||
querySelector(selectors: "path"): SVGPathElement | null;
|
||||
querySelector(selectors: "pattern"): SVGPatternElement | null;
|
||||
querySelector(selectors: "picture"): HTMLPictureElement | null;
|
||||
querySelector(selectors: "plaintext"): HTMLElement | null;
|
||||
querySelector(selectors: "polygon"): SVGPolygonElement | null;
|
||||
querySelector(selectors: "polyline"): SVGPolylineElement | null;
|
||||
querySelector(selectors: "pre"): HTMLPreElement | null;
|
||||
querySelector(selectors: "progress"): HTMLProgressElement | null;
|
||||
querySelector(selectors: "q"): HTMLQuoteElement | null;
|
||||
querySelector(selectors: "radialgradient"): SVGRadialGradientElement | null;
|
||||
querySelector(selectors: "rect"): SVGRectElement | null;
|
||||
querySelector(selectors: "rt"): HTMLElement | null;
|
||||
querySelector(selectors: "ruby"): HTMLElement | null;
|
||||
querySelector(selectors: "s"): HTMLElement | null;
|
||||
querySelector(selectors: "samp"): HTMLElement | null;
|
||||
querySelector(selectors: "script"): HTMLScriptElement | null;
|
||||
querySelector(selectors: "section"): HTMLElement | null;
|
||||
querySelector(selectors: "select"): HTMLSelectElement | null;
|
||||
querySelector(selectors: "small"): HTMLElement | null;
|
||||
querySelector(selectors: "source"): HTMLSourceElement | null;
|
||||
querySelector(selectors: "span"): HTMLSpanElement | null;
|
||||
querySelector(selectors: "stop"): SVGStopElement | null;
|
||||
querySelector(selectors: "strike"): HTMLElement | null;
|
||||
querySelector(selectors: "strong"): HTMLElement | null;
|
||||
querySelector(selectors: "style"): HTMLStyleElement | null;
|
||||
querySelector(selectors: "sub"): HTMLElement | null;
|
||||
querySelector(selectors: "sup"): HTMLElement | null;
|
||||
querySelector(selectors: "svg"): SVGSVGElement | null;
|
||||
querySelector(selectors: "switch"): SVGSwitchElement | null;
|
||||
querySelector(selectors: "symbol"): SVGSymbolElement | null;
|
||||
querySelector(selectors: "table"): HTMLTableElement | null;
|
||||
querySelector(selectors: "tbody"): HTMLTableSectionElement | null;
|
||||
querySelector(selectors: "td"): HTMLTableDataCellElement | null;
|
||||
querySelector(selectors: "template"): HTMLTemplateElement | null;
|
||||
querySelector(selectors: "text"): SVGTextElement | null;
|
||||
querySelector(selectors: "textpath"): SVGTextPathElement | null;
|
||||
querySelector(selectors: "textarea"): HTMLTextAreaElement | null;
|
||||
querySelector(selectors: "tfoot"): HTMLTableSectionElement | null;
|
||||
querySelector(selectors: "th"): HTMLTableHeaderCellElement | null;
|
||||
querySelector(selectors: "thead"): HTMLTableSectionElement | null;
|
||||
querySelector(selectors: "title"): HTMLTitleElement | null;
|
||||
querySelector(selectors: "tr"): HTMLTableRowElement | null;
|
||||
querySelector(selectors: "track"): HTMLTrackElement | null;
|
||||
querySelector(selectors: "tspan"): SVGTSpanElement | null;
|
||||
querySelector(selectors: "tt"): HTMLElement | null;
|
||||
querySelector(selectors: "u"): HTMLElement | null;
|
||||
querySelector(selectors: "ul"): HTMLUListElement | null;
|
||||
querySelector(selectors: "use"): SVGUseElement | null;
|
||||
querySelector(selectors: "var"): HTMLElement | null;
|
||||
querySelector(selectors: "video"): HTMLVideoElement | null;
|
||||
querySelector(selectors: "view"): SVGViewElement | null;
|
||||
querySelector(selectors: "wbr"): HTMLElement | null;
|
||||
querySelector(selectors: "x-ms-webview"): MSHTMLWebViewElement | null;
|
||||
querySelector(selectors: "xmp"): HTMLPreElement | null;
|
||||
querySelector(selectors: string): Element | null;
|
||||
querySelectorAll(selectors: "a"): NodeListOf<HTMLAnchorElement>;
|
||||
querySelectorAll(selectors: "abbr"): NodeListOf<HTMLElement>;
|
||||
querySelectorAll(selectors: "acronym"): NodeListOf<HTMLElement>;
|
||||
@@ -20448,11 +20499,16 @@ type ScrollLogicalPosition = "start" | "center" | "end" | "nearest";
|
||||
type IDBValidKey = number | string | Date | IDBArrayKey;
|
||||
type BufferSource = ArrayBuffer | ArrayBufferView;
|
||||
type MouseWheelEvent = WheelEvent;
|
||||
type ScrollRestoration = "auto" | "manual";
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
/// WorkerGlobalScope APIs
|
||||
/////////////////////////////
|
||||
// These are only available in a Web Worker
|
||||
declare function importScripts(...urls: string[]): void;
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
@@ -20744,6 +20800,8 @@ interface DateConstructor {
|
||||
interface Date {
|
||||
getVarDate: () => VarDate;
|
||||
}
|
||||
|
||||
|
||||
/// <reference path="lib.dom.d.ts" />
|
||||
|
||||
interface DOMTokenList {
|
||||
|
||||
Vendored
+4
@@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
|
||||
Vendored
+10
-6
@@ -13,7 +13,11 @@ See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
/// IE Worker APIs
|
||||
@@ -744,7 +748,7 @@ declare var Worker: {
|
||||
}
|
||||
|
||||
interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
|
||||
onreadystatechange: (this: this, ev: ProgressEvent) => any;
|
||||
onreadystatechange: (this: this, ev: Event) => any;
|
||||
readonly readyState: number;
|
||||
readonly response: any;
|
||||
readonly responseText: string;
|
||||
@@ -770,13 +774,13 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
|
||||
readonly LOADING: number;
|
||||
readonly OPENED: number;
|
||||
readonly UNSENT: number;
|
||||
addEventListener(type: "abort", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ErrorEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "load", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "abort", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "error", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "load", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadend", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadstart", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "loadstart", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "progress", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "readystatechange", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "readystatechange", listener: (this: this, ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "timeout", listener: (this: this, ev: ProgressEvent) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
Vendored
+1848
File diff suppressed because it is too large
Load Diff
+11027
-9072
File diff suppressed because it is too large
Load Diff
+18872
-14709
File diff suppressed because it is too large
Load Diff
Vendored
+1996
-7628
File diff suppressed because it is too large
Load Diff
+18721
-14691
File diff suppressed because it is too large
Load Diff
Vendored
+648
-360
File diff suppressed because it is too large
Load Diff
+14367
-12967
File diff suppressed because it is too large
Load Diff
Vendored
+648
-360
File diff suppressed because it is too large
Load Diff
+14367
-12967
File diff suppressed because it is too large
Load Diff
+1532
-435
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,22 @@
|
||||
// Import the utility functionality.
|
||||
import jobs.generation.Utilities;
|
||||
|
||||
// Defines a the new of the repo, used elsewhere in the file
|
||||
def project = GithubProject
|
||||
def branch = GithubBranchName
|
||||
|
||||
def nodeVersions = ['stable', '4']
|
||||
|
||||
nodeVersions.each { nodeVer ->
|
||||
|
||||
def newJobName = "typescript_node.${nodeVer}"
|
||||
def newJob = job(Utilities.getFullJobName(project, newJobName, true)) {
|
||||
steps {
|
||||
shell("./jenkins.sh ${nodeVer}")
|
||||
}
|
||||
}
|
||||
|
||||
Utilities.standardJobSetup(newJob, project, true, "*/${branch}")
|
||||
Utilities.setMachineAffinity(newJob, 'Ubuntu', '20161020')
|
||||
Utilities.addGithubPRTriggerForBranch(newJob, branch, "TypeScript Test Run ${newJobName}")
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
/// <reference types="node"/>
|
||||
|
||||
import * as ts from "../lib/typescript";
|
||||
import * as path from "path";
|
||||
|
||||
function endsWith(s: string, suffix: string) {
|
||||
return s.lastIndexOf(suffix, s.length - suffix.length) !== -1;
|
||||
}
|
||||
|
||||
class DeclarationsWalker {
|
||||
private visitedTypes: ts.Type[] = [];
|
||||
private text = "";
|
||||
private removedTypes: ts.Type[] = [];
|
||||
|
||||
private constructor(private typeChecker: ts.TypeChecker, private protocolFile: ts.SourceFile) {
|
||||
}
|
||||
|
||||
static getExtraDeclarations(typeChecker: ts.TypeChecker, protocolFile: ts.SourceFile): string {
|
||||
let text = "declare namespace ts.server.protocol {\n";
|
||||
var walker = new DeclarationsWalker(typeChecker, protocolFile);
|
||||
walker.visitTypeNodes(protocolFile);
|
||||
text = walker.text
|
||||
? `declare namespace ts.server.protocol {\n${walker.text}}`
|
||||
: "";
|
||||
if (walker.removedTypes) {
|
||||
text += "\ndeclare namespace ts {\n";
|
||||
text += " // these types are empty stubs for types from services and should not be used directly\n"
|
||||
for (const type of walker.removedTypes) {
|
||||
text += ` export type ${type.symbol.name} = never;\n`;
|
||||
}
|
||||
text += "}"
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
private processType(type: ts.Type): void {
|
||||
if (this.visitedTypes.indexOf(type) >= 0) {
|
||||
return;
|
||||
}
|
||||
this.visitedTypes.push(type);
|
||||
let s = type.aliasSymbol || type.getSymbol();
|
||||
if (!s) {
|
||||
return;
|
||||
}
|
||||
if (s.name === "Array") {
|
||||
// we should process type argument instead
|
||||
return this.processType((<any>type).typeArguments[0]);
|
||||
}
|
||||
else {
|
||||
for (const decl of s.getDeclarations()) {
|
||||
const sourceFile = decl.getSourceFile();
|
||||
if (sourceFile === this.protocolFile || path.basename(sourceFile.fileName) === "lib.d.ts") {
|
||||
return;
|
||||
}
|
||||
if (decl.kind === ts.SyntaxKind.EnumDeclaration) {
|
||||
this.removedTypes.push(type);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
// splice declaration in final d.ts file
|
||||
let text = decl.getFullText();
|
||||
this.text += `${text}\n`;
|
||||
// recursively pull all dependencies into result dts file
|
||||
|
||||
this.visitTypeNodes(decl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private visitTypeNodes(node: ts.Node) {
|
||||
if (node.parent) {
|
||||
switch (node.parent.kind) {
|
||||
case ts.SyntaxKind.VariableDeclaration:
|
||||
case ts.SyntaxKind.MethodDeclaration:
|
||||
case ts.SyntaxKind.MethodSignature:
|
||||
case ts.SyntaxKind.PropertyDeclaration:
|
||||
case ts.SyntaxKind.PropertySignature:
|
||||
case ts.SyntaxKind.Parameter:
|
||||
case ts.SyntaxKind.IndexSignature:
|
||||
if (((<ts.VariableDeclaration | ts.MethodDeclaration | ts.PropertyDeclaration | ts.ParameterDeclaration | ts.PropertySignature | ts.MethodSignature | ts.IndexSignatureDeclaration>node.parent).type) === node) {
|
||||
this.processTypeOfNode(node);
|
||||
}
|
||||
break;
|
||||
case ts.SyntaxKind.InterfaceDeclaration:
|
||||
const heritageClauses = (<ts.InterfaceDeclaration>node.parent).heritageClauses;
|
||||
if (heritageClauses) {
|
||||
if (heritageClauses[0].token !== ts.SyntaxKind.ExtendsKeyword) {
|
||||
throw new Error(`Unexpected kind of heritage clause: ${ts.SyntaxKind[heritageClauses[0].kind]}`);
|
||||
}
|
||||
for (const type of heritageClauses[0].types) {
|
||||
this.processTypeOfNode(type);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
ts.forEachChild(node, n => this.visitTypeNodes(n));
|
||||
}
|
||||
|
||||
private processTypeOfNode(node: ts.Node): void {
|
||||
if (node.kind === ts.SyntaxKind.UnionType) {
|
||||
for (const t of (<ts.UnionTypeNode>node).types) {
|
||||
this.processTypeOfNode(t);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const type = this.typeChecker.getTypeAtLocation(node);
|
||||
if (type && !(type.flags & (ts.TypeFlags.TypeParameter))) {
|
||||
this.processType(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function generateProtocolFile(protocolTs: string, typeScriptServicesDts: string): string {
|
||||
const options = { target: ts.ScriptTarget.ES5, declaration: true, noResolve: true, types: <string[]>[], stripInternal: true };
|
||||
|
||||
/**
|
||||
* 1st pass - generate a program from protocol.ts and typescriptservices.d.ts and emit core version of protocol.d.ts with all internal members stripped
|
||||
* @return text of protocol.d.t.s
|
||||
*/
|
||||
function getInitialDtsFileForProtocol() {
|
||||
const program = ts.createProgram([protocolTs, typeScriptServicesDts], options);
|
||||
|
||||
let protocolDts: string;
|
||||
program.emit(program.getSourceFile(protocolTs), (file, content) => {
|
||||
if (endsWith(file, ".d.ts")) {
|
||||
protocolDts = content;
|
||||
}
|
||||
});
|
||||
if (protocolDts === undefined) {
|
||||
throw new Error(`Declaration file for protocol.ts is not generated`)
|
||||
}
|
||||
return protocolDts;
|
||||
}
|
||||
|
||||
const protocolFileName = "protocol.d.ts";
|
||||
/**
|
||||
* Second pass - generate a program from protocol.d.ts and typescriptservices.d.ts, then augment core protocol.d.ts with extra types from typescriptservices.d.ts
|
||||
*/
|
||||
function getProgramWithProtocolText(protocolDts: string, includeTypeScriptServices: boolean) {
|
||||
const host = ts.createCompilerHost(options);
|
||||
const originalGetSourceFile = host.getSourceFile;
|
||||
host.getSourceFile = (fileName) => {
|
||||
if (fileName === protocolFileName) {
|
||||
return ts.createSourceFile(fileName, protocolDts, options.target);
|
||||
}
|
||||
return originalGetSourceFile.apply(host, [fileName]);
|
||||
}
|
||||
const rootFiles = includeTypeScriptServices ? [protocolFileName, typeScriptServicesDts] : [protocolFileName];
|
||||
return ts.createProgram(rootFiles, options, host);
|
||||
}
|
||||
|
||||
let protocolDts = getInitialDtsFileForProtocol();
|
||||
const program = getProgramWithProtocolText(protocolDts, /*includeTypeScriptServices*/ true);
|
||||
|
||||
const protocolFile = program.getSourceFile("protocol.d.ts");
|
||||
const extraDeclarations = DeclarationsWalker.getExtraDeclarations(program.getTypeChecker(), protocolFile);
|
||||
if (extraDeclarations) {
|
||||
protocolDts += extraDeclarations;
|
||||
}
|
||||
protocolDts += "\nimport protocol = ts.server.protocol;";
|
||||
protocolDts += "\nexport = protocol;";
|
||||
protocolDts += "\nexport as namespace protocol;";
|
||||
// do sanity check and try to compile generated text as standalone program
|
||||
const sanityCheckProgram = getProgramWithProtocolText(protocolDts, /*includeTypeScriptServices*/ false);
|
||||
const diagnostics = [...sanityCheckProgram.getSyntacticDiagnostics(), ...sanityCheckProgram.getSemanticDiagnostics(), ...sanityCheckProgram.getGlobalDiagnostics()];
|
||||
if (diagnostics.length) {
|
||||
const flattenedDiagnostics = diagnostics.map(d => ts.flattenDiagnosticMessageText(d.messageText, "\n")).join("\n");
|
||||
throw new Error(`Unexpected errors during sanity check: ${flattenedDiagnostics}`);
|
||||
}
|
||||
return protocolDts;
|
||||
}
|
||||
|
||||
if (process.argv.length < 5) {
|
||||
console.log(`Expected 3 arguments: path to 'protocol.ts', path to 'typescriptservices.d.ts' and path to output file`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const protocolTs = process.argv[2];
|
||||
const typeScriptServicesDts = process.argv[3];
|
||||
const outputFile = process.argv[4];
|
||||
const generatedProtocolDts = generateProtocolFile(protocolTs, typeScriptServicesDts);
|
||||
ts.sys.writeFile(outputFile, generatedProtocolDts);
|
||||
+220
-91
@@ -84,6 +84,7 @@ namespace ts {
|
||||
IsFunctionExpression = 1 << 4,
|
||||
HasLocals = 1 << 5,
|
||||
IsInterface = 1 << 6,
|
||||
IsObjectLiteralOrClassExpressionMethod = 1 << 7,
|
||||
}
|
||||
|
||||
const binder = createBinder();
|
||||
@@ -121,7 +122,8 @@ namespace ts {
|
||||
|
||||
// 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
|
||||
// not depending on if we see "use strict" in certain places (or if we hit a class/namespace).
|
||||
// not depending on if we see "use strict" in certain places or if we hit a class/namespace
|
||||
// or if compiler options contain alwaysStrict.
|
||||
let inStrictMode: boolean;
|
||||
|
||||
let symbolCount = 0;
|
||||
@@ -139,7 +141,7 @@ namespace ts {
|
||||
file = f;
|
||||
options = opts;
|
||||
languageVersion = getEmitScriptTarget(options);
|
||||
inStrictMode = !!file.externalModuleIndicator;
|
||||
inStrictMode = bindInStrictMode(file, opts);
|
||||
classifiableNames = createMap<string>();
|
||||
symbolCount = 0;
|
||||
skipTransformFlagAggregation = isDeclarationFile(file);
|
||||
@@ -174,6 +176,16 @@ namespace ts {
|
||||
|
||||
return bindSourceFile;
|
||||
|
||||
function bindInStrictMode(file: SourceFile, opts: CompilerOptions): boolean {
|
||||
if (opts.alwaysStrict && !isDeclarationFile(file)) {
|
||||
// bind in strict mode source files with alwaysStrict option
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return !!file.externalModuleIndicator;
|
||||
}
|
||||
}
|
||||
|
||||
function createSymbol(flags: SymbolFlags, name: string): Symbol {
|
||||
symbolCount++;
|
||||
return new Symbol(flags, name);
|
||||
@@ -486,8 +498,8 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
currentFlow = { flags: FlowFlags.Start };
|
||||
if (containerFlags & ContainerFlags.IsFunctionExpression) {
|
||||
(<FlowStart>currentFlow).container = <FunctionExpression | ArrowFunction>node;
|
||||
if (containerFlags & (ContainerFlags.IsFunctionExpression | ContainerFlags.IsObjectLiteralOrClassExpressionMethod)) {
|
||||
(<FlowStart>currentFlow).container = <FunctionExpression | ArrowFunction | MethodDeclaration>node;
|
||||
}
|
||||
currentReturnTarget = undefined;
|
||||
}
|
||||
@@ -773,6 +785,15 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
function createFlowArrayMutation(antecedent: FlowNode, node: CallExpression | BinaryExpression): FlowNode {
|
||||
setFlowNodeReferenced(antecedent);
|
||||
return <FlowArrayMutation>{
|
||||
flags: FlowFlags.ArrayMutation,
|
||||
antecedent,
|
||||
node
|
||||
};
|
||||
}
|
||||
|
||||
function finishFlowLabel(flow: FlowLabel): FlowNode {
|
||||
const antecedents = flow.antecedents;
|
||||
if (!antecedents) {
|
||||
@@ -963,24 +984,44 @@ namespace ts {
|
||||
}
|
||||
|
||||
function bindTryStatement(node: TryStatement): void {
|
||||
const postFinallyLabel = createBranchLabel();
|
||||
const preFinallyLabel = createBranchLabel();
|
||||
const preTryFlow = currentFlow;
|
||||
// TODO: Every statement in try block is potentially an exit point!
|
||||
bind(node.tryBlock);
|
||||
addAntecedent(postFinallyLabel, currentFlow);
|
||||
addAntecedent(preFinallyLabel, currentFlow);
|
||||
|
||||
const flowAfterTry = currentFlow;
|
||||
let flowAfterCatch = unreachableFlow;
|
||||
|
||||
if (node.catchClause) {
|
||||
currentFlow = preTryFlow;
|
||||
bind(node.catchClause);
|
||||
addAntecedent(postFinallyLabel, currentFlow);
|
||||
addAntecedent(preFinallyLabel, currentFlow);
|
||||
|
||||
flowAfterCatch = currentFlow;
|
||||
}
|
||||
if (node.finallyBlock) {
|
||||
currentFlow = preTryFlow;
|
||||
// in finally flow is combined from pre-try/flow from try/flow from catch
|
||||
// pre-flow is necessary to make sure that finally is reachable even if finally flows in both try and finally blocks are unreachable
|
||||
addAntecedent(preFinallyLabel, preTryFlow);
|
||||
currentFlow = finishFlowLabel(preFinallyLabel);
|
||||
bind(node.finallyBlock);
|
||||
// if flow after finally is unreachable - keep it
|
||||
// otherwise check if flows after try and after catch are unreachable
|
||||
// if yes - convert current flow to unreachable
|
||||
// i.e.
|
||||
// try { return "1" } finally { console.log(1); }
|
||||
// console.log(2); // this line should be unreachable even if flow falls out of finally block
|
||||
if (!(currentFlow.flags & FlowFlags.Unreachable)) {
|
||||
if ((flowAfterTry.flags & FlowFlags.Unreachable) && (flowAfterCatch.flags & FlowFlags.Unreachable)) {
|
||||
currentFlow = flowAfterTry === reportedUnreachableFlow || flowAfterCatch === reportedUnreachableFlow
|
||||
? reportedUnreachableFlow
|
||||
: unreachableFlow;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if try statement has finally block and flow after finally block is unreachable - keep it
|
||||
// otherwise use whatever flow was accumulated at postFinallyLabel
|
||||
if (!node.finallyBlock || !(currentFlow.flags & FlowFlags.Unreachable)) {
|
||||
currentFlow = finishFlowLabel(postFinallyLabel);
|
||||
else {
|
||||
currentFlow = finishFlowLabel(preFinallyLabel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1153,6 +1194,12 @@ namespace ts {
|
||||
forEachChild(node, bind);
|
||||
if (operator === SyntaxKind.EqualsToken && !isAssignmentTarget(node)) {
|
||||
bindAssignmentTargetFlow(node.left);
|
||||
if (node.left.kind === SyntaxKind.ElementAccessExpression) {
|
||||
const elementAccess = <ElementAccessExpression>node.left;
|
||||
if (isNarrowableOperand(elementAccess.expression)) {
|
||||
currentFlow = createFlowArrayMutation(currentFlow, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1213,6 +1260,12 @@ namespace ts {
|
||||
else {
|
||||
forEachChild(node, bind);
|
||||
}
|
||||
if (node.expression.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
const propertyAccess = <PropertyAccessExpression>node.expression;
|
||||
if (isNarrowableOperand(propertyAccess.expression) && isPushOrUnshiftIdentifier(propertyAccess.name)) {
|
||||
currentFlow = createFlowArrayMutation(currentFlow, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getContainerFlags(node: Node): ContainerFlags {
|
||||
@@ -1237,9 +1290,12 @@ namespace ts {
|
||||
case SyntaxKind.SourceFile:
|
||||
return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals;
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
if (isObjectLiteralOrClassExpressionMethod(node)) {
|
||||
return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals | ContainerFlags.IsFunctionLike | ContainerFlags.IsObjectLiteralOrClassExpressionMethod;
|
||||
}
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
@@ -1649,7 +1705,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function checkStrictModeFunctionDeclaration(node: FunctionDeclaration) {
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
if (languageVersion < ScriptTarget.ES2015) {
|
||||
// Report error if function is not top level function declaration
|
||||
if (blockScopeContainer.kind !== SyntaxKind.SourceFile &&
|
||||
blockScopeContainer.kind !== SyntaxKind.ModuleDeclaration &&
|
||||
@@ -2016,7 +2072,9 @@ namespace ts {
|
||||
function setCommonJsModuleIndicator(node: Node) {
|
||||
if (!file.commonJsModuleIndicator) {
|
||||
file.commonJsModuleIndicator = node;
|
||||
bindSourceFileAsExternalModule();
|
||||
if (!file.externalModuleIndicator) {
|
||||
bindSourceFileAsExternalModule();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2238,6 +2296,10 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
if (currentFlow && isObjectLiteralOrClassExpressionMethod(node)) {
|
||||
node.flowNode = currentFlow;
|
||||
}
|
||||
|
||||
return hasDynamicName(node)
|
||||
? bindAnonymousDeclaration(node, symbolFlags, "__computed")
|
||||
: declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
|
||||
@@ -2311,6 +2373,9 @@ namespace ts {
|
||||
case SyntaxKind.CallExpression:
|
||||
return computeCallExpression(<CallExpression>node, subtreeFlags);
|
||||
|
||||
case SyntaxKind.NewExpression:
|
||||
return computeNewExpression(<NewExpression>node, subtreeFlags);
|
||||
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
return computeModuleDeclaration(<ModuleDeclaration>node, subtreeFlags);
|
||||
|
||||
@@ -2356,6 +2421,9 @@ namespace ts {
|
||||
case SyntaxKind.HeritageClause:
|
||||
return computeHeritageClause(<HeritageClause>node, subtreeFlags);
|
||||
|
||||
case SyntaxKind.CatchClause:
|
||||
return computeCatchClause(<CatchClause>node, subtreeFlags);
|
||||
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return computeExpressionWithTypeArguments(<ExpressionWithTypeArguments>node, subtreeFlags);
|
||||
|
||||
@@ -2388,11 +2456,15 @@ namespace ts {
|
||||
const expression = node.expression;
|
||||
const expressionKind = expression.kind;
|
||||
|
||||
if (node.typeArguments) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
if (subtreeFlags & TransformFlags.ContainsSpreadElementExpression
|
||||
|| isSuperOrSuperProperty(expression, expressionKind)) {
|
||||
// If the this node contains a SpreadElementExpression, or is a super call, then it is an ES6
|
||||
// node.
|
||||
transformFlags |= TransformFlags.AssertES6;
|
||||
transformFlags |= TransformFlags.AssertES2015;
|
||||
}
|
||||
|
||||
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;
|
||||
@@ -2414,6 +2486,21 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function computeNewExpression(node: NewExpression, subtreeFlags: TransformFlags) {
|
||||
let transformFlags = subtreeFlags;
|
||||
if (node.typeArguments) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
if (subtreeFlags & TransformFlags.ContainsSpreadElementExpression) {
|
||||
// If the this node contains a SpreadElementExpression then it is an ES6
|
||||
// node.
|
||||
transformFlags |= TransformFlags.AssertES2015;
|
||||
}
|
||||
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;
|
||||
return transformFlags & ~TransformFlags.ArrayLiteralOrCallOrNewExcludes;
|
||||
}
|
||||
|
||||
|
||||
function computeBinaryExpression(node: BinaryExpression, subtreeFlags: TransformFlags) {
|
||||
let transformFlags = subtreeFlags;
|
||||
const operatorTokenKind = node.operatorToken.kind;
|
||||
@@ -2423,12 +2510,12 @@ namespace ts {
|
||||
&& (leftKind === SyntaxKind.ObjectLiteralExpression
|
||||
|| leftKind === SyntaxKind.ArrayLiteralExpression)) {
|
||||
// Destructuring assignments are ES6 syntax.
|
||||
transformFlags |= TransformFlags.AssertES6 | TransformFlags.DestructuringAssignment;
|
||||
transformFlags |= TransformFlags.AssertES2015 | TransformFlags.DestructuringAssignment;
|
||||
}
|
||||
else if (operatorTokenKind === SyntaxKind.AsteriskAsteriskToken
|
||||
|| operatorTokenKind === SyntaxKind.AsteriskAsteriskEqualsToken) {
|
||||
// Exponentiation is ES7 syntax.
|
||||
transformFlags |= TransformFlags.AssertES7;
|
||||
// Exponentiation is ES2016 syntax.
|
||||
transformFlags |= TransformFlags.AssertES2016;
|
||||
}
|
||||
|
||||
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;
|
||||
@@ -2442,13 +2529,12 @@ namespace ts {
|
||||
const initializer = node.initializer;
|
||||
const dotDotDotToken = node.dotDotDotToken;
|
||||
|
||||
// If the parameter has a question token, then it is TypeScript syntax.
|
||||
if (node.questionToken) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
// If the parameter's name is 'this', then it is TypeScript syntax.
|
||||
if (subtreeFlags & TransformFlags.ContainsDecorators || isThisIdentifier(name)) {
|
||||
// The '?' token, type annotations, decorators, and 'this' parameters are TypeSCript
|
||||
// syntax.
|
||||
if (node.questionToken
|
||||
|| node.type
|
||||
|| subtreeFlags & TransformFlags.ContainsDecorators
|
||||
|| isThisIdentifier(name)) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
@@ -2460,7 +2546,7 @@ namespace ts {
|
||||
// If a parameter has an initializer, a binding pattern or a dotDotDot token, then
|
||||
// it is ES6 syntax and its container must emit default value assignments or parameter destructuring downlevel.
|
||||
if (subtreeFlags & TransformFlags.ContainsBindingPattern || initializer || dotDotDotToken) {
|
||||
transformFlags |= TransformFlags.AssertES6 | TransformFlags.ContainsDefaultValueAssignments;
|
||||
transformFlags |= TransformFlags.AssertES2015 | TransformFlags.ContainsDefaultValueAssignments;
|
||||
}
|
||||
|
||||
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;
|
||||
@@ -2501,13 +2587,14 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
// A ClassDeclaration is ES6 syntax.
|
||||
transformFlags = subtreeFlags | TransformFlags.AssertES6;
|
||||
transformFlags = subtreeFlags | TransformFlags.AssertES2015;
|
||||
|
||||
// A class with a parameter property assignment, property initializer, or decorator is
|
||||
// TypeScript syntax.
|
||||
// An exported declaration may be TypeScript syntax.
|
||||
if ((subtreeFlags & TransformFlags.TypeScriptClassSyntaxMask)
|
||||
|| (modifierFlags & ModifierFlags.Export)) {
|
||||
|| (modifierFlags & ModifierFlags.Export)
|
||||
|| node.typeParameters) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
@@ -2524,11 +2611,12 @@ namespace ts {
|
||||
|
||||
function computeClassExpression(node: ClassExpression, subtreeFlags: TransformFlags) {
|
||||
// A ClassExpression is ES6 syntax.
|
||||
let transformFlags = subtreeFlags | TransformFlags.AssertES6;
|
||||
let transformFlags = subtreeFlags | TransformFlags.AssertES2015;
|
||||
|
||||
// A class with a parameter property assignment, property initializer, or decorator is
|
||||
// TypeScript syntax.
|
||||
if (subtreeFlags & TransformFlags.TypeScriptClassSyntaxMask) {
|
||||
if (subtreeFlags & TransformFlags.TypeScriptClassSyntaxMask
|
||||
|| node.typeParameters) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
@@ -2548,7 +2636,7 @@ namespace ts {
|
||||
switch (node.token) {
|
||||
case SyntaxKind.ExtendsKeyword:
|
||||
// An `extends` HeritageClause is ES6 syntax.
|
||||
transformFlags |= TransformFlags.AssertES6;
|
||||
transformFlags |= TransformFlags.AssertES2015;
|
||||
break;
|
||||
|
||||
case SyntaxKind.ImplementsKeyword:
|
||||
@@ -2565,10 +2653,21 @@ namespace ts {
|
||||
return transformFlags & ~TransformFlags.NodeExcludes;
|
||||
}
|
||||
|
||||
function computeCatchClause(node: CatchClause, subtreeFlags: TransformFlags) {
|
||||
let transformFlags = subtreeFlags;
|
||||
|
||||
if (node.variableDeclaration && isBindingPattern(node.variableDeclaration.name)) {
|
||||
transformFlags |= TransformFlags.AssertES2015;
|
||||
}
|
||||
|
||||
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;
|
||||
return transformFlags & ~TransformFlags.NodeExcludes;
|
||||
}
|
||||
|
||||
function computeExpressionWithTypeArguments(node: ExpressionWithTypeArguments, subtreeFlags: TransformFlags) {
|
||||
// An ExpressionWithTypeArguments is ES6 syntax, as it is used in the
|
||||
// extends clause of a class.
|
||||
let transformFlags = subtreeFlags | TransformFlags.AssertES6;
|
||||
let transformFlags = subtreeFlags | TransformFlags.AssertES2015;
|
||||
|
||||
// If an ExpressionWithTypeArguments contains type arguments, then it
|
||||
// is TypeScript syntax.
|
||||
@@ -2582,10 +2681,10 @@ namespace ts {
|
||||
|
||||
function computeConstructor(node: ConstructorDeclaration, subtreeFlags: TransformFlags) {
|
||||
let transformFlags = subtreeFlags;
|
||||
const body = node.body;
|
||||
|
||||
if (body === undefined) {
|
||||
// An overload constructor is TypeScript syntax.
|
||||
// TypeScript-specific modifiers and overloads are TypeScript syntax
|
||||
if (hasModifier(node, ModifierFlags.TypeScriptModifier)
|
||||
|| !node.body) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
@@ -2595,23 +2694,25 @@ namespace ts {
|
||||
|
||||
function computeMethod(node: MethodDeclaration, subtreeFlags: TransformFlags) {
|
||||
// A MethodDeclaration is ES6 syntax.
|
||||
let transformFlags = subtreeFlags | TransformFlags.AssertES6;
|
||||
const modifierFlags = getModifierFlags(node);
|
||||
const body = node.body;
|
||||
const typeParameters = node.typeParameters;
|
||||
const asteriskToken = node.asteriskToken;
|
||||
let transformFlags = subtreeFlags | TransformFlags.AssertES2015;
|
||||
|
||||
// A MethodDeclaration is TypeScript syntax if it is either async, abstract, overloaded,
|
||||
// generic, or has a decorator.
|
||||
if (!body
|
||||
|| typeParameters
|
||||
|| (modifierFlags & (ModifierFlags.Async | ModifierFlags.Abstract))
|
||||
|| (subtreeFlags & TransformFlags.ContainsDecorators)) {
|
||||
// Decorators, TypeScript-specific modifiers, type parameters, type annotations, and
|
||||
// overloads are TypeScript syntax.
|
||||
if (node.decorators
|
||||
|| hasModifier(node, ModifierFlags.TypeScriptModifier)
|
||||
|| node.typeParameters
|
||||
|| node.type
|
||||
|| !node.body) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
// An async method declaration is ES2017 syntax.
|
||||
if (hasModifier(node, ModifierFlags.Async)) {
|
||||
transformFlags |= TransformFlags.AssertES2017;
|
||||
}
|
||||
|
||||
// Currently, we only support generators that were originally async function bodies.
|
||||
if (asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) {
|
||||
if (node.asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) {
|
||||
transformFlags |= TransformFlags.AssertGenerator;
|
||||
}
|
||||
|
||||
@@ -2621,14 +2722,13 @@ namespace ts {
|
||||
|
||||
function computeAccessor(node: AccessorDeclaration, subtreeFlags: TransformFlags) {
|
||||
let transformFlags = subtreeFlags;
|
||||
const modifierFlags = getModifierFlags(node);
|
||||
const body = node.body;
|
||||
|
||||
// A MethodDeclaration is TypeScript syntax if it is either async, abstract, overloaded,
|
||||
// generic, or has a decorator.
|
||||
if (!body
|
||||
|| (modifierFlags & (ModifierFlags.Async | ModifierFlags.Abstract))
|
||||
|| (subtreeFlags & TransformFlags.ContainsDecorators)) {
|
||||
// Decorators, TypeScript-specific modifiers, type annotations, and overloads are
|
||||
// TypeScript syntax.
|
||||
if (node.decorators
|
||||
|| hasModifier(node, ModifierFlags.TypeScriptModifier)
|
||||
|| node.type
|
||||
|| !node.body) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
@@ -2654,7 +2754,6 @@ namespace ts {
|
||||
let transformFlags: TransformFlags;
|
||||
const modifierFlags = getModifierFlags(node);
|
||||
const body = node.body;
|
||||
const asteriskToken = node.asteriskToken;
|
||||
|
||||
if (!body || (modifierFlags & ModifierFlags.Ambient)) {
|
||||
// An ambient declaration is TypeScript syntax.
|
||||
@@ -2666,19 +2765,27 @@ namespace ts {
|
||||
|
||||
// If a FunctionDeclaration is exported, then it is either ES6 or TypeScript syntax.
|
||||
if (modifierFlags & ModifierFlags.Export) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES6;
|
||||
transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.AssertES2015;
|
||||
}
|
||||
|
||||
// If a FunctionDeclaration is async, then it is TypeScript syntax.
|
||||
if (modifierFlags & ModifierFlags.Async) {
|
||||
// TypeScript-specific modifiers, type parameters, and type annotations are TypeScript
|
||||
// syntax.
|
||||
if (modifierFlags & ModifierFlags.TypeScriptModifier
|
||||
|| node.typeParameters
|
||||
|| node.type) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
// An async function declaration is ES2017 syntax.
|
||||
if (modifierFlags & ModifierFlags.Async) {
|
||||
transformFlags |= TransformFlags.AssertES2017;
|
||||
}
|
||||
|
||||
// If a FunctionDeclaration's subtree has marked the container as needing to capture the
|
||||
// lexical this, or the function contains parameters with initializers, then this node is
|
||||
// ES6 syntax.
|
||||
if (subtreeFlags & TransformFlags.ES6FunctionSyntaxMask) {
|
||||
transformFlags |= TransformFlags.AssertES6;
|
||||
if (subtreeFlags & TransformFlags.ES2015FunctionSyntaxMask) {
|
||||
transformFlags |= TransformFlags.AssertES2015;
|
||||
}
|
||||
|
||||
// If a FunctionDeclaration is generator function and is the body of a
|
||||
@@ -2686,7 +2793,7 @@ namespace ts {
|
||||
// down-level generator.
|
||||
// Currently we do not support transforming any other generator fucntions
|
||||
// down level.
|
||||
if (asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) {
|
||||
if (node.asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) {
|
||||
transformFlags |= TransformFlags.AssertGenerator;
|
||||
}
|
||||
}
|
||||
@@ -2697,19 +2804,25 @@ namespace ts {
|
||||
|
||||
function computeFunctionExpression(node: FunctionExpression, subtreeFlags: TransformFlags) {
|
||||
let transformFlags = subtreeFlags;
|
||||
const modifierFlags = getModifierFlags(node);
|
||||
const asteriskToken = node.asteriskToken;
|
||||
|
||||
// An async function expression is TypeScript syntax.
|
||||
if (modifierFlags & ModifierFlags.Async) {
|
||||
// TypeScript-specific modifiers, type parameters, and type annotations are TypeScript
|
||||
// syntax.
|
||||
if (hasModifier(node, ModifierFlags.TypeScriptModifier)
|
||||
|| node.typeParameters
|
||||
|| node.type) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
// An async function expression is ES2017 syntax.
|
||||
if (hasModifier(node, ModifierFlags.Async)) {
|
||||
transformFlags |= TransformFlags.AssertES2017;
|
||||
}
|
||||
|
||||
// If a FunctionExpression's subtree has marked the container as needing to capture the
|
||||
// lexical this, or the function contains parameters with initializers, then this node is
|
||||
// ES6 syntax.
|
||||
if (subtreeFlags & TransformFlags.ES6FunctionSyntaxMask) {
|
||||
transformFlags |= TransformFlags.AssertES6;
|
||||
if (subtreeFlags & TransformFlags.ES2015FunctionSyntaxMask) {
|
||||
transformFlags |= TransformFlags.AssertES2015;
|
||||
}
|
||||
|
||||
// If a FunctionExpression is generator function and is the body of a
|
||||
@@ -2717,7 +2830,7 @@ namespace ts {
|
||||
// down-level generator.
|
||||
// Currently we do not support transforming any other generator fucntions
|
||||
// down level.
|
||||
if (asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) {
|
||||
if (node.asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) {
|
||||
transformFlags |= TransformFlags.AssertGenerator;
|
||||
}
|
||||
|
||||
@@ -2727,14 +2840,21 @@ namespace ts {
|
||||
|
||||
function computeArrowFunction(node: ArrowFunction, subtreeFlags: TransformFlags) {
|
||||
// An ArrowFunction is ES6 syntax, and excludes markers that should not escape the scope of an ArrowFunction.
|
||||
let transformFlags = subtreeFlags | TransformFlags.AssertES6;
|
||||
const modifierFlags = getModifierFlags(node);
|
||||
let transformFlags = subtreeFlags | TransformFlags.AssertES2015;
|
||||
|
||||
// An async arrow function is TypeScript syntax.
|
||||
if (modifierFlags & ModifierFlags.Async) {
|
||||
// TypeScript-specific modifiers, type parameters, and type annotations are TypeScript
|
||||
// syntax.
|
||||
if (hasModifier(node, ModifierFlags.TypeScriptModifier)
|
||||
|| node.typeParameters
|
||||
|| node.type) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
// An async arrow function is ES2017 syntax.
|
||||
if (hasModifier(node, ModifierFlags.Async)) {
|
||||
transformFlags |= TransformFlags.AssertES2017;
|
||||
}
|
||||
|
||||
// If an ArrowFunction contains a lexical this, its container must capture the lexical this.
|
||||
if (subtreeFlags & TransformFlags.ContainsLexicalThis) {
|
||||
transformFlags |= TransformFlags.ContainsCapturedLexicalThis;
|
||||
@@ -2765,7 +2885,12 @@ namespace ts {
|
||||
|
||||
// A VariableDeclaration with a binding pattern is ES6 syntax.
|
||||
if (nameKind === SyntaxKind.ObjectBindingPattern || nameKind === SyntaxKind.ArrayBindingPattern) {
|
||||
transformFlags |= TransformFlags.AssertES6 | TransformFlags.ContainsBindingPattern;
|
||||
transformFlags |= TransformFlags.AssertES2015 | TransformFlags.ContainsBindingPattern;
|
||||
}
|
||||
|
||||
// Type annotations are TypeScript syntax.
|
||||
if (node.type) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;
|
||||
@@ -2786,11 +2911,11 @@ namespace ts {
|
||||
|
||||
// If a VariableStatement is exported, then it is either ES6 or TypeScript syntax.
|
||||
if (modifierFlags & ModifierFlags.Export) {
|
||||
transformFlags |= TransformFlags.AssertES6 | TransformFlags.AssertTypeScript;
|
||||
transformFlags |= TransformFlags.AssertES2015 | TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
if (declarationListTransformFlags & TransformFlags.ContainsBindingPattern) {
|
||||
transformFlags |= TransformFlags.AssertES6;
|
||||
transformFlags |= TransformFlags.AssertES2015;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2804,7 +2929,7 @@ namespace ts {
|
||||
// A labeled statement containing a block scoped binding *may* need to be transformed from ES6.
|
||||
if (subtreeFlags & TransformFlags.ContainsBlockScopedBinding
|
||||
&& isIterationStatement(node, /*lookInLabeledStatements*/ true)) {
|
||||
transformFlags |= TransformFlags.AssertES6;
|
||||
transformFlags |= TransformFlags.AssertES2015;
|
||||
}
|
||||
|
||||
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;
|
||||
@@ -2830,7 +2955,7 @@ namespace ts {
|
||||
// then we treat the statement as ES6 so that we can indicate that we do not
|
||||
// need to hold on to the right-hand side.
|
||||
if (node.expression.transformFlags & TransformFlags.DestructuringAssignment) {
|
||||
transformFlags |= TransformFlags.AssertES6;
|
||||
transformFlags |= TransformFlags.AssertES2015;
|
||||
}
|
||||
|
||||
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;
|
||||
@@ -2853,12 +2978,12 @@ namespace ts {
|
||||
let transformFlags = subtreeFlags | TransformFlags.ContainsHoistedDeclarationOrCompletion;
|
||||
|
||||
if (subtreeFlags & TransformFlags.ContainsBindingPattern) {
|
||||
transformFlags |= TransformFlags.AssertES6;
|
||||
transformFlags |= TransformFlags.AssertES2015;
|
||||
}
|
||||
|
||||
// If a VariableDeclarationList is `let` or `const`, then it is ES6 syntax.
|
||||
if (node.flags & NodeFlags.BlockScoped) {
|
||||
transformFlags |= TransformFlags.AssertES6 | TransformFlags.ContainsBlockScopedBinding;
|
||||
transformFlags |= TransformFlags.AssertES2015 | TransformFlags.ContainsBlockScopedBinding;
|
||||
}
|
||||
|
||||
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;
|
||||
@@ -2871,14 +2996,18 @@ namespace ts {
|
||||
let excludeFlags = TransformFlags.NodeExcludes;
|
||||
|
||||
switch (kind) {
|
||||
case SyntaxKind.AsyncKeyword:
|
||||
case SyntaxKind.AwaitExpression:
|
||||
// async/await is ES2017 syntax
|
||||
transformFlags |= TransformFlags.AssertES2017;
|
||||
break;
|
||||
|
||||
case SyntaxKind.PublicKeyword:
|
||||
case SyntaxKind.PrivateKeyword:
|
||||
case SyntaxKind.ProtectedKeyword:
|
||||
case SyntaxKind.AbstractKeyword:
|
||||
case SyntaxKind.DeclareKeyword:
|
||||
case SyntaxKind.AsyncKeyword:
|
||||
case SyntaxKind.ConstKeyword:
|
||||
case SyntaxKind.AwaitExpression:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.EnumMember:
|
||||
case SyntaxKind.TypeAssertionExpression:
|
||||
@@ -2903,7 +3032,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.ExportKeyword:
|
||||
// This node is both ES6 and TypeScript syntax.
|
||||
transformFlags |= TransformFlags.AssertES6 | TransformFlags.AssertTypeScript;
|
||||
transformFlags |= TransformFlags.AssertES2015 | TransformFlags.AssertTypeScript;
|
||||
break;
|
||||
|
||||
case SyntaxKind.DefaultKeyword:
|
||||
@@ -2916,12 +3045,12 @@ namespace ts {
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
// These nodes are ES6 syntax.
|
||||
transformFlags |= TransformFlags.AssertES6;
|
||||
transformFlags |= TransformFlags.AssertES2015;
|
||||
break;
|
||||
|
||||
case SyntaxKind.YieldExpression:
|
||||
// This node is ES6 syntax.
|
||||
transformFlags |= TransformFlags.AssertES6 | TransformFlags.ContainsYield;
|
||||
transformFlags |= TransformFlags.AssertES2015 | TransformFlags.ContainsYield;
|
||||
break;
|
||||
|
||||
case SyntaxKind.AnyKeyword:
|
||||
@@ -2982,7 +3111,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.SuperKeyword:
|
||||
// This node is ES6 syntax.
|
||||
transformFlags |= TransformFlags.AssertES6;
|
||||
transformFlags |= TransformFlags.AssertES2015;
|
||||
break;
|
||||
|
||||
case SyntaxKind.ThisKeyword:
|
||||
@@ -2993,7 +3122,7 @@ namespace ts {
|
||||
case SyntaxKind.ObjectBindingPattern:
|
||||
case SyntaxKind.ArrayBindingPattern:
|
||||
// These nodes are ES6 syntax.
|
||||
transformFlags |= TransformFlags.AssertES6 | TransformFlags.ContainsBindingPattern;
|
||||
transformFlags |= TransformFlags.AssertES2015 | TransformFlags.ContainsBindingPattern;
|
||||
break;
|
||||
|
||||
case SyntaxKind.Decorator:
|
||||
@@ -3006,7 +3135,7 @@ namespace ts {
|
||||
if (subtreeFlags & TransformFlags.ContainsComputedPropertyName) {
|
||||
// If an ObjectLiteralExpression contains a ComputedPropertyName, then it
|
||||
// is an ES6 node.
|
||||
transformFlags |= TransformFlags.AssertES6;
|
||||
transformFlags |= TransformFlags.AssertES2015;
|
||||
}
|
||||
|
||||
if (subtreeFlags & TransformFlags.ContainsLexicalThisInComputedPropertyName) {
|
||||
@@ -3023,7 +3152,7 @@ namespace ts {
|
||||
if (subtreeFlags & TransformFlags.ContainsSpreadElementExpression) {
|
||||
// If the this node contains a SpreadElementExpression, then it is an ES6
|
||||
// node.
|
||||
transformFlags |= TransformFlags.AssertES6;
|
||||
transformFlags |= TransformFlags.AssertES2015;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -3034,14 +3163,14 @@ namespace ts {
|
||||
case SyntaxKind.ForInStatement:
|
||||
// A loop containing a block scoped binding *may* need to be transformed from ES6.
|
||||
if (subtreeFlags & TransformFlags.ContainsBlockScopedBinding) {
|
||||
transformFlags |= TransformFlags.AssertES6;
|
||||
transformFlags |= TransformFlags.AssertES2015;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SyntaxKind.SourceFile:
|
||||
if (subtreeFlags & TransformFlags.ContainsCapturedLexicalThis) {
|
||||
transformFlags |= TransformFlags.AssertES6;
|
||||
transformFlags |= TransformFlags.AssertES2015;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
+623
-324
File diff suppressed because it is too large
Load Diff
@@ -101,7 +101,7 @@ namespace ts {
|
||||
"amd": ModuleKind.AMD,
|
||||
"system": ModuleKind.System,
|
||||
"umd": ModuleKind.UMD,
|
||||
"es6": ModuleKind.ES6,
|
||||
"es6": ModuleKind.ES2015,
|
||||
"es2015": ModuleKind.ES2015,
|
||||
}),
|
||||
description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015,
|
||||
@@ -261,8 +261,10 @@ namespace ts {
|
||||
type: createMap({
|
||||
"es3": ScriptTarget.ES3,
|
||||
"es5": ScriptTarget.ES5,
|
||||
"es6": ScriptTarget.ES6,
|
||||
"es6": ScriptTarget.ES2015,
|
||||
"es2015": ScriptTarget.ES2015,
|
||||
"es2016": ScriptTarget.ES2016,
|
||||
"es2017": ScriptTarget.ES2017,
|
||||
}),
|
||||
description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015,
|
||||
paramType: Diagnostics.VERSION,
|
||||
@@ -444,6 +446,11 @@ namespace ts {
|
||||
name: "importHelpers",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Import_emit_helpers_from_tslib
|
||||
},
|
||||
{
|
||||
name: "alwaysStrict",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file
|
||||
}
|
||||
];
|
||||
|
||||
@@ -508,10 +515,7 @@ namespace ts {
|
||||
|
||||
/* @internal */
|
||||
export function createCompilerDiagnosticForInvalidCustomType(opt: CommandLineOptionOfCustomType): Diagnostic {
|
||||
const namesOfType: string[] = [];
|
||||
for (const key in opt.type) {
|
||||
namesOfType.push(` '${key}'`);
|
||||
}
|
||||
const namesOfType = Object.keys(opt.type).map(key => `'${key}'`).join(", ");
|
||||
return createCompilerDiagnostic(Diagnostics.Argument_for_0_option_must_be_Colon_1, `--${opt.name}`, namesOfType);
|
||||
}
|
||||
|
||||
@@ -595,7 +599,13 @@ namespace ts {
|
||||
i++;
|
||||
break;
|
||||
case "boolean":
|
||||
options[opt.name] = true;
|
||||
// boolean flag has optional value true, false, others
|
||||
let optValue = args[i];
|
||||
options[opt.name] = optValue !== "false";
|
||||
// consume next argument as boolean flag value
|
||||
if (optValue === "false" || optValue === "true") {
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
case "string":
|
||||
options[opt.name] = args[i] || "";
|
||||
@@ -902,6 +912,9 @@ namespace ts {
|
||||
if (hasProperty(json, "files")) {
|
||||
if (isArray(json["files"])) {
|
||||
fileNames = <string[]>json["files"];
|
||||
if (fileNames.length === 0) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "files", "Array"));
|
||||
@@ -944,7 +957,18 @@ namespace ts {
|
||||
includeSpecs = ["**/*"];
|
||||
}
|
||||
|
||||
return matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors);
|
||||
const result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors);
|
||||
|
||||
if (result.fileNames.length === 0 && !hasProperty(json, "files") && resolutionStack.length === 0) {
|
||||
errors.push(
|
||||
createCompilerDiagnostic(
|
||||
Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
configFileName || "tsconfig.json",
|
||||
JSON.stringify(includeSpecs || []),
|
||||
JSON.stringify(excludeSpecs || [])));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -975,7 +999,7 @@ namespace ts {
|
||||
basePath: string, errors: Diagnostic[], configFileName?: string): CompilerOptions {
|
||||
|
||||
const options: CompilerOptions = getBaseFileName(configFileName) === "jsconfig.json"
|
||||
? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true }
|
||||
? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true }
|
||||
: {};
|
||||
convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, options, Diagnostics.Unknown_compiler_option_0, errors);
|
||||
return options;
|
||||
|
||||
@@ -188,7 +188,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function emitLeadingComment(commentPos: number, commentEnd: number, kind: SyntaxKind, hasTrailingNewLine: boolean, rangePos: number) {
|
||||
function emitLeadingComment(commentPos: number, commentEnd: number, _kind: SyntaxKind, hasTrailingNewLine: boolean, rangePos: number) {
|
||||
if (!hasWrittenComment) {
|
||||
emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos);
|
||||
hasWrittenComment = true;
|
||||
@@ -211,7 +211,7 @@ namespace ts {
|
||||
forEachTrailingCommentToEmit(pos, emitTrailingComment);
|
||||
}
|
||||
|
||||
function emitTrailingComment(commentPos: number, commentEnd: number, kind: SyntaxKind, hasTrailingNewLine: boolean) {
|
||||
function emitTrailingComment(commentPos: number, commentEnd: number, _kind: SyntaxKind, hasTrailingNewLine: boolean) {
|
||||
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/
|
||||
if (!writer.isAtStartOfLine()) {
|
||||
writer.write(" ");
|
||||
@@ -242,7 +242,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function emitTrailingCommentOfPosition(commentPos: number, commentEnd: number, kind: SyntaxKind, hasTrailingNewLine: boolean) {
|
||||
function emitTrailingCommentOfPosition(commentPos: number, commentEnd: number, _kind: SyntaxKind, hasTrailingNewLine: boolean) {
|
||||
// trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space
|
||||
|
||||
emitPos(commentPos);
|
||||
|
||||
+63
-23
@@ -20,6 +20,9 @@ namespace ts {
|
||||
|
||||
const createObject = Object.create;
|
||||
|
||||
// More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times.
|
||||
export const collator: { compare(a: string, b: string): number } = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined;
|
||||
|
||||
export function createMap<T>(template?: MapLike<T>): Map<T> {
|
||||
const map: Map<T> = createObject(null); // tslint:disable-line:no-null-keyword
|
||||
|
||||
@@ -265,13 +268,33 @@ namespace ts {
|
||||
if (array) {
|
||||
result = [];
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
const v = array[i];
|
||||
result.push(f(v, i));
|
||||
result.push(f(array[i], i));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Maps from T to T and avoids allocation if all elements map to themselves
|
||||
export function sameMap<T>(array: T[], f: (x: T, i: number) => T): T[] {
|
||||
let result: T[];
|
||||
if (array) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (result) {
|
||||
result.push(f(array[i], i));
|
||||
}
|
||||
else {
|
||||
const item = array[i];
|
||||
const mapped = f(item, i);
|
||||
if (item !== mapped) {
|
||||
result = array.slice(0, i);
|
||||
result.push(mapped);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result || array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flattens an array containing a mix of array or non-array elements.
|
||||
*
|
||||
@@ -399,6 +422,17 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function some<T>(array: T[], predicate?: (value: T) => boolean): boolean {
|
||||
if (array) {
|
||||
for (const v of array) {
|
||||
if (!predicate || predicate(v)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function concatenate<T>(array1: T[], array2: T[]): T[] {
|
||||
if (!array2 || !array2.length) return array1;
|
||||
if (!array1 || !array1.length) return array2;
|
||||
@@ -498,6 +532,12 @@ namespace ts {
|
||||
: undefined;
|
||||
}
|
||||
|
||||
export function replaceElement<T>(array: T[], index: number, value: T): T[] {
|
||||
const result = array.slice(0);
|
||||
result[index] = value;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a binary search, finding the index at which 'value' occurs in 'array'.
|
||||
* If no such index is found, returns the 2's-complement of first index at which
|
||||
@@ -829,6 +869,14 @@ namespace ts {
|
||||
return Array.isArray ? Array.isArray(value) : value instanceof Array;
|
||||
}
|
||||
|
||||
/** Does nothing. */
|
||||
export function noop(): void {}
|
||||
|
||||
/** Throws an error because a function is not implemented. */
|
||||
export function notImplemented(): never {
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
|
||||
export function memoize<T>(callback: () => T): () => T {
|
||||
let value: T;
|
||||
return () => {
|
||||
@@ -869,7 +917,7 @@ namespace ts {
|
||||
return t => compose(a(t));
|
||||
}
|
||||
else {
|
||||
return t => u => u;
|
||||
return _ => u => u;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -906,10 +954,10 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function formatStringFromArgs(text: string, args: { [index: number]: any; }, baseIndex?: number): string {
|
||||
function formatStringFromArgs(text: string, args: { [index: number]: string; }, baseIndex?: number): string {
|
||||
baseIndex = baseIndex || 0;
|
||||
|
||||
return text.replace(/{(\d+)}/g, (match, index?) => args[+index + baseIndex]);
|
||||
return text.replace(/{(\d+)}/g, (_match, index?) => args[+index + baseIndex]);
|
||||
}
|
||||
|
||||
export let localizedDiagnosticMessages: Map<string> = undefined;
|
||||
@@ -918,7 +966,7 @@ namespace ts {
|
||||
return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] || message.message;
|
||||
}
|
||||
|
||||
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic;
|
||||
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic;
|
||||
export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage): Diagnostic {
|
||||
const end = start + length;
|
||||
|
||||
@@ -948,7 +996,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/* internal */
|
||||
export function formatMessage(dummy: any, message: DiagnosticMessage): string {
|
||||
export function formatMessage(_dummy: any, message: DiagnosticMessage): string {
|
||||
let text = getLocaleSpecificMessage(message);
|
||||
|
||||
if (arguments.length > 2) {
|
||||
@@ -958,7 +1006,7 @@ namespace ts {
|
||||
return text;
|
||||
}
|
||||
|
||||
export function createCompilerDiagnostic(message: DiagnosticMessage, ...args: any[]): Diagnostic;
|
||||
export function createCompilerDiagnostic(message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic;
|
||||
export function createCompilerDiagnostic(message: DiagnosticMessage): Diagnostic {
|
||||
let text = getLocaleSpecificMessage(message);
|
||||
|
||||
@@ -1016,7 +1064,8 @@ namespace ts {
|
||||
if (a === undefined) return Comparison.LessThan;
|
||||
if (b === undefined) return Comparison.GreaterThan;
|
||||
if (ignoreCase) {
|
||||
if (String.prototype.localeCompare) {
|
||||
if (collator && String.prototype.localeCompare) {
|
||||
// accent means a ≠ b, a ≠ á, a = A
|
||||
const result = a.localeCompare(b, /*locales*/ undefined, { usage: "sort", sensitivity: "accent" });
|
||||
return result < 0 ? Comparison.LessThan : result > 0 ? Comparison.GreaterThan : Comparison.EqualTo;
|
||||
}
|
||||
@@ -1186,12 +1235,6 @@ namespace ts {
|
||||
return path.substr(0, Math.max(getRootLength(path), path.lastIndexOf(directorySeparator)));
|
||||
}
|
||||
|
||||
function getBasename(path: Path): Path;
|
||||
function getBasename(path: string): string;
|
||||
function getBasename(path: string): string {
|
||||
return path.substr(Math.max(getRootLength(path), path.lastIndexOf(directorySeparator)));
|
||||
}
|
||||
|
||||
export function isUrl(path: string) {
|
||||
return path && !isRootedDiskPath(path) && path.indexOf("://") !== -1;
|
||||
}
|
||||
@@ -1209,7 +1252,7 @@ namespace ts {
|
||||
export function getEmitModuleKind(compilerOptions: CompilerOptions) {
|
||||
return typeof compilerOptions.module === "number" ?
|
||||
compilerOptions.module :
|
||||
getEmitScriptTarget(compilerOptions) === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.CommonJS;
|
||||
getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES2015 ? ModuleKind.ES2015 : ModuleKind.CommonJS;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -1622,7 +1665,7 @@ namespace ts {
|
||||
basePaths: string[];
|
||||
}
|
||||
|
||||
export function getFileMatcherPatterns(path: string, extensions: string[], excludes: string[], includes: string[], useCaseSensitiveFileNames: boolean, currentDirectory: string): FileMatcherPatterns {
|
||||
export function getFileMatcherPatterns(path: string, excludes: string[], includes: string[], useCaseSensitiveFileNames: boolean, currentDirectory: string): FileMatcherPatterns {
|
||||
path = normalizePath(path);
|
||||
currentDirectory = normalizePath(currentDirectory);
|
||||
const absolutePath = combinePaths(currentDirectory, path);
|
||||
@@ -1639,7 +1682,7 @@ namespace ts {
|
||||
path = normalizePath(path);
|
||||
currentDirectory = normalizePath(currentDirectory);
|
||||
|
||||
const patterns = getFileMatcherPatterns(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory);
|
||||
const patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory);
|
||||
|
||||
const regexFlag = useCaseSensitiveFileNames ? "" : "i";
|
||||
const includeFileRegex = patterns.includeFilePattern && new RegExp(patterns.includeFilePattern, regexFlag);
|
||||
@@ -1874,11 +1917,11 @@ namespace ts {
|
||||
this.declarations = undefined;
|
||||
}
|
||||
|
||||
function Type(this: Type, checker: TypeChecker, flags: TypeFlags) {
|
||||
function Type(this: Type, _checker: TypeChecker, flags: TypeFlags) {
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
function Signature(checker: TypeChecker) {
|
||||
function Signature() {
|
||||
}
|
||||
|
||||
function Node(this: Node, kind: SyntaxKind, pos: number, end: number) {
|
||||
@@ -1911,9 +1954,6 @@ namespace ts {
|
||||
}
|
||||
|
||||
export namespace Debug {
|
||||
declare var process: any;
|
||||
declare var require: any;
|
||||
|
||||
export let currentAssertionLevel = AssertionLevel.None;
|
||||
|
||||
export function shouldAssert(level: AssertionLevel): boolean {
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace ts {
|
||||
let isCurrentFileExternalModule: boolean;
|
||||
let reportedDeclarationError = false;
|
||||
let errorNameNode: DeclarationName;
|
||||
const emitJsDocComments = compilerOptions.removeComments ? function (declaration: Node) { } : writeJsDocComments;
|
||||
const emitJsDocComments = compilerOptions.removeComments ? noop : writeJsDocComments;
|
||||
const emit = compilerOptions.stripInternal ? stripInternal : emitNode;
|
||||
let noDeclare: boolean;
|
||||
|
||||
@@ -580,7 +580,7 @@ namespace ts {
|
||||
writeAsynchronousModuleElements(nodes);
|
||||
}
|
||||
|
||||
function getDefaultExportAccessibilityDiagnostic(diagnostic: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
|
||||
function getDefaultExportAccessibilityDiagnostic(): SymbolAccessibilityDiagnostic {
|
||||
return {
|
||||
diagnosticMessage: Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0,
|
||||
errorNode: node
|
||||
@@ -710,7 +710,7 @@ namespace ts {
|
||||
}
|
||||
writer.writeLine();
|
||||
|
||||
function getImportEntityNameVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
|
||||
function getImportEntityNameVisibilityError(): SymbolAccessibilityDiagnostic {
|
||||
return {
|
||||
diagnosticMessage: Diagnostics.Import_declaration_0_is_using_private_name_1,
|
||||
errorNode: node,
|
||||
@@ -888,7 +888,7 @@ namespace ts {
|
||||
writeLine();
|
||||
enclosingDeclaration = prevEnclosingDeclaration;
|
||||
|
||||
function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
|
||||
function getTypeAliasDeclarationVisibilityError(): SymbolAccessibilityDiagnostic {
|
||||
return {
|
||||
diagnosticMessage: Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1,
|
||||
errorNode: node.type,
|
||||
@@ -955,7 +955,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getTypeParameterConstraintVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
|
||||
function getTypeParameterConstraintVisibilityError(): SymbolAccessibilityDiagnostic {
|
||||
// Type parameter constraints are named by user so we should always be able to name it
|
||||
let diagnosticMessage: DiagnosticMessage;
|
||||
switch (node.parent.kind) {
|
||||
@@ -1029,7 +1029,7 @@ namespace ts {
|
||||
resolver.writeBaseConstructorTypeOfClass(<ClassLikeDeclaration>enclosingDeclaration, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue, writer);
|
||||
}
|
||||
|
||||
function getHeritageClauseVisibilityError(symbolAccessibilityResult: SymbolAccessibilityResult): SymbolAccessibilityDiagnostic {
|
||||
function getHeritageClauseVisibilityError(): SymbolAccessibilityDiagnostic {
|
||||
let diagnosticMessage: DiagnosticMessage;
|
||||
// Heritage clause is written by user so it can always be named
|
||||
if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) {
|
||||
@@ -1743,7 +1743,7 @@ namespace ts {
|
||||
}
|
||||
return addedBundledEmitReference;
|
||||
|
||||
function getDeclFileName(emitFileNames: EmitFileNames, sourceFiles: SourceFile[], isBundledEmit: boolean) {
|
||||
function getDeclFileName(emitFileNames: EmitFileNames, _sourceFiles: SourceFile[], isBundledEmit: boolean) {
|
||||
// Dont add reference path to this file if it is a bundled emit and caller asked not emit bundled file path
|
||||
if (isBundledEmit && !addBundledFileReference) {
|
||||
return;
|
||||
|
||||
@@ -603,10 +603,6 @@
|
||||
"category": "Error",
|
||||
"code": 1194
|
||||
},
|
||||
"Catch clause variable name must be an identifier.": {
|
||||
"category": "Error",
|
||||
"code": 1195
|
||||
},
|
||||
"Catch clause variable cannot have a type annotation.": {
|
||||
"category": "Error",
|
||||
"code": 1196
|
||||
@@ -1923,7 +1919,7 @@
|
||||
"category": "Error",
|
||||
"code": 2685
|
||||
},
|
||||
"Identifier '{0}' must be imported from a module": {
|
||||
"'{0}' refers to a UMD global, but the current file is a module. Consider adding an import instead.": {
|
||||
"category": "Error",
|
||||
"code": 2686
|
||||
},
|
||||
@@ -2861,6 +2857,10 @@
|
||||
"category": "Error",
|
||||
"code": 6140
|
||||
},
|
||||
"Parse in strict mode and emit \"use strict\" for each source file": {
|
||||
"category": "Message",
|
||||
"code": 6141
|
||||
},
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
"code": 7005
|
||||
@@ -2957,7 +2957,7 @@
|
||||
"category": "Error",
|
||||
"code": 7033
|
||||
},
|
||||
"Variable '{0}' implicitly has type 'any' in some locations where its type cannot be determined.": {
|
||||
"Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined.": {
|
||||
"category": "Error",
|
||||
"code": 7034
|
||||
},
|
||||
@@ -3081,5 +3081,42 @@
|
||||
"The path in an 'extends' options must be relative or rooted.": {
|
||||
"category": "Error",
|
||||
"code": 18001
|
||||
},
|
||||
"The 'files' list in config file '{0}' is empty.": {
|
||||
"category": "Error",
|
||||
"code": 18002
|
||||
},
|
||||
"No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'.": {
|
||||
"category": "Error",
|
||||
"code": 18003
|
||||
},
|
||||
|
||||
"Add missing 'super()' call.": {
|
||||
"category": "Message",
|
||||
"code": 90001
|
||||
},
|
||||
"Make 'super()' call the first statement in the constructor.": {
|
||||
"category": "Message",
|
||||
"code": 90002
|
||||
},
|
||||
"Change 'extends' to 'implements'": {
|
||||
"category": "Message",
|
||||
"code": 90003
|
||||
},
|
||||
"Remove unused identifiers": {
|
||||
"category": "Message",
|
||||
"code": 90004
|
||||
},
|
||||
"Implement interface on reference": {
|
||||
"category": "Message",
|
||||
"code": 90005
|
||||
},
|
||||
"Implement interface on class": {
|
||||
"category": "Message",
|
||||
"code": 90006
|
||||
},
|
||||
"Implement inherited abstract class": {
|
||||
"category": "Message",
|
||||
"code": 90007
|
||||
}
|
||||
}
|
||||
|
||||
+37
-17
@@ -14,7 +14,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
const id = (s: SourceFile) => s;
|
||||
const nullTransformers: Transformer[] = [ctx => id];
|
||||
const nullTransformers: Transformer[] = [_ => id];
|
||||
|
||||
// targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature
|
||||
export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile, emitOnlyDtsFiles?: boolean): EmitResult {
|
||||
@@ -504,15 +504,29 @@ const _super = (function (geti, seti) {
|
||||
|
||||
// Contextual keywords
|
||||
case SyntaxKind.AbstractKeyword:
|
||||
case SyntaxKind.AsKeyword:
|
||||
case SyntaxKind.AnyKeyword:
|
||||
case SyntaxKind.AsyncKeyword:
|
||||
case SyntaxKind.AwaitKeyword:
|
||||
case SyntaxKind.BooleanKeyword:
|
||||
case SyntaxKind.ConstructorKeyword:
|
||||
case SyntaxKind.DeclareKeyword:
|
||||
case SyntaxKind.NumberKeyword:
|
||||
case SyntaxKind.GetKeyword:
|
||||
case SyntaxKind.IsKeyword:
|
||||
case SyntaxKind.ModuleKeyword:
|
||||
case SyntaxKind.NamespaceKeyword:
|
||||
case SyntaxKind.NeverKeyword:
|
||||
case SyntaxKind.ReadonlyKeyword:
|
||||
case SyntaxKind.RequireKeyword:
|
||||
case SyntaxKind.NumberKeyword:
|
||||
case SyntaxKind.SetKeyword:
|
||||
case SyntaxKind.StringKeyword:
|
||||
case SyntaxKind.SymbolKeyword:
|
||||
case SyntaxKind.TypeKeyword:
|
||||
case SyntaxKind.UndefinedKeyword:
|
||||
case SyntaxKind.FromKeyword:
|
||||
case SyntaxKind.GlobalKeyword:
|
||||
case SyntaxKind.OfKeyword:
|
||||
writeTokenText(kind);
|
||||
return;
|
||||
|
||||
@@ -579,7 +593,7 @@ const _super = (function (geti, seti) {
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return emitExpressionWithTypeArguments(<ExpressionWithTypeArguments>node);
|
||||
case SyntaxKind.ThisType:
|
||||
return emitThisType(<ThisTypeNode>node);
|
||||
return emitThisType();
|
||||
case SyntaxKind.LiteralType:
|
||||
return emitLiteralType(<LiteralTypeNode>node);
|
||||
|
||||
@@ -595,7 +609,7 @@ const _super = (function (geti, seti) {
|
||||
case SyntaxKind.TemplateSpan:
|
||||
return emitTemplateSpan(<TemplateSpan>node);
|
||||
case SyntaxKind.SemicolonClassElement:
|
||||
return emitSemicolonClassElement(<SemicolonClassElement>node);
|
||||
return emitSemicolonClassElement();
|
||||
|
||||
// Statements
|
||||
case SyntaxKind.Block:
|
||||
@@ -603,7 +617,7 @@ const _super = (function (geti, seti) {
|
||||
case SyntaxKind.VariableStatement:
|
||||
return emitVariableStatement(<VariableStatement>node);
|
||||
case SyntaxKind.EmptyStatement:
|
||||
return emitEmptyStatement(<EmptyStatement>node);
|
||||
return emitEmptyStatement();
|
||||
case SyntaxKind.ExpressionStatement:
|
||||
return emitExpressionStatement(<ExpressionStatement>node);
|
||||
case SyntaxKind.IfStatement:
|
||||
@@ -1000,7 +1014,7 @@ const _super = (function (geti, seti) {
|
||||
write(";");
|
||||
}
|
||||
|
||||
function emitSemicolonClassElement(node: SemicolonClassElement) {
|
||||
function emitSemicolonClassElement() {
|
||||
write(";");
|
||||
}
|
||||
|
||||
@@ -1070,7 +1084,7 @@ const _super = (function (geti, seti) {
|
||||
write(")");
|
||||
}
|
||||
|
||||
function emitThisType(node: ThisTypeNode) {
|
||||
function emitThisType() {
|
||||
write("this");
|
||||
}
|
||||
|
||||
@@ -1198,12 +1212,14 @@ const _super = (function (geti, seti) {
|
||||
|
||||
function emitCallExpression(node: CallExpression) {
|
||||
emitExpression(node.expression);
|
||||
emitTypeArguments(node, node.typeArguments);
|
||||
emitExpressionList(node, node.arguments, ListFormat.CallExpressionArguments);
|
||||
}
|
||||
|
||||
function emitNewExpression(node: NewExpression) {
|
||||
write("new ");
|
||||
emitExpression(node.expression);
|
||||
emitTypeArguments(node, node.typeArguments);
|
||||
emitExpressionList(node, node.arguments, ListFormat.NewExpressionArguments);
|
||||
}
|
||||
|
||||
@@ -1381,7 +1397,7 @@ const _super = (function (geti, seti) {
|
||||
// Statements
|
||||
//
|
||||
|
||||
function emitBlock(node: Block, format?: ListFormat) {
|
||||
function emitBlock(node: Block) {
|
||||
if (isSingleLineEmptyBlock(node)) {
|
||||
writeToken(SyntaxKind.OpenBraceToken, node.pos, /*contextNode*/ node);
|
||||
write(" ");
|
||||
@@ -1409,7 +1425,7 @@ const _super = (function (geti, seti) {
|
||||
write(";");
|
||||
}
|
||||
|
||||
function emitEmptyStatement(node: EmptyStatement) {
|
||||
function emitEmptyStatement() {
|
||||
write(";");
|
||||
}
|
||||
|
||||
@@ -1575,6 +1591,7 @@ const _super = (function (geti, seti) {
|
||||
|
||||
function emitVariableDeclaration(node: VariableDeclaration) {
|
||||
emit(node.name);
|
||||
emitWithPrefix(": ", node.type);
|
||||
emitExpressionWithPrefix(" = ", node.initializer);
|
||||
}
|
||||
|
||||
@@ -1606,13 +1623,13 @@ const _super = (function (geti, seti) {
|
||||
|
||||
if (getEmitFlags(node) & EmitFlags.ReuseTempVariableScope) {
|
||||
emitSignatureHead(node);
|
||||
emitBlockFunctionBody(node, body);
|
||||
emitBlockFunctionBody(body);
|
||||
}
|
||||
else {
|
||||
const savedTempFlags = tempFlags;
|
||||
tempFlags = 0;
|
||||
emitSignatureHead(node);
|
||||
emitBlockFunctionBody(node, body);
|
||||
emitBlockFunctionBody(body);
|
||||
tempFlags = savedTempFlags;
|
||||
}
|
||||
|
||||
@@ -1639,7 +1656,7 @@ const _super = (function (geti, seti) {
|
||||
emitWithPrefix(": ", node.type);
|
||||
}
|
||||
|
||||
function shouldEmitBlockFunctionBodyOnSingleLine(parentNode: Node, body: Block) {
|
||||
function shouldEmitBlockFunctionBodyOnSingleLine(body: Block) {
|
||||
// We must emit a function body as a single-line body in the following case:
|
||||
// * The body has NodeEmitFlags.SingleLine specified.
|
||||
|
||||
@@ -1677,12 +1694,12 @@ const _super = (function (geti, seti) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function emitBlockFunctionBody(parentNode: Node, body: Block) {
|
||||
function emitBlockFunctionBody(body: Block) {
|
||||
write(" {");
|
||||
increaseIndent();
|
||||
|
||||
emitBodyWithDetachedComments(body, body.statements,
|
||||
shouldEmitBlockFunctionBodyOnSingleLine(parentNode, body)
|
||||
shouldEmitBlockFunctionBodyOnSingleLine(body)
|
||||
? emitBlockFunctionBodyOnSingleLine
|
||||
: emitBlockFunctionBodyWorker);
|
||||
|
||||
@@ -2165,7 +2182,7 @@ const _super = (function (geti, seti) {
|
||||
|
||||
// Only Emit __extends function when target ES5.
|
||||
// For target ES6 and above, we can emit classDeclaration as is.
|
||||
if ((languageVersion < ScriptTarget.ES6) && (!extendsEmitted && node.flags & NodeFlags.HasClassExtends)) {
|
||||
if ((languageVersion < ScriptTarget.ES2015) && (!extendsEmitted && node.flags & NodeFlags.HasClassExtends)) {
|
||||
writeLines(extendsHelper);
|
||||
extendsEmitted = true;
|
||||
helpersEmitted = true;
|
||||
@@ -2192,9 +2209,12 @@ const _super = (function (geti, seti) {
|
||||
helpersEmitted = true;
|
||||
}
|
||||
|
||||
if (!awaiterEmitted && node.flags & NodeFlags.HasAsyncFunctions) {
|
||||
// Only emit __awaiter function when target ES5/ES6.
|
||||
// Only emit __generator function when target ES5.
|
||||
// For target ES2017 and above, we can emit async/await as is.
|
||||
if ((languageVersion < ScriptTarget.ES2017) && (!awaiterEmitted && node.flags & NodeFlags.HasAsyncFunctions)) {
|
||||
writeLines(awaiterHelper);
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
if (languageVersion < ScriptTarget.ES2015) {
|
||||
writeLines(generatorHelper);
|
||||
}
|
||||
|
||||
|
||||
+57
-19
@@ -525,9 +525,9 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function createFunctionExpression(asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags) {
|
||||
export function createFunctionExpression(modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block, location?: TextRange, flags?: NodeFlags) {
|
||||
const node = <FunctionExpression>createNode(SyntaxKind.FunctionExpression, location, flags);
|
||||
node.modifiers = undefined;
|
||||
node.modifiers = modifiers ? createNodeArray(modifiers) : undefined;
|
||||
node.asteriskToken = asteriskToken;
|
||||
node.name = typeof name === "string" ? createIdentifier(name) : name;
|
||||
node.typeParameters = typeParameters ? createNodeArray(typeParameters) : undefined;
|
||||
@@ -537,9 +537,9 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
export function updateFunctionExpression(node: FunctionExpression, name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block) {
|
||||
if (node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) {
|
||||
return updateNode(createFunctionExpression(node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node);
|
||||
export function updateFunctionExpression(node: FunctionExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block) {
|
||||
if (node.name !== name || node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body) {
|
||||
return updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body, /*location*/ node, node.flags), node);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
@@ -1625,7 +1625,9 @@ namespace ts {
|
||||
// flag and setting a parent node.
|
||||
const react = createIdentifier(reactNamespace || "React");
|
||||
react.flags &= ~NodeFlags.Synthesized;
|
||||
react.parent = parent;
|
||||
// Set the parent that is in parse tree
|
||||
// this makes sure that parent chain is intact for checker to traverse complete scope tree
|
||||
react.parent = getParseTreeNode(parent);
|
||||
return react;
|
||||
}
|
||||
|
||||
@@ -1736,6 +1738,7 @@ namespace ts {
|
||||
|
||||
export function createAwaiterHelper(externalHelpersModuleName: Identifier | undefined, hasLexicalArguments: boolean, promiseConstructor: EntityName | Expression, body: Block) {
|
||||
const generatorFunc = createFunctionExpression(
|
||||
/*modifiers*/ undefined,
|
||||
createToken(SyntaxKind.AsteriskToken),
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
@@ -1909,6 +1912,7 @@ namespace ts {
|
||||
createCall(
|
||||
createParen(
|
||||
createFunctionExpression(
|
||||
/*modifiers*/ undefined,
|
||||
/*asteriskToken*/ undefined,
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
@@ -1984,7 +1988,7 @@ namespace ts {
|
||||
}
|
||||
else if (callee.kind === SyntaxKind.SuperKeyword) {
|
||||
thisArg = createThis();
|
||||
target = languageVersion < ScriptTarget.ES6 ? createIdentifier("_super", /*location*/ callee) : <PrimaryExpression>callee;
|
||||
target = languageVersion < ScriptTarget.ES2015 ? createIdentifier("_super", /*location*/ callee) : <PrimaryExpression>callee;
|
||||
}
|
||||
else {
|
||||
switch (callee.kind) {
|
||||
@@ -2090,6 +2094,7 @@ namespace ts {
|
||||
const properties: ObjectLiteralElementLike[] = [];
|
||||
if (getAccessor) {
|
||||
const getterFunction = createFunctionExpression(
|
||||
getAccessor.modifiers,
|
||||
/*asteriskToken*/ undefined,
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
@@ -2105,6 +2110,7 @@ namespace ts {
|
||||
|
||||
if (setAccessor) {
|
||||
const setterFunction = createFunctionExpression(
|
||||
setAccessor.modifiers,
|
||||
/*asteriskToken*/ undefined,
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
@@ -2171,6 +2177,7 @@ namespace ts {
|
||||
createMemberAccessForPropertyName(receiver, method.name, /*location*/ method.name),
|
||||
setOriginalNode(
|
||||
createFunctionExpression(
|
||||
method.modifiers,
|
||||
method.asteriskToken,
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
@@ -2206,7 +2213,7 @@ namespace ts {
|
||||
* @param visitor: Optional callback used to visit any custom prologue directives.
|
||||
*/
|
||||
export function addPrologueDirectives(target: Statement[], source: Statement[], ensureUseStrict?: boolean, visitor?: (node: Node) => VisitResult<Node>): number {
|
||||
Debug.assert(target.length === 0, "PrologueDirectives should be at the first statement in the target statements array");
|
||||
Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array");
|
||||
let foundUseStrict = false;
|
||||
let statementOffset = 0;
|
||||
const numStatements = source.length;
|
||||
@@ -2219,22 +2226,53 @@ namespace ts {
|
||||
target.push(statement);
|
||||
}
|
||||
else {
|
||||
if (ensureUseStrict && !foundUseStrict) {
|
||||
target.push(startOnNewLine(createStatement(createLiteral("use strict"))));
|
||||
foundUseStrict = true;
|
||||
}
|
||||
if (getEmitFlags(statement) & EmitFlags.CustomPrologue) {
|
||||
target.push(visitor ? visitNode(statement, visitor, isStatement) : statement);
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
statementOffset++;
|
||||
}
|
||||
if (ensureUseStrict && !foundUseStrict) {
|
||||
target.push(startOnNewLine(createStatement(createLiteral("use strict"))));
|
||||
}
|
||||
while (statementOffset < numStatements) {
|
||||
const statement = source[statementOffset];
|
||||
if (getEmitFlags(statement) & EmitFlags.CustomPrologue) {
|
||||
target.push(visitor ? visitNode(statement, visitor, isStatement) : statement);
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
statementOffset++;
|
||||
}
|
||||
return statementOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures "use strict" directive is added
|
||||
*
|
||||
* @param node source file
|
||||
*/
|
||||
export function ensureUseStrict(node: SourceFile): SourceFile {
|
||||
let foundUseStrict = false;
|
||||
for (const statement of node.statements) {
|
||||
if (isPrologueDirective(statement)) {
|
||||
if (isUseStrictPrologue(statement as ExpressionStatement)) {
|
||||
foundUseStrict = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!foundUseStrict) {
|
||||
const statements: Statement[] = [];
|
||||
statements.push(startOnNewLine(createStatement(createLiteral("use strict"))));
|
||||
// add "use strict" as the first statement
|
||||
return updateSourceFileNode(node, statements.concat(node.statements));
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps the operand to a BinaryExpression in parentheses if they are needed to preserve the intended
|
||||
* order of operations.
|
||||
@@ -2910,4 +2948,4 @@ namespace ts {
|
||||
function tryGetModuleNameFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration, host: EmitHost, resolver: EmitResolver, compilerOptions: CompilerOptions) {
|
||||
return tryGetModuleNameFromFile(resolver.getExternalModuleFileFromDeclaration(declaration), host, compilerOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace ts {
|
||||
|
||||
/* @internal */
|
||||
export function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void;
|
||||
export function trace(host: ModuleResolutionHost, message: DiagnosticMessage): void {
|
||||
export function trace(host: ModuleResolutionHost): void {
|
||||
host.trace(formatMessage.apply(undefined, arguments));
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -572,10 +572,10 @@ namespace ts {
|
||||
// attached to the EOF token.
|
||||
let parseErrorBeforeNextFinishedNode = false;
|
||||
|
||||
export function parseSourceFile(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile {
|
||||
export function parseSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, syntaxCursor: IncrementalParser.SyntaxCursor, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile {
|
||||
scriptKind = ensureScriptKind(fileName, scriptKind);
|
||||
|
||||
initializeState(fileName, _sourceText, languageVersion, _syntaxCursor, scriptKind);
|
||||
initializeState(sourceText, languageVersion, syntaxCursor, scriptKind);
|
||||
|
||||
const result = parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind);
|
||||
|
||||
@@ -589,7 +589,7 @@ namespace ts {
|
||||
return scriptKind === ScriptKind.TSX || scriptKind === ScriptKind.JSX || scriptKind === ScriptKind.JS ? LanguageVariant.JSX : LanguageVariant.Standard;
|
||||
}
|
||||
|
||||
function initializeState(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, scriptKind: ScriptKind) {
|
||||
function initializeState(_sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, scriptKind: ScriptKind) {
|
||||
NodeConstructor = objectAllocator.getNodeConstructor();
|
||||
TokenConstructor = objectAllocator.getTokenConstructor();
|
||||
IdentifierConstructor = objectAllocator.getIdentifierConstructor();
|
||||
@@ -5259,7 +5259,7 @@ namespace ts {
|
||||
parseExpected(SyntaxKind.ClassKeyword);
|
||||
node.name = parseNameOfClassDeclarationOrExpression();
|
||||
node.typeParameters = parseTypeParameters();
|
||||
node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ true);
|
||||
node.heritageClauses = parseHeritageClauses();
|
||||
|
||||
if (parseExpected(SyntaxKind.OpenBraceToken)) {
|
||||
// ClassTail[Yield,Await] : (Modified) See 14.5
|
||||
@@ -5289,7 +5289,7 @@ namespace ts {
|
||||
return token() === SyntaxKind.ImplementsKeyword && lookAhead(nextTokenIsIdentifierOrKeyword);
|
||||
}
|
||||
|
||||
function parseHeritageClauses(isClassHeritageClause: boolean): NodeArray<HeritageClause> {
|
||||
function parseHeritageClauses(): NodeArray<HeritageClause> {
|
||||
// ClassTail[Yield,Await] : (Modified) See 14.5
|
||||
// ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt }
|
||||
|
||||
@@ -5337,7 +5337,7 @@ namespace ts {
|
||||
parseExpected(SyntaxKind.InterfaceKeyword);
|
||||
node.name = parseIdentifier();
|
||||
node.typeParameters = parseTypeParameters();
|
||||
node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false);
|
||||
node.heritageClauses = parseHeritageClauses();
|
||||
node.members = parseObjectTypeMembers();
|
||||
return addJSDocComment(finishNode(node));
|
||||
}
|
||||
@@ -5352,7 +5352,7 @@ namespace ts {
|
||||
parseExpected(SyntaxKind.EqualsToken);
|
||||
node.type = parseType();
|
||||
parseSemicolon();
|
||||
return finishNode(node);
|
||||
return addJSDocComment(finishNode(node));
|
||||
}
|
||||
|
||||
// In an ambient declaration, the grammar only allows integer literals as initializers.
|
||||
@@ -5472,7 +5472,7 @@ namespace ts {
|
||||
|
||||
exportDeclaration.name = parseIdentifier();
|
||||
|
||||
parseExpected(SyntaxKind.SemicolonToken);
|
||||
parseSemicolon();
|
||||
|
||||
return finishNode(exportDeclaration);
|
||||
}
|
||||
@@ -5817,7 +5817,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function parseJSDocTypeExpressionForTests(content: string, start: number, length: number) {
|
||||
initializeState("file.js", content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS);
|
||||
initializeState(content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS);
|
||||
sourceFile = createSourceFile("file.js", ScriptTarget.Latest, ScriptKind.JS);
|
||||
scanner.setText(content, start, length);
|
||||
currentToken = scanner.scan();
|
||||
@@ -6134,7 +6134,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function parseIsolatedJSDocComment(content: string, start: number, length: number) {
|
||||
initializeState("file.js", content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS);
|
||||
initializeState(content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS);
|
||||
sourceFile = <SourceFile>{ languageVariant: LanguageVariant.Standard, text: content };
|
||||
const jsDoc = parseJSDocCommentWorker(start, length);
|
||||
const diagnostics = parseDiagnostics;
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace ts.performance {
|
||||
|
||||
const profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true
|
||||
? onProfilerEvent
|
||||
: (markName: string) => { };
|
||||
: (_markName: string) => { };
|
||||
|
||||
let enabled = false;
|
||||
let profilerStart = 0;
|
||||
|
||||
+33
-31
@@ -474,7 +474,7 @@ namespace ts {
|
||||
(oldOptions.baseUrl !== options.baseUrl) ||
|
||||
(oldOptions.maxNodeModuleJsDepth !== options.maxNodeModuleJsDepth) ||
|
||||
!arrayIsEqualTo(oldOptions.lib, options.lib) ||
|
||||
!arrayIsEqualTo(oldOptions.typeRoots, oldOptions.typeRoots) ||
|
||||
!arrayIsEqualTo(oldOptions.typeRoots, options.typeRoots) ||
|
||||
!arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) ||
|
||||
!equalOwnProperties(oldOptions.paths, options.paths)) {
|
||||
return false;
|
||||
@@ -724,7 +724,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getSyntacticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
|
||||
function getSyntacticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
|
||||
return sourceFile.parseDiagnostics;
|
||||
}
|
||||
|
||||
@@ -761,16 +761,16 @@ namespace ts {
|
||||
// Instead, we just report errors for using TypeScript-only constructs from within a
|
||||
// JavaScript file.
|
||||
const checkDiagnostics = isSourceFileJavaScript(sourceFile) ?
|
||||
getJavaScriptSemanticDiagnosticsForFile(sourceFile, cancellationToken) :
|
||||
getJavaScriptSemanticDiagnosticsForFile(sourceFile) :
|
||||
typeChecker.getDiagnostics(sourceFile, cancellationToken);
|
||||
const fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName);
|
||||
const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
|
||||
|
||||
return bindDiagnostics.concat(checkDiagnostics).concat(fileProcessingDiagnosticsInFile).concat(programDiagnosticsInFile);
|
||||
return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile);
|
||||
});
|
||||
}
|
||||
|
||||
function getJavaScriptSemanticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
|
||||
function getJavaScriptSemanticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
|
||||
return runWithCancellationToken(() => {
|
||||
const diagnostics: Diagnostic[] = [];
|
||||
walk(sourceFile);
|
||||
@@ -950,8 +950,7 @@ namespace ts {
|
||||
return runWithCancellationToken(() => {
|
||||
const resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken);
|
||||
// Don't actually write any files since we're just getting diagnostics.
|
||||
const writeFile: WriteFileCallback = () => { };
|
||||
return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile);
|
||||
return ts.getDeclarationDiagnostics(getEmitHost(noop), resolver, sourceFile);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -973,7 +972,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function processRootFile(fileName: string, isDefaultLib: boolean) {
|
||||
processSourceFile(normalizePath(fileName), isDefaultLib, /*isReference*/ true);
|
||||
processSourceFile(normalizePath(fileName), isDefaultLib);
|
||||
}
|
||||
|
||||
function fileReferenceIsEqualTo(a: FileReference, b: FileReference): boolean {
|
||||
@@ -1084,7 +1083,7 @@ namespace ts {
|
||||
/**
|
||||
* 'isReference' indicates whether the file was brought in via a reference directive (rather than an import declaration)
|
||||
*/
|
||||
function processSourceFile(fileName: string, isDefaultLib: boolean, isReference: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number) {
|
||||
function processSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number) {
|
||||
let diagnosticArgument: string[];
|
||||
let diagnostic: DiagnosticMessage;
|
||||
if (hasExtension(fileName)) {
|
||||
@@ -1092,7 +1091,7 @@ namespace ts {
|
||||
diagnostic = Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1;
|
||||
diagnosticArgument = [fileName, "'" + supportedExtensions.join("', '") + "'"];
|
||||
}
|
||||
else if (!findSourceFile(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd)) {
|
||||
else if (!findSourceFile(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd)) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
diagnosticArgument = [fileName];
|
||||
}
|
||||
@@ -1102,13 +1101,13 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
const nonTsFile: SourceFile = options.allowNonTsExtensions && findSourceFile(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd);
|
||||
const nonTsFile: SourceFile = options.allowNonTsExtensions && findSourceFile(fileName, toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd);
|
||||
if (!nonTsFile) {
|
||||
if (options.allowNonTsExtensions) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
diagnosticArgument = [fileName];
|
||||
}
|
||||
else if (!forEach(supportedExtensions, extension => findSourceFile(fileName + extension, toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, isReference, refFile, refPos, refEnd))) {
|
||||
else if (!forEach(supportedExtensions, extension => findSourceFile(fileName + extension, toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd))) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
fileName += ".ts";
|
||||
diagnosticArgument = [fileName];
|
||||
@@ -1137,7 +1136,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Get source file from normalized fileName
|
||||
function findSourceFile(fileName: string, path: Path, isDefaultLib: boolean, isReference: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): SourceFile {
|
||||
function findSourceFile(fileName: string, path: Path, isDefaultLib: boolean, refFile?: SourceFile, refPos?: number, refEnd?: number): SourceFile {
|
||||
if (filesByName.contains(path)) {
|
||||
const file = filesByName.get(path);
|
||||
// try to check if we've already seen this file but with a different casing in path
|
||||
@@ -1151,18 +1150,18 @@ namespace ts {
|
||||
if (file && sourceFilesFoundSearchingNodeModules[file.path] && currentNodeModulesDepth == 0) {
|
||||
sourceFilesFoundSearchingNodeModules[file.path] = false;
|
||||
if (!options.noResolve) {
|
||||
processReferencedFiles(file, getDirectoryPath(fileName), isDefaultLib);
|
||||
processReferencedFiles(file, isDefaultLib);
|
||||
processTypeReferenceDirectives(file);
|
||||
}
|
||||
|
||||
modulesWithElidedImports[file.path] = false;
|
||||
processImportedModules(file, getDirectoryPath(fileName));
|
||||
processImportedModules(file);
|
||||
}
|
||||
// See if we need to reprocess the imports due to prior skipped imports
|
||||
else if (file && modulesWithElidedImports[file.path]) {
|
||||
if (currentNodeModulesDepth < maxNodeModulesJsDepth) {
|
||||
modulesWithElidedImports[file.path] = false;
|
||||
processImportedModules(file, getDirectoryPath(fileName));
|
||||
processImportedModules(file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1198,14 +1197,13 @@ namespace ts {
|
||||
|
||||
skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib;
|
||||
|
||||
const basePath = getDirectoryPath(fileName);
|
||||
if (!options.noResolve) {
|
||||
processReferencedFiles(file, basePath, isDefaultLib);
|
||||
processReferencedFiles(file, isDefaultLib);
|
||||
processTypeReferenceDirectives(file);
|
||||
}
|
||||
|
||||
// always process imported modules to record module name resolutions
|
||||
processImportedModules(file, basePath);
|
||||
processImportedModules(file);
|
||||
|
||||
if (isDefaultLib) {
|
||||
files.unshift(file);
|
||||
@@ -1218,10 +1216,10 @@ namespace ts {
|
||||
return file;
|
||||
}
|
||||
|
||||
function processReferencedFiles(file: SourceFile, basePath: string, isDefaultLib: boolean) {
|
||||
function processReferencedFiles(file: SourceFile, isDefaultLib: boolean) {
|
||||
forEach(file.referencedFiles, ref => {
|
||||
const referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName);
|
||||
processSourceFile(referencedFileName, isDefaultLib, /*isReference*/ true, file, ref.pos, ref.end);
|
||||
processSourceFile(referencedFileName, isDefaultLib, file, ref.pos, ref.end);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1252,7 +1250,7 @@ namespace ts {
|
||||
if (resolvedTypeReferenceDirective) {
|
||||
if (resolvedTypeReferenceDirective.primary) {
|
||||
// resolved from the primary path
|
||||
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*isReference*/ true, refFile, refPos, refEnd);
|
||||
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd);
|
||||
}
|
||||
else {
|
||||
// If we already resolved to this file, it must have been a secondary reference. Check file contents
|
||||
@@ -1272,7 +1270,7 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
// First resolution of this library
|
||||
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*isReference*/ true, refFile, refPos, refEnd);
|
||||
processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1298,7 +1296,7 @@ namespace ts {
|
||||
return host.getCanonicalFileName(fileName);
|
||||
}
|
||||
|
||||
function processImportedModules(file: SourceFile, basePath: string) {
|
||||
function processImportedModules(file: SourceFile) {
|
||||
collectExternalModuleReferences(file);
|
||||
if (file.imports.length || file.moduleAugmentations.length) {
|
||||
file.resolvedModules = createMap<ResolvedModule>();
|
||||
@@ -1329,7 +1327,7 @@ namespace ts {
|
||||
else if (shouldAddFile) {
|
||||
findSourceFile(resolution.resolvedFileName,
|
||||
toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName),
|
||||
/*isDefaultLib*/ false, /*isReference*/ false,
|
||||
/*isDefaultLib*/ false,
|
||||
file,
|
||||
skipTrivia(file.text, file.imports[i].pos),
|
||||
file.imports[i].end);
|
||||
@@ -1469,12 +1467,16 @@ namespace ts {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib"));
|
||||
}
|
||||
|
||||
if (options.noImplicitUseStrict && options.alwaysStrict) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict"));
|
||||
}
|
||||
|
||||
const languageVersion = options.target || ScriptTarget.ES3;
|
||||
const outFile = options.outFile || options.out;
|
||||
|
||||
const firstNonAmbientExternalModuleSourceFile = forEach(files, f => isExternalModule(f) && !isDeclarationFile(f) ? f : undefined);
|
||||
if (options.isolatedModules) {
|
||||
if (options.module === ModuleKind.None && languageVersion < ScriptTarget.ES6) {
|
||||
if (options.module === ModuleKind.None && languageVersion < ScriptTarget.ES2015) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher));
|
||||
}
|
||||
|
||||
@@ -1484,7 +1486,7 @@ namespace ts {
|
||||
programDiagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
|
||||
}
|
||||
}
|
||||
else if (firstNonAmbientExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && options.module === ModuleKind.None) {
|
||||
else if (firstNonAmbientExternalModuleSourceFile && languageVersion < ScriptTarget.ES2015 && options.module === ModuleKind.None) {
|
||||
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
|
||||
const span = getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
|
||||
programDiagnostics.add(createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
|
||||
@@ -1533,7 +1535,7 @@ namespace ts {
|
||||
if (!options.noEmit && !options.suppressOutputPathCheck) {
|
||||
const emitHost = getEmitHost();
|
||||
const emitFilesSeen = createFileMap<boolean>(!host.useCaseSensitiveFileNames() ? key => key.toLocaleLowerCase() : undefined);
|
||||
forEachExpectedEmitFile(emitHost, (emitFileNames, sourceFiles, isBundledEmit) => {
|
||||
forEachExpectedEmitFile(emitHost, (emitFileNames) => {
|
||||
verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen);
|
||||
verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen);
|
||||
});
|
||||
@@ -1545,13 +1547,13 @@ namespace ts {
|
||||
const emitFilePath = toPath(emitFileName, currentDirectory, getCanonicalFileName);
|
||||
// Report error if the output overwrites input file
|
||||
if (filesByName.contains(emitFilePath)) {
|
||||
createEmitBlockingDiagnostics(emitFileName, emitFilePath, Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file);
|
||||
createEmitBlockingDiagnostics(emitFileName, Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file);
|
||||
}
|
||||
|
||||
// Report error if multiple files write into same file
|
||||
if (emitFilesSeen.contains(emitFilePath)) {
|
||||
// Already seen the same emit file - report error
|
||||
createEmitBlockingDiagnostics(emitFileName, emitFilePath, Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files);
|
||||
createEmitBlockingDiagnostics(emitFileName, Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files);
|
||||
}
|
||||
else {
|
||||
emitFilesSeen.set(emitFilePath, true);
|
||||
@@ -1560,7 +1562,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function createEmitBlockingDiagnostics(emitFileName: string, emitFilePath: Path, message: DiagnosticMessage) {
|
||||
function createEmitBlockingDiagnostics(emitFileName: string, message: DiagnosticMessage) {
|
||||
hasEmitBlockingDiagnostics.set(toPath(emitFileName, currentDirectory, getCanonicalFileName), true);
|
||||
programDiagnostics.add(createCompilerDiagnostic(message, emitFileName));
|
||||
}
|
||||
|
||||
@@ -723,7 +723,7 @@ namespace ts {
|
||||
return iterateCommentRanges(/*reduce*/ true, text, pos, /*trailing*/ true, cb, state, initial);
|
||||
}
|
||||
|
||||
function appendCommentRange(pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: any, comments: CommentRange[]) {
|
||||
function appendCommentRange(pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, _state: any, comments: CommentRange[]) {
|
||||
if (!comments) {
|
||||
comments = [];
|
||||
}
|
||||
@@ -1190,7 +1190,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function scanBinaryOrOctalDigits(base: number): number {
|
||||
Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8");
|
||||
Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8");
|
||||
|
||||
let value = 0;
|
||||
// For counting number of digits; Valid binaryIntegerLiteral must have at least one binary digit following B or b.
|
||||
|
||||
+13
-9
@@ -34,6 +34,8 @@ namespace ts {
|
||||
realpath?(path: string): string;
|
||||
/*@internal*/ getEnvironmentVariable(name: string): string;
|
||||
/*@internal*/ tryEnableSourceMapsForHost?(): void;
|
||||
setTimeout?(callback: (...args: any[]) => void, ms: number, ...args: any[]): any;
|
||||
clearTimeout?(timeoutId: any): void;
|
||||
}
|
||||
|
||||
export interface FileWatcher {
|
||||
@@ -46,13 +48,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
declare var require: any;
|
||||
declare var module: any;
|
||||
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;
|
||||
@@ -324,7 +322,7 @@ namespace ts {
|
||||
const platform: string = _os.platform();
|
||||
const useCaseSensitiveFileNames = isFileSystemCaseSensitive();
|
||||
|
||||
function readFile(fileName: string, encoding?: string): string {
|
||||
function readFile(fileName: string, _encoding?: string): string {
|
||||
if (!fileExists(fileName)) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -476,6 +474,10 @@ namespace ts {
|
||||
// Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
|
||||
// (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
|
||||
let options: any;
|
||||
if (!directoryExists(directoryName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) {
|
||||
options = { persistent: true, recursive: !!recursive };
|
||||
}
|
||||
@@ -560,7 +562,9 @@ namespace ts {
|
||||
catch (e) {
|
||||
// Could not enable source maps.
|
||||
}
|
||||
}
|
||||
},
|
||||
setTimeout,
|
||||
clearTimeout
|
||||
};
|
||||
return nodeSystem;
|
||||
}
|
||||
@@ -572,7 +576,7 @@ namespace ts {
|
||||
args: ChakraHost.args,
|
||||
useCaseSensitiveFileNames: !!ChakraHost.useCaseSensitiveFileNames,
|
||||
write: ChakraHost.echo,
|
||||
readFile(path: string, encoding?: string) {
|
||||
readFile(path: string, _encoding?: string) {
|
||||
// encoding is automatically handled by the implementation in ChakraHost
|
||||
return ChakraHost.readFile(path);
|
||||
},
|
||||
@@ -591,9 +595,9 @@ namespace ts {
|
||||
getExecutingFilePath: () => ChakraHost.executingFile,
|
||||
getCurrentDirectory: () => ChakraHost.currentDirectory,
|
||||
getDirectories: ChakraHost.getDirectories,
|
||||
getEnvironmentVariable: ChakraHost.getEnvironmentVariable || ((name: string) => ""),
|
||||
getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (() => ""),
|
||||
readDirectory: (path: string, extensions?: string[], excludes?: string[], includes?: string[]) => {
|
||||
const pattern = getFileMatcherPatterns(path, extensions, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory);
|
||||
const pattern = getFileMatcherPatterns(path, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory);
|
||||
return ChakraHost.readDirectory(path, extensions, pattern.basePaths, pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern);
|
||||
},
|
||||
exit: ChakraHost.quit,
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
/// <reference path="visitor.ts" />
|
||||
/// <reference path="transformers/ts.ts" />
|
||||
/// <reference path="transformers/jsx.ts" />
|
||||
/// <reference path="transformers/es7.ts" />
|
||||
/// <reference path="transformers/es6.ts" />
|
||||
/// <reference path="transformers/es2017.ts" />
|
||||
/// <reference path="transformers/es2016.ts" />
|
||||
/// <reference path="transformers/es2015.ts" />
|
||||
/// <reference path="transformers/generators.ts" />
|
||||
/// <reference path="transformers/es5.ts" />
|
||||
/// <reference path="transformers/module/module.ts" />
|
||||
/// <reference path="transformers/module/system.ts" />
|
||||
/// <reference path="transformers/module/es6.ts" />
|
||||
/// <reference path="transformers/module/es2015.ts" />
|
||||
|
||||
/* @internal */
|
||||
namespace ts {
|
||||
const moduleTransformerMap = createMap<Transformer>({
|
||||
[ModuleKind.ES6]: transformES6Module,
|
||||
[ModuleKind.ES2015]: transformES2015Module,
|
||||
[ModuleKind.System]: transformSystemModule,
|
||||
[ModuleKind.AMD]: transformModule,
|
||||
[ModuleKind.CommonJS]: transformModule,
|
||||
@@ -115,13 +117,23 @@ namespace ts {
|
||||
transformers.push(transformJsx);
|
||||
}
|
||||
|
||||
transformers.push(transformES7);
|
||||
if (languageVersion < ScriptTarget.ES2017) {
|
||||
transformers.push(transformES2017);
|
||||
}
|
||||
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
transformers.push(transformES6);
|
||||
if (languageVersion < ScriptTarget.ES2016) {
|
||||
transformers.push(transformES2016);
|
||||
}
|
||||
|
||||
if (languageVersion < ScriptTarget.ES2015) {
|
||||
transformers.push(transformES2015);
|
||||
transformers.push(transformGenerators);
|
||||
}
|
||||
|
||||
if (languageVersion < ScriptTarget.ES5) {
|
||||
transformers.push(transformES5);
|
||||
}
|
||||
|
||||
return transformers;
|
||||
}
|
||||
|
||||
@@ -153,7 +165,7 @@ namespace ts {
|
||||
hoistFunctionDeclaration,
|
||||
startLexicalEnvironment,
|
||||
endLexicalEnvironment,
|
||||
onSubstituteNode: (emitContext, node) => node,
|
||||
onSubstituteNode: (_emitContext, node) => node,
|
||||
enableSubstitution,
|
||||
isSubstitutionEnabled,
|
||||
onEmitNode: (node, emitContext, emitCallback) => emitCallback(node, emitContext),
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace ts {
|
||||
location = value;
|
||||
}
|
||||
|
||||
flattenDestructuring(context, node, value, location, emitAssignment, emitTempVariableAssignment, visitor);
|
||||
flattenDestructuring(node, value, location, emitAssignment, emitTempVariableAssignment, visitor);
|
||||
|
||||
if (needsValue) {
|
||||
expressions.push(value);
|
||||
@@ -87,13 +87,12 @@ namespace ts {
|
||||
* @param visitor An optional visitor to use to visit expressions.
|
||||
*/
|
||||
export function flattenParameterDestructuring(
|
||||
context: TransformationContext,
|
||||
node: ParameterDeclaration,
|
||||
value: Expression,
|
||||
visitor?: (node: Node) => VisitResult<Node>) {
|
||||
const declarations: VariableDeclaration[] = [];
|
||||
|
||||
flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor);
|
||||
flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor);
|
||||
|
||||
return declarations;
|
||||
|
||||
@@ -123,7 +122,6 @@ namespace ts {
|
||||
* @param visitor An optional visitor to use to visit expressions.
|
||||
*/
|
||||
export function flattenVariableDestructuring(
|
||||
context: TransformationContext,
|
||||
node: VariableDeclaration,
|
||||
value?: Expression,
|
||||
visitor?: (node: Node) => VisitResult<Node>,
|
||||
@@ -131,7 +129,7 @@ namespace ts {
|
||||
const declarations: VariableDeclaration[] = [];
|
||||
|
||||
let pendingAssignments: Expression[];
|
||||
flattenDestructuring(context, node, value, node, emitAssignment, emitTempVariableAssignment, visitor);
|
||||
flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, visitor);
|
||||
|
||||
return declarations;
|
||||
|
||||
@@ -180,7 +178,6 @@ namespace ts {
|
||||
* @param visitor An optional visitor to use to visit expressions.
|
||||
*/
|
||||
export function flattenVariableDestructuringToExpression(
|
||||
context: TransformationContext,
|
||||
node: VariableDeclaration,
|
||||
recordTempVariable: (name: Identifier) => void,
|
||||
nameSubstitution?: (name: Identifier) => Expression,
|
||||
@@ -188,7 +185,7 @@ namespace ts {
|
||||
|
||||
const pendingAssignments: Expression[] = [];
|
||||
|
||||
flattenDestructuring(context, node, /*value*/ undefined, node, emitAssignment, emitTempVariableAssignment, visitor);
|
||||
flattenDestructuring(node, /*value*/ undefined, node, emitAssignment, emitTempVariableAssignment, visitor);
|
||||
|
||||
const expression = inlineExpressions(pendingAssignments);
|
||||
aggregateTransformFlags(expression);
|
||||
@@ -219,7 +216,6 @@ namespace ts {
|
||||
}
|
||||
|
||||
function flattenDestructuring(
|
||||
context: TransformationContext,
|
||||
root: VariableDeclaration | ParameterDeclaration | BindingElement | BinaryExpression,
|
||||
value: Expression,
|
||||
location: TextRange,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
/*@internal*/
|
||||
namespace ts {
|
||||
|
||||
const enum ES6SubstitutionFlags {
|
||||
const enum ES2015SubstitutionFlags {
|
||||
/** Enables substitutions for captured `this` */
|
||||
CapturedThis = 1 << 0,
|
||||
/** Enables substitutions for block-scoped bindings. */
|
||||
@@ -163,7 +163,7 @@ namespace ts {
|
||||
ReplaceWithReturn,
|
||||
}
|
||||
|
||||
export function transformES6(context: TransformationContext) {
|
||||
export function transformES2015(context: TransformationContext) {
|
||||
const {
|
||||
startLexicalEnvironment,
|
||||
endLexicalEnvironment,
|
||||
@@ -197,7 +197,7 @@ namespace ts {
|
||||
* They are persisted between each SourceFile transformation and should not
|
||||
* be reset.
|
||||
*/
|
||||
let enabledSubstitutions: ES6SubstitutionFlags;
|
||||
let enabledSubstitutions: ES2015SubstitutionFlags;
|
||||
|
||||
return transformSourceFile;
|
||||
|
||||
@@ -252,7 +252,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function shouldCheckNode(node: Node): boolean {
|
||||
return (node.transformFlags & TransformFlags.ES6) !== 0 ||
|
||||
return (node.transformFlags & TransformFlags.ES2015) !== 0 ||
|
||||
node.kind === SyntaxKind.LabeledStatement ||
|
||||
(isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node));
|
||||
}
|
||||
@@ -261,7 +261,7 @@ namespace ts {
|
||||
if (shouldCheckNode(node)) {
|
||||
return visitJavaScript(node);
|
||||
}
|
||||
else if (node.transformFlags & TransformFlags.ContainsES6) {
|
||||
else if (node.transformFlags & TransformFlags.ContainsES2015) {
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
else {
|
||||
@@ -362,6 +362,9 @@ namespace ts {
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
return visitObjectLiteralExpression(<ObjectLiteralExpression>node);
|
||||
|
||||
case SyntaxKind.CatchClause:
|
||||
return visitCatchClause(<CatchClause>node);
|
||||
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
return visitShorthandPropertyAssignment(<ShorthandPropertyAssignment>node);
|
||||
|
||||
@@ -396,7 +399,7 @@ namespace ts {
|
||||
return visitYieldExpression(<YieldExpression>node);
|
||||
|
||||
case SyntaxKind.SuperKeyword:
|
||||
return visitSuperKeyword(<PrimaryExpression>node);
|
||||
return visitSuperKeyword();
|
||||
|
||||
case SyntaxKind.YieldExpression:
|
||||
// `yield` will be handled by a generators transform.
|
||||
@@ -681,6 +684,7 @@ namespace ts {
|
||||
|
||||
const extendsClauseElement = getClassExtendsHeritageClauseElement(node);
|
||||
const classFunction = createFunctionExpression(
|
||||
/*modifiers*/ undefined,
|
||||
/*asteriskToken*/ undefined,
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
@@ -1117,7 +1121,7 @@ namespace ts {
|
||||
createVariableStatement(
|
||||
/*modifiers*/ undefined,
|
||||
createVariableDeclarationList(
|
||||
flattenParameterDestructuring(context, parameter, temp, visitor)
|
||||
flattenParameterDestructuring(parameter, temp, visitor)
|
||||
)
|
||||
),
|
||||
EmitFlags.CustomPrologue
|
||||
@@ -1416,6 +1420,7 @@ namespace ts {
|
||||
if (getAccessor) {
|
||||
const getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined);
|
||||
setSourceMapRange(getterFunction, getSourceMapRange(getAccessor));
|
||||
setEmitFlags(getterFunction, EmitFlags.NoLeadingComments);
|
||||
const getter = createPropertyAssignment("get", getterFunction);
|
||||
setCommentRange(getter, getCommentRange(getAccessor));
|
||||
properties.push(getter);
|
||||
@@ -1424,6 +1429,7 @@ namespace ts {
|
||||
if (setAccessor) {
|
||||
const setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined);
|
||||
setSourceMapRange(setterFunction, getSourceMapRange(setAccessor));
|
||||
setEmitFlags(setterFunction, EmitFlags.NoLeadingComments);
|
||||
const setter = createPropertyAssignment("set", setterFunction);
|
||||
setCommentRange(setter, getCommentRange(setAccessor));
|
||||
properties.push(setter);
|
||||
@@ -1509,6 +1515,7 @@ namespace ts {
|
||||
|
||||
const expression = setOriginalNode(
|
||||
createFunctionExpression(
|
||||
/*modifiers*/ undefined,
|
||||
node.asteriskToken,
|
||||
name,
|
||||
/*typeParameters*/ undefined,
|
||||
@@ -1686,7 +1693,7 @@ namespace ts {
|
||||
if (decl.initializer) {
|
||||
let assignment: Expression;
|
||||
if (isBindingPattern(decl.name)) {
|
||||
assignment = flattenVariableDestructuringToExpression(context, decl, hoistVariableDeclaration, /*nameSubstitution*/ undefined, visitor);
|
||||
assignment = flattenVariableDestructuringToExpression(decl, hoistVariableDeclaration, /*nameSubstitution*/ undefined, visitor);
|
||||
}
|
||||
else {
|
||||
assignment = createBinary(<Identifier>decl.name, SyntaxKind.EqualsToken, visitNode(decl.initializer, visitor, isExpression));
|
||||
@@ -1839,7 +1846,7 @@ namespace ts {
|
||||
if (isBindingPattern(node.name)) {
|
||||
const recordTempVariablesInLine = !enclosingVariableStatement
|
||||
|| !hasModifier(enclosingVariableStatement, ModifierFlags.Export);
|
||||
return flattenVariableDestructuring(context, node, /*value*/ undefined, visitor,
|
||||
return flattenVariableDestructuring(node, /*value*/ undefined, visitor,
|
||||
recordTempVariablesInLine ? undefined : hoistVariableDeclaration);
|
||||
}
|
||||
|
||||
@@ -1942,7 +1949,6 @@ namespace ts {
|
||||
// This works whether the declaration is a var, let, or const.
|
||||
// It will use rhsIterationValue _a[_i] as the initializer.
|
||||
const declarations = flattenVariableDestructuring(
|
||||
context,
|
||||
firstOriginalDeclaration,
|
||||
createElementAccess(rhsReference, counter),
|
||||
visitor
|
||||
@@ -2240,6 +2246,7 @@ namespace ts {
|
||||
/*type*/ undefined,
|
||||
setEmitFlags(
|
||||
createFunctionExpression(
|
||||
/*modifiers*/ undefined,
|
||||
isAsyncBlockContainingAwait ? createToken(SyntaxKind.AsteriskToken) : undefined,
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
@@ -2534,15 +2541,15 @@ namespace ts {
|
||||
break;
|
||||
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
expressions.push(transformPropertyAssignmentToExpression(node, <PropertyAssignment>property, receiver, node.multiLine));
|
||||
expressions.push(transformPropertyAssignmentToExpression(<PropertyAssignment>property, receiver, node.multiLine));
|
||||
break;
|
||||
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
expressions.push(transformShorthandPropertyAssignmentToExpression(node, <ShorthandPropertyAssignment>property, receiver, node.multiLine));
|
||||
expressions.push(transformShorthandPropertyAssignmentToExpression(<ShorthandPropertyAssignment>property, receiver, node.multiLine));
|
||||
break;
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
expressions.push(transformObjectLiteralMethodDeclarationToExpression(node, <MethodDeclaration>property, receiver, node.multiLine));
|
||||
expressions.push(transformObjectLiteralMethodDeclarationToExpression(<MethodDeclaration>property, receiver, node.multiLine));
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -2559,7 +2566,7 @@ namespace ts {
|
||||
* @param property The PropertyAssignment node.
|
||||
* @param receiver The receiver for the assignment.
|
||||
*/
|
||||
function transformPropertyAssignmentToExpression(node: ObjectLiteralExpression, property: PropertyAssignment, receiver: Expression, startsOnNewLine: boolean) {
|
||||
function transformPropertyAssignmentToExpression(property: PropertyAssignment, receiver: Expression, startsOnNewLine: boolean) {
|
||||
const expression = createAssignment(
|
||||
createMemberAccessForPropertyName(
|
||||
receiver,
|
||||
@@ -2581,7 +2588,7 @@ namespace ts {
|
||||
* @param property The ShorthandPropertyAssignment node.
|
||||
* @param receiver The receiver for the assignment.
|
||||
*/
|
||||
function transformShorthandPropertyAssignmentToExpression(node: ObjectLiteralExpression, property: ShorthandPropertyAssignment, receiver: Expression, startsOnNewLine: boolean) {
|
||||
function transformShorthandPropertyAssignmentToExpression(property: ShorthandPropertyAssignment, receiver: Expression, startsOnNewLine: boolean) {
|
||||
const expression = createAssignment(
|
||||
createMemberAccessForPropertyName(
|
||||
receiver,
|
||||
@@ -2603,7 +2610,7 @@ namespace ts {
|
||||
* @param method The MethodDeclaration node.
|
||||
* @param receiver The receiver for the assignment.
|
||||
*/
|
||||
function transformObjectLiteralMethodDeclarationToExpression(node: ObjectLiteralExpression, method: MethodDeclaration, receiver: Expression, startsOnNewLine: boolean) {
|
||||
function transformObjectLiteralMethodDeclarationToExpression(method: MethodDeclaration, receiver: Expression, startsOnNewLine: boolean) {
|
||||
const expression = createAssignment(
|
||||
createMemberAccessForPropertyName(
|
||||
receiver,
|
||||
@@ -2618,6 +2625,24 @@ namespace ts {
|
||||
return expression;
|
||||
}
|
||||
|
||||
function visitCatchClause(node: CatchClause): CatchClause {
|
||||
Debug.assert(isBindingPattern(node.variableDeclaration.name));
|
||||
|
||||
const temp = createTempVariable(undefined);
|
||||
const newVariableDeclaration = createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration);
|
||||
|
||||
const vars = flattenVariableDestructuring(node.variableDeclaration, temp, visitor);
|
||||
const list = createVariableDeclarationList(vars, /*location*/node.variableDeclaration, /*flags*/node.variableDeclaration.flags);
|
||||
const destructure = createVariableStatement(undefined, list);
|
||||
|
||||
return updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure));
|
||||
}
|
||||
|
||||
function addStatementToStartOfBlock(block: Block, statement: Statement): Block {
|
||||
const transformedStatements = visitNodes(block.statements, visitor, isStatement);
|
||||
return updateBlock(block, [statement].concat(transformedStatements));
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a MethodDeclaration of an ObjectLiteralExpression and transforms it into a
|
||||
* PropertyAssignment.
|
||||
@@ -2793,7 +2818,7 @@ namespace ts {
|
||||
// expressions into an array literal.
|
||||
const numElements = elements.length;
|
||||
const segments = flatten(
|
||||
spanMap(elements, partitionSpreadElement, (partition, visitPartition, start, end) =>
|
||||
spanMap(elements, partitionSpreadElement, (partition, visitPartition, _start, end) =>
|
||||
visitPartition(partition, multiLine, hasTrailingComma && end === numElements)
|
||||
)
|
||||
);
|
||||
@@ -2815,7 +2840,7 @@ namespace ts {
|
||||
: visitSpanOfNonSpreadElements;
|
||||
}
|
||||
|
||||
function visitSpanOfSpreadElements(chunk: Expression[], multiLine: boolean, hasTrailingComma: boolean): VisitResult<Expression> {
|
||||
function visitSpanOfSpreadElements(chunk: Expression[]): VisitResult<Expression> {
|
||||
return map(chunk, visitExpressionOfSpreadElement);
|
||||
}
|
||||
|
||||
@@ -3004,7 +3029,7 @@ namespace ts {
|
||||
/**
|
||||
* Visits the `super` keyword
|
||||
*/
|
||||
function visitSuperKeyword(node: PrimaryExpression): LeftHandSideExpression {
|
||||
function visitSuperKeyword(): LeftHandSideExpression {
|
||||
return enclosingNonAsyncFunctionBody
|
||||
&& isClassElement(enclosingNonAsyncFunctionBody)
|
||||
&& !hasModifier(enclosingNonAsyncFunctionBody, ModifierFlags.Static)
|
||||
@@ -3034,7 +3059,7 @@ namespace ts {
|
||||
function onEmitNode(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void) {
|
||||
const savedEnclosingFunction = enclosingFunction;
|
||||
|
||||
if (enabledSubstitutions & ES6SubstitutionFlags.CapturedThis && isFunctionLike(node)) {
|
||||
if (enabledSubstitutions & ES2015SubstitutionFlags.CapturedThis && isFunctionLike(node)) {
|
||||
// If we are tracking a captured `this`, keep track of the enclosing function.
|
||||
enclosingFunction = node;
|
||||
}
|
||||
@@ -3049,8 +3074,8 @@ namespace ts {
|
||||
* contains block-scoped bindings (e.g. `let` or `const`).
|
||||
*/
|
||||
function enableSubstitutionsForBlockScopedBindings() {
|
||||
if ((enabledSubstitutions & ES6SubstitutionFlags.BlockScopedBindings) === 0) {
|
||||
enabledSubstitutions |= ES6SubstitutionFlags.BlockScopedBindings;
|
||||
if ((enabledSubstitutions & ES2015SubstitutionFlags.BlockScopedBindings) === 0) {
|
||||
enabledSubstitutions |= ES2015SubstitutionFlags.BlockScopedBindings;
|
||||
context.enableSubstitution(SyntaxKind.Identifier);
|
||||
}
|
||||
}
|
||||
@@ -3060,8 +3085,8 @@ namespace ts {
|
||||
* contains a captured `this`.
|
||||
*/
|
||||
function enableSubstitutionsForCapturedThis() {
|
||||
if ((enabledSubstitutions & ES6SubstitutionFlags.CapturedThis) === 0) {
|
||||
enabledSubstitutions |= ES6SubstitutionFlags.CapturedThis;
|
||||
if ((enabledSubstitutions & ES2015SubstitutionFlags.CapturedThis) === 0) {
|
||||
enabledSubstitutions |= ES2015SubstitutionFlags.CapturedThis;
|
||||
context.enableSubstitution(SyntaxKind.ThisKeyword);
|
||||
context.enableEmitNotification(SyntaxKind.Constructor);
|
||||
context.enableEmitNotification(SyntaxKind.MethodDeclaration);
|
||||
@@ -3100,7 +3125,7 @@ namespace ts {
|
||||
function substituteIdentifier(node: Identifier) {
|
||||
// Only substitute the identifier if we have enabled substitutions for block-scoped
|
||||
// bindings.
|
||||
if (enabledSubstitutions & ES6SubstitutionFlags.BlockScopedBindings) {
|
||||
if (enabledSubstitutions & ES2015SubstitutionFlags.BlockScopedBindings) {
|
||||
const original = getParseTreeNode(node, isIdentifier);
|
||||
if (original && isNameOfDeclarationWithCollidingName(original)) {
|
||||
return getGeneratedNameForNode(original);
|
||||
@@ -3153,7 +3178,7 @@ namespace ts {
|
||||
* @param node An Identifier node.
|
||||
*/
|
||||
function substituteExpressionIdentifier(node: Identifier): Identifier {
|
||||
if (enabledSubstitutions & ES6SubstitutionFlags.BlockScopedBindings) {
|
||||
if (enabledSubstitutions & ES2015SubstitutionFlags.BlockScopedBindings) {
|
||||
const declaration = resolver.getReferencedDeclarationWithCollidingName(node);
|
||||
if (declaration) {
|
||||
return getGeneratedNameForNode(declaration.name);
|
||||
@@ -3169,7 +3194,7 @@ namespace ts {
|
||||
* @param node The ThisKeyword node.
|
||||
*/
|
||||
function substituteThisKeyword(node: PrimaryExpression): PrimaryExpression {
|
||||
if (enabledSubstitutions & ES6SubstitutionFlags.CapturedThis
|
||||
if (enabledSubstitutions & ES2015SubstitutionFlags.CapturedThis
|
||||
&& enclosingFunction
|
||||
&& getEmitFlags(enclosingFunction) & EmitFlags.CapturesThis) {
|
||||
return createIdentifier("_this", /*location*/ node);
|
||||
@@ -3256,4 +3281,4 @@ namespace ts {
|
||||
return isIdentifier(expression) && expression === parameter.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
/*@internal*/
|
||||
namespace ts {
|
||||
export function transformES7(context: TransformationContext) {
|
||||
export function transformES2016(context: TransformationContext) {
|
||||
const { hoistVariableDeclaration } = context;
|
||||
|
||||
return transformSourceFile;
|
||||
@@ -17,10 +17,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
function visitor(node: Node): VisitResult<Node> {
|
||||
if (node.transformFlags & TransformFlags.ES7) {
|
||||
if (node.transformFlags & TransformFlags.ES2016) {
|
||||
return visitorWorker(node);
|
||||
}
|
||||
else if (node.transformFlags & TransformFlags.ContainsES7) {
|
||||
else if (node.transformFlags & TransformFlags.ContainsES2016) {
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
else {
|
||||
@@ -40,7 +40,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function visitBinaryExpression(node: BinaryExpression): Expression {
|
||||
// We are here because ES7 adds support for the exponentiation operator.
|
||||
// We are here because ES2016 adds support for the exponentiation operator.
|
||||
const left = visitNode(node.left, visitor, isExpression);
|
||||
const right = visitNode(node.right, visitor, isExpression);
|
||||
if (node.operatorToken.kind === SyntaxKind.AsteriskAsteriskEqualsToken) {
|
||||
@@ -98,4 +98,4 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,510 @@
|
||||
/// <reference path="../factory.ts" />
|
||||
/// <reference path="../visitor.ts" />
|
||||
|
||||
/*@internal*/
|
||||
namespace ts {
|
||||
type SuperContainer = ClassDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration;
|
||||
|
||||
export function transformES2017(context: TransformationContext) {
|
||||
|
||||
const enum ES2017SubstitutionFlags {
|
||||
/** Enables substitutions for async methods with `super` calls. */
|
||||
AsyncMethodsWithSuper = 1 << 0
|
||||
}
|
||||
|
||||
const {
|
||||
startLexicalEnvironment,
|
||||
endLexicalEnvironment,
|
||||
} = context;
|
||||
|
||||
const resolver = context.getEmitResolver();
|
||||
const compilerOptions = context.getCompilerOptions();
|
||||
const languageVersion = getEmitScriptTarget(compilerOptions);
|
||||
|
||||
// These variables contain state that changes as we descend into the tree.
|
||||
let currentSourceFileExternalHelpersModuleName: Identifier;
|
||||
/**
|
||||
* Keeps track of whether expression substitution has been enabled for specific edge cases.
|
||||
* They are persisted between each SourceFile transformation and should not be reset.
|
||||
*/
|
||||
let enabledSubstitutions: ES2017SubstitutionFlags;
|
||||
|
||||
/**
|
||||
* Keeps track of whether we are within any containing namespaces when performing
|
||||
* just-in-time substitution while printing an expression identifier.
|
||||
*/
|
||||
let applicableSubstitutions: ES2017SubstitutionFlags;
|
||||
|
||||
/**
|
||||
* This keeps track of containers where `super` is valid, for use with
|
||||
* just-in-time substitution for `super` expressions inside of async methods.
|
||||
*/
|
||||
let currentSuperContainer: SuperContainer;
|
||||
|
||||
// Save the previous transformation hooks.
|
||||
const previousOnEmitNode = context.onEmitNode;
|
||||
const previousOnSubstituteNode = context.onSubstituteNode;
|
||||
|
||||
// Set new transformation hooks.
|
||||
context.onEmitNode = onEmitNode;
|
||||
context.onSubstituteNode = onSubstituteNode;
|
||||
|
||||
let currentScope: SourceFile | Block | ModuleBlock | CaseBlock;
|
||||
|
||||
return transformSourceFile;
|
||||
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
if (isDeclarationFile(node)) {
|
||||
return node;
|
||||
}
|
||||
|
||||
currentSourceFileExternalHelpersModuleName = node.externalHelpersModuleName;
|
||||
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
function visitor(node: Node): VisitResult<Node> {
|
||||
if (node.transformFlags & TransformFlags.ES2017) {
|
||||
return visitorWorker(node);
|
||||
}
|
||||
else if (node.transformFlags & TransformFlags.ContainsES2017) {
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function visitorWorker(node: Node): VisitResult<Node> {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.AsyncKeyword:
|
||||
// ES2017 async modifier should be elided for targets < ES2017
|
||||
return undefined;
|
||||
|
||||
case SyntaxKind.AwaitExpression:
|
||||
// ES2017 'await' expressions must be transformed for targets < ES2017.
|
||||
return visitAwaitExpression(<AwaitExpression>node);
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
// ES2017 method declarations may be 'async'
|
||||
return visitMethodDeclaration(<MethodDeclaration>node);
|
||||
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
// ES2017 function declarations may be 'async'
|
||||
return visitFunctionDeclaration(<FunctionDeclaration>node);
|
||||
|
||||
case SyntaxKind.FunctionExpression:
|
||||
// ES2017 function expressions may be 'async'
|
||||
return visitFunctionExpression(<FunctionExpression>node);
|
||||
|
||||
case SyntaxKind.ArrowFunction:
|
||||
// ES2017 arrow functions may be 'async'
|
||||
return visitArrowFunction(<ArrowFunction>node);
|
||||
|
||||
default:
|
||||
Debug.failBadSyntaxKind(node);
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an await expression.
|
||||
*
|
||||
* This function will be called any time a ES2017 await expression is encountered.
|
||||
*
|
||||
* @param node The await expression node.
|
||||
*/
|
||||
function visitAwaitExpression(node: AwaitExpression): Expression {
|
||||
return setOriginalNode(
|
||||
createYield(
|
||||
/*asteriskToken*/ undefined,
|
||||
visitNode(node.expression, visitor, isExpression),
|
||||
/*location*/ node
|
||||
),
|
||||
node
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a method declaration of a class.
|
||||
*
|
||||
* This function will be called when one of the following conditions are met:
|
||||
* - The node is marked as async
|
||||
*
|
||||
* @param node The method node.
|
||||
*/
|
||||
function visitMethodDeclaration(node: MethodDeclaration) {
|
||||
if (!isAsyncFunctionLike(node)) {
|
||||
return node;
|
||||
}
|
||||
const method = createMethod(
|
||||
/*decorators*/ undefined,
|
||||
visitNodes(node.modifiers, visitor, isModifier),
|
||||
node.asteriskToken,
|
||||
node.name,
|
||||
/*typeParameters*/ undefined,
|
||||
visitNodes(node.parameters, visitor, isParameter),
|
||||
/*type*/ undefined,
|
||||
transformFunctionBody(node),
|
||||
/*location*/ node
|
||||
);
|
||||
|
||||
// While we emit the source map for the node after skipping decorators and modifiers,
|
||||
// we need to emit the comments for the original range.
|
||||
setCommentRange(method, node);
|
||||
setSourceMapRange(method, moveRangePastDecorators(node));
|
||||
setOriginalNode(method, node);
|
||||
|
||||
return method;
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a function declaration.
|
||||
*
|
||||
* This function will be called when one of the following conditions are met:
|
||||
* - The node is marked async
|
||||
*
|
||||
* @param node The function node.
|
||||
*/
|
||||
function visitFunctionDeclaration(node: FunctionDeclaration): VisitResult<Statement> {
|
||||
if (!isAsyncFunctionLike(node)) {
|
||||
return node;
|
||||
}
|
||||
const func = createFunctionDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
visitNodes(node.modifiers, visitor, isModifier),
|
||||
node.asteriskToken,
|
||||
node.name,
|
||||
/*typeParameters*/ undefined,
|
||||
visitNodes(node.parameters, visitor, isParameter),
|
||||
/*type*/ undefined,
|
||||
transformFunctionBody(node),
|
||||
/*location*/ node
|
||||
);
|
||||
setOriginalNode(func, node);
|
||||
|
||||
return func;
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a function expression node.
|
||||
*
|
||||
* This function will be called when one of the following conditions are met:
|
||||
* - The node is marked async
|
||||
*
|
||||
* @param node The function expression node.
|
||||
*/
|
||||
function visitFunctionExpression(node: FunctionExpression): Expression {
|
||||
if (!isAsyncFunctionLike(node)) {
|
||||
return node;
|
||||
}
|
||||
if (nodeIsMissing(node.body)) {
|
||||
return createOmittedExpression();
|
||||
}
|
||||
|
||||
const func = createFunctionExpression(
|
||||
/*modifiers*/ undefined,
|
||||
node.asteriskToken,
|
||||
node.name,
|
||||
/*typeParameters*/ undefined,
|
||||
visitNodes(node.parameters, visitor, isParameter),
|
||||
/*type*/ undefined,
|
||||
transformFunctionBody(node),
|
||||
/*location*/ node
|
||||
);
|
||||
|
||||
setOriginalNode(func, node);
|
||||
|
||||
return func;
|
||||
}
|
||||
|
||||
/**
|
||||
* @remarks
|
||||
* This function will be called when one of the following conditions are met:
|
||||
* - The node is marked async
|
||||
*/
|
||||
function visitArrowFunction(node: ArrowFunction) {
|
||||
if (!isAsyncFunctionLike(node)) {
|
||||
return node;
|
||||
}
|
||||
const func = createArrowFunction(
|
||||
visitNodes(node.modifiers, visitor, isModifier),
|
||||
/*typeParameters*/ undefined,
|
||||
visitNodes(node.parameters, visitor, isParameter),
|
||||
/*type*/ undefined,
|
||||
node.equalsGreaterThanToken,
|
||||
transformConciseBody(node),
|
||||
/*location*/ node
|
||||
);
|
||||
|
||||
setOriginalNode(func, node);
|
||||
|
||||
return func;
|
||||
}
|
||||
|
||||
function transformFunctionBody(node: MethodDeclaration | AccessorDeclaration | FunctionDeclaration | FunctionExpression): FunctionBody {
|
||||
return <FunctionBody>transformAsyncFunctionBody(node);
|
||||
}
|
||||
|
||||
function transformConciseBody(node: ArrowFunction): ConciseBody {
|
||||
return transformAsyncFunctionBody(node);
|
||||
}
|
||||
|
||||
function transformFunctionBodyWorker(body: Block, start = 0) {
|
||||
const savedCurrentScope = currentScope;
|
||||
currentScope = body;
|
||||
startLexicalEnvironment();
|
||||
|
||||
const statements = visitNodes(body.statements, visitor, isStatement, start);
|
||||
const visited = updateBlock(body, statements);
|
||||
const declarations = endLexicalEnvironment();
|
||||
currentScope = savedCurrentScope;
|
||||
return mergeFunctionBodyLexicalEnvironment(visited, declarations);
|
||||
}
|
||||
|
||||
function transformAsyncFunctionBody(node: FunctionLikeDeclaration): ConciseBody | FunctionBody {
|
||||
const nodeType = node.original ? (<FunctionLikeDeclaration>node.original).type : node.type;
|
||||
const promiseConstructor = languageVersion < ScriptTarget.ES2015 ? getPromiseConstructor(nodeType) : undefined;
|
||||
const isArrowFunction = node.kind === SyntaxKind.ArrowFunction;
|
||||
const hasLexicalArguments = (resolver.getNodeCheckFlags(node) & NodeCheckFlags.CaptureArguments) !== 0;
|
||||
|
||||
// An async function is emit as an outer function that calls an inner
|
||||
// generator function. To preserve lexical bindings, we pass the current
|
||||
// `this` and `arguments` objects to `__awaiter`. The generator function
|
||||
// passed to `__awaiter` is executed inside of the callback to the
|
||||
// promise constructor.
|
||||
|
||||
|
||||
if (!isArrowFunction) {
|
||||
const statements: Statement[] = [];
|
||||
const statementOffset = addPrologueDirectives(statements, (<Block>node.body).statements, /*ensureUseStrict*/ false, visitor);
|
||||
statements.push(
|
||||
createReturn(
|
||||
createAwaiterHelper(
|
||||
currentSourceFileExternalHelpersModuleName,
|
||||
hasLexicalArguments,
|
||||
promiseConstructor,
|
||||
transformFunctionBodyWorker(<Block>node.body, statementOffset)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
const block = createBlock(statements, /*location*/ node.body, /*multiLine*/ true);
|
||||
|
||||
// Minor optimization, emit `_super` helper to capture `super` access in an arrow.
|
||||
// This step isn't needed if we eventually transform this to ES5.
|
||||
if (languageVersion >= ScriptTarget.ES2015) {
|
||||
if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.AsyncMethodWithSuperBinding) {
|
||||
enableSubstitutionForAsyncMethodsWithSuper();
|
||||
setEmitFlags(block, EmitFlags.EmitAdvancedSuperHelper);
|
||||
}
|
||||
else if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.AsyncMethodWithSuper) {
|
||||
enableSubstitutionForAsyncMethodsWithSuper();
|
||||
setEmitFlags(block, EmitFlags.EmitSuperHelper);
|
||||
}
|
||||
}
|
||||
|
||||
return block;
|
||||
}
|
||||
else {
|
||||
return createAwaiterHelper(
|
||||
currentSourceFileExternalHelpersModuleName,
|
||||
hasLexicalArguments,
|
||||
promiseConstructor,
|
||||
<Block>transformConciseBodyWorker(node.body, /*forceBlockFunctionBody*/ true)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function transformConciseBodyWorker(body: Block | Expression, forceBlockFunctionBody: boolean) {
|
||||
if (isBlock(body)) {
|
||||
return transformFunctionBodyWorker(body);
|
||||
}
|
||||
else {
|
||||
startLexicalEnvironment();
|
||||
const visited: Expression | Block = visitNode(body, visitor, isConciseBody);
|
||||
const declarations = endLexicalEnvironment();
|
||||
const merged = mergeFunctionBodyLexicalEnvironment(visited, declarations);
|
||||
if (forceBlockFunctionBody && !isBlock(merged)) {
|
||||
return createBlock([
|
||||
createReturn(<Expression>merged)
|
||||
]);
|
||||
}
|
||||
else {
|
||||
return merged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getPromiseConstructor(type: TypeNode) {
|
||||
const typeName = getEntityNameFromTypeNode(type);
|
||||
if (typeName && isEntityName(typeName)) {
|
||||
const serializationKind = resolver.getTypeReferenceSerializationKind(typeName);
|
||||
if (serializationKind === TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue
|
||||
|| serializationKind === TypeReferenceSerializationKind.Unknown) {
|
||||
return typeName;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function enableSubstitutionForAsyncMethodsWithSuper() {
|
||||
if ((enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper) === 0) {
|
||||
enabledSubstitutions |= ES2017SubstitutionFlags.AsyncMethodsWithSuper;
|
||||
|
||||
// We need to enable substitutions for call, property access, and element access
|
||||
// if we need to rewrite super calls.
|
||||
context.enableSubstitution(SyntaxKind.CallExpression);
|
||||
context.enableSubstitution(SyntaxKind.PropertyAccessExpression);
|
||||
context.enableSubstitution(SyntaxKind.ElementAccessExpression);
|
||||
|
||||
// We need to be notified when entering and exiting declarations that bind super.
|
||||
context.enableEmitNotification(SyntaxKind.ClassDeclaration);
|
||||
context.enableEmitNotification(SyntaxKind.MethodDeclaration);
|
||||
context.enableEmitNotification(SyntaxKind.GetAccessor);
|
||||
context.enableEmitNotification(SyntaxKind.SetAccessor);
|
||||
context.enableEmitNotification(SyntaxKind.Constructor);
|
||||
}
|
||||
}
|
||||
|
||||
function substituteExpression(node: Expression) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
return substitutePropertyAccessExpression(<PropertyAccessExpression>node);
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
return substituteElementAccessExpression(<ElementAccessExpression>node);
|
||||
case SyntaxKind.CallExpression:
|
||||
if (enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper) {
|
||||
return substituteCallExpression(<CallExpression>node);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function substitutePropertyAccessExpression(node: PropertyAccessExpression) {
|
||||
if (enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper && node.expression.kind === SyntaxKind.SuperKeyword) {
|
||||
const flags = getSuperContainerAsyncMethodFlags();
|
||||
if (flags) {
|
||||
return createSuperAccessInAsyncMethod(
|
||||
createLiteral(node.name.text),
|
||||
flags,
|
||||
node
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function substituteElementAccessExpression(node: ElementAccessExpression) {
|
||||
if (enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper && node.expression.kind === SyntaxKind.SuperKeyword) {
|
||||
const flags = getSuperContainerAsyncMethodFlags();
|
||||
if (flags) {
|
||||
return createSuperAccessInAsyncMethod(
|
||||
node.argumentExpression,
|
||||
flags,
|
||||
node
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function substituteCallExpression(node: CallExpression): Expression {
|
||||
const expression = node.expression;
|
||||
if (isSuperProperty(expression)) {
|
||||
const flags = getSuperContainerAsyncMethodFlags();
|
||||
if (flags) {
|
||||
const argumentExpression = isPropertyAccessExpression(expression)
|
||||
? substitutePropertyAccessExpression(expression)
|
||||
: substituteElementAccessExpression(expression);
|
||||
return createCall(
|
||||
createPropertyAccess(argumentExpression, "call"),
|
||||
/*typeArguments*/ undefined,
|
||||
[
|
||||
createThis(),
|
||||
...node.arguments
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
function isSuperContainer(node: Node): node is SuperContainer {
|
||||
const kind = node.kind;
|
||||
return kind === SyntaxKind.ClassDeclaration
|
||||
|| kind === SyntaxKind.Constructor
|
||||
|| kind === SyntaxKind.MethodDeclaration
|
||||
|| kind === SyntaxKind.GetAccessor
|
||||
|| kind === SyntaxKind.SetAccessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook for node emit.
|
||||
*
|
||||
* @param node The node to emit.
|
||||
* @param emit A callback used to emit the node in the printer.
|
||||
*/
|
||||
function onEmitNode(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void {
|
||||
const savedApplicableSubstitutions = applicableSubstitutions;
|
||||
const savedCurrentSuperContainer = currentSuperContainer;
|
||||
// If we need to support substitutions for `super` in an async method,
|
||||
// we should track it here.
|
||||
if (enabledSubstitutions & ES2017SubstitutionFlags.AsyncMethodsWithSuper && isSuperContainer(node)) {
|
||||
currentSuperContainer = node;
|
||||
}
|
||||
|
||||
previousOnEmitNode(emitContext, node, emitCallback);
|
||||
|
||||
applicableSubstitutions = savedApplicableSubstitutions;
|
||||
currentSuperContainer = savedCurrentSuperContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hooks node substitutions.
|
||||
*
|
||||
* @param node The node to substitute.
|
||||
* @param isExpression A value indicating whether the node is to be used in an expression
|
||||
* position.
|
||||
*/
|
||||
function onSubstituteNode(emitContext: EmitContext, node: Node) {
|
||||
node = previousOnSubstituteNode(emitContext, node);
|
||||
if (emitContext === EmitContext.Expression) {
|
||||
return substituteExpression(<Expression>node);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function createSuperAccessInAsyncMethod(argumentExpression: Expression, flags: NodeCheckFlags, location: TextRange): LeftHandSideExpression {
|
||||
if (flags & NodeCheckFlags.AsyncMethodWithSuperBinding) {
|
||||
return createPropertyAccess(
|
||||
createCall(
|
||||
createIdentifier("_super"),
|
||||
/*typeArguments*/ undefined,
|
||||
[argumentExpression]
|
||||
),
|
||||
"value",
|
||||
location
|
||||
);
|
||||
}
|
||||
else {
|
||||
return createCall(
|
||||
createIdentifier("_super"),
|
||||
/*typeArguments*/ undefined,
|
||||
[argumentExpression],
|
||||
location
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function getSuperContainerAsyncMethodFlags() {
|
||||
return currentSuperContainer !== undefined
|
||||
&& resolver.getNodeCheckFlags(currentSuperContainer) & (NodeCheckFlags.AsyncMethodWithSuper | NodeCheckFlags.AsyncMethodWithSuperBinding);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/// <reference path="../factory.ts" />
|
||||
/// <reference path="../visitor.ts" />
|
||||
|
||||
/*@internal*/
|
||||
namespace ts {
|
||||
/**
|
||||
* Transforms ES5 syntax into ES3 syntax.
|
||||
*
|
||||
* @param context Context and state information for the transformation.
|
||||
*/
|
||||
export function transformES5(context: TransformationContext) {
|
||||
const previousOnSubstituteNode = context.onSubstituteNode;
|
||||
context.onSubstituteNode = onSubstituteNode;
|
||||
context.enableSubstitution(SyntaxKind.PropertyAccessExpression);
|
||||
context.enableSubstitution(SyntaxKind.PropertyAssignment);
|
||||
return transformSourceFile;
|
||||
|
||||
/**
|
||||
* Transforms an ES5 source file to ES3.
|
||||
*
|
||||
* @param node A SourceFile
|
||||
*/
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hooks node substitutions.
|
||||
*
|
||||
* @param emitContext The context for the emitter.
|
||||
* @param node The node to substitute.
|
||||
*/
|
||||
function onSubstituteNode(emitContext: EmitContext, node: Node) {
|
||||
node = previousOnSubstituteNode(emitContext, node);
|
||||
if (isPropertyAccessExpression(node)) {
|
||||
return substitutePropertyAccessExpression(node);
|
||||
}
|
||||
else if (isPropertyAssignment(node)) {
|
||||
return substitutePropertyAssignment(node);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Substitutes a PropertyAccessExpression whose name is a reserved word.
|
||||
*
|
||||
* @param node A PropertyAccessExpression
|
||||
*/
|
||||
function substitutePropertyAccessExpression(node: PropertyAccessExpression): Expression {
|
||||
const literalName = trySubstituteReservedName(node.name);
|
||||
if (literalName) {
|
||||
return createElementAccess(node.expression, literalName, /*location*/ node);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Substitutes a PropertyAssignment whose name is a reserved word.
|
||||
*
|
||||
* @param node A PropertyAssignment
|
||||
*/
|
||||
function substitutePropertyAssignment(node: PropertyAssignment): PropertyAssignment {
|
||||
const literalName = isIdentifier(node.name) && trySubstituteReservedName(node.name);
|
||||
if (literalName) {
|
||||
return updatePropertyAssignment(node, literalName, node.initializer);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* If an identifier name is a reserved word, returns a string literal for the name.
|
||||
*
|
||||
* @param name An Identifier
|
||||
*/
|
||||
function trySubstituteReservedName(name: Identifier) {
|
||||
const token = name.originalKeywordKind || (nodeIsSynthesized(name) ? stringToToken(name.text) : undefined);
|
||||
if (token >= SyntaxKind.FirstReservedWord && token <= SyntaxKind.LastReservedWord) {
|
||||
return createLiteral(name, /*location*/ name);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -496,6 +496,7 @@ namespace ts {
|
||||
if (node.asteriskToken && getEmitFlags(node) & EmitFlags.AsyncFunctionBody) {
|
||||
node = setOriginalNode(
|
||||
createFunctionExpression(
|
||||
/*modifiers*/ undefined,
|
||||
/*asteriskToken*/ undefined,
|
||||
node.name,
|
||||
/*typeParameters*/ undefined,
|
||||
@@ -955,7 +956,7 @@ namespace ts {
|
||||
* @param elements The elements to visit.
|
||||
* @param multiLine Whether array literals created should be emitted on multiple lines.
|
||||
*/
|
||||
function visitElements(elements: NodeArray<Expression>, multiLine: boolean) {
|
||||
function visitElements(elements: NodeArray<Expression>, _multiLine?: boolean) {
|
||||
// [source]
|
||||
// ar = [1, yield, 2];
|
||||
//
|
||||
@@ -1101,7 +1102,7 @@ namespace ts {
|
||||
createFunctionApply(
|
||||
cacheExpression(visitNode(target, visitor, isLeftHandSideExpression)),
|
||||
thisArg,
|
||||
visitElements(node.arguments, /*multiLine*/ false),
|
||||
visitElements(node.arguments),
|
||||
/*location*/ node
|
||||
),
|
||||
node
|
||||
@@ -1130,7 +1131,7 @@ namespace ts {
|
||||
createFunctionApply(
|
||||
cacheExpression(visitNode(target, visitor, isExpression)),
|
||||
thisArg,
|
||||
visitElements(node.arguments, /*multiLine*/ false)
|
||||
visitElements(node.arguments)
|
||||
),
|
||||
/*typeArguments*/ undefined,
|
||||
[],
|
||||
@@ -2591,6 +2592,7 @@ namespace ts {
|
||||
createThis(),
|
||||
setEmitFlags(
|
||||
createFunctionExpression(
|
||||
/*modifiers*/ undefined,
|
||||
/*asteriskToken*/ undefined,
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
@@ -3080,4 +3082,4 @@ namespace ts {
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/// <reference path="../../factory.ts" />
|
||||
/// <reference path="../../visitor.ts" />
|
||||
|
||||
/*@internal*/
|
||||
namespace ts {
|
||||
export function transformES2015Module(context: TransformationContext) {
|
||||
const compilerOptions = context.getCompilerOptions();
|
||||
return transformSourceFile;
|
||||
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
if (isDeclarationFile(node)) {
|
||||
return node;
|
||||
}
|
||||
|
||||
if (isExternalModule(node) || compilerOptions.isolatedModules) {
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function visitor(node: Node): VisitResult<Node> {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
// Elide `import=` as it is not legal with --module ES6
|
||||
return undefined;
|
||||
case SyntaxKind.ExportAssignment:
|
||||
return visitExportAssignment(<ExportAssignment>node);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function visitExportAssignment(node: ExportAssignment): VisitResult<ExportAssignment> {
|
||||
// Elide `export=` as it is not legal with --module ES6
|
||||
return node.isExportEquals ? undefined : node;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
/// <reference path="../../factory.ts" />
|
||||
/// <reference path="../../visitor.ts" />
|
||||
|
||||
/*@internal*/
|
||||
namespace ts {
|
||||
export function transformES6Module(context: TransformationContext) {
|
||||
const compilerOptions = context.getCompilerOptions();
|
||||
const resolver = context.getEmitResolver();
|
||||
|
||||
let currentSourceFile: SourceFile;
|
||||
|
||||
return transformSourceFile;
|
||||
|
||||
function transformSourceFile(node: SourceFile) {
|
||||
if (isDeclarationFile(node)) {
|
||||
return node;
|
||||
}
|
||||
|
||||
if (isExternalModule(node) || compilerOptions.isolatedModules) {
|
||||
currentSourceFile = node;
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
function visitor(node: Node): VisitResult<Node> {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
return visitImportDeclaration(<ImportDeclaration>node);
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
return visitImportEqualsDeclaration(<ImportEqualsDeclaration>node);
|
||||
case SyntaxKind.ImportClause:
|
||||
return visitImportClause(<ImportClause>node);
|
||||
case SyntaxKind.NamedImports:
|
||||
case SyntaxKind.NamespaceImport:
|
||||
return visitNamedBindings(<NamedImportBindings>node);
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
return visitImportSpecifier(<ImportSpecifier>node);
|
||||
case SyntaxKind.ExportAssignment:
|
||||
return visitExportAssignment(<ExportAssignment>node);
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
return visitExportDeclaration(<ExportDeclaration>node);
|
||||
case SyntaxKind.NamedExports:
|
||||
return visitNamedExports(<NamedExports>node);
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
return visitExportSpecifier(<ExportSpecifier>node);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function visitExportAssignment(node: ExportAssignment): ExportAssignment {
|
||||
if (node.isExportEquals) {
|
||||
return undefined; // do not emit export equals for ES6
|
||||
}
|
||||
const original = getOriginalNode(node);
|
||||
return nodeIsSynthesized(original) || resolver.isValueAliasDeclaration(original) ? node : undefined;
|
||||
}
|
||||
|
||||
function visitExportDeclaration(node: ExportDeclaration): ExportDeclaration {
|
||||
if (!node.exportClause) {
|
||||
return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined;
|
||||
}
|
||||
if (!resolver.isValueAliasDeclaration(node)) {
|
||||
return undefined;
|
||||
}
|
||||
const newExportClause = visitNode(node.exportClause, visitor, isNamedExports, /*optional*/ true);
|
||||
if (node.exportClause === newExportClause) {
|
||||
return node;
|
||||
}
|
||||
return newExportClause
|
||||
? createExportDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
newExportClause,
|
||||
node.moduleSpecifier)
|
||||
: undefined;
|
||||
}
|
||||
|
||||
function visitNamedExports(node: NamedExports): NamedExports {
|
||||
const newExports = visitNodes(node.elements, visitor, isExportSpecifier);
|
||||
if (node.elements === newExports) {
|
||||
return node;
|
||||
}
|
||||
return newExports.length ? createNamedExports(newExports) : undefined;
|
||||
}
|
||||
|
||||
function visitExportSpecifier(node: ExportSpecifier): ExportSpecifier {
|
||||
return resolver.isValueAliasDeclaration(node) ? node : undefined;
|
||||
}
|
||||
|
||||
function visitImportEqualsDeclaration(node: ImportEqualsDeclaration): ImportEqualsDeclaration {
|
||||
return !isExternalModuleImportEqualsDeclaration(node) || resolver.isReferencedAliasDeclaration(node) ? node : undefined;
|
||||
}
|
||||
|
||||
function visitImportDeclaration(node: ImportDeclaration) {
|
||||
if (node.importClause) {
|
||||
const newImportClause = visitNode(node.importClause, visitor, isImportClause);
|
||||
if (!newImportClause.name && !newImportClause.namedBindings) {
|
||||
return undefined;
|
||||
}
|
||||
else if (newImportClause !== node.importClause) {
|
||||
return createImportDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
newImportClause,
|
||||
node.moduleSpecifier);
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
function visitImportClause(node: ImportClause): ImportClause {
|
||||
let newDefaultImport = node.name;
|
||||
if (!resolver.isReferencedAliasDeclaration(node)) {
|
||||
newDefaultImport = undefined;
|
||||
}
|
||||
const newNamedBindings = visitNode(node.namedBindings, visitor, isNamedImportBindings, /*optional*/ true);
|
||||
return newDefaultImport !== node.name || newNamedBindings !== node.namedBindings
|
||||
? createImportClause(newDefaultImport, newNamedBindings)
|
||||
: node;
|
||||
}
|
||||
|
||||
function visitNamedBindings(node: NamedImportBindings): VisitResult<NamedImportBindings> {
|
||||
if (node.kind === SyntaxKind.NamespaceImport) {
|
||||
return resolver.isReferencedAliasDeclaration(node) ? node : undefined;
|
||||
}
|
||||
else {
|
||||
const newNamedImportElements = visitNodes((<NamedImports>node).elements, visitor, isImportSpecifier);
|
||||
if (!newNamedImportElements || newNamedImportElements.length == 0) {
|
||||
return undefined;
|
||||
}
|
||||
if (newNamedImportElements === (<NamedImports>node).elements) {
|
||||
return node;
|
||||
}
|
||||
return createNamedImports(newNamedImportElements);
|
||||
}
|
||||
}
|
||||
|
||||
function visitImportSpecifier(node: ImportSpecifier) {
|
||||
return resolver.isReferencedAliasDeclaration(node) ? node : undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ namespace ts {
|
||||
currentSourceFile = node;
|
||||
|
||||
// Collect information about the external module.
|
||||
({ externalImports, exportSpecifiers, exportEquals, hasExportStarsToExportValues } = collectExternalModuleInfo(node, resolver));
|
||||
({ externalImports, exportSpecifiers, exportEquals, hasExportStarsToExportValues } = collectExternalModuleInfo(node));
|
||||
|
||||
// Perform the transformation.
|
||||
const transformModule = transformModuleDelegates[moduleKind] || transformModuleDelegates[ModuleKind.None];
|
||||
@@ -179,6 +179,7 @@ namespace ts {
|
||||
//
|
||||
// function (require, exports, module1, module2) ...
|
||||
createFunctionExpression(
|
||||
/*modifiers*/ undefined,
|
||||
/*asteriskToken*/ undefined,
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
@@ -228,7 +229,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function addExportEqualsIfNeeded(statements: Statement[], emitAsReturn: boolean) {
|
||||
if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) {
|
||||
if (exportEquals) {
|
||||
if (emitAsReturn) {
|
||||
const statement = createReturn(
|
||||
exportEquals.expression,
|
||||
@@ -415,7 +416,7 @@ namespace ts {
|
||||
)
|
||||
],
|
||||
/*location*/ undefined,
|
||||
/*flags*/ languageVersion >= ScriptTarget.ES6 ? NodeFlags.Const : NodeFlags.None),
|
||||
/*flags*/ languageVersion >= ScriptTarget.ES2015 ? NodeFlags.Const : NodeFlags.None),
|
||||
/*location*/ node
|
||||
)
|
||||
);
|
||||
@@ -461,23 +462,21 @@ namespace ts {
|
||||
);
|
||||
}
|
||||
for (const specifier of node.exportClause.elements) {
|
||||
if (resolver.isValueAliasDeclaration(specifier)) {
|
||||
const exportedValue = createPropertyAccess(
|
||||
generatedName,
|
||||
specifier.propertyName || specifier.name
|
||||
);
|
||||
statements.push(
|
||||
createStatement(
|
||||
createExportAssignment(specifier.name, exportedValue),
|
||||
/*location*/ specifier
|
||||
)
|
||||
);
|
||||
}
|
||||
const exportedValue = createPropertyAccess(
|
||||
generatedName,
|
||||
specifier.propertyName || specifier.name
|
||||
);
|
||||
statements.push(
|
||||
createStatement(
|
||||
createExportAssignment(specifier.name, exportedValue),
|
||||
/*location*/ specifier
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return singleOrMany(statements);
|
||||
}
|
||||
else if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) {
|
||||
else {
|
||||
// export * from "mod";
|
||||
return createStatement(
|
||||
createCall(
|
||||
@@ -495,15 +494,14 @@ namespace ts {
|
||||
}
|
||||
|
||||
function visitExportAssignment(node: ExportAssignment): VisitResult<Statement> {
|
||||
if (!node.isExportEquals) {
|
||||
if (nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) {
|
||||
const statements: Statement[] = [];
|
||||
addExportDefault(statements, node.expression, /*location*/ node);
|
||||
return statements;
|
||||
}
|
||||
if (node.isExportEquals) {
|
||||
// Elide as `export=` is handled in addExportEqualsIfNeeded
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
const statements: Statement[] = [];
|
||||
addExportDefault(statements, node.expression, /*location*/ node);
|
||||
return statements;
|
||||
}
|
||||
|
||||
function addExportDefault(statements: Statement[], expression: Expression, location: TextRange): void {
|
||||
@@ -568,7 +566,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function collectExportMembers(names: Identifier[], node: Node): Identifier[] {
|
||||
if (isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node) && isDeclaration(node)) {
|
||||
if (isAliasSymbolDeclaration(node) && isDeclaration(node)) {
|
||||
const name = node.name;
|
||||
if (isIdentifier(name)) {
|
||||
names.push(name);
|
||||
@@ -682,7 +680,6 @@ namespace ts {
|
||||
const name = node.name;
|
||||
if (isBindingPattern(name)) {
|
||||
return flattenVariableDestructuringToExpression(
|
||||
context,
|
||||
node,
|
||||
hoistVariableDeclaration,
|
||||
getModuleMemberName,
|
||||
@@ -701,11 +698,13 @@ namespace ts {
|
||||
const statements: Statement[] = [];
|
||||
const name = node.name || getGeneratedNameForNode(node);
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
// Keep async modifier for ES2017 transformer
|
||||
const isAsync = hasModifier(node, ModifierFlags.Async);
|
||||
statements.push(
|
||||
setOriginalNode(
|
||||
createFunctionDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
isAsync ? [<Modifier>createNode(SyntaxKind.AsyncKeyword)] : undefined,
|
||||
node.asteriskToken,
|
||||
name,
|
||||
/*typeParameters*/ undefined,
|
||||
@@ -958,39 +957,19 @@ namespace ts {
|
||||
const declaration = resolver.getReferencedImportDeclaration(node);
|
||||
if (declaration) {
|
||||
if (isImportClause(declaration)) {
|
||||
if (languageVersion >= ScriptTarget.ES5) {
|
||||
return createPropertyAccess(
|
||||
getGeneratedNameForNode(declaration.parent),
|
||||
createIdentifier("default"),
|
||||
/*location*/ node
|
||||
);
|
||||
}
|
||||
else {
|
||||
// TODO: ES3 transform to handle x.default -> x["default"]
|
||||
return createElementAccess(
|
||||
getGeneratedNameForNode(declaration.parent),
|
||||
createLiteral("default"),
|
||||
/*location*/ node
|
||||
);
|
||||
}
|
||||
return createPropertyAccess(
|
||||
getGeneratedNameForNode(declaration.parent),
|
||||
createIdentifier("default"),
|
||||
/*location*/ node
|
||||
);
|
||||
}
|
||||
else if (isImportSpecifier(declaration)) {
|
||||
const name = declaration.propertyName || declaration.name;
|
||||
if (name.originalKeywordKind === SyntaxKind.DefaultKeyword && languageVersion <= ScriptTarget.ES3) {
|
||||
// TODO: ES3 transform to handle x.default -> x["default"]
|
||||
return createElementAccess(
|
||||
getGeneratedNameForNode(declaration.parent.parent.parent),
|
||||
createLiteral(name.text),
|
||||
/*location*/ node
|
||||
);
|
||||
}
|
||||
else {
|
||||
return createPropertyAccess(
|
||||
getGeneratedNameForNode(declaration.parent.parent.parent),
|
||||
getSynthesizedClone(name),
|
||||
/*location*/ node
|
||||
);
|
||||
}
|
||||
return createPropertyAccess(
|
||||
getGeneratedNameForNode(declaration.parent.parent.parent),
|
||||
getSynthesizedClone(name),
|
||||
/*location*/ node
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1027,15 +1006,10 @@ namespace ts {
|
||||
|
||||
function createExportAssignment(name: Identifier, value: Expression) {
|
||||
return createAssignment(
|
||||
name.originalKeywordKind === SyntaxKind.DefaultKeyword && languageVersion === ScriptTarget.ES3
|
||||
? createElementAccess(
|
||||
createIdentifier("exports"),
|
||||
createLiteral(name.text)
|
||||
)
|
||||
: createPropertyAccess(
|
||||
createIdentifier("exports"),
|
||||
getSynthesizedClone(name)
|
||||
),
|
||||
createPropertyAccess(
|
||||
createIdentifier("exports"),
|
||||
getSynthesizedClone(name)
|
||||
),
|
||||
value
|
||||
);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ namespace ts {
|
||||
const compilerOptions = context.getCompilerOptions();
|
||||
const resolver = context.getEmitResolver();
|
||||
const host = context.getEmitHost();
|
||||
const languageVersion = getEmitScriptTarget(compilerOptions);
|
||||
const previousOnSubstituteNode = context.onSubstituteNode;
|
||||
const previousOnEmitNode = context.onEmitNode;
|
||||
context.onSubstituteNode = onSubstituteNode;
|
||||
@@ -91,7 +90,7 @@ namespace ts {
|
||||
Debug.assert(!exportFunctionForFile);
|
||||
|
||||
// Collect information about the external module and dependency groups.
|
||||
({ externalImports, exportSpecifiers, exportEquals, hasExportStarsToExportValues } = collectExternalModuleInfo(node, resolver));
|
||||
({ externalImports, exportSpecifiers, exportEquals, hasExportStarsToExportValues } = collectExternalModuleInfo(node));
|
||||
|
||||
// Make sure that the name of the 'exports' function does not conflict with
|
||||
// existing identifiers.
|
||||
@@ -110,6 +109,7 @@ namespace ts {
|
||||
const moduleName = tryGetModuleNameFromFile(node, host, compilerOptions);
|
||||
const dependencies = createArrayLiteral(map(dependencyGroups, getNameOfDependencyGroup));
|
||||
const body = createFunctionExpression(
|
||||
/*modifiers*/ undefined,
|
||||
/*asteriskToken*/ undefined,
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
@@ -244,6 +244,7 @@ namespace ts {
|
||||
),
|
||||
createPropertyAssignment("execute",
|
||||
createFunctionExpression(
|
||||
/*modifiers*/ undefined,
|
||||
/*asteriskToken*/ undefined,
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
@@ -430,6 +431,7 @@ namespace ts {
|
||||
|
||||
setters.push(
|
||||
createFunctionExpression(
|
||||
/*modifiers*/ undefined,
|
||||
/*asteriskToken*/ undefined,
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
@@ -573,28 +575,23 @@ namespace ts {
|
||||
}
|
||||
|
||||
function visitExportSpecifier(specifier: ExportSpecifier): Statement {
|
||||
if (resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name)
|
||||
|| resolver.isValueAliasDeclaration(specifier)) {
|
||||
recordExportName(specifier.name);
|
||||
return createExportStatement(
|
||||
specifier.name,
|
||||
specifier.propertyName || specifier.name
|
||||
);
|
||||
}
|
||||
return undefined;
|
||||
recordExportName(specifier.name);
|
||||
return createExportStatement(
|
||||
specifier.name,
|
||||
specifier.propertyName || specifier.name
|
||||
);
|
||||
}
|
||||
|
||||
function visitExportAssignment(node: ExportAssignment): Statement {
|
||||
if (!node.isExportEquals) {
|
||||
if (nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) {
|
||||
return createExportStatement(
|
||||
createLiteral("default"),
|
||||
node.expression
|
||||
);
|
||||
}
|
||||
if (node.isExportEquals) {
|
||||
// Elide `export=` as it is illegal in a SystemJS module.
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
return createExportStatement(
|
||||
createLiteral("default"),
|
||||
node.expression
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -649,7 +646,7 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
// If the variable has a BindingPattern, flatten the variable into multiple assignment expressions.
|
||||
return flattenVariableDestructuringToExpression(context, node, hoistVariableDeclaration);
|
||||
return flattenVariableDestructuringToExpression(node, hoistVariableDeclaration);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -662,9 +659,11 @@ namespace ts {
|
||||
if (hasModifier(node, ModifierFlags.Export)) {
|
||||
// If the function is exported, ensure it has a name and rewrite the function without any export flags.
|
||||
const name = node.name || getGeneratedNameForNode(node);
|
||||
// Keep async modifier for ES2017 transformer
|
||||
const isAsync = hasModifier(node, ModifierFlags.Async);
|
||||
const newNode = createFunctionDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
isAsync ? [<Modifier>createNode(SyntaxKind.AsyncKeyword)] : undefined,
|
||||
node.asteriskToken,
|
||||
name,
|
||||
/*typeParameters*/ undefined,
|
||||
@@ -796,7 +795,7 @@ namespace ts {
|
||||
const name = firstDeclaration.name;
|
||||
return isIdentifier(name)
|
||||
? name
|
||||
: flattenVariableDestructuringToExpression(context, firstDeclaration, hoistVariableDeclaration);
|
||||
: flattenVariableDestructuringToExpression(firstDeclaration, hoistVariableDeclaration);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1317,12 +1316,7 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (name.originalKeywordKind && languageVersion === ScriptTarget.ES3) {
|
||||
return createElementAccess(importAlias, createLiteral(name.text));
|
||||
}
|
||||
else {
|
||||
return createPropertyAccess(importAlias, getSynthesizedClone(name));
|
||||
}
|
||||
return createPropertyAccess(importAlias, getSynthesizedClone(name));
|
||||
}
|
||||
|
||||
function collectDependencyGroups(externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[]) {
|
||||
@@ -1402,4 +1396,4 @@ namespace ts {
|
||||
return updated;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+237
-251
@@ -4,8 +4,6 @@
|
||||
|
||||
/*@internal*/
|
||||
namespace ts {
|
||||
type SuperContainer = ClassDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration;
|
||||
|
||||
/**
|
||||
* Indicates whether to emit type metadata in the new format.
|
||||
*/
|
||||
@@ -16,8 +14,6 @@ namespace ts {
|
||||
ClassAliases = 1 << 0,
|
||||
/** Enables substitutions for namespace exports. */
|
||||
NamespaceExports = 1 << 1,
|
||||
/** Enables substitutions for async methods with `super` calls. */
|
||||
AsyncMethodsWithSuper = 1 << 2,
|
||||
/* Enables substitutions for unqualified enum members */
|
||||
NonQualifiedEnumMembers = 1 << 3
|
||||
}
|
||||
@@ -72,12 +68,6 @@ namespace ts {
|
||||
*/
|
||||
let applicableSubstitutions: TypeScriptSubstitutionFlags;
|
||||
|
||||
/**
|
||||
* This keeps track of containers where `super` is valid, for use with
|
||||
* just-in-time substitution for `super` expressions inside of async methods.
|
||||
*/
|
||||
let currentSuperContainer: SuperContainer;
|
||||
|
||||
return transformSourceFile;
|
||||
|
||||
/**
|
||||
@@ -147,6 +137,35 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specialized visitor that visits the immediate children of a SourceFile.
|
||||
*
|
||||
* @param node The node to visit.
|
||||
*/
|
||||
function sourceElementVisitor(node: Node): VisitResult<Node> {
|
||||
return saveStateAndInvoke(node, sourceElementVisitorWorker);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specialized visitor that visits the immediate children of a SourceFile.
|
||||
*
|
||||
* @param node The node to visit.
|
||||
*/
|
||||
function sourceElementVisitorWorker(node: Node): VisitResult<Node> {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
return visitImportDeclaration(<ImportDeclaration>node);
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
return visitImportEqualsDeclaration(<ImportEqualsDeclaration>node);
|
||||
case SyntaxKind.ExportAssignment:
|
||||
return visitExportAssignment(<ExportAssignment>node);
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
return visitExportDeclaration(<ExportDeclaration>node);
|
||||
default:
|
||||
return visitorWorker(node);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Specialized visitor that visits the immediate children of a namespace.
|
||||
*
|
||||
@@ -244,7 +263,6 @@ namespace ts {
|
||||
case SyntaxKind.PrivateKeyword:
|
||||
case SyntaxKind.ProtectedKeyword:
|
||||
case SyntaxKind.AbstractKeyword:
|
||||
case SyntaxKind.AsyncKeyword:
|
||||
case SyntaxKind.ConstKeyword:
|
||||
case SyntaxKind.DeclareKeyword:
|
||||
case SyntaxKind.ReadonlyKeyword:
|
||||
@@ -286,8 +304,7 @@ namespace ts {
|
||||
// TypeScript property declarations are elided.
|
||||
|
||||
case SyntaxKind.Constructor:
|
||||
// TypeScript constructors are transformed in `visitClassDeclaration`.
|
||||
return undefined;
|
||||
return visitConstructor(<ConstructorDeclaration>node);
|
||||
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
// TypeScript interfaces are elided, but some comments may be preserved.
|
||||
@@ -304,7 +321,6 @@ namespace ts {
|
||||
// - property declarations
|
||||
// - index signatures
|
||||
// - method overload signatures
|
||||
// - async methods
|
||||
return visitClassDeclaration(<ClassDeclaration>node);
|
||||
|
||||
case SyntaxKind.ClassExpression:
|
||||
@@ -317,7 +333,6 @@ namespace ts {
|
||||
// - property declarations
|
||||
// - index signatures
|
||||
// - method overload signatures
|
||||
// - async methods
|
||||
return visitClassExpression(<ClassExpression>node);
|
||||
|
||||
case SyntaxKind.HeritageClause:
|
||||
@@ -332,7 +347,7 @@ namespace ts {
|
||||
return visitExpressionWithTypeArguments(<ExpressionWithTypeArguments>node);
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
// TypeScript method declarations may be 'async', and may have decorators, modifiers
|
||||
// TypeScript method declarations may have decorators, modifiers
|
||||
// or type annotations.
|
||||
return visitMethodDeclaration(<MethodDeclaration>node);
|
||||
|
||||
@@ -341,19 +356,19 @@ namespace ts {
|
||||
return visitGetAccessor(<GetAccessorDeclaration>node);
|
||||
|
||||
case SyntaxKind.SetAccessor:
|
||||
// Set Accessors can have TypeScript modifiers, decorators, and type annotations.
|
||||
// Set Accessors can have TypeScript modifiers and type annotations.
|
||||
return visitSetAccessor(<SetAccessorDeclaration>node);
|
||||
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
// TypeScript function declarations may be 'async'
|
||||
// Typescript function declarations can have modifiers, decorators, and type annotations.
|
||||
return visitFunctionDeclaration(<FunctionDeclaration>node);
|
||||
|
||||
case SyntaxKind.FunctionExpression:
|
||||
// TypeScript function expressions may be 'async'
|
||||
// TypeScript function expressions can have modifiers and type annotations.
|
||||
return visitFunctionExpression(<FunctionExpression>node);
|
||||
|
||||
case SyntaxKind.ArrowFunction:
|
||||
// TypeScript arrow functions may be 'async'
|
||||
// TypeScript arrow functions can have modifiers and type annotations.
|
||||
return visitArrowFunction(<ArrowFunction>node);
|
||||
|
||||
case SyntaxKind.Parameter:
|
||||
@@ -377,6 +392,12 @@ namespace ts {
|
||||
// TypeScript type assertions are removed, but their subtrees are preserved.
|
||||
return visitAssertionExpression(<AssertionExpression>node);
|
||||
|
||||
case SyntaxKind.CallExpression:
|
||||
return visitCallExpression(<CallExpression>node);
|
||||
|
||||
case SyntaxKind.NewExpression:
|
||||
return visitNewExpression(<NewExpression>node);
|
||||
|
||||
case SyntaxKind.NonNullExpression:
|
||||
// TypeScript non-null expressions are removed, but their subtrees are preserved.
|
||||
return visitNonNullExpression(<NonNullExpression>node);
|
||||
@@ -385,14 +406,13 @@ namespace ts {
|
||||
// TypeScript enum declarations do not exist in ES6 and must be rewritten.
|
||||
return visitEnumDeclaration(<EnumDeclaration>node);
|
||||
|
||||
case SyntaxKind.AwaitExpression:
|
||||
// TypeScript 'await' expressions must be transformed.
|
||||
return visitAwaitExpression(<AwaitExpression>node);
|
||||
|
||||
case SyntaxKind.VariableStatement:
|
||||
// TypeScript namespace exports for variable statements must be transformed.
|
||||
return visitVariableStatement(<VariableStatement>node);
|
||||
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
return visitVariableDeclaration(<VariableDeclaration>node);
|
||||
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
// TypeScript namespace declarations must be transformed.
|
||||
return visitModuleDeclaration(<ModuleDeclaration>node);
|
||||
@@ -436,6 +456,11 @@ namespace ts {
|
||||
function visitSourceFile(node: SourceFile) {
|
||||
currentSourceFile = node;
|
||||
|
||||
// ensure "use strict" is emitted in all scenarios in alwaysStrict mode
|
||||
if (compilerOptions.alwaysStrict) {
|
||||
node = ensureUseStrict(node);
|
||||
}
|
||||
|
||||
// If the source file requires any helpers and is an external module, and
|
||||
// the importHelpers compiler option is enabled, emit a synthesized import
|
||||
// statement for the helpers library.
|
||||
@@ -457,7 +482,7 @@ namespace ts {
|
||||
statements.push(externalHelpersModuleImport);
|
||||
|
||||
currentSourceFileExternalHelpersModuleName = externalHelpersModuleName;
|
||||
addRange(statements, visitNodes(node.statements, visitor, isStatement, statementOffset));
|
||||
addRange(statements, visitNodes(node.statements, sourceElementVisitor, isStatement, statementOffset));
|
||||
addRange(statements, endLexicalEnvironment());
|
||||
currentSourceFileExternalHelpersModuleName = undefined;
|
||||
|
||||
@@ -465,7 +490,7 @@ namespace ts {
|
||||
node.externalHelpersModuleName = externalHelpersModuleName;
|
||||
}
|
||||
else {
|
||||
node = visitEachChild(node, visitor, context);
|
||||
node = visitEachChild(node, sourceElementVisitor, context);
|
||||
}
|
||||
|
||||
setEmitFlags(node, EmitFlags.EmitEmitHelpers | getEmitFlags(node));
|
||||
@@ -555,7 +580,7 @@ namespace ts {
|
||||
// HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using
|
||||
// a lexical declaration such as a LexicalDeclaration or a ClassDeclaration.
|
||||
if (staticProperties.length) {
|
||||
addInitializedPropertyStatements(statements, node, staticProperties, getLocalName(node, /*noSourceMaps*/ true));
|
||||
addInitializedPropertyStatements(statements, staticProperties, getLocalName(node, /*noSourceMaps*/ true));
|
||||
}
|
||||
|
||||
// Write any decorators of the node.
|
||||
@@ -770,7 +795,7 @@ namespace ts {
|
||||
function visitClassExpression(node: ClassExpression): Expression {
|
||||
const staticProperties = getInitializedProperties(node, /*isStatic*/ true);
|
||||
const heritageClauses = visitNodes(node.heritageClauses, visitor, isHeritageClause);
|
||||
const members = transformClassMembers(node, heritageClauses !== undefined);
|
||||
const members = transformClassMembers(node, some(heritageClauses, c => c.token === SyntaxKind.ExtendsKeyword));
|
||||
|
||||
const classExpression = setOriginalNode(
|
||||
createClassExpression(
|
||||
@@ -797,7 +822,7 @@ namespace ts {
|
||||
// the body of a class with static initializers.
|
||||
setEmitFlags(classExpression, EmitFlags.Indented | getEmitFlags(classExpression));
|
||||
expressions.push(startOnNewLine(createAssignment(temp, classExpression)));
|
||||
addRange(expressions, generateInitializedPropertyExpressions(node, staticProperties, temp));
|
||||
addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp));
|
||||
expressions.push(startOnNewLine(temp));
|
||||
return inlineExpressions(expressions);
|
||||
}
|
||||
@@ -843,7 +868,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
const parameters = transformConstructorParameters(constructor);
|
||||
const body = transformConstructorBody(node, constructor, hasExtendsClause, parameters);
|
||||
const body = transformConstructorBody(node, constructor, hasExtendsClause);
|
||||
|
||||
// constructor(${parameters}) {
|
||||
// ${body}
|
||||
@@ -897,9 +922,8 @@ namespace ts {
|
||||
* @param node The current class.
|
||||
* @param constructor The current class constructor.
|
||||
* @param hasExtendsClause A value indicating whether the class has an extends clause.
|
||||
* @param parameters The transformed parameters for the constructor.
|
||||
*/
|
||||
function transformConstructorBody(node: ClassExpression | ClassDeclaration, constructor: ConstructorDeclaration, hasExtendsClause: boolean, parameters: ParameterDeclaration[]) {
|
||||
function transformConstructorBody(node: ClassExpression | ClassDeclaration, constructor: ConstructorDeclaration, hasExtendsClause: boolean) {
|
||||
const statements: Statement[] = [];
|
||||
let indexOfFirstStatement = 0;
|
||||
|
||||
@@ -951,7 +975,7 @@ namespace ts {
|
||||
// }
|
||||
//
|
||||
const properties = getInitializedProperties(node, /*isStatic*/ false);
|
||||
addInitializedPropertyStatements(statements, node, properties, createThis());
|
||||
addInitializedPropertyStatements(statements, properties, createThis());
|
||||
|
||||
if (constructor) {
|
||||
// The class already had a constructor, so we should add the existing statements, skipping the initial super call.
|
||||
@@ -1091,13 +1115,12 @@ namespace ts {
|
||||
/**
|
||||
* Generates assignment statements for property initializers.
|
||||
*
|
||||
* @param node The class node.
|
||||
* @param properties An array of property declarations to transform.
|
||||
* @param receiver The receiver on which each property should be assigned.
|
||||
*/
|
||||
function addInitializedPropertyStatements(statements: Statement[], node: ClassExpression | ClassDeclaration, properties: PropertyDeclaration[], receiver: LeftHandSideExpression) {
|
||||
function addInitializedPropertyStatements(statements: Statement[], properties: PropertyDeclaration[], receiver: LeftHandSideExpression) {
|
||||
for (const property of properties) {
|
||||
const statement = createStatement(transformInitializedProperty(node, property, receiver));
|
||||
const statement = createStatement(transformInitializedProperty(property, receiver));
|
||||
setSourceMapRange(statement, moveRangePastModifiers(property));
|
||||
setCommentRange(statement, property);
|
||||
statements.push(statement);
|
||||
@@ -1107,14 +1130,13 @@ namespace ts {
|
||||
/**
|
||||
* Generates assignment expressions for property initializers.
|
||||
*
|
||||
* @param node The class node.
|
||||
* @param properties An array of property declarations to transform.
|
||||
* @param receiver The receiver on which each property should be assigned.
|
||||
*/
|
||||
function generateInitializedPropertyExpressions(node: ClassExpression | ClassDeclaration, properties: PropertyDeclaration[], receiver: LeftHandSideExpression) {
|
||||
function generateInitializedPropertyExpressions(properties: PropertyDeclaration[], receiver: LeftHandSideExpression) {
|
||||
const expressions: Expression[] = [];
|
||||
for (const property of properties) {
|
||||
const expression = transformInitializedProperty(node, property, receiver);
|
||||
const expression = transformInitializedProperty(property, receiver);
|
||||
expression.startsOnNewLine = true;
|
||||
setSourceMapRange(expression, moveRangePastModifiers(property));
|
||||
setCommentRange(expression, property);
|
||||
@@ -1127,11 +1149,10 @@ namespace ts {
|
||||
/**
|
||||
* Transforms a property initializer into an assignment statement.
|
||||
*
|
||||
* @param node The class containing the property.
|
||||
* @param property The property declaration.
|
||||
* @param receiver The object receiving the property assignment.
|
||||
*/
|
||||
function transformInitializedProperty(node: ClassExpression | ClassDeclaration, property: PropertyDeclaration, receiver: LeftHandSideExpression) {
|
||||
function transformInitializedProperty(property: PropertyDeclaration, receiver: LeftHandSideExpression) {
|
||||
const propertyName = visitPropertyNameOfClassElement(property);
|
||||
const initializer = visitNode(property.initializer, visitor, isExpression);
|
||||
const memberAccess = createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName);
|
||||
@@ -1794,7 +1815,7 @@ namespace ts {
|
||||
return createIdentifier("Number");
|
||||
|
||||
case SyntaxKind.SymbolKeyword:
|
||||
return languageVersion < ScriptTarget.ES6
|
||||
return languageVersion < ScriptTarget.ES2015
|
||||
? getGlobalSymbolNameWithFallback()
|
||||
: createIdentifier("Symbol");
|
||||
|
||||
@@ -1891,7 +1912,7 @@ namespace ts {
|
||||
return createIdentifier("Array");
|
||||
|
||||
case TypeReferenceSerializationKind.ESSymbolType:
|
||||
return languageVersion < ScriptTarget.ES6
|
||||
return languageVersion < ScriptTarget.ES2015
|
||||
? getGlobalSymbolNameWithFallback()
|
||||
: createIdentifier("Symbol");
|
||||
|
||||
@@ -2083,12 +2104,20 @@ namespace ts {
|
||||
return !nodeIsMissing(node.body);
|
||||
}
|
||||
|
||||
function visitConstructor(node: ConstructorDeclaration) {
|
||||
if (!shouldEmitFunctionLikeDeclaration(node)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return visitEachChild(node, visitor, context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a method declaration of a class.
|
||||
*
|
||||
* This function will be called when one of the following conditions are met:
|
||||
* - The node is an overload
|
||||
* - The node is marked as abstract, async, public, private, protected, or readonly
|
||||
* - The node is marked as abstract, public, private, protected, or readonly
|
||||
* - The node has both a decorator and a computed property name
|
||||
*
|
||||
* @param node The method node.
|
||||
@@ -2199,8 +2228,8 @@ namespace ts {
|
||||
*
|
||||
* This function will be called when one of the following conditions are met:
|
||||
* - The node is an overload
|
||||
* - The node is marked async
|
||||
* - The node is exported from a TypeScript namespace
|
||||
* - The node has decorators
|
||||
*
|
||||
* @param node The function node.
|
||||
*/
|
||||
@@ -2235,7 +2264,7 @@ namespace ts {
|
||||
* Visits a function expression node.
|
||||
*
|
||||
* This function will be called when one of the following conditions are met:
|
||||
* - The node is marked async
|
||||
* - The node has type annotations
|
||||
*
|
||||
* @param node The function expression node.
|
||||
*/
|
||||
@@ -2245,6 +2274,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
const func = createFunctionExpression(
|
||||
visitNodes(node.modifiers, visitor, isModifier),
|
||||
node.asteriskToken,
|
||||
node.name,
|
||||
/*typeParameters*/ undefined,
|
||||
@@ -2262,11 +2292,11 @@ namespace ts {
|
||||
/**
|
||||
* @remarks
|
||||
* This function will be called when one of the following conditions are met:
|
||||
* - The node is marked async
|
||||
* - The node has type annotations
|
||||
*/
|
||||
function visitArrowFunction(node: ArrowFunction) {
|
||||
const func = createArrowFunction(
|
||||
/*modifiers*/ undefined,
|
||||
visitNodes(node.modifiers, visitor, isModifier),
|
||||
/*typeParameters*/ undefined,
|
||||
visitNodes(node.parameters, visitor, isParameter),
|
||||
/*type*/ undefined,
|
||||
@@ -2281,30 +2311,25 @@ namespace ts {
|
||||
}
|
||||
|
||||
function transformFunctionBody(node: MethodDeclaration | AccessorDeclaration | FunctionDeclaration | FunctionExpression): FunctionBody {
|
||||
if (isAsyncFunctionLike(node)) {
|
||||
return <FunctionBody>transformAsyncFunctionBody(node);
|
||||
}
|
||||
|
||||
return transformFunctionBodyWorker(node.body);
|
||||
}
|
||||
|
||||
function transformFunctionBodyWorker(body: Block, start = 0) {
|
||||
const savedCurrentScope = currentScope;
|
||||
const savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName;
|
||||
currentScope = body;
|
||||
currentScopeFirstDeclarationsOfName = createMap<Node>();
|
||||
startLexicalEnvironment();
|
||||
|
||||
const statements = visitNodes(body.statements, visitor, isStatement, start);
|
||||
const visited = updateBlock(body, statements);
|
||||
const declarations = endLexicalEnvironment();
|
||||
currentScope = savedCurrentScope;
|
||||
currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName;
|
||||
return mergeFunctionBodyLexicalEnvironment(visited, declarations);
|
||||
}
|
||||
|
||||
function transformConciseBody(node: ArrowFunction): ConciseBody {
|
||||
if (isAsyncFunctionLike(node)) {
|
||||
return transformAsyncFunctionBody(node);
|
||||
}
|
||||
|
||||
return transformConciseBodyWorker(node.body, /*forceBlockFunctionBody*/ false);
|
||||
}
|
||||
|
||||
@@ -2328,72 +2353,6 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getPromiseConstructor(type: TypeNode) {
|
||||
const typeName = getEntityNameFromTypeNode(type);
|
||||
if (typeName && isEntityName(typeName)) {
|
||||
const serializationKind = resolver.getTypeReferenceSerializationKind(typeName);
|
||||
if (serializationKind === TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue
|
||||
|| serializationKind === TypeReferenceSerializationKind.Unknown) {
|
||||
return typeName;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function transformAsyncFunctionBody(node: FunctionLikeDeclaration): ConciseBody | FunctionBody {
|
||||
const promiseConstructor = languageVersion < ScriptTarget.ES6 ? getPromiseConstructor(node.type) : undefined;
|
||||
const isArrowFunction = node.kind === SyntaxKind.ArrowFunction;
|
||||
const hasLexicalArguments = (resolver.getNodeCheckFlags(node) & NodeCheckFlags.CaptureArguments) !== 0;
|
||||
|
||||
// An async function is emit as an outer function that calls an inner
|
||||
// generator function. To preserve lexical bindings, we pass the current
|
||||
// `this` and `arguments` objects to `__awaiter`. The generator function
|
||||
// passed to `__awaiter` is executed inside of the callback to the
|
||||
// promise constructor.
|
||||
|
||||
|
||||
if (!isArrowFunction) {
|
||||
const statements: Statement[] = [];
|
||||
const statementOffset = addPrologueDirectives(statements, (<Block>node.body).statements, /*ensureUseStrict*/ false, visitor);
|
||||
statements.push(
|
||||
createReturn(
|
||||
createAwaiterHelper(
|
||||
currentSourceFileExternalHelpersModuleName,
|
||||
hasLexicalArguments,
|
||||
promiseConstructor,
|
||||
transformFunctionBodyWorker(<Block>node.body, statementOffset)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
const block = createBlock(statements, /*location*/ node.body, /*multiLine*/ true);
|
||||
|
||||
// Minor optimization, emit `_super` helper to capture `super` access in an arrow.
|
||||
// This step isn't needed if we eventually transform this to ES5.
|
||||
if (languageVersion >= ScriptTarget.ES6) {
|
||||
if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.AsyncMethodWithSuperBinding) {
|
||||
enableSubstitutionForAsyncMethodsWithSuper();
|
||||
setEmitFlags(block, EmitFlags.EmitAdvancedSuperHelper);
|
||||
}
|
||||
else if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.AsyncMethodWithSuper) {
|
||||
enableSubstitutionForAsyncMethodsWithSuper();
|
||||
setEmitFlags(block, EmitFlags.EmitSuperHelper);
|
||||
}
|
||||
}
|
||||
|
||||
return block;
|
||||
}
|
||||
else {
|
||||
return createAwaiterHelper(
|
||||
currentSourceFileExternalHelpersModuleName,
|
||||
hasLexicalArguments,
|
||||
promiseConstructor,
|
||||
<Block>transformConciseBodyWorker(node.body, /*forceBlockFunctionBody*/ true)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits a parameter declaration node.
|
||||
*
|
||||
@@ -2460,7 +2419,6 @@ namespace ts {
|
||||
const name = node.name;
|
||||
if (isBindingPattern(name)) {
|
||||
return flattenVariableDestructuringToExpression(
|
||||
context,
|
||||
node,
|
||||
hoistVariableDeclaration,
|
||||
getNamespaceMemberNameWithSourceMapsAndWithoutComments,
|
||||
@@ -2476,22 +2434,12 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an await expression.
|
||||
*
|
||||
* This function will be called any time a TypeScript await expression is encountered.
|
||||
*
|
||||
* @param node The await expression node.
|
||||
*/
|
||||
function visitAwaitExpression(node: AwaitExpression): Expression {
|
||||
return setOriginalNode(
|
||||
createYield(
|
||||
/*asteriskToken*/ undefined,
|
||||
visitNode(node.expression, visitor, isExpression),
|
||||
/*location*/ node
|
||||
),
|
||||
node
|
||||
);
|
||||
function visitVariableDeclaration(node: VariableDeclaration) {
|
||||
return updateVariableDeclaration(
|
||||
node,
|
||||
visitNode(node.name, visitor, isBindingName),
|
||||
/*type*/ undefined,
|
||||
visitNode(node.initializer, visitor, isExpression));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2536,6 +2484,22 @@ namespace ts {
|
||||
return createPartiallyEmittedExpression(expression, node);
|
||||
}
|
||||
|
||||
function visitCallExpression(node: CallExpression) {
|
||||
return updateCall(
|
||||
node,
|
||||
visitNode(node.expression, visitor, isExpression),
|
||||
/*typeArguments*/ undefined,
|
||||
visitNodes(node.arguments, visitor, isExpression));
|
||||
}
|
||||
|
||||
function visitNewExpression(node: NewExpression) {
|
||||
return updateNew(
|
||||
node,
|
||||
visitNode(node.expression, visitor, isExpression),
|
||||
/*typeArguments*/ undefined,
|
||||
visitNodes(node.arguments, visitor, isExpression));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether to emit an enum declaration.
|
||||
*
|
||||
@@ -2617,6 +2581,7 @@ namespace ts {
|
||||
const enumStatement = createStatement(
|
||||
createCall(
|
||||
createFunctionExpression(
|
||||
/*modifiers*/ undefined,
|
||||
/*asteriskToken*/ undefined,
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
@@ -2730,7 +2695,7 @@ namespace ts {
|
||||
|
||||
function isES6ExportedDeclaration(node: Node) {
|
||||
return isExternalModuleExport(node)
|
||||
&& moduleKind === ModuleKind.ES6;
|
||||
&& moduleKind === ModuleKind.ES2015;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2888,6 +2853,7 @@ namespace ts {
|
||||
const moduleStatement = createStatement(
|
||||
createCall(
|
||||
createFunctionExpression(
|
||||
/*modifiers*/ undefined,
|
||||
/*asteriskToken*/ undefined,
|
||||
/*name*/ undefined,
|
||||
/*typeParameters*/ undefined,
|
||||
@@ -2993,6 +2959,133 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an import declaration, eliding it if it is not referenced.
|
||||
*
|
||||
* @param node The import declaration node.
|
||||
*/
|
||||
function visitImportDeclaration(node: ImportDeclaration): VisitResult<Statement> {
|
||||
if (!node.importClause) {
|
||||
// Do not elide a side-effect only import declaration.
|
||||
// import "foo";
|
||||
return node;
|
||||
}
|
||||
|
||||
// Elide the declaration if the import clause was elided.
|
||||
const importClause = visitNode(node.importClause, visitImportClause, isImportClause, /*optional*/ true);
|
||||
return importClause
|
||||
? updateImportDeclaration(
|
||||
node,
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
importClause,
|
||||
node.moduleSpecifier)
|
||||
: undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an import clause, eliding it if it is not referenced.
|
||||
*
|
||||
* @param node The import clause node.
|
||||
*/
|
||||
function visitImportClause(node: ImportClause): VisitResult<ImportClause> {
|
||||
// Elide the import clause if we elide both its name and its named bindings.
|
||||
const name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined;
|
||||
const namedBindings = visitNode(node.namedBindings, visitNamedImportBindings, isNamedImportBindings, /*optional*/ true);
|
||||
return (name || namedBindings) ? updateImportClause(node, name, namedBindings) : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits named import bindings, eliding it if it is not referenced.
|
||||
*
|
||||
* @param node The named import bindings node.
|
||||
*/
|
||||
function visitNamedImportBindings(node: NamedImportBindings): VisitResult<NamedImportBindings> {
|
||||
if (node.kind === SyntaxKind.NamespaceImport) {
|
||||
// Elide a namespace import if it is not referenced.
|
||||
return resolver.isReferencedAliasDeclaration(node) ? node : undefined;
|
||||
}
|
||||
else {
|
||||
// Elide named imports if all of its import specifiers are elided.
|
||||
const elements = visitNodes(node.elements, visitImportSpecifier, isImportSpecifier);
|
||||
return some(elements) ? updateNamedImports(node, elements) : undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an import specifier, eliding it if it is not referenced.
|
||||
*
|
||||
* @param node The import specifier node.
|
||||
*/
|
||||
function visitImportSpecifier(node: ImportSpecifier): VisitResult<ImportSpecifier> {
|
||||
// Elide an import specifier if it is not referenced.
|
||||
return resolver.isReferencedAliasDeclaration(node) ? node : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an export assignment, eliding it if it does not contain a clause that resolves
|
||||
* to a value.
|
||||
*
|
||||
* @param node The export assignment node.
|
||||
*/
|
||||
function visitExportAssignment(node: ExportAssignment): VisitResult<Statement> {
|
||||
// Elide the export assignment if it does not reference a value.
|
||||
return resolver.isValueAliasDeclaration(node)
|
||||
? visitEachChild(node, visitor, context)
|
||||
: undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an export declaration, eliding it if it does not contain a clause that resolves
|
||||
* to a value.
|
||||
*
|
||||
* @param node The export declaration node.
|
||||
*/
|
||||
function visitExportDeclaration(node: ExportDeclaration): VisitResult<Statement> {
|
||||
if (!node.exportClause) {
|
||||
// Elide a star export if the module it references does not export a value.
|
||||
return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined;
|
||||
}
|
||||
|
||||
if (!resolver.isValueAliasDeclaration(node)) {
|
||||
// Elide the export declaration if it does not export a value.
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Elide the export declaration if all of its named exports are elided.
|
||||
const exportClause = visitNode(node.exportClause, visitNamedExports, isNamedExports, /*optional*/ true);
|
||||
return exportClause
|
||||
? updateExportDeclaration(
|
||||
node,
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
exportClause,
|
||||
node.moduleSpecifier)
|
||||
: undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits named exports, eliding it if it does not contain an export specifier that
|
||||
* resolves to a value.
|
||||
*
|
||||
* @param node The named exports node.
|
||||
*/
|
||||
function visitNamedExports(node: NamedExports): VisitResult<NamedExports> {
|
||||
// Elide the named exports if all of its export specifiers were elided.
|
||||
const elements = visitNodes(node.elements, visitExportSpecifier, isExportSpecifier);
|
||||
return some(elements) ? updateNamedExports(node, elements) : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits an export specifier, eliding it if it does not resolve to a value.
|
||||
*
|
||||
* @param node The export specifier node.
|
||||
*/
|
||||
function visitExportSpecifier(node: ExportSpecifier): VisitResult<ExportSpecifier> {
|
||||
// Elide an export specifier if it does not reference a value.
|
||||
return resolver.isValueAliasDeclaration(node) ? node : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether to emit an import equals declaration.
|
||||
*
|
||||
@@ -3014,7 +3107,10 @@ namespace ts {
|
||||
*/
|
||||
function visitImportEqualsDeclaration(node: ImportEqualsDeclaration): VisitResult<Statement> {
|
||||
if (isExternalModuleImportEqualsDeclaration(node)) {
|
||||
return visitEachChild(node, visitor, context);
|
||||
// Elide external module `import=` if it is not referenced.
|
||||
return resolver.isReferencedAliasDeclaration(node)
|
||||
? visitEachChild(node, visitor, context)
|
||||
: undefined;
|
||||
}
|
||||
|
||||
if (!shouldEmitImportEqualsDeclaration(node)) {
|
||||
@@ -3248,25 +3344,6 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function enableSubstitutionForAsyncMethodsWithSuper() {
|
||||
if ((enabledSubstitutions & TypeScriptSubstitutionFlags.AsyncMethodsWithSuper) === 0) {
|
||||
enabledSubstitutions |= TypeScriptSubstitutionFlags.AsyncMethodsWithSuper;
|
||||
|
||||
// We need to enable substitutions for call, property access, and element access
|
||||
// if we need to rewrite super calls.
|
||||
context.enableSubstitution(SyntaxKind.CallExpression);
|
||||
context.enableSubstitution(SyntaxKind.PropertyAccessExpression);
|
||||
context.enableSubstitution(SyntaxKind.ElementAccessExpression);
|
||||
|
||||
// We need to be notified when entering and exiting declarations that bind super.
|
||||
context.enableEmitNotification(SyntaxKind.ClassDeclaration);
|
||||
context.enableEmitNotification(SyntaxKind.MethodDeclaration);
|
||||
context.enableEmitNotification(SyntaxKind.GetAccessor);
|
||||
context.enableEmitNotification(SyntaxKind.SetAccessor);
|
||||
context.enableEmitNotification(SyntaxKind.Constructor);
|
||||
}
|
||||
}
|
||||
|
||||
function enableSubstitutionForClassAliases() {
|
||||
if ((enabledSubstitutions & TypeScriptSubstitutionFlags.ClassAliases) === 0) {
|
||||
enabledSubstitutions |= TypeScriptSubstitutionFlags.ClassAliases;
|
||||
@@ -3294,15 +3371,6 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function isSuperContainer(node: Node): node is SuperContainer {
|
||||
const kind = node.kind;
|
||||
return kind === SyntaxKind.ClassDeclaration
|
||||
|| kind === SyntaxKind.Constructor
|
||||
|| kind === SyntaxKind.MethodDeclaration
|
||||
|| kind === SyntaxKind.GetAccessor
|
||||
|| kind === SyntaxKind.SetAccessor;
|
||||
}
|
||||
|
||||
function isTransformedModuleDeclaration(node: Node): boolean {
|
||||
return getOriginalNode(node).kind === SyntaxKind.ModuleDeclaration;
|
||||
}
|
||||
@@ -3319,12 +3387,6 @@ namespace ts {
|
||||
*/
|
||||
function onEmitNode(emitContext: EmitContext, node: Node, emitCallback: (emitContext: EmitContext, node: Node) => void): void {
|
||||
const savedApplicableSubstitutions = applicableSubstitutions;
|
||||
const savedCurrentSuperContainer = currentSuperContainer;
|
||||
// If we need to support substitutions for `super` in an async method,
|
||||
// we should track it here.
|
||||
if (enabledSubstitutions & TypeScriptSubstitutionFlags.AsyncMethodsWithSuper && isSuperContainer(node)) {
|
||||
currentSuperContainer = node;
|
||||
}
|
||||
|
||||
if (enabledSubstitutions & TypeScriptSubstitutionFlags.NamespaceExports && isTransformedModuleDeclaration(node)) {
|
||||
applicableSubstitutions |= TypeScriptSubstitutionFlags.NamespaceExports;
|
||||
@@ -3337,7 +3399,6 @@ namespace ts {
|
||||
previousOnEmitNode(emitContext, node, emitCallback);
|
||||
|
||||
applicableSubstitutions = savedApplicableSubstitutions;
|
||||
currentSuperContainer = savedCurrentSuperContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3384,11 +3445,6 @@ namespace ts {
|
||||
return substitutePropertyAccessExpression(<PropertyAccessExpression>node);
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
return substituteElementAccessExpression(<ElementAccessExpression>node);
|
||||
case SyntaxKind.CallExpression:
|
||||
if (enabledSubstitutions & TypeScriptSubstitutionFlags.AsyncMethodsWithSuper) {
|
||||
return substituteCallExpression(<CallExpression>node);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return node;
|
||||
@@ -3443,54 +3499,11 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function substituteCallExpression(node: CallExpression): Expression {
|
||||
const expression = node.expression;
|
||||
if (isSuperProperty(expression)) {
|
||||
const flags = getSuperContainerAsyncMethodFlags();
|
||||
if (flags) {
|
||||
const argumentExpression = isPropertyAccessExpression(expression)
|
||||
? substitutePropertyAccessExpression(expression)
|
||||
: substituteElementAccessExpression(expression);
|
||||
return createCall(
|
||||
createPropertyAccess(argumentExpression, "call"),
|
||||
/*typeArguments*/ undefined,
|
||||
[
|
||||
createThis(),
|
||||
...node.arguments
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
function substitutePropertyAccessExpression(node: PropertyAccessExpression) {
|
||||
if (enabledSubstitutions & TypeScriptSubstitutionFlags.AsyncMethodsWithSuper && node.expression.kind === SyntaxKind.SuperKeyword) {
|
||||
const flags = getSuperContainerAsyncMethodFlags();
|
||||
if (flags) {
|
||||
return createSuperAccessInAsyncMethod(
|
||||
createLiteral(node.name.text),
|
||||
flags,
|
||||
node
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return substituteConstantValue(node);
|
||||
}
|
||||
|
||||
function substituteElementAccessExpression(node: ElementAccessExpression) {
|
||||
if (enabledSubstitutions & TypeScriptSubstitutionFlags.AsyncMethodsWithSuper && node.expression.kind === SyntaxKind.SuperKeyword) {
|
||||
const flags = getSuperContainerAsyncMethodFlags();
|
||||
if (flags) {
|
||||
return createSuperAccessInAsyncMethod(
|
||||
node.argumentExpression,
|
||||
flags,
|
||||
node
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return substituteConstantValue(node);
|
||||
}
|
||||
|
||||
@@ -3523,32 +3536,5 @@ namespace ts {
|
||||
? resolver.getConstantValue(<PropertyAccessExpression | ElementAccessExpression>node)
|
||||
: undefined;
|
||||
}
|
||||
|
||||
function createSuperAccessInAsyncMethod(argumentExpression: Expression, flags: NodeCheckFlags, location: TextRange): LeftHandSideExpression {
|
||||
if (flags & NodeCheckFlags.AsyncMethodWithSuperBinding) {
|
||||
return createPropertyAccess(
|
||||
createCall(
|
||||
createIdentifier("_super"),
|
||||
/*typeArguments*/ undefined,
|
||||
[argumentExpression]
|
||||
),
|
||||
"value",
|
||||
location
|
||||
);
|
||||
}
|
||||
else {
|
||||
return createCall(
|
||||
createIdentifier("_super"),
|
||||
/*typeArguments*/ undefined,
|
||||
[argumentExpression],
|
||||
location
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function getSuperContainerAsyncMethodFlags() {
|
||||
return currentSuperContainer !== undefined
|
||||
&& resolver.getNodeCheckFlags(currentSuperContainer) & (NodeCheckFlags.AsyncMethodWithSuper | NodeCheckFlags.AsyncMethodWithSuperBinding);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+20
-12
@@ -29,7 +29,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function reportEmittedFiles(files: string[], host: CompilerHost): void {
|
||||
function reportEmittedFiles(files: string[]): void {
|
||||
if (!files || files.length == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ namespace ts {
|
||||
return count;
|
||||
}
|
||||
|
||||
function getDiagnosticText(message: DiagnosticMessage, ...args: any[]): string {
|
||||
function getDiagnosticText(_message: DiagnosticMessage, ..._args: any[]): string {
|
||||
const diagnostic = createCompilerDiagnostic.apply(undefined, arguments);
|
||||
return <string>diagnostic.messageText;
|
||||
}
|
||||
@@ -250,8 +250,8 @@ namespace ts {
|
||||
let compilerOptions: CompilerOptions; // Compiler options for compilation
|
||||
let compilerHost: CompilerHost; // Compiler host
|
||||
let hostGetSourceFile: typeof compilerHost.getSourceFile; // getSourceFile method from default host
|
||||
let timerHandleForRecompilation: number; // Handle for 0.25s wait timer to trigger recompilation
|
||||
let timerHandleForDirectoryChanges: number; // Handle for 0.25s wait timer to trigger directory change handler
|
||||
let timerHandleForRecompilation: any; // Handle for 0.25s wait timer to trigger recompilation
|
||||
let timerHandleForDirectoryChanges: any; // Handle for 0.25s wait timer to trigger directory change handler
|
||||
|
||||
// This map stores and reuses results of fileExists check that happen inside 'createProgram'
|
||||
// This allows to save time in module resolution heavy scenarios when existence of the same file might be checked multiple times.
|
||||
@@ -456,7 +456,7 @@ namespace ts {
|
||||
const sourceFile = hostGetSourceFile(fileName, languageVersion, onError);
|
||||
if (sourceFile && isWatchSet(compilerOptions) && sys.watchFile) {
|
||||
// Attach a file watcher
|
||||
sourceFile.fileWatcher = sys.watchFile(sourceFile.fileName, (fileName: string, removed?: boolean) => sourceFileChanged(sourceFile, removed));
|
||||
sourceFile.fileWatcher = sys.watchFile(sourceFile.fileName, (_fileName: string, removed?: boolean) => sourceFileChanged(sourceFile, removed));
|
||||
}
|
||||
return sourceFile;
|
||||
}
|
||||
@@ -503,10 +503,14 @@ namespace ts {
|
||||
}
|
||||
|
||||
function startTimerForHandlingDirectoryChanges() {
|
||||
if (timerHandleForDirectoryChanges) {
|
||||
clearTimeout(timerHandleForDirectoryChanges);
|
||||
if (!sys.setTimeout || !sys.clearTimeout) {
|
||||
return;
|
||||
}
|
||||
timerHandleForDirectoryChanges = setTimeout(directoryChangeHandler, 250);
|
||||
|
||||
if (timerHandleForDirectoryChanges) {
|
||||
sys.clearTimeout(timerHandleForDirectoryChanges);
|
||||
}
|
||||
timerHandleForDirectoryChanges = sys.setTimeout(directoryChangeHandler, 250);
|
||||
}
|
||||
|
||||
function directoryChangeHandler() {
|
||||
@@ -525,10 +529,14 @@ namespace ts {
|
||||
// operations (such as saving all modified files in an editor) a chance to complete before we kick
|
||||
// off a new compilation.
|
||||
function startTimerForRecompilation() {
|
||||
if (timerHandleForRecompilation) {
|
||||
clearTimeout(timerHandleForRecompilation);
|
||||
if (!sys.setTimeout || !sys.clearTimeout) {
|
||||
return;
|
||||
}
|
||||
timerHandleForRecompilation = setTimeout(recompile, 250);
|
||||
|
||||
if (timerHandleForRecompilation) {
|
||||
sys.clearTimeout(timerHandleForRecompilation);
|
||||
}
|
||||
timerHandleForRecompilation = sys.setTimeout(recompile, 250);
|
||||
}
|
||||
|
||||
function recompile() {
|
||||
@@ -617,7 +625,7 @@ namespace ts {
|
||||
|
||||
reportDiagnostics(sortAndDeduplicateDiagnostics(diagnostics), compilerHost);
|
||||
|
||||
reportEmittedFiles(emitOutput.emittedFiles, compilerHost);
|
||||
reportEmittedFiles(emitOutput.emittedFiles);
|
||||
|
||||
if (emitOutput.emitSkipped && diagnostics.length > 0) {
|
||||
// If the emitter didn't emit anything, then pass that value along.
|
||||
|
||||
@@ -8,7 +8,10 @@
|
||||
"outFile": "../../built/local/tsc.js",
|
||||
"sourceMap": true,
|
||||
"declaration": true,
|
||||
"stripInternal": true
|
||||
"stripInternal": true,
|
||||
"target": "es5",
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true
|
||||
},
|
||||
"files": [
|
||||
"core.ts",
|
||||
@@ -24,13 +27,15 @@
|
||||
"visitor.ts",
|
||||
"transformers/ts.ts",
|
||||
"transformers/jsx.ts",
|
||||
"transformers/es7.ts",
|
||||
"transformers/es6.ts",
|
||||
"transformers/es2017.ts",
|
||||
"transformers/es2016.ts",
|
||||
"transformers/es2015.ts",
|
||||
"transformers/generators.ts",
|
||||
"transformers/es5.ts",
|
||||
"transformers/destructuring.ts",
|
||||
"transformers/module/module.ts",
|
||||
"transformers/module/system.ts",
|
||||
"transformers/module/es6.ts",
|
||||
"transformers/module/es2015.ts",
|
||||
"transformer.ts",
|
||||
"comments.ts",
|
||||
"sourcemap.ts",
|
||||
|
||||
+80
-58
@@ -45,6 +45,7 @@ namespace ts {
|
||||
// Literals
|
||||
NumericLiteral,
|
||||
StringLiteral,
|
||||
JsxText,
|
||||
RegularExpressionLiteral,
|
||||
NoSubstitutionTemplateLiteral,
|
||||
// Pseudo-literals
|
||||
@@ -302,7 +303,6 @@ namespace ts {
|
||||
JsxElement,
|
||||
JsxSelfClosingElement,
|
||||
JsxOpeningElement,
|
||||
JsxText,
|
||||
JsxClosingElement,
|
||||
JsxAttribute,
|
||||
JsxSpreadAttribute,
|
||||
@@ -456,6 +456,8 @@ namespace ts {
|
||||
// Accessibility modifiers and 'readonly' can be attached to a parameter in a constructor to make it a property.
|
||||
ParameterPropertyModifier = AccessibilityModifier | Readonly,
|
||||
NonPublicAccessibilityModifier = Private | Protected,
|
||||
|
||||
TypeScriptModifier = Ambient | Public | Private | Protected | Readonly | Abstract | Const
|
||||
}
|
||||
|
||||
export const enum JsxFlags {
|
||||
@@ -1907,8 +1909,9 @@ namespace ts {
|
||||
TrueCondition = 1 << 5, // Condition known to be true
|
||||
FalseCondition = 1 << 6, // Condition known to be false
|
||||
SwitchClause = 1 << 7, // Switch statement clause
|
||||
Referenced = 1 << 8, // Referenced as antecedent once
|
||||
Shared = 1 << 9, // Referenced as antecedent more than once
|
||||
ArrayMutation = 1 << 8, // Potential array mutation
|
||||
Referenced = 1 << 9, // Referenced as antecedent once
|
||||
Shared = 1 << 10, // Referenced as antecedent more than once
|
||||
Label = BranchLabel | LoopLabel,
|
||||
Condition = TrueCondition | FalseCondition
|
||||
}
|
||||
@@ -1922,7 +1925,7 @@ namespace ts {
|
||||
// function, the container property references the function (which in turn has a flowNode
|
||||
// property for the containing control flow).
|
||||
export interface FlowStart extends FlowNode {
|
||||
container?: FunctionExpression | ArrowFunction;
|
||||
container?: FunctionExpression | ArrowFunction | MethodDeclaration;
|
||||
}
|
||||
|
||||
// FlowLabel represents a junction with multiple possible preceding control flows.
|
||||
@@ -1951,6 +1954,13 @@ namespace ts {
|
||||
antecedent: FlowNode;
|
||||
}
|
||||
|
||||
// FlowArrayMutation represents a node potentially mutates an array, i.e. an
|
||||
// operation of the form 'x.push(value)', 'x.unshift(value)' or 'x[n] = value'.
|
||||
export interface FlowArrayMutation extends FlowNode {
|
||||
node: CallExpression | BinaryExpression;
|
||||
antecedent: FlowNode;
|
||||
}
|
||||
|
||||
export type FlowType = Type | IncompleteType;
|
||||
|
||||
// Incomplete types occur during control flow analysis of loops. An IncompleteType
|
||||
@@ -2602,24 +2612,17 @@ namespace ts {
|
||||
Null = 1 << 12,
|
||||
Never = 1 << 13, // Never type
|
||||
TypeParameter = 1 << 14, // Type parameter
|
||||
Class = 1 << 15, // Class
|
||||
Interface = 1 << 16, // Interface
|
||||
Reference = 1 << 17, // Generic type reference
|
||||
Tuple = 1 << 18, // Synthesized generic tuple type
|
||||
Union = 1 << 19, // Union (T | U)
|
||||
Intersection = 1 << 20, // Intersection (T & U)
|
||||
Anonymous = 1 << 21, // Anonymous
|
||||
Instantiated = 1 << 22, // Instantiated anonymous type
|
||||
Object = 1 << 15, // Object type
|
||||
Union = 1 << 16, // Union (T | U)
|
||||
Intersection = 1 << 17, // Intersection (T & U)
|
||||
/* @internal */
|
||||
ObjectLiteral = 1 << 23, // Originates in an object literal
|
||||
FreshLiteral = 1 << 18, // Fresh literal type
|
||||
/* @internal */
|
||||
FreshLiteral = 1 << 24, // Fresh literal type
|
||||
ContainsWideningType = 1 << 19, // Type is or contains undefined or null widening type
|
||||
/* @internal */
|
||||
ContainsWideningType = 1 << 25, // Type is or contains undefined or null widening type
|
||||
ContainsObjectLiteral = 1 << 20, // Type is or contains object literal type
|
||||
/* @internal */
|
||||
ContainsObjectLiteral = 1 << 26, // Type is or contains object literal type
|
||||
/* @internal */
|
||||
ContainsAnyFunctionType = 1 << 27, // Type is or contains object literal type
|
||||
ContainsAnyFunctionType = 1 << 21, // Type is or contains object literal type
|
||||
|
||||
/* @internal */
|
||||
Nullable = Undefined | Null,
|
||||
@@ -2636,15 +2639,14 @@ namespace ts {
|
||||
NumberLike = Number | NumberLiteral | Enum | EnumLiteral,
|
||||
BooleanLike = Boolean | BooleanLiteral,
|
||||
EnumLike = Enum | EnumLiteral,
|
||||
ObjectType = Class | Interface | Reference | Tuple | Anonymous,
|
||||
UnionOrIntersection = Union | Intersection,
|
||||
StructuredType = ObjectType | Union | Intersection,
|
||||
StructuredType = Object | Union | Intersection,
|
||||
StructuredOrTypeParameter = StructuredType | TypeParameter,
|
||||
|
||||
// 'Narrowable' types are types where narrowing actually narrows.
|
||||
// This *should* be every type other than null, undefined, void, and never
|
||||
Narrowable = Any | StructuredType | TypeParameter | StringLike | NumberLike | BooleanLike | ESSymbol,
|
||||
NotUnionOrUnit = Any | String | Number | ESSymbol | ObjectType,
|
||||
NotUnionOrUnit = Any | ESSymbol | Object,
|
||||
/* @internal */
|
||||
RequiresWidening = ContainsWideningType | ContainsObjectLiteral,
|
||||
/* @internal */
|
||||
@@ -2687,9 +2689,22 @@ namespace ts {
|
||||
baseType: EnumType & UnionType; // Base enum type
|
||||
}
|
||||
|
||||
export const enum ObjectFlags {
|
||||
Class = 1 << 0, // Class
|
||||
Interface = 1 << 1, // Interface
|
||||
Reference = 1 << 2, // Generic type reference
|
||||
Tuple = 1 << 3, // Synthesized generic tuple type
|
||||
Anonymous = 1 << 4, // Anonymous
|
||||
Instantiated = 1 << 5, // Instantiated anonymous type
|
||||
ObjectLiteral = 1 << 6, // Originates in an object literal
|
||||
EvolvingArray = 1 << 7, // Evolving array type
|
||||
ObjectLiteralPatternWithComputedProperties = 1 << 8, // Object literal pattern with computed properties
|
||||
ClassOrInterface = Class | Interface
|
||||
}
|
||||
|
||||
// Object types (TypeFlags.ObjectType)
|
||||
export interface ObjectType extends Type {
|
||||
isObjectLiteralPatternWithComputedProperties?: boolean;
|
||||
objectFlags: ObjectFlags;
|
||||
}
|
||||
|
||||
// Class and interface types (TypeFlags.Class and TypeFlags.Interface)
|
||||
@@ -2743,6 +2758,8 @@ namespace ts {
|
||||
|
||||
export interface IntersectionType extends UnionOrIntersectionType { }
|
||||
|
||||
export type StructuredType = ObjectType | UnionType | IntersectionType;
|
||||
|
||||
/* @internal */
|
||||
// An instantiated anonymous type has a target and a mapper
|
||||
export interface AnonymousType extends ObjectType {
|
||||
@@ -2750,6 +2767,11 @@ namespace ts {
|
||||
mapper?: TypeMapper; // Instantiation mapper
|
||||
}
|
||||
|
||||
export interface EvolvingArrayType extends ObjectType {
|
||||
elementType: Type; // Element expressions of evolving array type
|
||||
finalArrayType?: Type; // Final array type of evolving array type
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
// Resolved object, union, or intersection type
|
||||
export interface ResolvedType extends ObjectType, UnionOrIntersectionType {
|
||||
@@ -2917,11 +2939,7 @@ namespace ts {
|
||||
NodeJs = 2
|
||||
}
|
||||
|
||||
export type RootPaths = string[];
|
||||
export type PathSubstitutions = MapLike<string[]>;
|
||||
export type TsConfigOnlyOptions = RootPaths | PathSubstitutions;
|
||||
|
||||
export type CompilerOptionsValue = string | number | boolean | (string | number)[] | TsConfigOnlyOptions;
|
||||
export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike<string[]>;
|
||||
|
||||
export interface CompilerOptions {
|
||||
allowJs?: boolean;
|
||||
@@ -2929,6 +2947,7 @@ namespace ts {
|
||||
allowSyntheticDefaultImports?: boolean;
|
||||
allowUnreachableCode?: boolean;
|
||||
allowUnusedLabels?: boolean;
|
||||
alwaysStrict?: boolean;
|
||||
baseUrl?: string;
|
||||
charset?: string;
|
||||
/* @internal */ configFilePath?: string;
|
||||
@@ -2973,14 +2992,14 @@ namespace ts {
|
||||
out?: string;
|
||||
outDir?: string;
|
||||
outFile?: string;
|
||||
paths?: PathSubstitutions;
|
||||
paths?: MapLike<string[]>;
|
||||
preserveConstEnums?: boolean;
|
||||
project?: string;
|
||||
/* @internal */ pretty?: DiagnosticStyle;
|
||||
reactNamespace?: string;
|
||||
removeComments?: boolean;
|
||||
rootDir?: string;
|
||||
rootDirs?: RootPaths;
|
||||
rootDirs?: string[];
|
||||
skipLibCheck?: boolean;
|
||||
skipDefaultLibCheck?: boolean;
|
||||
sourceMap?: boolean;
|
||||
@@ -3023,8 +3042,7 @@ namespace ts {
|
||||
AMD = 2,
|
||||
UMD = 3,
|
||||
System = 4,
|
||||
ES6 = 5,
|
||||
ES2015 = ES6,
|
||||
ES2015 = 5,
|
||||
}
|
||||
|
||||
export const enum JsxEmit {
|
||||
@@ -3057,9 +3075,10 @@ namespace ts {
|
||||
export const enum ScriptTarget {
|
||||
ES3 = 0,
|
||||
ES5 = 1,
|
||||
ES6 = 2,
|
||||
ES2015 = ES6,
|
||||
Latest = ES6,
|
||||
ES2015 = 2,
|
||||
ES2016 = 3,
|
||||
ES2017 = 4,
|
||||
Latest = ES2017,
|
||||
}
|
||||
|
||||
export const enum LanguageVariant {
|
||||
@@ -3345,29 +3364,31 @@ namespace ts {
|
||||
ContainsTypeScript = 1 << 1,
|
||||
Jsx = 1 << 2,
|
||||
ContainsJsx = 1 << 3,
|
||||
ES7 = 1 << 4,
|
||||
ContainsES7 = 1 << 5,
|
||||
ES6 = 1 << 6,
|
||||
ContainsES6 = 1 << 7,
|
||||
DestructuringAssignment = 1 << 8,
|
||||
Generator = 1 << 9,
|
||||
ContainsGenerator = 1 << 10,
|
||||
ES2017 = 1 << 4,
|
||||
ContainsES2017 = 1 << 5,
|
||||
ES2016 = 1 << 6,
|
||||
ContainsES2016 = 1 << 7,
|
||||
ES2015 = 1 << 8,
|
||||
ContainsES2015 = 1 << 9,
|
||||
DestructuringAssignment = 1 << 10,
|
||||
Generator = 1 << 11,
|
||||
ContainsGenerator = 1 << 12,
|
||||
|
||||
// Markers
|
||||
// - Flags used to indicate that a subtree contains a specific transformation.
|
||||
ContainsDecorators = 1 << 11,
|
||||
ContainsPropertyInitializer = 1 << 12,
|
||||
ContainsLexicalThis = 1 << 13,
|
||||
ContainsCapturedLexicalThis = 1 << 14,
|
||||
ContainsLexicalThisInComputedPropertyName = 1 << 15,
|
||||
ContainsDefaultValueAssignments = 1 << 16,
|
||||
ContainsParameterPropertyAssignments = 1 << 17,
|
||||
ContainsSpreadElementExpression = 1 << 18,
|
||||
ContainsComputedPropertyName = 1 << 19,
|
||||
ContainsBlockScopedBinding = 1 << 20,
|
||||
ContainsBindingPattern = 1 << 21,
|
||||
ContainsYield = 1 << 22,
|
||||
ContainsHoistedDeclarationOrCompletion = 1 << 23,
|
||||
ContainsDecorators = 1 << 13,
|
||||
ContainsPropertyInitializer = 1 << 14,
|
||||
ContainsLexicalThis = 1 << 15,
|
||||
ContainsCapturedLexicalThis = 1 << 16,
|
||||
ContainsLexicalThisInComputedPropertyName = 1 << 17,
|
||||
ContainsDefaultValueAssignments = 1 << 18,
|
||||
ContainsParameterPropertyAssignments = 1 << 19,
|
||||
ContainsSpreadElementExpression = 1 << 20,
|
||||
ContainsComputedPropertyName = 1 << 21,
|
||||
ContainsBlockScopedBinding = 1 << 22,
|
||||
ContainsBindingPattern = 1 << 23,
|
||||
ContainsYield = 1 << 24,
|
||||
ContainsHoistedDeclarationOrCompletion = 1 << 25,
|
||||
|
||||
HasComputedFlags = 1 << 29, // Transform flags have been computed.
|
||||
|
||||
@@ -3375,14 +3396,15 @@ namespace ts {
|
||||
// - Bitmasks that are used to assert facts about the syntax of a node and its subtree.
|
||||
AssertTypeScript = TypeScript | ContainsTypeScript,
|
||||
AssertJsx = Jsx | ContainsJsx,
|
||||
AssertES7 = ES7 | ContainsES7,
|
||||
AssertES6 = ES6 | ContainsES6,
|
||||
AssertES2017 = ES2017 | ContainsES2017,
|
||||
AssertES2016 = ES2016 | ContainsES2016,
|
||||
AssertES2015 = ES2015 | ContainsES2015,
|
||||
AssertGenerator = Generator | ContainsGenerator,
|
||||
|
||||
// Scope Exclusions
|
||||
// - Bitmasks that exclude flags from propagating out of a specific context
|
||||
// into the subtree flags of their container.
|
||||
NodeExcludes = TypeScript | Jsx | ES7 | ES6 | DestructuringAssignment | Generator | HasComputedFlags,
|
||||
NodeExcludes = TypeScript | Jsx | ES2017 | ES2016 | ES2015 | DestructuringAssignment | Generator | HasComputedFlags,
|
||||
ArrowFunctionExcludes = NodeExcludes | ContainsDecorators | ContainsDefaultValueAssignments | ContainsLexicalThis | ContainsParameterPropertyAssignments | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion,
|
||||
FunctionExcludes = NodeExcludes | ContainsDecorators | ContainsDefaultValueAssignments | ContainsCapturedLexicalThis | ContainsLexicalThis | ContainsParameterPropertyAssignments | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion,
|
||||
ConstructorExcludes = NodeExcludes | ContainsDefaultValueAssignments | ContainsLexicalThis | ContainsCapturedLexicalThis | ContainsBlockScopedBinding | ContainsYield | ContainsHoistedDeclarationOrCompletion,
|
||||
@@ -3398,7 +3420,7 @@ namespace ts {
|
||||
// Masks
|
||||
// - Additional bitmasks
|
||||
TypeScriptClassSyntaxMask = ContainsParameterPropertyAssignments | ContainsPropertyInitializer | ContainsDecorators,
|
||||
ES6FunctionSyntaxMask = ContainsCapturedLexicalThis | ContainsDefaultValueAssignments,
|
||||
ES2015FunctionSyntaxMask = ContainsCapturedLexicalThis | ContainsDefaultValueAssignments,
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
|
||||
+48
-35
@@ -63,11 +63,11 @@ namespace ts {
|
||||
// Completely ignore indentation for string writers. And map newlines to
|
||||
// a single space.
|
||||
writeLine: () => str += " ",
|
||||
increaseIndent: () => { },
|
||||
decreaseIndent: () => { },
|
||||
increaseIndent: noop,
|
||||
decreaseIndent: noop,
|
||||
clear: () => str = "",
|
||||
trackSymbol: () => { },
|
||||
reportInaccessibleThisError: () => { }
|
||||
trackSymbol: noop,
|
||||
reportInaccessibleThisError: noop
|
||||
};
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ namespace ts {
|
||||
export function getLiteralText(node: LiteralLikeNode, sourceFile: SourceFile, languageVersion: ScriptTarget) {
|
||||
// Any template literal or string literal with an extended escape
|
||||
// (e.g. "\u{0067}") will need to be downleveled as a escaped string literal.
|
||||
if (languageVersion < ScriptTarget.ES6 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) {
|
||||
if (languageVersion < ScriptTarget.ES2015 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) {
|
||||
return getQuotedEscapedLiteralText('"', node.text, '"');
|
||||
}
|
||||
|
||||
@@ -345,7 +345,7 @@ namespace ts {
|
||||
// the node's parent reference, then simply get the text as it was originally written.
|
||||
if (!nodeIsSynthesized(node) && node.parent) {
|
||||
const text = getSourceTextOfNodeFromSourceFile(sourceFile, node);
|
||||
if (languageVersion < ScriptTarget.ES6 && isBinaryOrOctalIntegerLiteral(node, text)) {
|
||||
if (languageVersion < ScriptTarget.ES2015 && isBinaryOrOctalIntegerLiteral(node, text)) {
|
||||
return node.text;
|
||||
}
|
||||
return text;
|
||||
@@ -406,7 +406,12 @@ namespace ts {
|
||||
|
||||
export function isBlockOrCatchScoped(declaration: Declaration) {
|
||||
return (getCombinedNodeFlags(declaration) & NodeFlags.BlockScoped) !== 0 ||
|
||||
isCatchClauseVariableDeclaration(declaration);
|
||||
isCatchClauseVariableDeclarationOrBindingElement(declaration);
|
||||
}
|
||||
|
||||
export function isCatchClauseVariableDeclarationOrBindingElement(declaration: Declaration) {
|
||||
const node = getRootDeclaration(declaration);
|
||||
return node.kind === SyntaxKind.VariableDeclaration && node.parent.kind === SyntaxKind.CatchClause;
|
||||
}
|
||||
|
||||
export function isAmbientModule(node: Node): boolean {
|
||||
@@ -489,13 +494,6 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function isCatchClauseVariableDeclaration(declaration: Declaration) {
|
||||
return declaration &&
|
||||
declaration.kind === SyntaxKind.VariableDeclaration &&
|
||||
declaration.parent &&
|
||||
declaration.parent.kind === SyntaxKind.CatchClause;
|
||||
}
|
||||
|
||||
// Return display name of an identifier
|
||||
// Computed property names will just be emitted as "[<expr>]", where <expr> is the source
|
||||
// text of the expression in the computed property.
|
||||
@@ -503,7 +501,7 @@ namespace ts {
|
||||
return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name);
|
||||
}
|
||||
|
||||
export function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): Diagnostic {
|
||||
export function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number): Diagnostic {
|
||||
const sourceFile = getSourceFileOfNode(node);
|
||||
const span = getErrorSpanForNode(sourceFile, node);
|
||||
return createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2);
|
||||
@@ -895,6 +893,12 @@ namespace ts {
|
||||
return node && node.kind === SyntaxKind.MethodDeclaration && node.parent.kind === SyntaxKind.ObjectLiteralExpression;
|
||||
}
|
||||
|
||||
export function isObjectLiteralOrClassExpressionMethod(node: Node): node is MethodDeclaration {
|
||||
return node.kind === SyntaxKind.MethodDeclaration &&
|
||||
(node.parent.kind === SyntaxKind.ObjectLiteralExpression ||
|
||||
node.parent.kind === SyntaxKind.ClassExpression);
|
||||
}
|
||||
|
||||
export function isIdentifierTypePredicate(predicate: TypePredicate): predicate is IdentifierTypePredicate {
|
||||
return predicate && predicate.kind === TypePredicateKind.Identifier;
|
||||
}
|
||||
@@ -1895,6 +1899,10 @@ namespace ts {
|
||||
return node.kind === SyntaxKind.Identifier && (<Identifier>node).text === "Symbol";
|
||||
}
|
||||
|
||||
export function isPushOrUnshiftIdentifier(node: Identifier) {
|
||||
return node.text === "push" || node.text === "unshift";
|
||||
}
|
||||
|
||||
export function isModifierKind(token: SyntaxKind): boolean {
|
||||
switch (token) {
|
||||
case SyntaxKind.AbstractKeyword:
|
||||
@@ -2556,7 +2564,7 @@ namespace ts {
|
||||
const options = host.getCompilerOptions();
|
||||
// Emit on each source file
|
||||
if (options.outFile || options.out) {
|
||||
onBundledEmit(host, sourceFiles);
|
||||
onBundledEmit(sourceFiles);
|
||||
}
|
||||
else {
|
||||
for (const sourceFile of sourceFiles) {
|
||||
@@ -2589,7 +2597,7 @@ namespace ts {
|
||||
action(jsFilePath, sourceMapFilePath, declarationFilePath, [sourceFile], /*isBundledEmit*/ false);
|
||||
}
|
||||
|
||||
function onBundledEmit(host: EmitHost, sourceFiles: SourceFile[]) {
|
||||
function onBundledEmit(sourceFiles: SourceFile[]) {
|
||||
if (sourceFiles.length) {
|
||||
const jsFilePath = options.outFile || options.out;
|
||||
const sourceMapFilePath = getSourceMapFilePath(jsFilePath, options);
|
||||
@@ -3496,7 +3504,7 @@ namespace ts {
|
||||
return positionIsSynthesized(range.pos) ? -1 : skipTrivia(sourceFile.text, range.pos);
|
||||
}
|
||||
|
||||
export function collectExternalModuleInfo(sourceFile: SourceFile, resolver: EmitResolver) {
|
||||
export function collectExternalModuleInfo(sourceFile: SourceFile) {
|
||||
const externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[] = [];
|
||||
const exportSpecifiers = createMap<ExportSpecifier[]>();
|
||||
let exportEquals: ExportAssignment = undefined;
|
||||
@@ -3504,19 +3512,16 @@ namespace ts {
|
||||
for (const node of sourceFile.statements) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
if (!(<ImportDeclaration>node).importClause ||
|
||||
resolver.isReferencedAliasDeclaration((<ImportDeclaration>node).importClause, /*checkChildren*/ true)) {
|
||||
// import "mod"
|
||||
// import x from "mod" where x is referenced
|
||||
// import * as x from "mod" where x is referenced
|
||||
// import { x, y } from "mod" where at least one import is referenced
|
||||
externalImports.push(<ImportDeclaration>node);
|
||||
}
|
||||
// import "mod"
|
||||
// import x from "mod"
|
||||
// import * as x from "mod"
|
||||
// import { x, y } from "mod"
|
||||
externalImports.push(<ImportDeclaration>node);
|
||||
break;
|
||||
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
if ((<ImportEqualsDeclaration>node).moduleReference.kind === SyntaxKind.ExternalModuleReference && resolver.isReferencedAliasDeclaration(node)) {
|
||||
// import x = require("mod") where x is referenced
|
||||
if ((<ImportEqualsDeclaration>node).moduleReference.kind === SyntaxKind.ExternalModuleReference) {
|
||||
// import x = require("mod")
|
||||
externalImports.push(<ImportEqualsDeclaration>node);
|
||||
}
|
||||
break;
|
||||
@@ -3525,13 +3530,11 @@ namespace ts {
|
||||
if ((<ExportDeclaration>node).moduleSpecifier) {
|
||||
if (!(<ExportDeclaration>node).exportClause) {
|
||||
// export * from "mod"
|
||||
if (resolver.moduleExportsSomeValue((<ExportDeclaration>node).moduleSpecifier)) {
|
||||
externalImports.push(<ExportDeclaration>node);
|
||||
hasExportStarsToExportValues = true;
|
||||
}
|
||||
externalImports.push(<ExportDeclaration>node);
|
||||
hasExportStarsToExportValues = true;
|
||||
}
|
||||
else if (resolver.isValueAliasDeclaration(node)) {
|
||||
// export { x, y } from "mod" where at least one export is a value symbol
|
||||
else {
|
||||
// export { x, y } from "mod"
|
||||
externalImports.push(<ExportDeclaration>node);
|
||||
}
|
||||
}
|
||||
@@ -4161,7 +4164,17 @@ namespace ts {
|
||||
|
||||
namespace ts {
|
||||
export function getDefaultLibFileName(options: CompilerOptions): string {
|
||||
return options.target === ScriptTarget.ES6 ? "lib.es6.d.ts" : "lib.d.ts";
|
||||
switch (options.target) {
|
||||
case ScriptTarget.ES2017:
|
||||
return "lib.es2017.d.ts";
|
||||
case ScriptTarget.ES2016:
|
||||
return "lib.es2016.d.ts";
|
||||
case ScriptTarget.ES2015:
|
||||
return "lib.es6.d.ts";
|
||||
|
||||
default:
|
||||
return "lib.d.ts";
|
||||
}
|
||||
}
|
||||
|
||||
export function textSpanEnd(span: TextSpan) {
|
||||
|
||||
@@ -807,6 +807,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.FunctionExpression:
|
||||
return updateFunctionExpression(<FunctionExpression>node,
|
||||
visitNodes((<FunctionExpression>node).modifiers, visitor, isModifier),
|
||||
visitNode((<FunctionExpression>node).name, visitor, isPropertyName),
|
||||
visitNodes((<FunctionExpression>node).typeParameters, visitor, isTypeParameter),
|
||||
(context.startLexicalEnvironment(), visitNodes((<FunctionExpression>node).parameters, visitor, isParameter)),
|
||||
@@ -1330,18 +1331,18 @@ namespace ts {
|
||||
export namespace Debug {
|
||||
export const failNotOptional = shouldAssert(AssertionLevel.Normal)
|
||||
? (message?: string) => assert(false, message || "Node not optional.")
|
||||
: (message?: string) => {};
|
||||
: noop;
|
||||
|
||||
export const failBadSyntaxKind = shouldAssert(AssertionLevel.Normal)
|
||||
? (node: Node, message?: string) => assert(false, message || "Unexpected node.", () => `Node ${formatSyntaxKind(node.kind)} was unexpected.`)
|
||||
: (node: Node, message?: string) => {};
|
||||
: noop;
|
||||
|
||||
export const assertNode = shouldAssert(AssertionLevel.Normal)
|
||||
? (node: Node, test: (node: Node) => boolean, message?: string) => assert(
|
||||
test === undefined || test(node),
|
||||
message || "Unexpected node.",
|
||||
() => `Node ${formatSyntaxKind(node.kind)} did not pass test '${getFunctionName(test)}'.`)
|
||||
: (node: Node, test: (node: Node) => boolean, message?: string) => {};
|
||||
: noop;
|
||||
|
||||
function getFunctionName(func: Function) {
|
||||
if (typeof func !== "function") {
|
||||
@@ -1357,4 +1358,4 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+100
-42
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -47,19 +47,6 @@ namespace FourSlash {
|
||||
ranges: Range[];
|
||||
}
|
||||
|
||||
interface MemberListData {
|
||||
result: {
|
||||
maybeInaccurate: boolean;
|
||||
isMemberCompletion: boolean;
|
||||
entries: {
|
||||
name: string;
|
||||
type: string;
|
||||
kind: string;
|
||||
kindModifiers: string;
|
||||
}[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface Marker {
|
||||
fileName: string;
|
||||
position: number;
|
||||
@@ -178,15 +165,9 @@ namespace FourSlash {
|
||||
// Return object may lack some functionalities for other purposes.
|
||||
function createScriptSnapShot(sourceText: string): ts.IScriptSnapshot {
|
||||
return {
|
||||
getText: (start: number, end: number) => {
|
||||
return sourceText.substr(start, end - start);
|
||||
},
|
||||
getLength: () => {
|
||||
return sourceText.length;
|
||||
},
|
||||
getChangeRange: (oldSnapshot: ts.IScriptSnapshot) => {
|
||||
return <ts.TextChangeRange>undefined;
|
||||
}
|
||||
getText: (start: number, end: number) => sourceText.substr(start, end - start),
|
||||
getLength: () => sourceText.length,
|
||||
getChangeRange: () => undefined
|
||||
};
|
||||
}
|
||||
|
||||
@@ -419,15 +400,14 @@ namespace FourSlash {
|
||||
public verifyErrorExistsBetweenMarkers(startMarkerName: string, endMarkerName: string, negative: boolean) {
|
||||
const startMarker = this.getMarkerByName(startMarkerName);
|
||||
const endMarker = this.getMarkerByName(endMarkerName);
|
||||
const predicate = function(errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) {
|
||||
return ((errorMinChar === startPos) && (errorLimChar === endPos)) ? true : false;
|
||||
};
|
||||
const predicate = (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) =>
|
||||
((errorMinChar === startPos) && (errorLimChar === endPos)) ? true : false;
|
||||
|
||||
const exists = this.anyErrorInRange(predicate, startMarker, endMarker);
|
||||
|
||||
if (exists !== negative) {
|
||||
this.printErrorLog(negative, this.getAllDiagnostics());
|
||||
throw new Error("Failure between markers: " + startMarkerName + ", " + endMarkerName);
|
||||
throw new Error(`Failure between markers: '${startMarkerName}', '${endMarkerName}'`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -471,14 +451,12 @@ namespace FourSlash {
|
||||
let predicate: (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) => boolean;
|
||||
|
||||
if (after) {
|
||||
predicate = function(errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) {
|
||||
return ((errorMinChar >= startPos) && (errorLimChar >= startPos)) ? true : false;
|
||||
};
|
||||
predicate = (errorMinChar: number, errorLimChar: number, startPos: number) =>
|
||||
((errorMinChar >= startPos) && (errorLimChar >= startPos)) ? true : false;
|
||||
}
|
||||
else {
|
||||
predicate = function(errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) {
|
||||
return ((errorMinChar <= startPos) && (errorLimChar <= startPos)) ? true : false;
|
||||
};
|
||||
predicate = (errorMinChar: number, errorLimChar: number, startPos: number) =>
|
||||
((errorMinChar <= startPos) && (errorLimChar <= startPos)) ? true : false;
|
||||
}
|
||||
|
||||
const exists = this.anyErrorInRange(predicate, marker);
|
||||
@@ -742,7 +720,6 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public verifyCompletionListAllowsNewIdentifier(negative: boolean) {
|
||||
const completions = this.getCompletionListAtCaret();
|
||||
|
||||
@@ -1180,7 +1157,7 @@ namespace FourSlash {
|
||||
|
||||
private alignmentForExtraInfo = 50;
|
||||
|
||||
private spanInfoToString(pos: number, spanInfo: ts.TextSpan, prefixString: string) {
|
||||
private spanInfoToString(spanInfo: ts.TextSpan, prefixString: string) {
|
||||
let resultString = "SpanInfo: " + JSON.stringify(spanInfo);
|
||||
if (spanInfo) {
|
||||
const spanString = this.activeFile.content.substr(spanInfo.start, spanInfo.length);
|
||||
@@ -1231,7 +1208,7 @@ namespace FourSlash {
|
||||
startColumn = 0;
|
||||
length = 0;
|
||||
}
|
||||
const spanInfo = this.spanInfoToString(pos, getSpanAtPos(pos), prefixString);
|
||||
const spanInfo = this.spanInfoToString(getSpanAtPos(pos), prefixString);
|
||||
if (previousSpanInfo && previousSpanInfo !== spanInfo) {
|
||||
addSpanInfoString();
|
||||
previousSpanInfo = spanInfo;
|
||||
@@ -1301,10 +1278,10 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
emitOutput.outputFiles.forEach((outputFile, idx, array) => {
|
||||
for (const outputFile of emitOutput.outputFiles) {
|
||||
const fileName = "FileName : " + outputFile.name + Harness.IO.newLine();
|
||||
resultString = resultString + fileName + outputFile.text;
|
||||
});
|
||||
}
|
||||
resultString += Harness.IO.newLine();
|
||||
});
|
||||
|
||||
@@ -1329,7 +1306,7 @@ namespace FourSlash {
|
||||
}
|
||||
|
||||
public printBreakpointLocation(pos: number) {
|
||||
Harness.IO.log("\n**Pos: " + pos + " " + this.spanInfoToString(pos, this.getBreakpointStatementLocation(pos), " "));
|
||||
Harness.IO.log("\n**Pos: " + pos + " " + this.spanInfoToString(this.getBreakpointStatementLocation(pos), " "));
|
||||
}
|
||||
|
||||
public printBreakpointAtCurrentLocation() {
|
||||
@@ -1611,7 +1588,7 @@ namespace FourSlash {
|
||||
if (isFormattingEdit) {
|
||||
const newContent = this.getFileContent(fileName);
|
||||
|
||||
if (newContent.replace(/\s/g, "") !== oldContent.replace(/\s/g, "")) {
|
||||
if (this.removeWhitespace(newContent) !== this.removeWhitespace(oldContent)) {
|
||||
this.raiseError("Formatting operation destroyed non-whitespace content");
|
||||
}
|
||||
}
|
||||
@@ -1677,6 +1654,10 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
private removeWhitespace(text: string): string {
|
||||
return text.replace(/\s/g, "");
|
||||
}
|
||||
|
||||
public goToBOF() {
|
||||
this.goToPosition(0);
|
||||
}
|
||||
@@ -1827,7 +1808,7 @@ namespace FourSlash {
|
||||
return result;
|
||||
}
|
||||
|
||||
private rangeText({fileName, start, end}: Range, more = false): string {
|
||||
private rangeText({fileName, start, end}: Range): string {
|
||||
return this.getFileContent(fileName).slice(start, end);
|
||||
}
|
||||
|
||||
@@ -1922,7 +1903,7 @@ namespace FourSlash {
|
||||
}
|
||||
|
||||
public printNameOrDottedNameSpans(pos: number) {
|
||||
Harness.IO.log(this.spanInfoToString(pos, this.getNameOrDottedNameSpan(pos), "**"));
|
||||
Harness.IO.log(this.spanInfoToString(this.getNameOrDottedNameSpan(pos), "**"));
|
||||
}
|
||||
|
||||
private verifyClassifications(expected: { classificationType: string; text: string; textSpan?: TextSpan }[], actual: ts.ClassifiedSpan[]) {
|
||||
@@ -2038,6 +2019,47 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
private getCodeFixes(errorCode?: number) {
|
||||
const fileName = this.activeFile.fileName;
|
||||
const diagnostics = this.getDiagnostics(fileName);
|
||||
|
||||
if (diagnostics.length === 0) {
|
||||
this.raiseError("Errors expected.");
|
||||
}
|
||||
|
||||
if (diagnostics.length > 1 && errorCode !== undefined) {
|
||||
this.raiseError("When there's more than one error, you must specify the errror to fix.");
|
||||
}
|
||||
|
||||
const diagnostic = !errorCode ? diagnostics[0] : ts.find(diagnostics, d => d.code == errorCode);
|
||||
|
||||
return this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.length, [diagnostic.code]);
|
||||
}
|
||||
|
||||
public verifyCodeFixAtPosition(expectedText: string, errorCode?: number) {
|
||||
const ranges = this.getRanges();
|
||||
if (ranges.length == 0) {
|
||||
this.raiseError("At least one range should be specified in the testfile.");
|
||||
}
|
||||
|
||||
const actual = this.getCodeFixes(errorCode);
|
||||
|
||||
if (!actual || actual.length == 0) {
|
||||
this.raiseError("No codefixes returned.");
|
||||
}
|
||||
|
||||
if (actual.length > 1) {
|
||||
this.raiseError("More than 1 codefix returned.");
|
||||
}
|
||||
|
||||
this.applyEdits(actual[0].changes[0].fileName, actual[0].changes[0].textChanges, /*isFormattingEdit*/ false);
|
||||
const actualText = this.rangeText(ranges[0]);
|
||||
|
||||
if (this.removeWhitespace(actualText) !== this.removeWhitespace(expectedText)) {
|
||||
this.raiseError(`Actual text doesn't match expected text. Actual: '${actualText}' Expected: '${expectedText}'`);
|
||||
}
|
||||
}
|
||||
|
||||
public verifyDocCommentTemplate(expected?: ts.TextInsertion) {
|
||||
const name = "verifyDocCommentTemplate";
|
||||
const actual = this.languageService.getDocCommentTemplateAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
@@ -2211,6 +2233,18 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
public verifyNavigationTree(json: any) {
|
||||
const tree = this.languageService.getNavigationTree(this.activeFile.fileName);
|
||||
if (JSON.stringify(tree, replacer) !== JSON.stringify(json)) {
|
||||
this.raiseError(`verifyNavigationTree failed - expected: ${stringify(json)}, got: ${stringify(tree, replacer)}`);
|
||||
}
|
||||
|
||||
function replacer(key: string, value: any) {
|
||||
// Don't check "spans", and omit falsy values.
|
||||
return key === "spans" ? undefined : (value || undefined);
|
||||
}
|
||||
}
|
||||
|
||||
public printNavigationItems(searchValue: string) {
|
||||
const items = this.languageService.getNavigateToItems(searchValue);
|
||||
const length = items && items.length;
|
||||
@@ -2309,6 +2343,18 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
public verifyCodeFixAvailable(negative: boolean, errorCode?: number) {
|
||||
const fixes = this.getCodeFixes(errorCode);
|
||||
|
||||
if (negative && fixes && fixes.length > 0) {
|
||||
this.raiseError(`verifyCodeFixAvailable failed - expected no fixes, actual: ${fixes.length}`);
|
||||
}
|
||||
|
||||
if (!negative && (fixes === undefined || fixes.length === 0)) {
|
||||
this.raiseError(`verifyCodeFixAvailable failed - expected code fixes, actual: 0`);
|
||||
}
|
||||
}
|
||||
|
||||
// Get the text of the entire line the caret is currently at
|
||||
private getCurrentLineContent() {
|
||||
const text = this.getFileContent(this.activeFile.fileName);
|
||||
@@ -3096,6 +3142,10 @@ namespace FourSlashInterface {
|
||||
public isValidBraceCompletionAtPosition(openingBrace: string) {
|
||||
this.state.verifyBraceCompletionAtPosition(this.negative, openingBrace);
|
||||
}
|
||||
|
||||
public codeFixAvailable(errorCode?: number) {
|
||||
this.state.verifyCodeFixAvailable(this.negative, errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
export class Verify extends VerifyNegatable {
|
||||
@@ -3275,10 +3325,18 @@ namespace FourSlashInterface {
|
||||
this.DocCommentTemplate(/*expectedText*/ undefined, /*expectedOffset*/ undefined, /*empty*/ true);
|
||||
}
|
||||
|
||||
public codeFixAtPosition(expectedText: string, errorCode?: number): void {
|
||||
this.state.verifyCodeFixAtPosition(expectedText, errorCode);
|
||||
}
|
||||
|
||||
public navigationBar(json: any) {
|
||||
this.state.verifyNavigationBar(json);
|
||||
}
|
||||
|
||||
public navigationTree(json: any) {
|
||||
this.state.verifyNavigationTree(json);
|
||||
}
|
||||
|
||||
public navigationItemsListCount(count: number, searchValue: string, matchKind?: string, fileName?: string) {
|
||||
this.state.verifyNavigationItemsCount(count, searchValue, matchKind, fileName);
|
||||
}
|
||||
|
||||
+24
-17
@@ -220,9 +220,7 @@ namespace Utils {
|
||||
}
|
||||
|
||||
export function sourceFileToJSON(file: ts.Node): string {
|
||||
return JSON.stringify(file, (k, v) => {
|
||||
return isNodeOrArray(v) ? serializeNode(v) : v;
|
||||
}, " ");
|
||||
return JSON.stringify(file, (_, v) => isNodeOrArray(v) ? serializeNode(v) : v, " ");
|
||||
|
||||
function getKindName(k: number | string): string {
|
||||
if (typeof k === "string") {
|
||||
@@ -692,7 +690,7 @@ namespace Harness {
|
||||
export const getCurrentDirectory = () => "";
|
||||
export const args = () => <string[]>[];
|
||||
export const getExecutingFilePath = () => "";
|
||||
export const exit = (exitCode: number) => { };
|
||||
export const exit = ts.noop;
|
||||
export const getDirectories = () => <string[]>[];
|
||||
|
||||
export let log = (s: string) => console.log(s);
|
||||
@@ -742,7 +740,7 @@ namespace Harness {
|
||||
}
|
||||
}
|
||||
|
||||
export function createDirectory(path: string) {
|
||||
export function createDirectory() {
|
||||
// Do nothing (?)
|
||||
}
|
||||
|
||||
@@ -750,7 +748,7 @@ namespace Harness {
|
||||
Http.writeToServerSync(serverRoot + path, "DELETE");
|
||||
}
|
||||
|
||||
export function directoryExists(path: string): boolean {
|
||||
export function directoryExists(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -792,7 +790,7 @@ namespace Harness {
|
||||
return response.status === 200;
|
||||
}
|
||||
|
||||
export function _listFilesImpl(path: string, spec?: RegExp, options?: any) {
|
||||
export let listFiles = Utils.memoize((path: string, spec?: RegExp): string[] => {
|
||||
const response = Http.getFileFromServerSync(serverRoot + path);
|
||||
if (response.status === 200) {
|
||||
const results = response.responseText.split(",");
|
||||
@@ -806,8 +804,7 @@ namespace Harness {
|
||||
else {
|
||||
return [""];
|
||||
}
|
||||
};
|
||||
export let listFiles = Utils.memoize(_listFilesImpl);
|
||||
});
|
||||
|
||||
export function readFile(file: string) {
|
||||
const response = Http.getFileFromServerSync(serverRoot + file);
|
||||
@@ -941,7 +938,17 @@ namespace Harness {
|
||||
}
|
||||
|
||||
export function getDefaultLibFileName(options: ts.CompilerOptions): string {
|
||||
return options.target === ts.ScriptTarget.ES6 ? es2015DefaultLibFileName : defaultLibFileName;
|
||||
switch (options.target) {
|
||||
case ts.ScriptTarget.ES2017:
|
||||
return "lib.es2017.d.ts";
|
||||
case ts.ScriptTarget.ES2016:
|
||||
return "lib.es2016.d.ts";
|
||||
case ts.ScriptTarget.ES2015:
|
||||
return es2015DefaultLibFileName;
|
||||
|
||||
default:
|
||||
return defaultLibFileName;
|
||||
}
|
||||
}
|
||||
|
||||
// Cache these between executions so we don't have to re-parse them for every test
|
||||
@@ -981,7 +988,7 @@ namespace Harness {
|
||||
}
|
||||
}
|
||||
|
||||
function getSourceFile(fileName: string, languageVersion: ts.ScriptTarget) {
|
||||
function getSourceFile(fileName: string) {
|
||||
fileName = ts.normalizePath(fileName);
|
||||
const path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
|
||||
if (fileMap.contains(path)) {
|
||||
@@ -1041,7 +1048,7 @@ namespace Harness {
|
||||
getDirectories: d => {
|
||||
const path = ts.toPath(d, currentDirectory, getCanonicalFileName);
|
||||
const result: string[] = [];
|
||||
fileMap.forEachValue((key, value) => {
|
||||
fileMap.forEachValue(key => {
|
||||
if (key.indexOf(path) === 0 && key.lastIndexOf("/") > path.length) {
|
||||
let dirName = key.substr(path.length, key.indexOf("/", path.length + 1) - path.length);
|
||||
if (dirName[0] === "/") {
|
||||
@@ -1634,7 +1641,7 @@ namespace Harness {
|
||||
|
||||
export function collateOutputs(outputFiles: Harness.Compiler.GeneratedFile[]): string {
|
||||
// Collect, test, and sort the fileNames
|
||||
outputFiles.sort((a, b) => cleanName(a.fileName).localeCompare(cleanName(b.fileName)));
|
||||
outputFiles.sort((a, b) => ts.compareStrings(cleanName(a.fileName), cleanName(b.fileName)));
|
||||
|
||||
// Emit them
|
||||
let result = "";
|
||||
@@ -1659,9 +1666,9 @@ namespace Harness {
|
||||
}
|
||||
|
||||
// This does not need to exist strictly speaking, but many tests will need to be updated if it's removed
|
||||
export function compileString(code: string, unitName: string, callback: (result: CompilerResult) => void) {
|
||||
export function compileString(_code: string, _unitName: string, _callback: (result: CompilerResult) => void) {
|
||||
// NEWTODO: Re-implement 'compileString'
|
||||
throw new Error("compileString NYI");
|
||||
return ts.notImplemented();
|
||||
}
|
||||
|
||||
export interface GeneratedFile {
|
||||
@@ -1843,8 +1850,8 @@ namespace Harness {
|
||||
// unit tests always list files explicitly
|
||||
const parseConfigHost: ts.ParseConfigHost = {
|
||||
useCaseSensitiveFileNames: false,
|
||||
readDirectory: (name) => [],
|
||||
fileExists: (name) => true,
|
||||
readDirectory: () => [],
|
||||
fileExists: () => true,
|
||||
readFile: (name) => ts.forEach(testUnitData, data => data.name.toLowerCase() === name.toLowerCase() ? data.content : undefined)
|
||||
};
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace Harness.LanguageService {
|
||||
throw new Error("No script with name '" + fileName + "'");
|
||||
}
|
||||
|
||||
public openFile(fileName: string, content?: string, scriptKindName?: string): void {
|
||||
public openFile(_fileName: string, _content?: string, _scriptKindName?: string): void {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,7 +198,7 @@ namespace Harness.LanguageService {
|
||||
const script = this.getScriptInfo(fileName);
|
||||
return script ? new ScriptSnapshot(script) : undefined;
|
||||
}
|
||||
getScriptKind(fileName: string): ts.ScriptKind { return ts.ScriptKind.Unknown; }
|
||||
getScriptKind(): ts.ScriptKind { return ts.ScriptKind.Unknown; }
|
||||
getScriptVersion(fileName: string): string {
|
||||
const script = this.getScriptInfo(fileName);
|
||||
return script ? script.version.toString() : undefined;
|
||||
@@ -214,7 +214,7 @@ namespace Harness.LanguageService {
|
||||
this.getCurrentDirectory(),
|
||||
(p) => this.virtualFileSystem.getAccessibleFileSystemEntries(p));
|
||||
}
|
||||
readFile(path: string, encoding?: string): string {
|
||||
readFile(path: string): string {
|
||||
const snapshot = this.getScriptSnapshot(path);
|
||||
return snapshot.getText(0, snapshot.getLength());
|
||||
}
|
||||
@@ -223,9 +223,9 @@ namespace Harness.LanguageService {
|
||||
}
|
||||
|
||||
|
||||
log(s: string): void { }
|
||||
trace(s: string): void { }
|
||||
error(s: string): void { }
|
||||
log(_: string): void { }
|
||||
trace(_: string): void { }
|
||||
error(_: string): void { }
|
||||
}
|
||||
|
||||
export class NativeLanguageServiceAdapter implements LanguageServiceAdapter {
|
||||
@@ -308,19 +308,15 @@ namespace Harness.LanguageService {
|
||||
const nativeScriptSnapshot = this.nativeHost.getScriptSnapshot(fileName);
|
||||
return nativeScriptSnapshot && new ScriptSnapshotProxy(nativeScriptSnapshot);
|
||||
}
|
||||
getScriptKind(fileName: string): ts.ScriptKind { return this.nativeHost.getScriptKind(fileName); }
|
||||
getScriptKind(): ts.ScriptKind { return this.nativeHost.getScriptKind(); }
|
||||
getScriptVersion(fileName: string): string { return this.nativeHost.getScriptVersion(fileName); }
|
||||
getLocalizedDiagnosticMessages(): string { return JSON.stringify({}); }
|
||||
|
||||
readDirectory(rootDir: string, extension: string): string {
|
||||
throw new Error("NYI");
|
||||
}
|
||||
readDirectoryNames(path: string): string {
|
||||
throw new Error("Not implemented.");
|
||||
}
|
||||
readFileNames(path: string): string {
|
||||
throw new Error("Not implemented.");
|
||||
readDirectory(_rootDir: string, _extension: string): string {
|
||||
return ts.notImplemented();
|
||||
}
|
||||
readDirectoryNames = ts.notImplemented;
|
||||
readFileNames = ts.notImplemented;
|
||||
fileExists(fileName: string) { return this.getScriptInfo(fileName) !== undefined; }
|
||||
readFile(fileName: string) {
|
||||
const snapshot = this.nativeHost.getScriptSnapshot(fileName);
|
||||
@@ -329,7 +325,7 @@ namespace Harness.LanguageService {
|
||||
log(s: string): void { this.nativeHost.log(s); }
|
||||
trace(s: string): void { this.nativeHost.trace(s); }
|
||||
error(s: string): void { this.nativeHost.error(s); }
|
||||
directoryExists(directoryName: string): boolean {
|
||||
directoryExists(): boolean {
|
||||
// for tests pessimistically assume that directory always exists
|
||||
return true;
|
||||
}
|
||||
@@ -338,8 +334,8 @@ namespace Harness.LanguageService {
|
||||
class ClassifierShimProxy implements ts.Classifier {
|
||||
constructor(private shim: ts.ClassifierShim) {
|
||||
}
|
||||
getEncodedLexicalClassifications(text: string, lexState: ts.EndOfLineState, classifyKeywordsInGenerics?: boolean): ts.Classifications {
|
||||
throw new Error("NYI");
|
||||
getEncodedLexicalClassifications(_text: string, _lexState: ts.EndOfLineState, _classifyKeywordsInGenerics?: boolean): ts.Classifications {
|
||||
return ts.notImplemented();
|
||||
}
|
||||
getClassificationsForLine(text: string, lexState: ts.EndOfLineState, classifyKeywordsInGenerics?: boolean): ts.ClassificationResult {
|
||||
const result = this.shim.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics).split("\n");
|
||||
@@ -411,7 +407,7 @@ namespace Harness.LanguageService {
|
||||
getCompletionEntryDetails(fileName: string, position: number, entryName: string): ts.CompletionEntryDetails {
|
||||
return unwrapJSONCallResult(this.shim.getCompletionEntryDetails(fileName, position, entryName));
|
||||
}
|
||||
getCompletionEntrySymbol(fileName: string, position: number, entryName: string): ts.Symbol {
|
||||
getCompletionEntrySymbol(): ts.Symbol {
|
||||
throw new Error("getCompletionEntrySymbol not implemented across the shim layer.");
|
||||
}
|
||||
getQuickInfoAtPosition(fileName: string, position: number): ts.QuickInfo {
|
||||
@@ -459,6 +455,10 @@ namespace Harness.LanguageService {
|
||||
getNavigationBarItems(fileName: string): ts.NavigationBarItem[] {
|
||||
return unwrapJSONCallResult(this.shim.getNavigationBarItems(fileName));
|
||||
}
|
||||
getNavigationTree(fileName: string): ts.NavigationTree {
|
||||
return unwrapJSONCallResult(this.shim.getNavigationTree(fileName));
|
||||
}
|
||||
|
||||
getOutliningSpans(fileName: string): ts.OutliningSpan[] {
|
||||
return unwrapJSONCallResult(this.shim.getOutliningSpans(fileName));
|
||||
}
|
||||
@@ -486,16 +486,19 @@ namespace Harness.LanguageService {
|
||||
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean {
|
||||
return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPosition(fileName, position, openingBrace));
|
||||
}
|
||||
getCodeFixesAtPosition(): ts.CodeAction[] {
|
||||
throw new Error("Not supported on the shim.");
|
||||
}
|
||||
getEmitOutput(fileName: string): ts.EmitOutput {
|
||||
return unwrapJSONCallResult(this.shim.getEmitOutput(fileName));
|
||||
}
|
||||
getProgram(): ts.Program {
|
||||
throw new Error("Program can not be marshaled across the shim layer.");
|
||||
}
|
||||
getNonBoundSourceFile(fileName: string): ts.SourceFile {
|
||||
getNonBoundSourceFile(): ts.SourceFile {
|
||||
throw new Error("SourceFile can not be marshaled across the shim layer.");
|
||||
}
|
||||
getSourceFile(fileName: string): ts.SourceFile {
|
||||
getSourceFile(): ts.SourceFile {
|
||||
throw new Error("SourceFile can not be marshaled across the shim layer.");
|
||||
}
|
||||
dispose(): void { this.shim.dispose({}); }
|
||||
@@ -565,11 +568,11 @@ namespace Harness.LanguageService {
|
||||
super(cancellationToken, settings);
|
||||
}
|
||||
|
||||
onMessage(message: string): void {
|
||||
onMessage(): void {
|
||||
|
||||
}
|
||||
|
||||
writeMessage(message: string): void {
|
||||
writeMessage(): void {
|
||||
|
||||
}
|
||||
|
||||
@@ -597,11 +600,11 @@ namespace Harness.LanguageService {
|
||||
this.newLine = this.host.getNewLine();
|
||||
}
|
||||
|
||||
onMessage(message: string): void {
|
||||
onMessage(): void {
|
||||
|
||||
}
|
||||
|
||||
writeMessage(message: string): void {
|
||||
writeMessage(_message: string): void {
|
||||
}
|
||||
|
||||
write(message: string): void {
|
||||
@@ -617,7 +620,7 @@ namespace Harness.LanguageService {
|
||||
return snapshot && snapshot.getText(0, snapshot.getLength());
|
||||
}
|
||||
|
||||
writeFile(name: string, text: string, writeByteOrderMark: boolean): void {
|
||||
writeFile(): void {
|
||||
}
|
||||
|
||||
resolvePath(path: string): string {
|
||||
@@ -628,7 +631,7 @@ namespace Harness.LanguageService {
|
||||
return !!this.host.getScriptSnapshot(path);
|
||||
}
|
||||
|
||||
directoryExists(path: string): boolean {
|
||||
directoryExists(): boolean {
|
||||
// for tests assume that directory exists
|
||||
return true;
|
||||
}
|
||||
@@ -637,18 +640,18 @@ namespace Harness.LanguageService {
|
||||
return "";
|
||||
}
|
||||
|
||||
exit(exitCode: number): void {
|
||||
exit(): void {
|
||||
}
|
||||
|
||||
createDirectory(directoryName: string): void {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
createDirectory(_directoryName: string): void {
|
||||
return ts.notImplemented();
|
||||
}
|
||||
|
||||
getCurrentDirectory(): string {
|
||||
return this.host.getCurrentDirectory();
|
||||
}
|
||||
|
||||
getDirectories(path: string): string[] {
|
||||
getDirectories(): string[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -656,16 +659,16 @@ namespace Harness.LanguageService {
|
||||
return ts.sys.getEnvironmentVariable(name);
|
||||
}
|
||||
|
||||
readDirectory(path: string, extension?: string[], exclude?: string[], include?: string[]): string[] {
|
||||
throw new Error("Not implemented Yet.");
|
||||
readDirectory(_path: string, _extension?: string[], _exclude?: string[], _include?: string[]): string[] {
|
||||
return ts.notImplemented();
|
||||
}
|
||||
|
||||
watchFile(fileName: string, callback: (fileName: string) => void): ts.FileWatcher {
|
||||
return { close() { } };
|
||||
watchFile(): ts.FileWatcher {
|
||||
return { close: ts.noop };
|
||||
}
|
||||
|
||||
watchDirectory(path: string, callback: (path: string) => void, recursive?: boolean): ts.FileWatcher {
|
||||
return { close() { } };
|
||||
watchDirectory(): ts.FileWatcher {
|
||||
return { close: ts.noop };
|
||||
}
|
||||
|
||||
close(): void {
|
||||
@@ -710,7 +713,7 @@ namespace Harness.LanguageService {
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
|
||||
setImmediate(callback: (...args: any[]) => void, ms: number, ...args: any[]): any {
|
||||
setImmediate(callback: (...args: any[]) => void, _ms: number, ...args: any[]): any {
|
||||
return setImmediate(callback, args);
|
||||
}
|
||||
|
||||
@@ -753,6 +756,6 @@ namespace Harness.LanguageService {
|
||||
getHost() { return this.host; }
|
||||
getLanguageService(): ts.LanguageService { return this.client; }
|
||||
getClassifier(): ts.Classifier { throw new Error("getClassifier is not available using the server interface."); }
|
||||
getPreProcessedFileInfo(fileName: string, fileContents: string): ts.PreProcessedFileInfo { throw new Error("getPreProcessedFileInfo is not available using the server interface."); }
|
||||
getPreProcessedFileInfo(): ts.PreProcessedFileInfo { throw new Error("getPreProcessedFileInfo is not available using the server interface."); }
|
||||
}
|
||||
}
|
||||
|
||||
+15
-11
@@ -173,7 +173,7 @@ namespace Playback {
|
||||
path => callAndRecord(underlying.fileExists(path), recordLog.fileExists, { path }),
|
||||
memoize(path => {
|
||||
// If we read from the file, it must exist
|
||||
if (findFileByPath(wrapper, replayLog.filesRead, path, /*throwFileNotFoundError*/ false)) {
|
||||
if (findFileByPath(replayLog.filesRead, path, /*throwFileNotFoundError*/ false)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
@@ -217,7 +217,7 @@ namespace Playback {
|
||||
recordLog.filesRead.push(logEntry);
|
||||
return result;
|
||||
},
|
||||
memoize(path => findFileByPath(wrapper, replayLog.filesRead, path, /*throwFileNotFoundError*/ true).contents));
|
||||
memoize(path => findFileByPath(replayLog.filesRead, path, /*throwFileNotFoundError*/ true).contents));
|
||||
|
||||
wrapper.readDirectory = recordReplay(wrapper.readDirectory, underlying)(
|
||||
(path, extensions, exclude, include) => {
|
||||
@@ -226,7 +226,7 @@ namespace Playback {
|
||||
recordLog.directoriesRead.push(logEntry);
|
||||
return result;
|
||||
},
|
||||
(path, extensions, exclude) => {
|
||||
path => {
|
||||
// Because extensions is an array of all allowed extension, we will want to merge each of the replayLog.directoriesRead into one
|
||||
// if each of the directoriesRead has matched path with the given path (directory with same path but different extension will considered
|
||||
// different entry).
|
||||
@@ -244,7 +244,7 @@ namespace Playback {
|
||||
|
||||
wrapper.writeFile = recordReplay(wrapper.writeFile, underlying)(
|
||||
(path: string, contents: string) => callAndRecord(underlying.writeFile(path, contents), recordLog.filesWritten, { path, contents, bom: false }),
|
||||
(path: string, contents: string) => noOpReplay("writeFile"));
|
||||
() => noOpReplay("writeFile"));
|
||||
|
||||
wrapper.exit = (exitCode) => {
|
||||
if (recordLog !== undefined) {
|
||||
@@ -295,7 +295,7 @@ namespace Playback {
|
||||
return results[0].result;
|
||||
}
|
||||
|
||||
function findFileByPath(wrapper: { resolvePath(s: string): string }, logArray: IOLogFile[],
|
||||
function findFileByPath(logArray: IOLogFile[],
|
||||
expectedPath: string, throwFileNotFoundError: boolean): FileInformation {
|
||||
const normalizedName = ts.normalizePath(expectedPath).toLowerCase();
|
||||
// Try to find the result through normal fileName
|
||||
@@ -314,7 +314,7 @@ namespace Playback {
|
||||
}
|
||||
}
|
||||
|
||||
function noOpReplay(name: string) {
|
||||
function noOpReplay(_name: string) {
|
||||
// console.log("Swallowed write operation during replay: " + name);
|
||||
}
|
||||
|
||||
@@ -322,13 +322,17 @@ namespace Playback {
|
||||
const wrapper: PlaybackIO = <any>{};
|
||||
initWrapper(wrapper, underlying);
|
||||
|
||||
wrapper.directoryName = (path): string => { throw new Error("NotSupported"); };
|
||||
wrapper.createDirectory = (path): void => { throw new Error("NotSupported"); };
|
||||
wrapper.directoryExists = (path): boolean => { throw new Error("NotSupported"); };
|
||||
wrapper.deleteFile = (path): void => { throw new Error("NotSupported"); };
|
||||
wrapper.listFiles = (path, filter, options): string[] => { throw new Error("NotSupported"); };
|
||||
wrapper.directoryName = notSupported;
|
||||
wrapper.createDirectory = notSupported;
|
||||
wrapper.directoryExists = notSupported;
|
||||
wrapper.deleteFile = notSupported;
|
||||
wrapper.listFiles = notSupported;
|
||||
|
||||
return wrapper;
|
||||
|
||||
function notSupported(): never {
|
||||
throw new Error("NotSupported");
|
||||
}
|
||||
}
|
||||
|
||||
export function wrapSystem(underlying: ts.System): PlaybackSystem {
|
||||
|
||||
@@ -178,7 +178,7 @@ class ProjectRunner extends RunnerBase {
|
||||
function createCompilerHost(): ts.CompilerHost {
|
||||
return {
|
||||
getSourceFile,
|
||||
getDefaultLibFileName: options => Harness.Compiler.defaultLibFileName,
|
||||
getDefaultLibFileName: () => Harness.Compiler.defaultLibFileName,
|
||||
writeFile,
|
||||
getCurrentDirectory,
|
||||
getCanonicalFileName: Harness.Compiler.getCanonicalFileName,
|
||||
@@ -421,7 +421,7 @@ class ProjectRunner extends RunnerBase {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean) {
|
||||
function writeFile() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -222,5 +222,5 @@ else {
|
||||
}
|
||||
if (!runUnitTests) {
|
||||
// patch `describe` to skip unit tests
|
||||
describe = <any>(function () { });
|
||||
describe = ts.noop as any;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,10 @@
|
||||
"stripInternal": true,
|
||||
"types": [
|
||||
"node", "mocha", "chai"
|
||||
]
|
||||
],
|
||||
"target": "es5",
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true
|
||||
},
|
||||
"files": [
|
||||
"../compiler/core.ts",
|
||||
@@ -26,13 +29,15 @@
|
||||
"../compiler/visitor.ts",
|
||||
"../compiler/transformers/ts.ts",
|
||||
"../compiler/transformers/jsx.ts",
|
||||
"../compiler/transformers/es7.ts",
|
||||
"../compiler/transformers/es6.ts",
|
||||
"../compiler/transformers/es2017.ts",
|
||||
"../compiler/transformers/es2016.ts",
|
||||
"../compiler/transformers/es2015.ts",
|
||||
"../compiler/transformers/generators.ts",
|
||||
"../compiler/transformers/es5.ts",
|
||||
"../compiler/transformers/destructuring.ts",
|
||||
"../compiler/transformers/module/module.ts",
|
||||
"../compiler/transformers/module/system.ts",
|
||||
"../compiler/transformers/module/es6.ts",
|
||||
"../compiler/transformers/module/es2015.ts",
|
||||
"../compiler/transformer.ts",
|
||||
"../compiler/comments.ts",
|
||||
"../compiler/sourcemap.ts",
|
||||
|
||||
@@ -21,16 +21,15 @@ namespace ts {
|
||||
args: <string[]>[],
|
||||
newLine: "\r\n",
|
||||
useCaseSensitiveFileNames: false,
|
||||
write: (s: string) => {
|
||||
},
|
||||
readFile: (path: string, encoding?: string): string => {
|
||||
write: noop,
|
||||
readFile: (path: string): string => {
|
||||
return path in fileMap ? fileMap[path].content : undefined;
|
||||
},
|
||||
writeFile: (path: string, data: string, writeByteOrderMark?: boolean) => {
|
||||
throw new Error("NYI");
|
||||
writeFile: (_path: string, _data: string, _writeByteOrderMark?: boolean) => {
|
||||
return ts.notImplemented();
|
||||
},
|
||||
resolvePath: (path: string): string => {
|
||||
throw new Error("NYI");
|
||||
resolvePath: (_path: string): string => {
|
||||
return ts.notImplemented();
|
||||
},
|
||||
fileExists: (path: string): boolean => {
|
||||
return path in fileMap;
|
||||
@@ -38,31 +37,25 @@ namespace ts {
|
||||
directoryExists: (path: string): boolean => {
|
||||
return existingDirectories[path] || false;
|
||||
},
|
||||
createDirectory: (path: string) => {
|
||||
},
|
||||
createDirectory: noop,
|
||||
getExecutingFilePath: (): string => {
|
||||
return "";
|
||||
},
|
||||
getCurrentDirectory: (): string => {
|
||||
return "";
|
||||
},
|
||||
getDirectories: (path: string) => [],
|
||||
getEnvironmentVariable: (name: string) => "",
|
||||
readDirectory: (path: string, extension?: string[], exclude?: string[], include?: string[]): string[] => {
|
||||
throw new Error("NYI");
|
||||
},
|
||||
exit: (exitCode?: number) => {
|
||||
},
|
||||
watchFile: (path, callback) => {
|
||||
return {
|
||||
close: () => { }
|
||||
};
|
||||
},
|
||||
watchDirectory: (path, callback, recursive?) => {
|
||||
return {
|
||||
close: () => { }
|
||||
};
|
||||
getDirectories: () => [],
|
||||
getEnvironmentVariable: () => "",
|
||||
readDirectory: (_path: string, _extension?: string[], _exclude?: string[], _include?: string[]): string[] => {
|
||||
return ts.notImplemented();
|
||||
},
|
||||
exit: noop,
|
||||
watchFile: () => ({
|
||||
close: noop
|
||||
}),
|
||||
watchDirectory: () => ({
|
||||
close: noop
|
||||
}),
|
||||
setTimeout,
|
||||
clearTimeout,
|
||||
setImmediate,
|
||||
@@ -72,14 +65,14 @@ namespace ts {
|
||||
|
||||
function createProject(rootFile: string, serverHost: server.ServerHost): { project: server.Project, rootScriptInfo: server.ScriptInfo } {
|
||||
const logger: server.Logger = {
|
||||
close() { },
|
||||
close: noop,
|
||||
hasLevel: () => false,
|
||||
loggingEnabled: () => false,
|
||||
perftrc: (s: string) => { },
|
||||
info: (s: string) => { },
|
||||
startGroup: () => { },
|
||||
endGroup: () => { },
|
||||
msg: (s: string, type?: string) => { },
|
||||
perftrc: noop,
|
||||
info: noop,
|
||||
startGroup: noop,
|
||||
endGroup: noop,
|
||||
msg: noop,
|
||||
getLogFileName: (): string => undefined
|
||||
};
|
||||
|
||||
@@ -116,10 +109,7 @@ namespace ts {
|
||||
const originalFileExists = serverHost.fileExists;
|
||||
{
|
||||
// patch fileExists to make sure that disk is not touched
|
||||
serverHost.fileExists = (fileName): boolean => {
|
||||
assert.isTrue(false, "fileExists should not be called");
|
||||
return false;
|
||||
};
|
||||
serverHost.fileExists = notImplemented;
|
||||
|
||||
const newContent = `import {x} from "f1"
|
||||
var x: string = 1;`;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="..\harness.ts" />
|
||||
/// <reference path="..\harness.ts" />
|
||||
/// <reference path="..\..\compiler\commandLineParser.ts" />
|
||||
|
||||
namespace ts {
|
||||
@@ -60,7 +60,7 @@ namespace ts {
|
||||
assertParseResult(["--lib", "es5,invalidOption", "0.ts"],
|
||||
{
|
||||
errors: [{
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
|
||||
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace ts {
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
}, {
|
||||
messageText: "Argument for '--jsx' option must be: 'preserve', 'react'",
|
||||
messageText: "Argument for '--jsx' option must be: 'preserve', 'react'",
|
||||
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace ts {
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
}, {
|
||||
messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'",
|
||||
messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'",
|
||||
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace ts {
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
}, {
|
||||
messageText: "Argument for '--newLine' option must be: 'crlf', 'lf'",
|
||||
messageText: "Argument for '--newLine' option must be: 'crlf', 'lf'",
|
||||
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace ts {
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
}, {
|
||||
messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015'",
|
||||
messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017'",
|
||||
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace ts {
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
}, {
|
||||
messageText: "Argument for '--moduleResolution' option must be: 'node', 'classic'",
|
||||
messageText: "Argument for '--moduleResolution' option must be: 'node', 'classic'",
|
||||
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
|
||||
@@ -263,7 +263,7 @@ namespace ts {
|
||||
assertParseResult(["--lib", "es5,", "es7", "0.ts"],
|
||||
{
|
||||
errors: [{
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
|
||||
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
|
||||
@@ -283,7 +283,7 @@ namespace ts {
|
||||
assertParseResult(["--lib", "es5, ", "es7", "0.ts"],
|
||||
{
|
||||
errors: [{
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
|
||||
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
|
||||
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
|
||||
@@ -338,5 +338,38 @@ namespace ts {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("Parse explicit boolean flag value", () => {
|
||||
assertParseResult(["--strictNullChecks", "false", "0.ts"],
|
||||
{
|
||||
errors: [],
|
||||
fileNames: ["0.ts"],
|
||||
options: {
|
||||
strictNullChecks: false,
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("Parse non boolean argument after boolean flag", () => {
|
||||
assertParseResult(["--noImplicitAny", "t", "0.ts"],
|
||||
{
|
||||
errors: [],
|
||||
fileNames: ["t", "0.ts"],
|
||||
options: {
|
||||
noImplicitAny: true,
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("Parse implicit boolean flag value", () => {
|
||||
assertParseResult(["--strictNullChecks"],
|
||||
{
|
||||
errors: [],
|
||||
fileNames: [],
|
||||
options: {
|
||||
strictNullChecks: true,
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
/// <reference path="../../server/typingsInstaller/typingsInstaller.ts" />
|
||||
|
||||
namespace ts.projectSystem {
|
||||
import CommandNames = server.CommandNames;
|
||||
|
||||
function createTestTypingsInstaller(host: server.ServerHost) {
|
||||
return new TestTypingsInstaller("/a/data/", /*throttleLimit*/5, host);
|
||||
}
|
||||
@@ -75,7 +77,7 @@ namespace ts.projectSystem {
|
||||
};
|
||||
|
||||
// Change the content of file1 to `export var T: number;export function Foo() { };`
|
||||
changeModuleFile1ShapeRequest1 = makeSessionRequest<server.protocol.ChangeRequestArgs>(server.CommandNames.Change, {
|
||||
changeModuleFile1ShapeRequest1 = makeSessionRequest<server.protocol.ChangeRequestArgs>(CommandNames.Change, {
|
||||
file: moduleFile1.path,
|
||||
line: 1,
|
||||
offset: 1,
|
||||
@@ -85,7 +87,7 @@ namespace ts.projectSystem {
|
||||
});
|
||||
|
||||
// Change the content of file1 to `export var T: number;export function Foo() { };`
|
||||
changeModuleFile1InternalRequest1 = makeSessionRequest<server.protocol.ChangeRequestArgs>(server.CommandNames.Change, {
|
||||
changeModuleFile1InternalRequest1 = makeSessionRequest<server.protocol.ChangeRequestArgs>(CommandNames.Change, {
|
||||
file: moduleFile1.path,
|
||||
line: 1,
|
||||
offset: 1,
|
||||
@@ -95,7 +97,7 @@ namespace ts.projectSystem {
|
||||
});
|
||||
|
||||
// Change the content of file1 to `export var T: number;export function Foo() { };`
|
||||
changeModuleFile1ShapeRequest2 = makeSessionRequest<server.protocol.ChangeRequestArgs>(server.CommandNames.Change, {
|
||||
changeModuleFile1ShapeRequest2 = makeSessionRequest<server.protocol.ChangeRequestArgs>(CommandNames.Change, {
|
||||
file: moduleFile1.path,
|
||||
line: 1,
|
||||
offset: 1,
|
||||
@@ -104,7 +106,7 @@ namespace ts.projectSystem {
|
||||
insertString: `export var T2: number;`
|
||||
});
|
||||
|
||||
moduleFile1FileListRequest = makeSessionRequest<server.protocol.FileRequestArgs>(server.CommandNames.CompileOnSaveAffectedFileList, { file: moduleFile1.path, projectFileName: configFile.path });
|
||||
moduleFile1FileListRequest = makeSessionRequest<server.protocol.FileRequestArgs>(CommandNames.CompileOnSaveAffectedFileList, { file: moduleFile1.path, projectFileName: configFile.path });
|
||||
});
|
||||
|
||||
it("should contains only itself if a module file's shape didn't change, and all files referencing it if its shape changed", () => {
|
||||
@@ -120,7 +122,7 @@ namespace ts.projectSystem {
|
||||
sendAffectedFileRequestAndCheckResult(session, moduleFile1FileListRequest, [{ projectFileName: configFile.path, files: [moduleFile1, file1Consumer1, file1Consumer2] }]);
|
||||
|
||||
// Change the content of file1 to `export var T: number;export function Foo() { console.log('hi'); };`
|
||||
const changeFile1InternalRequest = makeSessionRequest<server.protocol.ChangeRequestArgs>(server.CommandNames.Change, {
|
||||
const changeFile1InternalRequest = makeSessionRequest<server.protocol.ChangeRequestArgs>(CommandNames.Change, {
|
||||
file: moduleFile1.path,
|
||||
line: 1,
|
||||
offset: 46,
|
||||
@@ -143,7 +145,7 @@ namespace ts.projectSystem {
|
||||
sendAffectedFileRequestAndCheckResult(session, moduleFile1FileListRequest, [{ projectFileName: configFile.path, files: [moduleFile1, file1Consumer1, file1Consumer2] }]);
|
||||
|
||||
// Change file2 content to `let y = Foo();`
|
||||
const removeFile1Consumer1ImportRequest = makeSessionRequest<server.protocol.ChangeRequestArgs>(server.CommandNames.Change, {
|
||||
const removeFile1Consumer1ImportRequest = makeSessionRequest<server.protocol.ChangeRequestArgs>(CommandNames.Change, {
|
||||
file: file1Consumer1.path,
|
||||
line: 1,
|
||||
offset: 1,
|
||||
@@ -156,7 +158,7 @@ namespace ts.projectSystem {
|
||||
sendAffectedFileRequestAndCheckResult(session, moduleFile1FileListRequest, [{ projectFileName: configFile.path, files: [moduleFile1, file1Consumer2] }]);
|
||||
|
||||
// Add the import statements back to file2
|
||||
const addFile2ImportRequest = makeSessionRequest<server.protocol.ChangeRequestArgs>(server.CommandNames.Change, {
|
||||
const addFile2ImportRequest = makeSessionRequest<server.protocol.ChangeRequestArgs>(CommandNames.Change, {
|
||||
file: file1Consumer1.path,
|
||||
line: 1,
|
||||
offset: 1,
|
||||
@@ -167,7 +169,7 @@ namespace ts.projectSystem {
|
||||
session.executeCommand(addFile2ImportRequest);
|
||||
|
||||
// Change the content of file1 to `export var T2: string;export var T: number;export function Foo() { };`
|
||||
const changeModuleFile1ShapeRequest2 = makeSessionRequest<server.protocol.ChangeRequestArgs>(server.CommandNames.Change, {
|
||||
const changeModuleFile1ShapeRequest2 = makeSessionRequest<server.protocol.ChangeRequestArgs>(CommandNames.Change, {
|
||||
file: moduleFile1.path,
|
||||
line: 1,
|
||||
offset: 1,
|
||||
@@ -272,7 +274,7 @@ namespace ts.projectSystem {
|
||||
const session = new server.Session(host, nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ false);
|
||||
|
||||
openFilesForSession([globalFile3], session);
|
||||
const changeGlobalFile3ShapeRequest = makeSessionRequest<server.protocol.ChangeRequestArgs>(server.CommandNames.Change, {
|
||||
const changeGlobalFile3ShapeRequest = makeSessionRequest<server.protocol.ChangeRequestArgs>(CommandNames.Change, {
|
||||
file: globalFile3.path,
|
||||
line: 1,
|
||||
offset: 1,
|
||||
@@ -283,7 +285,7 @@ namespace ts.projectSystem {
|
||||
|
||||
// check after file1 shape changes
|
||||
session.executeCommand(changeGlobalFile3ShapeRequest);
|
||||
const globalFile3FileListRequest = makeSessionRequest<server.protocol.FileRequestArgs>(server.CommandNames.CompileOnSaveAffectedFileList, { file: globalFile3.path });
|
||||
const globalFile3FileListRequest = makeSessionRequest<server.protocol.FileRequestArgs>(CommandNames.CompileOnSaveAffectedFileList, { file: globalFile3.path });
|
||||
sendAffectedFileRequestAndCheckResult(session, globalFile3FileListRequest, [{ projectFileName: configFile.path, files: [moduleFile1, file1Consumer1, file1Consumer2, globalFile3, moduleFile2] }]);
|
||||
});
|
||||
|
||||
@@ -316,7 +318,7 @@ namespace ts.projectSystem {
|
||||
const session = new server.Session(host, nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ false);
|
||||
openFilesForSession([moduleFile1], session);
|
||||
|
||||
const file1ChangeShapeRequest = makeSessionRequest<server.protocol.ChangeRequestArgs>(server.CommandNames.Change, {
|
||||
const file1ChangeShapeRequest = makeSessionRequest<server.protocol.ChangeRequestArgs>(CommandNames.Change, {
|
||||
file: moduleFile1.path,
|
||||
line: 1,
|
||||
offset: 27,
|
||||
@@ -345,7 +347,7 @@ namespace ts.projectSystem {
|
||||
const session = new server.Session(host, nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ false);
|
||||
openFilesForSession([moduleFile1], session);
|
||||
|
||||
const file1ChangeShapeRequest = makeSessionRequest<server.protocol.ChangeRequestArgs>(server.CommandNames.Change, {
|
||||
const file1ChangeShapeRequest = makeSessionRequest<server.protocol.ChangeRequestArgs>(CommandNames.Change, {
|
||||
file: moduleFile1.path,
|
||||
line: 1,
|
||||
offset: 27,
|
||||
@@ -369,7 +371,7 @@ namespace ts.projectSystem {
|
||||
openFilesForSession([moduleFile1, file1Consumer1], session);
|
||||
sendAffectedFileRequestAndCheckResult(session, moduleFile1FileListRequest, [{ projectFileName: configFile.path, files: [moduleFile1, file1Consumer1, file1Consumer1Consumer1] }]);
|
||||
|
||||
const changeFile1Consumer1ShapeRequest = makeSessionRequest<server.protocol.ChangeRequestArgs>(server.CommandNames.Change, {
|
||||
const changeFile1Consumer1ShapeRequest = makeSessionRequest<server.protocol.ChangeRequestArgs>(CommandNames.Change, {
|
||||
file: file1Consumer1.path,
|
||||
line: 2,
|
||||
offset: 1,
|
||||
@@ -400,7 +402,7 @@ namespace ts.projectSystem {
|
||||
const session = new server.Session(host, nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ false);
|
||||
|
||||
openFilesForSession([file1, file2], session);
|
||||
const file1AffectedListRequest = makeSessionRequest<server.protocol.FileRequestArgs>(server.CommandNames.CompileOnSaveAffectedFileList, { file: file1.path });
|
||||
const file1AffectedListRequest = makeSessionRequest<server.protocol.FileRequestArgs>(CommandNames.CompileOnSaveAffectedFileList, { file: file1.path });
|
||||
sendAffectedFileRequestAndCheckResult(session, file1AffectedListRequest, [{ projectFileName: configFile.path, files: [file1, file2] }]);
|
||||
});
|
||||
|
||||
@@ -415,7 +417,7 @@ namespace ts.projectSystem {
|
||||
const session = createSession(host);
|
||||
|
||||
openFilesForSession([file1, file2, file3], session);
|
||||
const file1AffectedListRequest = makeSessionRequest<server.protocol.FileRequestArgs>(server.CommandNames.CompileOnSaveAffectedFileList, { file: file1.path });
|
||||
const file1AffectedListRequest = makeSessionRequest<server.protocol.FileRequestArgs>(CommandNames.CompileOnSaveAffectedFileList, { file: file1.path });
|
||||
|
||||
sendAffectedFileRequestAndCheckResult(session, file1AffectedListRequest, [
|
||||
{ projectFileName: configFile1.path, files: [file1, file2] },
|
||||
@@ -437,11 +439,11 @@ namespace ts.projectSystem {
|
||||
host.reloadFS([referenceFile1, configFile]);
|
||||
host.triggerFileWatcherCallback(moduleFile1.path, /*removed*/ true);
|
||||
|
||||
const request = makeSessionRequest<server.protocol.FileRequestArgs>(server.CommandNames.CompileOnSaveAffectedFileList, { file: referenceFile1.path });
|
||||
const request = makeSessionRequest<server.protocol.FileRequestArgs>(CommandNames.CompileOnSaveAffectedFileList, { file: referenceFile1.path });
|
||||
sendAffectedFileRequestAndCheckResult(session, request, [
|
||||
{ projectFileName: configFile.path, files: [referenceFile1] }
|
||||
]);
|
||||
const requestForMissingFile = makeSessionRequest<server.protocol.FileRequestArgs>(server.CommandNames.CompileOnSaveAffectedFileList, { file: moduleFile1.path });
|
||||
const requestForMissingFile = makeSessionRequest<server.protocol.FileRequestArgs>(CommandNames.CompileOnSaveAffectedFileList, { file: moduleFile1.path });
|
||||
sendAffectedFileRequestAndCheckResult(session, requestForMissingFile, []);
|
||||
});
|
||||
|
||||
@@ -456,7 +458,7 @@ namespace ts.projectSystem {
|
||||
const session = createSession(host);
|
||||
|
||||
openFilesForSession([referenceFile1], session);
|
||||
const request = makeSessionRequest<server.protocol.FileRequestArgs>(server.CommandNames.CompileOnSaveAffectedFileList, { file: referenceFile1.path });
|
||||
const request = makeSessionRequest<server.protocol.FileRequestArgs>(CommandNames.CompileOnSaveAffectedFileList, { file: referenceFile1.path });
|
||||
sendAffectedFileRequestAndCheckResult(session, request, [
|
||||
{ projectFileName: configFile.path, files: [referenceFile1] }
|
||||
]);
|
||||
@@ -483,7 +485,7 @@ namespace ts.projectSystem {
|
||||
const session = new server.Session(host, nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ false);
|
||||
|
||||
openFilesForSession([file1, file2], session);
|
||||
const compileFileRequest = makeSessionRequest<server.protocol.CompileOnSaveEmitFileRequestArgs>(server.CommandNames.CompileOnSaveEmitFile, { file: file1.path, projectFileName: configFile.path });
|
||||
const compileFileRequest = makeSessionRequest<server.protocol.CompileOnSaveEmitFileRequestArgs>(CommandNames.CompileOnSaveEmitFile, { file: file1.path, projectFileName: configFile.path });
|
||||
session.executeCommand(compileFileRequest);
|
||||
|
||||
const expectedEmittedFileName = "/a/b/f1.js";
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace ts {
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--jsx' option must be: 'preserve', 'react'",
|
||||
messageText: "Argument for '--jsx' option must be: 'preserve', 'react'",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
@@ -122,7 +122,7 @@ namespace ts {
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'",
|
||||
messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
@@ -150,7 +150,7 @@ namespace ts {
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--newLine' option must be: 'crlf', 'lf'",
|
||||
messageText: "Argument for '--newLine' option must be: 'crlf', 'lf'",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
@@ -176,7 +176,7 @@ namespace ts {
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015'",
|
||||
messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017'",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
@@ -202,7 +202,7 @@ namespace ts {
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--moduleResolution' option must be: 'node', 'classic'",
|
||||
messageText: "Argument for '--moduleResolution' option must be: 'node', 'classic'",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
@@ -233,7 +233,7 @@ namespace ts {
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
@@ -264,7 +264,7 @@ namespace ts {
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
@@ -295,7 +295,7 @@ namespace ts {
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
@@ -326,7 +326,7 @@ namespace ts {
|
||||
file: undefined,
|
||||
start: 0,
|
||||
length: 0,
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
|
||||
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'dom', 'dom.iterable', 'webworker', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory'",
|
||||
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
|
||||
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
|
||||
}]
|
||||
@@ -405,6 +405,7 @@ namespace ts {
|
||||
allowJs: true,
|
||||
maxNodeModuleJsDepth: 2,
|
||||
allowSyntheticDefaultImports: true,
|
||||
skipLibCheck: true,
|
||||
module: ModuleKind.CommonJS,
|
||||
target: ScriptTarget.ES5,
|
||||
noImplicitAny: false,
|
||||
@@ -433,6 +434,7 @@ namespace ts {
|
||||
allowJs: false,
|
||||
maxNodeModuleJsDepth: 2,
|
||||
allowSyntheticDefaultImports: true,
|
||||
skipLibCheck: true,
|
||||
module: ModuleKind.CommonJS,
|
||||
target: ScriptTarget.ES5,
|
||||
noImplicitAny: false,
|
||||
@@ -456,7 +458,8 @@ namespace ts {
|
||||
{
|
||||
allowJs: true,
|
||||
maxNodeModuleJsDepth: 2,
|
||||
allowSyntheticDefaultImports: true
|
||||
allowSyntheticDefaultImports: true,
|
||||
skipLibCheck: true
|
||||
},
|
||||
errors: [{
|
||||
file: undefined,
|
||||
@@ -477,7 +480,8 @@ namespace ts {
|
||||
{
|
||||
allowJs: true,
|
||||
maxNodeModuleJsDepth: 2,
|
||||
allowSyntheticDefaultImports: true
|
||||
allowSyntheticDefaultImports: true,
|
||||
skipLibCheck: true
|
||||
},
|
||||
errors: <Diagnostic[]>[]
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace ts {
|
||||
|
||||
Harness.Baseline.runBaseline("JSDocParsing/DocComments.parsesCorrectly." + name + ".json",
|
||||
() => JSON.stringify(comment.jsDoc,
|
||||
(k, v) => v && v.pos !== undefined ? JSON.parse(Utils.sourceFileToJSON(v)) : v, 4));
|
||||
(_, v) => v && v.pos !== undefined ? JSON.parse(Utils.sourceFileToJSON(v)) : v, 4));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
namespace ts {
|
||||
const caseInsensitiveBasePath = "c:/dev/";
|
||||
const caseInsensitiveTsconfigPath = "c:/dev/tsconfig.json";
|
||||
const caseInsensitiveHost = new Utils.MockParseConfigHost(caseInsensitiveBasePath, /*useCaseSensitiveFileNames*/ false, [
|
||||
"c:/dev/a.ts",
|
||||
"c:/dev/a.d.ts",
|
||||
@@ -88,6 +89,8 @@ namespace ts {
|
||||
"c:/dev/g.min.js/.g/g.ts"
|
||||
]);
|
||||
|
||||
const defaultExcludes = ["node_modules", "bower_components", "jspm_packages"];
|
||||
|
||||
function assertParsed(actual: ts.ParsedCommandLine, expected: ts.ParsedCommandLine): void {
|
||||
assert.deepEqual(actual.fileNames, expected.fileNames);
|
||||
assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories);
|
||||
@@ -187,11 +190,14 @@ namespace ts {
|
||||
};
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [],
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes))
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with missing files are excluded", () => {
|
||||
@@ -203,11 +209,14 @@ namespace ts {
|
||||
};
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [],
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes))
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("with literal excludes", () => {
|
||||
@@ -519,13 +528,16 @@ namespace ts {
|
||||
};
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [],
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes))
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {
|
||||
"c:/dev": ts.WatchDirectoryFlags.Recursive
|
||||
},
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("always include literal files", () => {
|
||||
@@ -581,7 +593,7 @@ namespace ts {
|
||||
it("with common package folders and no exclusions", () => {
|
||||
const json = {
|
||||
include: [
|
||||
"**/a.ts"
|
||||
"**/a.ts"
|
||||
]
|
||||
};
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
@@ -657,13 +669,16 @@ namespace ts {
|
||||
options: {
|
||||
allowJs: false
|
||||
},
|
||||
errors: [],
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes))
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {
|
||||
"c:/dev/js": ts.WatchDirectoryFlags.None
|
||||
}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("include .js files when allowJs=true", () => {
|
||||
@@ -774,11 +789,14 @@ namespace ts {
|
||||
};
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [],
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(json.exclude))]
|
||||
,
|
||||
fileNames: [],
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("include files with .. in their name", () => {
|
||||
@@ -960,12 +978,14 @@ namespace ts {
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**")
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**"),
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes))
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("in excludes", () => {
|
||||
@@ -979,11 +999,14 @@ namespace ts {
|
||||
};
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [],
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(json.exclude))
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
});
|
||||
@@ -997,12 +1020,14 @@ namespace ts {
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, "**/x/**/*")
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0, "**/x/**/*"),
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes))
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
it("in excludes", () => {
|
||||
@@ -1044,12 +1069,14 @@ namespace ts {
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**/../*")
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**/../*"),
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes))
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
|
||||
@@ -1062,12 +1089,14 @@ namespace ts {
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**/y/../*")
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**/y/../*"),
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(defaultExcludes))
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath);
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
|
||||
@@ -1111,7 +1140,7 @@ namespace ts {
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**/y/..")
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, "**/y/..")
|
||||
],
|
||||
fileNames: [
|
||||
"c:/dev/a.ts",
|
||||
@@ -1244,11 +1273,14 @@ namespace ts {
|
||||
};
|
||||
const expected: ts.ParsedCommandLine = {
|
||||
options: {},
|
||||
errors: [],
|
||||
errors: [
|
||||
ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2,
|
||||
caseInsensitiveTsconfigPath, JSON.stringify(json.include), JSON.stringify(json.exclude))
|
||||
],
|
||||
fileNames: [],
|
||||
wildcardDirectories: {}
|
||||
};
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveDottedFoldersHost, caseInsensitiveBasePath);
|
||||
const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveDottedFoldersHost, caseInsensitiveBasePath, undefined, caseInsensitiveTsconfigPath);
|
||||
assertParsed(actual, expected);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -290,7 +290,7 @@ namespace ts {
|
||||
return path in files ? createSourceFile(fileName, files[path], languageVersion) : undefined;
|
||||
},
|
||||
getDefaultLibFileName: () => "lib.d.ts",
|
||||
writeFile: (fileName, content): void => { throw new Error("NotImplemented"); },
|
||||
writeFile: notImplemented,
|
||||
getCurrentDirectory: () => currentDirectory,
|
||||
getDirectories: () => [],
|
||||
getCanonicalFileName: fileName => fileName.toLowerCase(),
|
||||
@@ -300,7 +300,7 @@ namespace ts {
|
||||
const path = normalizePath(combinePaths(currentDirectory, fileName));
|
||||
return path in files;
|
||||
},
|
||||
readFile: (fileName): string => { throw new Error("NotImplemented"); }
|
||||
readFile: notImplemented
|
||||
};
|
||||
|
||||
const program = createProgram(rootFiles, options, host);
|
||||
@@ -370,7 +370,7 @@ export = C;
|
||||
return path in files ? createSourceFile(fileName, files[path], languageVersion) : undefined;
|
||||
},
|
||||
getDefaultLibFileName: () => "lib.d.ts",
|
||||
writeFile: (fileName, content): void => { throw new Error("NotImplemented"); },
|
||||
writeFile: notImplemented,
|
||||
getCurrentDirectory: () => currentDirectory,
|
||||
getDirectories: () => [],
|
||||
getCanonicalFileName,
|
||||
@@ -380,7 +380,7 @@ export = C;
|
||||
const path = getCanonicalFileName(normalizePath(combinePaths(currentDirectory, fileName)));
|
||||
return path in files;
|
||||
},
|
||||
readFile: (fileName): string => { throw new Error("NotImplemented"); }
|
||||
readFile: notImplemented
|
||||
};
|
||||
const program = createProgram(rootFiles, options, host);
|
||||
const diagnostics = sortAndDeduplicateDiagnostics(program.getSemanticDiagnostics().concat(program.getOptionsDiagnostics()));
|
||||
@@ -911,15 +911,11 @@ import b = require("./moduleB");
|
||||
});
|
||||
});
|
||||
|
||||
function notImplemented(name: string): () => any {
|
||||
return () => assert(`${name} is not implemented and should not be called`);
|
||||
}
|
||||
|
||||
describe("ModuleResolutionHost.directoryExists", () => {
|
||||
it("No 'fileExists' calls if containing directory is missing", () => {
|
||||
const host: ModuleResolutionHost = {
|
||||
readFile: notImplemented("readFile"),
|
||||
fileExists: notImplemented("fileExists"),
|
||||
readFile: notImplemented,
|
||||
fileExists: notImplemented,
|
||||
directoryExists: _ => false
|
||||
};
|
||||
|
||||
@@ -1017,14 +1013,12 @@ import b = require("./moduleB");
|
||||
const files = [f1, f2, f3, f4];
|
||||
|
||||
const names = map(files, f => f.name);
|
||||
const sourceFiles = arrayToMap(map(files, f => createSourceFile(f.name, f.content, ScriptTarget.ES6)), f => f.fileName);
|
||||
const sourceFiles = arrayToMap(map(files, f => createSourceFile(f.name, f.content, ScriptTarget.ES2015)), f => f.fileName);
|
||||
const compilerHost: CompilerHost = {
|
||||
fileExists : fileName => fileName in sourceFiles,
|
||||
getSourceFile: fileName => sourceFiles[fileName],
|
||||
getDefaultLibFileName: () => "lib.d.ts",
|
||||
writeFile(file, text) {
|
||||
throw new Error("NYI");
|
||||
},
|
||||
writeFile: notImplemented,
|
||||
getCurrentDirectory: () => "/",
|
||||
getDirectories: () => [],
|
||||
getCanonicalFileName: f => f.toLowerCase(),
|
||||
|
||||
@@ -111,13 +111,11 @@ namespace ts {
|
||||
getDefaultLibFileName(): string {
|
||||
return "lib.d.ts";
|
||||
},
|
||||
writeFile(file, text) {
|
||||
throw new Error("NYI");
|
||||
},
|
||||
writeFile: notImplemented,
|
||||
getCurrentDirectory(): string {
|
||||
return "";
|
||||
},
|
||||
getDirectories(path: string): string[] {
|
||||
getDirectories(): string[] {
|
||||
return [];
|
||||
},
|
||||
getCanonicalFileName(fileName): string {
|
||||
@@ -244,17 +242,13 @@ namespace ts {
|
||||
|
||||
it("fails if change affects type references", () => {
|
||||
const program_1 = newProgram(files, ["a.ts"], { types: ["a"] });
|
||||
updateProgram(program_1, ["a.ts"], { types: ["b"] }, files => {
|
||||
|
||||
});
|
||||
updateProgram(program_1, ["a.ts"], { types: ["b"] }, noop);
|
||||
assert.isTrue(!program_1.structureIsReused);
|
||||
});
|
||||
|
||||
it("succeeds if change doesn't affect type references", () => {
|
||||
const program_1 = newProgram(files, ["a.ts"], { types: ["a"] });
|
||||
updateProgram(program_1, ["a.ts"], { types: ["a"] }, files => {
|
||||
|
||||
});
|
||||
updateProgram(program_1, ["a.ts"], { types: ["a"] }, noop);
|
||||
assert.isTrue(program_1.structureIsReused);
|
||||
});
|
||||
|
||||
@@ -280,19 +274,19 @@ namespace ts {
|
||||
|
||||
it("fails if module kind changes", () => {
|
||||
const program_1 = newProgram(files, ["a.ts"], { target, module: ModuleKind.CommonJS });
|
||||
updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.AMD }, files => void 0);
|
||||
updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.AMD }, noop);
|
||||
assert.isTrue(!program_1.structureIsReused);
|
||||
});
|
||||
|
||||
it("fails if rootdir changes", () => {
|
||||
const program_1 = newProgram(files, ["a.ts"], { target, module: ModuleKind.CommonJS, rootDir: "/a/b" });
|
||||
updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.CommonJS, rootDir: "/a/c" }, files => void 0);
|
||||
updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.CommonJS, rootDir: "/a/c" }, noop);
|
||||
assert.isTrue(!program_1.structureIsReused);
|
||||
});
|
||||
|
||||
it("fails if config path changes", () => {
|
||||
const program_1 = newProgram(files, ["a.ts"], { target, module: ModuleKind.CommonJS, configFilePath: "/a/b/tsconfig.json" });
|
||||
updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.CommonJS, configFilePath: "/a/c/tsconfig.json" }, files => void 0);
|
||||
updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.CommonJS, configFilePath: "/a/c/tsconfig.json" }, noop);
|
||||
assert.isTrue(!program_1.structureIsReused);
|
||||
});
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ describe("DocumentRegistry", () => {
|
||||
const snapshot = ts.ScriptSnapshot.fromString(contents);
|
||||
|
||||
// Always treat any change as a full change.
|
||||
snapshot.getChangeRange = old => ts.createTextChangeRange(ts.createTextSpan(0, contents.length), contents.length);
|
||||
snapshot.getChangeRange = () => ts.createTextChangeRange(ts.createTextSpan(0, contents.length), contents.length);
|
||||
|
||||
// Simulate one LS getting the document.
|
||||
documentRegistry.acquireDocument("file1.ts", defaultCompilerOptions, snapshot, /* version */ "1");
|
||||
|
||||
@@ -10,41 +10,47 @@ namespace ts.server {
|
||||
useCaseSensitiveFileNames: true,
|
||||
write(s): void { lastWrittenToHost = s; },
|
||||
readFile(): string { return void 0; },
|
||||
writeFile(): void {},
|
||||
writeFile: noop,
|
||||
resolvePath(): string { return void 0; },
|
||||
fileExists: () => false,
|
||||
directoryExists: () => false,
|
||||
getDirectories: () => [],
|
||||
createDirectory(): void {},
|
||||
createDirectory: noop,
|
||||
getExecutingFilePath(): string { return void 0; },
|
||||
getCurrentDirectory(): string { return void 0; },
|
||||
getEnvironmentVariable(name: string): string { return ""; },
|
||||
getEnvironmentVariable(): string { return ""; },
|
||||
readDirectory(): string[] { return []; },
|
||||
exit(): void { },
|
||||
setTimeout(callback, ms, ...args) { return 0; },
|
||||
clearTimeout(timeoutId) { },
|
||||
exit: noop,
|
||||
setTimeout() { return 0; },
|
||||
clearTimeout: noop,
|
||||
setImmediate: () => 0,
|
||||
clearImmediate() {}
|
||||
clearImmediate: noop
|
||||
};
|
||||
const nullCancellationToken: HostCancellationToken = { isCancellationRequested: () => false };
|
||||
const mockLogger: Logger = {
|
||||
close(): void {},
|
||||
close: noop,
|
||||
hasLevel(): boolean { return false; },
|
||||
loggingEnabled(): boolean { return false; },
|
||||
perftrc(s: string): void {},
|
||||
info(s: string): void {},
|
||||
startGroup(): void {},
|
||||
endGroup(): void {},
|
||||
msg(s: string, type?: string): void {},
|
||||
perftrc: noop,
|
||||
info: noop,
|
||||
startGroup: noop,
|
||||
endGroup: noop,
|
||||
msg: noop,
|
||||
getLogFileName: (): string => undefined
|
||||
};
|
||||
|
||||
class TestSession extends Session {
|
||||
getProjectService() {
|
||||
return this.projectService;
|
||||
}
|
||||
}
|
||||
|
||||
describe("the Session class", () => {
|
||||
let session: Session;
|
||||
let session: TestSession;
|
||||
let lastSent: protocol.Message;
|
||||
|
||||
beforeEach(() => {
|
||||
session = new Session(mockHost, nullCancellationToken, /*useOneInferredProject*/ false, /*typingsInstaller*/ undefined, Utils.byteLength, process.hrtime, mockLogger, /*canUseEvents*/ true);
|
||||
session = new TestSession(mockHost, nullCancellationToken, /*useOneInferredProject*/ false, /*typingsInstaller*/ undefined, Utils.byteLength, process.hrtime, mockLogger, /*canUseEvents*/ true);
|
||||
session.send = (msg: protocol.Message) => {
|
||||
lastSent = msg;
|
||||
};
|
||||
@@ -55,7 +61,7 @@ namespace ts.server {
|
||||
const req: protocol.FileRequest = {
|
||||
command: CommandNames.Open,
|
||||
seq: 0,
|
||||
type: "command",
|
||||
type: "request",
|
||||
arguments: {
|
||||
file: undefined
|
||||
}
|
||||
@@ -67,7 +73,7 @@ namespace ts.server {
|
||||
const req: protocol.Request = {
|
||||
command: "foobar",
|
||||
seq: 0,
|
||||
type: "command"
|
||||
type: "request"
|
||||
};
|
||||
|
||||
session.executeCommand(req);
|
||||
@@ -85,7 +91,7 @@ namespace ts.server {
|
||||
const req: protocol.ConfigureRequest = {
|
||||
command: CommandNames.Configure,
|
||||
seq: 0,
|
||||
type: "command",
|
||||
type: "request",
|
||||
arguments: {
|
||||
hostInfo: "unit test",
|
||||
formatOptions: {
|
||||
@@ -106,6 +112,47 @@ namespace ts.server {
|
||||
body: undefined
|
||||
});
|
||||
});
|
||||
it ("should handle literal types in request", () => {
|
||||
const configureRequest: protocol.ConfigureRequest = {
|
||||
command: CommandNames.Configure,
|
||||
seq: 0,
|
||||
type: "request",
|
||||
arguments: {
|
||||
formatOptions: {
|
||||
indentStyle: "Block"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
session.onMessage(JSON.stringify(configureRequest));
|
||||
|
||||
assert.equal(session.getProjectService().getFormatCodeOptions().indentStyle, IndentStyle.Block);
|
||||
|
||||
const setOptionsRequest: protocol.SetCompilerOptionsForInferredProjectsRequest = {
|
||||
command: CommandNames.CompilerOptionsForInferredProjects,
|
||||
seq: 1,
|
||||
type: "request",
|
||||
arguments: {
|
||||
options: {
|
||||
module: "System",
|
||||
target: "ES5",
|
||||
jsx: "React",
|
||||
newLine: "Lf",
|
||||
moduleResolution: "Node"
|
||||
}
|
||||
}
|
||||
};
|
||||
session.onMessage(JSON.stringify(setOptionsRequest));
|
||||
assert.deepEqual(
|
||||
session.getProjectService().getCompilerOptionsForInferredProjects(),
|
||||
<CompilerOptions>{
|
||||
module: ModuleKind.System,
|
||||
target: ScriptTarget.ES5,
|
||||
jsx: JsxEmit.React,
|
||||
newLine: NewLineKind.LineFeed,
|
||||
moduleResolution: ModuleResolutionKind.NodeJs
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("onMessage", () => {
|
||||
@@ -118,7 +165,7 @@ namespace ts.server {
|
||||
const req: protocol.Request = {
|
||||
command: name,
|
||||
seq: i,
|
||||
type: "command"
|
||||
type: "request"
|
||||
};
|
||||
i++;
|
||||
session.onMessage(JSON.stringify(req));
|
||||
@@ -151,7 +198,7 @@ namespace ts.server {
|
||||
const req: protocol.ConfigureRequest = {
|
||||
command: CommandNames.Configure,
|
||||
seq: 0,
|
||||
type: "command",
|
||||
type: "request",
|
||||
arguments: {
|
||||
hostInfo: "unit test",
|
||||
formatOptions: {
|
||||
@@ -175,7 +222,7 @@ namespace ts.server {
|
||||
|
||||
describe("send", () => {
|
||||
it("is an overrideable handle which sends protocol messages over the wire", () => {
|
||||
const msg = { seq: 0, type: "none" };
|
||||
const msg: server.protocol.Request = { seq: 0, type: "request", command: "" };
|
||||
const strmsg = JSON.stringify(msg);
|
||||
const len = 1 + Utils.byteLength(strmsg, "utf8");
|
||||
const resultMsg = `Content-Length: ${len}\r\n\r\n${strmsg}\n`;
|
||||
@@ -198,12 +245,12 @@ namespace ts.server {
|
||||
responseRequired: true
|
||||
};
|
||||
|
||||
session.addProtocolHandler(command, (req) => result);
|
||||
session.addProtocolHandler(command, () => result);
|
||||
|
||||
expect(session.executeCommand({
|
||||
command,
|
||||
seq: 0,
|
||||
type: "command"
|
||||
type: "request"
|
||||
})).to.deep.equal(result);
|
||||
});
|
||||
it("throws when a duplicate handler is passed", () => {
|
||||
@@ -216,9 +263,9 @@ namespace ts.server {
|
||||
};
|
||||
const command = "newhandle";
|
||||
|
||||
session.addProtocolHandler(command, (req) => resp);
|
||||
session.addProtocolHandler(command, () => resp);
|
||||
|
||||
expect(() => session.addProtocolHandler(command, (req) => resp))
|
||||
expect(() => session.addProtocolHandler(command, () => resp))
|
||||
.to.throw(`Protocol handler already exists for command "${command}"`);
|
||||
});
|
||||
});
|
||||
@@ -304,7 +351,7 @@ namespace ts.server {
|
||||
|
||||
expect(session.executeCommand({
|
||||
seq: 0,
|
||||
type: "command",
|
||||
type: "request",
|
||||
command: session.customHandler
|
||||
})).to.deep.equal({
|
||||
response: undefined,
|
||||
@@ -405,7 +452,7 @@ namespace ts.server {
|
||||
this.seq++;
|
||||
this.server.enqueue({
|
||||
seq: this.seq,
|
||||
type: "command",
|
||||
type: "request",
|
||||
command,
|
||||
arguments: args
|
||||
});
|
||||
|
||||
@@ -253,6 +253,10 @@ var x = 0;`, {
|
||||
options: { compilerOptions: { allowUnusedLabels: true }, fileName: "input.js", reportDiagnostics: true }
|
||||
});
|
||||
|
||||
transpilesCorrectly("Supports setting 'alwaysStrict'", "x;", {
|
||||
options: { compilerOptions: { alwaysStrict: true }, fileName: "input.js", reportDiagnostics: true }
|
||||
});
|
||||
|
||||
transpilesCorrectly("Supports setting 'baseUrl'", "x;", {
|
||||
options: { compilerOptions: { baseUrl: "./folder/baseUrl" }, fileName: "input.js", reportDiagnostics: true }
|
||||
});
|
||||
|
||||
@@ -28,6 +28,14 @@ namespace ts {
|
||||
assert.isTrue(arrayIsEqualTo(parsed.fileNames.sort(), expectedFileList.sort()));
|
||||
}
|
||||
|
||||
function assertParseFileDiagnostics(jsonText: string, configFileName: string, basePath: string, allFileList: string[], expectedDiagnosticCode: number) {
|
||||
const json = JSON.parse(jsonText);
|
||||
const host: ParseConfigHost = new Utils.MockParseConfigHost(basePath, true, allFileList);
|
||||
const parsed = ts.parseJsonConfigFileContent(json, host, basePath, /*existingOptions*/ undefined, configFileName);
|
||||
assert.isTrue(parsed.errors.length >= 0);
|
||||
assert.isTrue(parsed.errors.filter(e => e.code === expectedDiagnosticCode).length > 0, `Expected error code ${expectedDiagnosticCode} to be in ${JSON.stringify(parsed.errors)}`);
|
||||
}
|
||||
|
||||
it("returns empty config for file with only whitespaces", () => {
|
||||
assertParseResult("", { config : {} });
|
||||
assertParseResult(" ", { config : {} });
|
||||
@@ -202,5 +210,64 @@ namespace ts {
|
||||
assert.isTrue(diagnostics.length === 2);
|
||||
assert.equal(JSON.stringify(configJsonObject), JSON.stringify(expectedResult));
|
||||
});
|
||||
|
||||
it("generates errors for empty files list", () => {
|
||||
const content = `{
|
||||
"files": []
|
||||
}`;
|
||||
assertParseFileDiagnostics(content,
|
||||
"/apath/tsconfig.json",
|
||||
"tests/cases/unittests",
|
||||
["/apath/a.ts"],
|
||||
Diagnostics.The_files_list_in_config_file_0_is_empty.code);
|
||||
});
|
||||
|
||||
it("generates errors for directory with no .ts files", () => {
|
||||
const content = `{
|
||||
}`;
|
||||
assertParseFileDiagnostics(content,
|
||||
"/apath/tsconfig.json",
|
||||
"tests/cases/unittests",
|
||||
["/apath/a.js"],
|
||||
Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2.code);
|
||||
});
|
||||
|
||||
it("generates errors for empty directory", () => {
|
||||
const content = `{
|
||||
"compilerOptions": {
|
||||
"allowJs": true
|
||||
}
|
||||
}`;
|
||||
assertParseFileDiagnostics(content,
|
||||
"/apath/tsconfig.json",
|
||||
"tests/cases/unittests",
|
||||
[],
|
||||
Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2.code);
|
||||
});
|
||||
|
||||
it("generates errors for empty include", () => {
|
||||
const content = `{
|
||||
"include": []
|
||||
}`;
|
||||
assertParseFileDiagnostics(content,
|
||||
"/apath/tsconfig.json",
|
||||
"tests/cases/unittests",
|
||||
["/apath/a.ts"],
|
||||
Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2.code);
|
||||
});
|
||||
|
||||
it("generates errors for includes with outDir", () => {
|
||||
const content = `{
|
||||
"compilerOptions": {
|
||||
"outDir": "./"
|
||||
},
|
||||
"include": ["**/*"]
|
||||
}`;
|
||||
assertParseFileDiagnostics(content,
|
||||
"/apath/tsconfig.json",
|
||||
"tests/cases/unittests",
|
||||
["/apath/a.ts"],
|
||||
Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2.code);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
/// <reference path="..\harness.ts" />
|
||||
/// <reference path="..\harness.ts" />
|
||||
/// <reference path="../../server/typingsInstaller/typingsInstaller.ts" />
|
||||
|
||||
namespace ts.projectSystem {
|
||||
import TI = server.typingsInstaller;
|
||||
import protocol = server.protocol;
|
||||
import CommandNames = server.CommandNames;
|
||||
|
||||
const safeList = {
|
||||
path: <Path>"/safeList.json",
|
||||
@@ -17,14 +19,8 @@ namespace ts.projectSystem {
|
||||
|
||||
export interface PostExecAction {
|
||||
readonly requestKind: TI.RequestKind;
|
||||
readonly error: Error;
|
||||
readonly stdout: string;
|
||||
readonly stderr: string;
|
||||
readonly callback: (err: Error, stdout: string, stderr: string) => void;
|
||||
}
|
||||
|
||||
export function notImplemented(): any {
|
||||
throw new Error("Not yet implemented");
|
||||
readonly success: boolean;
|
||||
readonly callback: TI.RequestCompletedAction;
|
||||
}
|
||||
|
||||
export const nullLogger: server.Logger = {
|
||||
@@ -52,7 +48,7 @@ namespace ts.projectSystem {
|
||||
export class TestTypingsInstaller extends TI.TypingsInstaller implements server.ITypingsInstaller {
|
||||
protected projectService: server.ProjectService;
|
||||
constructor(readonly globalTypingsCacheLocation: string, throttleLimit: number, readonly installTypingHost: server.ServerHost, log?: TI.Log) {
|
||||
super(globalTypingsCacheLocation, "npm", safeList.path, throttleLimit, log);
|
||||
super(globalTypingsCacheLocation, safeList.path, throttleLimit, log);
|
||||
this.init();
|
||||
}
|
||||
|
||||
@@ -63,7 +59,7 @@ namespace ts.projectSystem {
|
||||
const actionsToRun = this.postExecActions;
|
||||
this.postExecActions = [];
|
||||
for (const action of actionsToRun) {
|
||||
action.callback(action.error, action.stdout, action.stderr);
|
||||
action.callback(action.success);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +68,7 @@ namespace ts.projectSystem {
|
||||
this.postExecActions.forEach((act, i) => assert.equal(act.requestKind, expected[i], "Unexpected post install action"));
|
||||
}
|
||||
|
||||
onProjectClosed(p: server.Project) {
|
||||
onProjectClosed() {
|
||||
}
|
||||
|
||||
attach(projectService: server.ProjectService) {
|
||||
@@ -83,7 +79,7 @@ namespace ts.projectSystem {
|
||||
return this.installTypingHost;
|
||||
}
|
||||
|
||||
runCommand(requestKind: TI.RequestKind, requestId: number, command: string, cwd: string, cb: (err: Error, stdout: string, stderr: string) => void): void {
|
||||
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
|
||||
switch (requestKind) {
|
||||
case TI.NpmViewRequest:
|
||||
case TI.NpmInstallRequest:
|
||||
@@ -106,9 +102,7 @@ namespace ts.projectSystem {
|
||||
addPostExecAction(requestKind: TI.RequestKind, stdout: string | string[], cb: TI.RequestCompletedAction) {
|
||||
const out = typeof stdout === "string" ? stdout : createNpmPackageJsonString(stdout);
|
||||
const action: PostExecAction = {
|
||||
error: undefined,
|
||||
stdout: out,
|
||||
stderr: "",
|
||||
success: !!out,
|
||||
callback: cb,
|
||||
requestKind
|
||||
};
|
||||
@@ -124,11 +118,11 @@ namespace ts.projectSystem {
|
||||
return JSON.stringify({ dependencies: dependencies });
|
||||
}
|
||||
|
||||
export function getExecutingFilePathFromLibFile(libFilePath: string): string {
|
||||
export function getExecutingFilePathFromLibFile(): string {
|
||||
return combinePaths(getDirectoryPath(libFile.path), "tsc.js");
|
||||
}
|
||||
|
||||
export function toExternalFile(fileName: string): server.protocol.ExternalFile {
|
||||
export function toExternalFile(fileName: string): protocol.ExternalFile {
|
||||
return { fileName };
|
||||
}
|
||||
|
||||
@@ -136,6 +130,19 @@ namespace ts.projectSystem {
|
||||
return map(fileNames, toExternalFile);
|
||||
}
|
||||
|
||||
export class TestServerEventManager {
|
||||
public events: server.ProjectServiceEvent[] = [];
|
||||
|
||||
handler: server.ProjectServiceEventHandler = (event: server.ProjectServiceEvent) => {
|
||||
this.events.push(event);
|
||||
}
|
||||
|
||||
checkEventCountOfType(eventType: "context" | "configFileDiag", expectedCount: number) {
|
||||
const eventsOfType = filter(this.events, e => e.eventName === eventType);
|
||||
assert.equal(eventsOfType.length, expectedCount, `The actual event counts of type ${eventType} is ${eventsOfType.length}, while expected ${expectedCount}`);
|
||||
}
|
||||
}
|
||||
|
||||
export interface TestServerHostCreationParameters {
|
||||
useCaseSensitiveFileNames?: boolean;
|
||||
executingFilePath?: string;
|
||||
@@ -143,27 +150,31 @@ namespace ts.projectSystem {
|
||||
currentDirectory?: string;
|
||||
}
|
||||
|
||||
export function createServerHost(fileOrFolderList: FileOrFolder[],
|
||||
params?: TestServerHostCreationParameters,
|
||||
libFilePath: string = libFile.path): TestServerHost {
|
||||
|
||||
export function createServerHost(fileOrFolderList: FileOrFolder[], params?: TestServerHostCreationParameters): TestServerHost {
|
||||
if (!params) {
|
||||
params = {};
|
||||
}
|
||||
const host = new TestServerHost(
|
||||
params.useCaseSensitiveFileNames !== undefined ? params.useCaseSensitiveFileNames : false,
|
||||
params.executingFilePath || getExecutingFilePathFromLibFile(libFilePath),
|
||||
params.executingFilePath || getExecutingFilePathFromLibFile(),
|
||||
params.currentDirectory || "/",
|
||||
fileOrFolderList);
|
||||
host.createFileOrFolder(safeList, /*createParentDirectory*/ true);
|
||||
return host;
|
||||
}
|
||||
|
||||
export function createSession(host: server.ServerHost, typingsInstaller?: server.ITypingsInstaller) {
|
||||
class TestSession extends server.Session {
|
||||
getProjectService() {
|
||||
return this.projectService;
|
||||
}
|
||||
};
|
||||
|
||||
export function createSession(host: server.ServerHost, typingsInstaller?: server.ITypingsInstaller, projectServiceEventHandler?: server.ProjectServiceEventHandler) {
|
||||
if (typingsInstaller === undefined) {
|
||||
typingsInstaller = new TestTypingsInstaller("/a/data/", /*throttleLimit*/5, host);
|
||||
}
|
||||
return new server.Session(host, nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ false);
|
||||
|
||||
return new TestSession(host, nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ projectServiceEventHandler !== undefined, projectServiceEventHandler);
|
||||
}
|
||||
|
||||
export interface CreateProjectServiceParameters {
|
||||
@@ -304,9 +315,9 @@ namespace ts.projectSystem {
|
||||
|
||||
count() {
|
||||
let n = 0;
|
||||
/* tslint:disable:no-unused-variable */
|
||||
for (const _ in this.map) {
|
||||
/* tslint:enable:no-unused-variable */
|
||||
// TODO: GH#11734
|
||||
_;
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
@@ -455,7 +466,7 @@ namespace ts.projectSystem {
|
||||
}
|
||||
|
||||
// TOOD: record and invoke callbacks to simulate timer events
|
||||
setTimeout(callback: TimeOutCallback, time: number, ...args: any[]) {
|
||||
setTimeout(callback: TimeOutCallback, _time: number, ...args: any[]) {
|
||||
return this.timeoutCallbacks.register(callback, args);
|
||||
};
|
||||
|
||||
@@ -472,7 +483,7 @@ namespace ts.projectSystem {
|
||||
this.timeoutCallbacks.invoke();
|
||||
}
|
||||
|
||||
setImmediate(callback: TimeOutCallback, time: number, ...args: any[]) {
|
||||
setImmediate(callback: TimeOutCallback, _time: number, ...args: any[]) {
|
||||
return this.immediateCallbacks.register(callback, args);
|
||||
}
|
||||
|
||||
@@ -504,17 +515,18 @@ namespace ts.projectSystem {
|
||||
this.reloadFS(filesOrFolders);
|
||||
}
|
||||
|
||||
write() { }
|
||||
|
||||
readonly readFile = (s: string) => (<File>this.fs.get(this.toPath(s))).content;
|
||||
readonly resolvePath = (s: string) => s;
|
||||
readonly getExecutingFilePath = () => this.executingFilePath;
|
||||
readonly getCurrentDirectory = () => this.currentDirectory;
|
||||
readonly write = (s: string) => notImplemented();
|
||||
readonly exit = () => notImplemented();
|
||||
readonly getEnvironmentVariable = (v: string) => notImplemented();
|
||||
readonly exit = notImplemented;
|
||||
readonly getEnvironmentVariable = notImplemented;
|
||||
}
|
||||
|
||||
export function makeSessionRequest<T>(command: string, args: T) {
|
||||
const newRequest: server.protocol.Request = {
|
||||
const newRequest: protocol.Request = {
|
||||
seq: 0,
|
||||
type: "request",
|
||||
command,
|
||||
@@ -525,7 +537,7 @@ namespace ts.projectSystem {
|
||||
|
||||
export function openFilesForSession(files: FileOrFolder[], session: server.Session) {
|
||||
for (const file of files) {
|
||||
const request = makeSessionRequest<server.protocol.OpenRequestArgs>(server.CommandNames.Open, { file: file.path });
|
||||
const request = makeSessionRequest<protocol.OpenRequestArgs>(CommandNames.Open, { file: file.path });
|
||||
session.executeCommand(request);
|
||||
}
|
||||
}
|
||||
@@ -1738,7 +1750,7 @@ namespace ts.projectSystem {
|
||||
});
|
||||
|
||||
describe("navigate-to for javascript project", () => {
|
||||
function containsNavToItem(items: server.protocol.NavtoItem[], itemName: string, itemKind: string) {
|
||||
function containsNavToItem(items: protocol.NavtoItem[], itemName: string, itemKind: string) {
|
||||
return find(items, item => item.name === itemName && item.kind === itemKind) !== undefined;
|
||||
}
|
||||
|
||||
@@ -1756,12 +1768,12 @@ namespace ts.projectSystem {
|
||||
openFilesForSession([file1], session);
|
||||
|
||||
// Try to find some interface type defined in lib.d.ts
|
||||
const libTypeNavToRequest = makeSessionRequest<server.protocol.NavtoRequestArgs>(server.CommandNames.Navto, { searchValue: "Document", file: file1.path, projectFileName: configFile.path });
|
||||
const items: server.protocol.NavtoItem[] = session.executeCommand(libTypeNavToRequest).response;
|
||||
const libTypeNavToRequest = makeSessionRequest<protocol.NavtoRequestArgs>(CommandNames.Navto, { searchValue: "Document", file: file1.path, projectFileName: configFile.path });
|
||||
const items: protocol.NavtoItem[] = session.executeCommand(libTypeNavToRequest).response;
|
||||
assert.isFalse(containsNavToItem(items, "Document", "interface"), `Found lib.d.ts symbol in JavaScript project nav to request result.`);
|
||||
|
||||
const localFunctionNavToRequst = makeSessionRequest<server.protocol.NavtoRequestArgs>(server.CommandNames.Navto, { searchValue: "foo", file: file1.path, projectFileName: configFile.path });
|
||||
const items2: server.protocol.NavtoItem[] = session.executeCommand(localFunctionNavToRequst).response;
|
||||
const localFunctionNavToRequst = makeSessionRequest<protocol.NavtoRequestArgs>(CommandNames.Navto, { searchValue: "foo", file: file1.path, projectFileName: configFile.path });
|
||||
const items2: protocol.NavtoItem[] = session.executeCommand(localFunctionNavToRequst).response;
|
||||
assert.isTrue(containsNavToItem(items2, "foo", "function"), `Cannot find function symbol "foo".`);
|
||||
});
|
||||
});
|
||||
@@ -2084,7 +2096,7 @@ namespace ts.projectSystem {
|
||||
const projectFileName = "externalProject";
|
||||
const host = createServerHost([f]);
|
||||
const projectService = createProjectService(host);
|
||||
// create a project
|
||||
// create a project
|
||||
projectService.openExternalProject({ projectFileName, rootFiles: [toExternalFile(f.path)], options: {} });
|
||||
projectService.checkNumberOfProjects({ externalProjects: 1 });
|
||||
|
||||
@@ -2121,4 +2133,341 @@ namespace ts.projectSystem {
|
||||
projectService.inferredProjects[0].getLanguageService().getProgram();
|
||||
});
|
||||
});
|
||||
|
||||
describe("rename a module file and rename back", () => {
|
||||
it("should restore the states for inferred projects", () => {
|
||||
const moduleFile = {
|
||||
path: "/a/b/moduleFile.ts",
|
||||
content: "export function bar() { };"
|
||||
};
|
||||
const file1 = {
|
||||
path: "/a/b/file1.ts",
|
||||
content: "import * as T from './moduleFile'; T.bar();"
|
||||
};
|
||||
const host = createServerHost([moduleFile, file1]);
|
||||
const session = createSession(host);
|
||||
|
||||
openFilesForSession([file1], session);
|
||||
const getErrRequest = makeSessionRequest<server.protocol.SemanticDiagnosticsSyncRequestArgs>(
|
||||
server.CommandNames.SemanticDiagnosticsSync,
|
||||
{ file: file1.path }
|
||||
);
|
||||
let diags = <server.protocol.Diagnostic[]>session.executeCommand(getErrRequest).response;
|
||||
assert.equal(diags.length, 0);
|
||||
|
||||
const moduleFileOldPath = moduleFile.path;
|
||||
const moduleFileNewPath = "/a/b/moduleFile1.ts";
|
||||
moduleFile.path = moduleFileNewPath;
|
||||
host.reloadFS([moduleFile, file1]);
|
||||
host.triggerFileWatcherCallback(moduleFileOldPath);
|
||||
host.triggerDirectoryWatcherCallback("/a/b", moduleFile.path);
|
||||
host.runQueuedTimeoutCallbacks();
|
||||
diags = <server.protocol.Diagnostic[]>session.executeCommand(getErrRequest).response;
|
||||
assert.equal(diags.length, 1);
|
||||
|
||||
moduleFile.path = moduleFileOldPath;
|
||||
host.reloadFS([moduleFile, file1]);
|
||||
host.triggerFileWatcherCallback(moduleFileNewPath);
|
||||
host.triggerDirectoryWatcherCallback("/a/b", moduleFile.path);
|
||||
host.runQueuedTimeoutCallbacks();
|
||||
|
||||
// Make a change to trigger the program rebuild
|
||||
const changeRequest = makeSessionRequest<server.protocol.ChangeRequestArgs>(
|
||||
server.CommandNames.Change,
|
||||
{ file: file1.path, line: 1, offset: 44, endLine: 1, endOffset: 44, insertString: "\n" }
|
||||
);
|
||||
session.executeCommand(changeRequest);
|
||||
host.runQueuedTimeoutCallbacks();
|
||||
|
||||
diags = <server.protocol.Diagnostic[]>session.executeCommand(getErrRequest).response;
|
||||
assert.equal(diags.length, 0);
|
||||
});
|
||||
|
||||
it("should restore the states for configured projects", () => {
|
||||
const moduleFile = {
|
||||
path: "/a/b/moduleFile.ts",
|
||||
content: "export function bar() { };"
|
||||
};
|
||||
const file1 = {
|
||||
path: "/a/b/file1.ts",
|
||||
content: "import * as T from './moduleFile'; T.bar();"
|
||||
};
|
||||
const configFile = {
|
||||
path: "/a/b/tsconfig.json",
|
||||
content: `{}`
|
||||
};
|
||||
const host = createServerHost([moduleFile, file1, configFile]);
|
||||
const session = createSession(host);
|
||||
|
||||
openFilesForSession([file1], session);
|
||||
const getErrRequest = makeSessionRequest<server.protocol.SemanticDiagnosticsSyncRequestArgs>(
|
||||
server.CommandNames.SemanticDiagnosticsSync,
|
||||
{ file: file1.path }
|
||||
);
|
||||
let diags = <server.protocol.Diagnostic[]>session.executeCommand(getErrRequest).response;
|
||||
assert.equal(diags.length, 0);
|
||||
|
||||
const moduleFileOldPath = moduleFile.path;
|
||||
const moduleFileNewPath = "/a/b/moduleFile1.ts";
|
||||
moduleFile.path = moduleFileNewPath;
|
||||
host.reloadFS([moduleFile, file1, configFile]);
|
||||
host.triggerFileWatcherCallback(moduleFileOldPath);
|
||||
host.triggerDirectoryWatcherCallback("/a/b", moduleFile.path);
|
||||
host.runQueuedTimeoutCallbacks();
|
||||
diags = <server.protocol.Diagnostic[]>session.executeCommand(getErrRequest).response;
|
||||
assert.equal(diags.length, 1);
|
||||
|
||||
moduleFile.path = moduleFileOldPath;
|
||||
host.reloadFS([moduleFile, file1, configFile]);
|
||||
host.triggerFileWatcherCallback(moduleFileNewPath);
|
||||
host.triggerDirectoryWatcherCallback("/a/b", moduleFile.path);
|
||||
host.runQueuedTimeoutCallbacks();
|
||||
diags = <server.protocol.Diagnostic[]>session.executeCommand(getErrRequest).response;
|
||||
assert.equal(diags.length, 0);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("add the missing module file for inferred project", () => {
|
||||
it("should remove the `module not found` error", () => {
|
||||
const moduleFile = {
|
||||
path: "/a/b/moduleFile.ts",
|
||||
content: "export function bar() { };"
|
||||
};
|
||||
const file1 = {
|
||||
path: "/a/b/file1.ts",
|
||||
content: "import * as T from './moduleFile'; T.bar();"
|
||||
};
|
||||
const host = createServerHost([file1]);
|
||||
const session = createSession(host);
|
||||
openFilesForSession([file1], session);
|
||||
const getErrRequest = makeSessionRequest<server.protocol.SemanticDiagnosticsSyncRequestArgs>(
|
||||
server.CommandNames.SemanticDiagnosticsSync,
|
||||
{ file: file1.path }
|
||||
);
|
||||
let diags = <server.protocol.Diagnostic[]>session.executeCommand(getErrRequest).response;
|
||||
assert.equal(diags.length, 1);
|
||||
|
||||
host.reloadFS([file1, moduleFile]);
|
||||
host.triggerDirectoryWatcherCallback(getDirectoryPath(file1.path), moduleFile.path);
|
||||
host.runQueuedTimeoutCallbacks();
|
||||
|
||||
// Make a change to trigger the program rebuild
|
||||
const changeRequest = makeSessionRequest<server.protocol.ChangeRequestArgs>(
|
||||
server.CommandNames.Change,
|
||||
{ file: file1.path, line: 1, offset: 44, endLine: 1, endOffset: 44, insertString: "\n" }
|
||||
);
|
||||
session.executeCommand(changeRequest);
|
||||
|
||||
// Recheck
|
||||
diags = <server.protocol.Diagnostic[]>session.executeCommand(getErrRequest).response;
|
||||
assert.equal(diags.length, 0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Configure file diagnostics events", () => {
|
||||
|
||||
it("are generated when the config file has errors", () => {
|
||||
const serverEventManager = new TestServerEventManager();
|
||||
const file = {
|
||||
path: "/a/b/app.ts",
|
||||
content: "let x = 10"
|
||||
};
|
||||
const configFile = {
|
||||
path: "/a/b/tsconfig.json",
|
||||
content: `{
|
||||
"compilerOptions": {
|
||||
"foo": "bar",
|
||||
"allowJS": true
|
||||
}
|
||||
}`
|
||||
};
|
||||
|
||||
const host = createServerHost([file, configFile]);
|
||||
const session = createSession(host, /*typingsInstaller*/ undefined, serverEventManager.handler);
|
||||
openFilesForSession([file], session);
|
||||
serverEventManager.checkEventCountOfType("configFileDiag", 1);
|
||||
|
||||
for (const event of serverEventManager.events) {
|
||||
if (event.eventName === "configFileDiag") {
|
||||
assert.equal(event.data.configFileName, configFile.path);
|
||||
assert.equal(event.data.triggerFile, file.path);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("are generated when the config file doesn't have errors", () => {
|
||||
const serverEventManager = new TestServerEventManager();
|
||||
const file = {
|
||||
path: "/a/b/app.ts",
|
||||
content: "let x = 10"
|
||||
};
|
||||
const configFile = {
|
||||
path: "/a/b/tsconfig.json",
|
||||
content: `{
|
||||
"compilerOptions": {}
|
||||
}`
|
||||
};
|
||||
|
||||
const host = createServerHost([file, configFile]);
|
||||
const session = createSession(host, /*typingsInstaller*/ undefined, serverEventManager.handler);
|
||||
openFilesForSession([file], session);
|
||||
serverEventManager.checkEventCountOfType("configFileDiag", 1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("skipLibCheck", () => {
|
||||
it("should be turned on for js-only inferred projects", () => {
|
||||
const file1 = {
|
||||
path: "/a/b/file1.js",
|
||||
content: `
|
||||
/// <reference path="file2.d.ts" />
|
||||
var x = 1;`
|
||||
};
|
||||
const file2 = {
|
||||
path: "/a/b/file2.d.ts",
|
||||
content: `
|
||||
interface T {
|
||||
name: string;
|
||||
};
|
||||
interface T {
|
||||
name: number;
|
||||
};`
|
||||
};
|
||||
const host = createServerHost([file1, file2]);
|
||||
const session = createSession(host);
|
||||
openFilesForSession([file1, file2], session);
|
||||
|
||||
const file2GetErrRequest = makeSessionRequest<protocol.SemanticDiagnosticsSyncRequestArgs>(
|
||||
CommandNames.SemanticDiagnosticsSync,
|
||||
{ file: file2.path }
|
||||
);
|
||||
let errorResult = <protocol.Diagnostic[]>session.executeCommand(file2GetErrRequest).response;
|
||||
assert.isTrue(errorResult.length === 0);
|
||||
|
||||
const closeFileRequest = makeSessionRequest<protocol.FileRequestArgs>(CommandNames.Close, { file: file1.path });
|
||||
session.executeCommand(closeFileRequest);
|
||||
errorResult = <protocol.Diagnostic[]>session.executeCommand(file2GetErrRequest).response;
|
||||
assert.isTrue(errorResult.length !== 0);
|
||||
|
||||
openFilesForSession([file1], session);
|
||||
errorResult = <protocol.Diagnostic[]>session.executeCommand(file2GetErrRequest).response;
|
||||
assert.isTrue(errorResult.length === 0);
|
||||
});
|
||||
|
||||
it("should be turned on for js-only external projects", () => {
|
||||
const jsFile = {
|
||||
path: "/a/b/file1.js",
|
||||
content: "let x =1;"
|
||||
};
|
||||
const dTsFile = {
|
||||
path: "/a/b/file2.d.ts",
|
||||
content: `
|
||||
interface T {
|
||||
name: string;
|
||||
};
|
||||
interface T {
|
||||
name: number;
|
||||
};`
|
||||
};
|
||||
const host = createServerHost([jsFile, dTsFile]);
|
||||
const session = createSession(host);
|
||||
|
||||
const openExternalProjectRequest = makeSessionRequest<protocol.OpenExternalProjectArgs>(
|
||||
CommandNames.OpenExternalProject,
|
||||
{
|
||||
projectFileName: "project1",
|
||||
rootFiles: toExternalFiles([jsFile.path, dTsFile.path]),
|
||||
options: {}
|
||||
}
|
||||
);
|
||||
session.executeCommand(openExternalProjectRequest);
|
||||
|
||||
const dTsFileGetErrRequest = makeSessionRequest<protocol.SemanticDiagnosticsSyncRequestArgs>(
|
||||
CommandNames.SemanticDiagnosticsSync,
|
||||
{ file: dTsFile.path }
|
||||
);
|
||||
const errorResult = <protocol.Diagnostic[]>session.executeCommand(dTsFileGetErrRequest).response;
|
||||
assert.isTrue(errorResult.length === 0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("non-existing directories listed in config file input array", () => {
|
||||
it("should be tolerated without crashing the server", () => {
|
||||
const configFile = {
|
||||
path: "/a/b/tsconfig.json",
|
||||
content: `{
|
||||
"compilerOptions": {},
|
||||
"include": ["app/*", "test/**/*", "something"]
|
||||
}`
|
||||
};
|
||||
const file1 = {
|
||||
path: "/a/b/file1.ts",
|
||||
content: "let t = 10;"
|
||||
};
|
||||
|
||||
const host = createServerHost([file1, configFile]);
|
||||
const projectService = createProjectService(host);
|
||||
projectService.openClientFile(file1.path);
|
||||
host.runQueuedTimeoutCallbacks();
|
||||
checkNumberOfConfiguredProjects(projectService, 1);
|
||||
checkNumberOfInferredProjects(projectService, 1);
|
||||
|
||||
const configuredProject = projectService.configuredProjects[0];
|
||||
assert.isTrue(configuredProject.getFileNames().length == 0);
|
||||
|
||||
const inferredProject = projectService.inferredProjects[0];
|
||||
assert.isTrue(inferredProject.containsFile(<server.NormalizedPath>file1.path));
|
||||
});
|
||||
});
|
||||
|
||||
describe("reload", () => {
|
||||
it("should work with temp file", () => {
|
||||
const f1 = {
|
||||
path: "/a/b/app.ts",
|
||||
content: "let x = 1"
|
||||
};
|
||||
const tmp = {
|
||||
path: "/a/b/app.tmp",
|
||||
content: "const y = 42"
|
||||
};
|
||||
const host = createServerHost([f1, tmp]);
|
||||
const session = createSession(host);
|
||||
|
||||
// send open request
|
||||
session.executeCommand(<server.protocol.OpenRequest>{
|
||||
type: "request",
|
||||
command: "open",
|
||||
seq: 1,
|
||||
arguments: { file: f1.path }
|
||||
});
|
||||
|
||||
// reload from tmp file
|
||||
session.executeCommand(<server.protocol.ReloadRequest>{
|
||||
type: "request",
|
||||
command: "reload",
|
||||
seq: 2,
|
||||
arguments: { file: f1.path, tmpfile: tmp.path }
|
||||
});
|
||||
|
||||
// verify content
|
||||
const projectServiice = session.getProjectService();
|
||||
const snap1 = projectServiice.getScriptInfo(f1.path).snap();
|
||||
assert.equal(snap1.getText(0, snap1.getLength()), tmp.content, "content should be equal to the content of temp file");
|
||||
|
||||
// reload from original file file
|
||||
session.executeCommand(<server.protocol.ReloadRequest>{
|
||||
type: "request",
|
||||
command: "reload",
|
||||
seq: 2,
|
||||
arguments: { file: f1.path }
|
||||
});
|
||||
|
||||
// verify content
|
||||
const snap2 = projectServiice.getScriptInfo(f1.path).snap();
|
||||
assert.equal(snap2.getText(0, snap2.getLength()), f1.content, "content should be equal to the content of original file");
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -31,11 +31,11 @@ namespace ts.projectSystem {
|
||||
function executeCommand(self: Installer, host: TestServerHost, installedTypings: string[], typingFiles: FileOrFolder[], requestKind: TI.RequestKind, cb: TI.RequestCompletedAction): void {
|
||||
switch (requestKind) {
|
||||
case TI.NpmInstallRequest:
|
||||
self.addPostExecAction(requestKind, installedTypings, (err, stdout, stderr) => {
|
||||
self.addPostExecAction(requestKind, installedTypings, success => {
|
||||
for (const file of typingFiles) {
|
||||
host.createFileOrFolder(file, /*createParentDirectory*/ true);
|
||||
}
|
||||
cb(err, stdout, stderr);
|
||||
cb(success);
|
||||
});
|
||||
break;
|
||||
case TI.NpmViewRequest:
|
||||
@@ -81,7 +81,7 @@ namespace ts.projectSystem {
|
||||
constructor() {
|
||||
super(host);
|
||||
}
|
||||
runCommand(requestKind: TI.RequestKind, requestId: number, command: string, cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
|
||||
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
|
||||
const installedTypings = ["@types/jquery"];
|
||||
const typingFiles = [jquery];
|
||||
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
|
||||
@@ -125,7 +125,7 @@ namespace ts.projectSystem {
|
||||
constructor() {
|
||||
super(host);
|
||||
}
|
||||
runCommand(requestKind: TI.RequestKind, requestId: number, command: string, cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
|
||||
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
|
||||
const installedTypings = ["@types/jquery"];
|
||||
const typingFiles = [jquery];
|
||||
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
|
||||
@@ -221,7 +221,7 @@ namespace ts.projectSystem {
|
||||
enqueueIsCalled = true;
|
||||
super.enqueueInstallTypingsRequest(project, typingOptions);
|
||||
}
|
||||
runCommand(requestKind: TI.RequestKind, requestId: number, command: string, cwd: string, cb: TI.RequestCompletedAction): void {
|
||||
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
|
||||
const installedTypings = ["@types/jquery"];
|
||||
const typingFiles = [jquery];
|
||||
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
|
||||
@@ -275,7 +275,7 @@ namespace ts.projectSystem {
|
||||
constructor() {
|
||||
super(host);
|
||||
}
|
||||
runCommand(requestKind: TI.RequestKind, requestId: number, command: string, cwd: string, cb: TI.RequestCompletedAction): void {
|
||||
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
|
||||
const installedTypings = ["@types/lodash", "@types/react"];
|
||||
const typingFiles = [lodash, react];
|
||||
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
|
||||
@@ -323,7 +323,7 @@ namespace ts.projectSystem {
|
||||
enqueueIsCalled = true;
|
||||
super.enqueueInstallTypingsRequest(project, typingOptions);
|
||||
}
|
||||
runCommand(requestKind: TI.RequestKind, requestId: number, command: string, cwd: string, cb: TI.RequestCompletedAction): void {
|
||||
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
|
||||
const installedTypings: string[] = [];
|
||||
const typingFiles: FileOrFolder[] = [];
|
||||
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
|
||||
@@ -398,7 +398,7 @@ namespace ts.projectSystem {
|
||||
constructor() {
|
||||
super(host);
|
||||
}
|
||||
runCommand(requestKind: TI.RequestKind, requestId: number, command: string, cwd: string, cb: TI.RequestCompletedAction): void {
|
||||
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
|
||||
const installedTypings = ["@types/commander", "@types/express", "@types/jquery", "@types/moment"];
|
||||
const typingFiles = [commander, express, jquery, moment];
|
||||
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
|
||||
@@ -477,7 +477,7 @@ namespace ts.projectSystem {
|
||||
constructor() {
|
||||
super(host, { throttleLimit: 3 });
|
||||
}
|
||||
runCommand(requestKind: TI.RequestKind, requestId: number, command: string, cwd: string, cb: TI.RequestCompletedAction): void {
|
||||
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
|
||||
const installedTypings = ["@types/commander", "@types/express", "@types/jquery", "@types/moment", "@types/lodash"];
|
||||
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
|
||||
}
|
||||
@@ -567,10 +567,10 @@ namespace ts.projectSystem {
|
||||
constructor() {
|
||||
super(host, { throttleLimit: 3 });
|
||||
}
|
||||
runCommand(requestKind: TI.RequestKind, requestId: number, command: string, cwd: string, cb: TI.RequestCompletedAction): void {
|
||||
executeRequest(requestKind: TI.RequestKind, _requestId: number, args: string[], _cwd: string, cb: TI.RequestCompletedAction): void {
|
||||
if (requestKind === TI.NpmInstallRequest) {
|
||||
let typingFiles: (FileOrFolder & { typings: string}) [] = [];
|
||||
if (command.indexOf("commander") >= 0) {
|
||||
let typingFiles: (FileOrFolder & { typings: string })[] = [];
|
||||
if (args.indexOf("@types/commander") >= 0) {
|
||||
typingFiles = [commander, jquery, lodash, cordova];
|
||||
}
|
||||
else {
|
||||
@@ -591,7 +591,7 @@ namespace ts.projectSystem {
|
||||
projectFileName: projectFileName1,
|
||||
options: { allowJS: true, moduleResolution: ModuleResolutionKind.NodeJs },
|
||||
rootFiles: [toExternalFile(lodashJs.path), toExternalFile(commanderJs.path), toExternalFile(file3.path)],
|
||||
typingOptions: { include: ["jquery", "cordova" ] }
|
||||
typingOptions: { include: ["jquery", "cordova"] }
|
||||
});
|
||||
|
||||
installer.checkPendingCommands([TI.NpmViewRequest, TI.NpmViewRequest, TI.NpmViewRequest]);
|
||||
@@ -626,7 +626,7 @@ namespace ts.projectSystem {
|
||||
installer.executePendingCommands();
|
||||
|
||||
checkProjectActualFiles(p1, [lodashJs.path, commanderJs.path, file3.path, commander.path, jquery.path, lodash.path, cordova.path]);
|
||||
checkProjectActualFiles(p2, [file3.path, grunt.path, gulp.path ]);
|
||||
checkProjectActualFiles(p2, [file3.path, grunt.path, gulp.path]);
|
||||
});
|
||||
|
||||
it("configured projects discover from node_modules", () => {
|
||||
@@ -655,7 +655,7 @@ namespace ts.projectSystem {
|
||||
constructor() {
|
||||
super(host, { globalTypingsCacheLocation: "/tmp" });
|
||||
}
|
||||
runCommand(requestKind: TI.RequestKind, requestId: number, command: string, cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
|
||||
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
|
||||
const installedTypings = ["@types/jquery"];
|
||||
const typingFiles = [jqueryDTS];
|
||||
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
|
||||
@@ -687,10 +687,10 @@ namespace ts.projectSystem {
|
||||
const bowerJson = {
|
||||
path: "/bower.json",
|
||||
content: JSON.stringify({
|
||||
"dependencies": {
|
||||
"jquery": "^3.1.0"
|
||||
}
|
||||
})
|
||||
"dependencies": {
|
||||
"jquery": "^3.1.0"
|
||||
}
|
||||
})
|
||||
};
|
||||
const jqueryDTS = {
|
||||
path: "/tmp/node_modules/@types/jquery/index.d.ts",
|
||||
@@ -701,7 +701,7 @@ namespace ts.projectSystem {
|
||||
constructor() {
|
||||
super(host, { globalTypingsCacheLocation: "/tmp" });
|
||||
}
|
||||
runCommand(requestKind: TI.RequestKind, requestId: number, command: string, cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
|
||||
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
|
||||
const installedTypings = ["@types/jquery"];
|
||||
const typingFiles = [jqueryDTS];
|
||||
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
|
||||
@@ -720,26 +720,69 @@ namespace ts.projectSystem {
|
||||
checkNumberOfProjects(projectService, { configuredProjects: 1 });
|
||||
checkProjectActualFiles(p, [app.path, jqueryDTS.path]);
|
||||
});
|
||||
|
||||
it("Malformed package.json should be watched", () => {
|
||||
const f = {
|
||||
path: "/a/b/app.js",
|
||||
content: "var x = require('commander')"
|
||||
};
|
||||
const brokenPackageJson = {
|
||||
path: "/a/b/package.json",
|
||||
content: `{ "dependencies": { "co } }`
|
||||
};
|
||||
const fixedPackageJson = {
|
||||
path: brokenPackageJson.path,
|
||||
content: `{ "dependencies": { "commander": "0.0.2" } }`
|
||||
};
|
||||
const cachePath = "/a/cache/";
|
||||
const commander = {
|
||||
path: cachePath + "node_modules/@types/commander/index.d.ts",
|
||||
content: "export let x: number"
|
||||
};
|
||||
const host = createServerHost([f, brokenPackageJson]);
|
||||
const installer = new (class extends Installer {
|
||||
constructor() {
|
||||
super(host, { globalTypingsCacheLocation: cachePath });
|
||||
}
|
||||
executeRequest(requestKind: TI.RequestKind, _requestId: number, _args: string[], _cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
|
||||
const installedTypings = ["@types/commander"];
|
||||
const typingFiles = [commander];
|
||||
executeCommand(this, host, installedTypings, typingFiles, requestKind, cb);
|
||||
}
|
||||
})();
|
||||
const service = createProjectService(host, { typingsInstaller: installer });
|
||||
service.openClientFile(f.path);
|
||||
|
||||
installer.checkPendingCommands([]);
|
||||
|
||||
host.reloadFS([f, fixedPackageJson]);
|
||||
host.triggerFileWatcherCallback(fixedPackageJson.path, /*removed*/ false);
|
||||
// expected one view and one install request
|
||||
installer.installAll([TI.NpmViewRequest], [TI.NpmInstallRequest]);
|
||||
|
||||
service.checkNumberOfProjects({ inferredProjects: 1 });
|
||||
checkProjectActualFiles(service.inferredProjects[0], [f.path, commander.path]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Validate package name:", () => {
|
||||
it ("name cannot be too long", () => {
|
||||
it("name cannot be too long", () => {
|
||||
let packageName = "a";
|
||||
for (let i = 0; i < 8; i++) {
|
||||
packageName += packageName;
|
||||
}
|
||||
assert.equal(TI.validatePackageName(packageName), TI.PackageNameValidationResult.NameTooLong);
|
||||
});
|
||||
it ("name cannot start with dot", () => {
|
||||
it("name cannot start with dot", () => {
|
||||
assert.equal(TI.validatePackageName(".foo"), TI.PackageNameValidationResult.NameStartsWithDot);
|
||||
});
|
||||
it ("name cannot start with underscore", () => {
|
||||
it("name cannot start with underscore", () => {
|
||||
assert.equal(TI.validatePackageName("_foo"), TI.PackageNameValidationResult.NameStartsWithUnderscore);
|
||||
});
|
||||
it ("scoped packages not supported", () => {
|
||||
it("scoped packages not supported", () => {
|
||||
assert.equal(TI.validatePackageName("@scope/bar"), TI.PackageNameValidationResult.ScopedPackagesNotSupported);
|
||||
});
|
||||
it ("non URI safe characters are not supported", () => {
|
||||
it("non URI safe characters are not supported", () => {
|
||||
assert.equal(TI.validatePackageName(" scope "), TI.PackageNameValidationResult.NameContainsNonURISafeCharacters);
|
||||
assert.equal(TI.validatePackageName("; say ‘Hello from TypeScript!’ #"), TI.PackageNameValidationResult.NameContainsNonURISafeCharacters);
|
||||
assert.equal(TI.validatePackageName("a/b/c"), TI.PackageNameValidationResult.NameContainsNonURISafeCharacters);
|
||||
@@ -747,7 +790,7 @@ namespace ts.projectSystem {
|
||||
});
|
||||
|
||||
describe("Invalid package names", () => {
|
||||
it ("should not be installed", () => {
|
||||
it("should not be installed", () => {
|
||||
const f1 = {
|
||||
path: "/a/b/app.js",
|
||||
content: "let x = 1"
|
||||
@@ -766,7 +809,7 @@ namespace ts.projectSystem {
|
||||
constructor() {
|
||||
super(host, { globalTypingsCacheLocation: "/tmp" }, { isEnabled: () => true, writeLine: msg => messages.push(msg) });
|
||||
}
|
||||
runCommand(requestKind: TI.RequestKind, requestId: number, command: string, cwd: string, cb: server.typingsInstaller.RequestCompletedAction) {
|
||||
executeRequest() {
|
||||
assert(false, "runCommand should not be invoked");
|
||||
}
|
||||
})();
|
||||
|
||||
Vendored
+5
-5
@@ -201,17 +201,17 @@ interface NumberConstructor {
|
||||
|
||||
/**
|
||||
* Returns true if passed value is finite.
|
||||
* Unlike the global isFininte, Number.isFinite doesn't forcibly convert the parameter to a
|
||||
* Unlike the global isFinite, Number.isFinite doesn't forcibly convert the parameter to a
|
||||
* number. Only finite values of the type number, result in true.
|
||||
* @param number A numeric value.
|
||||
*/
|
||||
isFinite(number: number): boolean;
|
||||
isFinite(value: any): value is number;
|
||||
|
||||
/**
|
||||
* Returns true if the value passed is an integer, false otherwise.
|
||||
* @param number A numeric value.
|
||||
*/
|
||||
isInteger(number: number): boolean;
|
||||
isInteger(value: any): value is number;
|
||||
|
||||
/**
|
||||
* Returns a Boolean value that indicates whether a value is the reserved value NaN (not a
|
||||
@@ -219,13 +219,13 @@ interface NumberConstructor {
|
||||
* to a number. Only values of the type number, that are also NaN, result in true.
|
||||
* @param number A numeric value.
|
||||
*/
|
||||
isNaN(number: number): boolean;
|
||||
isNaN(value: any): value is number;
|
||||
|
||||
/**
|
||||
* Returns true if the value passed is a safe integer.
|
||||
* @param number A numeric value.
|
||||
*/
|
||||
isSafeInteger(number: number): boolean;
|
||||
isSafeInteger(value: any): value is number;
|
||||
|
||||
/**
|
||||
* The value of the largest integer n such that n and n + 1 are both exactly representable as
|
||||
|
||||
Vendored
+3
@@ -244,6 +244,9 @@ interface Function {
|
||||
*/
|
||||
bind(this: Function, thisArg: any, ...argArray: any[]): any;
|
||||
|
||||
/** Returns a string representation of a function. */
|
||||
toString(): string;
|
||||
|
||||
prototype: any;
|
||||
readonly length: number;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/// <reference path="..\compiler\commandLineParser.ts" />
|
||||
/// <reference path="..\services\services.ts" />
|
||||
/// <reference path="protocol.d.ts" />
|
||||
/// <reference path="session.ts" />
|
||||
/// <reference types="node" />
|
||||
|
||||
@@ -123,7 +122,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
protected forEachFileInfo(action: (fileInfo: T) => any) {
|
||||
this.fileInfos.forEachValue((path: Path, value: T) => action(value));
|
||||
this.fileInfos.forEachValue((_path, value) => action(value));
|
||||
}
|
||||
|
||||
abstract getFilesAffectedBy(scriptInfo: ScriptInfo): string[];
|
||||
|
||||
@@ -10,7 +10,10 @@
|
||||
"stripInternal": true,
|
||||
"types": [
|
||||
"node"
|
||||
]
|
||||
],
|
||||
"target": "es5",
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true
|
||||
},
|
||||
"files": [
|
||||
"cancellationToken.ts"
|
||||
|
||||
+133
-50
@@ -1,16 +1,10 @@
|
||||
/// <reference path="session.ts" />
|
||||
|
||||
namespace ts.server {
|
||||
|
||||
export interface SessionClientHost extends LanguageServiceHost {
|
||||
writeMessage(message: string): void;
|
||||
}
|
||||
|
||||
interface CompletionEntry extends CompletionInfo {
|
||||
fileName: string;
|
||||
position: number;
|
||||
}
|
||||
|
||||
interface RenameEntry extends RenameInfo {
|
||||
fileName: string;
|
||||
position: number;
|
||||
@@ -247,8 +241,8 @@ namespace ts.server {
|
||||
return response.body[0];
|
||||
}
|
||||
|
||||
getCompletionEntrySymbol(fileName: string, position: number, entryName: string): Symbol {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
getCompletionEntrySymbol(_fileName: string, _position: number, _entryName: string): Symbol {
|
||||
return notImplemented();
|
||||
}
|
||||
|
||||
getNavigateToItems(searchValue: string): NavigateToItem[] {
|
||||
@@ -279,7 +273,7 @@ namespace ts.server {
|
||||
});
|
||||
}
|
||||
|
||||
getFormattingEditsForRange(fileName: string, start: number, end: number, options: ts.FormatCodeOptions): ts.TextChange[] {
|
||||
getFormattingEditsForRange(fileName: string, start: number, end: number, _options: ts.FormatCodeOptions): ts.TextChange[] {
|
||||
const startLineOffset = this.positionToOneBasedLineOffset(fileName, start);
|
||||
const endLineOffset = this.positionToOneBasedLineOffset(fileName, end);
|
||||
const args: protocol.FormatRequestArgs = {
|
||||
@@ -301,7 +295,7 @@ namespace ts.server {
|
||||
return this.getFormattingEditsForRange(fileName, 0, this.host.getScriptSnapshot(fileName).getLength(), options);
|
||||
}
|
||||
|
||||
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): ts.TextChange[] {
|
||||
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, _options: FormatCodeOptions): ts.TextChange[] {
|
||||
const lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
const args: protocol.FormatOnKeyRequestArgs = {
|
||||
file: fileName,
|
||||
@@ -391,7 +385,7 @@ namespace ts.server {
|
||||
});
|
||||
}
|
||||
|
||||
findReferences(fileName: string, position: number): ReferencedSymbol[] {
|
||||
findReferences(_fileName: string, _position: number): ReferencedSymbol[] {
|
||||
// Not yet implemented.
|
||||
return [];
|
||||
}
|
||||
@@ -420,20 +414,50 @@ namespace ts.server {
|
||||
});
|
||||
}
|
||||
|
||||
getEmitOutput(fileName: string): EmitOutput {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
getEmitOutput(_fileName: string): EmitOutput {
|
||||
return notImplemented();
|
||||
}
|
||||
|
||||
getSyntacticDiagnostics(fileName: string): Diagnostic[] {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
const args: protocol.SyntacticDiagnosticsSyncRequestArgs = { file: fileName, includeLinePosition: true };
|
||||
|
||||
const request = this.processRequest<protocol.SyntacticDiagnosticsSyncRequest>(CommandNames.SyntacticDiagnosticsSync, args);
|
||||
const response = this.processResponse<protocol.SyntacticDiagnosticsSyncResponse>(request);
|
||||
|
||||
return (<protocol.DiagnosticWithLinePosition[]>response.body).map(entry => this.convertDiagnostic(entry, fileName));
|
||||
}
|
||||
|
||||
getSemanticDiagnostics(fileName: string): Diagnostic[] {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
const args: protocol.SemanticDiagnosticsSyncRequestArgs = { file: fileName, includeLinePosition: true };
|
||||
|
||||
const request = this.processRequest<protocol.SemanticDiagnosticsSyncRequest>(CommandNames.SemanticDiagnosticsSync, args);
|
||||
const response = this.processResponse<protocol.SemanticDiagnosticsSyncResponse>(request);
|
||||
|
||||
return (<protocol.DiagnosticWithLinePosition[]>response.body).map(entry => this.convertDiagnostic(entry, fileName));
|
||||
}
|
||||
|
||||
convertDiagnostic(entry: protocol.DiagnosticWithLinePosition, _fileName: string): Diagnostic {
|
||||
let category: DiagnosticCategory;
|
||||
for (const id in DiagnosticCategory) {
|
||||
if (typeof id === "string" && entry.category === id.toLowerCase()) {
|
||||
category = (<any>DiagnosticCategory)[id];
|
||||
}
|
||||
}
|
||||
|
||||
Debug.assert(category !== undefined, "convertDiagnostic: category should not be undefined");
|
||||
|
||||
return {
|
||||
file: undefined,
|
||||
start: entry.start,
|
||||
length: entry.length,
|
||||
messageText: entry.message,
|
||||
category: category,
|
||||
code: entry.code
|
||||
};
|
||||
}
|
||||
|
||||
getCompilerOptionsDiagnostics(): Diagnostic[] {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
return notImplemented();
|
||||
}
|
||||
|
||||
getRenameInfo(fileName: string, position: number, findInStrings?: boolean, findInComments?: boolean): RenameInfo {
|
||||
@@ -488,7 +512,7 @@ namespace ts.server {
|
||||
return this.lastRenameEntry.locations;
|
||||
}
|
||||
|
||||
decodeNavigationBarItems(items: protocol.NavigationBarItem[], fileName: string, lineMap: number[]): NavigationBarItem[] {
|
||||
private decodeNavigationBarItems(items: protocol.NavigationBarItem[], fileName: string, lineMap: number[]): NavigationBarItem[] {
|
||||
if (!items) {
|
||||
return [];
|
||||
}
|
||||
@@ -497,10 +521,7 @@ namespace ts.server {
|
||||
text: item.text,
|
||||
kind: item.kind,
|
||||
kindModifiers: item.kindModifiers || "",
|
||||
spans: item.spans.map(span =>
|
||||
createTextSpanFromBounds(
|
||||
this.lineOffsetToPosition(fileName, span.start, lineMap),
|
||||
this.lineOffsetToPosition(fileName, span.end, lineMap))),
|
||||
spans: item.spans.map(span => this.decodeSpan(span, fileName, lineMap)),
|
||||
childItems: this.decodeNavigationBarItems(item.childItems, fileName, lineMap),
|
||||
indent: item.indent,
|
||||
bolded: false,
|
||||
@@ -509,23 +530,43 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
getNavigationBarItems(fileName: string): NavigationBarItem[] {
|
||||
const args: protocol.FileRequestArgs = {
|
||||
file: fileName
|
||||
};
|
||||
|
||||
const request = this.processRequest<protocol.NavBarRequest>(CommandNames.NavBar, args);
|
||||
const request = this.processRequest<protocol.NavBarRequest>(CommandNames.NavBar, { file: fileName });
|
||||
const response = this.processResponse<protocol.NavBarResponse>(request);
|
||||
|
||||
const lineMap = this.getLineMap(fileName);
|
||||
return this.decodeNavigationBarItems(response.body, fileName, lineMap);
|
||||
}
|
||||
|
||||
getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
private decodeNavigationTree(tree: protocol.NavigationTree, fileName: string, lineMap: number[]): NavigationTree {
|
||||
return {
|
||||
text: tree.text,
|
||||
kind: tree.kind,
|
||||
kindModifiers: tree.kindModifiers,
|
||||
spans: tree.spans.map(span => this.decodeSpan(span, fileName, lineMap)),
|
||||
childItems: map(tree.childItems, item => this.decodeNavigationTree(item, fileName, lineMap))
|
||||
};
|
||||
}
|
||||
|
||||
getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
getNavigationTree(fileName: string): NavigationTree {
|
||||
const request = this.processRequest<protocol.NavTreeRequest>(CommandNames.NavTree, { file: fileName });
|
||||
const response = this.processResponse<protocol.NavTreeResponse>(request);
|
||||
|
||||
const lineMap = this.getLineMap(fileName);
|
||||
return this.decodeNavigationTree(response.body, fileName, lineMap);
|
||||
}
|
||||
|
||||
private decodeSpan(span: protocol.TextSpan, fileName: string, lineMap: number[]) {
|
||||
return createTextSpanFromBounds(
|
||||
this.lineOffsetToPosition(fileName, span.start, lineMap),
|
||||
this.lineOffsetToPosition(fileName, span.end, lineMap));
|
||||
}
|
||||
|
||||
getNameOrDottedNameSpan(_fileName: string, _startPos: number, _endPos: number): TextSpan {
|
||||
return notImplemented();
|
||||
}
|
||||
|
||||
getBreakpointStatementAtPosition(_fileName: string, _position: number): TextSpan {
|
||||
return notImplemented();
|
||||
}
|
||||
|
||||
getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems {
|
||||
@@ -614,20 +655,62 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
getOutliningSpans(fileName: string): OutliningSpan[] {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
getOutliningSpans(_fileName: string): OutliningSpan[] {
|
||||
return notImplemented();
|
||||
}
|
||||
|
||||
getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[] {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
getTodoComments(_fileName: string, _descriptors: TodoCommentDescriptor[]): TodoComment[] {
|
||||
return notImplemented();
|
||||
}
|
||||
|
||||
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
getDocCommentTemplateAtPosition(_fileName: string, _position: number): TextInsertion {
|
||||
return notImplemented();
|
||||
}
|
||||
|
||||
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
isValidBraceCompletionAtPosition(_fileName: string, _position: number, _openingBrace: number): boolean {
|
||||
return notImplemented();
|
||||
}
|
||||
|
||||
getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[] {
|
||||
const startLineOffset = this.positionToOneBasedLineOffset(fileName, start);
|
||||
const endLineOffset = this.positionToOneBasedLineOffset(fileName, end);
|
||||
|
||||
const args: protocol.CodeFixRequestArgs = {
|
||||
file: fileName,
|
||||
startLine: startLineOffset.line,
|
||||
startOffset: startLineOffset.offset,
|
||||
endLine: endLineOffset.line,
|
||||
endOffset: endLineOffset.offset,
|
||||
errorCodes: errorCodes,
|
||||
};
|
||||
|
||||
const request = this.processRequest<protocol.CodeFixRequest>(CommandNames.GetCodeFixes, args);
|
||||
const response = this.processResponse<protocol.CodeFixResponse>(request);
|
||||
|
||||
return response.body.map(entry => this.convertCodeActions(entry, fileName));
|
||||
}
|
||||
|
||||
convertCodeActions(entry: protocol.CodeAction, fileName: string): CodeAction {
|
||||
return {
|
||||
description: entry.description,
|
||||
changes: entry.changes.map(change => ({
|
||||
fileName: change.fileName,
|
||||
textChanges: change.textChanges.map(textChange => this.convertTextChangeToCodeEdit(textChange, fileName))
|
||||
}))
|
||||
};
|
||||
}
|
||||
|
||||
convertTextChangeToCodeEdit(change: protocol.CodeEdit, fileName: string): ts.TextChange {
|
||||
const start = this.lineOffsetToPosition(fileName, change.start);
|
||||
const end = this.lineOffsetToPosition(fileName, change.end);
|
||||
|
||||
return {
|
||||
span: {
|
||||
start: start,
|
||||
length: end - start
|
||||
},
|
||||
newText: change.newText ? change.newText : ""
|
||||
};
|
||||
}
|
||||
|
||||
getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[] {
|
||||
@@ -651,35 +734,35 @@ namespace ts.server {
|
||||
});
|
||||
}
|
||||
|
||||
getIndentationAtPosition(fileName: string, position: number, options: EditorOptions): number {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
getIndentationAtPosition(_fileName: string, _position: number, _options: EditorOptions): number {
|
||||
return notImplemented();
|
||||
}
|
||||
|
||||
getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
getSyntacticClassifications(_fileName: string, _span: TextSpan): ClassifiedSpan[] {
|
||||
return notImplemented();
|
||||
}
|
||||
|
||||
getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
getSemanticClassifications(_fileName: string, _span: TextSpan): ClassifiedSpan[] {
|
||||
return notImplemented();
|
||||
}
|
||||
|
||||
getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
getEncodedSyntacticClassifications(_fileName: string, _span: TextSpan): Classifications {
|
||||
return notImplemented();
|
||||
}
|
||||
|
||||
getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
getEncodedSemanticClassifications(_fileName: string, _span: TextSpan): Classifications {
|
||||
return notImplemented();
|
||||
}
|
||||
|
||||
getProgram(): Program {
|
||||
throw new Error("SourceFile objects are not serializable through the server protocol.");
|
||||
}
|
||||
|
||||
getNonBoundSourceFile(fileName: string): SourceFile {
|
||||
getNonBoundSourceFile(_fileName: string): SourceFile {
|
||||
throw new Error("SourceFile objects are not serializable through the server protocol.");
|
||||
}
|
||||
|
||||
getSourceFile(fileName: string): SourceFile {
|
||||
getSourceFile(_fileName: string): SourceFile {
|
||||
throw new Error("SourceFile objects are not serializable through the server protocol.");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/// <reference path="..\compiler\commandLineParser.ts" />
|
||||
/// <reference path="..\services\services.ts" />
|
||||
/// <reference path="protocol.d.ts" />
|
||||
/// <reference path="utilities.ts" />
|
||||
/// <reference path="session.ts" />
|
||||
/// <reference path="scriptVersionCache.ts"/>
|
||||
@@ -12,12 +11,74 @@ namespace ts.server {
|
||||
export const maxProgramSizeForNonTsFiles = 20 * 1024 * 1024;
|
||||
|
||||
export type ProjectServiceEvent =
|
||||
{ eventName: "context", data: { project: Project, fileName: NormalizedPath } } | { eventName: "configFileDiag", data: { triggerFile?: string, configFileName: string, diagnostics: Diagnostic[] } };
|
||||
{ eventName: "context", data: { project: Project, fileName: NormalizedPath } } | { eventName: "configFileDiag", data: { triggerFile: string, configFileName: string, diagnostics: Diagnostic[] } };
|
||||
|
||||
export interface ProjectServiceEventHandler {
|
||||
(event: ProjectServiceEvent): void;
|
||||
}
|
||||
|
||||
function prepareConvertersForEnumLikeCompilerOptions(commandLineOptions: CommandLineOption[]): Map<Map<number>> {
|
||||
const map: Map<Map<number>> = createMap<Map<number>>();
|
||||
for (const option of commandLineOptions) {
|
||||
if (typeof option.type === "object") {
|
||||
const optionMap = <Map<number>>option.type;
|
||||
// verify that map contains only numbers
|
||||
for (const id in optionMap) {
|
||||
Debug.assert(typeof optionMap[id] === "number");
|
||||
}
|
||||
map[option.name] = optionMap;
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
const compilerOptionConverters = prepareConvertersForEnumLikeCompilerOptions(optionDeclarations);
|
||||
const indentStyle = createMap({
|
||||
"none": IndentStyle.None,
|
||||
"block": IndentStyle.Block,
|
||||
"smart": IndentStyle.Smart
|
||||
});
|
||||
|
||||
export function convertFormatOptions(protocolOptions: protocol.FormatCodeSettings): FormatCodeSettings {
|
||||
if (typeof protocolOptions.indentStyle === "string") {
|
||||
protocolOptions.indentStyle = indentStyle[protocolOptions.indentStyle.toLowerCase()];
|
||||
Debug.assert(protocolOptions.indentStyle !== undefined);
|
||||
}
|
||||
return <any>protocolOptions;
|
||||
}
|
||||
|
||||
export function convertCompilerOptions(protocolOptions: protocol.ExternalProjectCompilerOptions): CompilerOptions & protocol.CompileOnSaveMixin {
|
||||
for (const id in compilerOptionConverters) {
|
||||
const propertyValue = protocolOptions[id];
|
||||
if (typeof propertyValue === "string") {
|
||||
const mappedValues = compilerOptionConverters[id];
|
||||
protocolOptions[id] = mappedValues[propertyValue.toLowerCase()];
|
||||
}
|
||||
}
|
||||
return <any>protocolOptions;
|
||||
}
|
||||
|
||||
export function tryConvertScriptKindName(scriptKindName: protocol.ScriptKindName | ScriptKind): ScriptKind {
|
||||
return typeof scriptKindName === "string"
|
||||
? convertScriptKindName(scriptKindName)
|
||||
: scriptKindName;
|
||||
}
|
||||
|
||||
export function convertScriptKindName(scriptKindName: protocol.ScriptKindName) {
|
||||
switch (scriptKindName) {
|
||||
case "JS":
|
||||
return ScriptKind.JS;
|
||||
case "JSX":
|
||||
return ScriptKind.JSX;
|
||||
case "TS":
|
||||
return ScriptKind.TS;
|
||||
case "TSX":
|
||||
return ScriptKind.TSX;
|
||||
default:
|
||||
return ScriptKind.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This helper function processes a list of projects and return the concatenated, sortd and deduplicated output of processing each project.
|
||||
*/
|
||||
@@ -64,7 +125,7 @@ namespace ts.server {
|
||||
|
||||
const externalFilePropertyReader: FilePropertyReader<protocol.ExternalFile> = {
|
||||
getFileName: x => x.fileName,
|
||||
getScriptKind: x => x.scriptKind,
|
||||
getScriptKind: x => tryConvertScriptKindName(x.scriptKind),
|
||||
hasMixedContent: x => x.hasMixedContent
|
||||
};
|
||||
|
||||
@@ -180,6 +241,8 @@ namespace ts.server {
|
||||
|
||||
private toCanonicalFileName: (f: string) => string;
|
||||
|
||||
public lastDeletedFile: ScriptInfo;
|
||||
|
||||
constructor(public readonly host: ServerHost,
|
||||
public readonly logger: Logger,
|
||||
public readonly cancellationToken: HostCancellationToken,
|
||||
@@ -213,6 +276,10 @@ namespace ts.server {
|
||||
this.ensureInferredProjectsUpToDate();
|
||||
}
|
||||
|
||||
getCompilerOptionsForInferredProjects() {
|
||||
return this.compilerOptionsForInferredProjects;
|
||||
}
|
||||
|
||||
updateTypingsForProject(response: SetTypings | InvalidateCachedTypings): void {
|
||||
const project = this.findProject(response.projectName);
|
||||
if (!project) {
|
||||
@@ -230,10 +297,10 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions): void {
|
||||
this.compilerOptionsForInferredProjects = projectCompilerOptions;
|
||||
this.compilerOptionsForInferredProjects = convertCompilerOptions(projectCompilerOptions);
|
||||
this.compileOnSaveForInferredProjects = projectCompilerOptions.compileOnSave;
|
||||
for (const proj of this.inferredProjects) {
|
||||
proj.setCompilerOptions(projectCompilerOptions);
|
||||
proj.setCompilerOptions(this.compilerOptionsForInferredProjects);
|
||||
proj.compileOnSaveEnabled = projectCompilerOptions.compileOnSave;
|
||||
}
|
||||
this.updateProjectGraphs(this.inferredProjects);
|
||||
@@ -272,7 +339,7 @@ namespace ts.server {
|
||||
else {
|
||||
projectsToUpdate = [];
|
||||
for (const f of this.changedFiles) {
|
||||
projectsToUpdate = projectsToUpdate.concat(f.containingProjects);
|
||||
projectsToUpdate = projectsToUpdate.concat(f.containingProjects);
|
||||
}
|
||||
}
|
||||
this.updateProjectGraphs(projectsToUpdate);
|
||||
@@ -342,6 +409,7 @@ namespace ts.server {
|
||||
|
||||
if (!info.isOpen) {
|
||||
this.filenameToScriptInfo.remove(info.path);
|
||||
this.lastDeletedFile = info;
|
||||
|
||||
// capture list of projects since detachAllProjects will wipe out original list
|
||||
const containingProjects = info.containingProjects.slice();
|
||||
@@ -350,6 +418,7 @@ namespace ts.server {
|
||||
|
||||
// update projects to make sure that set of referenced files is correct
|
||||
this.updateProjectGraphs(containingProjects);
|
||||
this.lastDeletedFile = undefined;
|
||||
|
||||
if (!this.eventHandler) {
|
||||
return;
|
||||
@@ -389,12 +458,12 @@ namespace ts.server {
|
||||
this.throttledOperations.schedule(
|
||||
project.configFileName,
|
||||
/*delay*/250,
|
||||
() => this.handleChangeInSourceFileForConfiguredProject(project));
|
||||
() => this.handleChangeInSourceFileForConfiguredProject(project, fileName));
|
||||
}
|
||||
|
||||
private handleChangeInSourceFileForConfiguredProject(project: ConfiguredProject) {
|
||||
private handleChangeInSourceFileForConfiguredProject(project: ConfiguredProject, triggerFile: string) {
|
||||
const { projectOptions, configFileErrors } = this.convertConfigFileContentToProjectOptions(project.configFileName);
|
||||
this.reportConfigFileDiagnostics(project.getProjectName(), configFileErrors);
|
||||
this.reportConfigFileDiagnostics(project.getProjectName(), configFileErrors, triggerFile);
|
||||
|
||||
const newRootFiles = projectOptions.files.map((f => this.getCanonicalFileName(f)));
|
||||
const currentRootFiles = project.getRootFiles().map((f => this.getCanonicalFileName(f)));
|
||||
@@ -431,7 +500,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
const { configFileErrors } = this.convertConfigFileContentToProjectOptions(fileName);
|
||||
this.reportConfigFileDiagnostics(fileName, configFileErrors);
|
||||
this.reportConfigFileDiagnostics(fileName, configFileErrors, fileName);
|
||||
|
||||
this.logger.info(`Detected newly added tsconfig file: ${fileName}`);
|
||||
this.reloadProjects();
|
||||
@@ -707,7 +776,7 @@ namespace ts.server {
|
||||
Debug.assert(!!parsedCommandLine.fileNames);
|
||||
|
||||
if (parsedCommandLine.fileNames.length === 0) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.The_config_file_0_found_doesn_t_contain_any_source_files, configFilename));
|
||||
(errors || (errors = [])).push(createCompilerDiagnostic(Diagnostics.The_config_file_0_found_doesn_t_contain_any_source_files, configFilename));
|
||||
return { success: false, configFileErrors: errors };
|
||||
}
|
||||
|
||||
@@ -741,12 +810,13 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private createAndAddExternalProject(projectFileName: string, files: protocol.ExternalFile[], options: protocol.ExternalProjectCompilerOptions, typingOptions: TypingOptions) {
|
||||
const compilerOptions = convertCompilerOptions(options);
|
||||
const project = new ExternalProject(
|
||||
projectFileName,
|
||||
this,
|
||||
this.documentRegistry,
|
||||
options,
|
||||
/*languageServiceEnabled*/ !this.exceededTotalSizeLimitForNonTsFiles(options, files, externalFilePropertyReader),
|
||||
compilerOptions,
|
||||
/*languageServiceEnabled*/ !this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, files, externalFilePropertyReader),
|
||||
options.compileOnSave === undefined ? true : options.compileOnSave);
|
||||
|
||||
this.addFilesToProjectAndUpdateGraph(project, files, externalFilePropertyReader, /*clientFileName*/ undefined, typingOptions, /*configFileErrors*/ undefined);
|
||||
@@ -754,13 +824,15 @@ namespace ts.server {
|
||||
return project;
|
||||
}
|
||||
|
||||
private reportConfigFileDiagnostics(configFileName: string, diagnostics: Diagnostic[], triggerFile?: string) {
|
||||
if (diagnostics && diagnostics.length > 0) {
|
||||
this.eventHandler({
|
||||
eventName: "configFileDiag",
|
||||
data: { configFileName, diagnostics, triggerFile }
|
||||
});
|
||||
private reportConfigFileDiagnostics(configFileName: string, diagnostics: Diagnostic[], triggerFile: string) {
|
||||
if (!this.eventHandler) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.eventHandler({
|
||||
eventName: "configFileDiag",
|
||||
data: { configFileName, diagnostics: diagnostics || [], triggerFile }
|
||||
});
|
||||
}
|
||||
|
||||
private createAndAddConfiguredProject(configFileName: NormalizedPath, projectOptions: ProjectOptions, configFileErrors: Diagnostic[], clientFileName?: string) {
|
||||
@@ -1013,7 +1085,7 @@ namespace ts.server {
|
||||
if (args.file) {
|
||||
const info = this.getScriptInfoForNormalizedPath(toNormalizedPath(args.file));
|
||||
if (info) {
|
||||
info.setFormatOptions(args.formatOptions);
|
||||
info.setFormatOptions(convertFormatOptions(args.formatOptions));
|
||||
this.logger.info(`Host configuration update for file ${args.file}`);
|
||||
}
|
||||
}
|
||||
@@ -1023,7 +1095,7 @@ namespace ts.server {
|
||||
this.logger.info(`Host information ${args.hostInfo}`);
|
||||
}
|
||||
if (args.formatOptions) {
|
||||
mergeMaps(this.hostConfiguration.formatCodeOptions, args.formatOptions);
|
||||
mergeMaps(this.hostConfiguration.formatCodeOptions, convertFormatOptions(args.formatOptions));
|
||||
this.logger.info("Format host information updated");
|
||||
}
|
||||
}
|
||||
@@ -1137,7 +1209,7 @@ namespace ts.server {
|
||||
const scriptInfo = this.getScriptInfo(file.fileName);
|
||||
Debug.assert(!scriptInfo || !scriptInfo.isOpen);
|
||||
const normalizedPath = scriptInfo ? scriptInfo.fileName : toNormalizedPath(file.fileName);
|
||||
this.openClientFileWithNormalizedPath(normalizedPath, file.content, file.scriptKind, file.hasMixedContent);
|
||||
this.openClientFileWithNormalizedPath(normalizedPath, file.content, tryConvertScriptKindName(file.scriptKind), file.hasMixedContent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1230,7 +1302,7 @@ namespace ts.server {
|
||||
if (externalProject) {
|
||||
if (!tsConfigFiles) {
|
||||
// external project already exists and not config files were added - update the project and return;
|
||||
this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, proj.options, proj.typingOptions, proj.options.compileOnSave, /*configFileErrors*/ undefined);
|
||||
this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, convertCompilerOptions(proj.options), proj.typingOptions, proj.options.compileOnSave, /*configFileErrors*/ undefined);
|
||||
return;
|
||||
}
|
||||
// some config files were added to external project (that previously were not there)
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace ts.server {
|
||||
};
|
||||
}
|
||||
|
||||
private resolveNamesWithLocalCache<T extends { failedLookupLocations: string[] }, R>(
|
||||
private resolveNamesWithLocalCache<T extends { failedLookupLocations: string[] }, R extends { resolvedFileName?: string }>(
|
||||
names: string[],
|
||||
containingFile: string,
|
||||
cache: ts.FileMap<Map<T>>,
|
||||
@@ -65,6 +65,7 @@ namespace ts.server {
|
||||
const newResolutions: Map<T> = createMap<T>();
|
||||
const resolvedModules: R[] = [];
|
||||
const compilerOptions = this.getCompilationSettings();
|
||||
const lastDeletedFileName = this.project.projectService.lastDeletedFile && this.project.projectService.lastDeletedFile.fileName;
|
||||
|
||||
for (const name of names) {
|
||||
// check if this is a duplicate entry in the list
|
||||
@@ -94,8 +95,11 @@ namespace ts.server {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getResult(resolution)) {
|
||||
// TODO: consider checking failedLookupLocations
|
||||
const result = getResult(resolution);
|
||||
if (result) {
|
||||
if (result.resolvedFileName && result.resolvedFileName === lastDeletedFileName) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user