Merge branch 'master' into testPerf

Conflicts:
	Jakefile.js
	src/compiler/program.ts
	src/compiler/types.ts
	src/harness/harness.ts
	src/harness/projectsRunner.ts
	src/harness/runner.ts
This commit is contained in:
Daniel Rosenwasser
2015-06-08 14:45:38 -07:00
137 changed files with 3308 additions and 1700 deletions
+47 -16
View File
@@ -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.
+2 -1
View File
@@ -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([
+3 -3
View File
@@ -5,8 +5,8 @@
[![Downloads](http://img.shields.io/npm/dm/TypeScript.svg)](https://npmjs.org/package/typescript)
# TypeScript
[![Join the chat at https://gitter.im/Microsoft/TypeScript](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Microsoft/TypeScript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Join the chat at https://gitter.im/Microsoft/TypeScript](https://badges.gitter.im/Join%20Chat.svg)](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:
+14 -6
View File
@@ -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
/////////////////////////////
+14 -7
View File
@@ -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;
+14 -6
View File
@@ -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
View File
File diff suppressed because it is too large Load Diff
+377 -331
View File
File diff suppressed because it is too large Load Diff
+5 -4
View File
@@ -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
View File
File diff suppressed because it is too large Load Diff
+5 -4
View File
@@ -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
View File
File diff suppressed because it is too large Load Diff
+147 -131
View File
@@ -1493,8 +1493,9 @@ module ts {
// Write undefined/null type as any
if (type.flags & TypeFlags.Intrinsic) {
// Special handling for unknown / resolving types, they should show up as any and not unknown or __resolving
writer.writeKeyword(!(globalFlags & TypeFormatFlags.WriteOwnNameForAnyLike) &&
(type.flags & TypeFlags.Any) ? "any" : (<IntrinsicType>type).intrinsicName);
writer.writeKeyword(!(globalFlags & TypeFormatFlags.WriteOwnNameForAnyLike) && isTypeAny(type)
? "any"
: (<IntrinsicType>type).intrinsicName);
}
else if (type.flags & TypeFlags.Reference) {
writeTypeReference(<TypeReference>type, flags);
@@ -2136,6 +2137,10 @@ module ts {
return prop ? getTypeOfSymbol(prop) : undefined;
}
function isTypeAny(type: Type) {
return type && (type.flags & TypeFlags.Any) !== 0;
}
// Return the inferred type for a binding element
function getTypeForBindingElement(declaration: BindingElement): Type {
let pattern = <BindingPattern>declaration.parent;
@@ -2147,7 +2152,7 @@ module ts {
// If no type was specified or inferred for parent, or if the specified or inferred type is any,
// infer from the initializer of the binding element if one is present. Otherwise, go with the
// undefined or any type of the parent.
if (!parentType || parentType === anyType) {
if (!parentType || isTypeAny(parentType)) {
if (declaration.initializer) {
return checkExpressionCached(declaration.initializer);
}
@@ -2174,7 +2179,7 @@ module ts {
// fact an iterable or array (depending on target language).
let elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false);
if (!declaration.dotDotDotToken) {
if (elementType.flags & TypeFlags.Any) {
if (isTypeAny(elementType)) {
return elementType;
}
@@ -3721,9 +3726,9 @@ module ts {
}
}
function containsAnyType(types: Type[]) {
function containsTypeAny(types: Type[]) {
for (let type of types) {
if (type.flags & TypeFlags.Any) {
if (isTypeAny(type)) {
return true;
}
}
@@ -3751,7 +3756,7 @@ module ts {
let sortedTypes: Type[] = [];
addTypesToSortedSet(sortedTypes, types);
if (noSubtypeReduction) {
if (containsAnyType(sortedTypes)) {
if (containsTypeAny(sortedTypes)) {
return anyType;
}
removeAllButLast(sortedTypes, undefinedType);
@@ -4175,13 +4180,13 @@ module ts {
// both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases
if (source === target) return Ternary.True;
if (relation !== identityRelation) {
if (target.flags & TypeFlags.Any) return Ternary.True;
if (isTypeAny(target)) return Ternary.True;
if (source === undefinedType) return Ternary.True;
if (source === nullType && target !== undefinedType) return Ternary.True;
if (source.flags & TypeFlags.Enum && target === numberType) return Ternary.True;
if (source.flags & TypeFlags.StringLiteral && target === stringType) return Ternary.True;
if (relation === assignableRelation) {
if (source.flags & TypeFlags.Any) return Ternary.True;
if (isTypeAny(source)) return Ternary.True;
if (source === numberType && target.flags & TypeFlags.Enum) return Ternary.True;
}
}
@@ -5406,55 +5411,58 @@ module ts {
function getNarrowedTypeOfSymbol(symbol: Symbol, node: Node) {
let type = getTypeOfSymbol(symbol);
// Only narrow when symbol is variable of type any or an object, union, or type parameter type
if (node && symbol.flags & SymbolFlags.Variable && type.flags & (TypeFlags.Any | TypeFlags.ObjectType | TypeFlags.Union | TypeFlags.TypeParameter)) {
loop: while (node.parent) {
let child = node;
node = node.parent;
let narrowedType = type;
switch (node.kind) {
case SyntaxKind.IfStatement:
// In a branch of an if statement, narrow based on controlling expression
if (child !== (<IfStatement>node).expression) {
narrowedType = narrowType(type, (<IfStatement>node).expression, /*assumeTrue*/ child === (<IfStatement>node).thenStatement);
}
break;
case SyntaxKind.ConditionalExpression:
// In a branch of a conditional expression, narrow based on controlling condition
if (child !== (<ConditionalExpression>node).condition) {
narrowedType = narrowType(type, (<ConditionalExpression>node).condition, /*assumeTrue*/ child === (<ConditionalExpression>node).whenTrue);
}
break;
case SyntaxKind.BinaryExpression:
// In the right operand of an && or ||, narrow based on left operand
if (child === (<BinaryExpression>node).right) {
if ((<BinaryExpression>node).operatorToken.kind === SyntaxKind.AmpersandAmpersandToken) {
narrowedType = narrowType(type, (<BinaryExpression>node).left, /*assumeTrue*/ true);
if (node && symbol.flags & SymbolFlags.Variable) {
if (isTypeAny(type) || type.flags & (TypeFlags.ObjectType | TypeFlags.Union | TypeFlags.TypeParameter)) {
loop: while (node.parent) {
let child = node;
node = node.parent;
let narrowedType = type;
switch (node.kind) {
case SyntaxKind.IfStatement:
// In a branch of an if statement, narrow based on controlling expression
if (child !== (<IfStatement>node).expression) {
narrowedType = narrowType(type, (<IfStatement>node).expression, /*assumeTrue*/ child === (<IfStatement>node).thenStatement);
}
else if ((<BinaryExpression>node).operatorToken.kind === SyntaxKind.BarBarToken) {
narrowedType = narrowType(type, (<BinaryExpression>node).left, /*assumeTrue*/ false);
break;
case SyntaxKind.ConditionalExpression:
// In a branch of a conditional expression, narrow based on controlling condition
if (child !== (<ConditionalExpression>node).condition) {
narrowedType = narrowType(type, (<ConditionalExpression>node).condition, /*assumeTrue*/ child === (<ConditionalExpression>node).whenTrue);
}
break;
case SyntaxKind.BinaryExpression:
// In the right operand of an && or ||, narrow based on left operand
if (child === (<BinaryExpression>node).right) {
if ((<BinaryExpression>node).operatorToken.kind === SyntaxKind.AmpersandAmpersandToken) {
narrowedType = narrowType(type, (<BinaryExpression>node).left, /*assumeTrue*/ true);
}
else if ((<BinaryExpression>node).operatorToken.kind === SyntaxKind.BarBarToken) {
narrowedType = narrowType(type, (<BinaryExpression>node).left, /*assumeTrue*/ false);
}
}
break;
case SyntaxKind.SourceFile:
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.Constructor:
// Stop at the first containing function or module declaration
break loop;
}
// Use narrowed type if construct contains no assignments to variable
if (narrowedType !== type) {
if (isVariableAssignedWithin(symbol, node)) {
break;
}
break;
case SyntaxKind.SourceFile:
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.Constructor:
// Stop at the first containing function or module declaration
break loop;
}
// Use narrowed type if construct contains no assignments to variable
if (narrowedType !== type) {
if (isVariableAssignedWithin(symbol, node)) {
break;
type = narrowedType;
}
type = narrowedType;
}
}
}
return type;
function narrowTypeByEquality(type: Type, expr: BinaryExpression, assumeTrue: boolean): Type {
@@ -5527,7 +5535,7 @@ module ts {
function narrowTypeByInstanceof(type: Type, expr: BinaryExpression, assumeTrue: boolean): Type {
// Check that type is not any, assumed result is true, and we have variable symbol on the left
if (type.flags & TypeFlags.Any || !assumeTrue || expr.left.kind !== SyntaxKind.Identifier || getResolvedSymbol(<Identifier>expr.left) !== symbol) {
if (isTypeAny(type) || !assumeTrue || expr.left.kind !== SyntaxKind.Identifier || getResolvedSymbol(<Identifier>expr.left) !== symbol) {
return type;
}
// Check that right operand is a function type with a prototype property
@@ -5541,7 +5549,7 @@ module ts {
if (prototypeProperty) {
// Target type is type of the protoype property
let prototypePropertyType = getTypeOfSymbol(prototypeProperty);
if (prototypePropertyType !== anyType) {
if (!isTypeAny(prototypePropertyType)) {
targetType = prototypePropertyType;
}
}
@@ -6302,7 +6310,11 @@ module ts {
function isNumericComputedName(name: ComputedPropertyName): boolean {
// It seems odd to consider an expression of type Any to result in a numeric name,
// but this behavior is consistent with checkIndexedAccess
return allConstituentTypesHaveKind(checkComputedPropertyName(name), TypeFlags.Any | TypeFlags.NumberLike);
return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), TypeFlags.NumberLike);
}
function isTypeAnyOrAllConstituentTypesHaveKind(type: Type, kind: TypeFlags): boolean {
return isTypeAny(type) || allConstituentTypesHaveKind(type, kind);
}
function isNumericLiteralName(name: string) {
@@ -6337,7 +6349,7 @@ module ts {
// This will allow types number, string, symbol or any. It will also allow enums, the unknown
// type, and any union of these types (like string | number).
if (!allConstituentTypesHaveKind(links.resolvedType, TypeFlags.Any | TypeFlags.NumberLike | TypeFlags.StringLike | TypeFlags.ESSymbol)) {
if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, TypeFlags.NumberLike | TypeFlags.StringLike | TypeFlags.ESSymbol)) {
error(node, Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any);
}
else {
@@ -6489,39 +6501,39 @@ module ts {
function checkPropertyAccessExpressionOrQualifiedName(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, right: Identifier) {
let type = checkExpressionOrQualifiedName(left);
if (type === unknownType) return type;
if (type !== anyType) {
let apparentType = getApparentType(getWidenedType(type));
if (apparentType === unknownType) {
// handle cases when type is Type parameter with invalid constraint
return unknownType;
}
let prop = getPropertyOfType(apparentType, right.text);
if (!prop) {
if (right.text) {
error(right, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(right), typeToString(type));
}
return unknownType;
}
getNodeLinks(node).resolvedSymbol = prop;
if (prop.parent && prop.parent.flags & SymbolFlags.Class) {
// TS 1.0 spec (April 2014): 4.8.2
// - In a constructor, instance member function, instance member accessor, or
// instance member variable initializer where this references a derived class instance,
// a super property access is permitted and must specify a public instance member function of the base class.
// - In a static member function or static member accessor
// where this references the constructor function object of a derived class,
// a super property access is permitted and must specify a public static member function of the base class.
if (left.kind === SyntaxKind.SuperKeyword && getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) {
error(right, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword);
}
else {
checkClassPropertyAccess(node, left, type, prop);
}
}
return getTypeOfSymbol(prop);
if (isTypeAny(type)) {
return type;
}
return anyType;
let apparentType = getApparentType(getWidenedType(type));
if (apparentType === unknownType) {
// handle cases when type is Type parameter with invalid constraint
return unknownType;
}
let prop = getPropertyOfType(apparentType, right.text);
if (!prop) {
if (right.text) {
error(right, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(right), typeToString(type));
}
return unknownType;
}
getNodeLinks(node).resolvedSymbol = prop;
if (prop.parent && prop.parent.flags & SymbolFlags.Class) {
// TS 1.0 spec (April 2014): 4.8.2
// - In a constructor, instance member function, instance member accessor, or
// instance member variable initializer where this references a derived class instance,
// a super property access is permitted and must specify a public instance member function of the base class.
// - In a static member function or static member accessor
// where this references the constructor function object of a derived class,
// a super property access is permitted and must specify a public static member function of the base class.
if (left.kind === SyntaxKind.SuperKeyword && getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) {
error(right, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword);
}
else {
checkClassPropertyAccess(node, left, type, prop);
}
}
return getTypeOfSymbol(prop);
}
function isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean {
@@ -6530,7 +6542,7 @@ module ts {
: (<QualifiedName>node).left;
let type = checkExpressionOrQualifiedName(left);
if (type !== unknownType && type !== anyType) {
if (type !== unknownType && !isTypeAny(type)) {
let prop = getPropertyOfType(getWidenedType(type), propertyName);
if (prop && prop.parent && prop.parent.flags & SymbolFlags.Class) {
if (left.kind === SyntaxKind.SuperKeyword && getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) {
@@ -6603,10 +6615,10 @@ module ts {
}
// Check for compatible indexer types.
if (allConstituentTypesHaveKind(indexType, TypeFlags.Any | TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbol)) {
if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbol)) {
// Try to use a number indexer.
if (allConstituentTypesHaveKind(indexType, TypeFlags.Any | TypeFlags.NumberLike)) {
if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.NumberLike)) {
let numberIndexType = getIndexTypeOfType(objectType, IndexKind.Number);
if (numberIndexType) {
return numberIndexType;
@@ -6620,7 +6632,7 @@ module ts {
}
// Fall back to any.
if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && objectType !== anyType) {
if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !isTypeAny(objectType)) {
error(node, Diagnostics.Index_signature_of_object_type_implicitly_has_an_any_type);
}
@@ -7270,8 +7282,10 @@ module ts {
// types are provided for the argument expressions, and the result is always of type Any.
// We exclude union types because we may have a union of function types that happen to have
// no common signatures.
if (funcType === anyType || (!callSignatures.length && !constructSignatures.length && !(funcType.flags & TypeFlags.Union) && isTypeAssignableTo(funcType, globalFunctionType))) {
if (node.typeArguments) {
if (isTypeAny(funcType) || (!callSignatures.length && !constructSignatures.length && !(funcType.flags & TypeFlags.Union) && isTypeAssignableTo(funcType, globalFunctionType))) {
// The unknownType indicates that an error already occured (and was reported). No
// need to report another error in this case.
if (funcType !== unknownType && node.typeArguments) {
error(node, Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
}
return resolveUntypedCall(node);
@@ -7300,15 +7314,6 @@ module ts {
}
let expressionType = checkExpression(node.expression);
// TS 1.0 spec: 4.11
// If ConstructExpr is of type Any, Args can be any argument
// list and the result of the operation is of type Any.
if (expressionType === anyType) {
if (node.typeArguments) {
error(node, Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
}
return resolveUntypedCall(node);
}
// If ConstructExpr's apparent type(section 3.8.1) is an object type with one or
// more construct signatures, the expression is processed in the same manner as a
@@ -7321,6 +7326,16 @@ module ts {
return resolveErrorCall(node);
}
// TS 1.0 spec: 4.11
// If ConstructExpr is of type Any, Args can be any argument
// list and the result of the operation is of type Any.
if (isTypeAny(expressionType)) {
if (node.typeArguments) {
error(node, Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
}
return resolveUntypedCall(node);
}
// Technically, this signatures list may be incomplete. We are taking the apparent type,
// but we are not including construct signatures that may have been added to the Object or
// Function interface, since they have none by default. This is a bit of a leap of faith
@@ -7358,7 +7373,7 @@ module ts {
let callSignatures = getSignaturesOfType(apparentType, SignatureKind.Call);
if (tagType === anyType || (!callSignatures.length && !(tagType.flags & TypeFlags.Union) && isTypeAssignableTo(tagType, globalFunctionType))) {
if (isTypeAny(tagType) || (!callSignatures.length && !(tagType.flags & TypeFlags.Union) && isTypeAssignableTo(tagType, globalFunctionType))) {
return resolveUntypedCall(node);
}
@@ -7570,7 +7585,7 @@ module ts {
}
// Functions that return 'void' or 'any' don't need any return expressions.
if (returnType === voidType || returnType === anyType) {
if (returnType === voidType || isTypeAny(returnType)) {
return;
}
@@ -7674,7 +7689,7 @@ module ts {
}
function checkArithmeticOperandType(operand: Node, type: Type, diagnostic: DiagnosticMessage): boolean {
if (!allConstituentTypesHaveKind(type, TypeFlags.Any | TypeFlags.NumberLike)) {
if (!isTypeAnyOrAllConstituentTypesHaveKind(type, TypeFlags.NumberLike)) {
error(operand, diagnostic);
return false;
}
@@ -7886,7 +7901,7 @@ module ts {
error(node.left, Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
}
// NOTE: do not raise error if right is unknown as related error was already reported
if (!(rightType.flags & TypeFlags.Any || isTypeSubtypeOf(rightType, globalFunctionType))) {
if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
error(node.right, Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type);
}
return booleanType;
@@ -7897,10 +7912,10 @@ module ts {
// The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type,
// and the right operand to be of type Any, an object type, or a type parameter type.
// The result is always of the Boolean primitive type.
if (!allConstituentTypesHaveKind(leftType, TypeFlags.Any | TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbol)) {
if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbol)) {
error(node.left, Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
}
if (!allConstituentTypesHaveKind(rightType, TypeFlags.Any | TypeFlags.ObjectType | TypeFlags.TypeParameter)) {
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, TypeFlags.ObjectType | TypeFlags.TypeParameter)) {
error(node.right, Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
}
return booleanType;
@@ -7912,10 +7927,11 @@ module ts {
if (p.kind === SyntaxKind.PropertyAssignment || p.kind === SyntaxKind.ShorthandPropertyAssignment) {
// TODO(andersh): Computed property support
let name = <Identifier>(<PropertyAssignment>p).name;
let type = sourceType.flags & TypeFlags.Any ? sourceType :
getTypeOfPropertyOfType(sourceType, name.text) ||
isNumericLiteralName(name.text) && getIndexTypeOfType(sourceType, IndexKind.Number) ||
getIndexTypeOfType(sourceType, IndexKind.String);
let type = isTypeAny(sourceType)
? sourceType
: getTypeOfPropertyOfType(sourceType, name.text) ||
isNumericLiteralName(name.text) && getIndexTypeOfType(sourceType, IndexKind.Number) ||
getIndexTypeOfType(sourceType, IndexKind.String);
if (type) {
checkDestructuringAssignment((<PropertyAssignment>p).initializer || name, type);
}
@@ -7941,8 +7957,9 @@ module ts {
if (e.kind !== SyntaxKind.OmittedExpression) {
if (e.kind !== SyntaxKind.SpreadElementExpression) {
let propName = "" + i;
let type = sourceType.flags & TypeFlags.Any ? sourceType :
isTupleLikeType(sourceType)
let type = isTypeAny(sourceType)
? sourceType
: isTupleLikeType(sourceType)
? getTypeOfPropertyOfType(sourceType, propName)
: elementType;
if (type) {
@@ -8081,10 +8098,10 @@ module ts {
// If one or both operands are of the String primitive type, the result is of the String primitive type.
resultType = stringType;
}
else if (leftType.flags & TypeFlags.Any || rightType.flags & TypeFlags.Any) {
else if (isTypeAny(leftType) || isTypeAny(rightType)) {
// Otherwise, the result is of type Any.
// NOTE: unknown type here denotes error type. Old compiler treated this case as any type so do we.
resultType = anyType;
resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType;
}
// Symbols are not allowed at all in arithmetic expressions
@@ -9780,7 +9797,7 @@ module ts {
if (varExpr.kind === SyntaxKind.ArrayLiteralExpression || varExpr.kind === SyntaxKind.ObjectLiteralExpression) {
error(varExpr, Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern);
}
else if (!allConstituentTypesHaveKind(leftType, TypeFlags.Any | TypeFlags.StringLike)) {
else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, TypeFlags.StringLike)) {
error(varExpr, Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any);
}
else {
@@ -9792,7 +9809,7 @@ module ts {
let rightType = checkExpression(node.expression);
// unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved
// in this case error about missing name is already reported - do not report extra one
if (!allConstituentTypesHaveKind(rightType, TypeFlags.Any | TypeFlags.ObjectType | TypeFlags.TypeParameter)) {
if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, TypeFlags.ObjectType | TypeFlags.TypeParameter)) {
error(node.expression, Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter);
}
@@ -9814,7 +9831,7 @@ module ts {
}
function checkIteratedTypeOrElementType(inputType: Type, errorNode: Node, allowStringInput: boolean): Type {
if (inputType.flags & TypeFlags.Any) {
if (isTypeAny(inputType)) {
return inputType;
}
@@ -9873,7 +9890,7 @@ module ts {
* whole pattern and that T (above) is 'any'.
*/
function getElementTypeOfIterable(type: Type, errorNode: Node): Type {
if (type.flags & TypeFlags.Any) {
if (isTypeAny(type)) {
return undefined;
}
@@ -9886,7 +9903,7 @@ module ts {
}
else {
let iteratorFunction = getTypeOfPropertyOfType(type, getPropertyNameForKnownSymbolName("iterator"));
if (iteratorFunction && iteratorFunction.flags & TypeFlags.Any) {
if (isTypeAny(iteratorFunction)) {
return undefined;
}
@@ -9919,7 +9936,7 @@ module ts {
*
*/
function getElementTypeOfIterator(type: Type, errorNode: Node): Type {
if (type.flags & TypeFlags.Any) {
if (isTypeAny(type)) {
return undefined;
}
@@ -9932,7 +9949,7 @@ module ts {
}
else {
let iteratorNextFunction = getTypeOfPropertyOfType(type, "next");
if (iteratorNextFunction && iteratorNextFunction.flags & TypeFlags.Any) {
if (isTypeAny(iteratorNextFunction)) {
return undefined;
}
@@ -9945,7 +9962,7 @@ module ts {
}
let iteratorNextResult = getUnionType(map(iteratorNextFunctionSignatures, getReturnTypeOfSignature));
if (iteratorNextResult.flags & TypeFlags.Any) {
if (isTypeAny(iteratorNextResult)) {
return undefined;
}
@@ -9965,7 +9982,7 @@ module ts {
}
function getElementTypeOfIterableIterator(type: Type): Type {
if (type.flags & TypeFlags.Any) {
if (isTypeAny(type)) {
return undefined;
}
@@ -11344,12 +11361,7 @@ module ts {
function checkSourceFile(node: SourceFile) {
let start = new Date().getTime();
// Check whether the file has declared it is the default lib,
// and whether the user has specifically chosen to avoid checking it.
let skipCheck = node.hasNoDefaultLib && compilerOptions.noLibCheck;
if (!skipCheck) {
checkSourceFileWorker(node);
}
checkSourceFileWorker(node);
checkTime += new Date().getTime() - start;
}
@@ -11358,6 +11370,10 @@ module ts {
function checkSourceFileWorker(node: SourceFile) {
let links = getNodeLinks(node);
if (!(links.flags & NodeCheckFlags.TypeChecked)) {
if (node.isDefaultLib && compilerOptions.skipDefaultLibCheck) {
return;
}
// Grammar checking
checkGrammarSourceFile(node);
+4
View File
@@ -103,6 +103,10 @@ module ts {
name: "noResolve",
type: "boolean",
},
{
name: "skipDefaultLibCheck",
type: "boolean",
},
{
name: "out",
type: "string",
+36
View File
@@ -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,
+23 -7
View File
@@ -1646,6 +1646,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
}
function parenthesizeForAccess(expr: Expression): LeftHandSideExpression {
// When diagnosing whether the expression needs parentheses, the decision should be based
// on the innermost expression in a chain of nested type assertions.
while (expr.kind === SyntaxKind.TypeAssertionExpression) {
expr = (<TypeAssertion>expr).expression;
}
// isLeftHandSideExpression is almost the correct criterion for when it is not necessary
// to parenthesize the expression before a dot. The known exceptions are:
//
@@ -1654,7 +1660,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
// NumberLiteral
// 1.x -> not the same as (1).x
//
if (isLeftHandSideExpression(expr) && expr.kind !== SyntaxKind.NewExpression && expr.kind !== SyntaxKind.NumericLiteral) {
if (isLeftHandSideExpression(expr) &&
expr.kind !== SyntaxKind.NewExpression &&
expr.kind !== SyntaxKind.NumericLiteral) {
return <LeftHandSideExpression>expr;
}
let node = <ParenthesizedExpression>createSynthesizedNode(SyntaxKind.ParenthesizedExpression);
@@ -1941,7 +1950,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
}
function emitParenExpression(node: ParenthesizedExpression) {
if (!node.parent || node.parent.kind !== SyntaxKind.ArrowFunction) {
// If the node is synthesized, it means the emitter put the parentheses there,
// not the user. If we didn't want them, the emitter would not have put them
// there.
if (!nodeIsSynthesized(node) && node.parent.kind !== SyntaxKind.ArrowFunction) {
if (node.expression.kind === SyntaxKind.TypeAssertionExpression) {
let operand = (<TypeAssertion>node.expression).expression;
@@ -4491,7 +4503,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
emitDeclarationName(node);
write(`", `);
emitDeclarationName(node);
write(")");
write(");");
}
emitExportMemberAssignments(node.name);
}
@@ -4612,7 +4624,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
emitDeclarationName(node);
write(`", `);
emitDeclarationName(node);
write(")");
write(");");
}
emitExportMemberAssignments(<Identifier>node.name);
}
@@ -5527,7 +5539,11 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
Debug.assert(!exportFunctionForFile);
// make sure that name of 'exports' function does not conflict with existing identifiers
exportFunctionForFile = makeUniqueName("exports");
write("System.register([");
write("System.register(");
if (node.moduleName) {
write(`"${node.moduleName}", `);
}
write("[")
for (let i = 0; i < externalImports.length; ++i) {
let text = getExternalModuleNameText(externalImports[i]);
if (i !== 0) {
@@ -5613,8 +5629,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
writeLine();
write("define(");
if (node.amdModuleName) {
write("\"" + node.amdModuleName + "\", ");
if (node.moduleName) {
write("\"" + node.moduleName + "\", ");
}
emitAMDDependencies(node, /*includeNonAmdDependencies*/ true);
write(") {");
+47 -14
View File
@@ -1816,7 +1816,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);
}
}
@@ -2686,7 +2686,7 @@ module ts {
function nextTokenIsIdentifierOnSameLine() {
nextToken();
return !scanner.hasPrecedingLineBreak() && isIdentifier()
return !scanner.hasPrecedingLineBreak() && isIdentifier();
}
function parseYieldExpression(): YieldExpression {
@@ -3809,14 +3809,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 ||
@@ -3829,7 +3857,6 @@ module ts {
return StatementFlags.ModuleElement;
}
continue;
case SyntaxKind.DeclareKeyword:
case SyntaxKind.PublicKeyword:
case SyntaxKind.PrivateKeyword:
case SyntaxKind.ProtectedKeyword:
@@ -3971,7 +3998,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();
@@ -3979,19 +4006,20 @@ module ts {
return parseDebuggerStatement();
case SyntaxKind.AtToken:
return parseDeclaration();
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();
}
@@ -4042,6 +4070,11 @@ module ts {
}
}
function nextTokenIsIdentifierOrStringLiteralOnSameLine() {
nextToken();
return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === SyntaxKind.StringLiteral);
}
function parseFunctionBlockOrSemicolon(isGenerator: boolean, diagnosticMessage?: DiagnosticMessage): Block {
if (token !== SyntaxKind.OpenBraceToken && canParseSemicolon()) {
parseSemicolon();
@@ -4583,7 +4616,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 {
@@ -4895,7 +4928,7 @@ module ts {
sourceFile.referencedFiles = referencedFiles;
sourceFile.amdDependencies = amdDependencies;
sourceFile.amdModuleName = amdModuleName;
sourceFile.moduleName = amdModuleName;
}
function setExternalModuleIndicator(sourceFile: SourceFile) {
+23 -19
View File
@@ -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,13 +143,14 @@ module ts {
export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program {
let program: Program;
let files: SourceFile[] = [];
let filesByName: Map<SourceFile> = {};
let filesByName = createFileMap<SourceFile>(fileName => host.getCanonicalFileName(fileName));
let diagnostics = createDiagnosticCollection();
let commonSourceDirectory: string;
let diagnosticsProducingTypeChecker: TypeChecker;
let noDiagnosticsTypeChecker: TypeChecker;
let encounteredTheNoDefaultLibTag = false;
let skipDefaultLib = options.noLib;
let start = new Date().getTime();
@@ -167,8 +162,9 @@ module ts {
// - The '--noLib' flag is used.
// - A 'no-default-lib' reference comment is encountered in
// processing the root files.
if (!(options.noLib || encounteredTheNoDefaultLibTag)) {
processRootFile(host.getDefaultLibFileName(options), /*isDefaultLib*/ true);
forEach(rootNames, name => processRootFile(name, /*isDefaultLib:*/ false));
if (!skipDefaultLib) {
processRootFile(host.getDefaultLibFileName(options), /*isDefaultLib:*/ true);
}
verifyCompilerOptions();
@@ -183,6 +179,7 @@ module ts {
getGlobalDiagnostics,
getSemanticDiagnostics,
getDeclarationDiagnostics,
getCompilerOptionsDiagnostics,
getTypeChecker,
getDiagnosticsProducingTypeChecker,
getCommonSourceDirectory: () => commonSourceDirectory,
@@ -246,8 +243,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[] {
@@ -299,6 +295,12 @@ module ts {
}
}
function getCompilerOptionsDiagnostics(): Diagnostic[] {
let allDiagnostics: Diagnostic[] = [];
addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
return sortAndDeduplicateDiagnostics(allDiagnostics);
}
function getGlobalDiagnostics(): Diagnostic[] {
let typeChecker = getDiagnosticsProducingTypeChecker();
@@ -366,19 +368,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));
@@ -387,11 +389,12 @@ module ts {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage));
}
});
filesByName.set(canonicalName, file);
if (file) {
encounteredTheNoDefaultLibTag = encounteredTheNoDefaultLibTag || 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);
@@ -399,6 +402,7 @@ module ts {
processImportedModules(file, basePath);
}
if (isDefaultLib) {
file.isDefaultLib = true;
files.unshift(file);
}
else {
@@ -410,7 +414,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) {
+16 -6
View File
@@ -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;
@@ -1134,7 +1142,7 @@ module ts {
text: string;
amdDependencies: {path: string; name: string}[];
amdModuleName: string;
moduleName: string;
referencedFiles: FileReference[];
/**
@@ -1151,7 +1159,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;
@@ -1205,6 +1214,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.
@@ -1830,11 +1840,11 @@ module ts {
isolatedModules?: boolean;
experimentalDecorators?: boolean;
emitDecoratorMetadata?: boolean;
/* @internal */ stripInternal?: boolean;
// Skip checking lib.d.ts to help speed up tests.
/* @internal */ noLibCheck?: boolean;
/* @internal */ stripInternal?: boolean;
// Skip checking lib.d.ts to help speed up tests.
/* @internal */ skipDefaultLibCheck?: boolean;
[option: string]: string | number | boolean;
}
+15
View File
@@ -1985,6 +1985,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 {
+25 -12
View File
@@ -809,9 +809,14 @@ module Harness {
}
}
export function createSourceFileAndAssertInvariants(fileName: string, sourceText: string, languageVersion: ts.ScriptTarget, assertInvariants: boolean) {
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);
}
@@ -834,13 +839,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 {
@@ -962,14 +968,15 @@ module Harness {
options.newLine = options.newLine || ts.NewLineKind.CarriageReturnLineFeed;
options.noErrorTruncation = true;
if (lightMode) {
options.noLibCheck = true;
options.skipDefaultLibCheck = true;
}
if (settingsCallback) {
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.
@@ -986,9 +993,11 @@ module Harness {
// always push the default lib in *last* to normalize the type/symbol baselines.
programFiles.push(defaultLibFileName);
}
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();
@@ -1081,6 +1090,10 @@ module Harness {
options.outDir = setting.value;
break;
case 'skipdefaultlibcheck':
options.skipDefaultLibCheck = setting.value === "true";
break;
case 'sourceroot':
options.sourceRoot = setting.value;
break;
+14 -7
View File
@@ -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
View File
@@ -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);
+9 -1
View File
@@ -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);
@@ -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.
@@ -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
}
@@ -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
@@ -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'.
@@ -0,0 +1,5 @@
//// [destructuringTypeAssertionsES5_2.ts]
var { x } = (<any>foo());
//// [destructuringTypeAssertionsES5_2.js]
var x = foo().x;
@@ -0,0 +1,7 @@
tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_3.ts(1,19): error TS2304: Cannot find name 'foo'.
==== tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_3.ts (1 errors) ====
var { x } = <any>(foo());
~~~
!!! error TS2304: Cannot find name 'foo'.
@@ -0,0 +1,5 @@
//// [destructuringTypeAssertionsES5_3.ts]
var { x } = <any>(foo());
//// [destructuringTypeAssertionsES5_3.js]
var x = (foo()).x;
@@ -0,0 +1,7 @@
tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_4.ts(1,23): error TS2304: Cannot find name 'foo'.
==== tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_4.ts (1 errors) ====
var { x } = <any><any>foo();
~~~
!!! error TS2304: Cannot find name 'foo'.
@@ -0,0 +1,5 @@
//// [destructuringTypeAssertionsES5_4.ts]
var { x } = <any><any>foo();
//// [destructuringTypeAssertionsES5_4.js]
var x = foo().x;
@@ -0,0 +1,5 @@
//// [destructuringTypeAssertionsES5_5.ts]
var { x } = <any>0;
//// [destructuringTypeAssertionsES5_5.js]
var x = (0).x;
@@ -0,0 +1,4 @@
=== tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_5.ts ===
var { x } = <any>0;
>x : Symbol(x, Decl(destructuringTypeAssertionsES5_5.ts, 0, 5))
@@ -0,0 +1,6 @@
=== tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_5.ts ===
var { x } = <any>0;
>x : any
><any>0 : any
>0 : number
@@ -0,0 +1,7 @@
tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_6.ts(1,22): error TS2304: Cannot find name 'Foo'.
==== tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_6.ts (1 errors) ====
var { x } = <any>new Foo;
~~~
!!! error TS2304: Cannot find name 'Foo'.
@@ -0,0 +1,5 @@
//// [destructuringTypeAssertionsES5_6.ts]
var { x } = <any>new Foo;
//// [destructuringTypeAssertionsES5_6.js]
var x = (new Foo).x;
@@ -0,0 +1,7 @@
tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_7.ts(1,27): error TS2304: Cannot find name 'Foo'.
==== tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_7.ts (1 errors) ====
var { x } = <any><any>new Foo;
~~~
!!! error TS2304: Cannot find name 'Foo'.
@@ -0,0 +1,5 @@
//// [destructuringTypeAssertionsES5_7.ts]
var { x } = <any><any>new Foo;
//// [destructuringTypeAssertionsES5_7.js]
var x = (new Foo).x;
@@ -1,5 +1,4 @@
tests/cases/compiler/genericRecursiveImplicitConstructorErrors3.ts(3,66): error TS2314: Generic type 'MemberName<A, B, C>' requires 3 type argument(s).
tests/cases/compiler/genericRecursiveImplicitConstructorErrors3.ts(3,66): 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/compiler/genericRecursiveImplicitConstructorErrors3.ts(10,22): error TS2314: Generic type 'PullTypeSymbol<A, B, C>' requires 3 type argument(s).
tests/cases/compiler/genericRecursiveImplicitConstructorErrors3.ts(12,48): error TS2314: Generic type 'PullSymbol<A, B, C>' requires 3 type argument(s).
tests/cases/compiler/genericRecursiveImplicitConstructorErrors3.ts(13,31): error TS2314: Generic type 'PullTypeSymbol<A, B, C>' requires 3 type argument(s).
@@ -8,14 +7,12 @@ tests/cases/compiler/genericRecursiveImplicitConstructorErrors3.ts(18,53): error
tests/cases/compiler/genericRecursiveImplicitConstructorErrors3.ts(19,22): error TS2339: Property 'isArray' does not exist on type 'PullTypeSymbol<A, B, C>'.
==== tests/cases/compiler/genericRecursiveImplicitConstructorErrors3.ts (8 errors) ====
==== tests/cases/compiler/genericRecursiveImplicitConstructorErrors3.ts (7 errors) ====
module TypeScript {
export class MemberName <A,B,C>{
static create<A,B,C>(arg1: any, arg2?: any, arg3?: any): MemberName {
~~~~~~~~~~
!!! error TS2314: Generic type 'MemberName<A, B, C>' requires 3 type argument(s).
~~~~~~~~~~
!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
}
}
}
@@ -2,10 +2,11 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefine
tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts(2,11): error TS2427: Interface name cannot be 'number'
tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts(3,11): error TS2427: Interface name cannot be 'string'
tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts(4,11): error TS2427: Interface name cannot be 'boolean'
tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts(5,11): error TS1003: Identifier expected.
tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts(5,1): error TS2304: Cannot find name 'interface'.
tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts(5,11): error TS1005: ';' expected.
==== tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts (5 errors) ====
==== tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefinedTypesAsNames.ts (6 errors) ====
interface any { }
~~~
!!! error TS2427: Interface name cannot be 'any'
@@ -19,5 +20,7 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfacesWithPredefine
~~~~~~~
!!! error TS2427: Interface name cannot be 'boolean'
interface void {}
~~~~~~~~~
!!! error TS2304: Cannot find name 'interface'.
~~~~
!!! error TS1003: Identifier expected.
!!! error TS1005: ';' expected.
@@ -6,4 +6,5 @@ interface boolean { }
interface void {}
//// [interfacesWithPredefinedTypesAsNames.js]
interface;
void {};
@@ -7,10 +7,9 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts
tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts1.ts(8,9): error TS2304: Cannot find name 'K'.
tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts1.ts(11,16): error TS2304: Cannot find name 'E'.
tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts1.ts(14,16): error TS2304: Cannot find name 'F'.
tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts1.ts(14,16): 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/Generics/parserGenericsInTypeContexts1.ts (10 errors) ====
==== tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts1.ts (9 errors) ====
class C extends A<T> implements B<T> {
~
!!! error TS2304: Cannot find name 'A'.
@@ -43,8 +42,6 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts
function f2(): F<T> {
~
!!! error TS2304: Cannot find name 'F'.
~~~~
!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
}
@@ -7,10 +7,9 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts
tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts2.ts(8,9): error TS2304: Cannot find name 'K'.
tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts2.ts(11,16): error TS2304: Cannot find name 'E'.
tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts2.ts(14,16): error TS2304: Cannot find name 'F'.
tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts2.ts(14,16): 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/Generics/parserGenericsInTypeContexts2.ts (10 errors) ====
==== tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts2.ts (9 errors) ====
class C extends A<X<T>, Y<Z<T>>> implements B<X<T>, Y<Z<T>>> {
~
!!! error TS2304: Cannot find name 'A'.
@@ -43,8 +42,6 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserGenericsInTypeContexts
function f2(): F<X<T>, Y<Z<T>>> {
~
!!! error TS2304: Cannot find name 'F'.
~~~~~~~~~~~~~~~~
!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
}
@@ -1,11 +1,8 @@
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/parserX_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/parserX_ArrowFunction3.ts(1,14): error TS1110: Type expected.
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/parserX_ArrowFunction3.ts (2 errors) ====
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/parserX_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.
@@ -2,12 +2,13 @@ tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(2,6): error
tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(3,6): error TS2457: Type alias name cannot be 'number'
tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(4,6): error TS2457: Type alias name cannot be 'boolean'
tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(5,6): error TS2457: Type alias name cannot be 'string'
tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,6): error TS1003: Identifier expected.
tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,11): error TS1005: ';' expected.
tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,1): error TS2304: Cannot find name 'type'.
tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,6): error TS1005: ';' expected.
tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,11): error TS1109: Expression expected.
tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,13): error TS2304: Cannot find name 'I'.
==== tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts (7 errors) ====
==== tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts (8 errors) ====
interface I {}
type any = I;
~~~
@@ -22,9 +23,11 @@ tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,13): error
~~~~~~
!!! error TS2457: Type alias name cannot be 'string'
type void = I;
~~~~
!!! error TS2304: Cannot find name 'type'.
~~~~
!!! error TS1003: Identifier expected.
~
!!! error TS1005: ';' expected.
~
!!! error TS1109: Expression expected.
~
!!! error TS2304: Cannot find name 'I'.
@@ -7,4 +7,6 @@ type string = I;
type void = I;
//// [reservedNamesInAliases.js]
type;
void ;
I;
@@ -13,8 +13,8 @@ tests/cases/compiler/reservedWords2.ts(4,12): error TS1109: Expression expected.
tests/cases/compiler/reservedWords2.ts(5,9): error TS2300: Duplicate identifier '(Missing)'.
tests/cases/compiler/reservedWords2.ts(5,10): error TS1003: Identifier expected.
tests/cases/compiler/reservedWords2.ts(5,18): error TS1005: '=>' expected.
tests/cases/compiler/reservedWords2.ts(6,7): error TS2300: Duplicate identifier '(Missing)'.
tests/cases/compiler/reservedWords2.ts(6,8): error TS1003: Identifier expected.
tests/cases/compiler/reservedWords2.ts(6,1): error TS2304: Cannot find name 'module'.
tests/cases/compiler/reservedWords2.ts(6,8): error TS1005: ';' expected.
tests/cases/compiler/reservedWords2.ts(7,11): error TS2300: Duplicate identifier '(Missing)'.
tests/cases/compiler/reservedWords2.ts(7,11): error TS1005: ':' expected.
tests/cases/compiler/reservedWords2.ts(7,19): error TS2300: Duplicate identifier '(Missing)'.
@@ -68,10 +68,10 @@ tests/cases/compiler/reservedWords2.ts(10,6): error TS1003: Identifier expected.
~
!!! error TS1005: '=>' expected.
module void {}
!!! error TS2300: Duplicate identifier '(Missing)'.
~~~~~~
!!! error TS2304: Cannot find name 'module'.
~~~~
!!! error TS1003: Identifier expected.
!!! error TS1005: ';' expected.
var {while, return} = { while: 1, return: 2 };
!!! error TS2300: Duplicate identifier '(Missing)'.
@@ -23,6 +23,7 @@ var ;
typeof ;
10;
throw function () { };
module;
void {};
var _a = { while: 1, return: 2 }, = _a.while, = _a.return;
var _b = { this: 1, switch: { continue: 2 } }, = _b.this, = _b.switch.continue;
@@ -0,0 +1,10 @@
tests/cases/compiler/systemModule12.ts(3,15): error TS2307: Cannot find module 'file1'.
==== tests/cases/compiler/systemModule12.ts (1 errors) ====
///<amd-module name='NamedModule'/>
import n from 'file1'
~~~~~~~
!!! error TS2307: Cannot find module 'file1'.
@@ -0,0 +1,14 @@
//// [systemModule12.ts]
///<amd-module name='NamedModule'/>
import n from 'file1'
//// [systemModule12.js]
System.register("NamedModule", [], function(exports_1) {
return {
setters:[],
execute: function() {
}
}
});
+1 -1
View File
@@ -20,7 +20,7 @@ System.register([], function(exports_1) {
(function (M) {
var x = 1;
})(M = M || (M = {}));
exports_1("M", M)
exports_1("M", M);
}
}
});
@@ -20,7 +20,7 @@ System.register([], function(exports_1) {
(function (F) {
var x;
})(F = F || (F = {}));
exports_1("F", F)
exports_1("F", F);
C = (function () {
function C() {
}
@@ -30,14 +30,14 @@ System.register([], function(exports_1) {
(function (C) {
var x;
})(C = C || (C = {}));
exports_1("C", C)
exports_1("C", C);
(function (E) {
})(E || (E = {}));
exports_1("E", E)
exports_1("E", E);
(function (E) {
var x;
})(E = E || (E = {}));
exports_1("E", E)
exports_1("E", E);
}
}
});
@@ -29,11 +29,11 @@ System.register([], function(exports_1) {
(function (TopLevelModule) {
var v;
})(TopLevelModule = TopLevelModule || (TopLevelModule = {}));
exports_1("TopLevelModule", TopLevelModule)
exports_1("TopLevelModule", TopLevelModule);
(function (TopLevelEnum) {
TopLevelEnum[TopLevelEnum["E"] = 0] = "E";
})(TopLevelEnum || (TopLevelEnum = {}));
exports_1("TopLevelEnum", TopLevelEnum)
exports_1("TopLevelEnum", TopLevelEnum);
(function (TopLevelModule2) {
var NonTopLevelClass = (function () {
function NonTopLevelClass() {
@@ -52,7 +52,7 @@ System.register([], function(exports_1) {
})(TopLevelModule2.NonTopLevelEnum || (TopLevelModule2.NonTopLevelEnum = {}));
var NonTopLevelEnum = TopLevelModule2.NonTopLevelEnum;
})(TopLevelModule2 = TopLevelModule2 || (TopLevelModule2 = {}));
exports_1("TopLevelModule2", TopLevelModule2)
exports_1("TopLevelModule2", TopLevelModule2);
}
}
});
@@ -0,0 +1,17 @@
//// [taggedTemplateStringsWithTagNamedDeclare.ts]
function declare(x: any, ...ys: any[]) {
}
declare `Hello ${0} world!`;
//// [taggedTemplateStringsWithTagNamedDeclare.js]
function declare(x) {
var ys = [];
for (var _i = 1; _i < arguments.length; _i++) {
ys[_i - 1] = arguments[_i];
}
}
(_a = ["Hello ", " world!"], _a.raw = ["Hello ", " world!"], declare(_a, 0));
var _a;

Some files were not shown because too many files have changed in this diff Show More