mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 19:16:17 -06:00
Merged branch 'master' into resolveDecoratorAsCall
This commit is contained in:
commit
071ef34e49
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -1 +1,2 @@
|
||||
*.js linguist-language=TypeScript
|
||||
*.js linguist-language=TypeScript
|
||||
* -text
|
||||
|
||||
@ -31,44 +31,75 @@ Your pull request should:
|
||||
## Running the Tests
|
||||
To run all tests, invoke the runtests target using jake:
|
||||
|
||||
`jake runtests`
|
||||
```Shell
|
||||
jake runtests
|
||||
```
|
||||
|
||||
This run will all tests; to run only a specific subset of tests, use:
|
||||
|
||||
`jake runtests tests=<regex>`
|
||||
```Shell
|
||||
jake runtests tests=<regex>
|
||||
```
|
||||
|
||||
e.g. to run all compiler baseline tests:
|
||||
|
||||
`jake runtests tests=compiler`
|
||||
```Shell
|
||||
jake runtests tests=compiler
|
||||
```
|
||||
|
||||
or to run specifc test:tests\cases\compiler\2dArrays.ts
|
||||
or to run specifc test: `tests\cases\compiler\2dArrays.ts`
|
||||
|
||||
`jake runtests tests=2dArrays`
|
||||
```Shell
|
||||
jake runtests tests=2dArrays
|
||||
```
|
||||
|
||||
## Adding a Test
|
||||
To add a new testcase, simply place a .ts file in tests\cases\compiler containing code that exemplifies the bugfix or change you are making.
|
||||
To add a new testcase, simply place a `.ts` file in `tests\cases\compiler` containing code that exemplifies the bugfix or change you are making.
|
||||
|
||||
These files support metadata tags in the format // @name: value . The supported names and values are:
|
||||
These files support metadata tags in the format `// @metaDataName: value`. The supported names and values are:
|
||||
|
||||
* comments, sourcemap, noimplicitany, declaration: true or false (corresponds to the compiler command-line options of the same name)
|
||||
* target: ES3 or ES5 (same as compiler)
|
||||
* out, outDir: path (same as compiler)
|
||||
* module: local, commonjs, or amd (local corresponds to not passing any compiler --module flag)
|
||||
* `comments`, `sourcemap`, `noimplicitany`, `declaration`: true or false (corresponds to the compiler command-line options of the same name)
|
||||
* `target`: ES3 or ES5 (same as compiler)
|
||||
* `out`, outDir: path (same as compiler)
|
||||
* `module`: local, commonjs, or amd (local corresponds to not passing any compiler --module flag)
|
||||
* `fileName`: path
|
||||
* These tags delimit sections of a file to be used as separate compilation units. They are useful for tests relating to modules. See below for examples.
|
||||
|
||||
**Note** that if you have a test corresponding to a specific spec compliance item, you can place it in tests\cases\conformance in an appropriately-named subfolder.
|
||||
**Note** that if you have a test corresponding to a specific spec compliance item, you can place it in `tests\cases\conformance` in an appropriately-named subfolder.
|
||||
**Note** that filenames here must be distinct from all other compiler testcase names, so you may have to work a bit to find a unique name if it's something common.
|
||||
|
||||
### Tests for multiple files
|
||||
|
||||
When one needs to test for scenarios which require multiple files, it is useful to use the `fileName` metadata tag as such:
|
||||
|
||||
```TypeScript
|
||||
// @fileName: file1.ts
|
||||
export function f() {
|
||||
}
|
||||
|
||||
// @fileName: file2.ts
|
||||
import { f as g } from "file1";
|
||||
|
||||
var x = g();
|
||||
```
|
||||
|
||||
One can also write a project test, but it is slightly more involved.
|
||||
|
||||
## Managing the Baselines
|
||||
Compiler testcases generate baselines that track the emitted .js, the errors produced by the compiler, and the type of each expression in the file. Additionally, some testcases opt in to baselining the source map output.
|
||||
Compiler testcases generate baselines that track the emitted `.js`, the errors produced by the compiler, and the type of each expression in the file. Additionally, some testcases opt in to baselining the source map output.
|
||||
|
||||
When a change in the baselines is detected, the test will fail. To inspect changes vs the expected baselines, use
|
||||
|
||||
`jake diff`
|
||||
```Shell
|
||||
jake diff
|
||||
```
|
||||
|
||||
After verifying that the changes in the baselines are correct, run
|
||||
|
||||
`jake baseline-accept`
|
||||
```Shell
|
||||
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.
|
||||
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.
|
||||
|
||||
43
Jakefile.js
43
Jakefile.js
@ -105,6 +105,14 @@ var serverSources = [
|
||||
return path.join(serverDirectory, f);
|
||||
});
|
||||
|
||||
var languageServiceLibrarySources = [
|
||||
"editorServices.ts",
|
||||
"protocol.d.ts",
|
||||
"session.ts"
|
||||
].map(function (f) {
|
||||
return path.join(serverDirectory, f);
|
||||
}).concat(servicesSources);
|
||||
|
||||
var harnessSources = [
|
||||
"harness.ts",
|
||||
"sourceMapRecorder.ts",
|
||||
@ -129,7 +137,8 @@ var harnessSources = [
|
||||
"services/preProcessFile.ts",
|
||||
"services/patternMatcher.ts",
|
||||
"versionCache.ts",
|
||||
"convertToBase64.ts"
|
||||
"convertToBase64.ts",
|
||||
"transpile.ts"
|
||||
].map(function (f) {
|
||||
return path.join(unittestsDirectory, f);
|
||||
})).concat([
|
||||
@ -148,7 +157,7 @@ var librarySourceMap = [
|
||||
{ target: "lib.scriptHost.d.ts", sources: ["importcore.d.ts", "scriptHost.d.ts"], },
|
||||
{ target: "lib.d.ts", sources: ["core.d.ts", "extensions.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], },
|
||||
{ target: "lib.core.es6.d.ts", sources: ["core.d.ts", "es6.d.ts"]},
|
||||
{ target: "lib.es6.d.ts", sources: ["core.d.ts", "es6.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"]},
|
||||
{ target: "lib.es6.d.ts", sources: ["core.d.ts", "es6.d.ts", "intl.d.ts", "dom.generated.d.ts", "dom.es6.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"] },
|
||||
];
|
||||
|
||||
var libraryTargets = librarySourceMap.map(function (f) {
|
||||
@ -360,7 +369,7 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca
|
||||
// Create the node definition file by replacing 'ts' module with '"typescript"' as a module.
|
||||
jake.cpR(standaloneDefinitionsFile, nodeDefinitionsFile, {silent: true});
|
||||
var definitionFileContents = fs.readFileSync(nodeDefinitionsFile).toString();
|
||||
definitionFileContents = definitionFileContents.replace(/declare module ts/g, 'declare module "typescript"');
|
||||
definitionFileContents = definitionFileContents.replace(/declare (namespace|module) ts/g, 'declare module "typescript"');
|
||||
fs.writeFileSync(nodeDefinitionsFile, definitionFileContents);
|
||||
});
|
||||
|
||||
@ -368,6 +377,20 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca
|
||||
var serverFile = path.join(builtLocalDirectory, "tsserver.js");
|
||||
compileFile(serverFile, serverSources,[builtLocalDirectory, copyright].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true);
|
||||
|
||||
var lsslFile = path.join(builtLocalDirectory, "tslssl.js");
|
||||
compileFile(
|
||||
lsslFile,
|
||||
languageServiceLibrarySources,
|
||||
[builtLocalDirectory, copyright].concat(languageServiceLibrarySources),
|
||||
/*prefixes*/ [copyright],
|
||||
/*useBuiltCompiler*/ true,
|
||||
/*noOutFile*/ false,
|
||||
/*generateDeclarations*/ true);
|
||||
|
||||
// Local target to build the language service server library
|
||||
desc("Builds language service server library");
|
||||
task("lssl", [lsslFile]);
|
||||
|
||||
// Local target to build the compiler and services
|
||||
desc("Builds the full compiler and services");
|
||||
task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile]);
|
||||
@ -504,9 +527,9 @@ function cleanTestDirs() {
|
||||
}
|
||||
|
||||
// used to pass data from jake command line directly to run.js
|
||||
function writeTestConfigFile(tests, testConfigFile) {
|
||||
function writeTestConfigFile(tests, light, testConfigFile) {
|
||||
console.log('Running test(s): ' + tests);
|
||||
var testConfigContents = '{\n' + '\ttest: [\'' + tests + '\']\n}';
|
||||
var testConfigContents = JSON.stringify({ test: [tests], light: light });
|
||||
fs.writeFileSync('test.config', testConfigContents);
|
||||
}
|
||||
|
||||
@ -522,13 +545,14 @@ task("runtests", ["tests", builtLocalDirectory], function() {
|
||||
cleanTestDirs();
|
||||
host = "mocha"
|
||||
tests = process.env.test || process.env.tests || process.env.t;
|
||||
var light = process.env.light || false;
|
||||
var testConfigFile = 'test.config';
|
||||
if(fs.existsSync(testConfigFile)) {
|
||||
fs.unlinkSync(testConfigFile);
|
||||
}
|
||||
|
||||
if(tests) {
|
||||
writeTestConfigFile(tests, testConfigFile);
|
||||
if(tests || light) {
|
||||
writeTestConfigFile(tests, light, testConfigFile);
|
||||
}
|
||||
|
||||
if (tests && tests.toLocaleLowerCase() === "rwc") {
|
||||
@ -571,12 +595,13 @@ task("runtests-browser", ["tests", "browserify", builtLocalDirectory], function(
|
||||
port = process.env.port || process.env.p || '8888';
|
||||
browser = process.env.browser || process.env.b || "IE";
|
||||
tests = process.env.test || process.env.tests || process.env.t;
|
||||
var light = process.env.light || false;
|
||||
var testConfigFile = 'test.config';
|
||||
if(fs.existsSync(testConfigFile)) {
|
||||
fs.unlinkSync(testConfigFile);
|
||||
}
|
||||
if(tests) {
|
||||
writeTestConfigFile(tests, testConfigFile);
|
||||
if(tests || light) {
|
||||
writeTestConfigFile(tests, light, testConfigFile);
|
||||
}
|
||||
|
||||
tests = tests ? tests : '';
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
[](https://npmjs.org/package/typescript)
|
||||
|
||||
# TypeScript
|
||||
|
||||
[](https://gitter.im/Microsoft/TypeScript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
[](https://gitter.im/Microsoft/TypeScript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
[TypeScript](http://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types, classes, and modules to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](http://www.typescriptlang.org/Playground), and stay up to date via [our blog](http://blogs.msdn.com/typescript) and [twitter account](https://twitter.com/typescriptlang).
|
||||
|
||||
@ -31,7 +31,7 @@ There are many ways to [contribute](https://github.com/Microsoft/TypeScript/blob
|
||||
|
||||
## Building
|
||||
|
||||
In order to build the TypeScript compiler, ensure that you have [Git](http://git-scm.com/downloads) and [Node.js](http://nodejs.org/) installed. Note that you need to have autocrlf off as we track whitespace changes (`git config --global core.autocrlf false`).
|
||||
In order to build the TypeScript compiler, ensure that you have [Git](http://git-scm.com/downloads) and [Node.js](http://nodejs.org/) installed.
|
||||
|
||||
Clone a copy of the repo:
|
||||
|
||||
|
||||
2
bin/lib.core.d.ts
vendored
2
bin/lib.core.d.ts
vendored
@ -1165,7 +1165,7 @@ interface ArrayConstructor {
|
||||
(arrayLength?: number): any[];
|
||||
<T>(arrayLength: number): T[];
|
||||
<T>(...items: T[]): T[];
|
||||
isArray(arg: any): boolean;
|
||||
isArray(arg: any): arg is Array<any>;
|
||||
prototype: Array<any>;
|
||||
}
|
||||
|
||||
|
||||
15
bin/lib.core.es6.d.ts
vendored
15
bin/lib.core.es6.d.ts
vendored
@ -1165,7 +1165,7 @@ interface ArrayConstructor {
|
||||
(arrayLength?: number): any[];
|
||||
<T>(arrayLength: number): T[];
|
||||
<T>(...items: T[]): T[];
|
||||
isArray(arg: any): boolean;
|
||||
isArray(arg: any): arg is Array<any>;
|
||||
prototype: Array<any>;
|
||||
}
|
||||
|
||||
@ -1502,6 +1502,11 @@ interface Array<T> {
|
||||
copyWithin(target: number, start: number, end?: number): T[];
|
||||
}
|
||||
|
||||
interface IArguments {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<any>;
|
||||
}
|
||||
|
||||
interface ArrayConstructor {
|
||||
/**
|
||||
* Creates an array from an array-like object.
|
||||
@ -1686,14 +1691,6 @@ interface GeneratorFunctionConstructor {
|
||||
}
|
||||
declare var GeneratorFunction: GeneratorFunctionConstructor;
|
||||
|
||||
interface Generator<T> extends IterableIterator<T> {
|
||||
next(value?: any): IteratorResult<T>;
|
||||
throw(exception: any): IteratorResult<T>;
|
||||
return(value: T): IteratorResult<T>;
|
||||
[Symbol.iterator](): Generator<T>;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface Math {
|
||||
/**
|
||||
* Returns the number of leading zero bits in the 32-bit binary representation of a number.
|
||||
|
||||
45
bin/lib.d.ts
vendored
45
bin/lib.d.ts
vendored
@ -1165,7 +1165,7 @@ interface ArrayConstructor {
|
||||
(arrayLength?: number): any[];
|
||||
<T>(arrayLength: number): T[];
|
||||
<T>(...items: T[]): T[];
|
||||
isArray(arg: any): boolean;
|
||||
isArray(arg: any): arg is Array<any>;
|
||||
prototype: Array<any>;
|
||||
}
|
||||
|
||||
@ -3531,6 +3531,11 @@ declare module Intl {
|
||||
currency?: string;
|
||||
currencyDisplay?: string;
|
||||
useGrouping?: boolean;
|
||||
minimumintegerDigits?: number;
|
||||
minimumFractionDigits?: number;
|
||||
maximumFractionDigits?: number;
|
||||
minimumSignificantDigits?: number;
|
||||
maximumSignificantDigits?: number;
|
||||
}
|
||||
|
||||
interface ResolvedNumberFormatOptions {
|
||||
@ -3552,10 +3557,10 @@ declare module Intl {
|
||||
resolvedOptions(): ResolvedNumberFormatOptions;
|
||||
}
|
||||
var NumberFormat: {
|
||||
new (locales?: string[], options?: NumberFormatOptions): Collator;
|
||||
new (locale?: string, options?: NumberFormatOptions): Collator;
|
||||
(locales?: string[], options?: NumberFormatOptions): Collator;
|
||||
(locale?: string, options?: NumberFormatOptions): Collator;
|
||||
new (locales?: string[], options?: NumberFormatOptions): NumberFormat;
|
||||
new (locale?: string, options?: NumberFormatOptions): NumberFormat;
|
||||
(locales?: string[], options?: NumberFormatOptions): NumberFormat;
|
||||
(locale?: string, options?: NumberFormatOptions): NumberFormat;
|
||||
supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[];
|
||||
supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[];
|
||||
}
|
||||
@ -3593,14 +3598,14 @@ declare module Intl {
|
||||
}
|
||||
|
||||
interface DateTimeFormat {
|
||||
format(date: number): string;
|
||||
format(date?: Date | number): string;
|
||||
resolvedOptions(): ResolvedDateTimeFormatOptions;
|
||||
}
|
||||
var DateTimeFormat: {
|
||||
new (locales?: string[], options?: DateTimeFormatOptions): Collator;
|
||||
new (locale?: string, options?: DateTimeFormatOptions): Collator;
|
||||
(locales?: string[], options?: DateTimeFormatOptions): Collator;
|
||||
(locale?: string, options?: DateTimeFormatOptions): Collator;
|
||||
new (locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat;
|
||||
new (locale?: string, options?: DateTimeFormatOptions): DateTimeFormat;
|
||||
(locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat;
|
||||
(locale?: string, options?: DateTimeFormatOptions): DateTimeFormat;
|
||||
supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[];
|
||||
supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[];
|
||||
}
|
||||
@ -11335,10 +11340,10 @@ declare var MediaQueryList: {
|
||||
interface MediaSource extends EventTarget {
|
||||
activeSourceBuffers: SourceBufferList;
|
||||
duration: number;
|
||||
readyState: string;
|
||||
readyState: number;
|
||||
sourceBuffers: SourceBufferList;
|
||||
addSourceBuffer(type: string): SourceBuffer;
|
||||
endOfStream(error?: string): void;
|
||||
endOfStream(error?: number): void;
|
||||
removeSourceBuffer(sourceBuffer: SourceBuffer): void;
|
||||
}
|
||||
|
||||
@ -12067,7 +12072,7 @@ declare var PopStateEvent: {
|
||||
|
||||
interface Position {
|
||||
coords: Coordinates;
|
||||
timestamp: Date;
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
declare var Position: {
|
||||
@ -14748,9 +14753,17 @@ interface WebGLRenderingContext {
|
||||
stencilMaskSeparate(face: number, mask: number): void;
|
||||
stencilOp(fail: number, zfail: number, zpass: number): void;
|
||||
stencilOpSeparate(face: number, fail: number, zfail: number, zpass: number): void;
|
||||
texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels: ArrayBufferView): void;
|
||||
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, image: HTMLImageElement): void;
|
||||
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, canvas: HTMLCanvasElement): void;
|
||||
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, video: HTMLVideoElement): void;
|
||||
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageData): void;
|
||||
texParameterf(target: number, pname: number, param: number): void;
|
||||
texParameteri(target: number, pname: number, param: number): void;
|
||||
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void;
|
||||
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, image: HTMLImageElement): void;
|
||||
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, canvas: HTMLCanvasElement): void;
|
||||
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, video: HTMLVideoElement): void;
|
||||
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageData): void;
|
||||
uniform1f(location: WebGLUniformLocation, x: number): void;
|
||||
uniform1fv(location: WebGLUniformLocation, v: any): void;
|
||||
@ -15990,10 +16003,11 @@ interface DocumentEvent {
|
||||
createEvent(eventInterface:"AriaRequestEvent"): AriaRequestEvent;
|
||||
createEvent(eventInterface:"AudioProcessingEvent"): AudioProcessingEvent;
|
||||
createEvent(eventInterface:"BeforeUnloadEvent"): BeforeUnloadEvent;
|
||||
createEvent(eventInterface:"ClipboardEvent"): ClipboardEvent;
|
||||
createEvent(eventInterface:"CloseEvent"): CloseEvent;
|
||||
createEvent(eventInterface:"CommandEvent"): CommandEvent;
|
||||
createEvent(eventInterface:"CompositionEvent"): CompositionEvent;
|
||||
createEvent(eventInterface: "CustomEvent"): CustomEvent;
|
||||
createEvent(eventInterface:"CustomEvent"): CustomEvent;
|
||||
createEvent(eventInterface:"DeviceMotionEvent"): DeviceMotionEvent;
|
||||
createEvent(eventInterface:"DeviceOrientationEvent"): DeviceOrientationEvent;
|
||||
createEvent(eventInterface:"DragEvent"): DragEvent;
|
||||
@ -16016,8 +16030,6 @@ interface DocumentEvent {
|
||||
createEvent(eventInterface:"MouseEvent"): MouseEvent;
|
||||
createEvent(eventInterface:"MouseEvents"): MouseEvent;
|
||||
createEvent(eventInterface:"MouseWheelEvent"): MouseWheelEvent;
|
||||
createEvent(eventInterface:"MSGestureEvent"): MSGestureEvent;
|
||||
createEvent(eventInterface:"MSPointerEvent"): MSPointerEvent;
|
||||
createEvent(eventInterface:"MutationEvent"): MutationEvent;
|
||||
createEvent(eventInterface:"MutationEvents"): MutationEvent;
|
||||
createEvent(eventInterface:"NavigationCompletedEvent"): NavigationCompletedEvent;
|
||||
@ -16630,6 +16642,7 @@ declare function addEventListener(type: "volumechange", listener: (ev: Event) =>
|
||||
declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
|
||||
/////////////////////////////
|
||||
/// WorkerGlobalScope APIs
|
||||
/////////////////////////////
|
||||
|
||||
44
bin/lib.dom.d.ts
vendored
44
bin/lib.dom.d.ts
vendored
@ -2361,6 +2361,11 @@ declare module Intl {
|
||||
currency?: string;
|
||||
currencyDisplay?: string;
|
||||
useGrouping?: boolean;
|
||||
minimumintegerDigits?: number;
|
||||
minimumFractionDigits?: number;
|
||||
maximumFractionDigits?: number;
|
||||
minimumSignificantDigits?: number;
|
||||
maximumSignificantDigits?: number;
|
||||
}
|
||||
|
||||
interface ResolvedNumberFormatOptions {
|
||||
@ -2382,10 +2387,10 @@ declare module Intl {
|
||||
resolvedOptions(): ResolvedNumberFormatOptions;
|
||||
}
|
||||
var NumberFormat: {
|
||||
new (locales?: string[], options?: NumberFormatOptions): Collator;
|
||||
new (locale?: string, options?: NumberFormatOptions): Collator;
|
||||
(locales?: string[], options?: NumberFormatOptions): Collator;
|
||||
(locale?: string, options?: NumberFormatOptions): Collator;
|
||||
new (locales?: string[], options?: NumberFormatOptions): NumberFormat;
|
||||
new (locale?: string, options?: NumberFormatOptions): NumberFormat;
|
||||
(locales?: string[], options?: NumberFormatOptions): NumberFormat;
|
||||
(locale?: string, options?: NumberFormatOptions): NumberFormat;
|
||||
supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[];
|
||||
supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[];
|
||||
}
|
||||
@ -2423,14 +2428,14 @@ declare module Intl {
|
||||
}
|
||||
|
||||
interface DateTimeFormat {
|
||||
format(date: number): string;
|
||||
format(date?: Date | number): string;
|
||||
resolvedOptions(): ResolvedDateTimeFormatOptions;
|
||||
}
|
||||
var DateTimeFormat: {
|
||||
new (locales?: string[], options?: DateTimeFormatOptions): Collator;
|
||||
new (locale?: string, options?: DateTimeFormatOptions): Collator;
|
||||
(locales?: string[], options?: DateTimeFormatOptions): Collator;
|
||||
(locale?: string, options?: DateTimeFormatOptions): Collator;
|
||||
new (locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat;
|
||||
new (locale?: string, options?: DateTimeFormatOptions): DateTimeFormat;
|
||||
(locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat;
|
||||
(locale?: string, options?: DateTimeFormatOptions): DateTimeFormat;
|
||||
supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[];
|
||||
supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[];
|
||||
}
|
||||
@ -10165,10 +10170,10 @@ declare var MediaQueryList: {
|
||||
interface MediaSource extends EventTarget {
|
||||
activeSourceBuffers: SourceBufferList;
|
||||
duration: number;
|
||||
readyState: string;
|
||||
readyState: number;
|
||||
sourceBuffers: SourceBufferList;
|
||||
addSourceBuffer(type: string): SourceBuffer;
|
||||
endOfStream(error?: string): void;
|
||||
endOfStream(error?: number): void;
|
||||
removeSourceBuffer(sourceBuffer: SourceBuffer): void;
|
||||
}
|
||||
|
||||
@ -10897,7 +10902,7 @@ declare var PopStateEvent: {
|
||||
|
||||
interface Position {
|
||||
coords: Coordinates;
|
||||
timestamp: Date;
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
declare var Position: {
|
||||
@ -13578,9 +13583,17 @@ interface WebGLRenderingContext {
|
||||
stencilMaskSeparate(face: number, mask: number): void;
|
||||
stencilOp(fail: number, zfail: number, zpass: number): void;
|
||||
stencilOpSeparate(face: number, fail: number, zfail: number, zpass: number): void;
|
||||
texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels: ArrayBufferView): void;
|
||||
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, image: HTMLImageElement): void;
|
||||
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, canvas: HTMLCanvasElement): void;
|
||||
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, video: HTMLVideoElement): void;
|
||||
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageData): void;
|
||||
texParameterf(target: number, pname: number, param: number): void;
|
||||
texParameteri(target: number, pname: number, param: number): void;
|
||||
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void;
|
||||
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, image: HTMLImageElement): void;
|
||||
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, canvas: HTMLCanvasElement): void;
|
||||
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, video: HTMLVideoElement): void;
|
||||
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageData): void;
|
||||
uniform1f(location: WebGLUniformLocation, x: number): void;
|
||||
uniform1fv(location: WebGLUniformLocation, v: any): void;
|
||||
@ -14820,10 +14833,11 @@ interface DocumentEvent {
|
||||
createEvent(eventInterface:"AriaRequestEvent"): AriaRequestEvent;
|
||||
createEvent(eventInterface:"AudioProcessingEvent"): AudioProcessingEvent;
|
||||
createEvent(eventInterface:"BeforeUnloadEvent"): BeforeUnloadEvent;
|
||||
createEvent(eventInterface:"ClipboardEvent"): ClipboardEvent;
|
||||
createEvent(eventInterface:"CloseEvent"): CloseEvent;
|
||||
createEvent(eventInterface:"CommandEvent"): CommandEvent;
|
||||
createEvent(eventInterface:"CompositionEvent"): CompositionEvent;
|
||||
createEvent(eventInterface: "CustomEvent"): CustomEvent;
|
||||
createEvent(eventInterface:"CustomEvent"): CustomEvent;
|
||||
createEvent(eventInterface:"DeviceMotionEvent"): DeviceMotionEvent;
|
||||
createEvent(eventInterface:"DeviceOrientationEvent"): DeviceOrientationEvent;
|
||||
createEvent(eventInterface:"DragEvent"): DragEvent;
|
||||
@ -14846,8 +14860,6 @@ interface DocumentEvent {
|
||||
createEvent(eventInterface:"MouseEvent"): MouseEvent;
|
||||
createEvent(eventInterface:"MouseEvents"): MouseEvent;
|
||||
createEvent(eventInterface:"MouseWheelEvent"): MouseWheelEvent;
|
||||
createEvent(eventInterface:"MSGestureEvent"): MSGestureEvent;
|
||||
createEvent(eventInterface:"MSPointerEvent"): MSPointerEvent;
|
||||
createEvent(eventInterface:"MutationEvent"): MutationEvent;
|
||||
createEvent(eventInterface:"MutationEvents"): MutationEvent;
|
||||
createEvent(eventInterface:"NavigationCompletedEvent"): NavigationCompletedEvent;
|
||||
@ -15459,4 +15471,4 @@ declare function addEventListener(type: "unload", listener: (ev: Event) => any,
|
||||
declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
|
||||
68
bin/lib.es6.d.ts
vendored
68
bin/lib.es6.d.ts
vendored
@ -1165,7 +1165,7 @@ interface ArrayConstructor {
|
||||
(arrayLength?: number): any[];
|
||||
<T>(arrayLength: number): T[];
|
||||
<T>(...items: T[]): T[];
|
||||
isArray(arg: any): boolean;
|
||||
isArray(arg: any): arg is Array<any>;
|
||||
prototype: Array<any>;
|
||||
}
|
||||
|
||||
@ -1502,6 +1502,11 @@ interface Array<T> {
|
||||
copyWithin(target: number, start: number, end?: number): T[];
|
||||
}
|
||||
|
||||
interface IArguments {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<any>;
|
||||
}
|
||||
|
||||
interface ArrayConstructor {
|
||||
/**
|
||||
* Creates an array from an array-like object.
|
||||
@ -1686,14 +1691,6 @@ interface GeneratorFunctionConstructor {
|
||||
}
|
||||
declare var GeneratorFunction: GeneratorFunctionConstructor;
|
||||
|
||||
interface Generator<T> extends IterableIterator<T> {
|
||||
next(value?: any): IteratorResult<T>;
|
||||
throw(exception: any): IteratorResult<T>;
|
||||
return(value: T): IteratorResult<T>;
|
||||
[Symbol.iterator](): Generator<T>;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface Math {
|
||||
/**
|
||||
* Returns the number of leading zero bits in the 32-bit binary representation of a number.
|
||||
@ -4912,6 +4909,11 @@ declare module Intl {
|
||||
currency?: string;
|
||||
currencyDisplay?: string;
|
||||
useGrouping?: boolean;
|
||||
minimumintegerDigits?: number;
|
||||
minimumFractionDigits?: number;
|
||||
maximumFractionDigits?: number;
|
||||
minimumSignificantDigits?: number;
|
||||
maximumSignificantDigits?: number;
|
||||
}
|
||||
|
||||
interface ResolvedNumberFormatOptions {
|
||||
@ -4933,10 +4935,10 @@ declare module Intl {
|
||||
resolvedOptions(): ResolvedNumberFormatOptions;
|
||||
}
|
||||
var NumberFormat: {
|
||||
new (locales?: string[], options?: NumberFormatOptions): Collator;
|
||||
new (locale?: string, options?: NumberFormatOptions): Collator;
|
||||
(locales?: string[], options?: NumberFormatOptions): Collator;
|
||||
(locale?: string, options?: NumberFormatOptions): Collator;
|
||||
new (locales?: string[], options?: NumberFormatOptions): NumberFormat;
|
||||
new (locale?: string, options?: NumberFormatOptions): NumberFormat;
|
||||
(locales?: string[], options?: NumberFormatOptions): NumberFormat;
|
||||
(locale?: string, options?: NumberFormatOptions): NumberFormat;
|
||||
supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[];
|
||||
supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[];
|
||||
}
|
||||
@ -4974,14 +4976,14 @@ declare module Intl {
|
||||
}
|
||||
|
||||
interface DateTimeFormat {
|
||||
format(date: number): string;
|
||||
format(date?: Date | number): string;
|
||||
resolvedOptions(): ResolvedDateTimeFormatOptions;
|
||||
}
|
||||
var DateTimeFormat: {
|
||||
new (locales?: string[], options?: DateTimeFormatOptions): Collator;
|
||||
new (locale?: string, options?: DateTimeFormatOptions): Collator;
|
||||
(locales?: string[], options?: DateTimeFormatOptions): Collator;
|
||||
(locale?: string, options?: DateTimeFormatOptions): Collator;
|
||||
new (locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat;
|
||||
new (locale?: string, options?: DateTimeFormatOptions): DateTimeFormat;
|
||||
(locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat;
|
||||
(locale?: string, options?: DateTimeFormatOptions): DateTimeFormat;
|
||||
supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[];
|
||||
supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[];
|
||||
}
|
||||
@ -12716,10 +12718,10 @@ declare var MediaQueryList: {
|
||||
interface MediaSource extends EventTarget {
|
||||
activeSourceBuffers: SourceBufferList;
|
||||
duration: number;
|
||||
readyState: string;
|
||||
readyState: number;
|
||||
sourceBuffers: SourceBufferList;
|
||||
addSourceBuffer(type: string): SourceBuffer;
|
||||
endOfStream(error?: string): void;
|
||||
endOfStream(error?: number): void;
|
||||
removeSourceBuffer(sourceBuffer: SourceBuffer): void;
|
||||
}
|
||||
|
||||
@ -13448,7 +13450,7 @@ declare var PopStateEvent: {
|
||||
|
||||
interface Position {
|
||||
coords: Coordinates;
|
||||
timestamp: Date;
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
declare var Position: {
|
||||
@ -16129,9 +16131,17 @@ interface WebGLRenderingContext {
|
||||
stencilMaskSeparate(face: number, mask: number): void;
|
||||
stencilOp(fail: number, zfail: number, zpass: number): void;
|
||||
stencilOpSeparate(face: number, fail: number, zfail: number, zpass: number): void;
|
||||
texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels: ArrayBufferView): void;
|
||||
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, image: HTMLImageElement): void;
|
||||
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, canvas: HTMLCanvasElement): void;
|
||||
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, video: HTMLVideoElement): void;
|
||||
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageData): void;
|
||||
texParameterf(target: number, pname: number, param: number): void;
|
||||
texParameteri(target: number, pname: number, param: number): void;
|
||||
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void;
|
||||
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, image: HTMLImageElement): void;
|
||||
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, canvas: HTMLCanvasElement): void;
|
||||
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, video: HTMLVideoElement): void;
|
||||
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageData): void;
|
||||
uniform1f(location: WebGLUniformLocation, x: number): void;
|
||||
uniform1fv(location: WebGLUniformLocation, v: any): void;
|
||||
@ -17371,10 +17381,11 @@ interface DocumentEvent {
|
||||
createEvent(eventInterface:"AriaRequestEvent"): AriaRequestEvent;
|
||||
createEvent(eventInterface:"AudioProcessingEvent"): AudioProcessingEvent;
|
||||
createEvent(eventInterface:"BeforeUnloadEvent"): BeforeUnloadEvent;
|
||||
createEvent(eventInterface:"ClipboardEvent"): ClipboardEvent;
|
||||
createEvent(eventInterface:"CloseEvent"): CloseEvent;
|
||||
createEvent(eventInterface:"CommandEvent"): CommandEvent;
|
||||
createEvent(eventInterface:"CompositionEvent"): CompositionEvent;
|
||||
createEvent(eventInterface: "CustomEvent"): CustomEvent;
|
||||
createEvent(eventInterface:"CustomEvent"): CustomEvent;
|
||||
createEvent(eventInterface:"DeviceMotionEvent"): DeviceMotionEvent;
|
||||
createEvent(eventInterface:"DeviceOrientationEvent"): DeviceOrientationEvent;
|
||||
createEvent(eventInterface:"DragEvent"): DragEvent;
|
||||
@ -17397,8 +17408,6 @@ interface DocumentEvent {
|
||||
createEvent(eventInterface:"MouseEvent"): MouseEvent;
|
||||
createEvent(eventInterface:"MouseEvents"): MouseEvent;
|
||||
createEvent(eventInterface:"MouseWheelEvent"): MouseWheelEvent;
|
||||
createEvent(eventInterface:"MSGestureEvent"): MSGestureEvent;
|
||||
createEvent(eventInterface:"MSPointerEvent"): MSPointerEvent;
|
||||
createEvent(eventInterface:"MutationEvent"): MutationEvent;
|
||||
createEvent(eventInterface:"MutationEvents"): MutationEvent;
|
||||
createEvent(eventInterface:"NavigationCompletedEvent"): NavigationCompletedEvent;
|
||||
@ -18011,6 +18020,17 @@ declare function addEventListener(type: "volumechange", listener: (ev: Event) =>
|
||||
declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
interface DOMTokenList {
|
||||
[Symbol.iterator](): IterableIterator<string>;
|
||||
}
|
||||
|
||||
interface NodeList {
|
||||
[Symbol.iterator](): IterableIterator<Node>
|
||||
}
|
||||
|
||||
interface NodeListOf<TNode extends Node> {
|
||||
[Symbol.iterator](): IterableIterator<TNode>
|
||||
}
|
||||
/////////////////////////////
|
||||
/// WorkerGlobalScope APIs
|
||||
/////////////////////////////
|
||||
|
||||
23
bin/lib.webworker.d.ts
vendored
23
bin/lib.webworker.d.ts
vendored
@ -2361,6 +2361,11 @@ declare module Intl {
|
||||
currency?: string;
|
||||
currencyDisplay?: string;
|
||||
useGrouping?: boolean;
|
||||
minimumintegerDigits?: number;
|
||||
minimumFractionDigits?: number;
|
||||
maximumFractionDigits?: number;
|
||||
minimumSignificantDigits?: number;
|
||||
maximumSignificantDigits?: number;
|
||||
}
|
||||
|
||||
interface ResolvedNumberFormatOptions {
|
||||
@ -2382,10 +2387,10 @@ declare module Intl {
|
||||
resolvedOptions(): ResolvedNumberFormatOptions;
|
||||
}
|
||||
var NumberFormat: {
|
||||
new (locales?: string[], options?: NumberFormatOptions): Collator;
|
||||
new (locale?: string, options?: NumberFormatOptions): Collator;
|
||||
(locales?: string[], options?: NumberFormatOptions): Collator;
|
||||
(locale?: string, options?: NumberFormatOptions): Collator;
|
||||
new (locales?: string[], options?: NumberFormatOptions): NumberFormat;
|
||||
new (locale?: string, options?: NumberFormatOptions): NumberFormat;
|
||||
(locales?: string[], options?: NumberFormatOptions): NumberFormat;
|
||||
(locale?: string, options?: NumberFormatOptions): NumberFormat;
|
||||
supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[];
|
||||
supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[];
|
||||
}
|
||||
@ -2423,14 +2428,14 @@ declare module Intl {
|
||||
}
|
||||
|
||||
interface DateTimeFormat {
|
||||
format(date: number): string;
|
||||
format(date?: Date | number): string;
|
||||
resolvedOptions(): ResolvedDateTimeFormatOptions;
|
||||
}
|
||||
var DateTimeFormat: {
|
||||
new (locales?: string[], options?: DateTimeFormatOptions): Collator;
|
||||
new (locale?: string, options?: DateTimeFormatOptions): Collator;
|
||||
(locales?: string[], options?: DateTimeFormatOptions): Collator;
|
||||
(locale?: string, options?: DateTimeFormatOptions): Collator;
|
||||
new (locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat;
|
||||
new (locale?: string, options?: DateTimeFormatOptions): DateTimeFormat;
|
||||
(locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat;
|
||||
(locale?: string, options?: DateTimeFormatOptions): DateTimeFormat;
|
||||
supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[];
|
||||
supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[];
|
||||
}
|
||||
|
||||
8600
bin/tsc.js
8600
bin/tsc.js
File diff suppressed because it is too large
Load Diff
10554
bin/tsserver.js
10554
bin/tsserver.js
File diff suppressed because it is too large
Load Diff
435
bin/typescript.d.ts
vendored
435
bin/typescript.d.ts
vendored
@ -17,6 +17,13 @@ declare module "typescript" {
|
||||
interface Map<T> {
|
||||
[index: string]: T;
|
||||
}
|
||||
interface FileMap<T> {
|
||||
get(fileName: string): T;
|
||||
set(fileName: string, value: T): void;
|
||||
contains(fileName: string): boolean;
|
||||
remove(fileName: string): void;
|
||||
forEachValue(f: (v: T) => void): void;
|
||||
}
|
||||
interface TextRange {
|
||||
pos: number;
|
||||
end: number;
|
||||
@ -139,134 +146,158 @@ declare module "typescript" {
|
||||
ConstructorKeyword = 114,
|
||||
DeclareKeyword = 115,
|
||||
GetKeyword = 116,
|
||||
ModuleKeyword = 117,
|
||||
NamespaceKeyword = 118,
|
||||
RequireKeyword = 119,
|
||||
NumberKeyword = 120,
|
||||
SetKeyword = 121,
|
||||
StringKeyword = 122,
|
||||
SymbolKeyword = 123,
|
||||
TypeKeyword = 124,
|
||||
FromKeyword = 125,
|
||||
OfKeyword = 126,
|
||||
QualifiedName = 127,
|
||||
ComputedPropertyName = 128,
|
||||
TypeParameter = 129,
|
||||
Parameter = 130,
|
||||
Decorator = 131,
|
||||
PropertySignature = 132,
|
||||
PropertyDeclaration = 133,
|
||||
MethodSignature = 134,
|
||||
MethodDeclaration = 135,
|
||||
Constructor = 136,
|
||||
GetAccessor = 137,
|
||||
SetAccessor = 138,
|
||||
CallSignature = 139,
|
||||
ConstructSignature = 140,
|
||||
IndexSignature = 141,
|
||||
TypeReference = 142,
|
||||
FunctionType = 143,
|
||||
ConstructorType = 144,
|
||||
TypeQuery = 145,
|
||||
TypeLiteral = 146,
|
||||
ArrayType = 147,
|
||||
TupleType = 148,
|
||||
UnionType = 149,
|
||||
ParenthesizedType = 150,
|
||||
ObjectBindingPattern = 151,
|
||||
ArrayBindingPattern = 152,
|
||||
BindingElement = 153,
|
||||
ArrayLiteralExpression = 154,
|
||||
ObjectLiteralExpression = 155,
|
||||
PropertyAccessExpression = 156,
|
||||
ElementAccessExpression = 157,
|
||||
CallExpression = 158,
|
||||
NewExpression = 159,
|
||||
TaggedTemplateExpression = 160,
|
||||
TypeAssertionExpression = 161,
|
||||
ParenthesizedExpression = 162,
|
||||
FunctionExpression = 163,
|
||||
ArrowFunction = 164,
|
||||
DeleteExpression = 165,
|
||||
TypeOfExpression = 166,
|
||||
VoidExpression = 167,
|
||||
PrefixUnaryExpression = 168,
|
||||
PostfixUnaryExpression = 169,
|
||||
BinaryExpression = 170,
|
||||
ConditionalExpression = 171,
|
||||
TemplateExpression = 172,
|
||||
YieldExpression = 173,
|
||||
SpreadElementExpression = 174,
|
||||
ClassExpression = 175,
|
||||
OmittedExpression = 176,
|
||||
ExpressionWithTypeArguments = 177,
|
||||
TemplateSpan = 178,
|
||||
SemicolonClassElement = 179,
|
||||
Block = 180,
|
||||
VariableStatement = 181,
|
||||
EmptyStatement = 182,
|
||||
ExpressionStatement = 183,
|
||||
IfStatement = 184,
|
||||
DoStatement = 185,
|
||||
WhileStatement = 186,
|
||||
ForStatement = 187,
|
||||
ForInStatement = 188,
|
||||
ForOfStatement = 189,
|
||||
ContinueStatement = 190,
|
||||
BreakStatement = 191,
|
||||
ReturnStatement = 192,
|
||||
WithStatement = 193,
|
||||
SwitchStatement = 194,
|
||||
LabeledStatement = 195,
|
||||
ThrowStatement = 196,
|
||||
TryStatement = 197,
|
||||
DebuggerStatement = 198,
|
||||
VariableDeclaration = 199,
|
||||
VariableDeclarationList = 200,
|
||||
FunctionDeclaration = 201,
|
||||
ClassDeclaration = 202,
|
||||
InterfaceDeclaration = 203,
|
||||
TypeAliasDeclaration = 204,
|
||||
EnumDeclaration = 205,
|
||||
ModuleDeclaration = 206,
|
||||
ModuleBlock = 207,
|
||||
CaseBlock = 208,
|
||||
ImportEqualsDeclaration = 209,
|
||||
ImportDeclaration = 210,
|
||||
ImportClause = 211,
|
||||
NamespaceImport = 212,
|
||||
NamedImports = 213,
|
||||
ImportSpecifier = 214,
|
||||
ExportAssignment = 215,
|
||||
ExportDeclaration = 216,
|
||||
NamedExports = 217,
|
||||
ExportSpecifier = 218,
|
||||
MissingDeclaration = 219,
|
||||
ExternalModuleReference = 220,
|
||||
CaseClause = 221,
|
||||
DefaultClause = 222,
|
||||
HeritageClause = 223,
|
||||
CatchClause = 224,
|
||||
PropertyAssignment = 225,
|
||||
ShorthandPropertyAssignment = 226,
|
||||
EnumMember = 227,
|
||||
SourceFile = 228,
|
||||
SyntaxList = 229,
|
||||
Count = 230,
|
||||
IsKeyword = 117,
|
||||
ModuleKeyword = 118,
|
||||
NamespaceKeyword = 119,
|
||||
RequireKeyword = 120,
|
||||
NumberKeyword = 121,
|
||||
SetKeyword = 122,
|
||||
StringKeyword = 123,
|
||||
SymbolKeyword = 124,
|
||||
TypeKeyword = 125,
|
||||
FromKeyword = 126,
|
||||
OfKeyword = 127,
|
||||
QualifiedName = 128,
|
||||
ComputedPropertyName = 129,
|
||||
TypeParameter = 130,
|
||||
Parameter = 131,
|
||||
Decorator = 132,
|
||||
PropertySignature = 133,
|
||||
PropertyDeclaration = 134,
|
||||
MethodSignature = 135,
|
||||
MethodDeclaration = 136,
|
||||
Constructor = 137,
|
||||
GetAccessor = 138,
|
||||
SetAccessor = 139,
|
||||
CallSignature = 140,
|
||||
ConstructSignature = 141,
|
||||
IndexSignature = 142,
|
||||
TypePredicate = 143,
|
||||
TypeReference = 144,
|
||||
FunctionType = 145,
|
||||
ConstructorType = 146,
|
||||
TypeQuery = 147,
|
||||
TypeLiteral = 148,
|
||||
ArrayType = 149,
|
||||
TupleType = 150,
|
||||
UnionType = 151,
|
||||
ParenthesizedType = 152,
|
||||
ObjectBindingPattern = 153,
|
||||
ArrayBindingPattern = 154,
|
||||
BindingElement = 155,
|
||||
ArrayLiteralExpression = 156,
|
||||
ObjectLiteralExpression = 157,
|
||||
PropertyAccessExpression = 158,
|
||||
ElementAccessExpression = 159,
|
||||
CallExpression = 160,
|
||||
NewExpression = 161,
|
||||
TaggedTemplateExpression = 162,
|
||||
TypeAssertionExpression = 163,
|
||||
ParenthesizedExpression = 164,
|
||||
FunctionExpression = 165,
|
||||
ArrowFunction = 166,
|
||||
DeleteExpression = 167,
|
||||
TypeOfExpression = 168,
|
||||
VoidExpression = 169,
|
||||
PrefixUnaryExpression = 170,
|
||||
PostfixUnaryExpression = 171,
|
||||
BinaryExpression = 172,
|
||||
ConditionalExpression = 173,
|
||||
TemplateExpression = 174,
|
||||
YieldExpression = 175,
|
||||
SpreadElementExpression = 176,
|
||||
ClassExpression = 177,
|
||||
OmittedExpression = 178,
|
||||
ExpressionWithTypeArguments = 179,
|
||||
TemplateSpan = 180,
|
||||
SemicolonClassElement = 181,
|
||||
Block = 182,
|
||||
VariableStatement = 183,
|
||||
EmptyStatement = 184,
|
||||
ExpressionStatement = 185,
|
||||
IfStatement = 186,
|
||||
DoStatement = 187,
|
||||
WhileStatement = 188,
|
||||
ForStatement = 189,
|
||||
ForInStatement = 190,
|
||||
ForOfStatement = 191,
|
||||
ContinueStatement = 192,
|
||||
BreakStatement = 193,
|
||||
ReturnStatement = 194,
|
||||
WithStatement = 195,
|
||||
SwitchStatement = 196,
|
||||
LabeledStatement = 197,
|
||||
ThrowStatement = 198,
|
||||
TryStatement = 199,
|
||||
DebuggerStatement = 200,
|
||||
VariableDeclaration = 201,
|
||||
VariableDeclarationList = 202,
|
||||
FunctionDeclaration = 203,
|
||||
ClassDeclaration = 204,
|
||||
InterfaceDeclaration = 205,
|
||||
TypeAliasDeclaration = 206,
|
||||
EnumDeclaration = 207,
|
||||
ModuleDeclaration = 208,
|
||||
ModuleBlock = 209,
|
||||
CaseBlock = 210,
|
||||
ImportEqualsDeclaration = 211,
|
||||
ImportDeclaration = 212,
|
||||
ImportClause = 213,
|
||||
NamespaceImport = 214,
|
||||
NamedImports = 215,
|
||||
ImportSpecifier = 216,
|
||||
ExportAssignment = 217,
|
||||
ExportDeclaration = 218,
|
||||
NamedExports = 219,
|
||||
ExportSpecifier = 220,
|
||||
MissingDeclaration = 221,
|
||||
ExternalModuleReference = 222,
|
||||
CaseClause = 223,
|
||||
DefaultClause = 224,
|
||||
HeritageClause = 225,
|
||||
CatchClause = 226,
|
||||
PropertyAssignment = 227,
|
||||
ShorthandPropertyAssignment = 228,
|
||||
EnumMember = 229,
|
||||
SourceFile = 230,
|
||||
JSDocTypeExpression = 231,
|
||||
JSDocAllType = 232,
|
||||
JSDocUnknownType = 233,
|
||||
JSDocArrayType = 234,
|
||||
JSDocUnionType = 235,
|
||||
JSDocTupleType = 236,
|
||||
JSDocNullableType = 237,
|
||||
JSDocNonNullableType = 238,
|
||||
JSDocRecordType = 239,
|
||||
JSDocRecordMember = 240,
|
||||
JSDocTypeReference = 241,
|
||||
JSDocOptionalType = 242,
|
||||
JSDocFunctionType = 243,
|
||||
JSDocVariadicType = 244,
|
||||
JSDocConstructorType = 245,
|
||||
JSDocThisType = 246,
|
||||
JSDocComment = 247,
|
||||
JSDocTag = 248,
|
||||
JSDocParameterTag = 249,
|
||||
JSDocReturnTag = 250,
|
||||
JSDocTypeTag = 251,
|
||||
JSDocTemplateTag = 252,
|
||||
SyntaxList = 253,
|
||||
Count = 254,
|
||||
FirstAssignment = 53,
|
||||
LastAssignment = 64,
|
||||
FirstReservedWord = 66,
|
||||
LastReservedWord = 101,
|
||||
FirstKeyword = 66,
|
||||
LastKeyword = 126,
|
||||
LastKeyword = 127,
|
||||
FirstFutureReservedWord = 102,
|
||||
LastFutureReservedWord = 110,
|
||||
FirstTypeNode = 142,
|
||||
LastTypeNode = 150,
|
||||
FirstTypeNode = 144,
|
||||
LastTypeNode = 152,
|
||||
FirstPunctuation = 14,
|
||||
LastPunctuation = 64,
|
||||
FirstToken = 0,
|
||||
LastToken = 126,
|
||||
LastToken = 127,
|
||||
FirstTriviaToken = 2,
|
||||
LastTriviaToken = 6,
|
||||
FirstLiteralToken = 7,
|
||||
@ -275,7 +306,7 @@ declare module "typescript" {
|
||||
LastTemplateToken = 13,
|
||||
FirstBinaryOperator = 24,
|
||||
LastBinaryOperator = 64,
|
||||
FirstNode = 127,
|
||||
FirstNode = 128,
|
||||
}
|
||||
const enum NodeFlags {
|
||||
Export = 1,
|
||||
@ -436,6 +467,10 @@ declare module "typescript" {
|
||||
typeName: EntityName;
|
||||
typeArguments?: NodeArray<TypeNode>;
|
||||
}
|
||||
interface TypePredicateNode extends TypeNode {
|
||||
parameterName: Identifier;
|
||||
type: TypeNode;
|
||||
}
|
||||
interface TypeQueryNode extends TypeNode {
|
||||
exprName: EntityName;
|
||||
}
|
||||
@ -495,7 +530,7 @@ declare module "typescript" {
|
||||
}
|
||||
interface YieldExpression extends Expression {
|
||||
asteriskToken?: Node;
|
||||
expression: Expression;
|
||||
expression?: Expression;
|
||||
}
|
||||
interface BinaryExpression extends Expression {
|
||||
left: Expression;
|
||||
@ -570,7 +605,7 @@ declare module "typescript" {
|
||||
type: TypeNode;
|
||||
expression: UnaryExpression;
|
||||
}
|
||||
interface Statement extends Node, ModuleElement {
|
||||
interface Statement extends Node {
|
||||
_statementBrand: any;
|
||||
}
|
||||
interface Block extends Statement {
|
||||
@ -650,9 +685,6 @@ declare module "typescript" {
|
||||
variableDeclaration: VariableDeclaration;
|
||||
block: Block;
|
||||
}
|
||||
interface ModuleElement extends Node {
|
||||
_moduleElementBrand: any;
|
||||
}
|
||||
interface ClassLikeDeclaration extends Declaration {
|
||||
name?: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
@ -666,7 +698,7 @@ declare module "typescript" {
|
||||
interface ClassElement extends Declaration {
|
||||
_classElementBrand: any;
|
||||
}
|
||||
interface InterfaceDeclaration extends Declaration, ModuleElement {
|
||||
interface InterfaceDeclaration extends Declaration, Statement {
|
||||
name: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
heritageClauses?: NodeArray<HeritageClause>;
|
||||
@ -676,33 +708,34 @@ declare module "typescript" {
|
||||
token: SyntaxKind;
|
||||
types?: NodeArray<ExpressionWithTypeArguments>;
|
||||
}
|
||||
interface TypeAliasDeclaration extends Declaration, ModuleElement {
|
||||
interface TypeAliasDeclaration extends Declaration, Statement {
|
||||
name: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
type: TypeNode;
|
||||
}
|
||||
interface EnumMember extends Declaration {
|
||||
name: DeclarationName;
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface EnumDeclaration extends Declaration, ModuleElement {
|
||||
interface EnumDeclaration extends Declaration, Statement {
|
||||
name: Identifier;
|
||||
members: NodeArray<EnumMember>;
|
||||
}
|
||||
interface ModuleDeclaration extends Declaration, ModuleElement {
|
||||
interface ModuleDeclaration extends Declaration, Statement {
|
||||
name: Identifier | LiteralExpression;
|
||||
body: ModuleBlock | ModuleDeclaration;
|
||||
}
|
||||
interface ModuleBlock extends Node, ModuleElement {
|
||||
statements: NodeArray<ModuleElement>;
|
||||
interface ModuleBlock extends Node, Statement {
|
||||
statements: NodeArray<Statement>;
|
||||
}
|
||||
interface ImportEqualsDeclaration extends Declaration, ModuleElement {
|
||||
interface ImportEqualsDeclaration extends Declaration, Statement {
|
||||
name: Identifier;
|
||||
moduleReference: EntityName | ExternalModuleReference;
|
||||
}
|
||||
interface ExternalModuleReference extends Node {
|
||||
expression?: Expression;
|
||||
}
|
||||
interface ImportDeclaration extends ModuleElement {
|
||||
interface ImportDeclaration extends Statement {
|
||||
importClause?: ImportClause;
|
||||
moduleSpecifier: Expression;
|
||||
}
|
||||
@ -713,7 +746,7 @@ declare module "typescript" {
|
||||
interface NamespaceImport extends Declaration {
|
||||
name: Identifier;
|
||||
}
|
||||
interface ExportDeclaration extends Declaration, ModuleElement {
|
||||
interface ExportDeclaration extends Declaration, Statement {
|
||||
exportClause?: NamedExports;
|
||||
moduleSpecifier?: Expression;
|
||||
}
|
||||
@ -728,7 +761,7 @@ declare module "typescript" {
|
||||
}
|
||||
type ImportSpecifier = ImportOrExportSpecifier;
|
||||
type ExportSpecifier = ImportOrExportSpecifier;
|
||||
interface ExportAssignment extends Declaration, ModuleElement {
|
||||
interface ExportAssignment extends Declaration, Statement {
|
||||
isExportEquals?: boolean;
|
||||
expression: Expression;
|
||||
}
|
||||
@ -739,8 +772,84 @@ declare module "typescript" {
|
||||
hasTrailingNewLine?: boolean;
|
||||
kind: SyntaxKind;
|
||||
}
|
||||
interface JSDocTypeExpression extends Node {
|
||||
type: JSDocType;
|
||||
}
|
||||
interface JSDocType extends TypeNode {
|
||||
_jsDocTypeBrand: any;
|
||||
}
|
||||
interface JSDocAllType extends JSDocType {
|
||||
_JSDocAllTypeBrand: any;
|
||||
}
|
||||
interface JSDocUnknownType extends JSDocType {
|
||||
_JSDocUnknownTypeBrand: any;
|
||||
}
|
||||
interface JSDocArrayType extends JSDocType {
|
||||
elementType: JSDocType;
|
||||
}
|
||||
interface JSDocUnionType extends JSDocType {
|
||||
types: NodeArray<JSDocType>;
|
||||
}
|
||||
interface JSDocTupleType extends JSDocType {
|
||||
types: NodeArray<JSDocType>;
|
||||
}
|
||||
interface JSDocNonNullableType extends JSDocType {
|
||||
type: JSDocType;
|
||||
}
|
||||
interface JSDocNullableType extends JSDocType {
|
||||
type: JSDocType;
|
||||
}
|
||||
interface JSDocRecordType extends JSDocType, TypeLiteralNode {
|
||||
members: NodeArray<JSDocRecordMember>;
|
||||
}
|
||||
interface JSDocTypeReference extends JSDocType {
|
||||
name: EntityName;
|
||||
typeArguments: NodeArray<JSDocType>;
|
||||
}
|
||||
interface JSDocOptionalType extends JSDocType {
|
||||
type: JSDocType;
|
||||
}
|
||||
interface JSDocFunctionType extends JSDocType, SignatureDeclaration {
|
||||
parameters: NodeArray<ParameterDeclaration>;
|
||||
type: JSDocType;
|
||||
}
|
||||
interface JSDocVariadicType extends JSDocType {
|
||||
type: JSDocType;
|
||||
}
|
||||
interface JSDocConstructorType extends JSDocType {
|
||||
type: JSDocType;
|
||||
}
|
||||
interface JSDocThisType extends JSDocType {
|
||||
type: JSDocType;
|
||||
}
|
||||
interface JSDocRecordMember extends PropertyDeclaration {
|
||||
name: Identifier | LiteralExpression;
|
||||
type?: JSDocType;
|
||||
}
|
||||
interface JSDocComment extends Node {
|
||||
tags: NodeArray<JSDocTag>;
|
||||
}
|
||||
interface JSDocTag extends Node {
|
||||
atToken: Node;
|
||||
tagName: Identifier;
|
||||
}
|
||||
interface JSDocTemplateTag extends JSDocTag {
|
||||
typeParameters: NodeArray<TypeParameterDeclaration>;
|
||||
}
|
||||
interface JSDocReturnTag extends JSDocTag {
|
||||
typeExpression: JSDocTypeExpression;
|
||||
}
|
||||
interface JSDocTypeTag extends JSDocTag {
|
||||
typeExpression: JSDocTypeExpression;
|
||||
}
|
||||
interface JSDocParameterTag extends JSDocTag {
|
||||
preParameterName?: Identifier;
|
||||
typeExpression?: JSDocTypeExpression;
|
||||
postParameterName?: Identifier;
|
||||
isBracketed: boolean;
|
||||
}
|
||||
interface SourceFile extends Declaration {
|
||||
statements: NodeArray<ModuleElement>;
|
||||
statements: NodeArray<Statement>;
|
||||
endOfFileToken: Node;
|
||||
fileName: string;
|
||||
text: string;
|
||||
@ -748,8 +857,16 @@ declare module "typescript" {
|
||||
path: string;
|
||||
name: string;
|
||||
}[];
|
||||
amdModuleName: string;
|
||||
moduleName: string;
|
||||
referencedFiles: FileReference[];
|
||||
/**
|
||||
* lib.d.ts should have a reference comment like
|
||||
*
|
||||
* /// <reference no-default-lib="true"/>
|
||||
*
|
||||
* If any other file has this comment, it signals not to include lib.d.ts
|
||||
* because this containing file is intended to act as a default library.
|
||||
*/
|
||||
hasNoDefaultLib: boolean;
|
||||
languageVersion: ScriptTarget;
|
||||
}
|
||||
@ -759,7 +876,7 @@ declare module "typescript" {
|
||||
getCurrentDirectory(): string;
|
||||
}
|
||||
interface ParseConfigHost {
|
||||
readDirectory(rootDir: string, extension: string): string[];
|
||||
readDirectory(rootDir: string, extension: string, exclude: string[]): string[];
|
||||
}
|
||||
interface WriteFileCallback {
|
||||
(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
@ -780,8 +897,9 @@ declare module "typescript" {
|
||||
* will be invoked when writing the JavaScript and declaration files.
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getOptionsDiagnostics(): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
/**
|
||||
@ -900,7 +1018,13 @@ declare module "typescript" {
|
||||
WriteTypeParametersOrArguments = 1,
|
||||
UseOnlyExternalAliasing = 2,
|
||||
}
|
||||
interface TypePredicate {
|
||||
parameterName: string;
|
||||
parameterIndex: number;
|
||||
type: Type;
|
||||
}
|
||||
const enum SymbolFlags {
|
||||
None = 0,
|
||||
FunctionScopedVariable = 1,
|
||||
BlockScopedVariable = 2,
|
||||
Property = 4,
|
||||
@ -959,10 +1083,9 @@ declare module "typescript" {
|
||||
AliasExcludes = 8388608,
|
||||
ModuleMember = 8914931,
|
||||
ExportHasLocal = 944,
|
||||
HasLocals = 255504,
|
||||
HasExports = 1952,
|
||||
HasMembers = 6240,
|
||||
IsContainer = 262128,
|
||||
BlockScoped = 418,
|
||||
PropertyOrAccessor = 98308,
|
||||
Export = 7340032,
|
||||
}
|
||||
@ -970,9 +1093,9 @@ declare module "typescript" {
|
||||
flags: SymbolFlags;
|
||||
name: string;
|
||||
declarations?: Declaration[];
|
||||
valueDeclaration?: Declaration;
|
||||
members?: SymbolTable;
|
||||
exports?: SymbolTable;
|
||||
valueDeclaration?: Declaration;
|
||||
}
|
||||
interface SymbolTable {
|
||||
[index: string]: Symbol;
|
||||
@ -994,8 +1117,9 @@ declare module "typescript" {
|
||||
Tuple = 8192,
|
||||
Union = 16384,
|
||||
Anonymous = 32768,
|
||||
ObjectLiteral = 131072,
|
||||
ESSymbol = 1048576,
|
||||
Instantiated = 65536,
|
||||
ObjectLiteral = 262144,
|
||||
ESSymbol = 2097152,
|
||||
StringLike = 258,
|
||||
NumberLike = 132,
|
||||
ObjectType = 48128,
|
||||
@ -1011,9 +1135,10 @@ declare module "typescript" {
|
||||
}
|
||||
interface InterfaceType extends ObjectType {
|
||||
typeParameters: TypeParameter[];
|
||||
}
|
||||
interface InterfaceTypeWithBaseTypes extends InterfaceType {
|
||||
baseTypes: ObjectType[];
|
||||
outerTypeParameters: TypeParameter[];
|
||||
localTypeParameters: TypeParameter[];
|
||||
resolvedBaseConstructorType?: Type;
|
||||
resolvedBaseTypes: ObjectType[];
|
||||
}
|
||||
interface InterfaceTypeWithDeclaredMembers extends InterfaceType {
|
||||
declaredProperties: Symbol[];
|
||||
@ -1046,6 +1171,7 @@ declare module "typescript" {
|
||||
declaration: SignatureDeclaration;
|
||||
typeParameters: TypeParameter[];
|
||||
parameters: Symbol[];
|
||||
typePredicate?: TypePredicate;
|
||||
}
|
||||
const enum IndexKind {
|
||||
String = 0,
|
||||
@ -1114,7 +1240,8 @@ declare module "typescript" {
|
||||
target?: ScriptTarget;
|
||||
version?: boolean;
|
||||
watch?: boolean;
|
||||
separateCompilation?: boolean;
|
||||
isolatedModules?: boolean;
|
||||
experimentalDecorators?: boolean;
|
||||
emitDecoratorMetadata?: boolean;
|
||||
[option: string]: string | number | boolean;
|
||||
}
|
||||
@ -1181,7 +1308,7 @@ declare module "typescript" {
|
||||
createDirectory(path: string): void;
|
||||
getExecutingFilePath(): string;
|
||||
getCurrentDirectory(): string;
|
||||
readDirectory(path: string, extension?: string): string[];
|
||||
readDirectory(path: string, extension?: string, exclude?: string[]): string[];
|
||||
getMemoryUsage?(): number;
|
||||
exit(exitCode?: number): void;
|
||||
}
|
||||
@ -1222,12 +1349,11 @@ declare module "typescript" {
|
||||
function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter;
|
||||
function isWhiteSpace(ch: number): boolean;
|
||||
function isLineBreak(ch: number): boolean;
|
||||
function couldStartTrivia(text: string, pos: number): boolean;
|
||||
function getLeadingCommentRanges(text: string, pos: number): CommentRange[];
|
||||
function getTrailingCommentRanges(text: string, pos: number): CommentRange[];
|
||||
function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean;
|
||||
function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean;
|
||||
/** Creates a scanner over a (possibly unspecified) range of a piece of text. */
|
||||
function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner;
|
||||
}
|
||||
declare module "typescript" {
|
||||
function getDefaultLibFileName(options: CompilerOptions): string;
|
||||
@ -1239,6 +1365,7 @@ declare module "typescript" {
|
||||
function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan;
|
||||
function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean;
|
||||
function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean;
|
||||
function decodedTextSpanIntersectsWith(start1: number, length1: number, start2: number, length2: number): boolean;
|
||||
function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean;
|
||||
function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan;
|
||||
function createTextSpan(start: number, length: number): TextSpan;
|
||||
@ -1256,6 +1383,7 @@ declare module "typescript" {
|
||||
* Vn.
|
||||
*/
|
||||
function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
|
||||
function getTypeParameterOwner(d: Declaration): Declaration;
|
||||
}
|
||||
declare module "typescript" {
|
||||
function getNodeConstructor(kind: SyntaxKind): new () => Node;
|
||||
@ -1390,6 +1518,7 @@ declare module "typescript" {
|
||||
log?(s: string): void;
|
||||
trace?(s: string): void;
|
||||
error?(s: string): void;
|
||||
useCaseSensitiveFileNames?(): boolean;
|
||||
}
|
||||
interface LanguageService {
|
||||
cleanupSemanticCache(): void;
|
||||
@ -1812,6 +1941,7 @@ declare module "typescript" {
|
||||
static typeParameterName: string;
|
||||
static typeAliasName: string;
|
||||
static parameterName: string;
|
||||
static docCommentTagName: string;
|
||||
}
|
||||
const enum ClassificationType {
|
||||
comment = 1,
|
||||
@ -1831,6 +1961,7 @@ declare module "typescript" {
|
||||
typeParameterName = 15,
|
||||
typeAliasName = 16,
|
||||
parameterName = 17,
|
||||
docCommentTagName = 18,
|
||||
}
|
||||
interface DisplayPartsSymbolWriter extends SymbolWriter {
|
||||
displayParts(): SymbolDisplayPart[];
|
||||
@ -1846,11 +1977,11 @@ declare module "typescript" {
|
||||
isCancellationRequested(): boolean;
|
||||
throwIfCancellationRequested(): void;
|
||||
}
|
||||
function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string;
|
||||
function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string;
|
||||
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
|
||||
let disableIncrementalParsing: boolean;
|
||||
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
|
||||
function createDocumentRegistry(): DocumentRegistry;
|
||||
function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry;
|
||||
function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo;
|
||||
function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService;
|
||||
function createClassifier(): Classifier;
|
||||
|
||||
12015
bin/typescript.js
12015
bin/typescript.js
File diff suppressed because it is too large
Load Diff
451
bin/typescriptServices.d.ts
vendored
451
bin/typescriptServices.d.ts
vendored
@ -13,10 +13,17 @@ See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
declare module ts {
|
||||
declare namespace ts {
|
||||
interface Map<T> {
|
||||
[index: string]: T;
|
||||
}
|
||||
interface FileMap<T> {
|
||||
get(fileName: string): T;
|
||||
set(fileName: string, value: T): void;
|
||||
contains(fileName: string): boolean;
|
||||
remove(fileName: string): void;
|
||||
forEachValue(f: (v: T) => void): void;
|
||||
}
|
||||
interface TextRange {
|
||||
pos: number;
|
||||
end: number;
|
||||
@ -139,134 +146,158 @@ declare module ts {
|
||||
ConstructorKeyword = 114,
|
||||
DeclareKeyword = 115,
|
||||
GetKeyword = 116,
|
||||
ModuleKeyword = 117,
|
||||
NamespaceKeyword = 118,
|
||||
RequireKeyword = 119,
|
||||
NumberKeyword = 120,
|
||||
SetKeyword = 121,
|
||||
StringKeyword = 122,
|
||||
SymbolKeyword = 123,
|
||||
TypeKeyword = 124,
|
||||
FromKeyword = 125,
|
||||
OfKeyword = 126,
|
||||
QualifiedName = 127,
|
||||
ComputedPropertyName = 128,
|
||||
TypeParameter = 129,
|
||||
Parameter = 130,
|
||||
Decorator = 131,
|
||||
PropertySignature = 132,
|
||||
PropertyDeclaration = 133,
|
||||
MethodSignature = 134,
|
||||
MethodDeclaration = 135,
|
||||
Constructor = 136,
|
||||
GetAccessor = 137,
|
||||
SetAccessor = 138,
|
||||
CallSignature = 139,
|
||||
ConstructSignature = 140,
|
||||
IndexSignature = 141,
|
||||
TypeReference = 142,
|
||||
FunctionType = 143,
|
||||
ConstructorType = 144,
|
||||
TypeQuery = 145,
|
||||
TypeLiteral = 146,
|
||||
ArrayType = 147,
|
||||
TupleType = 148,
|
||||
UnionType = 149,
|
||||
ParenthesizedType = 150,
|
||||
ObjectBindingPattern = 151,
|
||||
ArrayBindingPattern = 152,
|
||||
BindingElement = 153,
|
||||
ArrayLiteralExpression = 154,
|
||||
ObjectLiteralExpression = 155,
|
||||
PropertyAccessExpression = 156,
|
||||
ElementAccessExpression = 157,
|
||||
CallExpression = 158,
|
||||
NewExpression = 159,
|
||||
TaggedTemplateExpression = 160,
|
||||
TypeAssertionExpression = 161,
|
||||
ParenthesizedExpression = 162,
|
||||
FunctionExpression = 163,
|
||||
ArrowFunction = 164,
|
||||
DeleteExpression = 165,
|
||||
TypeOfExpression = 166,
|
||||
VoidExpression = 167,
|
||||
PrefixUnaryExpression = 168,
|
||||
PostfixUnaryExpression = 169,
|
||||
BinaryExpression = 170,
|
||||
ConditionalExpression = 171,
|
||||
TemplateExpression = 172,
|
||||
YieldExpression = 173,
|
||||
SpreadElementExpression = 174,
|
||||
ClassExpression = 175,
|
||||
OmittedExpression = 176,
|
||||
ExpressionWithTypeArguments = 177,
|
||||
TemplateSpan = 178,
|
||||
SemicolonClassElement = 179,
|
||||
Block = 180,
|
||||
VariableStatement = 181,
|
||||
EmptyStatement = 182,
|
||||
ExpressionStatement = 183,
|
||||
IfStatement = 184,
|
||||
DoStatement = 185,
|
||||
WhileStatement = 186,
|
||||
ForStatement = 187,
|
||||
ForInStatement = 188,
|
||||
ForOfStatement = 189,
|
||||
ContinueStatement = 190,
|
||||
BreakStatement = 191,
|
||||
ReturnStatement = 192,
|
||||
WithStatement = 193,
|
||||
SwitchStatement = 194,
|
||||
LabeledStatement = 195,
|
||||
ThrowStatement = 196,
|
||||
TryStatement = 197,
|
||||
DebuggerStatement = 198,
|
||||
VariableDeclaration = 199,
|
||||
VariableDeclarationList = 200,
|
||||
FunctionDeclaration = 201,
|
||||
ClassDeclaration = 202,
|
||||
InterfaceDeclaration = 203,
|
||||
TypeAliasDeclaration = 204,
|
||||
EnumDeclaration = 205,
|
||||
ModuleDeclaration = 206,
|
||||
ModuleBlock = 207,
|
||||
CaseBlock = 208,
|
||||
ImportEqualsDeclaration = 209,
|
||||
ImportDeclaration = 210,
|
||||
ImportClause = 211,
|
||||
NamespaceImport = 212,
|
||||
NamedImports = 213,
|
||||
ImportSpecifier = 214,
|
||||
ExportAssignment = 215,
|
||||
ExportDeclaration = 216,
|
||||
NamedExports = 217,
|
||||
ExportSpecifier = 218,
|
||||
MissingDeclaration = 219,
|
||||
ExternalModuleReference = 220,
|
||||
CaseClause = 221,
|
||||
DefaultClause = 222,
|
||||
HeritageClause = 223,
|
||||
CatchClause = 224,
|
||||
PropertyAssignment = 225,
|
||||
ShorthandPropertyAssignment = 226,
|
||||
EnumMember = 227,
|
||||
SourceFile = 228,
|
||||
SyntaxList = 229,
|
||||
Count = 230,
|
||||
IsKeyword = 117,
|
||||
ModuleKeyword = 118,
|
||||
NamespaceKeyword = 119,
|
||||
RequireKeyword = 120,
|
||||
NumberKeyword = 121,
|
||||
SetKeyword = 122,
|
||||
StringKeyword = 123,
|
||||
SymbolKeyword = 124,
|
||||
TypeKeyword = 125,
|
||||
FromKeyword = 126,
|
||||
OfKeyword = 127,
|
||||
QualifiedName = 128,
|
||||
ComputedPropertyName = 129,
|
||||
TypeParameter = 130,
|
||||
Parameter = 131,
|
||||
Decorator = 132,
|
||||
PropertySignature = 133,
|
||||
PropertyDeclaration = 134,
|
||||
MethodSignature = 135,
|
||||
MethodDeclaration = 136,
|
||||
Constructor = 137,
|
||||
GetAccessor = 138,
|
||||
SetAccessor = 139,
|
||||
CallSignature = 140,
|
||||
ConstructSignature = 141,
|
||||
IndexSignature = 142,
|
||||
TypePredicate = 143,
|
||||
TypeReference = 144,
|
||||
FunctionType = 145,
|
||||
ConstructorType = 146,
|
||||
TypeQuery = 147,
|
||||
TypeLiteral = 148,
|
||||
ArrayType = 149,
|
||||
TupleType = 150,
|
||||
UnionType = 151,
|
||||
ParenthesizedType = 152,
|
||||
ObjectBindingPattern = 153,
|
||||
ArrayBindingPattern = 154,
|
||||
BindingElement = 155,
|
||||
ArrayLiteralExpression = 156,
|
||||
ObjectLiteralExpression = 157,
|
||||
PropertyAccessExpression = 158,
|
||||
ElementAccessExpression = 159,
|
||||
CallExpression = 160,
|
||||
NewExpression = 161,
|
||||
TaggedTemplateExpression = 162,
|
||||
TypeAssertionExpression = 163,
|
||||
ParenthesizedExpression = 164,
|
||||
FunctionExpression = 165,
|
||||
ArrowFunction = 166,
|
||||
DeleteExpression = 167,
|
||||
TypeOfExpression = 168,
|
||||
VoidExpression = 169,
|
||||
PrefixUnaryExpression = 170,
|
||||
PostfixUnaryExpression = 171,
|
||||
BinaryExpression = 172,
|
||||
ConditionalExpression = 173,
|
||||
TemplateExpression = 174,
|
||||
YieldExpression = 175,
|
||||
SpreadElementExpression = 176,
|
||||
ClassExpression = 177,
|
||||
OmittedExpression = 178,
|
||||
ExpressionWithTypeArguments = 179,
|
||||
TemplateSpan = 180,
|
||||
SemicolonClassElement = 181,
|
||||
Block = 182,
|
||||
VariableStatement = 183,
|
||||
EmptyStatement = 184,
|
||||
ExpressionStatement = 185,
|
||||
IfStatement = 186,
|
||||
DoStatement = 187,
|
||||
WhileStatement = 188,
|
||||
ForStatement = 189,
|
||||
ForInStatement = 190,
|
||||
ForOfStatement = 191,
|
||||
ContinueStatement = 192,
|
||||
BreakStatement = 193,
|
||||
ReturnStatement = 194,
|
||||
WithStatement = 195,
|
||||
SwitchStatement = 196,
|
||||
LabeledStatement = 197,
|
||||
ThrowStatement = 198,
|
||||
TryStatement = 199,
|
||||
DebuggerStatement = 200,
|
||||
VariableDeclaration = 201,
|
||||
VariableDeclarationList = 202,
|
||||
FunctionDeclaration = 203,
|
||||
ClassDeclaration = 204,
|
||||
InterfaceDeclaration = 205,
|
||||
TypeAliasDeclaration = 206,
|
||||
EnumDeclaration = 207,
|
||||
ModuleDeclaration = 208,
|
||||
ModuleBlock = 209,
|
||||
CaseBlock = 210,
|
||||
ImportEqualsDeclaration = 211,
|
||||
ImportDeclaration = 212,
|
||||
ImportClause = 213,
|
||||
NamespaceImport = 214,
|
||||
NamedImports = 215,
|
||||
ImportSpecifier = 216,
|
||||
ExportAssignment = 217,
|
||||
ExportDeclaration = 218,
|
||||
NamedExports = 219,
|
||||
ExportSpecifier = 220,
|
||||
MissingDeclaration = 221,
|
||||
ExternalModuleReference = 222,
|
||||
CaseClause = 223,
|
||||
DefaultClause = 224,
|
||||
HeritageClause = 225,
|
||||
CatchClause = 226,
|
||||
PropertyAssignment = 227,
|
||||
ShorthandPropertyAssignment = 228,
|
||||
EnumMember = 229,
|
||||
SourceFile = 230,
|
||||
JSDocTypeExpression = 231,
|
||||
JSDocAllType = 232,
|
||||
JSDocUnknownType = 233,
|
||||
JSDocArrayType = 234,
|
||||
JSDocUnionType = 235,
|
||||
JSDocTupleType = 236,
|
||||
JSDocNullableType = 237,
|
||||
JSDocNonNullableType = 238,
|
||||
JSDocRecordType = 239,
|
||||
JSDocRecordMember = 240,
|
||||
JSDocTypeReference = 241,
|
||||
JSDocOptionalType = 242,
|
||||
JSDocFunctionType = 243,
|
||||
JSDocVariadicType = 244,
|
||||
JSDocConstructorType = 245,
|
||||
JSDocThisType = 246,
|
||||
JSDocComment = 247,
|
||||
JSDocTag = 248,
|
||||
JSDocParameterTag = 249,
|
||||
JSDocReturnTag = 250,
|
||||
JSDocTypeTag = 251,
|
||||
JSDocTemplateTag = 252,
|
||||
SyntaxList = 253,
|
||||
Count = 254,
|
||||
FirstAssignment = 53,
|
||||
LastAssignment = 64,
|
||||
FirstReservedWord = 66,
|
||||
LastReservedWord = 101,
|
||||
FirstKeyword = 66,
|
||||
LastKeyword = 126,
|
||||
LastKeyword = 127,
|
||||
FirstFutureReservedWord = 102,
|
||||
LastFutureReservedWord = 110,
|
||||
FirstTypeNode = 142,
|
||||
LastTypeNode = 150,
|
||||
FirstTypeNode = 144,
|
||||
LastTypeNode = 152,
|
||||
FirstPunctuation = 14,
|
||||
LastPunctuation = 64,
|
||||
FirstToken = 0,
|
||||
LastToken = 126,
|
||||
LastToken = 127,
|
||||
FirstTriviaToken = 2,
|
||||
LastTriviaToken = 6,
|
||||
FirstLiteralToken = 7,
|
||||
@ -275,7 +306,7 @@ declare module ts {
|
||||
LastTemplateToken = 13,
|
||||
FirstBinaryOperator = 24,
|
||||
LastBinaryOperator = 64,
|
||||
FirstNode = 127,
|
||||
FirstNode = 128,
|
||||
}
|
||||
const enum NodeFlags {
|
||||
Export = 1,
|
||||
@ -436,6 +467,10 @@ declare module ts {
|
||||
typeName: EntityName;
|
||||
typeArguments?: NodeArray<TypeNode>;
|
||||
}
|
||||
interface TypePredicateNode extends TypeNode {
|
||||
parameterName: Identifier;
|
||||
type: TypeNode;
|
||||
}
|
||||
interface TypeQueryNode extends TypeNode {
|
||||
exprName: EntityName;
|
||||
}
|
||||
@ -495,7 +530,7 @@ declare module ts {
|
||||
}
|
||||
interface YieldExpression extends Expression {
|
||||
asteriskToken?: Node;
|
||||
expression: Expression;
|
||||
expression?: Expression;
|
||||
}
|
||||
interface BinaryExpression extends Expression {
|
||||
left: Expression;
|
||||
@ -570,7 +605,7 @@ declare module ts {
|
||||
type: TypeNode;
|
||||
expression: UnaryExpression;
|
||||
}
|
||||
interface Statement extends Node, ModuleElement {
|
||||
interface Statement extends Node {
|
||||
_statementBrand: any;
|
||||
}
|
||||
interface Block extends Statement {
|
||||
@ -650,9 +685,6 @@ declare module ts {
|
||||
variableDeclaration: VariableDeclaration;
|
||||
block: Block;
|
||||
}
|
||||
interface ModuleElement extends Node {
|
||||
_moduleElementBrand: any;
|
||||
}
|
||||
interface ClassLikeDeclaration extends Declaration {
|
||||
name?: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
@ -666,7 +698,7 @@ declare module ts {
|
||||
interface ClassElement extends Declaration {
|
||||
_classElementBrand: any;
|
||||
}
|
||||
interface InterfaceDeclaration extends Declaration, ModuleElement {
|
||||
interface InterfaceDeclaration extends Declaration, Statement {
|
||||
name: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
heritageClauses?: NodeArray<HeritageClause>;
|
||||
@ -676,33 +708,34 @@ declare module ts {
|
||||
token: SyntaxKind;
|
||||
types?: NodeArray<ExpressionWithTypeArguments>;
|
||||
}
|
||||
interface TypeAliasDeclaration extends Declaration, ModuleElement {
|
||||
interface TypeAliasDeclaration extends Declaration, Statement {
|
||||
name: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
type: TypeNode;
|
||||
}
|
||||
interface EnumMember extends Declaration {
|
||||
name: DeclarationName;
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface EnumDeclaration extends Declaration, ModuleElement {
|
||||
interface EnumDeclaration extends Declaration, Statement {
|
||||
name: Identifier;
|
||||
members: NodeArray<EnumMember>;
|
||||
}
|
||||
interface ModuleDeclaration extends Declaration, ModuleElement {
|
||||
interface ModuleDeclaration extends Declaration, Statement {
|
||||
name: Identifier | LiteralExpression;
|
||||
body: ModuleBlock | ModuleDeclaration;
|
||||
}
|
||||
interface ModuleBlock extends Node, ModuleElement {
|
||||
statements: NodeArray<ModuleElement>;
|
||||
interface ModuleBlock extends Node, Statement {
|
||||
statements: NodeArray<Statement>;
|
||||
}
|
||||
interface ImportEqualsDeclaration extends Declaration, ModuleElement {
|
||||
interface ImportEqualsDeclaration extends Declaration, Statement {
|
||||
name: Identifier;
|
||||
moduleReference: EntityName | ExternalModuleReference;
|
||||
}
|
||||
interface ExternalModuleReference extends Node {
|
||||
expression?: Expression;
|
||||
}
|
||||
interface ImportDeclaration extends ModuleElement {
|
||||
interface ImportDeclaration extends Statement {
|
||||
importClause?: ImportClause;
|
||||
moduleSpecifier: Expression;
|
||||
}
|
||||
@ -713,7 +746,7 @@ declare module ts {
|
||||
interface NamespaceImport extends Declaration {
|
||||
name: Identifier;
|
||||
}
|
||||
interface ExportDeclaration extends Declaration, ModuleElement {
|
||||
interface ExportDeclaration extends Declaration, Statement {
|
||||
exportClause?: NamedExports;
|
||||
moduleSpecifier?: Expression;
|
||||
}
|
||||
@ -728,7 +761,7 @@ declare module ts {
|
||||
}
|
||||
type ImportSpecifier = ImportOrExportSpecifier;
|
||||
type ExportSpecifier = ImportOrExportSpecifier;
|
||||
interface ExportAssignment extends Declaration, ModuleElement {
|
||||
interface ExportAssignment extends Declaration, Statement {
|
||||
isExportEquals?: boolean;
|
||||
expression: Expression;
|
||||
}
|
||||
@ -739,8 +772,84 @@ declare module ts {
|
||||
hasTrailingNewLine?: boolean;
|
||||
kind: SyntaxKind;
|
||||
}
|
||||
interface JSDocTypeExpression extends Node {
|
||||
type: JSDocType;
|
||||
}
|
||||
interface JSDocType extends TypeNode {
|
||||
_jsDocTypeBrand: any;
|
||||
}
|
||||
interface JSDocAllType extends JSDocType {
|
||||
_JSDocAllTypeBrand: any;
|
||||
}
|
||||
interface JSDocUnknownType extends JSDocType {
|
||||
_JSDocUnknownTypeBrand: any;
|
||||
}
|
||||
interface JSDocArrayType extends JSDocType {
|
||||
elementType: JSDocType;
|
||||
}
|
||||
interface JSDocUnionType extends JSDocType {
|
||||
types: NodeArray<JSDocType>;
|
||||
}
|
||||
interface JSDocTupleType extends JSDocType {
|
||||
types: NodeArray<JSDocType>;
|
||||
}
|
||||
interface JSDocNonNullableType extends JSDocType {
|
||||
type: JSDocType;
|
||||
}
|
||||
interface JSDocNullableType extends JSDocType {
|
||||
type: JSDocType;
|
||||
}
|
||||
interface JSDocRecordType extends JSDocType, TypeLiteralNode {
|
||||
members: NodeArray<JSDocRecordMember>;
|
||||
}
|
||||
interface JSDocTypeReference extends JSDocType {
|
||||
name: EntityName;
|
||||
typeArguments: NodeArray<JSDocType>;
|
||||
}
|
||||
interface JSDocOptionalType extends JSDocType {
|
||||
type: JSDocType;
|
||||
}
|
||||
interface JSDocFunctionType extends JSDocType, SignatureDeclaration {
|
||||
parameters: NodeArray<ParameterDeclaration>;
|
||||
type: JSDocType;
|
||||
}
|
||||
interface JSDocVariadicType extends JSDocType {
|
||||
type: JSDocType;
|
||||
}
|
||||
interface JSDocConstructorType extends JSDocType {
|
||||
type: JSDocType;
|
||||
}
|
||||
interface JSDocThisType extends JSDocType {
|
||||
type: JSDocType;
|
||||
}
|
||||
interface JSDocRecordMember extends PropertyDeclaration {
|
||||
name: Identifier | LiteralExpression;
|
||||
type?: JSDocType;
|
||||
}
|
||||
interface JSDocComment extends Node {
|
||||
tags: NodeArray<JSDocTag>;
|
||||
}
|
||||
interface JSDocTag extends Node {
|
||||
atToken: Node;
|
||||
tagName: Identifier;
|
||||
}
|
||||
interface JSDocTemplateTag extends JSDocTag {
|
||||
typeParameters: NodeArray<TypeParameterDeclaration>;
|
||||
}
|
||||
interface JSDocReturnTag extends JSDocTag {
|
||||
typeExpression: JSDocTypeExpression;
|
||||
}
|
||||
interface JSDocTypeTag extends JSDocTag {
|
||||
typeExpression: JSDocTypeExpression;
|
||||
}
|
||||
interface JSDocParameterTag extends JSDocTag {
|
||||
preParameterName?: Identifier;
|
||||
typeExpression?: JSDocTypeExpression;
|
||||
postParameterName?: Identifier;
|
||||
isBracketed: boolean;
|
||||
}
|
||||
interface SourceFile extends Declaration {
|
||||
statements: NodeArray<ModuleElement>;
|
||||
statements: NodeArray<Statement>;
|
||||
endOfFileToken: Node;
|
||||
fileName: string;
|
||||
text: string;
|
||||
@ -748,8 +857,16 @@ declare module ts {
|
||||
path: string;
|
||||
name: string;
|
||||
}[];
|
||||
amdModuleName: string;
|
||||
moduleName: string;
|
||||
referencedFiles: FileReference[];
|
||||
/**
|
||||
* lib.d.ts should have a reference comment like
|
||||
*
|
||||
* /// <reference no-default-lib="true"/>
|
||||
*
|
||||
* If any other file has this comment, it signals not to include lib.d.ts
|
||||
* because this containing file is intended to act as a default library.
|
||||
*/
|
||||
hasNoDefaultLib: boolean;
|
||||
languageVersion: ScriptTarget;
|
||||
}
|
||||
@ -759,7 +876,7 @@ declare module ts {
|
||||
getCurrentDirectory(): string;
|
||||
}
|
||||
interface ParseConfigHost {
|
||||
readDirectory(rootDir: string, extension: string): string[];
|
||||
readDirectory(rootDir: string, extension: string, exclude: string[]): string[];
|
||||
}
|
||||
interface WriteFileCallback {
|
||||
(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
@ -780,8 +897,9 @@ declare module ts {
|
||||
* will be invoked when writing the JavaScript and declaration files.
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getOptionsDiagnostics(): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
/**
|
||||
@ -900,7 +1018,13 @@ declare module ts {
|
||||
WriteTypeParametersOrArguments = 1,
|
||||
UseOnlyExternalAliasing = 2,
|
||||
}
|
||||
interface TypePredicate {
|
||||
parameterName: string;
|
||||
parameterIndex: number;
|
||||
type: Type;
|
||||
}
|
||||
const enum SymbolFlags {
|
||||
None = 0,
|
||||
FunctionScopedVariable = 1,
|
||||
BlockScopedVariable = 2,
|
||||
Property = 4,
|
||||
@ -959,10 +1083,9 @@ declare module ts {
|
||||
AliasExcludes = 8388608,
|
||||
ModuleMember = 8914931,
|
||||
ExportHasLocal = 944,
|
||||
HasLocals = 255504,
|
||||
HasExports = 1952,
|
||||
HasMembers = 6240,
|
||||
IsContainer = 262128,
|
||||
BlockScoped = 418,
|
||||
PropertyOrAccessor = 98308,
|
||||
Export = 7340032,
|
||||
}
|
||||
@ -970,9 +1093,9 @@ declare module ts {
|
||||
flags: SymbolFlags;
|
||||
name: string;
|
||||
declarations?: Declaration[];
|
||||
valueDeclaration?: Declaration;
|
||||
members?: SymbolTable;
|
||||
exports?: SymbolTable;
|
||||
valueDeclaration?: Declaration;
|
||||
}
|
||||
interface SymbolTable {
|
||||
[index: string]: Symbol;
|
||||
@ -994,8 +1117,9 @@ declare module ts {
|
||||
Tuple = 8192,
|
||||
Union = 16384,
|
||||
Anonymous = 32768,
|
||||
ObjectLiteral = 131072,
|
||||
ESSymbol = 1048576,
|
||||
Instantiated = 65536,
|
||||
ObjectLiteral = 262144,
|
||||
ESSymbol = 2097152,
|
||||
StringLike = 258,
|
||||
NumberLike = 132,
|
||||
ObjectType = 48128,
|
||||
@ -1011,9 +1135,10 @@ declare module ts {
|
||||
}
|
||||
interface InterfaceType extends ObjectType {
|
||||
typeParameters: TypeParameter[];
|
||||
}
|
||||
interface InterfaceTypeWithBaseTypes extends InterfaceType {
|
||||
baseTypes: ObjectType[];
|
||||
outerTypeParameters: TypeParameter[];
|
||||
localTypeParameters: TypeParameter[];
|
||||
resolvedBaseConstructorType?: Type;
|
||||
resolvedBaseTypes: ObjectType[];
|
||||
}
|
||||
interface InterfaceTypeWithDeclaredMembers extends InterfaceType {
|
||||
declaredProperties: Symbol[];
|
||||
@ -1046,6 +1171,7 @@ declare module ts {
|
||||
declaration: SignatureDeclaration;
|
||||
typeParameters: TypeParameter[];
|
||||
parameters: Symbol[];
|
||||
typePredicate?: TypePredicate;
|
||||
}
|
||||
const enum IndexKind {
|
||||
String = 0,
|
||||
@ -1114,7 +1240,8 @@ declare module ts {
|
||||
target?: ScriptTarget;
|
||||
version?: boolean;
|
||||
watch?: boolean;
|
||||
separateCompilation?: boolean;
|
||||
isolatedModules?: boolean;
|
||||
experimentalDecorators?: boolean;
|
||||
emitDecoratorMetadata?: boolean;
|
||||
[option: string]: string | number | boolean;
|
||||
}
|
||||
@ -1166,7 +1293,7 @@ declare module ts {
|
||||
newLength: number;
|
||||
}
|
||||
}
|
||||
declare module ts {
|
||||
declare namespace ts {
|
||||
interface System {
|
||||
args: string[];
|
||||
newLine: string;
|
||||
@ -1181,7 +1308,7 @@ declare module ts {
|
||||
createDirectory(path: string): void;
|
||||
getExecutingFilePath(): string;
|
||||
getCurrentDirectory(): string;
|
||||
readDirectory(path: string, extension?: string): string[];
|
||||
readDirectory(path: string, extension?: string, exclude?: string[]): string[];
|
||||
getMemoryUsage?(): number;
|
||||
exit(exitCode?: number): void;
|
||||
}
|
||||
@ -1190,7 +1317,7 @@ declare module ts {
|
||||
}
|
||||
var sys: System;
|
||||
}
|
||||
declare module ts {
|
||||
declare namespace ts {
|
||||
interface ErrorCallback {
|
||||
(message: DiagnosticMessage, length: number): void;
|
||||
}
|
||||
@ -1222,14 +1349,13 @@ declare module ts {
|
||||
function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter;
|
||||
function isWhiteSpace(ch: number): boolean;
|
||||
function isLineBreak(ch: number): boolean;
|
||||
function couldStartTrivia(text: string, pos: number): boolean;
|
||||
function getLeadingCommentRanges(text: string, pos: number): CommentRange[];
|
||||
function getTrailingCommentRanges(text: string, pos: number): CommentRange[];
|
||||
function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean;
|
||||
function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean;
|
||||
/** Creates a scanner over a (possibly unspecified) range of a piece of text. */
|
||||
function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner;
|
||||
}
|
||||
declare module ts {
|
||||
declare namespace ts {
|
||||
function getDefaultLibFileName(options: CompilerOptions): string;
|
||||
function textSpanEnd(span: TextSpan): number;
|
||||
function textSpanIsEmpty(span: TextSpan): boolean;
|
||||
@ -1239,6 +1365,7 @@ declare module ts {
|
||||
function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan;
|
||||
function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean;
|
||||
function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean;
|
||||
function decodedTextSpanIntersectsWith(start1: number, length1: number, start2: number, length2: number): boolean;
|
||||
function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean;
|
||||
function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan;
|
||||
function createTextSpan(start: number, length: number): TextSpan;
|
||||
@ -1256,15 +1383,16 @@ declare module ts {
|
||||
* Vn.
|
||||
*/
|
||||
function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
|
||||
function getTypeParameterOwner(d: Declaration): Declaration;
|
||||
}
|
||||
declare module ts {
|
||||
declare namespace ts {
|
||||
function getNodeConstructor(kind: SyntaxKind): new () => Node;
|
||||
function createNode(kind: SyntaxKind): Node;
|
||||
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
|
||||
function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
|
||||
}
|
||||
declare module ts {
|
||||
declare namespace ts {
|
||||
/** The version of the TypeScript compiler release */
|
||||
const version: string;
|
||||
function findConfigFile(searchPath: string): string;
|
||||
@ -1273,7 +1401,7 @@ declare module ts {
|
||||
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
|
||||
}
|
||||
declare module ts {
|
||||
declare namespace ts {
|
||||
function parseCommandLine(commandLine: string[]): ParsedCommandLine;
|
||||
/**
|
||||
* Read tsconfig.json file
|
||||
@ -1300,7 +1428,7 @@ declare module ts {
|
||||
*/
|
||||
function parseConfigFile(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine;
|
||||
}
|
||||
declare module ts {
|
||||
declare namespace ts {
|
||||
/** The version of the language service API */
|
||||
let servicesVersion: string;
|
||||
interface Node {
|
||||
@ -1390,6 +1518,7 @@ declare module ts {
|
||||
log?(s: string): void;
|
||||
trace?(s: string): void;
|
||||
error?(s: string): void;
|
||||
useCaseSensitiveFileNames?(): boolean;
|
||||
}
|
||||
interface LanguageService {
|
||||
cleanupSemanticCache(): void;
|
||||
@ -1812,6 +1941,7 @@ declare module ts {
|
||||
static typeParameterName: string;
|
||||
static typeAliasName: string;
|
||||
static parameterName: string;
|
||||
static docCommentTagName: string;
|
||||
}
|
||||
const enum ClassificationType {
|
||||
comment = 1,
|
||||
@ -1831,6 +1961,7 @@ declare module ts {
|
||||
typeParameterName = 15,
|
||||
typeAliasName = 16,
|
||||
parameterName = 17,
|
||||
docCommentTagName = 18,
|
||||
}
|
||||
interface DisplayPartsSymbolWriter extends SymbolWriter {
|
||||
displayParts(): SymbolDisplayPart[];
|
||||
@ -1846,11 +1977,11 @@ declare module ts {
|
||||
isCancellationRequested(): boolean;
|
||||
throwIfCancellationRequested(): void;
|
||||
}
|
||||
function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string;
|
||||
function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string;
|
||||
function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile;
|
||||
let disableIncrementalParsing: boolean;
|
||||
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
|
||||
function createDocumentRegistry(): DocumentRegistry;
|
||||
function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry;
|
||||
function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo;
|
||||
function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService;
|
||||
function createClassifier(): Classifier;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
||||
"name": "typescript",
|
||||
"author": "Microsoft Corp.",
|
||||
"homepage": "http://typescriptlang.org/",
|
||||
"version": "1.5.2",
|
||||
"version": "1.5.3",
|
||||
"license": "Apache-2.0",
|
||||
"description": "TypeScript is a language for application scale JavaScript development",
|
||||
"keywords": [
|
||||
|
||||
@ -55,7 +55,7 @@ function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, nameMap:
|
||||
'// <auto-generated />\r\n' +
|
||||
'/// <reference path="types.ts" />\r\n' +
|
||||
'/* @internal */\r\n' +
|
||||
'module ts {\r\n' +
|
||||
'namespace ts {\r\n' +
|
||||
' export var Diagnostics = {\r\n';
|
||||
var names = Utilities.getObjectKeys(messageTable);
|
||||
for (var i = 0; i < names.length; i++) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,7 @@
|
||||
/// <reference path="core.ts"/>
|
||||
/// <reference path="scanner.ts"/>
|
||||
|
||||
module ts {
|
||||
namespace ts {
|
||||
/* @internal */
|
||||
export var optionDeclarations: CommandLineOption[] = [
|
||||
{
|
||||
@ -103,9 +103,14 @@ module ts {
|
||||
name: "noResolve",
|
||||
type: "boolean",
|
||||
},
|
||||
{
|
||||
name: "skipDefaultLibCheck",
|
||||
type: "boolean",
|
||||
},
|
||||
{
|
||||
name: "out",
|
||||
type: "string",
|
||||
isFilePath: true,
|
||||
description: Diagnostics.Concatenate_and_emit_output_to_single_file,
|
||||
paramType: Diagnostics.FILE,
|
||||
},
|
||||
@ -142,7 +147,7 @@ module ts {
|
||||
paramType: Diagnostics.LOCATION,
|
||||
},
|
||||
{
|
||||
name: "separateCompilation",
|
||||
name: "isolatedModules",
|
||||
type: "boolean",
|
||||
},
|
||||
{
|
||||
@ -188,10 +193,16 @@ module ts {
|
||||
type: "boolean",
|
||||
description: Diagnostics.Watch_input_files,
|
||||
},
|
||||
{
|
||||
name: "experimentalDecorators",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Enables_experimental_support_for_ES7_decorators
|
||||
},
|
||||
{
|
||||
name: "emitDecoratorMetadata",
|
||||
type: "boolean",
|
||||
experimental: true
|
||||
experimental: true,
|
||||
description: Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators
|
||||
}
|
||||
];
|
||||
|
||||
@ -343,7 +354,7 @@ module ts {
|
||||
|
||||
return {
|
||||
options: getCompilerOptions(),
|
||||
fileNames: getFiles(),
|
||||
fileNames: getFileNames(),
|
||||
errors
|
||||
};
|
||||
|
||||
@ -389,23 +400,24 @@ module ts {
|
||||
return options;
|
||||
}
|
||||
|
||||
function getFiles(): string[] {
|
||||
var files: string[] = [];
|
||||
function getFileNames(): string[] {
|
||||
var fileNames: string[] = [];
|
||||
if (hasProperty(json, "files")) {
|
||||
if (json["files"] instanceof Array) {
|
||||
var files = map(<string[]>json["files"], s => combinePaths(basePath, s));
|
||||
fileNames = map(<string[]>json["files"], s => combinePaths(basePath, s));
|
||||
}
|
||||
}
|
||||
else {
|
||||
var sysFiles = host.readDirectory(basePath, ".ts");
|
||||
var exclude = json["exclude"] instanceof Array ? map(<string[]>json["exclude"], normalizeSlashes) : undefined;
|
||||
var sysFiles = host.readDirectory(basePath, ".ts", exclude);
|
||||
for (var i = 0; i < sysFiles.length; i++) {
|
||||
var name = sysFiles[i];
|
||||
if (!fileExtensionIs(name, ".d.ts") || !contains(sysFiles, name.substr(0, name.length - 5) + ".ts")) {
|
||||
files.push(name);
|
||||
fileNames.push(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
return files;
|
||||
return fileNames;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/// <reference path="types.ts"/>
|
||||
|
||||
/* @internal */
|
||||
module ts {
|
||||
namespace ts {
|
||||
// Ternary values are defined such that
|
||||
// x & y is False if either x or y is False.
|
||||
// x & y is Maybe if either x or y is Maybe, but neither x or y is False.
|
||||
@ -15,6 +15,42 @@ module ts {
|
||||
True = -1
|
||||
}
|
||||
|
||||
export function createFileMap<T>(getCanonicalFileName: (fileName: string) => string): FileMap<T> {
|
||||
let files: Map<T> = {};
|
||||
return {
|
||||
get,
|
||||
set,
|
||||
contains,
|
||||
remove,
|
||||
forEachValue: forEachValueInMap
|
||||
}
|
||||
|
||||
function set(fileName: string, value: T) {
|
||||
files[normalizeKey(fileName)] = value;
|
||||
}
|
||||
|
||||
function get(fileName: string) {
|
||||
return files[normalizeKey(fileName)];
|
||||
}
|
||||
|
||||
function contains(fileName: string) {
|
||||
return hasProperty(files, normalizeKey(fileName));
|
||||
}
|
||||
|
||||
function remove (fileName: string) {
|
||||
let key = normalizeKey(fileName);
|
||||
delete files[key];
|
||||
}
|
||||
|
||||
function forEachValueInMap(f: (value: T) => void) {
|
||||
forEachValue(files, f);
|
||||
}
|
||||
|
||||
function normalizeKey(key: string) {
|
||||
return getCanonicalFileName(normalizeSlashes(key));
|
||||
}
|
||||
}
|
||||
|
||||
export const enum Comparison {
|
||||
LessThan = -1,
|
||||
EqualTo = 0,
|
||||
@ -129,6 +165,16 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function rangeEquals<T>(array1: T[], array2: T[], pos: number, end: number) {
|
||||
while (pos < end) {
|
||||
if (array1[pos] !== array2[pos]) {
|
||||
return false;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last element of an array if non-empty, undefined otherwise.
|
||||
*/
|
||||
@ -526,7 +572,7 @@ module ts {
|
||||
export function getNormalizedPathComponents(path: string, currentDirectory: string) {
|
||||
path = normalizeSlashes(path);
|
||||
let rootLength = getRootLength(path);
|
||||
if (rootLength == 0) {
|
||||
if (rootLength === 0) {
|
||||
// If the path is not rooted it is relative to current directory
|
||||
path = combinePaths(normalizeSlashes(currentDirectory), path);
|
||||
rootLength = getRootLength(path);
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/// <reference path="checker.ts"/>
|
||||
|
||||
/* @internal */
|
||||
module ts {
|
||||
namespace ts {
|
||||
interface ModuleElementDeclarationEmitInfo {
|
||||
node: Node;
|
||||
outputPos: number;
|
||||
@ -709,7 +709,12 @@ module ts {
|
||||
function writeModuleDeclaration(node: ModuleDeclaration) {
|
||||
emitJsDocComments(node);
|
||||
emitModuleElementDeclarationFlags(node);
|
||||
write("module ");
|
||||
if (node.flags & NodeFlags.Namespace) {
|
||||
write("namespace ");
|
||||
}
|
||||
else {
|
||||
write("module ");
|
||||
}
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
while (node.body.kind !== SyntaxKind.ModuleBlock) {
|
||||
node = <ModuleDeclaration>node.body;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// <auto-generated />
|
||||
/// <reference path="types.ts" />
|
||||
/* @internal */
|
||||
module ts {
|
||||
namespace ts {
|
||||
export var Diagnostics = {
|
||||
Unterminated_string_literal: { code: 1002, category: DiagnosticCategory.Error, key: "Unterminated string literal." },
|
||||
Identifier_expected: { code: 1003, category: DiagnosticCategory.Error, key: "Identifier expected." },
|
||||
@ -120,7 +120,7 @@ module ts {
|
||||
Unterminated_template_literal: { code: 1160, category: DiagnosticCategory.Error, key: "Unterminated template literal." },
|
||||
Unterminated_regular_expression_literal: { code: 1161, category: DiagnosticCategory.Error, key: "Unterminated regular expression literal." },
|
||||
An_object_member_cannot_be_declared_optional: { code: 1162, category: DiagnosticCategory.Error, key: "An object member cannot be declared optional." },
|
||||
yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: DiagnosticCategory.Error, key: "'yield' expression must be contained_within a generator declaration." },
|
||||
A_yield_expression_is_only_allowed_in_a_generator_body: { code: 1163, category: DiagnosticCategory.Error, key: "A 'yield' expression is only allowed in a generator body." },
|
||||
Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." },
|
||||
A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: DiagnosticCategory.Error, key: "A computed property name in an ambient context must directly refer to a built-in symbol." },
|
||||
A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: DiagnosticCategory.Error, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." },
|
||||
@ -165,22 +165,38 @@ module ts {
|
||||
Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." },
|
||||
Decorators_are_not_valid_here: { code: 1206, category: DiagnosticCategory.Error, key: "Decorators are not valid here." },
|
||||
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." },
|
||||
Cannot_compile_namespaces_when_the_separateCompilation_flag_is_provided: { code: 1208, category: DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--separateCompilation' flag is provided." },
|
||||
Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." },
|
||||
Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." },
|
||||
Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { code: 1209, category: DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--isolatedModules' flag is provided." },
|
||||
Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." },
|
||||
A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" },
|
||||
Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" },
|
||||
Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." },
|
||||
Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" },
|
||||
Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." },
|
||||
Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: { code: 1214, category: DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode." },
|
||||
Invalid_use_of_0_Modules_are_automatically_in_strict_mode: { code: 1215, category: DiagnosticCategory.Error, key: "Invalid use of '{0}'. Modules are automatically in strict mode." },
|
||||
Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." },
|
||||
_0_tag_already_specified: { code: 1219, category: DiagnosticCategory.Error, key: "'{0}' tag already specified." },
|
||||
The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1220, category: DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." },
|
||||
The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1221, category: DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." },
|
||||
Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1222, category: DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." },
|
||||
Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1223, category: DiagnosticCategory.Error, key: "Unable to resolve signature of parameter decorator when called as an expression." },
|
||||
Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1224, category: DiagnosticCategory.Error, key: "Unable to resolve signature of property decorator when called as an expression." },
|
||||
Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1225, category: DiagnosticCategory.Error, key: "Unable to resolve signature of method decorator when called as an expression." },
|
||||
Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: DiagnosticCategory.Error, key: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." },
|
||||
Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1220, category: DiagnosticCategory.Error, key: "Generators are only available when targeting ECMAScript 6 or higher." },
|
||||
Generators_are_not_allowed_in_an_ambient_context: { code: 1221, category: DiagnosticCategory.Error, key: "Generators are not allowed in an ambient context." },
|
||||
An_overload_signature_cannot_be_declared_as_a_generator: { code: 1222, category: DiagnosticCategory.Error, key: "An overload signature cannot be declared as a generator." },
|
||||
_0_tag_already_specified: { code: 1223, category: DiagnosticCategory.Error, key: "'{0}' tag already specified." },
|
||||
Signature_0_must_have_a_type_predicate: { code: 1224, category: DiagnosticCategory.Error, key: "Signature '{0}' must have a type predicate." },
|
||||
Cannot_find_parameter_0: { code: 1225, category: DiagnosticCategory.Error, key: "Cannot find parameter '{0}'." },
|
||||
Type_predicate_0_is_not_assignable_to_1: { code: 1226, category: DiagnosticCategory.Error, key: "Type predicate '{0}' is not assignable to '{1}'." },
|
||||
Parameter_0_is_not_in_the_same_position_as_parameter_1: { code: 1227, category: DiagnosticCategory.Error, key: "Parameter '{0}' is not in the same position as parameter '{1}'." },
|
||||
A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: { code: 1228, category: DiagnosticCategory.Error, key: "A type predicate is only allowed in return type position for functions and methods." },
|
||||
A_type_predicate_cannot_reference_a_rest_parameter: { code: 1229, category: DiagnosticCategory.Error, key: "A type predicate cannot reference a rest parameter." },
|
||||
A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: { code: 1230, category: DiagnosticCategory.Error, key: "A type predicate cannot reference element '{0}' in a binding pattern." },
|
||||
An_export_assignment_can_only_be_used_in_a_module: { code: 1231, category: DiagnosticCategory.Error, key: "An export assignment can only be used in a module." },
|
||||
An_import_declaration_can_only_be_used_in_a_namespace_or_module: { code: 1232, category: DiagnosticCategory.Error, key: "An import declaration can only be used in a namespace or module." },
|
||||
An_export_declaration_can_only_be_used_in_a_module: { code: 1233, category: DiagnosticCategory.Error, key: "An export declaration can only be used in a module." },
|
||||
An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: { code: 1234, category: DiagnosticCategory.Error, key: "An ambient module declaration is only allowed at the top level in a file." },
|
||||
A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: { code: 1235, category: DiagnosticCategory.Error, key: "A namespace declaration is only allowed in a namespace or module." },
|
||||
The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: { code: 1236, category: DiagnosticCategory.Error, key: "The return type of a property decorator function must be either 'void' or 'any'." },
|
||||
The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: { code: 1237, category: DiagnosticCategory.Error, key: "The return type of a parameter decorator function must be either 'void' or 'any'." },
|
||||
Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: { code: 1238, category: DiagnosticCategory.Error, key: "Unable to resolve signature of class decorator when called as an expression." },
|
||||
Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: DiagnosticCategory.Error, key: "Unable to resolve signature of parameter decorator when called as an expression." },
|
||||
Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: DiagnosticCategory.Error, key: "Unable to resolve signature of property decorator when called as an expression." },
|
||||
Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: DiagnosticCategory.Error, key: "Unable to resolve signature of method decorator when called as an expression." },
|
||||
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
|
||||
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
|
||||
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },
|
||||
@ -372,6 +388,13 @@ module ts {
|
||||
A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: DiagnosticCategory.Error, key: "A rest element cannot contain a binding pattern." },
|
||||
_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own type annotation." },
|
||||
Cannot_find_namespace_0: { code: 2503, category: DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." },
|
||||
No_best_common_type_exists_among_yield_expressions: { code: 2504, category: DiagnosticCategory.Error, key: "No best common type exists among yield expressions." },
|
||||
A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." },
|
||||
_0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own base expression." },
|
||||
Type_0_is_not_a_constructor_function_type: { code: 2507, category: DiagnosticCategory.Error, key: "Type '{0}' is not a constructor function type." },
|
||||
No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." },
|
||||
Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." },
|
||||
Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: DiagnosticCategory.Error, key: "Base constructors must all have the same return type." },
|
||||
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
|
||||
@ -456,11 +479,11 @@ module ts {
|
||||
Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." },
|
||||
Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." },
|
||||
Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." },
|
||||
Option_sourceMap_cannot_be_specified_with_option_separateCompilation: { code: 5043, category: DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'separateCompilation'." },
|
||||
Option_declaration_cannot_be_specified_with_option_separateCompilation: { code: 5044, category: DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'separateCompilation'." },
|
||||
Option_noEmitOnError_cannot_be_specified_with_option_separateCompilation: { code: 5045, category: DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'separateCompilation'." },
|
||||
Option_out_cannot_be_specified_with_option_separateCompilation: { code: 5046, category: DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'separateCompilation'." },
|
||||
Option_separateCompilation_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: DiagnosticCategory.Error, key: "Option 'separateCompilation' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." },
|
||||
Option_sourceMap_cannot_be_specified_with_option_isolatedModules: { code: 5043, category: DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'isolatedModules'." },
|
||||
Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." },
|
||||
Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." },
|
||||
Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'isolatedModules'." },
|
||||
Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." },
|
||||
Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap: { code: 5048, category: DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." },
|
||||
Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." },
|
||||
Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'." },
|
||||
@ -514,6 +537,9 @@ module ts {
|
||||
Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." },
|
||||
NEWLINE: { code: 6061, category: DiagnosticCategory.Message, key: "NEWLINE" },
|
||||
Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." },
|
||||
Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." },
|
||||
Enables_experimental_support_for_ES7_decorators: { code: 6065, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." },
|
||||
Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." },
|
||||
Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
|
||||
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
|
||||
Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
|
||||
@ -526,9 +552,10 @@ module ts {
|
||||
Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: DiagnosticCategory.Error, key: "Object literal's property '{0}' implicitly has an '{1}' type." },
|
||||
Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: DiagnosticCategory.Error, key: "Rest parameter '{0}' implicitly has an 'any[]' type." },
|
||||
Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: DiagnosticCategory.Error, key: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." },
|
||||
_0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer." },
|
||||
_0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer." },
|
||||
_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: DiagnosticCategory.Error, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." },
|
||||
Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." },
|
||||
Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: DiagnosticCategory.Error, key: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." },
|
||||
You_cannot_rename_this_element: { code: 8000, category: DiagnosticCategory.Error, key: "You cannot rename this element." },
|
||||
You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." },
|
||||
import_can_only_be_used_in_a_ts_file: { code: 8002, category: DiagnosticCategory.Error, key: "'import ... =' can only be used in a .ts file." },
|
||||
@ -546,10 +573,7 @@ module ts {
|
||||
enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: DiagnosticCategory.Error, key: "'enum declarations' can only be used in a .ts file." },
|
||||
type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: DiagnosticCategory.Error, key: "'type assertion expressions' can only be used in a .ts file." },
|
||||
decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." },
|
||||
yield_expressions_are_not_currently_supported: { code: 9000, category: DiagnosticCategory.Error, key: "'yield' expressions are not currently supported." },
|
||||
Generators_are_not_currently_supported: { code: 9001, category: DiagnosticCategory.Error, key: "Generators are not currently supported." },
|
||||
Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." },
|
||||
class_expressions_are_not_currently_supported: { code: 9003, category: DiagnosticCategory.Error, key: "'class' expressions are not currently supported." },
|
||||
class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration: { code: 9004, category: DiagnosticCategory.Error, key: "'class' declarations are only supported directly inside a module or as a top level declaration." },
|
||||
};
|
||||
}
|
||||
@ -467,7 +467,7 @@
|
||||
"category": "Error",
|
||||
"code": 1162
|
||||
},
|
||||
"'yield' expression must be contained_within a generator declaration.": {
|
||||
"A 'yield' expression is only allowed in a generator body.": {
|
||||
"category": "Error",
|
||||
"code": 1163
|
||||
},
|
||||
@ -647,11 +647,11 @@
|
||||
"category": "Error",
|
||||
"code": 1207
|
||||
},
|
||||
"Cannot compile namespaces when the '--separateCompilation' flag is provided.": {
|
||||
"Cannot compile namespaces when the '--isolatedModules' flag is provided.": {
|
||||
"category": "Error",
|
||||
"code": 1208
|
||||
},
|
||||
"Ambient const enums are not allowed when the '--separateCompilation' flag is provided.": {
|
||||
"Ambient const enums are not allowed when the '--isolatedModules' flag is provided.": {
|
||||
"category": "Error",
|
||||
"code": 1209
|
||||
},
|
||||
@ -671,46 +671,112 @@
|
||||
"category": "Error",
|
||||
"code": 1213
|
||||
},
|
||||
"Type expected. '{0}' is a reserved word in strict mode": {
|
||||
"Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode.": {
|
||||
"category": "Error",
|
||||
"code": 1214
|
||||
},
|
||||
"Invalid use of '{0}'. Modules are automatically in strict mode.": {
|
||||
"category": "Error",
|
||||
"code": 1215
|
||||
},
|
||||
"Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode.": {
|
||||
"category": "Error",
|
||||
"code": 1216
|
||||
},
|
||||
"Export assignment is not supported when '--module' flag is 'system'.": {
|
||||
"category": "Error",
|
||||
"code": 1218
|
||||
},
|
||||
"'{0}' tag already specified.": {
|
||||
"Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning.": {
|
||||
"category": "Error",
|
||||
"code": 1219
|
||||
},
|
||||
"The return type of a property decorator function must be either 'void' or 'any'.": {
|
||||
},
|
||||
"Generators are only available when targeting ECMAScript 6 or higher.": {
|
||||
"category": "Error",
|
||||
"code": 1220
|
||||
},
|
||||
"The return type of a parameter decorator function must be either 'void' or 'any'.": {
|
||||
"Generators are not allowed in an ambient context.": {
|
||||
"category": "Error",
|
||||
"code": 1221
|
||||
},
|
||||
"Unable to resolve signature of class decorator when called as an expression.": {
|
||||
"An overload signature cannot be declared as a generator.": {
|
||||
"category": "Error",
|
||||
"code": 1222
|
||||
},
|
||||
"Unable to resolve signature of parameter decorator when called as an expression.": {
|
||||
"'{0}' tag already specified.": {
|
||||
"category": "Error",
|
||||
"code": 1223
|
||||
},
|
||||
"Unable to resolve signature of property decorator when called as an expression.": {
|
||||
"Signature '{0}' must have a type predicate.": {
|
||||
"category": "Error",
|
||||
"code": 1224
|
||||
},
|
||||
"Unable to resolve signature of method decorator when called as an expression.": {
|
||||
"Cannot find parameter '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 1225
|
||||
},
|
||||
"Type predicate '{0}' is not assignable to '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 1226
|
||||
},
|
||||
"Parameter '{0}' is not in the same position as parameter '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 1227
|
||||
},
|
||||
"A type predicate is only allowed in return type position for functions and methods.": {
|
||||
"category": "Error",
|
||||
"code": 1228
|
||||
},
|
||||
"A type predicate cannot reference a rest parameter.": {
|
||||
"category": "Error",
|
||||
"code": 1229
|
||||
},
|
||||
"A type predicate cannot reference element '{0}' in a binding pattern.": {
|
||||
"category": "Error",
|
||||
"code": 1230
|
||||
},
|
||||
"An export assignment can only be used in a module.": {
|
||||
"category": "Error",
|
||||
"code": 1231
|
||||
},
|
||||
"An import declaration can only be used in a namespace or module.": {
|
||||
"category": "Error",
|
||||
"code": 1232
|
||||
},
|
||||
"An export declaration can only be used in a module.": {
|
||||
"category": "Error",
|
||||
"code": 1233
|
||||
},
|
||||
"An ambient module declaration is only allowed at the top level in a file.": {
|
||||
"category": "Error",
|
||||
"code": 1234
|
||||
},
|
||||
"A namespace declaration is only allowed in a namespace or module.": {
|
||||
"category": "Error",
|
||||
"code": 1235
|
||||
},
|
||||
|
||||
|
||||
"The return type of a property decorator function must be either 'void' or 'any'.": {
|
||||
"category": "Error",
|
||||
"code": 1236
|
||||
},
|
||||
"The return type of a parameter decorator function must be either 'void' or 'any'.": {
|
||||
"category": "Error",
|
||||
"code": 1237
|
||||
},
|
||||
"Unable to resolve signature of class decorator when called as an expression.": {
|
||||
"category": "Error",
|
||||
"code": 1238
|
||||
},
|
||||
"Unable to resolve signature of parameter decorator when called as an expression.": {
|
||||
"category": "Error",
|
||||
"code": 1239
|
||||
},
|
||||
"Unable to resolve signature of property decorator when called as an expression.": {
|
||||
"category": "Error",
|
||||
"code": 1240
|
||||
},
|
||||
"Unable to resolve signature of method decorator when called as an expression.": {
|
||||
"category": "Error",
|
||||
"code": 1241
|
||||
},
|
||||
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
@ -1476,6 +1542,34 @@
|
||||
"category": "Error",
|
||||
"code": 2503
|
||||
},
|
||||
"No best common type exists among yield expressions.": {
|
||||
"category": "Error",
|
||||
"code": 2504
|
||||
},
|
||||
"A generator cannot have a 'void' type annotation.": {
|
||||
"category": "Error",
|
||||
"code": 2505
|
||||
},
|
||||
"'{0}' is referenced directly or indirectly in its own base expression.": {
|
||||
"category": "Error",
|
||||
"code": 2506
|
||||
},
|
||||
"Type '{0}' is not a constructor function type.": {
|
||||
"category": "Error",
|
||||
"code": 2507
|
||||
},
|
||||
"No base constructor has the specified number of type arguments.": {
|
||||
"category": "Error",
|
||||
"code": 2508
|
||||
},
|
||||
"Base constructor return type '{0}' is not a class or interface type.": {
|
||||
"category": "Error",
|
||||
"code": 2509
|
||||
},
|
||||
"Base constructors must all have the same return type.": {
|
||||
"category": "Error",
|
||||
"code": 2510
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
@ -1813,23 +1907,23 @@
|
||||
"category": "Error",
|
||||
"code": 5042
|
||||
},
|
||||
"Option 'sourceMap' cannot be specified with option 'separateCompilation'.": {
|
||||
"Option 'sourceMap' cannot be specified with option 'isolatedModules'.": {
|
||||
"category": "Error",
|
||||
"code": 5043
|
||||
},
|
||||
"Option 'declaration' cannot be specified with option 'separateCompilation'.": {
|
||||
"Option 'declaration' cannot be specified with option 'isolatedModules'.": {
|
||||
"category": "Error",
|
||||
"code": 5044
|
||||
},
|
||||
"Option 'noEmitOnError' cannot be specified with option 'separateCompilation'.": {
|
||||
"Option 'noEmitOnError' cannot be specified with option 'isolatedModules'.": {
|
||||
"category": "Error",
|
||||
"code": 5045
|
||||
},
|
||||
"Option 'out' cannot be specified with option 'separateCompilation'.": {
|
||||
"Option 'out' cannot be specified with option 'isolatedModules'.": {
|
||||
"category": "Error",
|
||||
"code": 5046
|
||||
},
|
||||
"Option 'separateCompilation' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher.": {
|
||||
"Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher.": {
|
||||
"category": "Error",
|
||||
"code": 5047
|
||||
},
|
||||
@ -2046,7 +2140,18 @@
|
||||
"category": "Error",
|
||||
"code": 6062
|
||||
},
|
||||
|
||||
"Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified.": {
|
||||
"category": "Error",
|
||||
"code": 6064
|
||||
},
|
||||
"Enables experimental support for ES7 decorators.": {
|
||||
"category": "Message",
|
||||
"code": 6065
|
||||
},
|
||||
"Enables experimental support for emitting type metadata for decorators.": {
|
||||
"category": "Message",
|
||||
"code": 6066
|
||||
},
|
||||
|
||||
"Variable '{0}' implicitly has an '{1}' type.": {
|
||||
"category": "Error",
|
||||
@ -2096,7 +2201,7 @@
|
||||
"category": "Error",
|
||||
"code": 7020
|
||||
},
|
||||
"'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer.": {
|
||||
"'{0}' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.": {
|
||||
"category": "Error",
|
||||
"code": 7022
|
||||
},
|
||||
@ -2108,6 +2213,10 @@
|
||||
"category": "Error",
|
||||
"code": 7024
|
||||
},
|
||||
"Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type.": {
|
||||
"category": "Error",
|
||||
"code": 7025
|
||||
},
|
||||
"You cannot rename this element.": {
|
||||
"category": "Error",
|
||||
"code": 8000
|
||||
@ -2177,14 +2286,6 @@
|
||||
"code": 8017
|
||||
},
|
||||
|
||||
"'yield' expressions are not currently supported.": {
|
||||
"category": "Error",
|
||||
"code": 9000
|
||||
},
|
||||
"Generators are not currently supported.": {
|
||||
"category": "Error",
|
||||
"code": 9001
|
||||
},
|
||||
"Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses.": {
|
||||
"category": "Error",
|
||||
"code": 9002
|
||||
@ -2192,9 +2293,5 @@
|
||||
"'class' expressions are not currently supported.": {
|
||||
"category": "Error",
|
||||
"code": 9003
|
||||
},
|
||||
"'class' declarations are only supported directly inside a module or as a top level declaration.": {
|
||||
"category": "Error",
|
||||
"code": 9004
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/// <reference path="declarationEmitter.ts"/>
|
||||
|
||||
/* @internal */
|
||||
module ts {
|
||||
namespace ts {
|
||||
export function isExternalModuleOrDeclarationFile(sourceFile: SourceFile) {
|
||||
return isExternalModule(sourceFile) || isDeclarationFile(sourceFile);
|
||||
}
|
||||
@ -21,8 +21,7 @@ module ts {
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};`;
|
||||
|
||||
// emit output for the __decorate helper function
|
||||
@ -125,7 +124,6 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
|
||||
let generatedNameSet: Map<string> = {};
|
||||
let nodeToGeneratedName: string[] = [];
|
||||
let blockScopedVariableToGeneratedName: string[];
|
||||
let computedPropertyNamesToGeneratedNames: string[];
|
||||
|
||||
let extendsEmitted = false;
|
||||
@ -249,81 +247,44 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
}
|
||||
}
|
||||
|
||||
function assignGeneratedName(node: Node, name: string) {
|
||||
nodeToGeneratedName[getNodeId(node)] = unescapeIdentifier(name);
|
||||
}
|
||||
|
||||
function generateNameForFunctionOrClassDeclaration(node: Declaration) {
|
||||
if (!node.name) {
|
||||
assignGeneratedName(node, makeUniqueName("default"));
|
||||
}
|
||||
}
|
||||
|
||||
function generateNameForModuleOrEnum(node: ModuleDeclaration | EnumDeclaration) {
|
||||
if (node.name.kind === SyntaxKind.Identifier) {
|
||||
let name = node.name.text;
|
||||
// Use module/enum name itself if it is unique, otherwise make a unique variation
|
||||
assignGeneratedName(node, isUniqueLocalName(name, node) ? name : makeUniqueName(name));
|
||||
}
|
||||
let name = node.name.text;
|
||||
// Use module/enum name itself if it is unique, otherwise make a unique variation
|
||||
return isUniqueLocalName(name, node) ? name : makeUniqueName(name);
|
||||
}
|
||||
|
||||
function generateNameForImportOrExportDeclaration(node: ImportDeclaration | ExportDeclaration) {
|
||||
let expr = getExternalModuleName(node);
|
||||
let baseName = expr.kind === SyntaxKind.StringLiteral ?
|
||||
escapeIdentifier(makeIdentifierFromModuleName((<LiteralExpression>expr).text)) : "module";
|
||||
assignGeneratedName(node, makeUniqueName(baseName));
|
||||
return makeUniqueName(baseName);
|
||||
}
|
||||
|
||||
function generateNameForImportDeclaration(node: ImportDeclaration) {
|
||||
if (node.importClause) {
|
||||
generateNameForImportOrExportDeclaration(node);
|
||||
}
|
||||
}
|
||||
|
||||
function generateNameForExportDeclaration(node: ExportDeclaration) {
|
||||
if (node.moduleSpecifier) {
|
||||
generateNameForImportOrExportDeclaration(node);
|
||||
}
|
||||
}
|
||||
|
||||
function generateNameForExportAssignment(node: ExportAssignment) {
|
||||
if (node.expression && node.expression.kind !== SyntaxKind.Identifier) {
|
||||
assignGeneratedName(node, makeUniqueName("default"));
|
||||
}
|
||||
function generateNameForExportDefault() {
|
||||
return makeUniqueName("default");
|
||||
}
|
||||
|
||||
function generateNameForNode(node: Node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
return makeUniqueName((<Identifier>node).text);
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
return generateNameForModuleOrEnum(<ModuleDeclaration | EnumDeclaration>node);
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
return generateNameForImportOrExportDeclaration(<ImportDeclaration | ExportDeclaration>node);
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.ClassExpression:
|
||||
generateNameForFunctionOrClassDeclaration(<Declaration>node);
|
||||
break;
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
generateNameForModuleOrEnum(<ModuleDeclaration>node);
|
||||
generateNameForNode((<ModuleDeclaration>node).body);
|
||||
break;
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
generateNameForModuleOrEnum(<EnumDeclaration>node);
|
||||
break;
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
generateNameForImportDeclaration(<ImportDeclaration>node);
|
||||
break;
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
generateNameForExportDeclaration(<ExportDeclaration>node);
|
||||
break;
|
||||
case SyntaxKind.ExportAssignment:
|
||||
generateNameForExportAssignment(<ExportAssignment>node);
|
||||
break;
|
||||
return generateNameForExportDefault();
|
||||
}
|
||||
}
|
||||
|
||||
function getGeneratedNameForNode(node: Node) {
|
||||
let nodeId = getNodeId(node);
|
||||
if (!nodeToGeneratedName[nodeId]) {
|
||||
generateNameForNode(node);
|
||||
}
|
||||
return nodeToGeneratedName[nodeId];
|
||||
let id = getNodeId(node);
|
||||
return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = unescapeIdentifier(generateNameForNode(node)));
|
||||
}
|
||||
|
||||
function initializeEmitterWithSourceMaps() {
|
||||
@ -358,7 +319,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
|
||||
let prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn;
|
||||
// Line/Comma delimiters
|
||||
if (lastEncodedSourceMapSpan.emittedLine == lastRecordedSourceMapSpan.emittedLine) {
|
||||
if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) {
|
||||
// Emit comma to separate the entry
|
||||
if (sourceMapData.sourceMapMappings) {
|
||||
sourceMapData.sourceMapMappings += ",";
|
||||
@ -441,8 +402,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
|
||||
// If this location wasn't recorded or the location in source is going backwards, record the span
|
||||
if (!lastRecordedSourceMapSpan ||
|
||||
lastRecordedSourceMapSpan.emittedLine != emittedLine ||
|
||||
lastRecordedSourceMapSpan.emittedColumn != emittedColumn ||
|
||||
lastRecordedSourceMapSpan.emittedLine !== emittedLine ||
|
||||
lastRecordedSourceMapSpan.emittedColumn !== emittedColumn ||
|
||||
(lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex &&
|
||||
(lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line ||
|
||||
(lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) {
|
||||
@ -687,19 +648,19 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
sourceMapDir = getDirectoryPath(normalizePath(jsFilePath));
|
||||
}
|
||||
|
||||
function emitNodeWithSourceMap(node: Node, allowGeneratedIdentifiers?: boolean) {
|
||||
function emitNodeWithSourceMap(node: Node) {
|
||||
if (node) {
|
||||
if (nodeIsSynthesized(node)) {
|
||||
return emitNodeWithoutSourceMap(node, /*allowGeneratedIdentifiers*/ false);
|
||||
return emitNodeWithoutSourceMap(node);
|
||||
}
|
||||
if (node.kind != SyntaxKind.SourceFile) {
|
||||
if (node.kind !== SyntaxKind.SourceFile) {
|
||||
recordEmitNodeStartSpan(node);
|
||||
emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers);
|
||||
emitNodeWithoutSourceMap(node);
|
||||
recordEmitNodeEndSpan(node);
|
||||
}
|
||||
else {
|
||||
recordNewSourceFileStart(<SourceFile>node);
|
||||
emitNodeWithoutSourceMap(node, /*allowGeneratedIdentifiers*/ false);
|
||||
emitNodeWithoutSourceMap(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1201,80 +1162,129 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
}
|
||||
}
|
||||
|
||||
function isNotExpressionIdentifier(node: Identifier) {
|
||||
function isExpressionIdentifier(node: Node): boolean {
|
||||
let parent = node.parent;
|
||||
switch (parent.kind) {
|
||||
case SyntaxKind.Parameter:
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
case SyntaxKind.BindingElement:
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
case SyntaxKind.EnumMember:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
case SyntaxKind.ImportClause:
|
||||
case SyntaxKind.NamespaceImport:
|
||||
return (<Declaration>parent).name === node;
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
return (<ImportOrExportSpecifier>parent).name === node || (<ImportOrExportSpecifier>parent).propertyName === node;
|
||||
case SyntaxKind.BreakStatement:
|
||||
case SyntaxKind.ContinueStatement:
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
case SyntaxKind.BinaryExpression:
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.CaseClause:
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
case SyntaxKind.ConditionalExpression:
|
||||
case SyntaxKind.Decorator:
|
||||
case SyntaxKind.DeleteExpression:
|
||||
case SyntaxKind.DoStatement:
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
case SyntaxKind.ExportAssignment:
|
||||
return false;
|
||||
case SyntaxKind.LabeledStatement:
|
||||
return (<LabeledStatement>node.parent).label === node;
|
||||
case SyntaxKind.ExpressionStatement:
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
case SyntaxKind.ForStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
case SyntaxKind.IfStatement:
|
||||
case SyntaxKind.NewExpression:
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
case SyntaxKind.PostfixUnaryExpression:
|
||||
case SyntaxKind.PrefixUnaryExpression:
|
||||
case SyntaxKind.ReturnStatement:
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
case SyntaxKind.SpreadElementExpression:
|
||||
case SyntaxKind.SwitchStatement:
|
||||
case SyntaxKind.TaggedTemplateExpression:
|
||||
case SyntaxKind.TemplateSpan:
|
||||
case SyntaxKind.ThrowStatement:
|
||||
case SyntaxKind.TypeAssertionExpression:
|
||||
case SyntaxKind.TypeOfExpression:
|
||||
case SyntaxKind.VoidExpression:
|
||||
case SyntaxKind.WhileStatement:
|
||||
case SyntaxKind.WithStatement:
|
||||
case SyntaxKind.YieldExpression:
|
||||
return true;
|
||||
case SyntaxKind.BindingElement:
|
||||
case SyntaxKind.EnumMember:
|
||||
case SyntaxKind.Parameter:
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
return (<BindingElement | EnumMember | ParameterDeclaration | PropertyAssignment | PropertyDeclaration | VariableDeclaration>parent).initializer === node;
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
return (<ExpressionStatement>parent).expression === node;
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
return (<FunctionLikeDeclaration>parent).body === node;
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
return (<ImportEqualsDeclaration>parent).moduleReference === node;
|
||||
case SyntaxKind.QualifiedName:
|
||||
return (<QualifiedName>parent).left === node;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function emitExpressionIdentifier(node: Identifier) {
|
||||
let substitution = resolver.getExpressionNameSubstitution(node, getGeneratedNameForNode);
|
||||
if (substitution) {
|
||||
write(substitution);
|
||||
let container = resolver.getReferencedExportContainer(node);
|
||||
if (container) {
|
||||
if (container.kind === SyntaxKind.SourceFile) {
|
||||
// Identifier references module export
|
||||
if (languageVersion < ScriptTarget.ES6 && compilerOptions.module !== ModuleKind.System) {
|
||||
write("exports.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Identifier references namespace export
|
||||
write(getGeneratedNameForNode(container));
|
||||
write(".");
|
||||
}
|
||||
}
|
||||
else {
|
||||
writeTextOfNode(currentSourceFile, node);
|
||||
}
|
||||
}
|
||||
|
||||
function getGeneratedNameForIdentifier(node: Identifier): string {
|
||||
if (nodeIsSynthesized(node) || !blockScopedVariableToGeneratedName) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var variableId = resolver.getBlockScopedVariableId(node)
|
||||
if (variableId === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return blockScopedVariableToGeneratedName[variableId];
|
||||
}
|
||||
|
||||
function emitIdentifier(node: Identifier, allowGeneratedIdentifiers: boolean) {
|
||||
if (allowGeneratedIdentifiers) {
|
||||
let generatedName = getGeneratedNameForIdentifier(node);
|
||||
if (generatedName) {
|
||||
write(generatedName);
|
||||
else if (languageVersion < ScriptTarget.ES6) {
|
||||
let declaration = resolver.getReferencedImportDeclaration(node);
|
||||
if (declaration) {
|
||||
if (declaration.kind === SyntaxKind.ImportClause) {
|
||||
// Identifier references default import
|
||||
write(getGeneratedNameForNode(<ImportDeclaration>declaration.parent));
|
||||
write(languageVersion === ScriptTarget.ES3 ? '["default"]' : ".default");
|
||||
return;
|
||||
}
|
||||
else if (declaration.kind === SyntaxKind.ImportSpecifier) {
|
||||
// Identifier references named import
|
||||
write(getGeneratedNameForNode(<ImportDeclaration>declaration.parent.parent.parent));
|
||||
write(".");
|
||||
writeTextOfNode(currentSourceFile, (<ImportSpecifier>declaration).propertyName || (<ImportSpecifier>declaration).name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
declaration = resolver.getReferencedNestedRedeclaration(node);
|
||||
if (declaration) {
|
||||
write(getGeneratedNameForNode(declaration.name));
|
||||
return;
|
||||
}
|
||||
}
|
||||
writeTextOfNode(currentSourceFile, node);
|
||||
}
|
||||
|
||||
function isNameOfNestedRedeclaration(node: Identifier) {
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
let parent = node.parent;
|
||||
switch (parent.kind) {
|
||||
case SyntaxKind.BindingElement:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
return (<Declaration>parent).name === node && resolver.isNestedRedeclaration(<Declaration>parent);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function emitIdentifier(node: Identifier) {
|
||||
if (!node.parent) {
|
||||
write(node.text);
|
||||
}
|
||||
else if (!isNotExpressionIdentifier(node)) {
|
||||
else if (isExpressionIdentifier(node)) {
|
||||
emitExpressionIdentifier(node);
|
||||
}
|
||||
else if (isNameOfNestedRedeclaration(node)) {
|
||||
write(getGeneratedNameForNode(node));
|
||||
}
|
||||
else {
|
||||
writeTextOfNode(currentSourceFile, node);
|
||||
}
|
||||
@ -1320,7 +1330,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
|
||||
function emitBindingElement(node: BindingElement) {
|
||||
if (node.propertyName) {
|
||||
emit(node.propertyName, /*allowGeneratedIdentifiers*/ false);
|
||||
emit(node.propertyName);
|
||||
write(": ");
|
||||
}
|
||||
if (node.dotDotDotToken) {
|
||||
@ -1646,6 +1656,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
}
|
||||
|
||||
function parenthesizeForAccess(expr: Expression): LeftHandSideExpression {
|
||||
// When diagnosing whether the expression needs parentheses, the decision should be based
|
||||
// on the innermost expression in a chain of nested type assertions.
|
||||
while (expr.kind === SyntaxKind.TypeAssertionExpression) {
|
||||
expr = (<TypeAssertion>expr).expression;
|
||||
}
|
||||
|
||||
// isLeftHandSideExpression is almost the correct criterion for when it is not necessary
|
||||
// to parenthesize the expression before a dot. The known exceptions are:
|
||||
//
|
||||
@ -1654,7 +1670,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
// NumberLiteral
|
||||
// 1.x -> not the same as (1).x
|
||||
//
|
||||
if (isLeftHandSideExpression(expr) && expr.kind !== SyntaxKind.NewExpression && expr.kind !== SyntaxKind.NumericLiteral) {
|
||||
if (isLeftHandSideExpression(expr) &&
|
||||
expr.kind !== SyntaxKind.NewExpression &&
|
||||
expr.kind !== SyntaxKind.NumericLiteral) {
|
||||
|
||||
return <LeftHandSideExpression>expr;
|
||||
}
|
||||
let node = <ParenthesizedExpression>createSynthesizedNode(SyntaxKind.ParenthesizedExpression);
|
||||
@ -1673,7 +1692,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
write("*");
|
||||
}
|
||||
|
||||
emit(node.name, /*allowGeneratedIdentifiers*/ false);
|
||||
emit(node.name);
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
write(": function ");
|
||||
}
|
||||
@ -1681,45 +1700,39 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
}
|
||||
|
||||
function emitPropertyAssignment(node: PropertyDeclaration) {
|
||||
emit(node.name, /*allowGeneratedIdentifiers*/ false);
|
||||
emit(node.name);
|
||||
write(": ");
|
||||
emit(node.initializer);
|
||||
}
|
||||
|
||||
// Return true if identifier resolves to an exported member of a namespace
|
||||
function isNamespaceExportReference(node: Identifier) {
|
||||
let container = resolver.getReferencedExportContainer(node);
|
||||
return container && container.kind !== SyntaxKind.SourceFile;
|
||||
}
|
||||
|
||||
function emitShorthandPropertyAssignment(node: ShorthandPropertyAssignment) {
|
||||
emit(node.name, /*allowGeneratedIdentifiers*/ false);
|
||||
// If short-hand property has a prefix, then regardless of the target version, we will emit it as normal property assignment. For example:
|
||||
// module m {
|
||||
// export let y;
|
||||
// }
|
||||
// module m {
|
||||
// export let obj = { y };
|
||||
// }
|
||||
// The short-hand property in obj need to emit as such ... = { y : m.y } regardless of the TargetScript version
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
// The name property of a short-hand property assignment is considered an expression position, so here
|
||||
// we manually emit the identifier to avoid rewriting.
|
||||
writeTextOfNode(currentSourceFile, node.name);
|
||||
// If emitting pre-ES6 code, or if the name requires rewriting when resolved as an expression identifier,
|
||||
// we emit a normal property assignment. For example:
|
||||
// module m {
|
||||
// export let y;
|
||||
// }
|
||||
// module m {
|
||||
// let obj = { y };
|
||||
// }
|
||||
// Here we need to emit obj = { y : m.y } regardless of the output target.
|
||||
if (languageVersion < ScriptTarget.ES6 || isNamespaceExportReference(node.name)) {
|
||||
// Emit identifier as an identifier
|
||||
write(": ");
|
||||
var generatedName = getGeneratedNameForIdentifier(node.name);
|
||||
if (generatedName) {
|
||||
write(generatedName);
|
||||
}
|
||||
else {
|
||||
// Even though this is stored as identifier treat it as an expression
|
||||
// Short-hand, { x }, is equivalent of normal form { x: x }
|
||||
emitExpressionIdentifier(node.name);
|
||||
}
|
||||
}
|
||||
else if (resolver.getExpressionNameSubstitution(node.name, getGeneratedNameForNode)) {
|
||||
// Emit identifier as an identifier
|
||||
write(": ");
|
||||
// Even though this is stored as identifier treat it as an expression
|
||||
// Short-hand, { x }, is equivalent of normal form { x: x }
|
||||
emitExpressionIdentifier(node.name);
|
||||
emit(node.name);
|
||||
}
|
||||
}
|
||||
|
||||
function tryEmitConstantValue(node: PropertyAccessExpression | ElementAccessExpression): boolean {
|
||||
if (compilerOptions.separateCompilation) {
|
||||
if (compilerOptions.isolatedModules) {
|
||||
// do not inline enum values in separate compilation mode
|
||||
return false;
|
||||
}
|
||||
@ -1767,7 +1780,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
let indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken);
|
||||
write(".");
|
||||
let indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name);
|
||||
emit(node.name, /*allowGeneratedIdentifiers*/ false);
|
||||
emit(node.name);
|
||||
decreaseIndentIf(indentedBeforeDot, indentedAfterDot);
|
||||
}
|
||||
|
||||
@ -1889,23 +1902,21 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
function emitNewExpression(node: NewExpression) {
|
||||
write("new ");
|
||||
|
||||
// Spread operator logic can be supported in new expressions in ES5 using a combination
|
||||
// Spread operator logic is supported in new expressions in ES5 using a combination
|
||||
// of Function.prototype.bind() and Function.prototype.apply().
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var arguments = [1, 2, 3, 4, 5];
|
||||
// new Array(...arguments);
|
||||
// var args = [1, 2, 3, 4, 5];
|
||||
// new Array(...args);
|
||||
//
|
||||
// Could be transpiled into ES5:
|
||||
// is compiled into the following ES5:
|
||||
//
|
||||
// var arguments = [1, 2, 3, 4, 5];
|
||||
// new (Array.bind.apply(Array, [void 0].concat(arguments)));
|
||||
// var args = [1, 2, 3, 4, 5];
|
||||
// new (Array.bind.apply(Array, [void 0].concat(args)));
|
||||
//
|
||||
// `[void 0]` is the first argument which represents `thisArg` to the bind method above.
|
||||
// And `thisArg` will be set to the return value of the constructor when instantiated
|
||||
// with the new operator — regardless of any value we set `thisArg` to. Thus, we set it
|
||||
// to an undefined, `void 0`.
|
||||
// The 'thisArg' to 'bind' is ignored when invoking the result of 'bind' with 'new',
|
||||
// Thus, we set it to undefined ('void 0').
|
||||
if (languageVersion === ScriptTarget.ES5 &&
|
||||
node.arguments &&
|
||||
hasSpreadElement(node.arguments)) {
|
||||
@ -1941,13 +1952,16 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
}
|
||||
|
||||
function emitParenExpression(node: ParenthesizedExpression) {
|
||||
if (!node.parent || node.parent.kind !== SyntaxKind.ArrowFunction) {
|
||||
// If the node is synthesized, it means the emitter put the parentheses there,
|
||||
// not the user. If we didn't want them, the emitter would not have put them
|
||||
// there.
|
||||
if (!nodeIsSynthesized(node) && node.parent.kind !== SyntaxKind.ArrowFunction) {
|
||||
if (node.expression.kind === SyntaxKind.TypeAssertionExpression) {
|
||||
let operand = (<TypeAssertion>node.expression).expression;
|
||||
|
||||
// Make sure we consider all nested cast expressions, e.g.:
|
||||
// (<any><number><any>-A).x;
|
||||
while (operand.kind == SyntaxKind.TypeAssertionExpression) {
|
||||
while (operand.kind === SyntaxKind.TypeAssertionExpression) {
|
||||
operand = (<TypeAssertion>operand).expression;
|
||||
}
|
||||
|
||||
@ -2769,8 +2783,6 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
write(", ");
|
||||
}
|
||||
|
||||
renameNonTopLevelLetAndConst(name);
|
||||
|
||||
const isVariableDeclarationOrBindingElement =
|
||||
name.parent && (name.parent.kind === SyntaxKind.VariableDeclaration || name.parent.kind === SyntaxKind.BindingElement);
|
||||
|
||||
@ -2838,11 +2850,14 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
}
|
||||
|
||||
function createPropertyAccessForDestructuringProperty(object: Expression, propName: Identifier | LiteralExpression): Expression {
|
||||
if (propName.kind !== SyntaxKind.Identifier) {
|
||||
return createElementAccessExpression(object, propName);
|
||||
// We create a synthetic copy of the identifier in order to avoid the rewriting that might
|
||||
// otherwise occur when the identifier is emitted.
|
||||
let syntheticName = <Identifier | LiteralExpression>createSynthesizedNode(propName.kind);
|
||||
syntheticName.text = propName.text;
|
||||
if (syntheticName.kind !== SyntaxKind.Identifier) {
|
||||
return createElementAccessExpression(object, syntheticName);
|
||||
}
|
||||
|
||||
return createPropertyAccessExpression(object, propName);
|
||||
return createPropertyAccessExpression(object, syntheticName);
|
||||
}
|
||||
|
||||
function createSliceCall(value: Expression, sliceIndex: number): CallExpression {
|
||||
@ -2864,8 +2879,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
}
|
||||
for (let p of properties) {
|
||||
if (p.kind === SyntaxKind.PropertyAssignment || p.kind === SyntaxKind.ShorthandPropertyAssignment) {
|
||||
// TODO(andersh): Computed property support
|
||||
let propName = <Identifier | LiteralExpression>((<PropertyAssignment>p).name);
|
||||
let propName = <Identifier | LiteralExpression>(<PropertyAssignment>p).name;
|
||||
emitDestructuringAssignment((<PropertyAssignment>p).initializer || propName, createPropertyAccessForDestructuringProperty(value, propName));
|
||||
}
|
||||
}
|
||||
@ -2979,8 +2993,6 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
renameNonTopLevelLetAndConst(<Identifier>node.name);
|
||||
|
||||
let initializer = node.initializer;
|
||||
if (!initializer && languageVersion < ScriptTarget.ES6) {
|
||||
|
||||
@ -3040,54 +3052,6 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return getCombinedNodeFlags(node.parent);
|
||||
}
|
||||
|
||||
function renameNonTopLevelLetAndConst(node: Node): void {
|
||||
// do not rename if
|
||||
// - language version is ES6+
|
||||
// - node is synthesized
|
||||
// - node is not identifier (can happen when tree is malformed)
|
||||
// - node is definitely not name of variable declaration.
|
||||
// it still can be part of parameter declaration, this check will be done next
|
||||
if (languageVersion >= ScriptTarget.ES6 ||
|
||||
nodeIsSynthesized(node) ||
|
||||
node.kind !== SyntaxKind.Identifier ||
|
||||
(node.parent.kind !== SyntaxKind.VariableDeclaration && node.parent.kind !== SyntaxKind.BindingElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let combinedFlags = getCombinedFlagsForIdentifier(<Identifier>node);
|
||||
if (((combinedFlags & NodeFlags.BlockScoped) === 0) || combinedFlags & NodeFlags.Export) {
|
||||
// do not rename exported or non-block scoped variables
|
||||
return;
|
||||
}
|
||||
|
||||
// here it is known that node is a block scoped variable
|
||||
let list = getAncestor(node, SyntaxKind.VariableDeclarationList);
|
||||
if (list.parent.kind === SyntaxKind.VariableStatement) {
|
||||
let isSourceFileLevelBinding = list.parent.parent.kind === SyntaxKind.SourceFile;
|
||||
let isModuleLevelBinding = list.parent.parent.kind === SyntaxKind.ModuleBlock;
|
||||
let isFunctionLevelBinding =
|
||||
list.parent.parent.kind === SyntaxKind.Block && isFunctionLike(list.parent.parent.parent);
|
||||
if (isSourceFileLevelBinding || isModuleLevelBinding || isFunctionLevelBinding) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let blockScopeContainer = getEnclosingBlockScopeContainer(node);
|
||||
let parent = blockScopeContainer.kind === SyntaxKind.SourceFile
|
||||
? blockScopeContainer
|
||||
: blockScopeContainer.parent;
|
||||
|
||||
if (resolver.resolvesToSomeValue(parent, (<Identifier>node).text)) {
|
||||
let variableId = resolver.getBlockScopedVariableId(<Identifier>node);
|
||||
if (!blockScopedVariableToGeneratedName) {
|
||||
blockScopedVariableToGeneratedName = [];
|
||||
}
|
||||
|
||||
let generatedName = makeUniqueName((<Identifier>node).text);
|
||||
blockScopedVariableToGeneratedName[variableId] = generatedName;
|
||||
}
|
||||
}
|
||||
|
||||
function isES6ExportedDeclaration(node: Node) {
|
||||
return !!(node.flags & NodeFlags.Export) &&
|
||||
languageVersion >= ScriptTarget.ES6 &&
|
||||
@ -3205,7 +3169,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
}
|
||||
|
||||
function emitRestParameter(node: FunctionLikeDeclaration) {
|
||||
if (languageVersion < ScriptTarget.ES6 && hasRestParameters(node)) {
|
||||
if (languageVersion < ScriptTarget.ES6 && hasRestParameter(node)) {
|
||||
let restIndex = node.parameters.length - 1;
|
||||
let restParam = node.parameters[restIndex];
|
||||
|
||||
@ -3251,7 +3215,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
|
||||
function emitAccessor(node: AccessorDeclaration) {
|
||||
write(node.kind === SyntaxKind.GetAccessor ? "get " : "set ");
|
||||
emit(node.name, /*allowGeneratedIdentifiers*/ false);
|
||||
emit(node.name);
|
||||
emitSignatureAndBody(node);
|
||||
}
|
||||
|
||||
@ -3333,7 +3297,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
write("(");
|
||||
if (node) {
|
||||
let parameters = node.parameters;
|
||||
let omitCount = languageVersion < ScriptTarget.ES6 && hasRestParameters(node) ? 1 : 0;
|
||||
let omitCount = languageVersion < ScriptTarget.ES6 && hasRestParameter(node) ? 1 : 0;
|
||||
emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false);
|
||||
}
|
||||
write(")");
|
||||
@ -4354,7 +4318,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
let argumentsWritten = 0;
|
||||
if (compilerOptions.emitDecoratorMetadata) {
|
||||
if (shouldEmitTypeMetadata(node)) {
|
||||
var serializedType = resolver.serializeTypeOfNode(node, getGeneratedNameForNode);
|
||||
var serializedType = resolver.serializeTypeOfNode(node);
|
||||
if (serializedType) {
|
||||
if (writeComma) {
|
||||
write(", ");
|
||||
@ -4367,7 +4331,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
}
|
||||
}
|
||||
if (shouldEmitParamTypesMetadata(node)) {
|
||||
var serializedTypes = resolver.serializeParameterTypesOfNode(node, getGeneratedNameForNode);
|
||||
var serializedTypes = resolver.serializeParameterTypesOfNode(node);
|
||||
if (serializedTypes) {
|
||||
if (writeComma || argumentsWritten) {
|
||||
write(", ");
|
||||
@ -4385,7 +4349,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
}
|
||||
}
|
||||
if (shouldEmitReturnTypeMetadata(node)) {
|
||||
var serializedType = resolver.serializeReturnTypeOfNode(node, getGeneratedNameForNode);
|
||||
var serializedType = resolver.serializeReturnTypeOfNode(node);
|
||||
if (serializedType) {
|
||||
if (writeComma || argumentsWritten) {
|
||||
write(", ");
|
||||
@ -4430,7 +4394,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
|
||||
function shouldEmitEnumDeclaration(node: EnumDeclaration) {
|
||||
let isConstEnum = isConst(node);
|
||||
return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.separateCompilation;
|
||||
return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules;
|
||||
}
|
||||
|
||||
function emitEnumDeclaration(node: EnumDeclaration) {
|
||||
@ -4491,7 +4455,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
emitDeclarationName(node);
|
||||
write(`", `);
|
||||
emitDeclarationName(node);
|
||||
write(")");
|
||||
write(");");
|
||||
}
|
||||
emitExportMemberAssignments(node.name);
|
||||
}
|
||||
@ -4535,7 +4499,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
}
|
||||
|
||||
function shouldEmitModuleDeclaration(node: ModuleDeclaration) {
|
||||
return isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.separateCompilation);
|
||||
return isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules);
|
||||
}
|
||||
|
||||
function isModuleMergedWithES6Class(node: ModuleDeclaration) {
|
||||
@ -4612,7 +4576,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
emitDeclarationName(node);
|
||||
write(`", `);
|
||||
emitDeclarationName(node);
|
||||
write(")");
|
||||
write(");");
|
||||
}
|
||||
emitExportMemberAssignments(<Identifier>node.name);
|
||||
}
|
||||
@ -4983,13 +4947,16 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
}
|
||||
}
|
||||
|
||||
function getLocalNameForExternalImport(importNode: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration): string {
|
||||
let namespaceDeclaration = getNamespaceDeclarationNode(importNode);
|
||||
if (namespaceDeclaration && !isDefaultImport(importNode)) {
|
||||
function getLocalNameForExternalImport(node: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration): string {
|
||||
let namespaceDeclaration = getNamespaceDeclarationNode(node);
|
||||
if (namespaceDeclaration && !isDefaultImport(node)) {
|
||||
return getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name);
|
||||
}
|
||||
else {
|
||||
return getGeneratedNameForNode(<ImportDeclaration | ExportDeclaration>importNode);
|
||||
if (node.kind === SyntaxKind.ImportDeclaration && (<ImportDeclaration>node).importClause) {
|
||||
return getGeneratedNameForNode(node);
|
||||
}
|
||||
if (node.kind === SyntaxKind.ExportDeclaration && (<ExportDeclaration>node).moduleSpecifier) {
|
||||
return getGeneratedNameForNode(node);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5377,10 +5344,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
emitSetters(exportStarFunction);
|
||||
writeLine();
|
||||
emitExecute(node, startIndex);
|
||||
emitTempDeclarations(/*newLine*/ true)
|
||||
decreaseIndent();
|
||||
writeLine();
|
||||
write("}"); // return
|
||||
emitTempDeclarations(/*newLine*/ true);
|
||||
}
|
||||
|
||||
function emitSetters(exportStarFunction: string) {
|
||||
@ -5527,7 +5494,11 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
Debug.assert(!exportFunctionForFile);
|
||||
// make sure that name of 'exports' function does not conflict with existing identifiers
|
||||
exportFunctionForFile = makeUniqueName("exports");
|
||||
write("System.register([");
|
||||
write("System.register(");
|
||||
if (node.moduleName) {
|
||||
write(`"${node.moduleName}", `);
|
||||
}
|
||||
write("[")
|
||||
for (let i = 0; i < externalImports.length; ++i) {
|
||||
let text = getExternalModuleNameText(externalImports[i]);
|
||||
if (i !== 0) {
|
||||
@ -5613,8 +5584,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
|
||||
writeLine();
|
||||
write("define(");
|
||||
if (node.amdModuleName) {
|
||||
write("\"" + node.amdModuleName + "\", ");
|
||||
if (node.moduleName) {
|
||||
write("\"" + node.moduleName + "\", ");
|
||||
}
|
||||
emitAMDDependencies(node, /*includeNonAmdDependencies*/ true);
|
||||
write(") {");
|
||||
@ -5744,7 +5715,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
}
|
||||
}
|
||||
|
||||
if (isExternalModule(node) || compilerOptions.separateCompilation) {
|
||||
if (isExternalModule(node) || compilerOptions.isolatedModules) {
|
||||
if (languageVersion >= ScriptTarget.ES6) {
|
||||
emitES6Module(node, startIndex);
|
||||
}
|
||||
@ -5774,7 +5745,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
emitLeadingComments(node.endOfFileToken);
|
||||
}
|
||||
|
||||
function emitNodeWithoutSourceMap(node: Node, allowGeneratedIdentifiers?: boolean): void {
|
||||
function emitNodeWithoutSourceMap(node: Node): void {
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
@ -5788,7 +5759,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
emitLeadingComments(node);
|
||||
}
|
||||
|
||||
emitJavaScriptWorker(node, allowGeneratedIdentifiers);
|
||||
emitJavaScriptWorker(node);
|
||||
|
||||
if (emitComments) {
|
||||
emitTrailingComments(node);
|
||||
@ -5838,11 +5809,11 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function emitJavaScriptWorker(node: Node, allowGeneratedIdentifiers: boolean = true) {
|
||||
function emitJavaScriptWorker(node: Node) {
|
||||
// Check if the node can be emitted regardless of the ScriptTarget
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
return emitIdentifier(<Identifier>node, allowGeneratedIdentifiers);
|
||||
return emitIdentifier(<Identifier>node);
|
||||
case SyntaxKind.Parameter:
|
||||
return emitParameter(<ParameterDeclaration>node);
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,17 +1,14 @@
|
||||
/// <reference path="sys.ts" />
|
||||
/// <reference path="emitter.ts" />
|
||||
|
||||
module ts {
|
||||
namespace ts {
|
||||
/* @internal */ export let programTime = 0;
|
||||
/* @internal */ export let emitTime = 0;
|
||||
/* @internal */ export let ioReadTime = 0;
|
||||
/* @internal */ export let ioWriteTime = 0;
|
||||
|
||||
/** The version of the TypeScript compiler release */
|
||||
export const version = "1.5.2";
|
||||
|
||||
const carriageReturnLineFeed = "\r\n";
|
||||
const lineFeed = "\n";
|
||||
export const version = "1.5.3";
|
||||
|
||||
export function findConfigFile(searchPath: string): string {
|
||||
var fileName = "tsconfig.json";
|
||||
@ -94,10 +91,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
let newLine =
|
||||
options.newLine === NewLineKind.CarriageReturnLineFeed ? carriageReturnLineFeed :
|
||||
options.newLine === NewLineKind.LineFeed ? lineFeed :
|
||||
sys.newLine;
|
||||
const newLine = getNewLineCharacter(options);
|
||||
|
||||
return {
|
||||
getSourceFile,
|
||||
@ -111,7 +105,10 @@ module ts {
|
||||
}
|
||||
|
||||
export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile): Diagnostic[] {
|
||||
let diagnostics = program.getSyntacticDiagnostics(sourceFile).concat(program.getGlobalDiagnostics()).concat(program.getSemanticDiagnostics(sourceFile));
|
||||
let diagnostics = program.getOptionsDiagnostics().concat(
|
||||
program.getSyntacticDiagnostics(sourceFile),
|
||||
program.getGlobalDiagnostics(),
|
||||
program.getSemanticDiagnostics(sourceFile));
|
||||
|
||||
if (program.getCompilerOptions().declaration) {
|
||||
diagnostics.concat(program.getDeclarationDiagnostics(sourceFile));
|
||||
@ -149,20 +146,31 @@ module ts {
|
||||
export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program {
|
||||
let program: Program;
|
||||
let files: SourceFile[] = [];
|
||||
let filesByName: Map<SourceFile> = {};
|
||||
let diagnostics = createDiagnosticCollection();
|
||||
let seenNoDefaultLib = options.noLib;
|
||||
|
||||
let commonSourceDirectory: string;
|
||||
let diagnosticsProducingTypeChecker: TypeChecker;
|
||||
let noDiagnosticsTypeChecker: TypeChecker;
|
||||
let classifiableNames: Map<string>;
|
||||
|
||||
let skipDefaultLib = options.noLib;
|
||||
|
||||
let start = new Date().getTime();
|
||||
|
||||
host = host || createCompilerHost(options);
|
||||
forEach(rootNames, name => processRootFile(name, false));
|
||||
if (!seenNoDefaultLib) {
|
||||
processRootFile(host.getDefaultLibFileName(options), true);
|
||||
|
||||
let filesByName = createFileMap<SourceFile>(fileName => host.getCanonicalFileName(fileName));
|
||||
|
||||
forEach(rootNames, name => processRootFile(name, /*isDefaultLib:*/ false));
|
||||
|
||||
// Do not process the default library if:
|
||||
// - The '--noLib' flag is used.
|
||||
// - A 'no-default-lib' reference comment is encountered in
|
||||
// processing the root files.
|
||||
if (!skipDefaultLib) {
|
||||
processRootFile(host.getDefaultLibFileName(options), /*isDefaultLib:*/ true);
|
||||
}
|
||||
|
||||
verifyCompilerOptions();
|
||||
|
||||
programTime += new Date().getTime() - start;
|
||||
@ -172,10 +180,12 @@ module ts {
|
||||
getSourceFiles: () => files,
|
||||
getCompilerOptions: () => options,
|
||||
getSyntacticDiagnostics,
|
||||
getOptionsDiagnostics,
|
||||
getGlobalDiagnostics,
|
||||
getSemanticDiagnostics,
|
||||
getDeclarationDiagnostics,
|
||||
getTypeChecker,
|
||||
getClassifiableNames,
|
||||
getDiagnosticsProducingTypeChecker,
|
||||
getCommonSourceDirectory: () => commonSourceDirectory,
|
||||
emit,
|
||||
@ -187,6 +197,20 @@ module ts {
|
||||
};
|
||||
return program;
|
||||
|
||||
function getClassifiableNames() {
|
||||
if (!classifiableNames) {
|
||||
// Initialize a checker so that all our files are bound.
|
||||
getTypeChecker();
|
||||
classifiableNames = {};
|
||||
|
||||
for (let sourceFile of files) {
|
||||
copyMap(sourceFile.classifiableNames, classifiableNames);
|
||||
}
|
||||
}
|
||||
|
||||
return classifiableNames;
|
||||
}
|
||||
|
||||
function getEmitHost(writeFileCallback?: WriteFileCallback): EmitHost {
|
||||
return {
|
||||
getCanonicalFileName: fileName => host.getCanonicalFileName(fileName),
|
||||
@ -238,8 +262,7 @@ module ts {
|
||||
}
|
||||
|
||||
function getSourceFile(fileName: string) {
|
||||
fileName = host.getCanonicalFileName(normalizeSlashes(fileName));
|
||||
return hasProperty(filesByName, fileName) ? filesByName[fileName] : undefined;
|
||||
return filesByName.get(fileName);
|
||||
}
|
||||
|
||||
function getDiagnosticsHelper(sourceFile: SourceFile, getDiagnostics: (sourceFile: SourceFile) => Diagnostic[]): Diagnostic[] {
|
||||
@ -291,13 +314,15 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getGlobalDiagnostics(): Diagnostic[] {
|
||||
let typeChecker = getDiagnosticsProducingTypeChecker();
|
||||
|
||||
function getOptionsDiagnostics(): Diagnostic[] {
|
||||
let allDiagnostics: Diagnostic[] = [];
|
||||
addRange(allDiagnostics, typeChecker.getGlobalDiagnostics());
|
||||
addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
|
||||
return sortAndDeduplicateDiagnostics(allDiagnostics);
|
||||
}
|
||||
|
||||
function getGlobalDiagnostics(): Diagnostic[] {
|
||||
let allDiagnostics: Diagnostic[] = [];
|
||||
addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics());
|
||||
return sortAndDeduplicateDiagnostics(allDiagnostics);
|
||||
}
|
||||
|
||||
@ -334,14 +359,17 @@ module ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (options.allowNonTsExtensions && !findSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd)) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
diagnosticArgument = [fileName];
|
||||
}
|
||||
else if (!forEach(supportedExtensions, extension => findSourceFile(fileName + extension, isDefaultLib, refFile, refPos, refEnd))) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
fileName += ".ts";
|
||||
diagnosticArgument = [fileName];
|
||||
var nonTsFile: SourceFile = options.allowNonTsExtensions && findSourceFile(fileName, 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, isDefaultLib, refFile, refPos, refEnd))) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
fileName += ".ts";
|
||||
diagnosticArgument = [fileName];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -358,19 +386,19 @@ module ts {
|
||||
// Get source file from normalized fileName
|
||||
function findSourceFile(fileName: string, isDefaultLib: boolean, refFile?: SourceFile, refStart?: number, refLength?: number): SourceFile {
|
||||
let canonicalName = host.getCanonicalFileName(normalizeSlashes(fileName));
|
||||
if (hasProperty(filesByName, canonicalName)) {
|
||||
if (filesByName.contains(canonicalName)) {
|
||||
// We've already looked for this file, use cached result
|
||||
return getSourceFileFromCache(fileName, canonicalName, /*useAbsolutePath*/ false);
|
||||
}
|
||||
else {
|
||||
let normalizedAbsolutePath = getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
|
||||
let canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath);
|
||||
if (hasProperty(filesByName, canonicalAbsolutePath)) {
|
||||
if (filesByName.contains(canonicalAbsolutePath)) {
|
||||
return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, /*useAbsolutePath*/ true);
|
||||
}
|
||||
|
||||
// We haven't looked for this file, do so now and cache result
|
||||
let file = filesByName[canonicalName] = host.getSourceFile(fileName, options.target, hostErrorMessage => {
|
||||
let file = host.getSourceFile(fileName, options.target, hostErrorMessage => {
|
||||
if (refFile) {
|
||||
diagnostics.add(createFileDiagnostic(refFile, refStart, refLength,
|
||||
Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
|
||||
@ -379,11 +407,12 @@ module ts {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
|
||||
}
|
||||
});
|
||||
filesByName.set(canonicalName, file);
|
||||
if (file) {
|
||||
seenNoDefaultLib = seenNoDefaultLib || file.hasNoDefaultLib;
|
||||
skipDefaultLib = skipDefaultLib || file.hasNoDefaultLib;
|
||||
|
||||
// Set the source file for normalized absolute path
|
||||
filesByName[canonicalAbsolutePath] = file;
|
||||
filesByName.set(canonicalAbsolutePath, file);
|
||||
|
||||
if (!options.noResolve) {
|
||||
let basePath = getDirectoryPath(fileName);
|
||||
@ -391,6 +420,7 @@ module ts {
|
||||
processImportedModules(file, basePath);
|
||||
}
|
||||
if (isDefaultLib) {
|
||||
file.isDefaultLib = true;
|
||||
files.unshift(file);
|
||||
}
|
||||
else {
|
||||
@ -402,7 +432,7 @@ module ts {
|
||||
}
|
||||
|
||||
function getSourceFileFromCache(fileName: string, canonicalName: string, useAbsolutePath: boolean): SourceFile {
|
||||
let file = filesByName[canonicalName];
|
||||
let file = filesByName.get(canonicalName);
|
||||
if (file && host.useCaseSensitiveFileNames()) {
|
||||
let sourceFileName = useAbsolutePath ? getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory()) : file.fileName;
|
||||
if (canonicalName !== sourceFileName) {
|
||||
@ -534,21 +564,21 @@ module ts {
|
||||
}
|
||||
|
||||
function verifyCompilerOptions() {
|
||||
if (options.separateCompilation) {
|
||||
if (options.isolatedModules) {
|
||||
if (options.sourceMap) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceMap_cannot_be_specified_with_option_separateCompilation));
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceMap_cannot_be_specified_with_option_isolatedModules));
|
||||
}
|
||||
|
||||
if (options.declaration) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_declaration_cannot_be_specified_with_option_separateCompilation));
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules));
|
||||
}
|
||||
|
||||
if (options.noEmitOnError) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_separateCompilation));
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules));
|
||||
}
|
||||
|
||||
if (options.out) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_out_cannot_be_specified_with_option_separateCompilation));
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_out_cannot_be_specified_with_option_isolatedModules));
|
||||
}
|
||||
}
|
||||
|
||||
@ -585,15 +615,15 @@ module ts {
|
||||
let languageVersion = options.target || ScriptTarget.ES3;
|
||||
|
||||
let firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined);
|
||||
if (options.separateCompilation) {
|
||||
if (options.isolatedModules) {
|
||||
if (!options.module && languageVersion < ScriptTarget.ES6) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_separateCompilation_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher));
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher));
|
||||
}
|
||||
|
||||
let firstNonExternalModuleSourceFile = forEach(files, f => !isExternalModule(f) && !isDeclarationFile(f) ? f : undefined);
|
||||
if (firstNonExternalModuleSourceFile) {
|
||||
let span = getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
|
||||
diagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_separateCompilation_flag_is_provided));
|
||||
diagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
|
||||
}
|
||||
}
|
||||
else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && !options.module) {
|
||||
@ -640,6 +670,11 @@ module ts {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration));
|
||||
}
|
||||
}
|
||||
|
||||
if (options.emitDecoratorMetadata &&
|
||||
!options.experimentalDecorators) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/// <reference path="core.ts"/>
|
||||
/// <reference path="diagnosticInformationMap.generated.ts"/>
|
||||
|
||||
module ts {
|
||||
namespace ts {
|
||||
export interface ErrorCallback {
|
||||
(message: DiagnosticMessage, length: number): void;
|
||||
}
|
||||
@ -72,6 +72,7 @@ module ts {
|
||||
"in": SyntaxKind.InKeyword,
|
||||
"instanceof": SyntaxKind.InstanceOfKeyword,
|
||||
"interface": SyntaxKind.InterfaceKeyword,
|
||||
"is": SyntaxKind.IsKeyword,
|
||||
"let": SyntaxKind.LetKeyword,
|
||||
"module": SyntaxKind.ModuleKeyword,
|
||||
"namespace": SyntaxKind.NamespaceKeyword,
|
||||
@ -375,8 +376,31 @@ module ts {
|
||||
return ch >= CharacterCodes._0 && ch <= CharacterCodes._7;
|
||||
}
|
||||
|
||||
export function couldStartTrivia(text: string, pos: number): boolean {
|
||||
// Keep in sync with skipTrivia
|
||||
let ch = text.charCodeAt(pos);
|
||||
switch (ch) {
|
||||
case CharacterCodes.carriageReturn:
|
||||
case CharacterCodes.lineFeed:
|
||||
case CharacterCodes.tab:
|
||||
case CharacterCodes.verticalTab:
|
||||
case CharacterCodes.formFeed:
|
||||
case CharacterCodes.space:
|
||||
case CharacterCodes.slash:
|
||||
// starts of normal trivia
|
||||
case CharacterCodes.lessThan:
|
||||
case CharacterCodes.equals:
|
||||
case CharacterCodes.greaterThan:
|
||||
// Starts of conflict marker trivia
|
||||
return true;
|
||||
default:
|
||||
return ch > CharacterCodes.maxAsciiCharacter;
|
||||
}
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function skipTrivia(text: string, pos: number, stopAfterLineBreak?: boolean): number {
|
||||
// Keep in sync with couldStartTrivia
|
||||
while (true) {
|
||||
let ch = text.charCodeAt(pos);
|
||||
switch (ch) {
|
||||
@ -933,7 +957,7 @@ module ts {
|
||||
error(Diagnostics.Unexpected_end_of_text);
|
||||
isInvalidExtendedEscape = true;
|
||||
}
|
||||
else if (text.charCodeAt(pos) == CharacterCodes.closeBrace) {
|
||||
else if (text.charCodeAt(pos) === CharacterCodes.closeBrace) {
|
||||
// Only swallow the following character up if it's a '}'.
|
||||
pos++;
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/// <reference path="core.ts"/>
|
||||
|
||||
module ts {
|
||||
namespace ts {
|
||||
export interface System {
|
||||
args: string[];
|
||||
newLine: string;
|
||||
@ -15,7 +15,7 @@ module ts {
|
||||
createDirectory(path: string): void;
|
||||
getExecutingFilePath(): string;
|
||||
getCurrentDirectory(): string;
|
||||
readDirectory(path: string, extension?: string): string[];
|
||||
readDirectory(path: string, extension?: string, exclude?: string[]): string[];
|
||||
getMemoryUsage?(): number;
|
||||
exit(exitCode?: number): void;
|
||||
}
|
||||
@ -109,7 +109,11 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getNames(collection: any): string[] {
|
||||
function getCanonicalPath(path: string): string {
|
||||
return path.toLowerCase();
|
||||
}
|
||||
|
||||
function getNames(collection: any): string[]{
|
||||
var result: string[] = [];
|
||||
for (var e = new Enumerator(collection); !e.atEnd(); e.moveNext()) {
|
||||
result.push(e.item().Name);
|
||||
@ -117,21 +121,26 @@ module ts {
|
||||
return result.sort();
|
||||
}
|
||||
|
||||
function readDirectory(path: string, extension?: string): string[] {
|
||||
function readDirectory(path: string, extension?: string, exclude?: string[]): string[] {
|
||||
var result: string[] = [];
|
||||
exclude = map(exclude, s => getCanonicalPath(combinePaths(path, s)));
|
||||
visitDirectory(path);
|
||||
return result;
|
||||
function visitDirectory(path: string) {
|
||||
var folder = fso.GetFolder(path || ".");
|
||||
var files = getNames(folder.files);
|
||||
for (let name of files) {
|
||||
if (!extension || fileExtensionIs(name, extension)) {
|
||||
result.push(combinePaths(path, name));
|
||||
for (let current of files) {
|
||||
let name = combinePaths(path, current);
|
||||
if ((!extension || fileExtensionIs(name, extension)) && !contains(exclude, getCanonicalPath(name))) {
|
||||
result.push(name);
|
||||
}
|
||||
}
|
||||
var subfolders = getNames(folder.subfolders);
|
||||
for (let current of subfolders) {
|
||||
visitDirectory(combinePaths(path, current));
|
||||
let name = combinePaths(path, current);
|
||||
if (!contains(exclude, getCanonicalPath(name))) {
|
||||
visitDirectory(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -222,8 +231,13 @@ module ts {
|
||||
_fs.writeFileSync(fileName, data, "utf8");
|
||||
}
|
||||
|
||||
function readDirectory(path: string, extension?: string): string[] {
|
||||
function getCanonicalPath(path: string): string {
|
||||
return useCaseSensitiveFileNames ? path.toLowerCase() : path;
|
||||
}
|
||||
|
||||
function readDirectory(path: string, extension?: string, exclude?: string[]): string[] {
|
||||
var result: string[] = [];
|
||||
exclude = map(exclude, s => getCanonicalPath(combinePaths(path, s)));
|
||||
visitDirectory(path);
|
||||
return result;
|
||||
function visitDirectory(path: string) {
|
||||
@ -231,14 +245,16 @@ module ts {
|
||||
var directories: string[] = [];
|
||||
for (let current of files) {
|
||||
var name = combinePaths(path, current);
|
||||
var stat = _fs.lstatSync(name);
|
||||
if (stat.isFile()) {
|
||||
if (!extension || fileExtensionIs(name, extension)) {
|
||||
result.push(name);
|
||||
if (!contains(exclude, getCanonicalPath(name))) {
|
||||
var stat = _fs.statSync(name);
|
||||
if (stat.isFile()) {
|
||||
if (!extension || fileExtensionIs(name, extension)) {
|
||||
result.push(name);
|
||||
}
|
||||
}
|
||||
else if (stat.isDirectory()) {
|
||||
directories.push(name);
|
||||
}
|
||||
}
|
||||
else if (stat.isDirectory()) {
|
||||
directories.push(name);
|
||||
}
|
||||
}
|
||||
for (let current of directories) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/// <reference path="program.ts"/>
|
||||
/// <reference path="commandLineParser.ts"/>
|
||||
|
||||
module ts {
|
||||
namespace ts {
|
||||
export interface SourceFile {
|
||||
fileWatcher: FileWatcher;
|
||||
}
|
||||
|
||||
@ -1,8 +1,16 @@
|
||||
module ts {
|
||||
namespace ts {
|
||||
export interface Map<T> {
|
||||
[index: string]: T;
|
||||
}
|
||||
|
||||
export interface FileMap<T> {
|
||||
get(fileName: string): T;
|
||||
set(fileName: string, value: T): void;
|
||||
contains(fileName: string): boolean;
|
||||
remove(fileName: string): void;
|
||||
forEachValue(f: (v: T) => void): void;
|
||||
}
|
||||
|
||||
export interface TextRange {
|
||||
pos: number;
|
||||
end: number;
|
||||
@ -137,6 +145,7 @@ module ts {
|
||||
ConstructorKeyword,
|
||||
DeclareKeyword,
|
||||
GetKeyword,
|
||||
IsKeyword,
|
||||
ModuleKeyword,
|
||||
NamespaceKeyword,
|
||||
RequireKeyword,
|
||||
@ -169,6 +178,7 @@ module ts {
|
||||
ConstructSignature,
|
||||
IndexSignature,
|
||||
// Type
|
||||
TypePredicate,
|
||||
TypeReference,
|
||||
FunctionType,
|
||||
ConstructorType,
|
||||
@ -352,10 +362,6 @@ module ts {
|
||||
export const enum ParserContextFlags {
|
||||
None = 0,
|
||||
|
||||
// Set if this node was parsed in strict mode. Used for grammar error checks, as well as
|
||||
// checking if the node can be reused in incremental settings.
|
||||
StrictMode = 1 << 0,
|
||||
|
||||
// If this node was parsed in a context where 'in-expressions' are not allowed.
|
||||
DisallowIn = 1 << 1,
|
||||
|
||||
@ -378,7 +384,7 @@ module ts {
|
||||
JavaScriptFile = 1 << 6,
|
||||
|
||||
// Context flags set directly by the parser.
|
||||
ParserGeneratedFlags = StrictMode | DisallowIn | Yield | GeneratorParameter | Decorator | ThisNodeHasError,
|
||||
ParserGeneratedFlags = DisallowIn | Yield | GeneratorParameter | Decorator | ThisNodeHasError,
|
||||
|
||||
// Context flags computed by aggregating child flags upwards.
|
||||
|
||||
@ -606,6 +612,11 @@ module ts {
|
||||
typeArguments?: NodeArray<TypeNode>;
|
||||
}
|
||||
|
||||
export interface TypePredicateNode extends TypeNode {
|
||||
parameterName: Identifier;
|
||||
type: TypeNode;
|
||||
}
|
||||
|
||||
export interface TypeQueryNode extends TypeNode {
|
||||
exprName: EntityName;
|
||||
}
|
||||
@ -693,7 +704,7 @@ module ts {
|
||||
|
||||
export interface YieldExpression extends Expression {
|
||||
asteriskToken?: Node;
|
||||
expression: Expression;
|
||||
expression?: Expression;
|
||||
}
|
||||
|
||||
export interface BinaryExpression extends Expression {
|
||||
@ -793,7 +804,7 @@ module ts {
|
||||
expression: UnaryExpression;
|
||||
}
|
||||
|
||||
export interface Statement extends Node, ModuleElement {
|
||||
export interface Statement extends Node {
|
||||
_statementBrand: any;
|
||||
}
|
||||
|
||||
@ -896,10 +907,6 @@ module ts {
|
||||
block: Block;
|
||||
}
|
||||
|
||||
export interface ModuleElement extends Node {
|
||||
_moduleElementBrand: any;
|
||||
}
|
||||
|
||||
export interface ClassLikeDeclaration extends Declaration {
|
||||
name?: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
@ -917,7 +924,7 @@ module ts {
|
||||
_classElementBrand: any;
|
||||
}
|
||||
|
||||
export interface InterfaceDeclaration extends Declaration, ModuleElement {
|
||||
export interface InterfaceDeclaration extends Declaration, Statement {
|
||||
name: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
heritageClauses?: NodeArray<HeritageClause>;
|
||||
@ -929,8 +936,9 @@ module ts {
|
||||
types?: NodeArray<ExpressionWithTypeArguments>;
|
||||
}
|
||||
|
||||
export interface TypeAliasDeclaration extends Declaration, ModuleElement {
|
||||
export interface TypeAliasDeclaration extends Declaration, Statement {
|
||||
name: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
type: TypeNode;
|
||||
}
|
||||
|
||||
@ -941,21 +949,21 @@ module ts {
|
||||
initializer?: Expression;
|
||||
}
|
||||
|
||||
export interface EnumDeclaration extends Declaration, ModuleElement {
|
||||
export interface EnumDeclaration extends Declaration, Statement {
|
||||
name: Identifier;
|
||||
members: NodeArray<EnumMember>;
|
||||
}
|
||||
|
||||
export interface ModuleDeclaration extends Declaration, ModuleElement {
|
||||
export interface ModuleDeclaration extends Declaration, Statement {
|
||||
name: Identifier | LiteralExpression;
|
||||
body: ModuleBlock | ModuleDeclaration;
|
||||
}
|
||||
|
||||
export interface ModuleBlock extends Node, ModuleElement {
|
||||
statements: NodeArray<ModuleElement>
|
||||
export interface ModuleBlock extends Node, Statement {
|
||||
statements: NodeArray<Statement>
|
||||
}
|
||||
|
||||
export interface ImportEqualsDeclaration extends Declaration, ModuleElement {
|
||||
export interface ImportEqualsDeclaration extends Declaration, Statement {
|
||||
name: Identifier;
|
||||
|
||||
// 'EntityName' for an internal module reference, 'ExternalModuleReference' for an external
|
||||
@ -971,7 +979,7 @@ module ts {
|
||||
// import "mod" => importClause = undefined, moduleSpecifier = "mod"
|
||||
// In rest of the cases, module specifier is string literal corresponding to module
|
||||
// ImportClause information is shown at its declaration below.
|
||||
export interface ImportDeclaration extends ModuleElement {
|
||||
export interface ImportDeclaration extends Statement {
|
||||
importClause?: ImportClause;
|
||||
moduleSpecifier: Expression;
|
||||
}
|
||||
@ -991,7 +999,7 @@ module ts {
|
||||
name: Identifier;
|
||||
}
|
||||
|
||||
export interface ExportDeclaration extends Declaration, ModuleElement {
|
||||
export interface ExportDeclaration extends Declaration, Statement {
|
||||
exportClause?: NamedExports;
|
||||
moduleSpecifier?: Expression;
|
||||
}
|
||||
@ -1011,7 +1019,7 @@ module ts {
|
||||
export type ImportSpecifier = ImportOrExportSpecifier;
|
||||
export type ExportSpecifier = ImportOrExportSpecifier;
|
||||
|
||||
export interface ExportAssignment extends Declaration, ModuleElement {
|
||||
export interface ExportAssignment extends Declaration, Statement {
|
||||
isExportEquals?: boolean;
|
||||
expression: Expression;
|
||||
}
|
||||
@ -1127,23 +1135,32 @@ module ts {
|
||||
|
||||
// Source files are declarations when they are external modules.
|
||||
export interface SourceFile extends Declaration {
|
||||
statements: NodeArray<ModuleElement>;
|
||||
statements: NodeArray<Statement>;
|
||||
endOfFileToken: Node;
|
||||
|
||||
fileName: string;
|
||||
text: string;
|
||||
|
||||
amdDependencies: {path: string; name: string}[];
|
||||
amdModuleName: string;
|
||||
moduleName: string;
|
||||
referencedFiles: FileReference[];
|
||||
|
||||
/**
|
||||
* lib.d.ts should have a reference comment like
|
||||
*
|
||||
* /// <reference no-default-lib="true"/>
|
||||
*
|
||||
* If any other file has this comment, it signals not to include lib.d.ts
|
||||
* because this containing file is intended to act as a default library.
|
||||
*/
|
||||
hasNoDefaultLib: boolean;
|
||||
|
||||
languageVersion: ScriptTarget;
|
||||
|
||||
// The first node that causes this file to be an external module
|
||||
/* @internal */ externalModuleIndicator: Node;
|
||||
|
||||
|
||||
/* @internal */ isDefaultLib: boolean;
|
||||
/* @internal */ identifiers: Map<string>;
|
||||
/* @internal */ nodeCount: number;
|
||||
/* @internal */ identifierCount: number;
|
||||
@ -1159,6 +1176,8 @@ module ts {
|
||||
// Stores a line map for the file.
|
||||
// This field should never be used directly to obtain line map, use getLineMap function instead.
|
||||
/* @internal */ lineMap: number[];
|
||||
|
||||
/* @internal */ classifiableNames?: Map<string>;
|
||||
}
|
||||
|
||||
export interface ScriptReferenceHost {
|
||||
@ -1168,7 +1187,7 @@ module ts {
|
||||
}
|
||||
|
||||
export interface ParseConfigHost {
|
||||
readDirectory(rootDir: string, extension: string): string[];
|
||||
readDirectory(rootDir: string, extension: string, exclude: string[]): string[];
|
||||
}
|
||||
|
||||
export interface WriteFileCallback {
|
||||
@ -1193,8 +1212,9 @@ module ts {
|
||||
*/
|
||||
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
|
||||
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getOptionsDiagnostics(): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
|
||||
@ -1209,6 +1229,8 @@ module ts {
|
||||
// language service).
|
||||
/* @internal */ getDiagnosticsProducingTypeChecker(): TypeChecker;
|
||||
|
||||
/* @internal */ getClassifiableNames(): Map<string>;
|
||||
|
||||
/* @internal */ getNodeCount(): number;
|
||||
/* @internal */ getIdentifierCount(): number;
|
||||
/* @internal */ getSymbolCount(): number;
|
||||
@ -1376,6 +1398,12 @@ module ts {
|
||||
NotAccessible,
|
||||
CannotBeNamed
|
||||
}
|
||||
|
||||
export interface TypePredicate {
|
||||
parameterName: string;
|
||||
parameterIndex: number;
|
||||
type: Type;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration;
|
||||
@ -1396,7 +1424,10 @@ module ts {
|
||||
/* @internal */
|
||||
export interface EmitResolver {
|
||||
hasGlobalName(name: string): boolean;
|
||||
getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string;
|
||||
getReferencedExportContainer(node: Identifier): SourceFile | ModuleDeclaration | EnumDeclaration;
|
||||
getReferencedImportDeclaration(node: Identifier): Declaration;
|
||||
getReferencedNestedRedeclaration(node: Identifier): Declaration;
|
||||
isNestedRedeclaration(node: Declaration): boolean;
|
||||
isValueAliasDeclaration(node: Node): boolean;
|
||||
isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean;
|
||||
isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean;
|
||||
@ -1411,15 +1442,15 @@ module ts {
|
||||
isEntityNameVisible(entityName: EntityName | Expression, enclosingDeclaration: Node): SymbolVisibilityResult;
|
||||
// Returns the constant value this property access resolves to, or 'undefined' for a non-constant
|
||||
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
|
||||
resolvesToSomeValue(location: Node, name: string): boolean;
|
||||
getBlockScopedVariableId(node: Identifier): number;
|
||||
getReferencedValueDeclaration(reference: Identifier): Declaration;
|
||||
serializeTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
|
||||
serializeParameterTypesOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): (string | string[])[];
|
||||
serializeReturnTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
|
||||
serializeTypeOfNode(node: Node): string | string[];
|
||||
serializeParameterTypesOfNode(node: Node): (string | string[])[];
|
||||
serializeReturnTypeOfNode(node: Node): string | string[];
|
||||
}
|
||||
|
||||
export const enum SymbolFlags {
|
||||
None = 0,
|
||||
FunctionScopedVariable = 0x00000001, // Variable (var) or parameter
|
||||
BlockScopedVariable = 0x00000002, // A block-scoped variable (let or const)
|
||||
Property = 0x00000004, // Property or enum member
|
||||
@ -1489,26 +1520,32 @@ module ts {
|
||||
|
||||
ExportHasLocal = Function | Class | Enum | ValueModule,
|
||||
|
||||
HasLocals = Function | Module | Method | Constructor | Accessor | Signature,
|
||||
HasExports = Class | Enum | Module,
|
||||
HasMembers = Class | Interface | TypeLiteral | ObjectLiteral,
|
||||
|
||||
IsContainer = HasLocals | HasExports | HasMembers,
|
||||
BlockScoped = BlockScopedVariable | Class | Enum,
|
||||
|
||||
PropertyOrAccessor = Property | Accessor,
|
||||
Export = ExportNamespace | ExportType | ExportValue,
|
||||
|
||||
/* @internal */
|
||||
// The set of things we consider semantically classifiable. Used to speed up the LS during
|
||||
// classification.
|
||||
Classifiable = Class | Enum | TypeAlias | Interface | TypeParameter | Module,
|
||||
}
|
||||
|
||||
export interface Symbol {
|
||||
flags: SymbolFlags; // Symbol flags
|
||||
name: string; // Name of symbol
|
||||
/* @internal */ id?: number; // Unique id (used to look up SymbolLinks)
|
||||
/* @internal */ mergeId?: number; // Merge id (used to look up merged symbol)
|
||||
declarations?: Declaration[]; // Declarations associated with this symbol
|
||||
/* @internal */ parent?: Symbol; // Parent symbol
|
||||
valueDeclaration?: Declaration; // First value declaration of the symbol
|
||||
|
||||
members?: SymbolTable; // Class, interface or literal instance members
|
||||
exports?: SymbolTable; // Module exports
|
||||
/* @internal */ id?: number; // Unique id (used to look up SymbolLinks)
|
||||
/* @internal */ mergeId?: number; // Merge id (used to look up merged symbol)
|
||||
/* @internal */ parent?: Symbol; // Parent symbol
|
||||
/* @internal */ exportSymbol?: Symbol; // Exported symbol associated with this symbol
|
||||
valueDeclaration?: Declaration; // First value declaration of the symbol
|
||||
/* @internal */ constEnumOnlyModule?: boolean; // True if module contains only const enums or other modules with only const enums
|
||||
}
|
||||
|
||||
@ -1516,12 +1553,15 @@ module ts {
|
||||
export interface SymbolLinks {
|
||||
target?: Symbol; // Resolved (non-alias) target of an alias
|
||||
type?: Type; // Type of value symbol
|
||||
declaredType?: Type; // Type of class, interface, enum, or type parameter
|
||||
declaredType?: Type; // Type of class, interface, enum, type alias, or type parameter
|
||||
typeParameters?: TypeParameter[]; // Type parameters of type alias (undefined if non-generic)
|
||||
instantiations?: Map<Type>; // Instantiations of generic type alias (undefined if non-generic)
|
||||
mapper?: TypeMapper; // Type mapper for instantiation alias
|
||||
referenced?: boolean; // True if alias symbol has been referenced as a value
|
||||
unionType?: UnionType; // Containing union type for union property
|
||||
resolvedExports?: SymbolTable; // Resolved exports of module
|
||||
exportsChecked?: boolean; // True if exports of external module have been checked
|
||||
isNestedRedeclaration?: boolean; // True if symbol is block scoped redeclaration
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@ -1582,14 +1622,15 @@ module ts {
|
||||
Tuple = 0x00002000, // Tuple
|
||||
Union = 0x00004000, // Union
|
||||
Anonymous = 0x00008000, // Anonymous
|
||||
/* @internal */
|
||||
FromSignature = 0x00010000, // Created for signature assignment check
|
||||
ObjectLiteral = 0x00020000, // Originates in an object literal
|
||||
/* @internal */
|
||||
ContainsUndefinedOrNull = 0x00040000, // Type is or contains Undefined or Null type
|
||||
/* @internal */
|
||||
ContainsObjectLiteral = 0x00080000, // Type is or contains object literal type
|
||||
ESSymbol = 0x00100000, // Type of symbol primitive introduced in ES6
|
||||
Instantiated = 0x00010000, // Instantiated anonymous type
|
||||
/* @internal */
|
||||
FromSignature = 0x00020000, // Created for signature assignment check
|
||||
ObjectLiteral = 0x00040000, // Originates in an object literal
|
||||
/* @internal */
|
||||
ContainsUndefinedOrNull = 0x00080000, // Type is or contains Undefined or Null type
|
||||
/* @internal */
|
||||
ContainsObjectLiteral = 0x00100000, // Type is or contains object literal type
|
||||
ESSymbol = 0x00200000, // Type of symbol primitive introduced in ES6
|
||||
|
||||
/* @internal */
|
||||
Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null,
|
||||
@ -1626,10 +1667,10 @@ module ts {
|
||||
// Class and interface types (TypeFlags.Class and TypeFlags.Interface)
|
||||
export interface InterfaceType extends ObjectType {
|
||||
typeParameters: TypeParameter[]; // Type parameters (undefined if non-generic)
|
||||
}
|
||||
|
||||
export interface InterfaceTypeWithBaseTypes extends InterfaceType {
|
||||
baseTypes: ObjectType[];
|
||||
outerTypeParameters: TypeParameter[]; // Outer type parameters (undefined if none)
|
||||
localTypeParameters: TypeParameter[]; // Local type parameters (undefined if none)
|
||||
resolvedBaseConstructorType?: Type; // Resolved base constructor type of class
|
||||
resolvedBaseTypes: ObjectType[]; // Resolved base types
|
||||
}
|
||||
|
||||
export interface InterfaceTypeWithDeclaredMembers extends InterfaceType {
|
||||
@ -1672,8 +1713,15 @@ module ts {
|
||||
properties: Symbol[]; // Properties
|
||||
callSignatures: Signature[]; // Call signatures of type
|
||||
constructSignatures: Signature[]; // Construct signatures of type
|
||||
stringIndexType: Type; // String index type
|
||||
numberIndexType: Type; // Numeric index type
|
||||
stringIndexType?: Type; // String index type
|
||||
numberIndexType?: Type; // Numeric index type
|
||||
}
|
||||
|
||||
// Just a place to cache element types of iterables and iterators
|
||||
/* @internal */
|
||||
export interface IterableOrIteratorType extends ObjectType, UnionType {
|
||||
iterableElementType?: Type;
|
||||
iteratorElementType?: Type;
|
||||
}
|
||||
|
||||
// Type parameters (TypeFlags.TypeParameter)
|
||||
@ -1694,6 +1742,7 @@ module ts {
|
||||
declaration: SignatureDeclaration; // Originating declaration
|
||||
typeParameters: TypeParameter[]; // Type parameters (undefined if non-generic)
|
||||
parameters: Symbol[]; // Parameters
|
||||
typePredicate?: TypePredicate; // Type predicate
|
||||
/* @internal */
|
||||
resolvedReturnType: Type; // Resolved return type
|
||||
/* @internal */
|
||||
@ -1722,7 +1771,6 @@ module ts {
|
||||
/* @internal */
|
||||
export interface TypeMapper {
|
||||
(t: TypeParameter): Type;
|
||||
mappings?: Map<Type>; // Type mapping cache
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@ -1810,9 +1858,14 @@ module ts {
|
||||
target?: ScriptTarget;
|
||||
version?: boolean;
|
||||
watch?: boolean;
|
||||
separateCompilation?: boolean;
|
||||
isolatedModules?: boolean;
|
||||
experimentalDecorators?: boolean;
|
||||
emitDecoratorMetadata?: boolean;
|
||||
/* @internal */ stripInternal?: boolean;
|
||||
|
||||
// Skip checking lib.d.ts to help speed up tests.
|
||||
/* @internal */ skipDefaultLibCheck?: boolean;
|
||||
|
||||
[option: string]: string | number | boolean;
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/// <reference path="binder.ts" />
|
||||
|
||||
/* @internal */
|
||||
module ts {
|
||||
namespace ts {
|
||||
export interface ReferencePathMatchResult {
|
||||
fileReference?: FileReference
|
||||
diagnosticMessage?: DiagnosticMessage
|
||||
@ -42,7 +42,7 @@ module ts {
|
||||
// Pool writers to avoid needing to allocate them for every symbol we write.
|
||||
let stringWriters: StringSymbolWriter[] = [];
|
||||
export function getSingleLineStringWriter(): StringSymbolWriter {
|
||||
if (stringWriters.length == 0) {
|
||||
if (stringWriters.length === 0) {
|
||||
let str = "";
|
||||
|
||||
let writeText: (text: string) => void = text => str += text;
|
||||
@ -408,6 +408,93 @@ module ts {
|
||||
|
||||
export let fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)('|")(.+?)\2.*?\/>/
|
||||
|
||||
export function isTypeNode(node: Node): boolean {
|
||||
if (SyntaxKind.FirstTypeNode <= node.kind && node.kind <= SyntaxKind.LastTypeNode) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.AnyKeyword:
|
||||
case SyntaxKind.NumberKeyword:
|
||||
case SyntaxKind.StringKeyword:
|
||||
case SyntaxKind.BooleanKeyword:
|
||||
case SyntaxKind.SymbolKeyword:
|
||||
return true;
|
||||
case SyntaxKind.VoidKeyword:
|
||||
return node.parent.kind !== SyntaxKind.VoidExpression;
|
||||
case SyntaxKind.StringLiteral:
|
||||
// Specialized signatures can have string literals as their parameters' type names
|
||||
return node.parent.kind === SyntaxKind.Parameter;
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return !isExpressionWithTypeArgumentsInClassExtendsClause(node);
|
||||
|
||||
// Identifiers and qualified names may be type nodes, depending on their context. Climb
|
||||
// above them to find the lowest container
|
||||
case SyntaxKind.Identifier:
|
||||
// If the identifier is the RHS of a qualified name, then it's a type iff its parent is.
|
||||
if (node.parent.kind === SyntaxKind.QualifiedName && (<QualifiedName>node.parent).right === node) {
|
||||
node = node.parent;
|
||||
}
|
||||
else if (node.parent.kind === SyntaxKind.PropertyAccessExpression && (<PropertyAccessExpression>node.parent).name === node) {
|
||||
node = node.parent;
|
||||
}
|
||||
// fall through
|
||||
case SyntaxKind.QualifiedName:
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
// At this point, node is either a qualified name or an identifier
|
||||
Debug.assert(node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName || node.kind === SyntaxKind.PropertyAccessExpression,
|
||||
"'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'.");
|
||||
|
||||
let parent = node.parent;
|
||||
if (parent.kind === SyntaxKind.TypeQuery) {
|
||||
return false;
|
||||
}
|
||||
// Do not recursively call isTypeNode on the parent. In the example:
|
||||
//
|
||||
// let a: A.B.C;
|
||||
//
|
||||
// Calling isTypeNode would consider the qualified name A.B a type node. Only C or
|
||||
// A.B.C is a type node.
|
||||
if (SyntaxKind.FirstTypeNode <= parent.kind && parent.kind <= SyntaxKind.LastTypeNode) {
|
||||
return true;
|
||||
}
|
||||
switch (parent.kind) {
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return !isExpressionWithTypeArgumentsInClassExtendsClause(parent);
|
||||
case SyntaxKind.TypeParameter:
|
||||
return node === (<TypeParameterDeclaration>parent).constraint;
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
case SyntaxKind.Parameter:
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
return node === (<VariableLikeDeclaration>parent).type;
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
return node === (<FunctionLikeDeclaration>parent).type;
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
case SyntaxKind.IndexSignature:
|
||||
return node === (<SignatureDeclaration>parent).type;
|
||||
case SyntaxKind.TypeAssertionExpression:
|
||||
return node === (<TypeAssertion>parent).type;
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.NewExpression:
|
||||
return (<CallExpression>parent).typeArguments && indexOf((<CallExpression>parent).typeArguments, node) >= 0;
|
||||
case SyntaxKind.TaggedTemplateExpression:
|
||||
// TODO (drosen): TaggedTemplateExpressions may eventually support type arguments.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Warning: This has the same semantics as the forEach family of functions,
|
||||
// in that traversal terminates in the event that 'visitor' supplies a truthy value.
|
||||
export function forEachReturnStatement<T>(body: Block, visitor: (stmt: ReturnStatement) => T): T {
|
||||
@ -438,6 +525,46 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function forEachYieldExpression(body: Block, visitor: (expr: YieldExpression) => void): void {
|
||||
|
||||
return traverse(body);
|
||||
|
||||
function traverse(node: Node): void {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.YieldExpression:
|
||||
visitor(<YieldExpression>node);
|
||||
let operand = (<YieldExpression>node).expression;
|
||||
if (operand) {
|
||||
traverse(operand);
|
||||
}
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
// These are not allowed inside a generator now, but eventually they may be allowed
|
||||
// as local types. Regardless, any yield statements contained within them should be
|
||||
// skipped in this traversal.
|
||||
return;
|
||||
default:
|
||||
if (isFunctionLike(node)) {
|
||||
let name = (<FunctionLikeDeclaration>node).name;
|
||||
if (name && name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
// Note that we will not include methods/accessors of a class because they would require
|
||||
// first descending into the class. This is by design.
|
||||
traverse((<ComputedPropertyName>name).expression);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (!isTypeNode(node)) {
|
||||
// This is the general case, which should include mostly expressions and statements.
|
||||
// Also includes NodeArrays.
|
||||
forEachChild(node, traverse);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function isVariableLike(node: Node): boolean {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
@ -739,12 +866,12 @@ module ts {
|
||||
case SyntaxKind.TemplateExpression:
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
case SyntaxKind.OmittedExpression:
|
||||
case SyntaxKind.YieldExpression:
|
||||
return true;
|
||||
case SyntaxKind.QualifiedName:
|
||||
while (node.parent.kind === SyntaxKind.QualifiedName) {
|
||||
node = node.parent;
|
||||
}
|
||||
|
||||
return node.parent.kind === SyntaxKind.TypeQuery;
|
||||
case SyntaxKind.Identifier:
|
||||
if (node.parent.kind === SyntaxKind.TypeQuery) {
|
||||
@ -792,6 +919,8 @@ module ts {
|
||||
return node === (<ComputedPropertyName>parent).expression;
|
||||
case SyntaxKind.Decorator:
|
||||
return true;
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return (<ExpressionWithTypeArguments>parent).expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent);
|
||||
default:
|
||||
if (isExpression(parent)) {
|
||||
return true;
|
||||
@ -835,10 +964,6 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function hasDotDotDotToken(node: Node) {
|
||||
return node && node.kind === SyntaxKind.Parameter && (<ParameterDeclaration>node).dotDotDotToken !== undefined;
|
||||
}
|
||||
|
||||
export function hasQuestionToken(node: Node) {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
@ -858,10 +983,6 @@ module ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
export function hasRestParameters(s: SignatureDeclaration): boolean {
|
||||
return s.parameters.length > 0 && lastOrUndefined(s.parameters).dotDotDotToken !== undefined;
|
||||
}
|
||||
|
||||
export function isJSDocConstructSignature(node: Node) {
|
||||
return node.kind === SyntaxKind.JSDocFunctionType &&
|
||||
(<JSDocFunctionType>node).parameters.length > 0 &&
|
||||
@ -1057,6 +1178,41 @@ module ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return true if the given identifier is classified as an IdentifierName
|
||||
export function isIdentifierName(node: Identifier): boolean {
|
||||
let parent = node.parent;
|
||||
switch (parent.kind) {
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.EnumMember:
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
// Name in member declaration or property name in property access
|
||||
return (<Declaration | PropertyAccessExpression>parent).name === node;
|
||||
case SyntaxKind.QualifiedName:
|
||||
// Name on right hand side of dot in a type query
|
||||
if ((<QualifiedName>parent).right === node) {
|
||||
while (parent.kind === SyntaxKind.QualifiedName) {
|
||||
parent = parent.parent;
|
||||
}
|
||||
return parent.kind === SyntaxKind.TypeQuery;
|
||||
}
|
||||
return false;
|
||||
case SyntaxKind.BindingElement:
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
// Property name in binding element or import specifier
|
||||
return (<BindingElement | ImportSpecifier>parent).propertyName === node;
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
// Any name in an export specifier
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// An alias symbol is created by one of the following declarations:
|
||||
// import <symbol> = ...
|
||||
// import <symbol> from ...
|
||||
@ -1525,7 +1681,7 @@ module ts {
|
||||
if ((isExternalModule(sourceFile) || !compilerOptions.out)) {
|
||||
// 1. in-browser single file compilation scenario
|
||||
// 2. non .js file
|
||||
return compilerOptions.separateCompilation || !fileExtensionIs(sourceFile.fileName, ".js");
|
||||
return compilerOptions.isolatedModules || !fileExtensionIs(sourceFile.fileName, ".js");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -1758,6 +1914,12 @@ module ts {
|
||||
return token >= SyntaxKind.FirstAssignment && token <= SyntaxKind.LastAssignment;
|
||||
}
|
||||
|
||||
export function isExpressionWithTypeArgumentsInClassExtendsClause(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.ExpressionWithTypeArguments &&
|
||||
(<HeritageClause>node.parent).token === SyntaxKind.ExtendsKeyword &&
|
||||
node.parent.parent.kind === SyntaxKind.ClassDeclaration;
|
||||
}
|
||||
|
||||
// Returns false if this heritage clause element's expression contains something unsupported
|
||||
// (i.e. not a name or dotted name).
|
||||
export function isSupportedExpressionWithTypeArguments(node: ExpressionWithTypeArguments): boolean {
|
||||
@ -1865,9 +2027,24 @@ module ts {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const carriageReturnLineFeed = "\r\n";
|
||||
const lineFeed = "\n";
|
||||
export function getNewLineCharacter(options: CompilerOptions): string {
|
||||
if (options.newLine === NewLineKind.CarriageReturnLineFeed) {
|
||||
return carriageReturnLineFeed;
|
||||
}
|
||||
else if (options.newLine === NewLineKind.LineFeed) {
|
||||
return lineFeed;
|
||||
}
|
||||
else if (sys) {
|
||||
return sys.newLine
|
||||
}
|
||||
return carriageReturnLineFeed;
|
||||
}
|
||||
}
|
||||
|
||||
module ts {
|
||||
namespace ts {
|
||||
export function getDefaultLibFileName(options: CompilerOptions): string {
|
||||
return options.target === ScriptTarget.ES6 ? "lib.es6.d.ts" : "lib.d.ts";
|
||||
}
|
||||
@ -1913,6 +2090,12 @@ module ts {
|
||||
return start <= textSpanEnd(span) && end >= span.start;
|
||||
}
|
||||
|
||||
export function decodedTextSpanIntersectsWith(start1: number, length1: number, start2: number, length2: number) {
|
||||
let end1 = start1 + length1;
|
||||
let end2 = start2 + length2;
|
||||
return start2 <= end1 && end2 >= start1;
|
||||
}
|
||||
|
||||
export function textSpanIntersectsWithPosition(span: TextSpan, position: number) {
|
||||
return position <= textSpanEnd(span) && position >= span.start;
|
||||
}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
/// <reference path='harness.ts' />
|
||||
/// <reference path='runnerbase.ts' />
|
||||
/// <reference path='typeWriter.ts' />
|
||||
/// <reference path='syntacticCleaner.ts' />
|
||||
|
||||
const enum CompilerTestType {
|
||||
Conformance,
|
||||
@ -18,7 +17,7 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
|
||||
public options: string;
|
||||
|
||||
constructor(public testType?: CompilerTestType) {
|
||||
constructor(public testType: CompilerTestType) {
|
||||
super();
|
||||
this.errors = true;
|
||||
this.emit = true;
|
||||
@ -171,7 +170,6 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
it('Correct JS output for ' + fileName, () => {
|
||||
if (!ts.fileExtensionIs(lastUnit.name, '.d.ts') && this.emit) {
|
||||
if (result.files.length === 0 && result.errors.length === 0) {
|
||||
@ -195,8 +193,6 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
jsCode += '//// [' + Harness.Path.getFileName(result.files[i].fileName) + ']\r\n';
|
||||
jsCode += getByteOrderMarkText(result.files[i]);
|
||||
jsCode += result.files[i].code;
|
||||
// Re-enable this if we want to do another comparison of old vs new compiler baselines
|
||||
// jsCode += SyntacticCleaner.clean(result.files[i].code);
|
||||
}
|
||||
|
||||
if (result.declFilesCode.length > 0) {
|
||||
|
||||
@ -1,74 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// Allows for executing a program with command-line arguments and reading the result
|
||||
interface IExec {
|
||||
exec: (fileName: string, cmdLineArgs: string[], handleResult: (ExecResult: ExecResult) => void) => void;
|
||||
}
|
||||
|
||||
class ExecResult {
|
||||
public stdout = "";
|
||||
public stderr = "";
|
||||
public exitCode: number;
|
||||
}
|
||||
|
||||
class WindowsScriptHostExec implements IExec {
|
||||
public exec(fileName: string, cmdLineArgs: string[], handleResult: (ExecResult: ExecResult) => void) : void {
|
||||
var result = new ExecResult();
|
||||
var shell = new ActiveXObject('WScript.Shell');
|
||||
try {
|
||||
var process = shell.Exec(fileName + ' ' + cmdLineArgs.join(' '));
|
||||
} catch(e) {
|
||||
result.stderr = e.message;
|
||||
result.exitCode = 1;
|
||||
handleResult(result);
|
||||
return;
|
||||
}
|
||||
// Wait for it to finish running
|
||||
while (process.Status != 0) { /* todo: sleep? */ }
|
||||
|
||||
|
||||
result.exitCode = process.ExitCode;
|
||||
if(!process.StdOut.AtEndOfStream) result.stdout = process.StdOut.ReadAll();
|
||||
if(!process.StdErr.AtEndOfStream) result.stderr = process.StdErr.ReadAll();
|
||||
|
||||
handleResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
class NodeExec implements IExec {
|
||||
public exec(fileName: string, cmdLineArgs: string[], handleResult: (ExecResult: ExecResult) => void) : void {
|
||||
var nodeExec = require('child_process').exec;
|
||||
|
||||
var result = new ExecResult();
|
||||
result.exitCode = null;
|
||||
var cmdLine = fileName + ' ' + cmdLineArgs.join(' ');
|
||||
var process = nodeExec(cmdLine, function(error: any, stdout: string, stderr: string) {
|
||||
result.stdout = stdout;
|
||||
result.stderr = stderr;
|
||||
result.exitCode = error ? error.code : 0;
|
||||
handleResult(result);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var Exec: IExec = function() : IExec {
|
||||
var global = <any>Function("return this;").call(null);
|
||||
if(typeof global.ActiveXObject !== "undefined") {
|
||||
return new WindowsScriptHostExec();
|
||||
} else {
|
||||
return new NodeExec();
|
||||
}
|
||||
}();
|
||||
@ -343,7 +343,8 @@ module FourSlash {
|
||||
if (!resolvedResult.isLibFile) {
|
||||
this.languageServiceAdapterHost.addScript(Harness.Compiler.defaultLibFileName, Harness.Compiler.defaultLibSourceFile.text);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// resolveReference file-option is not specified then do not resolve any files and include all inputFiles
|
||||
ts.forEachKey(this.inputFiles, fileName => {
|
||||
if (!Harness.isLibraryFile(fileName)) {
|
||||
@ -830,6 +831,7 @@ module FourSlash {
|
||||
if (expectedText !== undefined) {
|
||||
assert.notEqual(actualQuickInfoText, expectedText, this.messageAtLastKnownMarker("quick info text"));
|
||||
}
|
||||
// TODO: should be '==='?
|
||||
if (expectedDocumentation != undefined) {
|
||||
assert.notEqual(actualQuickInfoDocumentation, expectedDocumentation, this.messageAtLastKnownMarker("quick info doc comment"));
|
||||
}
|
||||
@ -837,6 +839,7 @@ module FourSlash {
|
||||
if (expectedText !== undefined) {
|
||||
assert.equal(actualQuickInfoText, expectedText, this.messageAtLastKnownMarker("quick info text"));
|
||||
}
|
||||
// TODO: should be '==='?
|
||||
if (expectedDocumentation != undefined) {
|
||||
assert.equal(actualQuickInfoDocumentation, expectedDocumentation, assertionMessage("quick info doc"));
|
||||
}
|
||||
@ -1818,6 +1821,21 @@ module FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
private verifyProjectInfo(expected: string[]) {
|
||||
if (this.testType === FourSlashTestType.Server) {
|
||||
let actual = (<ts.server.SessionClient>this.languageService).getProjectInfo(
|
||||
this.activeFile.fileName,
|
||||
/* needFileNameList */ true
|
||||
);
|
||||
assert.equal(
|
||||
expected.join(","),
|
||||
actual.fileNameList.map( file => {
|
||||
return file.replace(this.basePath + "/", "")
|
||||
}).join(",")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public verifySemanticClassifications(expected: { classificationType: string; text: string }[]) {
|
||||
var actual = this.languageService.getSemanticClassifications(this.activeFile.fileName,
|
||||
ts.createTextSpan(0, this.activeFile.content.length));
|
||||
@ -1921,7 +1939,7 @@ module FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
if (expected != actual) {
|
||||
if (expected !== actual) {
|
||||
this.raiseError('verifyNavigationItemsCount failed - found: ' + actual + ' navigation items, expected: ' + expected + '.');
|
||||
}
|
||||
}
|
||||
@ -1968,7 +1986,7 @@ module FourSlash {
|
||||
var items = this.languageService.getNavigationBarItems(this.activeFile.fileName);
|
||||
var actual = this.getNavigationBarItemsCount(items);
|
||||
|
||||
if (expected != actual) {
|
||||
if (expected !== actual) {
|
||||
this.raiseError('verifyGetScriptLexicalStructureListCount failed - found: ' + actual + ' navigation items, expected: ' + expected + '.');
|
||||
}
|
||||
}
|
||||
@ -2386,6 +2404,7 @@ module FourSlash {
|
||||
globalOptions[match[1]] = match[2];
|
||||
}
|
||||
}
|
||||
// TODO: should be '==='?
|
||||
} else if (line == '' || lineLength === 0) {
|
||||
// Previously blank lines between fourslash content caused it to be considered as 2 files,
|
||||
// Remove this behavior since it just causes errors now
|
||||
|
||||
@ -99,7 +99,7 @@ module Utils {
|
||||
}
|
||||
|
||||
try {
|
||||
var content = ts.sys.readFile(Harness.userSpecifiedroot + path);
|
||||
var content = ts.sys.readFile(Harness.userSpecifiedRoot + path);
|
||||
}
|
||||
catch (err) {
|
||||
return undefined;
|
||||
@ -732,7 +732,8 @@ module Harness {
|
||||
}
|
||||
|
||||
// Settings
|
||||
export var userSpecifiedroot = "";
|
||||
export let userSpecifiedRoot = "";
|
||||
export let lightMode = false;
|
||||
|
||||
/** Functionality for compiling TypeScript code */
|
||||
export module Compiler {
|
||||
@ -808,12 +809,20 @@ module Harness {
|
||||
}
|
||||
}
|
||||
|
||||
export function createSourceFileAndAssertInvariants(fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, assertInvariants = true) {
|
||||
export function createSourceFileAndAssertInvariants(
|
||||
fileName: string,
|
||||
sourceText: string,
|
||||
languageVersion: ts.ScriptTarget) {
|
||||
// We'll only assert invariants outside of light mode.
|
||||
const shouldAssertInvariants = !Harness.lightMode;
|
||||
|
||||
// Only set the parent nodes if we're asserting invariants. We don't need them otherwise.
|
||||
var result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ assertInvariants);
|
||||
if (assertInvariants) {
|
||||
var result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ shouldAssertInvariants);
|
||||
|
||||
if (shouldAssertInvariants) {
|
||||
Utils.assertInvariants(result, /*parent:*/ undefined);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -832,13 +841,14 @@ module Harness {
|
||||
return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
|
||||
}
|
||||
|
||||
export function createCompilerHost(inputFiles: { unitName: string; content: string; }[],
|
||||
writeFile: (fn: string, contents: string, writeByteOrderMark: boolean) => void,
|
||||
scriptTarget: ts.ScriptTarget,
|
||||
useCaseSensitiveFileNames: boolean,
|
||||
// the currentDirectory is needed for rwcRunner to passed in specified current directory to compiler host
|
||||
currentDirectory?: string,
|
||||
newLineKind?: ts.NewLineKind): ts.CompilerHost {
|
||||
export function createCompilerHost(
|
||||
inputFiles: { unitName: string; content: string; }[],
|
||||
writeFile: (fn: string, contents: string, writeByteOrderMark: boolean) => void,
|
||||
scriptTarget: ts.ScriptTarget,
|
||||
useCaseSensitiveFileNames: boolean,
|
||||
// the currentDirectory is needed for rwcRunner to passed in specified current directory to compiler host
|
||||
currentDirectory?: string,
|
||||
newLineKind?: ts.NewLineKind): ts.CompilerHost {
|
||||
|
||||
// Local get canonical file name function, that depends on passed in parameter for useCaseSensitiveFileNames
|
||||
function getCanonicalFileName(fileName: string): string {
|
||||
@ -899,7 +909,7 @@ module Harness {
|
||||
private compileOptions: ts.CompilerOptions;
|
||||
private settings: Harness.TestCaseParser.CompilerSetting[] = [];
|
||||
|
||||
private lastErrors: HarnessDiagnostic[];
|
||||
private lastErrors: ts.Diagnostic[];
|
||||
|
||||
public reset() {
|
||||
this.inputFiles = [];
|
||||
@ -932,17 +942,19 @@ module Harness {
|
||||
}
|
||||
|
||||
public emitAll(ioHost?: IEmitterIOHost) {
|
||||
this.compileFiles(this.inputFiles, [],(result) => {
|
||||
result.files.forEach(file => {
|
||||
ioHost.writeFile(file.fileName, file.code, false);
|
||||
});
|
||||
result.declFilesCode.forEach(file => {
|
||||
ioHost.writeFile(file.fileName, file.code, false);
|
||||
});
|
||||
result.sourceMaps.forEach(file => {
|
||||
ioHost.writeFile(file.fileName, file.code, false);
|
||||
});
|
||||
},() => { }, this.compileOptions);
|
||||
this.compileFiles(this.inputFiles,
|
||||
/*otherFiles*/ [],
|
||||
/*onComplete*/ result => {
|
||||
result.files.forEach(writeFile);
|
||||
result.declFilesCode.forEach(writeFile);
|
||||
result.sourceMaps.forEach(writeFile);
|
||||
},
|
||||
/*settingsCallback*/ () => { },
|
||||
this.compileOptions);
|
||||
|
||||
function writeFile(file: GeneratedFile) {
|
||||
ioHost.writeFile(file.fileName, file.code, false);
|
||||
}
|
||||
}
|
||||
|
||||
public compileFiles(inputFiles: { unitName: string; content: string }[],
|
||||
@ -951,8 +963,7 @@ module Harness {
|
||||
settingsCallback?: (settings: ts.CompilerOptions) => void,
|
||||
options?: ts.CompilerOptions,
|
||||
// Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file
|
||||
currentDirectory?: string,
|
||||
assertInvariants = true) {
|
||||
currentDirectory?: string) {
|
||||
|
||||
options = options || { noResolve: false };
|
||||
options.target = options.target || ts.ScriptTarget.ES3;
|
||||
@ -964,14 +975,39 @@ module Harness {
|
||||
settingsCallback(null);
|
||||
}
|
||||
|
||||
var newLine = '\r\n';
|
||||
let newLine = '\r\n';
|
||||
options.skipDefaultLibCheck = true;
|
||||
|
||||
// Files from built\local that are requested by test "@includeBuiltFiles" to be in the context.
|
||||
// Treat them as library files, so include them in build, but not in baselines.
|
||||
var includeBuiltFiles: { unitName: string; content: string }[] = [];
|
||||
|
||||
var useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames;
|
||||
this.settings.forEach(setting => {
|
||||
this.settings.forEach(setCompilerOptionForSetting);
|
||||
|
||||
var fileOutputs: GeneratedFile[] = [];
|
||||
|
||||
var programFiles = inputFiles.concat(includeBuiltFiles).map(file => file.unitName);
|
||||
|
||||
var compilerHost = createCompilerHost(
|
||||
inputFiles.concat(includeBuiltFiles).concat(otherFiles),
|
||||
(fn, contents, writeByteOrderMark) => fileOutputs.push({ fileName: fn, code: contents, writeByteOrderMark: writeByteOrderMark }),
|
||||
options.target, useCaseSensitiveFileNames, currentDirectory, options.newLine);
|
||||
var program = ts.createProgram(programFiles, options, compilerHost);
|
||||
|
||||
var emitResult = program.emit();
|
||||
|
||||
var errors = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
||||
this.lastErrors = errors;
|
||||
|
||||
var result = new CompilerResult(fileOutputs, errors, program, ts.sys.getCurrentDirectory(), emitResult.sourceMaps);
|
||||
onComplete(result, program);
|
||||
|
||||
// reset what newline means in case the last test changed it
|
||||
ts.sys.newLine = newLine;
|
||||
return options;
|
||||
|
||||
function setCompilerOptionForSetting(setting: Harness.TestCaseParser.CompilerSetting) {
|
||||
switch (setting.flag.toLowerCase()) {
|
||||
// "fileName", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noimplicitany", "noresolve"
|
||||
case "module":
|
||||
@ -1011,6 +1047,10 @@ module Harness {
|
||||
options.target = <any>setting.value;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'experimentaldecorators':
|
||||
options.experimentalDecorators = setting.value === 'true';
|
||||
break;
|
||||
|
||||
case 'emitdecoratormetadata':
|
||||
options.emitDecoratorMetadata = setting.value === 'true';
|
||||
@ -1046,6 +1086,10 @@ module Harness {
|
||||
options.outDir = setting.value;
|
||||
break;
|
||||
|
||||
case 'skipdefaultlibcheck':
|
||||
options.skipDefaultLibCheck = setting.value === "true";
|
||||
break;
|
||||
|
||||
case 'sourceroot':
|
||||
options.sourceRoot = setting.value;
|
||||
break;
|
||||
@ -1074,10 +1118,6 @@ module Harness {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'normalizenewline':
|
||||
newLine = setting.value;
|
||||
break;
|
||||
|
||||
case 'comments':
|
||||
options.removeComments = setting.value === 'false';
|
||||
break;
|
||||
@ -1105,8 +1145,8 @@ module Harness {
|
||||
options.preserveConstEnums = setting.value === 'true';
|
||||
break;
|
||||
|
||||
case 'separatecompilation':
|
||||
options.separateCompilation = setting.value === 'true';
|
||||
case 'isolatedmodules':
|
||||
options.isolatedModules = setting.value === 'true';
|
||||
break;
|
||||
|
||||
case 'suppressimplicitanyindexerrors':
|
||||
@ -1121,7 +1161,7 @@ module Harness {
|
||||
case 'inlinesourcemap':
|
||||
options.inlineSourceMap = setting.value === 'true';
|
||||
break;
|
||||
|
||||
|
||||
case 'inlinesources':
|
||||
options.inlineSources = setting.value === 'true';
|
||||
break;
|
||||
@ -1129,30 +1169,7 @@ module Harness {
|
||||
default:
|
||||
throw new Error('Unsupported compiler setting ' + setting.flag);
|
||||
}
|
||||
});
|
||||
|
||||
var fileOutputs: GeneratedFile[] = [];
|
||||
|
||||
var programFiles = inputFiles.concat(includeBuiltFiles).map(file => file.unitName);
|
||||
var program = ts.createProgram(programFiles, options, createCompilerHost(inputFiles.concat(includeBuiltFiles).concat(otherFiles),
|
||||
(fn, contents, writeByteOrderMark) => fileOutputs.push({ fileName: fn, code: contents, writeByteOrderMark: writeByteOrderMark }),
|
||||
options.target, useCaseSensitiveFileNames, currentDirectory, options.newLine));
|
||||
|
||||
var emitResult = program.emit();
|
||||
|
||||
var errors: HarnessDiagnostic[] = [];
|
||||
ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics).forEach(err => {
|
||||
// TODO: new compiler formats errors after this point to add . and newlines so we'll just do it manually for now
|
||||
errors.push(getMinimalDiagnostic(err));
|
||||
});
|
||||
this.lastErrors = errors;
|
||||
|
||||
var result = new CompilerResult(fileOutputs, errors, program, ts.sys.getCurrentDirectory(), emitResult.sourceMaps);
|
||||
onComplete(result, program);
|
||||
|
||||
// reset what newline means in case the last test changed it
|
||||
ts.sys.newLine = newLine;
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
||||
public compileDeclarationFiles(inputFiles: { unitName: string; content: string; }[],
|
||||
@ -1231,70 +1248,50 @@ module Harness {
|
||||
return normalized;
|
||||
}
|
||||
|
||||
export function getMinimalDiagnostic(err: ts.Diagnostic): HarnessDiagnostic {
|
||||
var errorLineInfo = err.file ? err.file.getLineAndCharacterOfPosition(err.start) : { line: -1, character: -1 };
|
||||
return {
|
||||
fileName: err.file && err.file.fileName,
|
||||
start: err.start,
|
||||
end: err.start + err.length,
|
||||
line: errorLineInfo.line + 1,
|
||||
character: errorLineInfo.character + 1,
|
||||
message: ts.flattenDiagnosticMessageText(err.messageText, ts.sys.newLine),
|
||||
category: ts.DiagnosticCategory[err.category].toLowerCase(),
|
||||
code: err.code
|
||||
};
|
||||
}
|
||||
|
||||
export function minimalDiagnosticsToString(diagnostics: HarnessDiagnostic[]) {
|
||||
export function minimalDiagnosticsToString(diagnostics: ts.Diagnostic[]) {
|
||||
// This is basically copied from tsc.ts's reportError to replicate what tsc does
|
||||
var errorOutput = "";
|
||||
ts.forEach(diagnostics, diagnotic => {
|
||||
if (diagnotic.fileName) {
|
||||
errorOutput += diagnotic.fileName + "(" + diagnotic.line + "," + diagnotic.character + "): ";
|
||||
ts.forEach(diagnostics, diagnostic => {
|
||||
if (diagnostic.file) {
|
||||
var lineAndCharacter = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
errorOutput += diagnostic.file.fileName + "(" + (lineAndCharacter.line + 1) + "," + (lineAndCharacter.character + 1) + "): ";
|
||||
}
|
||||
|
||||
errorOutput += diagnotic.category + " TS" + diagnotic.code + ": " + diagnotic.message + ts.sys.newLine;
|
||||
errorOutput += ts.DiagnosticCategory[diagnostic.category].toLowerCase() + " TS" + diagnostic.code + ": " + ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine) + ts.sys.newLine;
|
||||
});
|
||||
|
||||
return errorOutput;
|
||||
}
|
||||
|
||||
function compareDiagnostics(d1: HarnessDiagnostic, d2: HarnessDiagnostic) {
|
||||
return ts.compareValues(d1.fileName, d2.fileName) ||
|
||||
ts.compareValues(d1.start, d2.start) ||
|
||||
ts.compareValues(d1.end, d2.end) ||
|
||||
ts.compareValues(d1.code, d2.code) ||
|
||||
ts.compareValues(d1.message, d2.message) ||
|
||||
0;
|
||||
}
|
||||
|
||||
export function getErrorBaseline(inputFiles: { unitName: string; content: string }[], diagnostics: HarnessDiagnostic[]) {
|
||||
diagnostics.sort(compareDiagnostics);
|
||||
export function getErrorBaseline(inputFiles: { unitName: string; content: string }[], diagnostics: ts.Diagnostic[]) {
|
||||
diagnostics.sort(ts.compareDiagnostics);
|
||||
var outputLines: string[] = [];
|
||||
// Count up all the errors we find so we don't miss any
|
||||
var totalErrorsReported = 0;
|
||||
|
||||
function outputErrorText(error: Harness.Compiler.HarnessDiagnostic) {
|
||||
var errLines = RunnerBase.removeFullPaths(error.message)
|
||||
function outputErrorText(error: ts.Diagnostic) {
|
||||
var message = ts.flattenDiagnosticMessageText(error.messageText, ts.sys.newLine);
|
||||
|
||||
var errLines = RunnerBase.removeFullPaths(message)
|
||||
.split('\n')
|
||||
.map(s => s.length > 0 && s.charAt(s.length - 1) === '\r' ? s.substr(0, s.length - 1) : s)
|
||||
.filter(s => s.length > 0)
|
||||
.map(s => '!!! ' + error.category + " TS" + error.code + ": " + s);
|
||||
.map(s => '!!! ' + ts.DiagnosticCategory[error.category].toLowerCase() + " TS" + error.code + ": " + s);
|
||||
errLines.forEach(e => outputLines.push(e));
|
||||
|
||||
totalErrorsReported++;
|
||||
}
|
||||
|
||||
// Report global errors
|
||||
var globalErrors = diagnostics.filter(err => !err.fileName);
|
||||
var globalErrors = diagnostics.filter(err => !err.file);
|
||||
globalErrors.forEach(outputErrorText);
|
||||
|
||||
// 'merge' the lines of each input file with any errors associated with it
|
||||
inputFiles.filter(f => f.content !== undefined).forEach(inputFile => {
|
||||
// Filter down to the errors in the file
|
||||
var fileErrors = diagnostics.filter(e => {
|
||||
var errFn = e.fileName;
|
||||
return errFn && errFn === inputFile.unitName;
|
||||
var errFn = e.file;
|
||||
return errFn && errFn.fileName === inputFile.unitName;
|
||||
});
|
||||
|
||||
|
||||
@ -1330,18 +1327,19 @@ module Harness {
|
||||
outputLines.push(' ' + line);
|
||||
fileErrors.forEach(err => {
|
||||
// Does any error start or continue on to this line? Emit squiggles
|
||||
if ((err.end >= thisLineStart) && ((err.start < nextLineStart) || (lineIndex === lines.length - 1))) {
|
||||
let end = ts.textSpanEnd(err);
|
||||
if ((end >= thisLineStart) && ((err.start < nextLineStart) || (lineIndex === lines.length - 1))) {
|
||||
// How many characters from the start of this line the error starts at (could be positive or negative)
|
||||
var relativeOffset = err.start - thisLineStart;
|
||||
// How many characters of the error are on this line (might be longer than this line in reality)
|
||||
var length = (err.end - err.start) - Math.max(0, thisLineStart - err.start);
|
||||
var length = (end - err.start) - Math.max(0, thisLineStart - err.start);
|
||||
// Calculate the start of the squiggle
|
||||
var squiggleStart = Math.max(0, relativeOffset);
|
||||
// TODO/REVIEW: this doesn't work quite right in the browser if a multi file test has files whose names are just the right length relative to one another
|
||||
outputLines.push(' ' + line.substr(0, squiggleStart).replace(/[^\s]/g, ' ') + new Array(Math.min(length, line.length - squiggleStart) + 1).join('~'));
|
||||
|
||||
// If the error ended here, or we're at the end of the file, emit its message
|
||||
if ((lineIndex === lines.length - 1) || nextLineStart > err.end) {
|
||||
if ((lineIndex === lines.length - 1) || nextLineStart > end) {
|
||||
// Just like above, we need to do a split on a string instead of on a regex
|
||||
// because the JS engine does regexes wrong
|
||||
|
||||
@ -1357,12 +1355,12 @@ module Harness {
|
||||
});
|
||||
|
||||
var numLibraryDiagnostics = ts.countWhere(diagnostics, diagnostic => {
|
||||
return diagnostic.fileName && (isLibraryFile(diagnostic.fileName) || isBuiltFile(diagnostic.fileName));
|
||||
return diagnostic.file && (isLibraryFile(diagnostic.file.fileName) || isBuiltFile(diagnostic.file.fileName));
|
||||
});
|
||||
|
||||
var numTest262HarnessDiagnostics = ts.countWhere(diagnostics, diagnostic => {
|
||||
// Count an error generated from tests262-harness folder.This should only apply for test262
|
||||
return diagnostic.fileName && diagnostic.fileName.indexOf("test262-harness") >= 0;
|
||||
return diagnostic.file && diagnostic.file.fileName.indexOf("test262-harness") >= 0;
|
||||
});
|
||||
|
||||
// Verify we didn't miss any errors in total
|
||||
@ -1372,29 +1370,30 @@ module Harness {
|
||||
ts.sys.newLine + ts.sys.newLine + outputLines.join('\r\n');
|
||||
}
|
||||
|
||||
export function collateOutputs(outputFiles: Harness.Compiler.GeneratedFile[], clean?: (s: string) => string) {
|
||||
export function collateOutputs(outputFiles: Harness.Compiler.GeneratedFile[]): string {
|
||||
// Collect, test, and sort the fileNames
|
||||
function cleanName(fn: string) {
|
||||
var lastSlash = ts.normalizeSlashes(fn).lastIndexOf('/');
|
||||
return fn.substr(lastSlash + 1).toLowerCase();
|
||||
}
|
||||
outputFiles.sort((a, b) => cleanName(a.fileName).localeCompare(cleanName(b.fileName)));
|
||||
|
||||
// Emit them
|
||||
var result = '';
|
||||
ts.forEach(outputFiles, outputFile => {
|
||||
for (let outputFile of outputFiles) {
|
||||
// Some extra spacing if this isn't the first file
|
||||
if (result.length) result = result + '\r\n\r\n';
|
||||
if (result.length) {
|
||||
result += '\r\n\r\n';
|
||||
}
|
||||
|
||||
// FileName header + content
|
||||
result = result + '/*====== ' + outputFile.fileName + ' ======*/\r\n';
|
||||
if (clean) {
|
||||
result = result + clean(outputFile.code);
|
||||
} else {
|
||||
result = result + outputFile.code;
|
||||
}
|
||||
});
|
||||
result += '/*====== ' + outputFile.fileName + ' ======*/\r\n';
|
||||
|
||||
result += outputFile.code;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
function cleanName(fn: string) {
|
||||
var lastSlash = ts.normalizeSlashes(fn).lastIndexOf('/');
|
||||
return fn.substr(lastSlash + 1).toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
/** The harness' compiler instance used when tests are actually run. Reseting or changing settings of this compiler instance must be done within a test case (i.e., describe/it) */
|
||||
@ -1415,17 +1414,6 @@ module Harness {
|
||||
//harnessCompiler.compileString(code, unitName, callback);
|
||||
}
|
||||
|
||||
export interface HarnessDiagnostic {
|
||||
fileName: string;
|
||||
start: number;
|
||||
end: number;
|
||||
line: number;
|
||||
character: number;
|
||||
message: string;
|
||||
category: string;
|
||||
code: number;
|
||||
}
|
||||
|
||||
export interface GeneratedFile {
|
||||
fileName: string;
|
||||
code: string;
|
||||
@ -1455,12 +1443,12 @@ module Harness {
|
||||
/** Contains the code and errors of a compilation and some helper methods to check its status. */
|
||||
export class CompilerResult {
|
||||
public files: GeneratedFile[] = [];
|
||||
public errors: HarnessDiagnostic[] = [];
|
||||
public errors: ts.Diagnostic[] = [];
|
||||
public declFilesCode: GeneratedFile[] = [];
|
||||
public sourceMaps: GeneratedFile[] = [];
|
||||
|
||||
/** @param fileResults an array of strings for the fileName and an ITextWriter with its code */
|
||||
constructor(fileResults: GeneratedFile[], errors: HarnessDiagnostic[], public program: ts.Program,
|
||||
constructor(fileResults: GeneratedFile[], errors: ts.Diagnostic[], public program: ts.Program,
|
||||
public currentDirectoryForProgram: string, private sourceMapData: ts.SourceMapData[]) {
|
||||
|
||||
fileResults.forEach(emittedFile => {
|
||||
@ -1485,15 +1473,6 @@ module Harness {
|
||||
return Harness.SourceMapRecoder.getSourceMapRecord(this.sourceMapData, this.program, this.files);
|
||||
}
|
||||
}
|
||||
|
||||
public isErrorAt(line: number, column: number, message: string) {
|
||||
for (var i = 0; i < this.errors.length; i++) {
|
||||
if ((this.errors[i].line + 1) === line && (this.errors[i].character + 1) === column && this.errors[i].message === message)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1516,15 +1495,6 @@ module Harness {
|
||||
// Regex for parsing options in the format "@Alpha: Value of any sort"
|
||||
var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines
|
||||
|
||||
// List of allowed metadata names
|
||||
var fileMetadataNames = ["filename", "comments", "declaration", "module",
|
||||
"nolib", "sourcemap", "target", "out", "outdir", "noemithelpers", "noemitonerror",
|
||||
"noimplicitany", "noresolve", "newline", "normalizenewline", "emitbom",
|
||||
"errortruncation", "usecasesensitivefilenames", "preserveconstenums",
|
||||
"includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal",
|
||||
"separatecompilation", "inlinesourcemap", "maproot", "sourceroot",
|
||||
"inlinesources", "emitdecoratormetadata"];
|
||||
|
||||
function extractCompilerSettings(content: string): CompilerSetting[] {
|
||||
|
||||
var opts: CompilerSetting[] = [];
|
||||
@ -1558,10 +1528,8 @@ module Harness {
|
||||
if (testMetaData) {
|
||||
// Comment line, check for global/file @options and record them
|
||||
optionRegex.lastIndex = 0;
|
||||
var fileNameIndex = fileMetadataNames.indexOf(testMetaData[1].toLowerCase());
|
||||
if (fileNameIndex === -1) {
|
||||
throw new Error('Unrecognized metadata name "' + testMetaData[1] + '". Available file metadata names are: ' + fileMetadataNames.join(', '));
|
||||
} else if (fileNameIndex === 0) {
|
||||
var metaDataName = testMetaData[1].toLowerCase();
|
||||
if (metaDataName === "filename") {
|
||||
currentFileOptions[testMetaData[1]] = testMetaData[2];
|
||||
} else {
|
||||
continue;
|
||||
@ -1647,9 +1615,9 @@ module Harness {
|
||||
|
||||
function baselinePath(fileName: string, type: string, baselineFolder: string, subfolder?: string) {
|
||||
if (subfolder !== undefined) {
|
||||
return Harness.userSpecifiedroot + baselineFolder + '/' + subfolder + '/' + type + '/' + fileName;
|
||||
return Harness.userSpecifiedRoot + baselineFolder + '/' + subfolder + '/' + type + '/' + fileName;
|
||||
} else {
|
||||
return Harness.userSpecifiedroot + baselineFolder + '/' + type + '/' + fileName;
|
||||
return Harness.userSpecifiedRoot + baselineFolder + '/' + type + '/' + fileName;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1758,7 +1726,7 @@ module Harness {
|
||||
}
|
||||
|
||||
export function getDefaultLibraryFile(): { unitName: string, content: string } {
|
||||
var libFile = Harness.userSpecifiedroot + Harness.libFolder + "/" + "lib.d.ts";
|
||||
var libFile = Harness.userSpecifiedRoot + Harness.libFolder + "/" + "lib.d.ts";
|
||||
return {
|
||||
unitName: libFile,
|
||||
content: IO.readFile(libFile)
|
||||
|
||||
@ -583,7 +583,7 @@ module Harness.LanguageService {
|
||||
// This host is just a proxy for the clientHost, it uses the client
|
||||
// host to answer server queries about files on disk
|
||||
var serverHost = new SessionServerHost(clientHost);
|
||||
var server = new ts.server.Session(serverHost, serverHost);
|
||||
var server = new ts.server.Session(serverHost, Buffer.byteLength, process.hrtime, serverHost);
|
||||
|
||||
// Fake the connection between the client and the server
|
||||
serverHost.writeMessage = client.onMessage.bind(client);
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
/// <reference path="exec.ts" />
|
||||
/// <reference path="generate.ts" />
|
||||
/// <reference path="harness.ts" />
|
||||
/// <reference path="diff.ts" />
|
||||
@ -110,6 +110,7 @@ class ProjectRunner extends RunnerBase {
|
||||
else if (url.indexOf(diskProjectPath) === 0) {
|
||||
// Replace the disk specific path into the project root path
|
||||
url = url.substr(diskProjectPath.length);
|
||||
// TODO: should be '!=='?
|
||||
if (url.charCodeAt(0) != ts.CharacterCodes.slash) {
|
||||
url = "/" + url;
|
||||
}
|
||||
@ -240,7 +241,7 @@ class ProjectRunner extends RunnerBase {
|
||||
if (Harness.Compiler.isJS(fileName)) {
|
||||
// Make sure if there is URl we have it cleaned up
|
||||
var indexOfSourceMapUrl = data.lastIndexOf("//# sourceMappingURL=");
|
||||
if (indexOfSourceMapUrl != -1) {
|
||||
if (indexOfSourceMapUrl !== -1) {
|
||||
data = data.substring(0, indexOfSourceMapUrl + 21) + cleanProjectUrl(data.substring(indexOfSourceMapUrl + 21));
|
||||
}
|
||||
}
|
||||
@ -323,9 +324,8 @@ class ProjectRunner extends RunnerBase {
|
||||
sourceFile => {
|
||||
return { unitName: sourceFile.fileName, content: sourceFile.text };
|
||||
});
|
||||
var diagnostics = ts.map(compilerResult.errors, error => Harness.Compiler.getMinimalDiagnostic(error));
|
||||
|
||||
return Harness.Compiler.getErrorBaseline(inputFiles, diagnostics);
|
||||
return Harness.Compiler.getErrorBaseline(inputFiles, compilerResult.errors);
|
||||
}
|
||||
|
||||
var name = 'Compiling project for ' + testCase.scenario + ': testcase ' + testCaseFileName;
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
/// <reference path='fourslashRunner.ts' />
|
||||
/// <reference path='projectsRunner.ts' />
|
||||
/// <reference path='rwcRunner.ts' />
|
||||
/// <reference path='harness.ts' />
|
||||
|
||||
function runTests(runners: RunnerBase[]) {
|
||||
for (var i = iterations; i > 0; i--) {
|
||||
@ -38,41 +39,47 @@ var testConfigFile =
|
||||
(Harness.IO.fileExists(testconfig) ? Harness.IO.readFile(testconfig) : '');
|
||||
|
||||
if (testConfigFile !== '') {
|
||||
// TODO: not sure why this is crashing mocha
|
||||
//var testConfig = JSON.parse(testConfigRaw);
|
||||
var testConfig = testConfigFile.match(/test:\s\['(.*)'\]/);
|
||||
var options = testConfig ? [testConfig[1]] : [];
|
||||
for (var i = 0; i < options.length; i++) {
|
||||
switch (options[i]) {
|
||||
case 'compiler':
|
||||
runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance));
|
||||
runners.push(new CompilerBaselineRunner(CompilerTestType.Regressions));
|
||||
runners.push(new ProjectRunner());
|
||||
break;
|
||||
case 'conformance':
|
||||
runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance));
|
||||
break;
|
||||
case 'project':
|
||||
runners.push(new ProjectRunner());
|
||||
break;
|
||||
case 'fourslash':
|
||||
runners.push(new FourSlashRunner(FourSlashTestType.Native));
|
||||
break;
|
||||
case 'fourslash-shims':
|
||||
runners.push(new FourSlashRunner(FourSlashTestType.Shims));
|
||||
break;
|
||||
case 'fourslash-server':
|
||||
runners.push(new FourSlashRunner(FourSlashTestType.Server));
|
||||
break;
|
||||
case 'fourslash-generated':
|
||||
runners.push(new GeneratedFourslashRunner(FourSlashTestType.Native));
|
||||
break;
|
||||
case 'rwc':
|
||||
runners.push(new RWCRunner());
|
||||
break;
|
||||
case 'test262':
|
||||
runners.push(new Test262BaselineRunner());
|
||||
break;
|
||||
var testConfig = JSON.parse(testConfigFile);
|
||||
if (testConfig.light) {
|
||||
Harness.lightMode = true;
|
||||
}
|
||||
|
||||
if (testConfig.test && testConfig.test.length > 0) {
|
||||
for (let option of testConfig.test) {
|
||||
if (!option) {
|
||||
continue;
|
||||
}
|
||||
switch (option) {
|
||||
case 'compiler':
|
||||
runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance));
|
||||
runners.push(new CompilerBaselineRunner(CompilerTestType.Regressions));
|
||||
runners.push(new ProjectRunner());
|
||||
break;
|
||||
case 'conformance':
|
||||
runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance));
|
||||
break;
|
||||
case 'project':
|
||||
runners.push(new ProjectRunner());
|
||||
break;
|
||||
case 'fourslash':
|
||||
runners.push(new FourSlashRunner(FourSlashTestType.Native));
|
||||
break;
|
||||
case 'fourslash-shims':
|
||||
runners.push(new FourSlashRunner(FourSlashTestType.Shims));
|
||||
break;
|
||||
case 'fourslash-server':
|
||||
runners.push(new FourSlashRunner(FourSlashTestType.Server));
|
||||
break;
|
||||
case 'fourslash-generated':
|
||||
runners.push(new GeneratedFourslashRunner(FourSlashTestType.Native));
|
||||
break;
|
||||
case 'rwc':
|
||||
runners.push(new RWCRunner());
|
||||
break;
|
||||
case 'test262':
|
||||
runners.push(new Test262BaselineRunner());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ class RunnerBase {
|
||||
}
|
||||
|
||||
public enumerateFiles(folder: string, regex?: RegExp, options?: { recursive: boolean }): string[] {
|
||||
return Harness.IO.listFiles(Harness.userSpecifiedroot + folder, regex, { recursive: (options ? options.recursive : false) });
|
||||
return Harness.IO.listFiles(Harness.userSpecifiedRoot + folder, regex, { recursive: (options ? options.recursive : false) });
|
||||
}
|
||||
|
||||
/** Setup the runner's tests so that they are ready to be executed by the harness
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
/// <reference path='harness.ts'/>
|
||||
/// <reference path='runnerbase.ts' />
|
||||
/// <reference path='syntacticCleaner.ts' />
|
||||
/// <reference path='loggedIO.ts' />
|
||||
/// <reference path='..\compiler\commandLineParser.ts'/>
|
||||
|
||||
@ -75,7 +74,7 @@ module RWC {
|
||||
});
|
||||
|
||||
// Add files to compilation
|
||||
for(let fileRead of ioLog.filesRead) {
|
||||
for (let fileRead of ioLog.filesRead) {
|
||||
// Check if the file is already added into the set of input files.
|
||||
var resolvedPath = ts.normalizeSlashes(ts.sys.resolvePath(fileRead.path));
|
||||
var inInputList = ts.forEach(inputFiles, inputFile => inputFile.unitName === resolvedPath);
|
||||
@ -107,14 +106,14 @@ module RWC {
|
||||
opts.options.noLib = true;
|
||||
|
||||
// Emit the results
|
||||
compilerOptions = harnessCompiler.compileFiles(inputFiles, otherFiles, compileResult => {
|
||||
compilerResult = compileResult;
|
||||
},
|
||||
compilerOptions = harnessCompiler.compileFiles(
|
||||
inputFiles,
|
||||
otherFiles,
|
||||
newCompilerResults => { compilerResult = newCompilerResults; },
|
||||
/*settingsCallback*/ undefined, opts.options,
|
||||
// Since all Rwc json file specified current directory in its json file, we need to pass this information to compilerHost
|
||||
// so that when the host is asked for current directory, it should give the value from json rather than from process
|
||||
currentDirectory,
|
||||
/*assertInvariants:*/ false);
|
||||
// Since each RWC json file specifies its current directory in its json file, we need
|
||||
// to pass this information in explicitly instead of acquiring it from the process.
|
||||
currentDirectory);
|
||||
});
|
||||
|
||||
function getHarnessCompilerInputUnit(fileName: string) {
|
||||
@ -132,7 +131,7 @@ module RWC {
|
||||
|
||||
it('has the expected emitted code', () => {
|
||||
Harness.Baseline.runBaseline('has the expected emitted code', baseName + '.output.js', () => {
|
||||
return Harness.Compiler.collateOutputs(compilerResult.files, s => SyntacticCleaner.clean(s));
|
||||
return Harness.Compiler.collateOutputs(compilerResult.files);
|
||||
}, false, baselineOpts);
|
||||
});
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@ module Harness.SourceMapRecoder {
|
||||
}
|
||||
|
||||
function isSourceMappingSegmentEnd() {
|
||||
if (decodingIndex == sourceMapMappings.length) {
|
||||
if (decodingIndex === sourceMapMappings.length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ module Harness.SourceMapRecoder {
|
||||
var currentByte = base64FormatDecode();
|
||||
|
||||
// If msb is set, we still have more bits to continue
|
||||
moreDigits = (currentByte & 32) != 0;
|
||||
moreDigits = (currentByte & 32) !== 0;
|
||||
|
||||
// least significant 5 bits are the next msbs in the final value.
|
||||
value = value | ((currentByte & 31) << shiftCount);
|
||||
@ -103,7 +103,7 @@ module Harness.SourceMapRecoder {
|
||||
}
|
||||
|
||||
// Least significant bit if 1 represents negative and rest of the msb is actual absolute value
|
||||
if ((value & 1) == 0) {
|
||||
if ((value & 1) === 0) {
|
||||
// + number
|
||||
value = value >> 1;
|
||||
}
|
||||
@ -182,7 +182,7 @@ module Harness.SourceMapRecoder {
|
||||
}
|
||||
}
|
||||
// Dont support reading mappings that dont have information about original source and its line numbers
|
||||
if (createErrorIfCondition(!isSourceMappingSegmentEnd(), "Unsupported Error Format: There are more entries after " + (decodeOfEncodedMapping.nameIndex == -1 ? "sourceColumn" : "nameIndex"))) {
|
||||
if (createErrorIfCondition(!isSourceMappingSegmentEnd(), "Unsupported Error Format: There are more entries after " + (decodeOfEncodedMapping.nameIndex === -1 ? "sourceColumn" : "nameIndex"))) {
|
||||
return { error: errorDecodeOfEncodedMapping, sourceMapSpan: decodeOfEncodedMapping };
|
||||
}
|
||||
|
||||
@ -249,7 +249,7 @@ module Harness.SourceMapRecoder {
|
||||
mapString += " name (" + sourceMapNames[mapEntry.nameIndex] + ")";
|
||||
}
|
||||
else {
|
||||
if (mapEntry.nameIndex != -1 || getAbsentNameIndex) {
|
||||
if (mapEntry.nameIndex !== -1 || getAbsentNameIndex) {
|
||||
mapString += " nameIndex (" + mapEntry.nameIndex + ")";
|
||||
}
|
||||
}
|
||||
@ -262,12 +262,12 @@ module Harness.SourceMapRecoder {
|
||||
var decodeResult = SourceMapDecoder.decodeNextEncodedSourceMapSpan();
|
||||
var decodedErrors: string[];
|
||||
if (decodeResult.error
|
||||
|| decodeResult.sourceMapSpan.emittedLine != sourceMapSpan.emittedLine
|
||||
|| decodeResult.sourceMapSpan.emittedColumn != sourceMapSpan.emittedColumn
|
||||
|| decodeResult.sourceMapSpan.sourceLine != sourceMapSpan.sourceLine
|
||||
|| decodeResult.sourceMapSpan.sourceColumn != sourceMapSpan.sourceColumn
|
||||
|| decodeResult.sourceMapSpan.sourceIndex != sourceMapSpan.sourceIndex
|
||||
|| decodeResult.sourceMapSpan.nameIndex != sourceMapSpan.nameIndex) {
|
||||
|| decodeResult.sourceMapSpan.emittedLine !== sourceMapSpan.emittedLine
|
||||
|| decodeResult.sourceMapSpan.emittedColumn !== sourceMapSpan.emittedColumn
|
||||
|| decodeResult.sourceMapSpan.sourceLine !== sourceMapSpan.sourceLine
|
||||
|| decodeResult.sourceMapSpan.sourceColumn !== sourceMapSpan.sourceColumn
|
||||
|| decodeResult.sourceMapSpan.sourceIndex !== sourceMapSpan.sourceIndex
|
||||
|| decodeResult.sourceMapSpan.nameIndex !== sourceMapSpan.nameIndex) {
|
||||
if (decodeResult.error) {
|
||||
decodedErrors = ["!!^^ !!^^ There was decoding error in the sourcemap at this location: " + decodeResult.error];
|
||||
}
|
||||
@ -288,7 +288,7 @@ module Harness.SourceMapRecoder {
|
||||
}
|
||||
|
||||
export function recordNewSourceFileSpan(sourceMapSpan: ts.SourceMapSpan, newSourceFileCode: string) {
|
||||
assert.isTrue(spansOnSingleLine.length == 0 || spansOnSingleLine[0].sourceMapSpan.emittedLine !== sourceMapSpan.emittedLine, "new file source map span should be on new line. We currently handle only that scenario");
|
||||
assert.isTrue(spansOnSingleLine.length === 0 || spansOnSingleLine[0].sourceMapSpan.emittedLine !== sourceMapSpan.emittedLine, "new file source map span should be on new line. We currently handle only that scenario");
|
||||
recordSourceMapSpan(sourceMapSpan);
|
||||
|
||||
assert.isTrue(spansOnSingleLine.length === 1);
|
||||
@ -395,9 +395,9 @@ module Harness.SourceMapRecoder {
|
||||
|
||||
var tsCodeLineMap = ts.computeLineStarts(sourceText);
|
||||
for (var i = 0; i < tsCodeLineMap.length; i++) {
|
||||
writeSourceMapIndent(prevEmittedCol, i == 0 ? markerIds[index] : " >");
|
||||
writeSourceMapIndent(prevEmittedCol, i === 0 ? markerIds[index] : " >");
|
||||
sourceMapRecoder.Write(getTextOfLine(i, tsCodeLineMap, sourceText));
|
||||
if (i == tsCodeLineMap.length - 1) {
|
||||
if (i === tsCodeLineMap.length - 1) {
|
||||
sourceMapRecoder.WriteLine("");
|
||||
}
|
||||
}
|
||||
@ -447,7 +447,7 @@ module Harness.SourceMapRecoder {
|
||||
for (var j = 0; j < sourceMapData.sourceMapDecodedMappings.length; j++) {
|
||||
var decodedSourceMapping = sourceMapData.sourceMapDecodedMappings[j];
|
||||
var currentSourceFile = program.getSourceFile(sourceMapData.inputSourceFileNames[decodedSourceMapping.sourceIndex]);
|
||||
if (currentSourceFile != prevSourceFile) {
|
||||
if (currentSourceFile !== prevSourceFile) {
|
||||
SourceMapSpanWriter.recordNewSourceFileSpan(decodedSourceMapping, currentSourceFile.text);
|
||||
prevSourceFile = currentSourceFile;
|
||||
}
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
// Use this to get emitter-agnostic baselines
|
||||
|
||||
class SyntacticCleaner {
|
||||
static clean(sourceFileContents: string) {
|
||||
return sourceFileContents;
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: Re-implement or maybe delete
|
||||
class SyntacticCleaner extends TypeScript.SyntaxWalker {
|
||||
private emit: string[] = [];
|
||||
|
||||
public visitToken(token: TypeScript.ISyntaxToken): void {
|
||||
this.emit.push(token.text());
|
||||
if (token.kind() === TypeScript.SyntaxKind.SemicolonToken) {
|
||||
this.emit.push('\r\n');
|
||||
} else {
|
||||
this.emit.push(' ');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static clean(sourceFileContents: string): string {
|
||||
var parsed = TypeScript.Parser.parse('_emitted.ts', TypeScript.SimpleText.fromString(sourceFileContents), TypeScript.LanguageVersion.EcmaScript5, false);
|
||||
var cleaner = new SyntacticCleaner();
|
||||
cleaner.visitSourceUnit(parsed.sourceUnit());
|
||||
return cleaner.emit.join('');
|
||||
}
|
||||
}
|
||||
*/
|
||||
@ -1,6 +1,5 @@
|
||||
/// <reference path='harness.ts' />
|
||||
/// <reference path='runnerbase.ts' />
|
||||
/// <reference path='syntacticCleaner.ts' />
|
||||
|
||||
class Test262BaselineRunner extends RunnerBase {
|
||||
private static basePath = 'internal/cases/test262';
|
||||
@ -65,7 +64,7 @@ class Test262BaselineRunner extends RunnerBase {
|
||||
it('has the expected emitted code', () => {
|
||||
Harness.Baseline.runBaseline('has the expected emitted code', testState.filename + '.output.js', () => {
|
||||
var files = testState.compilerResult.files.filter(f=> f.fileName !== Test262BaselineRunner.helpersFilePath);
|
||||
return Harness.Compiler.collateOutputs(files, s => SyntacticCleaner.clean(s));
|
||||
return Harness.Compiler.collateOutputs(files);
|
||||
}, false, Test262BaselineRunner.baselineOptions);
|
||||
});
|
||||
|
||||
|
||||
@ -41,7 +41,10 @@ class TypeWriterWalker {
|
||||
var lineAndCharacter = this.currentSourceFile.getLineAndCharacterOfPosition(actualPos);
|
||||
var sourceText = ts.getTextOfNodeFromSourceText(this.currentSourceFile.text, node);
|
||||
|
||||
var type = this.checker.getTypeAtLocation(node);
|
||||
// Workaround to ensure we output 'C' instead of 'typeof C' for base class expressions
|
||||
// var type = this.checker.getTypeAtLocation(node);
|
||||
var type = node.parent && ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent) && this.checker.getTypeAtLocation(node.parent) || this.checker.getTypeAtLocation(node);
|
||||
|
||||
ts.Debug.assert(type !== undefined, "type doesn't exist");
|
||||
var symbol = this.checker.getSymbolAtLocation(node);
|
||||
|
||||
|
||||
2
src/lib/core.d.ts
vendored
2
src/lib/core.d.ts
vendored
@ -1150,7 +1150,7 @@ interface ArrayConstructor {
|
||||
(arrayLength?: number): any[];
|
||||
<T>(arrayLength: number): T[];
|
||||
<T>(...items: T[]): T[];
|
||||
isArray(arg: any): boolean;
|
||||
isArray(arg: any): arg is Array<any>;
|
||||
prototype: Array<any>;
|
||||
}
|
||||
|
||||
|
||||
11
src/lib/dom.es6.d.ts
vendored
Normal file
11
src/lib/dom.es6.d.ts
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
interface DOMTokenList {
|
||||
[Symbol.iterator](): IterableIterator<string>;
|
||||
}
|
||||
|
||||
interface NodeList {
|
||||
[Symbol.iterator](): IterableIterator<Node>
|
||||
}
|
||||
|
||||
interface NodeListOf<TNode extends Node> {
|
||||
[Symbol.iterator](): IterableIterator<TNode>
|
||||
}
|
||||
21
src/lib/dom.generated.d.ts
vendored
21
src/lib/dom.generated.d.ts
vendored
@ -7677,10 +7677,10 @@ declare var MediaQueryList: {
|
||||
interface MediaSource extends EventTarget {
|
||||
activeSourceBuffers: SourceBufferList;
|
||||
duration: number;
|
||||
readyState: string;
|
||||
readyState: number;
|
||||
sourceBuffers: SourceBufferList;
|
||||
addSourceBuffer(type: string): SourceBuffer;
|
||||
endOfStream(error?: string): void;
|
||||
endOfStream(error?: number): void;
|
||||
removeSourceBuffer(sourceBuffer: SourceBuffer): void;
|
||||
}
|
||||
|
||||
@ -8409,7 +8409,7 @@ declare var PopStateEvent: {
|
||||
|
||||
interface Position {
|
||||
coords: Coordinates;
|
||||
timestamp: Date;
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
declare var Position: {
|
||||
@ -11090,9 +11090,17 @@ interface WebGLRenderingContext {
|
||||
stencilMaskSeparate(face: number, mask: number): void;
|
||||
stencilOp(fail: number, zfail: number, zpass: number): void;
|
||||
stencilOpSeparate(face: number, fail: number, zfail: number, zpass: number): void;
|
||||
texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels: ArrayBufferView): void;
|
||||
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, image: HTMLImageElement): void;
|
||||
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, canvas: HTMLCanvasElement): void;
|
||||
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, video: HTMLVideoElement): void;
|
||||
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageData): void;
|
||||
texParameterf(target: number, pname: number, param: number): void;
|
||||
texParameteri(target: number, pname: number, param: number): void;
|
||||
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void;
|
||||
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, image: HTMLImageElement): void;
|
||||
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, canvas: HTMLCanvasElement): void;
|
||||
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, video: HTMLVideoElement): void;
|
||||
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageData): void;
|
||||
uniform1f(location: WebGLUniformLocation, x: number): void;
|
||||
uniform1fv(location: WebGLUniformLocation, v: any): void;
|
||||
@ -12332,10 +12340,11 @@ interface DocumentEvent {
|
||||
createEvent(eventInterface:"AriaRequestEvent"): AriaRequestEvent;
|
||||
createEvent(eventInterface:"AudioProcessingEvent"): AudioProcessingEvent;
|
||||
createEvent(eventInterface:"BeforeUnloadEvent"): BeforeUnloadEvent;
|
||||
createEvent(eventInterface:"ClipboardEvent"): ClipboardEvent;
|
||||
createEvent(eventInterface:"CloseEvent"): CloseEvent;
|
||||
createEvent(eventInterface:"CommandEvent"): CommandEvent;
|
||||
createEvent(eventInterface:"CompositionEvent"): CompositionEvent;
|
||||
createEvent(eventInterface: "CustomEvent"): CustomEvent;
|
||||
createEvent(eventInterface:"CustomEvent"): CustomEvent;
|
||||
createEvent(eventInterface:"DeviceMotionEvent"): DeviceMotionEvent;
|
||||
createEvent(eventInterface:"DeviceOrientationEvent"): DeviceOrientationEvent;
|
||||
createEvent(eventInterface:"DragEvent"): DragEvent;
|
||||
@ -12358,8 +12367,6 @@ interface DocumentEvent {
|
||||
createEvent(eventInterface:"MouseEvent"): MouseEvent;
|
||||
createEvent(eventInterface:"MouseEvents"): MouseEvent;
|
||||
createEvent(eventInterface:"MouseWheelEvent"): MouseWheelEvent;
|
||||
createEvent(eventInterface:"MSGestureEvent"): MSGestureEvent;
|
||||
createEvent(eventInterface:"MSPointerEvent"): MSPointerEvent;
|
||||
createEvent(eventInterface:"MutationEvent"): MutationEvent;
|
||||
createEvent(eventInterface:"MutationEvents"): MutationEvent;
|
||||
createEvent(eventInterface:"NavigationCompletedEvent"): NavigationCompletedEvent;
|
||||
@ -12971,4 +12978,4 @@ declare function addEventListener(type: "unload", listener: (ev: Event) => any,
|
||||
declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
|
||||
13
src/lib/es6.d.ts
vendored
13
src/lib/es6.d.ts
vendored
@ -316,6 +316,11 @@ interface Array<T> {
|
||||
copyWithin(target: number, start: number, end?: number): T[];
|
||||
}
|
||||
|
||||
interface IArguments {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): IterableIterator<any>;
|
||||
}
|
||||
|
||||
interface ArrayConstructor {
|
||||
/**
|
||||
* Creates an array from an array-like object.
|
||||
@ -500,14 +505,6 @@ interface GeneratorFunctionConstructor {
|
||||
}
|
||||
declare var GeneratorFunction: GeneratorFunctionConstructor;
|
||||
|
||||
interface Generator<T> extends IterableIterator<T> {
|
||||
next(value?: any): IteratorResult<T>;
|
||||
throw(exception: any): IteratorResult<T>;
|
||||
return(value: T): IteratorResult<T>;
|
||||
[Symbol.iterator](): Generator<T>;
|
||||
[Symbol.toStringTag]: string;
|
||||
}
|
||||
|
||||
interface Math {
|
||||
/**
|
||||
* Returns the number of leading zero bits in the 32-bit binary representation of a number.
|
||||
|
||||
7
src/lib/intl.d.ts
vendored
7
src/lib/intl.d.ts
vendored
@ -41,6 +41,11 @@ declare module Intl {
|
||||
currency?: string;
|
||||
currencyDisplay?: string;
|
||||
useGrouping?: boolean;
|
||||
minimumintegerDigits?: number;
|
||||
minimumFractionDigits?: number;
|
||||
maximumFractionDigits?: number;
|
||||
minimumSignificantDigits?: number;
|
||||
maximumSignificantDigits?: number;
|
||||
}
|
||||
|
||||
interface ResolvedNumberFormatOptions {
|
||||
@ -103,7 +108,7 @@ declare module Intl {
|
||||
}
|
||||
|
||||
interface DateTimeFormat {
|
||||
format(date: number): string;
|
||||
format(date?: Date | number): string;
|
||||
resolvedOptions(): ResolvedDateTimeFormatOptions;
|
||||
}
|
||||
var DateTimeFormat: {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/// <reference path="session.ts" />
|
||||
|
||||
module ts.server {
|
||||
namespace ts.server {
|
||||
|
||||
export interface SessionClientHost extends LanguageServiceHost {
|
||||
writeMessage(message: string): void;
|
||||
@ -171,6 +171,21 @@ module ts.server {
|
||||
documentation: [{ kind: "text", text: response.body.documentation }]
|
||||
};
|
||||
}
|
||||
|
||||
getProjectInfo(fileName: string, needFileNameList: boolean): protocol.ProjectInfo {
|
||||
var args: protocol.ProjectInfoRequestArgs = {
|
||||
file: fileName,
|
||||
needFileNameList: needFileNameList
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.ProjectInfoRequest>(CommandNames.ProjectInfo, args);
|
||||
var response = this.processResponse<protocol.ProjectInfoResponse>(request);
|
||||
|
||||
return {
|
||||
configFileName: response.body.configFileName,
|
||||
fileNameList: response.body.fileNameList
|
||||
};
|
||||
}
|
||||
|
||||
getCompletionsAtPosition(fileName: string, position: number): CompletionInfo {
|
||||
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
@ -204,7 +219,7 @@ module ts.server {
|
||||
|
||||
var request = this.processRequest<protocol.CompletionDetailsRequest>(CommandNames.CompletionDetails, args);
|
||||
var response = this.processResponse<protocol.CompletionDetailsResponse>(request);
|
||||
Debug.assert(response.body.length == 1, "Unexpected length of completion details response body.");
|
||||
Debug.assert(response.body.length === 1, "Unexpected length of completion details response body.");
|
||||
return response.body[0];
|
||||
}
|
||||
|
||||
@ -414,8 +429,8 @@ module ts.server {
|
||||
if (!this.lastRenameEntry ||
|
||||
this.lastRenameEntry.fileName !== fileName ||
|
||||
this.lastRenameEntry.position !== position ||
|
||||
this.lastRenameEntry.findInStrings != findInStrings ||
|
||||
this.lastRenameEntry.findInComments != findInComments) {
|
||||
this.lastRenameEntry.findInStrings !== findInStrings ||
|
||||
this.lastRenameEntry.findInComments !== findInComments) {
|
||||
this.getRenameInfo(fileName, position, findInStrings, findInComments);
|
||||
}
|
||||
|
||||
|
||||
@ -2,9 +2,8 @@
|
||||
/// <reference path="..\services\services.ts" />
|
||||
/// <reference path="protocol.d.ts" />
|
||||
/// <reference path="session.ts" />
|
||||
/// <reference path="node.d.ts" />
|
||||
|
||||
module ts.server {
|
||||
namespace ts.server {
|
||||
export interface Logger {
|
||||
close(): void;
|
||||
isVerbose(): boolean;
|
||||
@ -28,7 +27,7 @@ module ts.server {
|
||||
});
|
||||
}
|
||||
|
||||
class ScriptInfo {
|
||||
export class ScriptInfo {
|
||||
svc: ScriptVersionCache;
|
||||
children: ScriptInfo[] = []; // files referenced by this file
|
||||
defaultProject: Project; // project to use by default for file
|
||||
@ -36,7 +35,7 @@ module ts.server {
|
||||
formatCodeOptions = ts.clone(CompilerService.defaultFormatCodeOptions);
|
||||
|
||||
constructor(private host: ServerHost, public fileName: string, public content: string, public isOpen = false) {
|
||||
this.svc = ScriptVersionCache.fromString(content);
|
||||
this.svc = ScriptVersionCache.fromString(host, content);
|
||||
}
|
||||
|
||||
setFormatOptions(formatOptions: protocol.FormatOptions): void {
|
||||
@ -80,7 +79,7 @@ module ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
class LSHost implements ts.LanguageServiceHost {
|
||||
export class LSHost implements ts.LanguageServiceHost {
|
||||
ls: ts.LanguageService = null;
|
||||
compilationSettings: ts.CompilerOptions;
|
||||
filenameToScript: ts.Map<ScriptInfo> = {};
|
||||
@ -273,7 +272,7 @@ module ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
interface ProjectOptions {
|
||||
export interface ProjectOptions {
|
||||
// these fields can be present in the project file
|
||||
files?: string[];
|
||||
compilerOptions?: ts.CompilerOptions;
|
||||
@ -305,6 +304,11 @@ module ts.server {
|
||||
return this.projectService.openFile(filename, false);
|
||||
}
|
||||
|
||||
getFileNameList() {
|
||||
let sourceFiles = this.program.getSourceFiles();
|
||||
return sourceFiles.map(sourceFile => sourceFile.fileName);
|
||||
}
|
||||
|
||||
getSourceFile(info: ScriptInfo) {
|
||||
return this.filenameToSourceFile[info.fileName];
|
||||
}
|
||||
@ -371,7 +375,7 @@ module ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
interface ProjectOpenResult {
|
||||
export interface ProjectOpenResult {
|
||||
success?: boolean;
|
||||
errorMsg?: string;
|
||||
project?: Project;
|
||||
@ -387,11 +391,11 @@ module ts.server {
|
||||
return copiedList;
|
||||
}
|
||||
|
||||
interface ProjectServiceEventHandler {
|
||||
export interface ProjectServiceEventHandler {
|
||||
(eventName: string, project: Project, fileName: string): void;
|
||||
}
|
||||
|
||||
interface HostConfiguration {
|
||||
export interface HostConfiguration {
|
||||
formatCodeOptions: ts.FormatCodeOptions;
|
||||
hostInfo: string;
|
||||
}
|
||||
@ -624,7 +628,7 @@ module ts.server {
|
||||
for (var i = 0, len = this.openFilesReferenced.length; i < len; i++) {
|
||||
var f = this.openFilesReferenced[i];
|
||||
// if f was referenced by the removed project, remember it
|
||||
if (f.defaultProject == removedProject) {
|
||||
if (f.defaultProject === removedProject) {
|
||||
f.defaultProject = undefined;
|
||||
orphanFiles.push(f);
|
||||
}
|
||||
@ -651,7 +655,7 @@ module ts.server {
|
||||
for (var i = 0, len = this.inferredProjects.length; i < len; i++) {
|
||||
var inferredProject = this.inferredProjects[i];
|
||||
inferredProject.updateGraph();
|
||||
if (inferredProject != excludedProject) {
|
||||
if (inferredProject !== excludedProject) {
|
||||
if (inferredProject.getSourceFile(info)) {
|
||||
info.defaultProject = inferredProject;
|
||||
referencingProjects.push(inferredProject);
|
||||
@ -705,7 +709,7 @@ module ts.server {
|
||||
var rootFile = this.openFileRoots[i];
|
||||
var rootedProject = rootFile.defaultProject;
|
||||
var referencingProjects = this.findReferencingProjects(rootFile, rootedProject);
|
||||
if (referencingProjects.length == 0) {
|
||||
if (referencingProjects.length === 0) {
|
||||
rootFile.defaultProject = rootedProject;
|
||||
openFileRoots.push(rootFile);
|
||||
}
|
||||
@ -911,7 +915,7 @@ module ts.server {
|
||||
return rawConfig.error;
|
||||
}
|
||||
else {
|
||||
var parsedCommandLine = ts.parseConfigFile(rawConfig.config, ts.sys, dirPath);
|
||||
var parsedCommandLine = ts.parseConfigFile(rawConfig.config, this.host, dirPath);
|
||||
if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) {
|
||||
return { errorMsg: "tsconfig option errors" };
|
||||
}
|
||||
@ -948,7 +952,7 @@ module ts.server {
|
||||
|
||||
}
|
||||
|
||||
class CompilerService {
|
||||
export class CompilerService {
|
||||
host: LSHost;
|
||||
languageService: ts.LanguageService;
|
||||
classifier: ts.Classifier;
|
||||
@ -980,7 +984,7 @@ module ts.server {
|
||||
static defaultFormatCodeOptions: ts.FormatCodeOptions = {
|
||||
IndentSize: 4,
|
||||
TabSize: 4,
|
||||
NewLineCharacter: ts.sys.newLine,
|
||||
NewLineCharacter: ts.sys ? ts.sys.newLine : '\n',
|
||||
ConvertTabsToSpaces: true,
|
||||
InsertSpaceAfterCommaDelimiter: true,
|
||||
InsertSpaceAfterSemicolonInForStatements: true,
|
||||
@ -994,7 +998,7 @@ module ts.server {
|
||||
|
||||
}
|
||||
|
||||
interface LineCollection {
|
||||
export interface LineCollection {
|
||||
charCount(): number;
|
||||
lineCount(): number;
|
||||
isLeaf(): boolean;
|
||||
@ -1008,7 +1012,7 @@ module ts.server {
|
||||
leaf?: LineLeaf;
|
||||
}
|
||||
|
||||
enum CharRangeSection {
|
||||
export enum CharRangeSection {
|
||||
PreStart,
|
||||
Start,
|
||||
Entire,
|
||||
@ -1017,7 +1021,7 @@ module ts.server {
|
||||
PostEnd
|
||||
}
|
||||
|
||||
interface ILineIndexWalker {
|
||||
export interface ILineIndexWalker {
|
||||
goSubtree: boolean;
|
||||
done: boolean;
|
||||
leaf(relativeStart: number, relativeLength: number, lineCollection: LineLeaf): void;
|
||||
@ -1077,7 +1081,7 @@ module ts.server {
|
||||
|
||||
for (var k = this.endBranch.length - 1; k >= 0; k--) {
|
||||
(<LineNode>this.endBranch[k]).updateCounts();
|
||||
if (this.endBranch[k].charCount() == 0) {
|
||||
if (this.endBranch[k].charCount() === 0) {
|
||||
lastZeroCount = this.endBranch[k];
|
||||
if (k > 0) {
|
||||
branchParent = <LineNode>this.endBranch[k - 1];
|
||||
@ -1142,7 +1146,7 @@ module ts.server {
|
||||
post(relativeStart: number, relativeLength: number, lineCollection: LineCollection, parent: LineCollection, nodeType: CharRangeSection): LineCollection {
|
||||
// have visited the path for start of range, now looking for end
|
||||
// if range is on single line, we will never make this state transition
|
||||
if (lineCollection == this.lineCollectionAtBranch) {
|
||||
if (lineCollection === this.lineCollectionAtBranch) {
|
||||
this.state = CharRangeSection.End;
|
||||
}
|
||||
// always pop stack because post only called when child has been visited
|
||||
@ -1154,7 +1158,7 @@ module ts.server {
|
||||
// currentNode corresponds to parent, but in the new tree
|
||||
var currentNode = this.stack[this.stack.length - 1];
|
||||
|
||||
if ((this.state == CharRangeSection.Entire) && (nodeType == CharRangeSection.Start)) {
|
||||
if ((this.state === CharRangeSection.Entire) && (nodeType === CharRangeSection.Start)) {
|
||||
// if range is on single line, we will never make this state transition
|
||||
this.state = CharRangeSection.Start;
|
||||
this.branchNode = currentNode;
|
||||
@ -1171,12 +1175,12 @@ module ts.server {
|
||||
switch (nodeType) {
|
||||
case CharRangeSection.PreStart:
|
||||
this.goSubtree = false;
|
||||
if (this.state != CharRangeSection.End) {
|
||||
if (this.state !== CharRangeSection.End) {
|
||||
currentNode.add(lineCollection);
|
||||
}
|
||||
break;
|
||||
case CharRangeSection.Start:
|
||||
if (this.state == CharRangeSection.End) {
|
||||
if (this.state === CharRangeSection.End) {
|
||||
this.goSubtree = false;
|
||||
}
|
||||
else {
|
||||
@ -1186,7 +1190,7 @@ module ts.server {
|
||||
}
|
||||
break;
|
||||
case CharRangeSection.Entire:
|
||||
if (this.state != CharRangeSection.End) {
|
||||
if (this.state !== CharRangeSection.End) {
|
||||
child = fresh(lineCollection);
|
||||
currentNode.add(child);
|
||||
this.startPath[this.startPath.length] = child;
|
||||
@ -1203,7 +1207,7 @@ module ts.server {
|
||||
this.goSubtree = false;
|
||||
break;
|
||||
case CharRangeSection.End:
|
||||
if (this.state != CharRangeSection.End) {
|
||||
if (this.state !== CharRangeSection.End) {
|
||||
this.goSubtree = false;
|
||||
}
|
||||
else {
|
||||
@ -1216,7 +1220,7 @@ module ts.server {
|
||||
break;
|
||||
case CharRangeSection.PostEnd:
|
||||
this.goSubtree = false;
|
||||
if (this.state != CharRangeSection.Start) {
|
||||
if (this.state !== CharRangeSection.Start) {
|
||||
currentNode.add(lineCollection);
|
||||
}
|
||||
break;
|
||||
@ -1228,10 +1232,10 @@ module ts.server {
|
||||
}
|
||||
// just gather text from the leaves
|
||||
leaf(relativeStart: number, relativeLength: number, ll: LineLeaf) {
|
||||
if (this.state == CharRangeSection.Start) {
|
||||
if (this.state === CharRangeSection.Start) {
|
||||
this.initialText = ll.text.substring(0, relativeStart);
|
||||
}
|
||||
else if (this.state == CharRangeSection.Entire) {
|
||||
else if (this.state === CharRangeSection.Entire) {
|
||||
this.initialText = ll.text.substring(0, relativeStart);
|
||||
this.trailingText = ll.text.substring(relativeStart + relativeLength);
|
||||
}
|
||||
@ -1243,7 +1247,7 @@ module ts.server {
|
||||
}
|
||||
|
||||
// text change information
|
||||
class TextChange {
|
||||
export class TextChange {
|
||||
constructor(public pos: number, public deleteLen: number, public insertedText?: string) {
|
||||
}
|
||||
|
||||
@ -1258,6 +1262,7 @@ module ts.server {
|
||||
versions: LineIndexSnapshot[] = [];
|
||||
minVersion = 0; // no versions earlier than min version will maintain change history
|
||||
private currentVersion = 0;
|
||||
private host: ServerHost;
|
||||
|
||||
static changeNumberThreshold = 8;
|
||||
static changeLengthThreshold = 256;
|
||||
@ -1285,7 +1290,7 @@ module ts.server {
|
||||
}
|
||||
|
||||
reloadFromFile(filename: string, cb?: () => any) {
|
||||
var content = ts.sys.readFile(filename);
|
||||
var content = this.host.readFile(filename);
|
||||
this.reload(content);
|
||||
if (cb)
|
||||
cb();
|
||||
@ -1355,10 +1360,11 @@ module ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
static fromString(script: string) {
|
||||
static fromString(host: ServerHost, script: string) {
|
||||
var svc = new ScriptVersionCache();
|
||||
var snap = new LineIndexSnapshot(0, svc);
|
||||
svc.versions[svc.currentVersion] = snap;
|
||||
svc.host = host;
|
||||
snap.index = new LineIndex();
|
||||
var lm = LineIndex.linesFromText(script);
|
||||
snap.index.load(lm.lines);
|
||||
@ -1366,7 +1372,7 @@ module ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
class LineIndexSnapshot implements ts.IScriptSnapshot {
|
||||
export class LineIndexSnapshot implements ts.IScriptSnapshot {
|
||||
index: LineIndex;
|
||||
changesSincePreviousVersion: TextChange[] = [];
|
||||
|
||||
@ -1494,8 +1500,8 @@ module ts.server {
|
||||
function editFlat(source: string, s: number, dl: number, nt = "") {
|
||||
return source.substring(0, s) + nt + source.substring(s + dl, source.length);
|
||||
}
|
||||
if (this.root.charCount() == 0) {
|
||||
// TODO: assert deleteLength == 0
|
||||
if (this.root.charCount() === 0) {
|
||||
// TODO: assert deleteLength === 0
|
||||
if (newText) {
|
||||
this.load(LineIndex.linesFromText(newText).lines);
|
||||
return this;
|
||||
@ -1523,7 +1529,7 @@ module ts.server {
|
||||
// check whether last characters deleted are line break
|
||||
var e = pos + deleteLength;
|
||||
var lineInfo = this.charOffsetToLineNumberAndPos(e);
|
||||
if ((lineInfo && (lineInfo.offset == 0))) {
|
||||
if ((lineInfo && (lineInfo.offset === 0))) {
|
||||
// move range end just past line that will merge with previous line
|
||||
deleteLength += lineInfo.text.length;
|
||||
// store text by appending to end of insertedText
|
||||
@ -1569,7 +1575,7 @@ module ts.server {
|
||||
interiorNodes[i].totalChars = charCount;
|
||||
interiorNodes[i].totalLines = lineCount;
|
||||
}
|
||||
if (interiorNodes.length == 1) {
|
||||
if (interiorNodes.length === 1) {
|
||||
return interiorNodes[0];
|
||||
}
|
||||
else {
|
||||
@ -1580,7 +1586,7 @@ module ts.server {
|
||||
static linesFromText(text: string) {
|
||||
var lineStarts = ts.computeLineStarts(text);
|
||||
|
||||
if (lineStarts.length == 0) {
|
||||
if (lineStarts.length === 0) {
|
||||
return { lines: <string[]>[], lineMap: lineStarts };
|
||||
}
|
||||
var lines = <string[]>new Array(lineStarts.length);
|
||||
@ -1600,7 +1606,7 @@ module ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
class LineNode implements LineCollection {
|
||||
export class LineNode implements LineCollection {
|
||||
totalChars = 0;
|
||||
totalLines = 0;
|
||||
children: LineCollection[] = [];
|
||||
@ -1816,7 +1822,7 @@ module ts.server {
|
||||
findChildIndex(child: LineCollection) {
|
||||
var childIndex = 0;
|
||||
var clen = this.children.length;
|
||||
while ((this.children[childIndex] != child) && (childIndex < clen)) childIndex++;
|
||||
while ((this.children[childIndex] !== child) && (childIndex < clen)) childIndex++;
|
||||
return childIndex;
|
||||
}
|
||||
|
||||
@ -1825,7 +1831,7 @@ module ts.server {
|
||||
var clen = this.children.length;
|
||||
var nodeCount = nodes.length;
|
||||
// if child is last and there is more room and only one node to place, place it
|
||||
if ((clen < lineCollectionCapacity) && (childIndex == (clen - 1)) && (nodeCount == 1)) {
|
||||
if ((clen < lineCollectionCapacity) && (childIndex === (clen - 1)) && (nodeCount === 1)) {
|
||||
this.add(nodes[0]);
|
||||
this.updateCounts();
|
||||
return [];
|
||||
@ -1849,13 +1855,13 @@ module ts.server {
|
||||
var splitNode = <LineNode>splitNodes[0];
|
||||
while (nodeIndex < nodeCount) {
|
||||
splitNode.add(nodes[nodeIndex++]);
|
||||
if (splitNode.children.length == lineCollectionCapacity) {
|
||||
if (splitNode.children.length === lineCollectionCapacity) {
|
||||
splitNodeIndex++;
|
||||
splitNode = <LineNode>splitNodes[splitNodeIndex];
|
||||
}
|
||||
}
|
||||
for (i = splitNodes.length - 1; i >= 0; i--) {
|
||||
if (splitNodes[i].children.length == 0) {
|
||||
if (splitNodes[i].children.length === 0) {
|
||||
splitNodes.length--;
|
||||
}
|
||||
}
|
||||
@ -1886,7 +1892,7 @@ module ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
class LineLeaf implements LineCollection {
|
||||
export class LineLeaf implements LineCollection {
|
||||
udata: any;
|
||||
|
||||
constructor(public text: string) {
|
||||
|
||||
4
src/server/node.d.ts
vendored
4
src/server/node.d.ts
vendored
@ -584,9 +584,9 @@ declare module NodeJS {
|
||||
export interface Response extends Message {
|
||||
request_seq: number;
|
||||
success: boolean;
|
||||
/** Contains error message if success == false. */
|
||||
/** Contains error message if success === false. */
|
||||
message?: string;
|
||||
/** Contains message body if success == true. */
|
||||
/** Contains message body if success === true. */
|
||||
body?: any;
|
||||
}
|
||||
|
||||
|
||||
45
src/server/protocol.d.ts
vendored
45
src/server/protocol.d.ts
vendored
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Declaration module describing the TypeScript Server protocol
|
||||
*/
|
||||
declare module ts.server.protocol {
|
||||
declare namespace ts.server.protocol {
|
||||
/**
|
||||
* A TypeScript Server message
|
||||
*/
|
||||
@ -67,12 +67,12 @@ declare module ts.server.protocol {
|
||||
command: string;
|
||||
|
||||
/**
|
||||
* Contains error message if success == false.
|
||||
* Contains error message if success === false.
|
||||
*/
|
||||
message?: string;
|
||||
|
||||
/**
|
||||
* Contains message body if success == true.
|
||||
* Contains message body if success === true.
|
||||
*/
|
||||
body?: any;
|
||||
}
|
||||
@ -87,6 +87,45 @@ declare module ts.server.protocol {
|
||||
file: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Arguments for ProjectInfoRequest request.
|
||||
*/
|
||||
export interface ProjectInfoRequestArgs extends FileRequestArgs {
|
||||
/**
|
||||
* Indicate if the file name list of the project is needed
|
||||
*/
|
||||
needFileNameList: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* A request to get the project information of the current file
|
||||
*/
|
||||
export interface ProjectInfoRequest extends Request {
|
||||
arguments: ProjectInfoRequestArgs
|
||||
}
|
||||
|
||||
/**
|
||||
* Response message body for "projectInfo" request
|
||||
*/
|
||||
export interface ProjectInfo {
|
||||
/**
|
||||
* For configured project, this is the normalized path of the 'tsconfig.json' file
|
||||
* For inferred project, this is undefined
|
||||
*/
|
||||
configFileName: string;
|
||||
/**
|
||||
* The list of normalized file name in the project, including 'lib.d.ts'
|
||||
*/
|
||||
fileNameList?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Response message for "projectInfo" request
|
||||
*/
|
||||
export interface ProjectInfoResponse extends Response {
|
||||
body?: ProjectInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request whose sole parameter is a file name.
|
||||
*/
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/// <reference path="node.d.ts" />
|
||||
/// <reference path="session.ts" />
|
||||
|
||||
module ts.server {
|
||||
namespace ts.server {
|
||||
var nodeproto: typeof NodeJS._debugger = require('_debugger');
|
||||
var readline: NodeJS.ReadLine = require('readline');
|
||||
var path: NodeJS.Path = require('path');
|
||||
@ -11,7 +11,7 @@ module ts.server {
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
terminal: false,
|
||||
});
|
||||
});
|
||||
|
||||
class Logger implements ts.server.Logger {
|
||||
fd = -1;
|
||||
@ -123,7 +123,7 @@ module ts.server {
|
||||
if (err) {
|
||||
watchedFile.callback(watchedFile.fileName);
|
||||
}
|
||||
else if (watchedFile.mtime.getTime() != stats.mtime.getTime()) {
|
||||
else if (watchedFile.mtime.getTime() !== stats.mtime.getTime()) {
|
||||
watchedFile.mtime = WatchedFileSet.getModifiedTime(watchedFile.fileName);
|
||||
watchedFile.callback(watchedFile.fileName);
|
||||
}
|
||||
@ -138,7 +138,7 @@ module ts.server {
|
||||
var count = 0;
|
||||
var nextToCheck = this.nextFileToCheck;
|
||||
var firstCheck = -1;
|
||||
while ((count < this.chunkSize) && (nextToCheck != firstCheck)) {
|
||||
while ((count < this.chunkSize) && (nextToCheck !== firstCheck)) {
|
||||
this.poll(nextToCheck);
|
||||
if (firstCheck < 0) {
|
||||
firstCheck = nextToCheck;
|
||||
@ -170,11 +170,11 @@ module ts.server {
|
||||
removeFile(file: WatchedFile) {
|
||||
this.watchedFiles = WatchedFileSet.copyListRemovingItem(file, this.watchedFiles);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class IOSession extends Session {
|
||||
constructor(host: ServerHost, logger: ts.server.Logger) {
|
||||
super(host, logger);
|
||||
super(host, Buffer.byteLength, process.hrtime, logger);
|
||||
}
|
||||
|
||||
exit() {
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
/// <reference path="..\compiler\commandLineParser.ts" />
|
||||
/// <reference path="..\services\services.ts" />
|
||||
/// <reference path="node.d.ts" />
|
||||
/// <reference path="protocol.d.ts" />
|
||||
/// <reference path="editorServices.ts" />
|
||||
|
||||
module ts.server {
|
||||
namespace ts.server {
|
||||
var spaceCache:string[] = [];
|
||||
|
||||
interface StackTraceError extends Error {
|
||||
@ -31,7 +30,7 @@ module ts.server {
|
||||
if (a < b) {
|
||||
return -1;
|
||||
}
|
||||
else if (a == b) {
|
||||
else if (a === b) {
|
||||
return 0;
|
||||
}
|
||||
else return 1;
|
||||
@ -43,7 +42,7 @@ module ts.server {
|
||||
}
|
||||
else if (a.file == b.file) {
|
||||
var n = compareNumber(a.start.line, b.start.line);
|
||||
if (n == 0) {
|
||||
if (n === 0) {
|
||||
return compareNumber(a.start.offset, b.start.offset);
|
||||
}
|
||||
else return n;
|
||||
@ -61,7 +60,7 @@ module ts.server {
|
||||
};
|
||||
}
|
||||
|
||||
interface PendingErrorCheck {
|
||||
export interface PendingErrorCheck {
|
||||
fileName: string;
|
||||
project: Project;
|
||||
}
|
||||
@ -76,29 +75,30 @@ module ts.server {
|
||||
}
|
||||
|
||||
export module CommandNames {
|
||||
export var Brace = "brace";
|
||||
export var Change = "change";
|
||||
export var Close = "close";
|
||||
export var Completions = "completions";
|
||||
export var CompletionDetails = "completionEntryDetails";
|
||||
export var Configure = "configure";
|
||||
export var Definition = "definition";
|
||||
export var Exit = "exit";
|
||||
export var Format = "format";
|
||||
export var Formatonkey = "formatonkey";
|
||||
export var Geterr = "geterr";
|
||||
export var NavBar = "navbar";
|
||||
export var Navto = "navto";
|
||||
export var Occurrences = "occurrences";
|
||||
export var Open = "open";
|
||||
export var Quickinfo = "quickinfo";
|
||||
export var References = "references";
|
||||
export var Reload = "reload";
|
||||
export var Rename = "rename";
|
||||
export var Saveto = "saveto";
|
||||
export var SignatureHelp = "signatureHelp";
|
||||
export var TypeDefinition = "typeDefinition";
|
||||
export var Unknown = "unknown";
|
||||
export const Brace = "brace";
|
||||
export const Change = "change";
|
||||
export const Close = "close";
|
||||
export const Completions = "completions";
|
||||
export const CompletionDetails = "completionEntryDetails";
|
||||
export const Configure = "configure";
|
||||
export const Definition = "definition";
|
||||
export const Exit = "exit";
|
||||
export const Format = "format";
|
||||
export const Formatonkey = "formatonkey";
|
||||
export const Geterr = "geterr";
|
||||
export const NavBar = "navbar";
|
||||
export const Navto = "navto";
|
||||
export const Occurrences = "occurrences";
|
||||
export const Open = "open";
|
||||
export const Quickinfo = "quickinfo";
|
||||
export const References = "references";
|
||||
export const Reload = "reload";
|
||||
export const Rename = "rename";
|
||||
export const Saveto = "saveto";
|
||||
export const SignatureHelp = "signatureHelp";
|
||||
export const TypeDefinition = "typeDefinition";
|
||||
export const ProjectInfo = "projectInfo";
|
||||
export const Unknown = "unknown";
|
||||
}
|
||||
|
||||
module Errors {
|
||||
@ -113,11 +113,16 @@ module ts.server {
|
||||
pendingOperation = false;
|
||||
fileHash: ts.Map<number> = {};
|
||||
nextFileId = 1;
|
||||
errorTimer: NodeJS.Timer;
|
||||
errorTimer: any; /*NodeJS.Timer | number*/
|
||||
immediateId: any;
|
||||
changeSeq = 0;
|
||||
|
||||
constructor(private host: ServerHost, private logger: Logger) {
|
||||
constructor(
|
||||
private host: ServerHost,
|
||||
private byteLength: (buf: string, encoding?: string) => number,
|
||||
private hrtime: (start?: number[]) => number[],
|
||||
private logger: Logger
|
||||
) {
|
||||
this.projectService =
|
||||
new ProjectService(host, logger, (eventName,project,fileName) => {
|
||||
this.handleEvent(eventName, project, fileName);
|
||||
@ -128,7 +133,7 @@ module ts.server {
|
||||
if (eventName == "context") {
|
||||
this.projectService.log("got context event, updating diagnostics for" + fileName, "Info");
|
||||
this.updateErrorCheck([{ fileName, project }], this.changeSeq,
|
||||
(n) => n == this.changeSeq, 100);
|
||||
(n) => n === this.changeSeq, 100);
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,17 +153,17 @@ module ts.server {
|
||||
this.host.write(line + this.host.newLine);
|
||||
}
|
||||
|
||||
send(msg: NodeJS._debugger.Message) {
|
||||
send(msg: protocol.Message) {
|
||||
var json = JSON.stringify(msg);
|
||||
if (this.logger.isVerbose()) {
|
||||
this.logger.info(msg.type + ": " + json);
|
||||
}
|
||||
this.sendLineToClient('Content-Length: ' + (1 + Buffer.byteLength(json, 'utf8')) +
|
||||
this.sendLineToClient('Content-Length: ' + (1 + this.byteLength(json, 'utf8')) +
|
||||
'\r\n\r\n' + json);
|
||||
}
|
||||
|
||||
event(info: any, eventName: string) {
|
||||
var ev: NodeJS._debugger.Event = {
|
||||
var ev: protocol.Event = {
|
||||
seq: 0,
|
||||
type: "event",
|
||||
event: eventName,
|
||||
@ -338,6 +343,21 @@ module ts.server {
|
||||
});
|
||||
}
|
||||
|
||||
getProjectInfo(fileName: string, needFileNameList: boolean): protocol.ProjectInfo {
|
||||
fileName = ts.normalizePath(fileName)
|
||||
let project = this.projectService.getProjectForFile(fileName)
|
||||
|
||||
let projectInfo: protocol.ProjectInfo = {
|
||||
configFileName: project.projectFilename
|
||||
}
|
||||
|
||||
if (needFileNameList) {
|
||||
projectInfo.fileNameList = project.getFileNameList();
|
||||
}
|
||||
|
||||
return projectInfo;
|
||||
}
|
||||
|
||||
getRenameLocations(line: number, offset: number, fileName: string,findInComments: boolean, findInStrings: boolean): protocol.RenameResponseBody {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
@ -530,7 +550,7 @@ module ts.server {
|
||||
// getFormattingEditsAfterKeytroke either empty or pertaining
|
||||
// only to the previous line. If all this is true, then
|
||||
// add edits necessary to properly indent the current line.
|
||||
if ((key == "\n") && ((!edits) || (edits.length == 0) || allEditsBeforePos(edits, position))) {
|
||||
if ((key == "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) {
|
||||
var scriptInfo = compilerService.host.getScriptInfo(file);
|
||||
if (scriptInfo) {
|
||||
var lineInfo = scriptInfo.getLineInfo(line);
|
||||
@ -606,7 +626,7 @@ module ts.server {
|
||||
}
|
||||
|
||||
return completions.entries.reduce((result: protocol.CompletionEntry[], entry: ts.CompletionEntry) => {
|
||||
if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) == 0)) {
|
||||
if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) {
|
||||
result.push(entry);
|
||||
}
|
||||
return result;
|
||||
@ -673,7 +693,7 @@ module ts.server {
|
||||
}, []);
|
||||
|
||||
if (checkList.length > 0) {
|
||||
this.updateErrorCheck(checkList, this.changeSeq,(n) => n == this.changeSeq, delay)
|
||||
this.updateErrorCheck(checkList, this.changeSeq,(n) => n === this.changeSeq, delay)
|
||||
}
|
||||
}
|
||||
|
||||
@ -688,7 +708,7 @@ module ts.server {
|
||||
compilerService.host.editScript(file, start, end, insertString);
|
||||
this.changeSeq++;
|
||||
}
|
||||
this.updateProjectStructure(this.changeSeq, (n) => n == this.changeSeq);
|
||||
this.updateProjectStructure(this.changeSeq, (n) => n === this.changeSeq);
|
||||
}
|
||||
}
|
||||
|
||||
@ -822,7 +842,7 @@ module ts.server {
|
||||
onMessage(message: string) {
|
||||
if (this.logger.isVerbose()) {
|
||||
this.logger.info("request: " + message);
|
||||
var start = process.hrtime();
|
||||
var start = this.hrtime();
|
||||
}
|
||||
try {
|
||||
var request = <protocol.Request>JSON.parse(message);
|
||||
@ -951,6 +971,11 @@ module ts.server {
|
||||
response = this.getOccurrences(line, offset, fileName);
|
||||
break;
|
||||
}
|
||||
case CommandNames.ProjectInfo: {
|
||||
var { file, needFileNameList } = <protocol.ProjectInfoRequestArgs>request.arguments;
|
||||
response = this.getProjectInfo(file, needFileNameList);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
this.projectService.log("Unrecognized JSON command: " + message);
|
||||
this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command);
|
||||
@ -959,7 +984,7 @@ module ts.server {
|
||||
}
|
||||
|
||||
if (this.logger.isVerbose()) {
|
||||
var elapsed = process.hrtime(start);
|
||||
var elapsed = this.hrtime(start);
|
||||
var seconds = elapsed[0]
|
||||
var nanoseconds = elapsed[1];
|
||||
var elapsedMs = ((1e9 * seconds) + nanoseconds)/1000000.0;
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
/// <reference path='services.ts' />
|
||||
|
||||
/* @internal */
|
||||
module ts.BreakpointResolver {
|
||||
namespace ts.BreakpointResolver {
|
||||
/**
|
||||
* Get the breakpoint span in given sourceFile
|
||||
*/
|
||||
@ -75,7 +75,7 @@ module ts.BreakpointResolver {
|
||||
return textSpan(node);
|
||||
}
|
||||
|
||||
if (node.parent.kind == SyntaxKind.ArrowFunction && (<FunctionLikeDeclaration>node.parent).body == node) {
|
||||
if (node.parent.kind === SyntaxKind.ArrowFunction && (<FunctionLikeDeclaration>node.parent).body === node) {
|
||||
// If this is body of arrow function, it is allowed to have the breakpoint
|
||||
return textSpan(node);
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
/* @internal */
|
||||
module ts.formatting {
|
||||
namespace ts.formatting {
|
||||
|
||||
export interface TextRangeWithKind extends TextRange {
|
||||
kind: SyntaxKind;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/// <reference path="references.ts"/>
|
||||
|
||||
/* @internal */
|
||||
module ts.formatting {
|
||||
namespace ts.formatting {
|
||||
export class FormattingContext {
|
||||
public currentTokenSpan: TextRangeWithKind;
|
||||
public nextTokenSpan: TextRangeWithKind;
|
||||
@ -59,7 +59,7 @@ module ts.formatting {
|
||||
if (this.tokensAreOnSameLine === undefined) {
|
||||
let startLine = this.sourceFile.getLineAndCharacterOfPosition(this.currentTokenSpan.pos).line;
|
||||
let endLine = this.sourceFile.getLineAndCharacterOfPosition(this.nextTokenSpan.pos).line;
|
||||
this.tokensAreOnSameLine = (startLine == endLine);
|
||||
this.tokensAreOnSameLine = (startLine === endLine);
|
||||
}
|
||||
|
||||
return this.tokensAreOnSameLine;
|
||||
@ -84,7 +84,7 @@ module ts.formatting {
|
||||
private NodeIsOnOneLine(node: Node): boolean {
|
||||
let startLine = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile)).line;
|
||||
let endLine = this.sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line;
|
||||
return startLine == endLine;
|
||||
return startLine === endLine;
|
||||
}
|
||||
|
||||
private BlockIsOnOneLine(node: Node): boolean {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/// <reference path="references.ts"/>
|
||||
|
||||
/* @internal */
|
||||
module ts.formatting {
|
||||
namespace ts.formatting {
|
||||
export const enum FormattingRequestKind {
|
||||
FormatDocument,
|
||||
FormatSelection,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/// <reference path="..\..\compiler\scanner.ts"/>
|
||||
|
||||
/* @internal */
|
||||
module ts.formatting {
|
||||
namespace ts.formatting {
|
||||
let scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ false);
|
||||
|
||||
export interface FormattingScanner {
|
||||
@ -224,7 +224,7 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
function isOnToken(): boolean {
|
||||
let current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken();
|
||||
let current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken();
|
||||
let startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos();
|
||||
return startPos < endPos && current !== SyntaxKind.EndOfFileToken && !isTrivia(current);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
/* @internal */
|
||||
module ts.formatting {
|
||||
namespace ts.formatting {
|
||||
export class Rule {
|
||||
constructor(
|
||||
public Descriptor: RuleDescriptor,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
/* @internal */
|
||||
module ts.formatting {
|
||||
namespace ts.formatting {
|
||||
export const enum RuleAction {
|
||||
Ignore = 0x00000001,
|
||||
Space = 0x00000002,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
/* @internal */
|
||||
module ts.formatting {
|
||||
namespace ts.formatting {
|
||||
export class RuleDescriptor {
|
||||
constructor(public LeftTokenRange: Shared.TokenRange, public RightTokenRange: Shared.TokenRange) {
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
/* @internal */
|
||||
module ts.formatting {
|
||||
namespace ts.formatting {
|
||||
export const enum RuleFlags {
|
||||
None,
|
||||
CanDeleteNewLines
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
/* @internal */
|
||||
module ts.formatting {
|
||||
namespace ts.formatting {
|
||||
export class RuleOperation {
|
||||
public Context: RuleOperationContext;
|
||||
public Action: RuleAction;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
/* @internal */
|
||||
module ts.formatting {
|
||||
namespace ts.formatting {
|
||||
|
||||
export class RuleOperationContext {
|
||||
private customContextChecks: { (context: FormattingContext): boolean; }[];
|
||||
@ -14,7 +14,7 @@ module ts.formatting {
|
||||
|
||||
|
||||
public IsAny(): boolean {
|
||||
return this == RuleOperationContext.Any;
|
||||
return this === RuleOperationContext.Any;
|
||||
}
|
||||
|
||||
public InContext(context: FormattingContext): boolean {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
/* @internal */
|
||||
module ts.formatting {
|
||||
namespace ts.formatting {
|
||||
export class Rules {
|
||||
public getRuleName(rule: Rule) {
|
||||
let o: ts.Map<any> = <any>this;
|
||||
@ -199,6 +199,12 @@ module ts.formatting {
|
||||
public NoSpaceAfterAt: Rule;
|
||||
public SpaceAfterDecorator: Rule;
|
||||
|
||||
// Generator: function*
|
||||
public NoSpaceBetweenFunctionKeywordAndStar: Rule;
|
||||
public SpaceAfterStarInGeneratorDeclaration: Rule;
|
||||
public NoSpaceBetweenYieldKeywordAndStar: Rule;
|
||||
public SpaceBetweenYieldOrYieldStarAndOperand: Rule;
|
||||
|
||||
constructor() {
|
||||
///
|
||||
/// Common Rules
|
||||
@ -340,6 +346,11 @@ module ts.formatting {
|
||||
this.NoSpaceAfterAt = new Rule(RuleDescriptor.create3(SyntaxKind.AtToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.SpaceAfterDecorator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.ExportKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.ClassKeyword, SyntaxKind.StaticKeyword, SyntaxKind.PublicKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.GetKeyword, SyntaxKind.SetKeyword, SyntaxKind.OpenBracketToken, SyntaxKind.AsteriskToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), RuleAction.Space));
|
||||
|
||||
this.NoSpaceBetweenFunctionKeywordAndStar = new Rule(RuleDescriptor.create1(SyntaxKind.FunctionKeyword, SyntaxKind.AsteriskToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), RuleAction.Delete));
|
||||
this.SpaceAfterStarInGeneratorDeclaration = new Rule(RuleDescriptor.create3(SyntaxKind.AsteriskToken, Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.OpenParenToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), RuleAction.Space));
|
||||
this.NoSpaceBetweenYieldKeywordAndStar = new Rule(RuleDescriptor.create1(SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), RuleAction.Delete));
|
||||
this.SpaceBetweenYieldOrYieldStarAndOperand = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), RuleAction.Space));
|
||||
|
||||
// These rules are higher in priority than user-configurable rules.
|
||||
this.HighPriorityCommonRules =
|
||||
[
|
||||
@ -357,7 +368,9 @@ module ts.formatting {
|
||||
this.NoSpaceAfterCloseBrace,
|
||||
this.SpaceAfterOpenBrace, this.SpaceBeforeCloseBrace, this.NewLineBeforeCloseBraceInBlockContext,
|
||||
this.SpaceAfterCloseBrace, this.SpaceBetweenCloseBraceAndElse, this.SpaceBetweenCloseBraceAndWhile, this.NoSpaceBetweenEmptyBraceBrackets,
|
||||
this.NoSpaceBetweenFunctionKeywordAndStar, this.SpaceAfterStarInGeneratorDeclaration,
|
||||
this.SpaceAfterFunctionInFuncDecl, this.NewLineAfterOpenBraceInBlockContext, this.SpaceAfterGetSetInMember,
|
||||
this.NoSpaceBetweenYieldKeywordAndStar, this.SpaceBetweenYieldOrYieldStarAndOperand,
|
||||
this.NoSpaceBetweenReturnAndSemicolon,
|
||||
this.SpaceAfterCertainKeywords,
|
||||
this.SpaceAfterLetConstInVariableDeclaration,
|
||||
@ -457,8 +470,9 @@ module ts.formatting {
|
||||
switch (context.contextNode.kind) {
|
||||
case SyntaxKind.BinaryExpression:
|
||||
case SyntaxKind.ConditionalExpression:
|
||||
case SyntaxKind.TypePredicate:
|
||||
return true;
|
||||
|
||||
|
||||
// equals in binding elements: function foo([[x, y] = [1, 2]])
|
||||
case SyntaxKind.BindingElement:
|
||||
// equals in type X = ...
|
||||
@ -574,6 +588,10 @@ module ts.formatting {
|
||||
return false;
|
||||
}
|
||||
|
||||
static IsFunctionDeclarationOrFunctionExpressionContext(context: FormattingContext): boolean {
|
||||
return context.contextNode.kind === SyntaxKind.FunctionDeclaration || context.contextNode.kind === SyntaxKind.FunctionExpression;
|
||||
}
|
||||
|
||||
static IsTypeScriptDeclWithBlockContext(context: FormattingContext): boolean {
|
||||
return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode);
|
||||
}
|
||||
@ -674,7 +692,7 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
static IsNotFormatOnEnter(context: FormattingContext): boolean {
|
||||
return context.formattingRequestKind != FormattingRequestKind.FormatOnEnter;
|
||||
return context.formattingRequestKind !== FormattingRequestKind.FormatOnEnter;
|
||||
}
|
||||
|
||||
static IsModuleDeclContext(context: FormattingContext): boolean {
|
||||
@ -717,5 +735,9 @@ module ts.formatting {
|
||||
static IsVoidOpContext(context: FormattingContext): boolean {
|
||||
return context.currentTokenSpan.kind === SyntaxKind.VoidKeyword && context.currentTokenParent.kind === SyntaxKind.VoidExpression;
|
||||
}
|
||||
|
||||
static IsYieldOrYieldStarWithOperand(context: FormattingContext): boolean {
|
||||
return context.contextNode.kind === SyntaxKind.YieldExpression && (<YieldExpression>context.contextNode).expression !== undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
/* @internal */
|
||||
module ts.formatting {
|
||||
namespace ts.formatting {
|
||||
export class RulesMap {
|
||||
public map: RulesBucket[];
|
||||
public mapRowLength: number;
|
||||
@ -41,15 +41,15 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
private FillRule(rule: Rule, rulesBucketConstructionStateList: RulesBucketConstructionState[]): void {
|
||||
let specificRule = rule.Descriptor.LeftTokenRange != Shared.TokenRange.Any &&
|
||||
rule.Descriptor.RightTokenRange != Shared.TokenRange.Any;
|
||||
let specificRule = rule.Descriptor.LeftTokenRange !== Shared.TokenRange.Any &&
|
||||
rule.Descriptor.RightTokenRange !== Shared.TokenRange.Any;
|
||||
|
||||
rule.Descriptor.LeftTokenRange.GetTokens().forEach((left) => {
|
||||
rule.Descriptor.RightTokenRange.GetTokens().forEach((right) => {
|
||||
let rulesBucketIndex = this.GetRuleBucketIndex(left, right);
|
||||
|
||||
let rulesBucket = this.map[rulesBucketIndex];
|
||||
if (rulesBucket == undefined) {
|
||||
if (rulesBucket === undefined) {
|
||||
rulesBucket = this.map[rulesBucketIndex] = new RulesBucket();
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ module ts.formatting {
|
||||
public IncreaseInsertionIndex(maskPosition: RulesPosition): void {
|
||||
let value = (this.rulesInsertionIndexBitmap >> maskPosition) & Mask;
|
||||
value++;
|
||||
Debug.assert((value & Mask) == value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules.");
|
||||
Debug.assert((value & Mask) === value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules.");
|
||||
|
||||
let temp = this.rulesInsertionIndexBitmap & ~(Mask << maskPosition);
|
||||
temp |= value << maskPosition;
|
||||
@ -147,7 +147,7 @@ module ts.formatting {
|
||||
public AddRule(rule: Rule, specificTokens: boolean, constructionState: RulesBucketConstructionState[], rulesBucketIndex: number): void {
|
||||
let position: RulesPosition;
|
||||
|
||||
if (rule.Operation.Action == RuleAction.Ignore) {
|
||||
if (rule.Operation.Action === RuleAction.Ignore) {
|
||||
position = specificTokens ?
|
||||
RulesPosition.IgnoreRulesSpecific :
|
||||
RulesPosition.IgnoreRulesAny;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/// <reference path="references.ts"/>
|
||||
|
||||
/* @internal */
|
||||
module ts.formatting {
|
||||
namespace ts.formatting {
|
||||
export class RulesProvider {
|
||||
private globalRules: Rules;
|
||||
private options: ts.FormatCodeOptions;
|
||||
@ -25,6 +25,7 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
public ensureUpToDate(options: ts.FormatCodeOptions) {
|
||||
// TODO: Should this be '==='?
|
||||
if (this.options == null || !ts.compareDataObjects(this.options, options)) {
|
||||
let activeRules = this.createActiveRules(options);
|
||||
let rulesMap = RulesMap.create(activeRules);
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
///<reference path='..\services.ts' />
|
||||
|
||||
/* @internal */
|
||||
module ts.formatting {
|
||||
namespace ts.formatting {
|
||||
export module SmartIndenter {
|
||||
|
||||
const enum Value {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
/* @internal */
|
||||
module ts.formatting {
|
||||
namespace ts.formatting {
|
||||
export module Shared {
|
||||
export interface ITokenAccess {
|
||||
GetTokens(): SyntaxKind[];
|
||||
@ -54,7 +54,7 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
public Contains(tokenValue: SyntaxKind): boolean {
|
||||
return tokenValue == this.token;
|
||||
return tokenValue === this.token;
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ module ts.formatting {
|
||||
static AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([SyntaxKind.MultiLineCommentTrivia]));
|
||||
static Keywords = TokenRange.FromRange(SyntaxKind.FirstKeyword, SyntaxKind.LastKeyword);
|
||||
static BinaryOperators = TokenRange.FromRange(SyntaxKind.FirstBinaryOperator, SyntaxKind.LastBinaryOperator);
|
||||
static BinaryKeywordOperators = TokenRange.FromTokens([SyntaxKind.InKeyword, SyntaxKind.InstanceOfKeyword, SyntaxKind.OfKeyword]);
|
||||
static BinaryKeywordOperators = TokenRange.FromTokens([SyntaxKind.InKeyword, SyntaxKind.InstanceOfKeyword, SyntaxKind.OfKeyword, SyntaxKind.IsKeyword]);
|
||||
static UnaryPrefixOperators = TokenRange.FromTokens([SyntaxKind.PlusPlusToken, SyntaxKind.MinusMinusToken, SyntaxKind.TildeToken, SyntaxKind.ExclamationToken]);
|
||||
static UnaryPrefixExpressions = TokenRange.FromTokens([SyntaxKind.NumericLiteral, SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.OpenBracketToken, SyntaxKind.OpenBraceToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]);
|
||||
static UnaryPreincrementExpressions = TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/* @internal */
|
||||
module ts.NavigateTo {
|
||||
namespace ts.NavigateTo {
|
||||
type RawNavigateToItem = { name: string; fileName: string; matchKind: PatternMatchKind; isCaseSensitive: boolean; declaration: Declaration };
|
||||
|
||||
export function getNavigateToItems(program: Program, cancellationToken: CancellationTokenObject, searchValue: string, maxResultCount: number): NavigateToItem[] {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/// <reference path='services.ts' />
|
||||
|
||||
/* @internal */
|
||||
module ts.NavigationBar {
|
||||
namespace ts.NavigationBar {
|
||||
export function getNavigationBarItems(sourceFile: SourceFile): ts.NavigationBarItem[] {
|
||||
// If the source file has any child items, then it included in the tree
|
||||
// and takes lexical ownership of all other top-level items.
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/* @internal */
|
||||
module ts {
|
||||
namespace ts {
|
||||
export module OutliningElementsCollector {
|
||||
export function collectElements(sourceFile: SourceFile): OutliningSpan[] {
|
||||
let elements: OutliningSpan[] = [];
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/* @internal */
|
||||
module ts {
|
||||
namespace ts {
|
||||
// Note(cyrusn): this enum is ordered from strongest match type to weakest match type.
|
||||
export enum PatternMatchKind {
|
||||
exact,
|
||||
@ -686,7 +686,7 @@ module ts {
|
||||
|
||||
if (charIsPunctuation(identifier.charCodeAt(i - 1)) ||
|
||||
charIsPunctuation(identifier.charCodeAt(i)) ||
|
||||
lastIsDigit != currentIsDigit ||
|
||||
lastIsDigit !== currentIsDigit ||
|
||||
hasTransitionFromLowerToUpper ||
|
||||
hasTransitionFromUpperToLower) {
|
||||
|
||||
@ -757,7 +757,7 @@ module ts {
|
||||
// 3) HTMLDocument -> HTML, Document
|
||||
//
|
||||
// etc.
|
||||
if (index != wordStart &&
|
||||
if (index !== wordStart &&
|
||||
index + 1 < identifier.length) {
|
||||
let currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index));
|
||||
let nextIsLower = isLowerCaseLetter(identifier.charCodeAt(index + 1));
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
/// <reference path='formatting\formatting.ts' />
|
||||
/// <reference path='formatting\smartIndenter.ts' />
|
||||
|
||||
module ts {
|
||||
namespace ts {
|
||||
/** The version of the language service API */
|
||||
export let servicesVersion = "0.4"
|
||||
|
||||
@ -167,7 +167,7 @@ module ts {
|
||||
}
|
||||
|
||||
public getFullWidth(): number {
|
||||
return this.end - this.getFullStart();
|
||||
return this.end - this.pos;
|
||||
}
|
||||
|
||||
public getLeadingTriviaWidth(sourceFile?: SourceFile): number {
|
||||
@ -735,7 +735,7 @@ module ts {
|
||||
public endOfFileToken: Node;
|
||||
|
||||
public amdDependencies: { name: string; path: string }[];
|
||||
public amdModuleName: string;
|
||||
public moduleName: string;
|
||||
public referencedFiles: FileReference[];
|
||||
|
||||
public syntacticDiagnostics: Diagnostic[];
|
||||
@ -743,6 +743,7 @@ module ts {
|
||||
public parseDiagnostics: Diagnostic[];
|
||||
public bindDiagnostics: Diagnostic[];
|
||||
|
||||
public isDefaultLib: boolean;
|
||||
public hasNoDefaultLib: boolean;
|
||||
public externalModuleIndicator: Node; // The first node that causes this file to be an external module
|
||||
public nodeCount: number;
|
||||
@ -960,6 +961,7 @@ module ts {
|
||||
log? (s: string): void;
|
||||
trace? (s: string): void;
|
||||
error? (s: string): void;
|
||||
useCaseSensitiveFileNames? (): boolean;
|
||||
}
|
||||
|
||||
//
|
||||
@ -971,6 +973,9 @@ module ts {
|
||||
|
||||
getSyntacticDiagnostics(fileName: string): Diagnostic[];
|
||||
getSemanticDiagnostics(fileName: string): Diagnostic[];
|
||||
|
||||
// TODO: Rename this to getProgramDiagnostics to better indicate that these are any
|
||||
// diagnostics present for the program level, and not just 'options' diagnostics.
|
||||
getCompilerOptionsDiagnostics(): Diagnostic[];
|
||||
|
||||
/**
|
||||
@ -1510,6 +1515,7 @@ module ts {
|
||||
public static typeParameterName = "type parameter name";
|
||||
public static typeAliasName = "type alias name";
|
||||
public static parameterName = "parameter name";
|
||||
public static docCommentTagName = "doc comment tag name";
|
||||
}
|
||||
|
||||
export const enum ClassificationType {
|
||||
@ -1529,7 +1535,8 @@ module ts {
|
||||
moduleName = 14,
|
||||
typeParameterName = 15,
|
||||
typeAliasName = 16,
|
||||
parameterName = 17
|
||||
parameterName = 17,
|
||||
docCommentTagName = 18,
|
||||
}
|
||||
|
||||
/// Language Service
|
||||
@ -1630,12 +1637,12 @@ module ts {
|
||||
// at each language service public entry point, since we don't know when
|
||||
// set of scripts handled by the host changes.
|
||||
class HostCache {
|
||||
private fileNameToEntry: Map<HostFileInformation>;
|
||||
private fileNameToEntry: FileMap<HostFileInformation>;
|
||||
private _compilationSettings: CompilerOptions;
|
||||
|
||||
constructor(private host: LanguageServiceHost, private getCanonicalFileName: (fileName: string) => string) {
|
||||
constructor(private host: LanguageServiceHost, getCanonicalFileName: (fileName: string) => string) {
|
||||
// script id => script index
|
||||
this.fileNameToEntry = {};
|
||||
this.fileNameToEntry = createFileMap<HostFileInformation>(getCanonicalFileName);
|
||||
|
||||
// Initialize the list with the root file names
|
||||
let rootFileNames = host.getScriptFileNames();
|
||||
@ -1651,10 +1658,6 @@ module ts {
|
||||
return this._compilationSettings;
|
||||
}
|
||||
|
||||
private normalizeFileName(fileName: string): string {
|
||||
return this.getCanonicalFileName(normalizeSlashes(fileName));
|
||||
}
|
||||
|
||||
private createEntry(fileName: string) {
|
||||
let entry: HostFileInformation;
|
||||
let scriptSnapshot = this.host.getScriptSnapshot(fileName);
|
||||
@ -1666,15 +1669,16 @@ module ts {
|
||||
};
|
||||
}
|
||||
|
||||
return this.fileNameToEntry[this.normalizeFileName(fileName)] = entry;
|
||||
this.fileNameToEntry.set(fileName, entry);
|
||||
return entry;
|
||||
}
|
||||
|
||||
private getEntry(fileName: string): HostFileInformation {
|
||||
return lookUp(this.fileNameToEntry, this.normalizeFileName(fileName));
|
||||
return this.fileNameToEntry.get(fileName);
|
||||
}
|
||||
|
||||
private contains(fileName: string): boolean {
|
||||
return hasProperty(this.fileNameToEntry, this.normalizeFileName(fileName));
|
||||
return this.fileNameToEntry.contains(fileName);
|
||||
}
|
||||
|
||||
public getOrCreateEntry(fileName: string): HostFileInformation {
|
||||
@ -1688,10 +1692,9 @@ module ts {
|
||||
public getRootFileNames(): string[] {
|
||||
let fileNames: string[] = [];
|
||||
|
||||
forEachKey(this.fileNameToEntry, key => {
|
||||
let entry = this.getEntry(key);
|
||||
if (entry) {
|
||||
fileNames.push(entry.hostFileName);
|
||||
this.fileNameToEntry.forEachValue(value => {
|
||||
if (value) {
|
||||
fileNames.push(value.hostFileName);
|
||||
}
|
||||
});
|
||||
|
||||
@ -1761,26 +1764,36 @@ module ts {
|
||||
* This function will compile source text from 'input' argument using specified compiler options.
|
||||
* If not options are provided - it will use a set of default compiler options.
|
||||
* Extra compiler options that will unconditionally be used bu this function are:
|
||||
* - separateCompilation = true
|
||||
* - isolatedModules = true
|
||||
* - allowNonTsExtensions = true
|
||||
* - noLib = true
|
||||
* - noResolve = true
|
||||
*/
|
||||
export function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string {
|
||||
export function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string {
|
||||
let options = compilerOptions ? clone(compilerOptions) : getDefaultCompilerOptions();
|
||||
|
||||
options.separateCompilation = true;
|
||||
options.isolatedModules = true;
|
||||
|
||||
// Filename can be non-ts file.
|
||||
options.allowNonTsExtensions = true;
|
||||
|
||||
// Parse
|
||||
var inputFileName = fileName || "module.ts";
|
||||
var sourceFile = createSourceFile(inputFileName, input, options.target);
|
||||
// We are not returning a sourceFile for lib file when asked by the program,
|
||||
// so pass --noLib to avoid reporting a file not found error.
|
||||
options.noLib = true;
|
||||
|
||||
// Store syntactic diagnostics
|
||||
if (diagnostics && sourceFile.parseDiagnostics) {
|
||||
diagnostics.push(...sourceFile.parseDiagnostics);
|
||||
// We are not doing a full typecheck, we are not resolving the whole context,
|
||||
// so pass --noResolve to avoid reporting missing file errors.
|
||||
options.noResolve = true;
|
||||
|
||||
// Parse
|
||||
let inputFileName = fileName || "module.ts";
|
||||
let sourceFile = createSourceFile(inputFileName, input, options.target);
|
||||
if (moduleName) {
|
||||
sourceFile.moduleName = moduleName;
|
||||
}
|
||||
|
||||
let newLine = getNewLineCharacter(options);
|
||||
|
||||
// Output
|
||||
let outputText: string;
|
||||
|
||||
@ -1795,14 +1808,13 @@ module ts {
|
||||
useCaseSensitiveFileNames: () => false,
|
||||
getCanonicalFileName: fileName => fileName,
|
||||
getCurrentDirectory: () => "",
|
||||
getNewLine: () => (sys && sys.newLine) || "\r\n"
|
||||
getNewLine: () => newLine
|
||||
};
|
||||
|
||||
var program = createProgram([inputFileName], options, compilerHost);
|
||||
|
||||
if (diagnostics) {
|
||||
diagnostics.push(...program.getGlobalDiagnostics());
|
||||
}
|
||||
addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile));
|
||||
addRange(/*to*/ diagnostics, /*from*/ program.getOptionsDiagnostics());
|
||||
|
||||
// Emit
|
||||
program.emit();
|
||||
@ -1813,7 +1825,8 @@ module ts {
|
||||
}
|
||||
|
||||
export function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile {
|
||||
let sourceFile = createSourceFile(fileName, scriptSnapshot.getText(0, scriptSnapshot.getLength()), scriptTarget, setNodeParents);
|
||||
let text = scriptSnapshot.getText(0, scriptSnapshot.getLength());
|
||||
let sourceFile = createSourceFile(fileName, text, scriptTarget, setNodeParents);
|
||||
setSourceFileFields(sourceFile, scriptSnapshot, version);
|
||||
// after full parsing we can use table with interned strings as name table
|
||||
sourceFile.nameTable = sourceFile.identifiers;
|
||||
@ -1870,20 +1883,28 @@ module ts {
|
||||
return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents:*/ true);
|
||||
}
|
||||
|
||||
export function createDocumentRegistry(): DocumentRegistry {
|
||||
function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string {
|
||||
return useCaseSensitivefileNames
|
||||
? ((fileName) => fileName)
|
||||
: ((fileName) => fileName.toLowerCase());
|
||||
}
|
||||
|
||||
|
||||
export function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry {
|
||||
// Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have
|
||||
// for those settings.
|
||||
let buckets: Map<Map<DocumentRegistryEntry>> = {};
|
||||
let buckets: Map<FileMap<DocumentRegistryEntry>> = {};
|
||||
let getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames);
|
||||
|
||||
function getKeyFromCompilationSettings(settings: CompilerOptions): string {
|
||||
return "_" + settings.target; // + "|" + settings.propagateEnumConstantoString()
|
||||
}
|
||||
|
||||
function getBucketForCompilationSettings(settings: CompilerOptions, createIfMissing: boolean): Map<DocumentRegistryEntry> {
|
||||
function getBucketForCompilationSettings(settings: CompilerOptions, createIfMissing: boolean): FileMap<DocumentRegistryEntry> {
|
||||
let key = getKeyFromCompilationSettings(settings);
|
||||
let bucket = lookUp(buckets, key);
|
||||
if (!bucket && createIfMissing) {
|
||||
buckets[key] = bucket = {};
|
||||
buckets[key] = bucket = createFileMap<DocumentRegistryEntry>(getCanonicalFileName);
|
||||
}
|
||||
return bucket;
|
||||
}
|
||||
@ -1893,7 +1914,7 @@ module ts {
|
||||
let entries = lookUp(buckets, name);
|
||||
let sourceFiles: { name: string; refCount: number; references: string[]; }[] = [];
|
||||
for (let i in entries) {
|
||||
let entry = entries[i];
|
||||
let entry = entries.get(i);
|
||||
sourceFiles.push({
|
||||
name: i,
|
||||
refCount: entry.languageServiceRefCount,
|
||||
@ -1925,18 +1946,19 @@ module ts {
|
||||
acquiring: boolean): SourceFile {
|
||||
|
||||
let bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true);
|
||||
let entry = lookUp(bucket, fileName);
|
||||
let entry = bucket.get(fileName);
|
||||
if (!entry) {
|
||||
Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?");
|
||||
|
||||
// Have never seen this file with these settings. Create a new source file for it.
|
||||
let sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents:*/ false);
|
||||
|
||||
bucket[fileName] = entry = {
|
||||
entry = {
|
||||
sourceFile: sourceFile,
|
||||
languageServiceRefCount: 0,
|
||||
owners: []
|
||||
};
|
||||
bucket.set(fileName, entry);
|
||||
}
|
||||
else {
|
||||
// We have an entry for this file. However, it may be for a different version of
|
||||
@ -1964,12 +1986,12 @@ module ts {
|
||||
let bucket = getBucketForCompilationSettings(compilationSettings, false);
|
||||
Debug.assert(bucket !== undefined);
|
||||
|
||||
let entry = lookUp(bucket, fileName);
|
||||
let entry = bucket.get(fileName);
|
||||
entry.languageServiceRefCount--;
|
||||
|
||||
Debug.assert(entry.languageServiceRefCount >= 0);
|
||||
if (entry.languageServiceRefCount === 0) {
|
||||
delete bucket[fileName];
|
||||
bucket.remove(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2397,9 +2419,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getCanonicalFileName(fileName: string) {
|
||||
return useCaseSensitivefileNames ? fileName : fileName.toLowerCase();
|
||||
}
|
||||
let getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames);
|
||||
|
||||
function getValidSourceFile(fileName: string): SourceFile {
|
||||
fileName = normalizeSlashes(fileName);
|
||||
@ -2475,6 +2495,10 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
// hostCache is captured in the closure for 'getOrCreateSourceFile' but it should not be used past this point.
|
||||
// It needs to be cleared to allow all collected snapshots to be released
|
||||
hostCache = undefined;
|
||||
|
||||
program = newProgram;
|
||||
|
||||
// Make sure all the nodes in the program are both bound, and have their parent
|
||||
@ -2483,6 +2507,7 @@ module ts {
|
||||
return;
|
||||
|
||||
function getOrCreateSourceFile(fileName: string): SourceFile {
|
||||
Debug.assert(hostCache !== undefined);
|
||||
// The program is asking for this file, check first if the host can locate it.
|
||||
// If the host can not locate the file, then it does not exist. return undefined
|
||||
// to the program to allow reporting of errors for missing files.
|
||||
@ -2768,7 +2793,7 @@ module ts {
|
||||
|
||||
function getCompilerOptionsDiagnostics() {
|
||||
synchronizeHostData();
|
||||
return program.getGlobalDiagnostics();
|
||||
return program.getOptionsDiagnostics().concat(program.getGlobalDiagnostics());
|
||||
}
|
||||
|
||||
/// Completion
|
||||
@ -2832,6 +2857,7 @@ module ts {
|
||||
let typeChecker = program.getTypeChecker();
|
||||
let syntacticStart = new Date().getTime();
|
||||
let sourceFile = getValidSourceFile(fileName);
|
||||
let isJavaScriptFile = isJavaScript(fileName);
|
||||
|
||||
let start = new Date().getTime();
|
||||
let currentToken = getTokenAtPosition(sourceFile, position);
|
||||
@ -2932,13 +2958,29 @@ module ts {
|
||||
}
|
||||
|
||||
let type = typeChecker.getTypeAtLocation(node);
|
||||
addTypeProperties(type);
|
||||
}
|
||||
|
||||
function addTypeProperties(type: Type) {
|
||||
if (type) {
|
||||
// Filter private properties
|
||||
forEach(type.getApparentProperties(), symbol => {
|
||||
for (let symbol of type.getApparentProperties()) {
|
||||
if (typeChecker.isValidPropertyAccess(<PropertyAccessExpression>(node.parent), symbol.name)) {
|
||||
symbols.push(symbol);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (isJavaScriptFile && type.flags & TypeFlags.Union) {
|
||||
// In javascript files, for union types, we don't just get the members that
|
||||
// the individual types have in common, we also include all the members that
|
||||
// each individual type has. This is because we're going to add all identifiers
|
||||
// anyways. So we might as well elevate the members that were at least part
|
||||
// of the individual types to a higher status since we know what they are.
|
||||
let unionType = <UnionType>type;
|
||||
for (let elementType of unionType.types) {
|
||||
addTypeProperties(elementType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3125,16 +3167,20 @@ module ts {
|
||||
if (previousToken.kind === SyntaxKind.StringLiteral
|
||||
|| previousToken.kind === SyntaxKind.RegularExpressionLiteral
|
||||
|| isTemplateLiteralKind(previousToken.kind)) {
|
||||
// The position has to be either: 1. entirely within the token text, or
|
||||
// 2. at the end position of an unterminated token.
|
||||
let start = previousToken.getStart();
|
||||
let end = previousToken.getEnd();
|
||||
|
||||
// To be "in" one of these literals, the position has to be:
|
||||
// 1. entirely within the token text.
|
||||
// 2. at the end position of an unterminated token.
|
||||
// 3. at the end of a regular expression (due to trailing flags like '/foo/g').
|
||||
if (start < position && position < end) {
|
||||
return true;
|
||||
}
|
||||
else if (position === end) {
|
||||
return !!(<LiteralExpression>previousToken).isUnterminated;
|
||||
|
||||
if (position === end) {
|
||||
return !!(<LiteralExpression>previousToken).isUnterminated ||
|
||||
previousToken.kind === SyntaxKind.RegularExpressionLiteral;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4139,7 +4185,7 @@ module ts {
|
||||
var result: DefinitionInfo[] = [];
|
||||
forEach((<UnionType>type).types, t => {
|
||||
if (t.symbol) {
|
||||
result.push(...getDefinitionFromSymbol(t.symbol, node));
|
||||
addRange(/*to*/ result, /*from*/ getDefinitionFromSymbol(t.symbol, node));
|
||||
}
|
||||
});
|
||||
return result;
|
||||
@ -5762,7 +5808,8 @@ module ts {
|
||||
node = node.parent;
|
||||
}
|
||||
|
||||
return node.parent.kind === SyntaxKind.TypeReference || node.parent.kind === SyntaxKind.ExpressionWithTypeArguments;
|
||||
return node.parent.kind === SyntaxKind.TypeReference ||
|
||||
(node.parent.kind === SyntaxKind.ExpressionWithTypeArguments && !isExpressionWithTypeArgumentsInClassExtendsClause(<ExpressionWithTypeArguments>node.parent));
|
||||
}
|
||||
|
||||
function isNamespaceReference(node: Node): boolean {
|
||||
@ -5943,6 +5990,7 @@ module ts {
|
||||
let typeChecker = program.getTypeChecker();
|
||||
|
||||
let result: number[] = [];
|
||||
let classifiableNames = program.getClassifiableNames();
|
||||
processNode(sourceFile);
|
||||
|
||||
return { spans: result, endOfLineState: EndOfLineState.None };
|
||||
@ -5955,6 +6003,9 @@ module ts {
|
||||
|
||||
function classifySymbol(symbol: Symbol, meaningAtPosition: SemanticMeaning): ClassificationType {
|
||||
let flags = symbol.getFlags();
|
||||
if ((flags & SymbolFlags.Classifiable) === SymbolFlags.None) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (flags & SymbolFlags.Class) {
|
||||
return ClassificationType.className;
|
||||
@ -5990,20 +6041,28 @@ module ts {
|
||||
*/
|
||||
function hasValueSideModule(symbol: Symbol): boolean {
|
||||
return forEach(symbol.declarations, declaration => {
|
||||
return declaration.kind === SyntaxKind.ModuleDeclaration && getModuleInstanceState(declaration) == ModuleInstanceState.Instantiated;
|
||||
return declaration.kind === SyntaxKind.ModuleDeclaration &&
|
||||
getModuleInstanceState(declaration) === ModuleInstanceState.Instantiated;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function processNode(node: Node) {
|
||||
// Only walk into nodes that intersect the requested span.
|
||||
if (node && textSpanIntersectsWith(span, node.getStart(), node.getWidth())) {
|
||||
if (node.kind === SyntaxKind.Identifier && node.getWidth() > 0) {
|
||||
let symbol = typeChecker.getSymbolAtLocation(node);
|
||||
if (symbol) {
|
||||
let type = classifySymbol(symbol, getMeaningFromLocation(node));
|
||||
if (type) {
|
||||
pushClassification(node.getStart(), node.getWidth(), type);
|
||||
if (node && textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) {
|
||||
if (node.kind === SyntaxKind.Identifier && !nodeIsMissing(node)) {
|
||||
let identifier = <Identifier>node;
|
||||
|
||||
// Only bother calling into the typechecker if this is an identifier that
|
||||
// could possibly resolve to a type name. This makes classification run
|
||||
// in a third of the time it would normally take.
|
||||
if (classifiableNames[identifier.text]) {
|
||||
let symbol = typeChecker.getSymbolAtLocation(node);
|
||||
if (symbol) {
|
||||
let type = classifySymbol(symbol, getMeaningFromLocation(node));
|
||||
if (type) {
|
||||
pushClassification(node.getStart(), node.getWidth(), type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6031,6 +6090,7 @@ module ts {
|
||||
case ClassificationType.typeParameterName: return ClassificationTypeNames.typeParameterName;
|
||||
case ClassificationType.typeAliasName: return ClassificationTypeNames.typeAliasName;
|
||||
case ClassificationType.parameterName: return ClassificationTypeNames.parameterName;
|
||||
case ClassificationType.docCommentTagName: return ClassificationTypeNames.docCommentTagName;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6055,6 +6115,8 @@ module ts {
|
||||
function getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications {
|
||||
// doesn't use compiler - no need to synchronize with host
|
||||
let sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
|
||||
let spanStart = span.start;
|
||||
let spanLength = span.length;
|
||||
|
||||
// Make a scanner we can get trivia from.
|
||||
let triviaScanner = createScanner(ScriptTarget.Latest, /*skipTrivia:*/ false, sourceFile.text);
|
||||
@ -6071,53 +6133,145 @@ module ts {
|
||||
result.push(type);
|
||||
}
|
||||
|
||||
function classifyLeadingTrivia(token: Node): void {
|
||||
let tokenStart = skipTrivia(sourceFile.text, token.pos, /*stopAfterLineBreak:*/ false);
|
||||
if (tokenStart === token.pos) {
|
||||
return;
|
||||
}
|
||||
|
||||
// token has trivia. Classify them appropriately.
|
||||
function classifyLeadingTriviaAndGetTokenStart(token: Node): number {
|
||||
triviaScanner.setTextPos(token.pos);
|
||||
while (true) {
|
||||
let start = triviaScanner.getTextPos();
|
||||
// only bother scanning if we have something that could be trivia.
|
||||
if (!couldStartTrivia(sourceFile.text, start)) {
|
||||
return start;
|
||||
}
|
||||
|
||||
let kind = triviaScanner.scan();
|
||||
let end = triviaScanner.getTextPos();
|
||||
let width = end - start;
|
||||
|
||||
// The moment we get something that isn't trivia, then stop processing.
|
||||
if (!isTrivia(kind)) {
|
||||
return;
|
||||
return start;
|
||||
}
|
||||
|
||||
// Don't bother with newlines/whitespace.
|
||||
if (kind === SyntaxKind.NewLineTrivia || kind === SyntaxKind.WhitespaceTrivia) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Only bother with the trivia if it at least intersects the span of interest.
|
||||
if (textSpanIntersectsWith(span, start, width)) {
|
||||
if (isComment(kind)) {
|
||||
// Simple comment. Just add as is.
|
||||
if (isComment(kind)) {
|
||||
classifyComment(token, kind, start, width);
|
||||
|
||||
// Classifying a comment might cause us to reuse the trivia scanner
|
||||
// (because of jsdoc comments). So after we classify the comment make
|
||||
// sure we set the scanner position back to where it needs to be.
|
||||
triviaScanner.setTextPos(end);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (kind === SyntaxKind.ConflictMarkerTrivia) {
|
||||
let text = sourceFile.text;
|
||||
let ch = text.charCodeAt(start);
|
||||
|
||||
// for the <<<<<<< and >>>>>>> markers, we just add them in as comments
|
||||
// in the classification stream.
|
||||
if (ch === CharacterCodes.lessThan || ch === CharacterCodes.greaterThan) {
|
||||
pushClassification(start, width, ClassificationType.comment);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (kind === SyntaxKind.ConflictMarkerTrivia) {
|
||||
let text = sourceFile.text;
|
||||
let ch = text.charCodeAt(start);
|
||||
|
||||
// for the <<<<<<< and >>>>>>> markers, we just add them in as comments
|
||||
// in the classification stream.
|
||||
if (ch === CharacterCodes.lessThan || ch === CharacterCodes.greaterThan) {
|
||||
pushClassification(start, width, ClassificationType.comment);
|
||||
continue;
|
||||
}
|
||||
|
||||
// for the ======== add a comment for the first line, and then lex all
|
||||
// subsequent lines up until the end of the conflict marker.
|
||||
Debug.assert(ch === CharacterCodes.equals);
|
||||
classifyDisabledMergeCode(text, start, end);
|
||||
}
|
||||
// for the ======== add a comment for the first line, and then lex all
|
||||
// subsequent lines up until the end of the conflict marker.
|
||||
Debug.assert(ch === CharacterCodes.equals);
|
||||
classifyDisabledMergeCode(text, start, end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function classifyComment(token: Node, kind: SyntaxKind, start: number, width: number) {
|
||||
if (kind === SyntaxKind.MultiLineCommentTrivia) {
|
||||
// See if this is a doc comment. If so, we'll classify certain portions of it
|
||||
// specially.
|
||||
let docCommentAndDiagnostics = parseIsolatedJSDocComment(sourceFile.text, start, width);
|
||||
if (docCommentAndDiagnostics && docCommentAndDiagnostics.jsDocComment) {
|
||||
docCommentAndDiagnostics.jsDocComment.parent = token;
|
||||
classifyJSDocComment(docCommentAndDiagnostics.jsDocComment);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Simple comment. Just add as is.
|
||||
pushCommentRange(start, width);
|
||||
}
|
||||
|
||||
function pushCommentRange(start: number, width: number) {
|
||||
pushClassification(start, width, ClassificationType.comment);
|
||||
}
|
||||
|
||||
function classifyJSDocComment(docComment: JSDocComment) {
|
||||
let pos = docComment.pos;
|
||||
|
||||
for (let tag of docComment.tags) {
|
||||
// As we walk through each tag, classify the portion of text from the end of
|
||||
// the last tag (or the start of the entire doc comment) as 'comment'.
|
||||
if (tag.pos !== pos) {
|
||||
pushCommentRange(pos, tag.pos - pos);
|
||||
}
|
||||
|
||||
pushClassification(tag.atToken.pos, tag.atToken.end - tag.atToken.pos, ClassificationType.punctuation);
|
||||
pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, ClassificationType.docCommentTagName);
|
||||
|
||||
pos = tag.tagName.end;
|
||||
|
||||
switch (tag.kind) {
|
||||
case SyntaxKind.JSDocParameterTag:
|
||||
processJSDocParameterTag(<JSDocParameterTag>tag);
|
||||
break;
|
||||
case SyntaxKind.JSDocTemplateTag:
|
||||
processJSDocTemplateTag(<JSDocTemplateTag>tag);
|
||||
break;
|
||||
case SyntaxKind.JSDocTypeTag:
|
||||
processElement((<JSDocTypeTag>tag).typeExpression);
|
||||
break;
|
||||
case SyntaxKind.JSDocReturnTag:
|
||||
processElement((<JSDocReturnTag>tag).typeExpression);
|
||||
break;
|
||||
}
|
||||
|
||||
pos = tag.end;
|
||||
}
|
||||
|
||||
if (pos !== docComment.end) {
|
||||
pushCommentRange(pos, docComment.end - pos);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
function processJSDocParameterTag(tag: JSDocParameterTag) {
|
||||
if (tag.preParameterName) {
|
||||
pushCommentRange(pos, tag.preParameterName.pos - pos);
|
||||
pushClassification(tag.preParameterName.pos, tag.preParameterName.end - tag.preParameterName.pos, ClassificationType.parameterName);
|
||||
pos = tag.preParameterName.end;
|
||||
}
|
||||
|
||||
if (tag.typeExpression) {
|
||||
pushCommentRange(pos, tag.typeExpression.pos - pos);
|
||||
processElement(tag.typeExpression);
|
||||
pos = tag.typeExpression.end;
|
||||
}
|
||||
|
||||
if (tag.postParameterName) {
|
||||
pushCommentRange(pos, tag.postParameterName.pos - pos);
|
||||
pushClassification(tag.postParameterName.pos, tag.postParameterName.end - tag.postParameterName.pos, ClassificationType.parameterName);
|
||||
pos = tag.postParameterName.end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function processJSDocTemplateTag(tag: JSDocTemplateTag) {
|
||||
for (let child of tag.getChildren()) {
|
||||
processElement(child);
|
||||
}
|
||||
}
|
||||
|
||||
function classifyDisabledMergeCode(text: string, start: number, end: number) {
|
||||
// Classify the line that the ======= marker is on as a comment. Then just lex
|
||||
// all further tokens and add them to the result.
|
||||
@ -6146,12 +6300,18 @@ module ts {
|
||||
}
|
||||
|
||||
function classifyToken(token: Node): void {
|
||||
classifyLeadingTrivia(token);
|
||||
if (nodeIsMissing(token)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (token.getWidth() > 0) {
|
||||
let tokenStart = classifyLeadingTriviaAndGetTokenStart(token);
|
||||
|
||||
let tokenWidth = token.end - tokenStart;
|
||||
Debug.assert(tokenWidth >= 0);
|
||||
if (tokenWidth > 0) {
|
||||
let type = classifyTokenType(token.kind, token);
|
||||
if (type) {
|
||||
pushClassification(token.getStart(), token.getWidth(), type);
|
||||
pushClassification(tokenStart, tokenWidth, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6251,10 +6411,15 @@ module ts {
|
||||
}
|
||||
|
||||
function processElement(element: Node) {
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Ignore nodes that don't intersect the original span to classify.
|
||||
if (textSpanIntersectsWith(span, element.getFullStart(), element.getFullWidth())) {
|
||||
let children = element.getChildren();
|
||||
for (let child of children) {
|
||||
if (decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) {
|
||||
let children = element.getChildren(sourceFile);
|
||||
for (let i = 0, n = children.length; i < n; i++) {
|
||||
let child = children[i];
|
||||
if (isToken(child)) {
|
||||
classifyToken(child);
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
var debugObjectHost = (<any>this);
|
||||
|
||||
/* @internal */
|
||||
module ts {
|
||||
namespace ts {
|
||||
export interface ScriptSnapshotShim {
|
||||
/** Gets a portion of the script snapshot specified by [start, end). */
|
||||
getText(start: number, end: number): string;
|
||||
@ -56,6 +56,7 @@ module ts {
|
||||
getDefaultLibFileName(options: string): string;
|
||||
getNewLine?(): string;
|
||||
getProjectVersion?(): string;
|
||||
useCaseSensitiveFileNames?(): boolean;
|
||||
}
|
||||
|
||||
/** Public interface of the the of a config service shim instance.*/
|
||||
@ -233,6 +234,7 @@ module ts {
|
||||
public getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange {
|
||||
var oldSnapshotShim = <ScriptSnapshotShimAdapter>oldSnapshot;
|
||||
var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim);
|
||||
// TODO: should this be '==='?
|
||||
if (encoded == null) {
|
||||
return null;
|
||||
}
|
||||
@ -245,16 +247,22 @@ module ts {
|
||||
|
||||
export class LanguageServiceShimHostAdapter implements LanguageServiceHost {
|
||||
private files: string[];
|
||||
private loggingEnabled = false;
|
||||
private tracingEnabled = false;
|
||||
|
||||
constructor(private shimHost: LanguageServiceShimHost) {
|
||||
}
|
||||
|
||||
public log(s: string): void {
|
||||
this.shimHost.log(s);
|
||||
if (this.loggingEnabled) {
|
||||
this.shimHost.log(s);
|
||||
}
|
||||
}
|
||||
|
||||
public trace(s: string): void {
|
||||
this.shimHost.trace(s);
|
||||
if (this.tracingEnabled) {
|
||||
this.shimHost.trace(s);
|
||||
}
|
||||
}
|
||||
|
||||
public error(s: string): void {
|
||||
@ -270,8 +278,13 @@ module ts {
|
||||
return this.shimHost.getProjectVersion();
|
||||
}
|
||||
|
||||
public useCaseSensitiveFileNames(): boolean {
|
||||
return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false;
|
||||
}
|
||||
|
||||
public getCompilationSettings(): CompilerOptions {
|
||||
var settingsJson = this.shimHost.getCompilationSettings();
|
||||
// TODO: should this be '==='?
|
||||
if (settingsJson == null || settingsJson == "") {
|
||||
throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings");
|
||||
return null;
|
||||
@ -344,15 +357,15 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function simpleForwardCall(logger: Logger, actionDescription: string, action: () => any, noPerfLogging: boolean): any {
|
||||
if (!noPerfLogging) {
|
||||
function simpleForwardCall(logger: Logger, actionDescription: string, action: () => any, logPerformance: boolean): any {
|
||||
if (logPerformance) {
|
||||
logger.log(actionDescription);
|
||||
var start = Date.now();
|
||||
}
|
||||
|
||||
var result = action();
|
||||
|
||||
if (!noPerfLogging) {
|
||||
if (logPerformance) {
|
||||
var end = Date.now();
|
||||
logger.log(actionDescription + " completed in " + (end - start) + " msec");
|
||||
if (typeof (result) === "string") {
|
||||
@ -367,9 +380,9 @@ module ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
function forwardJSONCall(logger: Logger, actionDescription: string, action: () => any, noPerfLogging: boolean): string {
|
||||
function forwardJSONCall(logger: Logger, actionDescription: string, action: () => any, logPerformance: boolean): string {
|
||||
try {
|
||||
var result = simpleForwardCall(logger, actionDescription, action, noPerfLogging);
|
||||
var result = simpleForwardCall(logger, actionDescription, action, logPerformance);
|
||||
return JSON.stringify({ result: result });
|
||||
}
|
||||
catch (err) {
|
||||
@ -408,6 +421,7 @@ module ts {
|
||||
|
||||
class LanguageServiceShimObject extends ShimBase implements LanguageServiceShim {
|
||||
private logger: Logger;
|
||||
private logPerformance = false;
|
||||
|
||||
constructor(factory: ShimFactory,
|
||||
private host: LanguageServiceShimHost,
|
||||
@ -417,7 +431,7 @@ module ts {
|
||||
}
|
||||
|
||||
public forwardJSONCall(actionDescription: string, action: () => any): string {
|
||||
return forwardJSONCall(this.logger, actionDescription, action, /*noPerfLogging:*/ false);
|
||||
return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance);
|
||||
}
|
||||
|
||||
/// DISPOSE
|
||||
@ -806,6 +820,7 @@ module ts {
|
||||
|
||||
class ClassifierShimObject extends ShimBase implements ClassifierShim {
|
||||
public classifier: Classifier;
|
||||
private logPerformance = false;
|
||||
|
||||
constructor(factory: ShimFactory, private logger: Logger) {
|
||||
super(factory);
|
||||
@ -815,7 +830,7 @@ module ts {
|
||||
public getEncodedLexicalClassifications(text: string, lexState: EndOfLineState, syntacticClassifierAbsent?: boolean): string {
|
||||
return forwardJSONCall(this.logger, "getEncodedLexicalClassifications",
|
||||
() => convertClassifications(this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)),
|
||||
/*noPerfLogging:*/ true);
|
||||
this.logPerformance);
|
||||
}
|
||||
|
||||
/// COLORIZATION
|
||||
@ -833,13 +848,14 @@ module ts {
|
||||
}
|
||||
|
||||
class CoreServicesShimObject extends ShimBase implements CoreServicesShim {
|
||||
private logPerformance = false;
|
||||
|
||||
constructor(factory: ShimFactory, public logger: Logger, private host: CoreServicesShimHostAdapter) {
|
||||
super(factory);
|
||||
}
|
||||
|
||||
private forwardJSONCall(actionDescription: string, action: () => any): any {
|
||||
return forwardJSONCall(this.logger, actionDescription, action, /*noPerfLogging:*/ false);
|
||||
return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance);
|
||||
}
|
||||
|
||||
public getPreProcessedFileInfo(fileName: string, sourceTextSnapshot: IScriptSnapshot): string {
|
||||
@ -909,7 +925,7 @@ module ts {
|
||||
|
||||
export class TypeScriptServicesFactory implements ShimFactory {
|
||||
private _shims: Shim[] = [];
|
||||
private documentRegistry: DocumentRegistry = createDocumentRegistry();
|
||||
private documentRegistry: DocumentRegistry;
|
||||
|
||||
/*
|
||||
* Returns script API version.
|
||||
@ -920,6 +936,9 @@ module ts {
|
||||
|
||||
public createLanguageServiceShim(host: LanguageServiceShimHost): LanguageServiceShim {
|
||||
try {
|
||||
if (this.documentRegistry === undefined) {
|
||||
this.documentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames());
|
||||
}
|
||||
var hostAdapter = new LanguageServiceShimHostAdapter(host);
|
||||
var languageService = createLanguageService(hostAdapter, this.documentRegistry);
|
||||
return new LanguageServiceShimObject(this, host, languageService);
|
||||
@ -989,4 +1008,4 @@ module TypeScript.Services {
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
let toolsVersion = "1.4";
|
||||
let toolsVersion = "1.5";
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
///<reference path='services.ts' />
|
||||
/* @internal */
|
||||
module ts.SignatureHelp {
|
||||
namespace ts.SignatureHelp {
|
||||
|
||||
// A partially written generic type expression is not guaranteed to have the correct syntax tree. the expression could be parsed as less than/greater than expression or a comma expression
|
||||
// or some other combination depending on what the user has typed so far. For the purposes of signature help we need to consider any location after "<" as a possible generic type reference.
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// These utilities are common to multiple language service features.
|
||||
/* @internal */
|
||||
module ts {
|
||||
namespace ts {
|
||||
export interface ListItemInfo {
|
||||
listItemIndex: number;
|
||||
list: Node;
|
||||
@ -502,7 +502,7 @@ module ts {
|
||||
|
||||
// Display-part writer helpers
|
||||
/* @internal */
|
||||
module ts {
|
||||
namespace ts {
|
||||
export function isFirstDeclarationOfSymbolParameter(symbol: Symbol) {
|
||||
return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === SyntaxKind.Parameter;
|
||||
}
|
||||
|
||||
@ -75,26 +75,26 @@ function delint(sourceFile) {
|
||||
delintNode(sourceFile);
|
||||
function delintNode(node) {
|
||||
switch (node.kind) {
|
||||
case 187 /* ForStatement */:
|
||||
case 188 /* ForInStatement */:
|
||||
case 186 /* WhileStatement */:
|
||||
case 185 /* DoStatement */:
|
||||
if (node.statement.kind !== 180 /* Block */) {
|
||||
case 189 /* ForStatement */:
|
||||
case 190 /* ForInStatement */:
|
||||
case 188 /* WhileStatement */:
|
||||
case 187 /* DoStatement */:
|
||||
if (node.statement.kind !== 182 /* Block */) {
|
||||
report(node, "A looping statement's contents should be wrapped in a block body.");
|
||||
}
|
||||
break;
|
||||
case 184 /* IfStatement */:
|
||||
case 186 /* IfStatement */:
|
||||
var ifStatement = node;
|
||||
if (ifStatement.thenStatement.kind !== 180 /* Block */) {
|
||||
if (ifStatement.thenStatement.kind !== 182 /* Block */) {
|
||||
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
|
||||
}
|
||||
if (ifStatement.elseStatement &&
|
||||
ifStatement.elseStatement.kind !== 180 /* Block */ &&
|
||||
ifStatement.elseStatement.kind !== 184 /* IfStatement */) {
|
||||
ifStatement.elseStatement.kind !== 182 /* Block */ &&
|
||||
ifStatement.elseStatement.kind !== 186 /* IfStatement */) {
|
||||
report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.");
|
||||
}
|
||||
break;
|
||||
case 170 /* BinaryExpression */:
|
||||
case 172 /* BinaryExpression */:
|
||||
var op = node.operatorToken.kind;
|
||||
if (op === 28 /* EqualsEqualsToken */ || op == 29 /* ExclamationEqualsToken */) {
|
||||
report(node, "Use '===' and '!=='.");
|
||||
|
||||
@ -1,11 +1,8 @@
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts(1,13): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts(1,14): error TS1110: Type expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts (2 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts (1 errors) ====
|
||||
var v = (a): => {
|
||||
|
||||
!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
||||
~~
|
||||
!!! error TS1110: Type expected.
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ for (let v of []) {
|
||||
for (var _i = 0, _a = []; _i < _a.length; _i++) {
|
||||
var v = _a[_i];
|
||||
v;
|
||||
for (var _b = 0, _c = [v]; _b < _c.length; _b++) {
|
||||
for (var _b = 0, _c = [v_1]; _b < _c.length; _b++) {
|
||||
var v_1 = _c[_b];
|
||||
var x = v_1;
|
||||
v_1++;
|
||||
|
||||
@ -10,7 +10,7 @@ for (let v of []) {
|
||||
for (var _i = 0, _a = []; _i < _a.length; _i++) {
|
||||
var v = _a[_i];
|
||||
var v_1;
|
||||
for (var _b = 0, _c = [v]; _b < _c.length; _b++) {
|
||||
for (var _b = 0, _c = [v_2]; _b < _c.length; _b++) {
|
||||
var v_2 = _c[_b];
|
||||
var v_3;
|
||||
}
|
||||
|
||||
@ -24,8 +24,7 @@ module A {
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var A;
|
||||
(function (A) {
|
||||
|
||||
@ -28,8 +28,7 @@ module A {
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var A;
|
||||
(function (A) {
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,10): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,10): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts (1 errors) ====
|
||||
function * foo(a = yield => yield) {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts(1,10): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts(1,10): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts (1 errors) ====
|
||||
function * yield() {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
}
|
||||
@ -1,11 +1,11 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts(1,10): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts(1,10): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts(3,11): error TS2304: Cannot find name 'yield'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts (2 errors) ====
|
||||
function * foo() {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
// Legal to use 'yield' in a type context.
|
||||
var v: yield;
|
||||
~~~~~
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts(1,10): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts(1,10): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts (1 errors) ====
|
||||
function * foo() {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
}
|
||||
@ -1,11 +1,11 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,9): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,18): error TS2304: Cannot find name 'yield'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts (2 errors) ====
|
||||
function*foo(a = yield) {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'yield'.
|
||||
}
|
||||
@ -1,16 +1,16 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(1,9): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,11): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,11): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,20): error TS2304: Cannot find name 'yield'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts (3 errors) ====
|
||||
function*bar() {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
// 'yield' here is an identifier, and not a yield expression.
|
||||
function*foo(a = yield) {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'yield'.
|
||||
}
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(1,10): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(2,14): error TS9000: 'yield' expressions are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(1,10): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (2 errors) ====
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (1 errors) ====
|
||||
function * foo() {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
var v = { [yield]: foo }
|
||||
~~~~~
|
||||
!!! error TS9000: 'yield' expressions are not currently supported.
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts(1,18): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts(1,18): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts (1 errors) ====
|
||||
var v = function * () { }
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts(1,18): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts(1,18): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts (1 errors) ====
|
||||
var v = function * foo() { }
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts(1,11): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts(1,11): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts (1 errors) ====
|
||||
var v = { *foo() { } }
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
@ -1,10 +1,10 @@
|
||||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,11): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,11): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,13): error TS2304: Cannot find name 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (2 errors) ====
|
||||
var v = { *[foo()]() { } }
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'foo'.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user