mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merged branch 'master' into asyncFunctions
This commit is contained in:
commit
6fc07e65f5
234 files changed
+7969
-2573
No files matched your search
+47
-16
@@ -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.
|
||||
+4
-3
@@ -129,7 +129,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 +149,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) {
|
||||
@@ -506,7 +507,7 @@ function cleanTestDirs() {
|
||||
// used to pass data from jake command line directly to run.js
|
||||
function writeTestConfigFile(tests, testConfigFile) {
|
||||
console.log('Running test(s): ' + tests);
|
||||
var testConfigContents = '{\n' + '\ttest: [\'' + tests + '\']\n}';
|
||||
var testConfigContents = JSON.stringify({ test: [tests]});
|
||||
fs.writeFileSync('test.config', testConfigContents);
|
||||
}
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
|
||||
Vendored
+14
-6
@@ -11335,10 +11335,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 +12067,7 @@ declare var PopStateEvent: {
|
||||
|
||||
interface Position {
|
||||
coords: Coordinates;
|
||||
timestamp: Date;
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
declare var Position: {
|
||||
@@ -14748,9 +14748,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 +15998,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 +16025,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 +16637,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
|
||||
/////////////////////////////
|
||||
|
||||
Vendored
+14
-7
@@ -10165,10 +10165,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 +10897,7 @@ declare var PopStateEvent: {
|
||||
|
||||
interface Position {
|
||||
coords: Coordinates;
|
||||
timestamp: Date;
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
declare var Position: {
|
||||
@@ -13578,9 +13578,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 +14828,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 +14855,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 +15466,4 @@ declare function addEventListener(type: "unload", listener: (ev: Event) => any,
|
||||
declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
Vendored
+14
-6
@@ -12713,10 +12713,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;
|
||||
}
|
||||
|
||||
@@ -13445,7 +13445,7 @@ declare var PopStateEvent: {
|
||||
|
||||
interface Position {
|
||||
coords: Coordinates;
|
||||
timestamp: Date;
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
declare var Position: {
|
||||
@@ -16126,9 +16126,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;
|
||||
@@ -17368,10 +17376,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;
|
||||
@@ -17394,8 +17403,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;
|
||||
@@ -18008,6 +18015,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
|
||||
/////////////////////////////
|
||||
|
||||
+350
-307
File diff suppressed because it is too large.
Load diff
+377
-331
File diff suppressed because it is too large.
Load diff
Vendored
+5
-4
@@ -857,7 +857,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;
|
||||
@@ -1091,8 +1091,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,
|
||||
@@ -1281,7 +1282,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;
|
||||
}
|
||||
|
||||
+431
-364
File diff suppressed because it is too large.
Load diff
Vendored
+5
-4
@@ -857,7 +857,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;
|
||||
@@ -1091,8 +1091,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,
|
||||
@@ -1281,7 +1282,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;
|
||||
}
|
||||
|
||||
+431
-364
File diff suppressed because it is too large.
Load diff
+12
-9
@@ -338,6 +338,7 @@ module ts {
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.SourceFile:
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
return ContainerFlags.IsContainerWithLocals;
|
||||
|
||||
case SyntaxKind.CatchClause:
|
||||
@@ -385,10 +386,10 @@ module ts {
|
||||
|
||||
function declareSymbolAndAddToSymbolTableWorker(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): Symbol {
|
||||
switch (container.kind) {
|
||||
// Modules, source files, and classes need specialized handling for how their
|
||||
// Modules, source files, and classes need specialized handling for how their
|
||||
// members are declared (for example, a member of a class will go into a specific
|
||||
// symbol table depending on if it is static or not). As such, we defer to
|
||||
// specialized handlers to take care of declaring these child members.
|
||||
// symbol table depending on if it is static or not). We defer to specialized
|
||||
// handlers to take care of declaring these child members.
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
return declareModuleMember(node, symbolFlags, symbolExcludes);
|
||||
|
||||
@@ -406,9 +407,10 @@ module ts {
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
// Interface/Object-types always have their children added to the 'members' of
|
||||
// their container. They are only accessible through an instance of their
|
||||
// container, and are never in scope otherwise (even inside the body of the
|
||||
// object / type / interface declaring them).
|
||||
// their container. They are only accessible through an instance of their
|
||||
// container, and are never in scope otherwise (even inside the body of the
|
||||
// object / type / interface declaring them). An exception is type parameters,
|
||||
// which are in scope without qualification (similar to 'locals').
|
||||
return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes);
|
||||
|
||||
case SyntaxKind.FunctionType:
|
||||
@@ -424,11 +426,12 @@ module ts {
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
// All the children of these container types are never visible through another
|
||||
// symbol (i.e. through another symbol's 'exports' or 'members'). Instead,
|
||||
// they're only accessed 'lexically' (i.e. from code that exists underneath
|
||||
// symbol (i.e. through another symbol's 'exports' or 'members'). Instead,
|
||||
// they're only accessed 'lexically' (i.e. from code that exists underneath
|
||||
// their container in the tree. To accomplish this, we simply add their declared
|
||||
// symbol to the 'locals' of the container. These symbols can then be found as
|
||||
// symbol to the 'locals' of the container. These symbols can then be found as
|
||||
// the type checker walks up the containers, checking them for matching names.
|
||||
return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes);
|
||||
}
|
||||
|
||||
+633
-419
File diff suppressed because it is too large.
Load diff
@@ -103,6 +103,10 @@ module ts {
|
||||
name: "noResolve",
|
||||
type: "boolean",
|
||||
},
|
||||
{
|
||||
name: "skipDefaultLibCheck",
|
||||
type: "boolean",
|
||||
},
|
||||
{
|
||||
name: "out",
|
||||
type: "string",
|
||||
@@ -349,7 +353,7 @@ module ts {
|
||||
|
||||
return {
|
||||
options: getCompilerOptions(),
|
||||
fileNames: getFiles(),
|
||||
fileNames: getFileNames(),
|
||||
errors
|
||||
};
|
||||
|
||||
@@ -395,23 +399,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
@@ -187,6 +187,13 @@ module ts {
|
||||
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." },
|
||||
with_statements_are_not_allowed_in_an_async_function_block: { code: 1300, category: DiagnosticCategory.Error, key: "'with' statements are not allowed in an async function block." },
|
||||
await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: DiagnosticCategory.Error, key: "'await' expression is only allowed within an async function." },
|
||||
Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: DiagnosticCategory.Error, key: "Async functions are only available when targeting ECMAScript 6 and higher." },
|
||||
|
||||
@@ -735,6 +735,35 @@
|
||||
"category": "Error",
|
||||
"code": 1223
|
||||
},
|
||||
"Signature '{0}' must have a type predicate.": {
|
||||
"category": "Error",
|
||||
"code": 1224
|
||||
},
|
||||
"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
|
||||
},
|
||||
|
||||
|
||||
"'with' statements are not allowed in an async function block.": {
|
||||
"category": "Error",
|
||||
|
||||
+210
-238
@@ -141,7 +141,6 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
|
||||
let generatedNameSet: Map<string> = {};
|
||||
let nodeToGeneratedName: string[] = [];
|
||||
let blockScopedVariableToGeneratedName: string[];
|
||||
let computedPropertyNamesToGeneratedNames: string[];
|
||||
|
||||
let extendsEmitted = false;
|
||||
@@ -266,81 +265,44 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
}
|
||||
}
|
||||
|
||||
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() {
|
||||
@@ -704,19 +666,19 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
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) {
|
||||
recordEmitNodeStartSpan(node);
|
||||
emitNodeWithoutSourceMap(node, allowGeneratedIdentifiers);
|
||||
emitNodeWithoutSourceMap(node);
|
||||
recordEmitNodeEndSpan(node);
|
||||
}
|
||||
else {
|
||||
recordNewSourceFileStart(<SourceFile>node);
|
||||
emitNodeWithoutSourceMap(node, /*allowGeneratedIdentifiers*/ false);
|
||||
emitNodeWithoutSourceMap(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1218,80 +1180,129 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1337,7 +1348,7 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
|
||||
function emitBindingElement(node: BindingElement) {
|
||||
if (node.propertyName) {
|
||||
emit(node.propertyName, /*allowGeneratedIdentifiers*/ false);
|
||||
emit(node.propertyName);
|
||||
write(": ");
|
||||
}
|
||||
if (node.dotDotDotToken) {
|
||||
@@ -1687,6 +1698,12 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
}
|
||||
|
||||
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:
|
||||
//
|
||||
@@ -1695,7 +1712,10 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
// 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);
|
||||
@@ -1714,7 +1734,7 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
write("*");
|
||||
}
|
||||
|
||||
emit(node.name, /*allowGeneratedIdentifiers*/ false);
|
||||
emit(node.name);
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
write(": function ");
|
||||
}
|
||||
@@ -1722,40 +1742,34 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1808,7 +1822,7 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1930,23 +1944,21 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
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)) {
|
||||
@@ -1982,7 +1994,10 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -2810,8 +2825,6 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
write(", ");
|
||||
}
|
||||
|
||||
renameNonTopLevelLetAndConst(name);
|
||||
|
||||
const isVariableDeclarationOrBindingElement =
|
||||
name.parent && (name.parent.kind === SyntaxKind.VariableDeclaration || name.parent.kind === SyntaxKind.BindingElement);
|
||||
|
||||
@@ -2879,11 +2892,14 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
}
|
||||
|
||||
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 {
|
||||
@@ -2905,8 +2921,7 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -3020,8 +3035,6 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
}
|
||||
}
|
||||
else {
|
||||
renameNonTopLevelLetAndConst(<Identifier>node.name);
|
||||
|
||||
let initializer = node.initializer;
|
||||
if (!initializer && languageVersion < ScriptTarget.ES6) {
|
||||
|
||||
@@ -3081,54 +3094,6 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
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 &&
|
||||
@@ -3292,7 +3257,7 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
|
||||
function emitAccessor(node: AccessorDeclaration) {
|
||||
write(node.kind === SyntaxKind.GetAccessor ? "get " : "set ");
|
||||
emit(node.name, /*allowGeneratedIdentifiers*/ false);
|
||||
emit(node.name);
|
||||
emitSignatureAndBody(node);
|
||||
}
|
||||
|
||||
@@ -3390,9 +3355,9 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
|
||||
emitSignatureParameters(node);
|
||||
}
|
||||
|
||||
|
||||
function emitAsyncFunctionBodyForES6(node: FunctionLikeDeclaration) {
|
||||
let promiseConstructor = resolver.getPromiseConstructor(node);
|
||||
let promiseConstructor = getEntityNameFromTypeNode(node.type);
|
||||
let isArrowFunction = node.kind === SyntaxKind.ArrowFunction;
|
||||
let args: string;
|
||||
|
||||
@@ -4524,7 +4489,7 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
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(", ");
|
||||
@@ -4537,7 +4502,7 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
}
|
||||
}
|
||||
if (shouldEmitParamTypesMetadata(node)) {
|
||||
var serializedTypes = resolver.serializeParameterTypesOfNode(node, getGeneratedNameForNode);
|
||||
var serializedTypes = resolver.serializeParameterTypesOfNode(node);
|
||||
if (serializedTypes) {
|
||||
if (writeComma || argumentsWritten) {
|
||||
write(", ");
|
||||
@@ -4555,7 +4520,7 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
}
|
||||
}
|
||||
if (shouldEmitReturnTypeMetadata(node)) {
|
||||
var serializedType = resolver.serializeReturnTypeOfNode(node, getGeneratedNameForNode);
|
||||
var serializedType = resolver.serializeReturnTypeOfNode(node);
|
||||
if (serializedType) {
|
||||
if (writeComma || argumentsWritten) {
|
||||
write(", ");
|
||||
@@ -4661,7 +4626,7 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
emitDeclarationName(node);
|
||||
write(`", `);
|
||||
emitDeclarationName(node);
|
||||
write(")");
|
||||
write(");");
|
||||
}
|
||||
emitExportMemberAssignments(node.name);
|
||||
}
|
||||
@@ -4782,7 +4747,7 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
emitDeclarationName(node);
|
||||
write(`", `);
|
||||
emitDeclarationName(node);
|
||||
write(")");
|
||||
write(");");
|
||||
}
|
||||
emitExportMemberAssignments(<Identifier>node.name);
|
||||
}
|
||||
@@ -5153,13 +5118,16 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5547,10 +5515,10 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
emitSetters(exportStarFunction);
|
||||
writeLine();
|
||||
emitExecute(node, startIndex);
|
||||
emitTempDeclarations(/*newLine*/ true)
|
||||
decreaseIndent();
|
||||
writeLine();
|
||||
write("}"); // return
|
||||
emitTempDeclarations(/*newLine*/ true)
|
||||
}
|
||||
|
||||
function emitSetters(exportStarFunction: string) {
|
||||
@@ -5697,7 +5665,11 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
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) {
|
||||
@@ -5783,8 +5755,8 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
|
||||
writeLine();
|
||||
write("define(");
|
||||
if (node.amdModuleName) {
|
||||
write("\"" + node.amdModuleName + "\", ");
|
||||
if (node.moduleName) {
|
||||
write("\"" + node.moduleName + "\", ");
|
||||
}
|
||||
emitAMDDependencies(node, /*includeNonAmdDependencies*/ true);
|
||||
write(") {");
|
||||
@@ -5949,7 +5921,7 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
emitLeadingComments(node.endOfFileToken);
|
||||
}
|
||||
|
||||
function emitNodeWithoutSourceMap(node: Node, allowGeneratedIdentifiers?: boolean): void {
|
||||
function emitNodeWithoutSourceMap(node: Node): void {
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
@@ -5963,7 +5935,7 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
emitLeadingComments(node);
|
||||
}
|
||||
|
||||
emitJavaScriptWorker(node, allowGeneratedIdentifiers);
|
||||
emitJavaScriptWorker(node);
|
||||
|
||||
if (emitComments) {
|
||||
emitTrailingComments(node);
|
||||
@@ -6013,11 +5985,11 @@ var __awaiter = (this && this.__awaiter) || function (generator, thisArg, args,
|
||||
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:
|
||||
|
||||
+64
-19
@@ -103,6 +103,9 @@ module ts {
|
||||
case SyntaxKind.TypeReference:
|
||||
return visitNode(cbNode, (<TypeReferenceNode>node).typeName) ||
|
||||
visitNodes(cbNodes, (<TypeReferenceNode>node).typeArguments);
|
||||
case SyntaxKind.TypePredicate:
|
||||
return visitNode(cbNode, (<TypePredicateNode>node).parameterName) ||
|
||||
visitNode(cbNode, (<TypePredicateNode>node).type);
|
||||
case SyntaxKind.TypeQuery:
|
||||
return visitNode(cbNode, (<TypeQueryNode>node).exprName);
|
||||
case SyntaxKind.TypeLiteral:
|
||||
@@ -257,6 +260,7 @@ module ts {
|
||||
return visitNodes(cbNodes, node.decorators) ||
|
||||
visitNodes(cbNodes, node.modifiers) ||
|
||||
visitNode(cbNode, (<TypeAliasDeclaration>node).name) ||
|
||||
visitNodes(cbNodes, (<TypeAliasDeclaration>node).typeParameters) ||
|
||||
visitNode(cbNode, (<TypeAliasDeclaration>node).type);
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
return visitNodes(cbNodes, node.decorators) ||
|
||||
@@ -1848,7 +1852,7 @@ module ts {
|
||||
if (matchesPattern) {
|
||||
// Report that we need an identifier. However, report it right after the dot,
|
||||
// and not on the next token. This is because the next token might actually
|
||||
// be an identifier and the error woudl be quite confusing.
|
||||
// be an identifier and the error would be quite confusing.
|
||||
return <Identifier>createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentToken*/ true, Diagnostics.Identifier_expected);
|
||||
}
|
||||
}
|
||||
@@ -1929,9 +1933,17 @@ module ts {
|
||||
|
||||
// TYPES
|
||||
|
||||
function parseTypeReference(): TypeReferenceNode {
|
||||
let node = <TypeReferenceNode>createNode(SyntaxKind.TypeReference);
|
||||
node.typeName = parseEntityName(/*allowReservedWords*/ false, Diagnostics.Type_expected);
|
||||
function parseTypeReferenceOrTypePredicate(): TypeReferenceNode | TypePredicateNode {
|
||||
let typeName = parseEntityName(/*allowReservedWords*/ false, Diagnostics.Type_expected);
|
||||
if (typeName.kind === SyntaxKind.Identifier && token === SyntaxKind.IsKeyword && !scanner.hasPrecedingLineBreak()) {
|
||||
nextToken();
|
||||
let node = <TypePredicateNode>createNode(SyntaxKind.TypePredicate, typeName.pos);
|
||||
node.parameterName = <Identifier>typeName;
|
||||
node.type = parseType();
|
||||
return finishNode(node);
|
||||
}
|
||||
let node = <TypeReferenceNode>createNode(SyntaxKind.TypeReference, typeName.pos);
|
||||
node.typeName = typeName;
|
||||
if (!scanner.hasPrecedingLineBreak() && token === SyntaxKind.LessThanToken) {
|
||||
node.typeArguments = parseBracketedList(ParsingContext.TypeArguments, parseType, SyntaxKind.LessThanToken, SyntaxKind.GreaterThanToken);
|
||||
}
|
||||
@@ -2391,7 +2403,7 @@ module ts {
|
||||
case SyntaxKind.SymbolKeyword:
|
||||
// If these are followed by a dot, then parse these out as a dotted type reference instead.
|
||||
let node = tryParse(parseKeywordAndNoDot);
|
||||
return node || parseTypeReference();
|
||||
return node || parseTypeReferenceOrTypePredicate();
|
||||
case SyntaxKind.VoidKeyword:
|
||||
return parseTokenNode<TypeNode>();
|
||||
case SyntaxKind.TypeOfKeyword:
|
||||
@@ -2403,7 +2415,7 @@ module ts {
|
||||
case SyntaxKind.OpenParenToken:
|
||||
return parseParenthesizedType();
|
||||
default:
|
||||
return parseTypeReference();
|
||||
return parseTypeReferenceOrTypePredicate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2735,7 +2747,7 @@ module ts {
|
||||
|
||||
function nextTokenIsIdentifierOnSameLine() {
|
||||
nextToken();
|
||||
return !scanner.hasPrecedingLineBreak() && isIdentifier()
|
||||
return !scanner.hasPrecedingLineBreak() && isIdentifier();
|
||||
}
|
||||
|
||||
function parseYieldExpression(): YieldExpression {
|
||||
@@ -3926,14 +3938,42 @@ module ts {
|
||||
case SyntaxKind.ClassKeyword:
|
||||
case SyntaxKind.EnumKeyword:
|
||||
return StatementFlags.Statement;
|
||||
|
||||
// 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers;
|
||||
// however, an identifier cannot be followed by another identifier on the same line. This is what we
|
||||
// count on to parse out the respective declarations. For instance, we exploit this to say that
|
||||
//
|
||||
// namespace n
|
||||
//
|
||||
// can be none other than the beginning of a namespace declaration, but need to respect that JavaScript sees
|
||||
//
|
||||
// namespace
|
||||
// n
|
||||
//
|
||||
// as the identifier 'namespace' on one line followed by the identifier 'n' on another.
|
||||
// We need to look one token ahead to see if it permissible to try parsing a declaration.
|
||||
//
|
||||
// *Note*: 'interface' is actually a strict mode reserved word. So while
|
||||
//
|
||||
// "use strict"
|
||||
// interface
|
||||
// I {}
|
||||
//
|
||||
// could be legal, it would add complexity for very little gain.
|
||||
case SyntaxKind.InterfaceKeyword:
|
||||
case SyntaxKind.TypeKeyword:
|
||||
nextToken();
|
||||
return isIdentifierOrKeyword() ? StatementFlags.Statement : StatementFlags.None;
|
||||
return nextTokenIsIdentifierOnSameLine() ? StatementFlags.Statement : StatementFlags.None;
|
||||
case SyntaxKind.ModuleKeyword:
|
||||
case SyntaxKind.NamespaceKeyword:
|
||||
return nextTokenIsIdentifierOrStringLiteralOnSameLine() ? StatementFlags.ModuleElement : StatementFlags.None;
|
||||
case SyntaxKind.DeclareKeyword:
|
||||
nextToken();
|
||||
return isIdentifierOrKeyword() || token === SyntaxKind.StringLiteral ? StatementFlags.ModuleElement : StatementFlags.None;
|
||||
// ASI takes effect for this modifier.
|
||||
if (scanner.hasPrecedingLineBreak()) {
|
||||
return StatementFlags.None;
|
||||
}
|
||||
continue;
|
||||
|
||||
case SyntaxKind.ImportKeyword:
|
||||
nextToken();
|
||||
return token === SyntaxKind.StringLiteral || token === SyntaxKind.AsteriskToken ||
|
||||
@@ -3955,7 +3995,6 @@ module ts {
|
||||
|
||||
continue;
|
||||
|
||||
case SyntaxKind.DeclareKeyword:
|
||||
case SyntaxKind.PublicKeyword:
|
||||
case SyntaxKind.PrivateKeyword:
|
||||
case SyntaxKind.ProtectedKeyword:
|
||||
@@ -4098,7 +4137,7 @@ module ts {
|
||||
case SyntaxKind.ThrowKeyword:
|
||||
return parseThrowStatement();
|
||||
case SyntaxKind.TryKeyword:
|
||||
// Include the next two for error recovery.
|
||||
// Include 'catch' and 'finally' for error recovery.
|
||||
case SyntaxKind.CatchKeyword:
|
||||
case SyntaxKind.FinallyKeyword:
|
||||
return parseTryStatement();
|
||||
@@ -4107,19 +4146,19 @@ module ts {
|
||||
case SyntaxKind.AtToken:
|
||||
return parseDeclaration();
|
||||
case SyntaxKind.AsyncKeyword:
|
||||
case SyntaxKind.ConstKeyword:
|
||||
case SyntaxKind.InterfaceKeyword:
|
||||
case SyntaxKind.TypeKeyword:
|
||||
case SyntaxKind.ModuleKeyword:
|
||||
case SyntaxKind.NamespaceKeyword:
|
||||
case SyntaxKind.DeclareKeyword:
|
||||
case SyntaxKind.ConstKeyword:
|
||||
case SyntaxKind.EnumKeyword:
|
||||
case SyntaxKind.ExportKeyword:
|
||||
case SyntaxKind.ImportKeyword:
|
||||
case SyntaxKind.InterfaceKeyword:
|
||||
case SyntaxKind.ModuleKeyword:
|
||||
case SyntaxKind.NamespaceKeyword:
|
||||
case SyntaxKind.PrivateKeyword:
|
||||
case SyntaxKind.ProtectedKeyword:
|
||||
case SyntaxKind.PublicKeyword:
|
||||
case SyntaxKind.StaticKeyword:
|
||||
case SyntaxKind.TypeKeyword:
|
||||
if (getDeclarationFlags() & flags) {
|
||||
return parseDeclaration();
|
||||
}
|
||||
@@ -4170,6 +4209,11 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function nextTokenIsIdentifierOrStringLiteralOnSameLine() {
|
||||
nextToken();
|
||||
return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === SyntaxKind.StringLiteral);
|
||||
}
|
||||
|
||||
function parseFunctionBlockOrSemicolon(isGenerator: boolean, isAsync: boolean, diagnosticMessage?: DiagnosticMessage): Block {
|
||||
if (token !== SyntaxKind.OpenBraceToken && canParseSemicolon()) {
|
||||
parseSemicolon();
|
||||
@@ -4687,6 +4731,7 @@ module ts {
|
||||
setModifiers(node, modifiers);
|
||||
parseExpected(SyntaxKind.TypeKeyword);
|
||||
node.name = parseIdentifier();
|
||||
node.typeParameters = parseTypeParameters();
|
||||
parseExpected(SyntaxKind.EqualsToken);
|
||||
node.type = parseType();
|
||||
parseSemicolon();
|
||||
@@ -4723,7 +4768,7 @@ module ts {
|
||||
function parseModuleBlock(): ModuleBlock {
|
||||
let node = <ModuleBlock>createNode(SyntaxKind.ModuleBlock, scanner.getStartPos());
|
||||
if (parseExpected(SyntaxKind.OpenBraceToken)) {
|
||||
node.statements = parseList(ParsingContext.ModuleElements, /*checkForStrictMode*/false, parseModuleElement);
|
||||
node.statements = parseList(ParsingContext.ModuleElements, /*checkForStrictMode*/ false, parseModuleElement);
|
||||
parseExpected(SyntaxKind.CloseBraceToken);
|
||||
}
|
||||
else {
|
||||
@@ -5035,7 +5080,7 @@ module ts {
|
||||
|
||||
sourceFile.referencedFiles = referencedFiles;
|
||||
sourceFile.amdDependencies = amdDependencies;
|
||||
sourceFile.amdModuleName = amdModuleName;
|
||||
sourceFile.moduleName = amdModuleName;
|
||||
}
|
||||
|
||||
function setExternalModuleIndicator(sourceFile: SourceFile) {
|
||||
|
||||
+23
-20
@@ -10,9 +10,6 @@ module ts {
|
||||
/** The version of the TypeScript compiler release */
|
||||
export const version = "1.5.3";
|
||||
|
||||
const carriageReturnLineFeed = "\r\n";
|
||||
const lineFeed = "\n";
|
||||
|
||||
export function findConfigFile(searchPath: string): string {
|
||||
var fileName = "tsconfig.json";
|
||||
while (true) {
|
||||
@@ -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,
|
||||
@@ -149,9 +143,8 @@ 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 skipDefaultLib = options.noLib;
|
||||
let commonSourceDirectory: string;
|
||||
let diagnosticsProducingTypeChecker: TypeChecker;
|
||||
let noDiagnosticsTypeChecker: TypeChecker;
|
||||
@@ -159,9 +152,11 @@ module ts {
|
||||
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));
|
||||
if (!skipDefaultLib) {
|
||||
processRootFile(host.getDefaultLibFileName(options), /*isDefaultLib:*/ true);
|
||||
}
|
||||
verifyCompilerOptions();
|
||||
|
||||
@@ -175,6 +170,7 @@ module ts {
|
||||
getGlobalDiagnostics,
|
||||
getSemanticDiagnostics,
|
||||
getDeclarationDiagnostics,
|
||||
getCompilerOptionsDiagnostics,
|
||||
getTypeChecker,
|
||||
getDiagnosticsProducingTypeChecker,
|
||||
getCommonSourceDirectory: () => commonSourceDirectory,
|
||||
@@ -238,8 +234,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,6 +286,12 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getCompilerOptionsDiagnostics(): Diagnostic[] {
|
||||
let allDiagnostics: Diagnostic[] = [];
|
||||
addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
|
||||
return sortAndDeduplicateDiagnostics(allDiagnostics);
|
||||
}
|
||||
|
||||
function getGlobalDiagnostics(): Diagnostic[] {
|
||||
let typeChecker = getDiagnosticsProducingTypeChecker();
|
||||
|
||||
@@ -358,19 +359,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 +380,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 +393,7 @@ module ts {
|
||||
processImportedModules(file, basePath);
|
||||
}
|
||||
if (isDefaultLib) {
|
||||
file.isDefaultLib = true;
|
||||
files.unshift(file);
|
||||
}
|
||||
else {
|
||||
@@ -402,7 +405,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) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
+31
-15
@@ -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.statSync(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) {
|
||||
|
||||
+51
-20
@@ -3,6 +3,14 @@ module ts {
|
||||
[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;
|
||||
@@ -139,6 +147,7 @@ module ts {
|
||||
ConstructorKeyword,
|
||||
DeclareKeyword,
|
||||
GetKeyword,
|
||||
IsKeyword,
|
||||
ModuleKeyword,
|
||||
NamespaceKeyword,
|
||||
RequireKeyword,
|
||||
@@ -171,6 +180,7 @@ module ts {
|
||||
ConstructSignature,
|
||||
IndexSignature,
|
||||
// Type
|
||||
TypePredicate,
|
||||
TypeReference,
|
||||
FunctionType,
|
||||
ConstructorType,
|
||||
@@ -626,6 +636,11 @@ module ts {
|
||||
typeArguments?: NodeArray<TypeNode>;
|
||||
}
|
||||
|
||||
export interface TypePredicateNode extends TypeNode {
|
||||
parameterName: Identifier;
|
||||
type: TypeNode;
|
||||
}
|
||||
|
||||
export interface TypeQueryNode extends TypeNode {
|
||||
exprName: EntityName;
|
||||
}
|
||||
@@ -955,6 +970,7 @@ module ts {
|
||||
|
||||
export interface TypeAliasDeclaration extends Declaration, Statement {
|
||||
name: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
type: TypeNode;
|
||||
}
|
||||
|
||||
@@ -1158,7 +1174,7 @@ module ts {
|
||||
text: string;
|
||||
|
||||
amdDependencies: {path: string; name: string}[];
|
||||
amdModuleName: string;
|
||||
moduleName: string;
|
||||
referencedFiles: FileReference[];
|
||||
|
||||
hasNoDefaultLib: boolean;
|
||||
@@ -1167,7 +1183,8 @@ module ts {
|
||||
|
||||
// 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;
|
||||
@@ -1192,7 +1209,7 @@ module ts {
|
||||
}
|
||||
|
||||
export interface ParseConfigHost {
|
||||
readDirectory(rootDir: string, extension: string): string[];
|
||||
readDirectory(rootDir: string, extension: string, exclude: string[]): string[];
|
||||
}
|
||||
|
||||
export interface WriteFileCallback {
|
||||
@@ -1221,6 +1238,7 @@ module ts {
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
/* @internal */ getCompilerOptionsDiagnostics(): Diagnostic[];
|
||||
|
||||
/**
|
||||
* Gets a type checker that can be used to semantically analyze source fils in the program.
|
||||
@@ -1400,6 +1418,12 @@ module ts {
|
||||
NotAccessible,
|
||||
CannotBeNamed
|
||||
}
|
||||
|
||||
export interface TypePredicate {
|
||||
parameterName: string;
|
||||
parameterIndex: number;
|
||||
type: Type;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration;
|
||||
@@ -1420,7 +1444,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;
|
||||
@@ -1435,13 +1462,11 @@ 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[];
|
||||
getPromiseConstructor(node: SignatureDeclaration): EntityName | Expression;
|
||||
serializeTypeOfNode(node: Node): string | string[];
|
||||
serializeParameterTypesOfNode(node: Node): (string | string[])[];
|
||||
serializeReturnTypeOfNode(node: Node): string | string[];
|
||||
}
|
||||
|
||||
export const enum SymbolFlags {
|
||||
@@ -1518,6 +1543,8 @@ module ts {
|
||||
HasExports = Class | Enum | Module,
|
||||
HasMembers = Class | Interface | TypeLiteral | ObjectLiteral,
|
||||
|
||||
BlockScoped = BlockScopedVariable | Class | Enum,
|
||||
|
||||
PropertyOrAccessor = Property | Accessor,
|
||||
Export = ExportNamespace | ExportType | ExportValue,
|
||||
}
|
||||
@@ -1541,12 +1568,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 */
|
||||
@@ -1592,7 +1622,6 @@ module ts {
|
||||
assignmentChecks?: Map<boolean>; // Cache of assignment checks
|
||||
hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context
|
||||
importOnRightSide?: Symbol; // for import declarations - import that appear on the right side
|
||||
promiseConstructor?: EntityName | Expression;
|
||||
}
|
||||
|
||||
export const enum TypeFlags {
|
||||
@@ -1612,14 +1641,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,
|
||||
@@ -1733,6 +1763,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 */
|
||||
@@ -1761,7 +1792,6 @@ module ts {
|
||||
/* @internal */
|
||||
export interface TypeMapper {
|
||||
(t: TypeParameter): Type;
|
||||
mappings?: Map<Type>; // Type mapping cache
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -1853,6 +1883,7 @@ module ts {
|
||||
experimentalDecorators?: boolean;
|
||||
emitDecoratorMetadata?: boolean;
|
||||
/* @internal */ stripInternal?: boolean;
|
||||
/* @internal */ skipDefaultLibCheck?: boolean;
|
||||
[option: string]: string | number | boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -761,6 +761,22 @@ module ts {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function getEntityNameFromTypeNode(node: TypeNode): EntityName | Expression {
|
||||
if (node) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.TypeReference:
|
||||
return (<TypeReferenceNode>node).typeName;
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return (<ExpressionWithTypeArguments>node).expression
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.QualifiedName:
|
||||
return (<EntityName><Node>node);
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function getInvokedExpression(node: CallLikeExpression): Expression {
|
||||
if (node.kind === SyntaxKind.TaggedTemplateExpression) {
|
||||
@@ -2004,6 +2020,21 @@ 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 {
|
||||
|
||||
+57
-89
@@ -808,9 +808,15 @@ module Harness {
|
||||
}
|
||||
}
|
||||
|
||||
export function createSourceFileAndAssertInvariants(fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, assertInvariants = true) {
|
||||
export function createSourceFileAndAssertInvariants(
|
||||
fileName: string,
|
||||
sourceText: string,
|
||||
languageVersion: ts.ScriptTarget,
|
||||
assertInvariants: boolean) {
|
||||
|
||||
// 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) {
|
||||
Utils.assertInvariants(result, /*parent:*/ undefined);
|
||||
}
|
||||
@@ -821,8 +827,8 @@ module Harness {
|
||||
const lineFeed = "\n";
|
||||
|
||||
export var defaultLibFileName = 'lib.d.ts';
|
||||
export var defaultLibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest);
|
||||
export var defaultES6LibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest);
|
||||
export var defaultLibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest, /*assertInvariants:*/ true);
|
||||
export var defaultES6LibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest, /*assertInvariants:*/ true);
|
||||
|
||||
// Cache these between executions so we don't have to re-parse them for every test
|
||||
export var fourslashFileName = 'fourslash.ts';
|
||||
@@ -832,13 +838,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 {
|
||||
@@ -852,7 +859,7 @@ module Harness {
|
||||
function register(file: { unitName: string; content: string; }) {
|
||||
if (file.content !== undefined) {
|
||||
var fileName = ts.normalizePath(file.unitName);
|
||||
filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget);
|
||||
filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget, /*assertInvariants:*/ true);
|
||||
}
|
||||
};
|
||||
inputFiles.forEach(register);
|
||||
@@ -875,7 +882,7 @@ module Harness {
|
||||
}
|
||||
else if (fn === fourslashFileName) {
|
||||
var tsFn = 'tests/cases/fourslash/' + fourslashFileName;
|
||||
fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants(tsFn, Harness.IO.readFile(tsFn), scriptTarget);
|
||||
fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants(tsFn, Harness.IO.readFile(tsFn), scriptTarget, /*assertInvariants:*/ true);
|
||||
return fourslashSourceFile;
|
||||
}
|
||||
else {
|
||||
@@ -899,7 +906,7 @@ module Harness {
|
||||
private compileOptions: ts.CompilerOptions;
|
||||
private settings: Harness.TestCaseParser.CompilerSetting[] = [];
|
||||
|
||||
private lastErrors: HarnessDiagnostic[];
|
||||
private lastErrors: ts.Diagnostic[];
|
||||
|
||||
public reset() {
|
||||
this.inputFiles = [];
|
||||
@@ -964,7 +971,8 @@ 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.
|
||||
@@ -1050,6 +1058,10 @@ module Harness {
|
||||
options.outDir = setting.value;
|
||||
break;
|
||||
|
||||
case 'skipdefaultlibcheck':
|
||||
options.skipDefaultLibCheck = setting.value === "true";
|
||||
break;
|
||||
|
||||
case 'sourceroot':
|
||||
options.sourceRoot = setting.value;
|
||||
break;
|
||||
@@ -1078,10 +1090,6 @@ module Harness {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'normalizenewline':
|
||||
newLine = setting.value;
|
||||
break;
|
||||
|
||||
case 'comments':
|
||||
options.removeComments = setting.value === 'false';
|
||||
break;
|
||||
@@ -1138,17 +1146,15 @@ module Harness {
|
||||
var fileOutputs: GeneratedFile[] = [];
|
||||
|
||||
var programFiles = inputFiles.concat(includeBuiltFiles).map(file => file.unitName);
|
||||
var program = ts.createProgram(programFiles, options, createCompilerHost(inputFiles.concat(includeBuiltFiles).concat(otherFiles),
|
||||
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));
|
||||
options.target, useCaseSensitiveFileNames, currentDirectory, options.newLine);
|
||||
var program = ts.createProgram(programFiles, options, compilerHost);
|
||||
|
||||
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));
|
||||
});
|
||||
var errors = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
||||
this.lastErrors = errors;
|
||||
|
||||
var result = new CompilerResult(fileOutputs, errors, program, ts.sys.getCurrentDirectory(), emitResult.sourceMaps);
|
||||
@@ -1235,70 +1241,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;
|
||||
});
|
||||
|
||||
|
||||
@@ -1334,18 +1320,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
|
||||
|
||||
@@ -1361,12 +1348,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
|
||||
@@ -1419,17 +1406,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;
|
||||
@@ -1459,12 +1435,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 => {
|
||||
@@ -1489,15 +1465,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1527,7 +1494,8 @@ module Harness {
|
||||
"errortruncation", "usecasesensitivefilenames", "preserveconstenums",
|
||||
"includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal",
|
||||
"isolatedmodules", "inlinesourcemap", "maproot", "sourceroot",
|
||||
"inlinesources", "emitdecoratormetadata", "experimentaldecorators"];
|
||||
"inlinesources", "emitdecoratormetadata", "experimentaldecorators",
|
||||
"skipdefaultlibcheck"];
|
||||
|
||||
function extractCompilerSettings(content: string): CompilerSetting[] {
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ class ProjectRunner extends RunnerBase {
|
||||
else {
|
||||
var text = getSourceFileText(fileName);
|
||||
if (text !== undefined) {
|
||||
sourceFile = Harness.Compiler.createSourceFileAndAssertInvariants(fileName, text, languageVersion);
|
||||
sourceFile = Harness.Compiler.createSourceFileAndAssertInvariants(fileName, text, languageVersion, /*assertInvariants:*/ true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,9 +323,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;
|
||||
|
||||
+39
-35
@@ -38,41 +38,45 @@ 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.test && testConfig.test.length > 0) {
|
||||
for (let option of testConfig.test) {
|
||||
if (!option) {
|
||||
continue;
|
||||
}
|
||||
ts.sys.write("Option: " + option + "\r\n");
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+11
@@ -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>
|
||||
}
|
||||
Vendored
+14
-7
@@ -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;
|
||||
+52
-32
@@ -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;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1632,12 +1634,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();
|
||||
@@ -1653,10 +1655,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);
|
||||
@@ -1668,15 +1666,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 {
|
||||
@@ -1690,10 +1689,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);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1765,8 +1763,10 @@ module ts {
|
||||
* Extra compiler options that will unconditionally be used bu this function are:
|
||||
* - 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.isolatedModules = true;
|
||||
@@ -1774,15 +1774,28 @@ module ts {
|
||||
// Filename can be non-ts file.
|
||||
options.allowNonTsExtensions = true;
|
||||
|
||||
// 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;
|
||||
|
||||
// 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
|
||||
var inputFileName = fileName || "module.ts";
|
||||
var sourceFile = createSourceFile(inputFileName, input, options.target);
|
||||
let inputFileName = fileName || "module.ts";
|
||||
let sourceFile = createSourceFile(inputFileName, input, options.target);
|
||||
if (moduleName) {
|
||||
sourceFile.moduleName = moduleName;
|
||||
}
|
||||
|
||||
// Store syntactic diagnostics
|
||||
if (diagnostics && sourceFile.parseDiagnostics) {
|
||||
diagnostics.push(...sourceFile.parseDiagnostics);
|
||||
}
|
||||
|
||||
let newLine = getNewLineCharacter(options);
|
||||
|
||||
// Output
|
||||
let outputText: string;
|
||||
|
||||
@@ -1797,13 +1810,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());
|
||||
diagnostics.push(...program.getCompilerOptionsDiagnostics());
|
||||
}
|
||||
|
||||
// Emit
|
||||
@@ -1873,20 +1886,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;
|
||||
}
|
||||
@@ -1896,7 +1917,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,
|
||||
@@ -1928,18 +1949,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
|
||||
@@ -1967,12 +1989,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2400,9 +2422,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getCanonicalFileName(fileName: string) {
|
||||
return useCaseSensitivefileNames ? fileName : fileName.toLowerCase();
|
||||
}
|
||||
let getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames);
|
||||
|
||||
function getValidSourceFile(fileName: string): SourceFile {
|
||||
fileName = normalizeSlashes(fileName);
|
||||
|
||||
@@ -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.*/
|
||||
@@ -270,6 +271,10 @@ 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();
|
||||
if (settingsJson == null || settingsJson == "") {
|
||||
@@ -909,7 +914,7 @@ module ts {
|
||||
|
||||
export class TypeScriptServicesFactory implements ShimFactory {
|
||||
private _shims: Shim[] = [];
|
||||
private documentRegistry: DocumentRegistry = createDocumentRegistry();
|
||||
private documentRegistry: DocumentRegistry;
|
||||
|
||||
/*
|
||||
* Returns script API version.
|
||||
@@ -920,6 +925,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);
|
||||
|
||||
@@ -75,26 +75,26 @@ function delint(sourceFile) {
|
||||
delintNode(sourceFile);
|
||||
function delintNode(node) {
|
||||
switch (node.kind) {
|
||||
case 190 /* ForStatement */:
|
||||
case 191 /* ForInStatement */:
|
||||
case 189 /* WhileStatement */:
|
||||
case 188 /* DoStatement */:
|
||||
if (node.statement.kind !== 183 /* Block */) {
|
||||
case 192 /* ForStatement */:
|
||||
case 193 /* ForInStatement */:
|
||||
case 191 /* WhileStatement */:
|
||||
case 190 /* DoStatement */:
|
||||
if (node.statement.kind !== 185 /* Block */) {
|
||||
report(node, "A looping statement's contents should be wrapped in a block body.");
|
||||
}
|
||||
break;
|
||||
case 187 /* IfStatement */:
|
||||
case 189 /* IfStatement */:
|
||||
var ifStatement = node;
|
||||
if (ifStatement.thenStatement.kind !== 183 /* Block */) {
|
||||
if (ifStatement.thenStatement.kind !== 185 /* Block */) {
|
||||
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
|
||||
}
|
||||
if (ifStatement.elseStatement &&
|
||||
ifStatement.elseStatement.kind !== 183 /* Block */ &&
|
||||
ifStatement.elseStatement.kind !== 187 /* IfStatement */) {
|
||||
ifStatement.elseStatement.kind !== 185 /* Block */ &&
|
||||
ifStatement.elseStatement.kind !== 189 /* IfStatement */) {
|
||||
report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.");
|
||||
}
|
||||
break;
|
||||
case 173 /* BinaryExpression */:
|
||||
case 175 /* 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;
|
||||
}
|
||||
|
||||
@@ -35,14 +35,14 @@ function f1(x: Color | string) {
|
||||
}
|
||||
|
||||
function f2(x: Color | string | string[]) {
|
||||
>f2 : (x: string | string[] | Color) => void
|
||||
>x : string | string[] | Color
|
||||
>f2 : (x: string | Color | string[]) => void
|
||||
>x : string | Color | string[]
|
||||
>Color : Color
|
||||
|
||||
if (typeof x === "object") {
|
||||
>typeof x === "object" : boolean
|
||||
>typeof x : string
|
||||
>x : string | string[] | Color
|
||||
>x : string | Color | string[]
|
||||
>"object" : string
|
||||
|
||||
var y = x;
|
||||
@@ -55,7 +55,7 @@ function f2(x: Color | string | string[]) {
|
||||
if (typeof x === "number") {
|
||||
>typeof x === "number" : boolean
|
||||
>typeof x : string
|
||||
>x : string | string[] | Color
|
||||
>x : string | Color | string[]
|
||||
>"number" : string
|
||||
|
||||
var z = x;
|
||||
@@ -77,7 +77,7 @@ function f2(x: Color | string | string[]) {
|
||||
if (typeof x === "string") {
|
||||
>typeof x === "string" : boolean
|
||||
>typeof x : string
|
||||
>x : string | string[] | Color
|
||||
>x : string | Color | string[]
|
||||
>"string" : string
|
||||
|
||||
var a = x;
|
||||
@@ -89,11 +89,11 @@ function f2(x: Color | string | string[]) {
|
||||
}
|
||||
else {
|
||||
var b = x;
|
||||
>b : string[] | Color
|
||||
>x : string[] | Color
|
||||
>b : Color | string[]
|
||||
>x : Color | string[]
|
||||
|
||||
var b: Color | string[];
|
||||
>b : string[] | Color
|
||||
>b : Color | string[]
|
||||
>Color : Color
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// Empty array literal with no contextual type has type Undefined[]
|
||||
|
||||
var arr1= [[], [1], ['']];
|
||||
>arr1 : (string[] | number[])[]
|
||||
>[[], [1], ['']] : (string[] | number[])[]
|
||||
>arr1 : (number[] | string[])[]
|
||||
>[[], [1], ['']] : (number[] | string[])[]
|
||||
>[] : undefined[]
|
||||
>[1] : number[]
|
||||
>1 : number
|
||||
@@ -11,8 +11,8 @@ var arr1= [[], [1], ['']];
|
||||
>'' : string
|
||||
|
||||
var arr2 = [[null], [1], ['']];
|
||||
>arr2 : (string[] | number[])[]
|
||||
>[[null], [1], ['']] : (string[] | number[])[]
|
||||
>arr2 : (number[] | string[])[]
|
||||
>[[null], [1], ['']] : (number[] | string[])[]
|
||||
>[null] : null[]
|
||||
>null : null
|
||||
>[1] : number[]
|
||||
|
||||
@@ -8,8 +8,8 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(17,5): error
|
||||
Type '() => string | number | boolean' is not assignable to type '() => number'.
|
||||
Type 'string | number | boolean' is not assignable to type 'number'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(32,5): error TS2322: Type '(string[] | number[])[]' is not assignable to type 'tup'.
|
||||
Property '0' is missing in type '(string[] | number[])[]'.
|
||||
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(32,5): error TS2322: Type '(number[] | string[])[]' is not assignable to type 'tup'.
|
||||
Property '0' is missing in type '(number[] | string[])[]'.
|
||||
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(33,5): error TS2322: Type 'number[]' is not assignable to type '[number, number, number]'.
|
||||
Property '0' is missing in type 'number[]'.
|
||||
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error TS2322: Type '(string | number)[]' is not assignable to type 'myArray'.
|
||||
@@ -68,8 +68,8 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error
|
||||
interface myArray2 extends Array<Number|String> { }
|
||||
var c0: tup = [...temp2]; // Error
|
||||
~~
|
||||
!!! error TS2322: Type '(string[] | number[])[]' is not assignable to type 'tup'.
|
||||
!!! error TS2322: Property '0' is missing in type '(string[] | number[])[]'.
|
||||
!!! error TS2322: Type '(number[] | string[])[]' is not assignable to type 'tup'.
|
||||
!!! error TS2322: Property '0' is missing in type '(number[] | string[])[]'.
|
||||
var c1: [number, number, number] = [...temp1]; // Error cannot assign number[] to [number, number, number]
|
||||
~~
|
||||
!!! error TS2322: Type 'number[]' is not assignable to type '[number, number, number]'.
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
//// [asiPreventsParsingAsAmbientExternalModule01.ts]
|
||||
|
||||
var declare: number;
|
||||
var module: string;
|
||||
|
||||
declare // this is the identifier 'declare'
|
||||
module // this is the identifier 'module'
|
||||
"my external module" // this is just a string
|
||||
{ } // this is a block body
|
||||
|
||||
//// [asiPreventsParsingAsAmbientExternalModule01.js]
|
||||
var declare;
|
||||
var module;
|
||||
declare; // this is the identifier 'declare'
|
||||
module; // this is the identifier 'module'
|
||||
"my external module"; // this is just a string
|
||||
{ } // this is a block body
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/conformance/externalModules/asiPreventsParsingAsAmbientExternalModule01.ts ===
|
||||
|
||||
var declare: number;
|
||||
>declare : Symbol(declare, Decl(asiPreventsParsingAsAmbientExternalModule01.ts, 1, 3))
|
||||
|
||||
var module: string;
|
||||
>module : Symbol(module, Decl(asiPreventsParsingAsAmbientExternalModule01.ts, 2, 3))
|
||||
|
||||
declare // this is the identifier 'declare'
|
||||
>declare : Symbol(declare, Decl(asiPreventsParsingAsAmbientExternalModule01.ts, 1, 3))
|
||||
|
||||
module // this is the identifier 'module'
|
||||
>module : Symbol(module, Decl(asiPreventsParsingAsAmbientExternalModule01.ts, 2, 3))
|
||||
|
||||
"my external module" // this is just a string
|
||||
{ } // this is a block body
|
||||
@@ -0,0 +1,18 @@
|
||||
=== tests/cases/conformance/externalModules/asiPreventsParsingAsAmbientExternalModule01.ts ===
|
||||
|
||||
var declare: number;
|
||||
>declare : number
|
||||
|
||||
var module: string;
|
||||
>module : string
|
||||
|
||||
declare // this is the identifier 'declare'
|
||||
>declare : number
|
||||
|
||||
module // this is the identifier 'module'
|
||||
>module : string
|
||||
|
||||
"my external module" // this is just a string
|
||||
>"my external module" : string
|
||||
|
||||
{ } // this is a block body
|
||||
@@ -0,0 +1,22 @@
|
||||
//// [asiPreventsParsingAsAmbientExternalModule02.ts]
|
||||
|
||||
var declare: number;
|
||||
var module: string;
|
||||
|
||||
module container {
|
||||
declare // this is the identifier 'declare'
|
||||
module // this is the identifier 'module'
|
||||
"my external module" // this is just a string
|
||||
{ } // this is a block body
|
||||
}
|
||||
|
||||
//// [asiPreventsParsingAsAmbientExternalModule02.js]
|
||||
var declare;
|
||||
var module;
|
||||
var container;
|
||||
(function (container) {
|
||||
declare; // this is the identifier 'declare'
|
||||
module; // this is the identifier 'module'
|
||||
"my external module"; // this is just a string
|
||||
{ } // this is a block body
|
||||
})(container || (container = {}));
|
||||
@@ -0,0 +1,20 @@
|
||||
=== tests/cases/conformance/externalModules/asiPreventsParsingAsAmbientExternalModule02.ts ===
|
||||
|
||||
var declare: number;
|
||||
>declare : Symbol(declare, Decl(asiPreventsParsingAsAmbientExternalModule02.ts, 1, 3))
|
||||
|
||||
var module: string;
|
||||
>module : Symbol(module, Decl(asiPreventsParsingAsAmbientExternalModule02.ts, 2, 3))
|
||||
|
||||
module container {
|
||||
>container : Symbol(container, Decl(asiPreventsParsingAsAmbientExternalModule02.ts, 2, 19))
|
||||
|
||||
declare // this is the identifier 'declare'
|
||||
>declare : Symbol(declare, Decl(asiPreventsParsingAsAmbientExternalModule02.ts, 1, 3))
|
||||
|
||||
module // this is the identifier 'module'
|
||||
>module : Symbol(module, Decl(asiPreventsParsingAsAmbientExternalModule02.ts, 2, 3))
|
||||
|
||||
"my external module" // this is just a string
|
||||
{ } // this is a block body
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
=== tests/cases/conformance/externalModules/asiPreventsParsingAsAmbientExternalModule02.ts ===
|
||||
|
||||
var declare: number;
|
||||
>declare : number
|
||||
|
||||
var module: string;
|
||||
>module : string
|
||||
|
||||
module container {
|
||||
>container : typeof container
|
||||
|
||||
declare // this is the identifier 'declare'
|
||||
>declare : number
|
||||
|
||||
module // this is the identifier 'module'
|
||||
>module : string
|
||||
|
||||
"my external module" // this is just a string
|
||||
>"my external module" : string
|
||||
|
||||
{ } // this is a block body
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [asiPreventsParsingAsInterface01.ts]
|
||||
|
||||
var interface: number, I: string;
|
||||
|
||||
interface // This should be the identifier 'interface'
|
||||
I // This should be the identifier 'I'
|
||||
{} // This should be a block body
|
||||
|
||||
//// [asiPreventsParsingAsInterface01.js]
|
||||
var interface, I;
|
||||
interface; // This should be the identifier 'interface'
|
||||
I; // This should be the identifier 'I'
|
||||
{ } // This should be a block body
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/conformance/interfaces/interfaceDeclarations/asiPreventsParsingAsInterface01.ts ===
|
||||
|
||||
var interface: number, I: string;
|
||||
>interface : Symbol(interface, Decl(asiPreventsParsingAsInterface01.ts, 1, 3))
|
||||
>I : Symbol(I, Decl(asiPreventsParsingAsInterface01.ts, 1, 22))
|
||||
|
||||
interface // This should be the identifier 'interface'
|
||||
>interface : Symbol(interface, Decl(asiPreventsParsingAsInterface01.ts, 1, 3))
|
||||
|
||||
I // This should be the identifier 'I'
|
||||
>I : Symbol(I, Decl(asiPreventsParsingAsInterface01.ts, 1, 22))
|
||||
|
||||
{} // This should be a block body
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/conformance/interfaces/interfaceDeclarations/asiPreventsParsingAsInterface01.ts ===
|
||||
|
||||
var interface: number, I: string;
|
||||
>interface : number
|
||||
>I : string
|
||||
|
||||
interface // This should be the identifier 'interface'
|
||||
>interface : number
|
||||
|
||||
I // This should be the identifier 'I'
|
||||
>I : string
|
||||
|
||||
{} // This should be a block body
|
||||
@@ -0,0 +1,14 @@
|
||||
//// [asiPreventsParsingAsInterface02.ts]
|
||||
|
||||
function f(interface: number, I: string) {
|
||||
interface // This should be the identifier 'interface'
|
||||
I // This should be the identifier 'I'
|
||||
{} // This should be a block body
|
||||
}
|
||||
|
||||
//// [asiPreventsParsingAsInterface02.js]
|
||||
function f(interface, I) {
|
||||
interface; // This should be the identifier 'interface'
|
||||
I; // This should be the identifier 'I'
|
||||
{ } // This should be a block body
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
=== tests/cases/conformance/interfaces/interfaceDeclarations/asiPreventsParsingAsInterface02.ts ===
|
||||
|
||||
function f(interface: number, I: string) {
|
||||
>f : Symbol(f, Decl(asiPreventsParsingAsInterface02.ts, 0, 0))
|
||||
>interface : Symbol(interface, Decl(asiPreventsParsingAsInterface02.ts, 1, 11))
|
||||
>I : Symbol(I, Decl(asiPreventsParsingAsInterface02.ts, 1, 29))
|
||||
|
||||
interface // This should be the identifier 'interface'
|
||||
>interface : Symbol(interface, Decl(asiPreventsParsingAsInterface02.ts, 1, 11))
|
||||
|
||||
I // This should be the identifier 'I'
|
||||
>I : Symbol(I, Decl(asiPreventsParsingAsInterface02.ts, 1, 29))
|
||||
|
||||
{} // This should be a block body
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
=== tests/cases/conformance/interfaces/interfaceDeclarations/asiPreventsParsingAsInterface02.ts ===
|
||||
|
||||
function f(interface: number, I: string) {
|
||||
>f : (interface: number, I: string) => void
|
||||
>interface : number
|
||||
>I : string
|
||||
|
||||
interface // This should be the identifier 'interface'
|
||||
>interface : number
|
||||
|
||||
I // This should be the identifier 'I'
|
||||
>I : string
|
||||
|
||||
{} // This should be a block body
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
//// [asiPreventsParsingAsInterface03.ts]
|
||||
|
||||
var interface: number, I: string;
|
||||
|
||||
namespace n {
|
||||
interface // This should be the identifier 'interface'
|
||||
I // This should be the identifier 'I'
|
||||
{} // This should be a block body
|
||||
}
|
||||
|
||||
//// [asiPreventsParsingAsInterface03.js]
|
||||
var interface, I;
|
||||
var n;
|
||||
(function (n) {
|
||||
interface; // This should be the identifier 'interface'
|
||||
I; // This should be the identifier 'I'
|
||||
{ } // This should be a block body
|
||||
})(n || (n = {}));
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/interfaces/interfaceDeclarations/asiPreventsParsingAsInterface03.ts ===
|
||||
|
||||
var interface: number, I: string;
|
||||
>interface : Symbol(interface, Decl(asiPreventsParsingAsInterface03.ts, 1, 3))
|
||||
>I : Symbol(I, Decl(asiPreventsParsingAsInterface03.ts, 1, 22))
|
||||
|
||||
namespace n {
|
||||
>n : Symbol(n, Decl(asiPreventsParsingAsInterface03.ts, 1, 33))
|
||||
|
||||
interface // This should be the identifier 'interface'
|
||||
>interface : Symbol(interface, Decl(asiPreventsParsingAsInterface03.ts, 1, 3))
|
||||
|
||||
I // This should be the identifier 'I'
|
||||
>I : Symbol(I, Decl(asiPreventsParsingAsInterface03.ts, 1, 22))
|
||||
|
||||
{} // This should be a block body
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/interfaces/interfaceDeclarations/asiPreventsParsingAsInterface03.ts ===
|
||||
|
||||
var interface: number, I: string;
|
||||
>interface : number
|
||||
>I : string
|
||||
|
||||
namespace n {
|
||||
>n : typeof n
|
||||
|
||||
interface // This should be the identifier 'interface'
|
||||
>interface : number
|
||||
|
||||
I // This should be the identifier 'I'
|
||||
>I : string
|
||||
|
||||
{} // This should be a block body
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//// [asiPreventsParsingAsInterface04.ts]
|
||||
|
||||
var declare: boolean, interface: number, I: string;
|
||||
|
||||
declare // This should be the identifier 'declare'
|
||||
interface // This should be the identifier 'interface'
|
||||
I // This should be the identifier 'I'
|
||||
{} // This should be a block body
|
||||
|
||||
//// [asiPreventsParsingAsInterface04.js]
|
||||
var declare, interface, I;
|
||||
declare; // This should be the identifier 'declare'
|
||||
interface; // This should be the identifier 'interface'
|
||||
I; // This should be the identifier 'I'
|
||||
{ } // This should be a block body
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/interfaces/interfaceDeclarations/asiPreventsParsingAsInterface04.ts ===
|
||||
|
||||
var declare: boolean, interface: number, I: string;
|
||||
>declare : Symbol(declare, Decl(asiPreventsParsingAsInterface04.ts, 1, 3))
|
||||
>interface : Symbol(interface, Decl(asiPreventsParsingAsInterface04.ts, 1, 21))
|
||||
>I : Symbol(I, Decl(asiPreventsParsingAsInterface04.ts, 1, 40))
|
||||
|
||||
declare // This should be the identifier 'declare'
|
||||
>declare : Symbol(declare, Decl(asiPreventsParsingAsInterface04.ts, 1, 3))
|
||||
|
||||
interface // This should be the identifier 'interface'
|
||||
>interface : Symbol(interface, Decl(asiPreventsParsingAsInterface04.ts, 1, 21))
|
||||
|
||||
I // This should be the identifier 'I'
|
||||
>I : Symbol(I, Decl(asiPreventsParsingAsInterface04.ts, 1, 40))
|
||||
|
||||
{} // This should be a block body
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/interfaces/interfaceDeclarations/asiPreventsParsingAsInterface04.ts ===
|
||||
|
||||
var declare: boolean, interface: number, I: string;
|
||||
>declare : boolean
|
||||
>interface : number
|
||||
>I : string
|
||||
|
||||
declare // This should be the identifier 'declare'
|
||||
>declare : boolean
|
||||
|
||||
interface // This should be the identifier 'interface'
|
||||
>interface : number
|
||||
|
||||
I // This should be the identifier 'I'
|
||||
>I : string
|
||||
|
||||
{} // This should be a block body
|
||||
@@ -0,0 +1,24 @@
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/asiPreventsParsingAsInterface05.ts(3,5): error TS1212: Identifier expected. 'interface' is a reserved word in strict mode
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/asiPreventsParsingAsInterface05.ts(10,1): error TS1212: Identifier expected. 'interface' is a reserved word in strict mode
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/asiPreventsParsingAsInterface05.ts(11,1): error TS2304: Cannot find name 'I'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/interfaces/interfaceDeclarations/asiPreventsParsingAsInterface05.ts (3 errors) ====
|
||||
"use strict"
|
||||
|
||||
var interface: number;
|
||||
~~~~~~~~~
|
||||
!!! error TS1212: Identifier expected. 'interface' is a reserved word in strict mode
|
||||
|
||||
// 'interface' is a strict mode reserved word, and so it would be permissible
|
||||
// to allow 'interface' and the name of the interface to be on separate lines;
|
||||
// however, this complicates things, and so it is preferable to restrict interface
|
||||
// declarations such that their identifier must follow 'interface' on the same line.
|
||||
|
||||
interface // This should be the identifier 'interface'
|
||||
~~~~~~~~~
|
||||
!!! error TS1212: Identifier expected. 'interface' is a reserved word in strict mode
|
||||
I // This should be the identifier 'I'
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'I'.
|
||||
{ } // This should be a block body
|
||||
@@ -0,0 +1,24 @@
|
||||
//// [asiPreventsParsingAsInterface05.ts]
|
||||
"use strict"
|
||||
|
||||
var interface: number;
|
||||
|
||||
// 'interface' is a strict mode reserved word, and so it would be permissible
|
||||
// to allow 'interface' and the name of the interface to be on separate lines;
|
||||
// however, this complicates things, and so it is preferable to restrict interface
|
||||
// declarations such that their identifier must follow 'interface' on the same line.
|
||||
|
||||
interface // This should be the identifier 'interface'
|
||||
I // This should be the identifier 'I'
|
||||
{ } // This should be a block body
|
||||
|
||||
//// [asiPreventsParsingAsInterface05.js]
|
||||
"use strict";
|
||||
var interface;
|
||||
// 'interface' is a strict mode reserved word, and so it would be permissible
|
||||
// to allow 'interface' and the name of the interface to be on separate lines;
|
||||
// however, this complicates things, and so it is preferable to restrict interface
|
||||
// declarations such that their identifier must follow 'interface' on the same line.
|
||||
interface; // This should be the identifier 'interface'
|
||||
I; // This should be the identifier 'I'
|
||||
{ } // This should be a block body
|
||||
@@ -0,0 +1,15 @@
|
||||
//// [asiPreventsParsingAsNamespace01.ts]
|
||||
|
||||
var namespace: number;
|
||||
var n: string;
|
||||
|
||||
namespace // this is the identifier 'namespace'
|
||||
n // this is the identifier 'n'
|
||||
{ } // this is a block body
|
||||
|
||||
//// [asiPreventsParsingAsNamespace01.js]
|
||||
var namespace;
|
||||
var n;
|
||||
namespace; // this is the identifier 'namespace'
|
||||
n; // this is the identifier 'n'
|
||||
{ } // this is a block body
|
||||
@@ -0,0 +1,15 @@
|
||||
=== tests/cases/conformance/internalModules/moduleDeclarations/asiPreventsParsingAsNamespace01.ts ===
|
||||
|
||||
var namespace: number;
|
||||
>namespace : Symbol(namespace, Decl(asiPreventsParsingAsNamespace01.ts, 1, 3))
|
||||
|
||||
var n: string;
|
||||
>n : Symbol(n, Decl(asiPreventsParsingAsNamespace01.ts, 2, 3))
|
||||
|
||||
namespace // this is the identifier 'namespace'
|
||||
>namespace : Symbol(namespace, Decl(asiPreventsParsingAsNamespace01.ts, 1, 3))
|
||||
|
||||
n // this is the identifier 'n'
|
||||
>n : Symbol(n, Decl(asiPreventsParsingAsNamespace01.ts, 2, 3))
|
||||
|
||||
{ } // this is a block body
|
||||
@@ -0,0 +1,15 @@
|
||||
=== tests/cases/conformance/internalModules/moduleDeclarations/asiPreventsParsingAsNamespace01.ts ===
|
||||
|
||||
var namespace: number;
|
||||
>namespace : number
|
||||
|
||||
var n: string;
|
||||
>n : string
|
||||
|
||||
namespace // this is the identifier 'namespace'
|
||||
>namespace : number
|
||||
|
||||
n // this is the identifier 'n'
|
||||
>n : string
|
||||
|
||||
{ } // this is a block body
|
||||
@@ -0,0 +1,15 @@
|
||||
//// [asiPreventsParsingAsNamespace02.ts]
|
||||
|
||||
var module: number;
|
||||
var m: string;
|
||||
|
||||
module // this is the identifier 'namespace'
|
||||
m // this is the identifier 'm'
|
||||
{ } // this is a block body
|
||||
|
||||
//// [asiPreventsParsingAsNamespace02.js]
|
||||
var module;
|
||||
var m;
|
||||
module; // this is the identifier 'namespace'
|
||||
m; // this is the identifier 'm'
|
||||
{ } // this is a block body
|
||||
@@ -0,0 +1,15 @@
|
||||
=== tests/cases/conformance/internalModules/moduleDeclarations/asiPreventsParsingAsNamespace02.ts ===
|
||||
|
||||
var module: number;
|
||||
>module : Symbol(module, Decl(asiPreventsParsingAsNamespace02.ts, 1, 3))
|
||||
|
||||
var m: string;
|
||||
>m : Symbol(m, Decl(asiPreventsParsingAsNamespace02.ts, 2, 3))
|
||||
|
||||
module // this is the identifier 'namespace'
|
||||
>module : Symbol(module, Decl(asiPreventsParsingAsNamespace02.ts, 1, 3))
|
||||
|
||||
m // this is the identifier 'm'
|
||||
>m : Symbol(m, Decl(asiPreventsParsingAsNamespace02.ts, 2, 3))
|
||||
|
||||
{ } // this is a block body
|
||||
@@ -0,0 +1,15 @@
|
||||
=== tests/cases/conformance/internalModules/moduleDeclarations/asiPreventsParsingAsNamespace02.ts ===
|
||||
|
||||
var module: number;
|
||||
>module : number
|
||||
|
||||
var m: string;
|
||||
>m : string
|
||||
|
||||
module // this is the identifier 'namespace'
|
||||
>module : number
|
||||
|
||||
m // this is the identifier 'm'
|
||||
>m : string
|
||||
|
||||
{ } // this is a block body
|
||||
@@ -0,0 +1,20 @@
|
||||
//// [asiPreventsParsingAsNamespace03.ts]
|
||||
|
||||
var namespace: number;
|
||||
var n: string;
|
||||
|
||||
namespace container {
|
||||
namespace // this is the identifier 'namespace'
|
||||
n // this is the identifier 'n'
|
||||
{ } // this is a block body
|
||||
}
|
||||
|
||||
//// [asiPreventsParsingAsNamespace03.js]
|
||||
var namespace;
|
||||
var n;
|
||||
var container;
|
||||
(function (container) {
|
||||
namespace; // this is the identifier 'namespace'
|
||||
n; // this is the identifier 'n'
|
||||
{ } // this is a block body
|
||||
})(container || (container = {}));
|
||||
@@ -0,0 +1,19 @@
|
||||
=== tests/cases/conformance/internalModules/moduleDeclarations/asiPreventsParsingAsNamespace03.ts ===
|
||||
|
||||
var namespace: number;
|
||||
>namespace : Symbol(namespace, Decl(asiPreventsParsingAsNamespace03.ts, 1, 3))
|
||||
|
||||
var n: string;
|
||||
>n : Symbol(n, Decl(asiPreventsParsingAsNamespace03.ts, 2, 3))
|
||||
|
||||
namespace container {
|
||||
>container : Symbol(container, Decl(asiPreventsParsingAsNamespace03.ts, 2, 14))
|
||||
|
||||
namespace // this is the identifier 'namespace'
|
||||
>namespace : Symbol(namespace, Decl(asiPreventsParsingAsNamespace03.ts, 1, 3))
|
||||
|
||||
n // this is the identifier 'n'
|
||||
>n : Symbol(n, Decl(asiPreventsParsingAsNamespace03.ts, 2, 3))
|
||||
|
||||
{ } // this is a block body
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
=== tests/cases/conformance/internalModules/moduleDeclarations/asiPreventsParsingAsNamespace03.ts ===
|
||||
|
||||
var namespace: number;
|
||||
>namespace : number
|
||||
|
||||
var n: string;
|
||||
>n : string
|
||||
|
||||
namespace container {
|
||||
>container : typeof container
|
||||
|
||||
namespace // this is the identifier 'namespace'
|
||||
>namespace : number
|
||||
|
||||
n // this is the identifier 'n'
|
||||
>n : string
|
||||
|
||||
{ } // this is a block body
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
//// [asiPreventsParsingAsNamespace04.ts]
|
||||
|
||||
let module = 10;
|
||||
module in {}
|
||||
|
||||
//// [asiPreventsParsingAsNamespace04.js]
|
||||
var module = 10;
|
||||
module in {};
|
||||
@@ -0,0 +1,8 @@
|
||||
=== tests/cases/conformance/internalModules/moduleDeclarations/asiPreventsParsingAsNamespace04.ts ===
|
||||
|
||||
let module = 10;
|
||||
>module : Symbol(module, Decl(asiPreventsParsingAsNamespace04.ts, 1, 3))
|
||||
|
||||
module in {}
|
||||
>module : Symbol(module, Decl(asiPreventsParsingAsNamespace04.ts, 1, 3))
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
=== tests/cases/conformance/internalModules/moduleDeclarations/asiPreventsParsingAsNamespace04.ts ===
|
||||
|
||||
let module = 10;
|
||||
>module : number
|
||||
>10 : number
|
||||
|
||||
module in {}
|
||||
>module in {} : boolean
|
||||
>module : number
|
||||
>{} : {}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//// [asiPreventsParsingAsNamespace05.ts]
|
||||
|
||||
let namespace = 10;
|
||||
namespace a.b {
|
||||
export let c = 20;
|
||||
}
|
||||
|
||||
namespace
|
||||
a.b.c
|
||||
{
|
||||
}
|
||||
|
||||
//// [asiPreventsParsingAsNamespace05.js]
|
||||
var namespace = 10;
|
||||
var a;
|
||||
(function (a) {
|
||||
var b;
|
||||
(function (b) {
|
||||
b.c = 20;
|
||||
})(b = a.b || (a.b = {}));
|
||||
})(a || (a = {}));
|
||||
namespace;
|
||||
a.b.c;
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
=== tests/cases/conformance/internalModules/moduleDeclarations/asiPreventsParsingAsNamespace05.ts ===
|
||||
|
||||
let namespace = 10;
|
||||
>namespace : Symbol(namespace, Decl(asiPreventsParsingAsNamespace05.ts, 1, 3))
|
||||
|
||||
namespace a.b {
|
||||
>a : Symbol(a, Decl(asiPreventsParsingAsNamespace05.ts, 1, 19))
|
||||
>b : Symbol(b, Decl(asiPreventsParsingAsNamespace05.ts, 2, 12))
|
||||
|
||||
export let c = 20;
|
||||
>c : Symbol(c, Decl(asiPreventsParsingAsNamespace05.ts, 3, 14))
|
||||
}
|
||||
|
||||
namespace
|
||||
>namespace : Symbol(namespace, Decl(asiPreventsParsingAsNamespace05.ts, 1, 3))
|
||||
|
||||
a.b.c
|
||||
>a.b.c : Symbol(a.b.c, Decl(asiPreventsParsingAsNamespace05.ts, 3, 14))
|
||||
>a.b : Symbol(a.b, Decl(asiPreventsParsingAsNamespace05.ts, 2, 12))
|
||||
>a : Symbol(a, Decl(asiPreventsParsingAsNamespace05.ts, 1, 19))
|
||||
>b : Symbol(a.b, Decl(asiPreventsParsingAsNamespace05.ts, 2, 12))
|
||||
>c : Symbol(a.b.c, Decl(asiPreventsParsingAsNamespace05.ts, 3, 14))
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
=== tests/cases/conformance/internalModules/moduleDeclarations/asiPreventsParsingAsNamespace05.ts ===
|
||||
|
||||
let namespace = 10;
|
||||
>namespace : number
|
||||
>10 : number
|
||||
|
||||
namespace a.b {
|
||||
>a : typeof a
|
||||
>b : typeof b
|
||||
|
||||
export let c = 20;
|
||||
>c : number
|
||||
>20 : number
|
||||
}
|
||||
|
||||
namespace
|
||||
>namespace : number
|
||||
|
||||
a.b.c
|
||||
>a.b.c : number
|
||||
>a.b : typeof a.b
|
||||
>a : typeof a
|
||||
>b : typeof a.b
|
||||
>c : number
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//// [asiPreventsParsingAsTypeAlias01.ts]
|
||||
|
||||
var type;
|
||||
var string;
|
||||
var Foo;
|
||||
|
||||
type
|
||||
Foo = string;
|
||||
|
||||
//// [asiPreventsParsingAsTypeAlias01.js]
|
||||
var type;
|
||||
var string;
|
||||
var Foo;
|
||||
type;
|
||||
Foo = string;
|
||||
@@ -0,0 +1,18 @@
|
||||
=== tests/cases/conformance/types/typeAliases/asiPreventsParsingAsTypeAlias01.ts ===
|
||||
|
||||
var type;
|
||||
>type : Symbol(type, Decl(asiPreventsParsingAsTypeAlias01.ts, 1, 3))
|
||||
|
||||
var string;
|
||||
>string : Symbol(string, Decl(asiPreventsParsingAsTypeAlias01.ts, 2, 3))
|
||||
|
||||
var Foo;
|
||||
>Foo : Symbol(Foo, Decl(asiPreventsParsingAsTypeAlias01.ts, 3, 3))
|
||||
|
||||
type
|
||||
>type : Symbol(type, Decl(asiPreventsParsingAsTypeAlias01.ts, 1, 3))
|
||||
|
||||
Foo = string;
|
||||
>Foo : Symbol(Foo, Decl(asiPreventsParsingAsTypeAlias01.ts, 3, 3))
|
||||
>string : Symbol(string, Decl(asiPreventsParsingAsTypeAlias01.ts, 2, 3))
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
=== tests/cases/conformance/types/typeAliases/asiPreventsParsingAsTypeAlias01.ts ===
|
||||
|
||||
var type;
|
||||
>type : any
|
||||
|
||||
var string;
|
||||
>string : any
|
||||
|
||||
var Foo;
|
||||
>Foo : any
|
||||
|
||||
type
|
||||
>type : any
|
||||
|
||||
Foo = string;
|
||||
>Foo = string : any
|
||||
>Foo : any
|
||||
>string : any
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
//// [asiPreventsParsingAsTypeAlias02.ts]
|
||||
|
||||
var type;
|
||||
var string;
|
||||
var Foo;
|
||||
|
||||
namespace container {
|
||||
type
|
||||
Foo = string;
|
||||
}
|
||||
|
||||
//// [asiPreventsParsingAsTypeAlias02.js]
|
||||
var type;
|
||||
var string;
|
||||
var Foo;
|
||||
var container;
|
||||
(function (container) {
|
||||
type;
|
||||
Foo = string;
|
||||
})(container || (container = {}));
|
||||
@@ -0,0 +1,21 @@
|
||||
=== tests/cases/conformance/types/typeAliases/asiPreventsParsingAsTypeAlias02.ts ===
|
||||
|
||||
var type;
|
||||
>type : Symbol(type, Decl(asiPreventsParsingAsTypeAlias02.ts, 1, 3))
|
||||
|
||||
var string;
|
||||
>string : Symbol(string, Decl(asiPreventsParsingAsTypeAlias02.ts, 2, 3))
|
||||
|
||||
var Foo;
|
||||
>Foo : Symbol(Foo, Decl(asiPreventsParsingAsTypeAlias02.ts, 3, 3))
|
||||
|
||||
namespace container {
|
||||
>container : Symbol(container, Decl(asiPreventsParsingAsTypeAlias02.ts, 3, 8))
|
||||
|
||||
type
|
||||
>type : Symbol(type, Decl(asiPreventsParsingAsTypeAlias02.ts, 1, 3))
|
||||
|
||||
Foo = string;
|
||||
>Foo : Symbol(Foo, Decl(asiPreventsParsingAsTypeAlias02.ts, 3, 3))
|
||||
>string : Symbol(string, Decl(asiPreventsParsingAsTypeAlias02.ts, 2, 3))
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
=== tests/cases/conformance/types/typeAliases/asiPreventsParsingAsTypeAlias02.ts ===
|
||||
|
||||
var type;
|
||||
>type : any
|
||||
|
||||
var string;
|
||||
>string : any
|
||||
|
||||
var Foo;
|
||||
>Foo : any
|
||||
|
||||
namespace container {
|
||||
>container : typeof container
|
||||
|
||||
type
|
||||
>type : any
|
||||
|
||||
Foo = string;
|
||||
>Foo = string : any
|
||||
>Foo : any
|
||||
>string : any
|
||||
}
|
||||
@@ -14,9 +14,9 @@ var C = (function () {
|
||||
return C;
|
||||
})();
|
||||
{
|
||||
var C = (function () {
|
||||
function C() {
|
||||
var C_1 = (function () {
|
||||
function C_1() {
|
||||
}
|
||||
return C;
|
||||
return C_1;
|
||||
})();
|
||||
}
|
||||
@@ -18,12 +18,12 @@ function f() {
|
||||
})();
|
||||
var c1 = C;
|
||||
{
|
||||
var C = (function () {
|
||||
function C() {
|
||||
var C_1 = (function () {
|
||||
function C_1() {
|
||||
}
|
||||
return C;
|
||||
return C_1;
|
||||
})();
|
||||
var c2 = C;
|
||||
var c2 = C_1;
|
||||
}
|
||||
return C === c1;
|
||||
}
|
||||
@@ -17,9 +17,9 @@ declare function foo<T>(obj: I<T>): T
|
||||
>T : T
|
||||
|
||||
foo({
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | number | boolean | number[] | (() => void)
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | number | boolean | (() => void) | number[]
|
||||
>foo : <T>(obj: I<T>) => T
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | number | boolean | number[] | (() => void); 0: () => void; p: string; }
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | number | boolean | (() => void) | number[]; 0: () => void; p: string; }
|
||||
|
||||
p: "",
|
||||
>p : string
|
||||
|
||||
@@ -17,9 +17,9 @@ declare function foo<T>(obj: I<T>): T
|
||||
>T : T
|
||||
|
||||
foo({
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | number | boolean | number[] | (() => void)
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | number | boolean | (() => void) | number[]
|
||||
>foo : <T>(obj: I<T>) => T
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | number | boolean | number[] | (() => void); 0: () => void; p: string; }
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | number | boolean | (() => void) | number[]; 0: () => void; p: string; }
|
||||
|
||||
p: "",
|
||||
>p : string
|
||||
|
||||
@@ -17,9 +17,9 @@ declare function foo<T>(obj: I<T>): T
|
||||
>T : T
|
||||
|
||||
foo({
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : number | number[] | (() => void)
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : number | (() => void) | number[]
|
||||
>foo : <T>(obj: I<T>) => T
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: number]: number | number[] | (() => void); 0: () => void; p: string; }
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: number]: number | (() => void) | number[]; 0: () => void; p: string; }
|
||||
|
||||
p: "",
|
||||
>p : string
|
||||
|
||||
@@ -17,9 +17,9 @@ declare function foo<T>(obj: I<T>): T
|
||||
>T : T
|
||||
|
||||
foo({
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : number | number[] | (() => void)
|
||||
>foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : number | (() => void) | number[]
|
||||
>foo : <T>(obj: I<T>) => T
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: number]: number | number[] | (() => void); 0: () => void; p: string; }
|
||||
>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: number]: number | (() => void) | number[]; 0: () => void; p: string; }
|
||||
|
||||
p: "",
|
||||
>p : string
|
||||
|
||||
@@ -120,35 +120,35 @@ var b = baz(b, b, g); // Should be number | string
|
||||
>g : <T>(x: T, y: T) => T
|
||||
|
||||
var d: number[] | string[];
|
||||
>d : string[] | number[]
|
||||
>d : number[] | string[]
|
||||
|
||||
var d = foo(h); // Should be number[] | string[]
|
||||
>d : string[] | number[]
|
||||
>foo(h) : string[] | number[]
|
||||
>d : number[] | string[]
|
||||
>foo(h) : number[] | string[]
|
||||
>foo : <T>(cb: (x: number, y: string) => T) => T
|
||||
>h : <T, U>(x: T, y: U) => T[] | U[]
|
||||
|
||||
var d = bar(1, "one", h); // Should be number[] | string[]
|
||||
>d : string[] | number[]
|
||||
>bar(1, "one", h) : string[] | number[]
|
||||
>d : number[] | string[]
|
||||
>bar(1, "one", h) : number[] | string[]
|
||||
>bar : <T, U, V>(x: T, y: U, cb: (x: T, y: U) => V) => V
|
||||
>1 : number
|
||||
>"one" : string
|
||||
>h : <T, U>(x: T, y: U) => T[] | U[]
|
||||
|
||||
var d = bar("one", 1, h); // Should be number[] | string[]
|
||||
>d : string[] | number[]
|
||||
>bar("one", 1, h) : string[] | number[]
|
||||
>d : number[] | string[]
|
||||
>bar("one", 1, h) : number[] | string[]
|
||||
>bar : <T, U, V>(x: T, y: U, cb: (x: T, y: U) => V) => V
|
||||
>"one" : string
|
||||
>1 : number
|
||||
>h : <T, U>(x: T, y: U) => T[] | U[]
|
||||
|
||||
var d = baz(d, d, g); // Should be number[] | string[]
|
||||
>d : string[] | number[]
|
||||
>baz(d, d, g) : string[] | number[]
|
||||
>d : number[] | string[]
|
||||
>baz(d, d, g) : number[] | string[]
|
||||
>baz : <T, U>(x: T, y: T, cb: (x: T, y: T) => U) => U
|
||||
>d : string[] | number[]
|
||||
>d : string[] | number[]
|
||||
>d : number[] | string[]
|
||||
>d : number[] | string[]
|
||||
>g : <T>(x: T, y: T) => T
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
tests/cases/compiler/contextualTyping.ts(189,18): error TS2384: Overload signatures must all be ambient or non-ambient.\ntests/cases/compiler/contextualTyping.ts(197,15): error TS2300: Duplicate identifier 'Point'.\ntests/cases/compiler/contextualTyping.ts(207,10): error TS2300: Duplicate identifier 'Point'.\ntests/cases/compiler/contextualTyping.ts(230,5): error TS2322: Type '{}' is not assignable to type 'B'.
|
||||
Property 'x' is missing in type '{}'.\n\n\n==== tests/cases/compiler/contextualTyping.ts (4 errors) ====
|
||||
tests/cases/compiler/contextualTyping.ts(189,18): error TS2384: Overload signatures must all be ambient or non-ambient.
|
||||
tests/cases/compiler/contextualTyping.ts(197,15): error TS2300: Duplicate identifier 'Point'.
|
||||
tests/cases/compiler/contextualTyping.ts(207,10): error TS2300: Duplicate identifier 'Point'.
|
||||
tests/cases/compiler/contextualTyping.ts(230,5): error TS2322: Type '{}' is not assignable to type 'B'.
|
||||
Property 'x' is missing in type '{}'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/contextualTyping.ts (4 errors) ====
|
||||
// DEFAULT INTERFACES
|
||||
interface IFoo {
|
||||
n: number;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
//// [cyclicGenericTypeInstantiation.ts]
|
||||
function foo<T>() {
|
||||
var z = foo<typeof y>();
|
||||
var y: {
|
||||
y2: typeof z
|
||||
};
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
function bar<T>() {
|
||||
var z = bar<typeof y>();
|
||||
var y: {
|
||||
y2: typeof z;
|
||||
}
|
||||
return y;
|
||||
}
|
||||
|
||||
var a = foo<number>();
|
||||
var b = bar<number>();
|
||||
a = b;
|
||||
|
||||
|
||||
//// [cyclicGenericTypeInstantiation.js]
|
||||
function foo() {
|
||||
var z = foo();
|
||||
var y;
|
||||
return y;
|
||||
}
|
||||
function bar() {
|
||||
var z = bar();
|
||||
var y;
|
||||
return y;
|
||||
}
|
||||
var a = foo();
|
||||
var b = bar();
|
||||
a = b;
|
||||
@@ -0,0 +1,55 @@
|
||||
=== tests/cases/compiler/cyclicGenericTypeInstantiation.ts ===
|
||||
function foo<T>() {
|
||||
>foo : Symbol(foo, Decl(cyclicGenericTypeInstantiation.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(cyclicGenericTypeInstantiation.ts, 0, 13))
|
||||
|
||||
var z = foo<typeof y>();
|
||||
>z : Symbol(z, Decl(cyclicGenericTypeInstantiation.ts, 1, 7))
|
||||
>foo : Symbol(foo, Decl(cyclicGenericTypeInstantiation.ts, 0, 0))
|
||||
>y : Symbol(y, Decl(cyclicGenericTypeInstantiation.ts, 2, 7))
|
||||
|
||||
var y: {
|
||||
>y : Symbol(y, Decl(cyclicGenericTypeInstantiation.ts, 2, 7))
|
||||
|
||||
y2: typeof z
|
||||
>y2 : Symbol(y2, Decl(cyclicGenericTypeInstantiation.ts, 2, 12))
|
||||
>z : Symbol(z, Decl(cyclicGenericTypeInstantiation.ts, 1, 7))
|
||||
|
||||
};
|
||||
return y;
|
||||
>y : Symbol(y, Decl(cyclicGenericTypeInstantiation.ts, 2, 7))
|
||||
}
|
||||
|
||||
|
||||
function bar<T>() {
|
||||
>bar : Symbol(bar, Decl(cyclicGenericTypeInstantiation.ts, 6, 1))
|
||||
>T : Symbol(T, Decl(cyclicGenericTypeInstantiation.ts, 9, 13))
|
||||
|
||||
var z = bar<typeof y>();
|
||||
>z : Symbol(z, Decl(cyclicGenericTypeInstantiation.ts, 10, 7))
|
||||
>bar : Symbol(bar, Decl(cyclicGenericTypeInstantiation.ts, 6, 1))
|
||||
>y : Symbol(y, Decl(cyclicGenericTypeInstantiation.ts, 11, 7))
|
||||
|
||||
var y: {
|
||||
>y : Symbol(y, Decl(cyclicGenericTypeInstantiation.ts, 11, 7))
|
||||
|
||||
y2: typeof z;
|
||||
>y2 : Symbol(y2, Decl(cyclicGenericTypeInstantiation.ts, 11, 12))
|
||||
>z : Symbol(z, Decl(cyclicGenericTypeInstantiation.ts, 10, 7))
|
||||
}
|
||||
return y;
|
||||
>y : Symbol(y, Decl(cyclicGenericTypeInstantiation.ts, 11, 7))
|
||||
}
|
||||
|
||||
var a = foo<number>();
|
||||
>a : Symbol(a, Decl(cyclicGenericTypeInstantiation.ts, 17, 3))
|
||||
>foo : Symbol(foo, Decl(cyclicGenericTypeInstantiation.ts, 0, 0))
|
||||
|
||||
var b = bar<number>();
|
||||
>b : Symbol(b, Decl(cyclicGenericTypeInstantiation.ts, 18, 3))
|
||||
>bar : Symbol(bar, Decl(cyclicGenericTypeInstantiation.ts, 6, 1))
|
||||
|
||||
a = b;
|
||||
>a : Symbol(a, Decl(cyclicGenericTypeInstantiation.ts, 17, 3))
|
||||
>b : Symbol(b, Decl(cyclicGenericTypeInstantiation.ts, 18, 3))
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
=== tests/cases/compiler/cyclicGenericTypeInstantiation.ts ===
|
||||
function foo<T>() {
|
||||
>foo : <T>() => { y2: any; }
|
||||
>T : T
|
||||
|
||||
var z = foo<typeof y>();
|
||||
>z : { y2: any; }
|
||||
>foo<typeof y>() : { y2: any; }
|
||||
>foo : <T>() => { y2: any; }
|
||||
>y : { y2: any; }
|
||||
|
||||
var y: {
|
||||
>y : { y2: any; }
|
||||
|
||||
y2: typeof z
|
||||
>y2 : { y2: any; }
|
||||
>z : { y2: any; }
|
||||
|
||||
};
|
||||
return y;
|
||||
>y : { y2: any; }
|
||||
}
|
||||
|
||||
|
||||
function bar<T>() {
|
||||
>bar : <T>() => { y2: any; }
|
||||
>T : T
|
||||
|
||||
var z = bar<typeof y>();
|
||||
>z : { y2: any; }
|
||||
>bar<typeof y>() : { y2: any; }
|
||||
>bar : <T>() => { y2: any; }
|
||||
>y : { y2: any; }
|
||||
|
||||
var y: {
|
||||
>y : { y2: any; }
|
||||
|
||||
y2: typeof z;
|
||||
>y2 : { y2: any; }
|
||||
>z : { y2: any; }
|
||||
}
|
||||
return y;
|
||||
>y : { y2: any; }
|
||||
}
|
||||
|
||||
var a = foo<number>();
|
||||
>a : { y2: any; }
|
||||
>foo<number>() : { y2: any; }
|
||||
>foo : <T>() => { y2: any; }
|
||||
|
||||
var b = bar<number>();
|
||||
>b : { y2: any; }
|
||||
>bar<number>() : { y2: any; }
|
||||
>bar : <T>() => { y2: any; }
|
||||
|
||||
a = b;
|
||||
>a = b : { y2: any; }
|
||||
>a : { y2: any; }
|
||||
>b : { y2: any; }
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
//// [declareIdentifierAsBeginningOfStatementExpression01.ts]
|
||||
class C {
|
||||
}
|
||||
|
||||
var declare: any;
|
||||
|
||||
declare instanceof C;
|
||||
|
||||
//// [declareIdentifierAsBeginningOfStatementExpression01.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
var declare;
|
||||
declare instanceof C;
|
||||
@@ -0,0 +1,12 @@
|
||||
=== tests/cases/compiler/declareIdentifierAsBeginningOfStatementExpression01.ts ===
|
||||
class C {
|
||||
>C : Symbol(C, Decl(declareIdentifierAsBeginningOfStatementExpression01.ts, 0, 0))
|
||||
}
|
||||
|
||||
var declare: any;
|
||||
>declare : Symbol(declare, Decl(declareIdentifierAsBeginningOfStatementExpression01.ts, 3, 3))
|
||||
|
||||
declare instanceof C;
|
||||
>declare : Symbol(declare, Decl(declareIdentifierAsBeginningOfStatementExpression01.ts, 3, 3))
|
||||
>C : Symbol(C, Decl(declareIdentifierAsBeginningOfStatementExpression01.ts, 0, 0))
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/declareIdentifierAsBeginningOfStatementExpression01.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
}
|
||||
|
||||
var declare: any;
|
||||
>declare : any
|
||||
|
||||
declare instanceof C;
|
||||
>declare instanceof C : boolean
|
||||
>declare : any
|
||||
>C : typeof C
|
||||
|
||||
@@ -12,7 +12,7 @@ type arrayString = Array<String>
|
||||
>String : String
|
||||
|
||||
type someArray = Array<String> | number[];
|
||||
>someArray : number[] | String[]
|
||||
>someArray : String[] | number[]
|
||||
>Array : T[]
|
||||
>String : String
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ type arrayString = Array<String>
|
||||
>String : String
|
||||
|
||||
type someArray = Array<String> | number[];
|
||||
>someArray : number[] | String[]
|
||||
>someArray : String[] | number[]
|
||||
>Array : T[]
|
||||
>String : String
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_1.ts(1,18): error TS2304: Cannot find name 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_1.ts (1 errors) ====
|
||||
var { x } = <any>foo();
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'foo'.
|
||||
@@ -0,0 +1,5 @@
|
||||
//// [destructuringTypeAssertionsES5_1.ts]
|
||||
var { x } = <any>foo();
|
||||
|
||||
//// [destructuringTypeAssertionsES5_1.js]
|
||||
var x = foo().x;
|
||||
@@ -0,0 +1,7 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_2.ts(1,19): error TS2304: Cannot find name 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_2.ts (1 errors) ====
|
||||
var { x } = (<any>foo());
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'foo'.
|
||||
Loaded 100 of 234 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user