Merge branch 'master' into tsConfigExclude

Conflicts:
	src/compiler/sys.ts
This commit is contained in:
Anders Hejlsberg 2015-06-03 15:12:13 -07:00
commit 990f19b69e
689 changed files with 25222 additions and 6025 deletions

3
.gitattributes vendored
View file

@ -1 +1,2 @@
*.js linguist-language=TypeScript
*.js linguist-language=TypeScript
* -text

4
.gitignore vendored
View file

@ -21,6 +21,7 @@ tests/services/baselines/local/*
tests/baselines/prototyping/local/*
tests/baselines/rwc/*
tests/baselines/test262/*
tests/baselines/reference/projectOutput/*
tests/baselines/local/projectOutput/*
tests/services/baselines/prototyping/local/*
tests/services/browser/typescriptServices.js
@ -46,4 +47,5 @@ scripts/*.js.map
coverage/
internal/
**/.DS_Store
.settings/
.settings/*
!.settings/tasks.json

23
.settings/tasks.json Normal file
View file

@ -0,0 +1,23 @@
// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${file}: the current opened file
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process
{
"version": "0.1.0",
"command": "jake",
"isShellCommand": true,
"showOutput": "silent",
"tasks": [
{
"taskName": "local",
"isBuildCommand": true,
"showOutput": "silent",
"problemMatcher": [
"$tsc"
]
}
]
}

View file

@ -123,6 +123,7 @@ var harnessSources = [
return path.join(harnessDirectory, f);
}).concat([
"incrementalParser.ts",
"jsDocParsing.ts",
"services/colorization.ts",
"services/documentRegistry.ts",
"services/preProcessFile.ts",

View file

@ -5,6 +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)
[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).
@ -29,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.
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`).
Clone a copy of the repo:

13
bin/lib.core.es6.d.ts vendored
View file

@ -1502,6 +1502,11 @@ interface Array<T> {
copyWithin(target: number, start: number, end?: number): T[];
}
interface IArguments {
/** Iterator */
[Symbol.iterator](): IterableIterator<any>;
}
interface ArrayConstructor {
/**
* Creates an array from an array-like object.
@ -1686,14 +1691,6 @@ interface GeneratorFunctionConstructor {
}
declare var GeneratorFunction: GeneratorFunctionConstructor;
interface Generator<T> extends IterableIterator<T> {
next(value?: any): IteratorResult<T>;
throw(exception: any): IteratorResult<T>;
return(value: T): IteratorResult<T>;
[Symbol.iterator](): Generator<T>;
[Symbol.toStringTag]: string;
}
interface Math {
/**
* Returns the number of leading zero bits in the 32-bit binary representation of a number.

16
bin/lib.d.ts vendored
View file

@ -3552,10 +3552,10 @@ declare module Intl {
resolvedOptions(): ResolvedNumberFormatOptions;
}
var NumberFormat: {
new (locales?: string[], options?: NumberFormatOptions): Collator;
new (locale?: string, options?: NumberFormatOptions): Collator;
(locales?: string[], options?: NumberFormatOptions): Collator;
(locale?: string, options?: NumberFormatOptions): Collator;
new (locales?: string[], options?: NumberFormatOptions): NumberFormat;
new (locale?: string, options?: NumberFormatOptions): NumberFormat;
(locales?: string[], options?: NumberFormatOptions): NumberFormat;
(locale?: string, options?: NumberFormatOptions): NumberFormat;
supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[];
supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[];
}
@ -3597,10 +3597,10 @@ declare module Intl {
resolvedOptions(): ResolvedDateTimeFormatOptions;
}
var DateTimeFormat: {
new (locales?: string[], options?: DateTimeFormatOptions): Collator;
new (locale?: string, options?: DateTimeFormatOptions): Collator;
(locales?: string[], options?: DateTimeFormatOptions): Collator;
(locale?: string, options?: DateTimeFormatOptions): Collator;
new (locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat;
new (locale?: string, options?: DateTimeFormatOptions): DateTimeFormat;
(locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat;
(locale?: string, options?: DateTimeFormatOptions): DateTimeFormat;
supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[];
supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[];
}

16
bin/lib.dom.d.ts vendored
View file

@ -2382,10 +2382,10 @@ declare module Intl {
resolvedOptions(): ResolvedNumberFormatOptions;
}
var NumberFormat: {
new (locales?: string[], options?: NumberFormatOptions): Collator;
new (locale?: string, options?: NumberFormatOptions): Collator;
(locales?: string[], options?: NumberFormatOptions): Collator;
(locale?: string, options?: NumberFormatOptions): Collator;
new (locales?: string[], options?: NumberFormatOptions): NumberFormat;
new (locale?: string, options?: NumberFormatOptions): NumberFormat;
(locales?: string[], options?: NumberFormatOptions): NumberFormat;
(locale?: string, options?: NumberFormatOptions): NumberFormat;
supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[];
supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[];
}
@ -2427,10 +2427,10 @@ declare module Intl {
resolvedOptions(): ResolvedDateTimeFormatOptions;
}
var DateTimeFormat: {
new (locales?: string[], options?: DateTimeFormatOptions): Collator;
new (locale?: string, options?: DateTimeFormatOptions): Collator;
(locales?: string[], options?: DateTimeFormatOptions): Collator;
(locale?: string, options?: DateTimeFormatOptions): Collator;
new (locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat;
new (locale?: string, options?: DateTimeFormatOptions): DateTimeFormat;
(locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat;
(locale?: string, options?: DateTimeFormatOptions): DateTimeFormat;
supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[];
supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[];
}

29
bin/lib.es6.d.ts vendored
View file

@ -1502,6 +1502,11 @@ interface Array<T> {
copyWithin(target: number, start: number, end?: number): T[];
}
interface IArguments {
/** Iterator */
[Symbol.iterator](): IterableIterator<any>;
}
interface ArrayConstructor {
/**
* Creates an array from an array-like object.
@ -1686,14 +1691,6 @@ interface GeneratorFunctionConstructor {
}
declare var GeneratorFunction: GeneratorFunctionConstructor;
interface Generator<T> extends IterableIterator<T> {
next(value?: any): IteratorResult<T>;
throw(exception: any): IteratorResult<T>;
return(value: T): IteratorResult<T>;
[Symbol.iterator](): Generator<T>;
[Symbol.toStringTag]: string;
}
interface Math {
/**
* Returns the number of leading zero bits in the 32-bit binary representation of a number.
@ -4933,10 +4930,10 @@ declare module Intl {
resolvedOptions(): ResolvedNumberFormatOptions;
}
var NumberFormat: {
new (locales?: string[], options?: NumberFormatOptions): Collator;
new (locale?: string, options?: NumberFormatOptions): Collator;
(locales?: string[], options?: NumberFormatOptions): Collator;
(locale?: string, options?: NumberFormatOptions): Collator;
new (locales?: string[], options?: NumberFormatOptions): NumberFormat;
new (locale?: string, options?: NumberFormatOptions): NumberFormat;
(locales?: string[], options?: NumberFormatOptions): NumberFormat;
(locale?: string, options?: NumberFormatOptions): NumberFormat;
supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[];
supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[];
}
@ -4978,10 +4975,10 @@ declare module Intl {
resolvedOptions(): ResolvedDateTimeFormatOptions;
}
var DateTimeFormat: {
new (locales?: string[], options?: DateTimeFormatOptions): Collator;
new (locale?: string, options?: DateTimeFormatOptions): Collator;
(locales?: string[], options?: DateTimeFormatOptions): Collator;
(locale?: string, options?: DateTimeFormatOptions): Collator;
new (locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat;
new (locale?: string, options?: DateTimeFormatOptions): DateTimeFormat;
(locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat;
(locale?: string, options?: DateTimeFormatOptions): DateTimeFormat;
supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[];
supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[];
}

View file

@ -2382,10 +2382,10 @@ declare module Intl {
resolvedOptions(): ResolvedNumberFormatOptions;
}
var NumberFormat: {
new (locales?: string[], options?: NumberFormatOptions): Collator;
new (locale?: string, options?: NumberFormatOptions): Collator;
(locales?: string[], options?: NumberFormatOptions): Collator;
(locale?: string, options?: NumberFormatOptions): Collator;
new (locales?: string[], options?: NumberFormatOptions): NumberFormat;
new (locale?: string, options?: NumberFormatOptions): NumberFormat;
(locales?: string[], options?: NumberFormatOptions): NumberFormat;
(locale?: string, options?: NumberFormatOptions): NumberFormat;
supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[];
supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[];
}
@ -2427,10 +2427,10 @@ declare module Intl {
resolvedOptions(): ResolvedDateTimeFormatOptions;
}
var DateTimeFormat: {
new (locales?: string[], options?: DateTimeFormatOptions): Collator;
new (locale?: string, options?: DateTimeFormatOptions): Collator;
(locales?: string[], options?: DateTimeFormatOptions): Collator;
(locale?: string, options?: DateTimeFormatOptions): Collator;
new (locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat;
new (locale?: string, options?: DateTimeFormatOptions): DateTimeFormat;
(locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat;
(locale?: string, options?: DateTimeFormatOptions): DateTimeFormat;
supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[];
supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[];
}

2736
bin/tsc.js

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

125
bin/typescript.d.ts vendored
View file

@ -251,8 +251,30 @@ declare module "typescript" {
ShorthandPropertyAssignment = 226,
EnumMember = 227,
SourceFile = 228,
SyntaxList = 229,
Count = 230,
JSDocTypeExpression = 229,
JSDocAllType = 230,
JSDocUnknownType = 231,
JSDocArrayType = 232,
JSDocUnionType = 233,
JSDocTupleType = 234,
JSDocNullableType = 235,
JSDocNonNullableType = 236,
JSDocRecordType = 237,
JSDocRecordMember = 238,
JSDocTypeReference = 239,
JSDocOptionalType = 240,
JSDocFunctionType = 241,
JSDocVariadicType = 242,
JSDocConstructorType = 243,
JSDocThisType = 244,
JSDocComment = 245,
JSDocTag = 246,
JSDocParameterTag = 247,
JSDocReturnTag = 248,
JSDocTypeTag = 249,
JSDocTemplateTag = 250,
SyntaxList = 251,
Count = 252,
FirstAssignment = 53,
LastAssignment = 64,
FirstReservedWord = 66,
@ -495,7 +517,7 @@ declare module "typescript" {
}
interface YieldExpression extends Expression {
asteriskToken?: Node;
expression: Expression;
expression?: Expression;
}
interface BinaryExpression extends Expression {
left: Expression;
@ -666,7 +688,7 @@ declare module "typescript" {
interface ClassElement extends Declaration {
_classElementBrand: any;
}
interface InterfaceDeclaration extends Declaration, ModuleElement {
interface InterfaceDeclaration extends Declaration, Statement {
name: Identifier;
typeParameters?: NodeArray<TypeParameterDeclaration>;
heritageClauses?: NodeArray<HeritageClause>;
@ -676,7 +698,7 @@ declare module "typescript" {
token: SyntaxKind;
types?: NodeArray<ExpressionWithTypeArguments>;
}
interface TypeAliasDeclaration extends Declaration, ModuleElement {
interface TypeAliasDeclaration extends Declaration, Statement {
name: Identifier;
type: TypeNode;
}
@ -684,7 +706,7 @@ declare module "typescript" {
name: DeclarationName;
initializer?: Expression;
}
interface EnumDeclaration extends Declaration, ModuleElement {
interface EnumDeclaration extends Declaration, Statement {
name: Identifier;
members: NodeArray<EnumMember>;
}
@ -739,6 +761,82 @@ declare module "typescript" {
hasTrailingNewLine?: boolean;
kind: SyntaxKind;
}
interface JSDocTypeExpression extends Node {
type: JSDocType;
}
interface JSDocType extends TypeNode {
_jsDocTypeBrand: any;
}
interface JSDocAllType extends JSDocType {
_JSDocAllTypeBrand: any;
}
interface JSDocUnknownType extends JSDocType {
_JSDocUnknownTypeBrand: any;
}
interface JSDocArrayType extends JSDocType {
elementType: JSDocType;
}
interface JSDocUnionType extends JSDocType {
types: NodeArray<JSDocType>;
}
interface JSDocTupleType extends JSDocType {
types: NodeArray<JSDocType>;
}
interface JSDocNonNullableType extends JSDocType {
type: JSDocType;
}
interface JSDocNullableType extends JSDocType {
type: JSDocType;
}
interface JSDocRecordType extends JSDocType, TypeLiteralNode {
members: NodeArray<JSDocRecordMember>;
}
interface JSDocTypeReference extends JSDocType {
name: EntityName;
typeArguments: NodeArray<JSDocType>;
}
interface JSDocOptionalType extends JSDocType {
type: JSDocType;
}
interface JSDocFunctionType extends JSDocType, SignatureDeclaration {
parameters: NodeArray<ParameterDeclaration>;
type: JSDocType;
}
interface JSDocVariadicType extends JSDocType {
type: JSDocType;
}
interface JSDocConstructorType extends JSDocType {
type: JSDocType;
}
interface JSDocThisType extends JSDocType {
type: JSDocType;
}
interface JSDocRecordMember extends PropertyDeclaration {
name: Identifier | LiteralExpression;
type?: JSDocType;
}
interface JSDocComment extends Node {
tags: NodeArray<JSDocTag>;
}
interface JSDocTag extends Node {
atToken: Node;
tagName: Identifier;
}
interface JSDocTemplateTag extends JSDocTag {
typeParameters: NodeArray<TypeParameterDeclaration>;
}
interface JSDocReturnTag extends JSDocTag {
typeExpression: JSDocTypeExpression;
}
interface JSDocTypeTag extends JSDocTag {
typeExpression: JSDocTypeExpression;
}
interface JSDocParameterTag extends JSDocTag {
preParameterName?: Identifier;
typeExpression?: JSDocTypeExpression;
postParameterName?: Identifier;
isBracketed: boolean;
}
interface SourceFile extends Declaration {
statements: NodeArray<ModuleElement>;
endOfFileToken: Node;
@ -901,6 +999,7 @@ declare module "typescript" {
UseOnlyExternalAliasing = 2,
}
const enum SymbolFlags {
None = 0,
FunctionScopedVariable = 1,
BlockScopedVariable = 2,
Property = 4,
@ -959,10 +1058,8 @@ declare module "typescript" {
AliasExcludes = 8388608,
ModuleMember = 8914931,
ExportHasLocal = 944,
HasLocals = 255504,
HasExports = 1952,
HasMembers = 6240,
IsContainer = 262128,
PropertyOrAccessor = 98308,
Export = 7340032,
}
@ -970,9 +1067,9 @@ declare module "typescript" {
flags: SymbolFlags;
name: string;
declarations?: Declaration[];
valueDeclaration?: Declaration;
members?: SymbolTable;
exports?: SymbolTable;
valueDeclaration?: Declaration;
}
interface SymbolTable {
[index: string]: Symbol;
@ -1011,6 +1108,8 @@ declare module "typescript" {
}
interface InterfaceType extends ObjectType {
typeParameters: TypeParameter[];
outerTypeParameters: TypeParameter[];
localTypeParameters: TypeParameter[];
}
interface InterfaceTypeWithBaseTypes extends InterfaceType {
baseTypes: ObjectType[];
@ -1114,7 +1213,8 @@ declare module "typescript" {
target?: ScriptTarget;
version?: boolean;
watch?: boolean;
separateCompilation?: boolean;
isolatedModules?: boolean;
experimentalDecorators?: boolean;
emitDecoratorMetadata?: boolean;
[option: string]: string | number | boolean;
}
@ -1226,8 +1326,6 @@ declare module "typescript" {
function getTrailingCommentRanges(text: string, pos: number): CommentRange[];
function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean;
function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean;
/** Creates a scanner over a (possibly unspecified) range of a piece of text. */
function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner;
}
declare module "typescript" {
function getDefaultLibFileName(options: CompilerOptions): string;
@ -1256,6 +1354,7 @@ declare module "typescript" {
* Vn.
*/
function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
function getTypeParameterOwner(d: Declaration): Declaration;
}
declare module "typescript" {
function getNodeConstructor(kind: SyntaxKind): new () => Node;
@ -1812,6 +1911,7 @@ declare module "typescript" {
static typeParameterName: string;
static typeAliasName: string;
static parameterName: string;
static docCommentTagName: string;
}
const enum ClassificationType {
comment = 1,
@ -1831,6 +1931,7 @@ declare module "typescript" {
typeParameterName = 15,
typeAliasName = 16,
parameterName = 17,
docCommentTagName = 18,
}
interface DisplayPartsSymbolWriter extends SymbolWriter {
displayParts(): SymbolDisplayPart[];

File diff suppressed because it is too large Load diff

View file

@ -251,8 +251,30 @@ declare module ts {
ShorthandPropertyAssignment = 226,
EnumMember = 227,
SourceFile = 228,
SyntaxList = 229,
Count = 230,
JSDocTypeExpression = 229,
JSDocAllType = 230,
JSDocUnknownType = 231,
JSDocArrayType = 232,
JSDocUnionType = 233,
JSDocTupleType = 234,
JSDocNullableType = 235,
JSDocNonNullableType = 236,
JSDocRecordType = 237,
JSDocRecordMember = 238,
JSDocTypeReference = 239,
JSDocOptionalType = 240,
JSDocFunctionType = 241,
JSDocVariadicType = 242,
JSDocConstructorType = 243,
JSDocThisType = 244,
JSDocComment = 245,
JSDocTag = 246,
JSDocParameterTag = 247,
JSDocReturnTag = 248,
JSDocTypeTag = 249,
JSDocTemplateTag = 250,
SyntaxList = 251,
Count = 252,
FirstAssignment = 53,
LastAssignment = 64,
FirstReservedWord = 66,
@ -495,7 +517,7 @@ declare module ts {
}
interface YieldExpression extends Expression {
asteriskToken?: Node;
expression: Expression;
expression?: Expression;
}
interface BinaryExpression extends Expression {
left: Expression;
@ -666,7 +688,7 @@ declare module ts {
interface ClassElement extends Declaration {
_classElementBrand: any;
}
interface InterfaceDeclaration extends Declaration, ModuleElement {
interface InterfaceDeclaration extends Declaration, Statement {
name: Identifier;
typeParameters?: NodeArray<TypeParameterDeclaration>;
heritageClauses?: NodeArray<HeritageClause>;
@ -676,7 +698,7 @@ declare module ts {
token: SyntaxKind;
types?: NodeArray<ExpressionWithTypeArguments>;
}
interface TypeAliasDeclaration extends Declaration, ModuleElement {
interface TypeAliasDeclaration extends Declaration, Statement {
name: Identifier;
type: TypeNode;
}
@ -684,7 +706,7 @@ declare module ts {
name: DeclarationName;
initializer?: Expression;
}
interface EnumDeclaration extends Declaration, ModuleElement {
interface EnumDeclaration extends Declaration, Statement {
name: Identifier;
members: NodeArray<EnumMember>;
}
@ -739,6 +761,82 @@ declare module ts {
hasTrailingNewLine?: boolean;
kind: SyntaxKind;
}
interface JSDocTypeExpression extends Node {
type: JSDocType;
}
interface JSDocType extends TypeNode {
_jsDocTypeBrand: any;
}
interface JSDocAllType extends JSDocType {
_JSDocAllTypeBrand: any;
}
interface JSDocUnknownType extends JSDocType {
_JSDocUnknownTypeBrand: any;
}
interface JSDocArrayType extends JSDocType {
elementType: JSDocType;
}
interface JSDocUnionType extends JSDocType {
types: NodeArray<JSDocType>;
}
interface JSDocTupleType extends JSDocType {
types: NodeArray<JSDocType>;
}
interface JSDocNonNullableType extends JSDocType {
type: JSDocType;
}
interface JSDocNullableType extends JSDocType {
type: JSDocType;
}
interface JSDocRecordType extends JSDocType, TypeLiteralNode {
members: NodeArray<JSDocRecordMember>;
}
interface JSDocTypeReference extends JSDocType {
name: EntityName;
typeArguments: NodeArray<JSDocType>;
}
interface JSDocOptionalType extends JSDocType {
type: JSDocType;
}
interface JSDocFunctionType extends JSDocType, SignatureDeclaration {
parameters: NodeArray<ParameterDeclaration>;
type: JSDocType;
}
interface JSDocVariadicType extends JSDocType {
type: JSDocType;
}
interface JSDocConstructorType extends JSDocType {
type: JSDocType;
}
interface JSDocThisType extends JSDocType {
type: JSDocType;
}
interface JSDocRecordMember extends PropertyDeclaration {
name: Identifier | LiteralExpression;
type?: JSDocType;
}
interface JSDocComment extends Node {
tags: NodeArray<JSDocTag>;
}
interface JSDocTag extends Node {
atToken: Node;
tagName: Identifier;
}
interface JSDocTemplateTag extends JSDocTag {
typeParameters: NodeArray<TypeParameterDeclaration>;
}
interface JSDocReturnTag extends JSDocTag {
typeExpression: JSDocTypeExpression;
}
interface JSDocTypeTag extends JSDocTag {
typeExpression: JSDocTypeExpression;
}
interface JSDocParameterTag extends JSDocTag {
preParameterName?: Identifier;
typeExpression?: JSDocTypeExpression;
postParameterName?: Identifier;
isBracketed: boolean;
}
interface SourceFile extends Declaration {
statements: NodeArray<ModuleElement>;
endOfFileToken: Node;
@ -901,6 +999,7 @@ declare module ts {
UseOnlyExternalAliasing = 2,
}
const enum SymbolFlags {
None = 0,
FunctionScopedVariable = 1,
BlockScopedVariable = 2,
Property = 4,
@ -959,10 +1058,8 @@ declare module ts {
AliasExcludes = 8388608,
ModuleMember = 8914931,
ExportHasLocal = 944,
HasLocals = 255504,
HasExports = 1952,
HasMembers = 6240,
IsContainer = 262128,
PropertyOrAccessor = 98308,
Export = 7340032,
}
@ -970,9 +1067,9 @@ declare module ts {
flags: SymbolFlags;
name: string;
declarations?: Declaration[];
valueDeclaration?: Declaration;
members?: SymbolTable;
exports?: SymbolTable;
valueDeclaration?: Declaration;
}
interface SymbolTable {
[index: string]: Symbol;
@ -1011,6 +1108,8 @@ declare module ts {
}
interface InterfaceType extends ObjectType {
typeParameters: TypeParameter[];
outerTypeParameters: TypeParameter[];
localTypeParameters: TypeParameter[];
}
interface InterfaceTypeWithBaseTypes extends InterfaceType {
baseTypes: ObjectType[];
@ -1114,7 +1213,8 @@ declare module ts {
target?: ScriptTarget;
version?: boolean;
watch?: boolean;
separateCompilation?: boolean;
isolatedModules?: boolean;
experimentalDecorators?: boolean;
emitDecoratorMetadata?: boolean;
[option: string]: string | number | boolean;
}
@ -1226,8 +1326,6 @@ declare module ts {
function getTrailingCommentRanges(text: string, pos: number): CommentRange[];
function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean;
function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean;
/** Creates a scanner over a (possibly unspecified) range of a piece of text. */
function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner;
}
declare module ts {
function getDefaultLibFileName(options: CompilerOptions): string;
@ -1256,6 +1354,7 @@ declare module ts {
* Vn.
*/
function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
function getTypeParameterOwner(d: Declaration): Declaration;
}
declare module ts {
function getNodeConstructor(kind: SyntaxKind): new () => Node;
@ -1812,6 +1911,7 @@ declare module ts {
static typeParameterName: string;
static typeAliasName: string;
static parameterName: string;
static docCommentTagName: string;
}
const enum ClassificationType {
comment = 1,
@ -1831,6 +1931,7 @@ declare module ts {
typeParameterName = 15,
typeAliasName = 16,
parameterName = 17,
docCommentTagName = 18,
}
interface DisplayPartsSymbolWriter extends SymbolWriter {
displayParts(): SymbolDisplayPart[];

File diff suppressed because it is too large Load diff

View file

@ -2,13 +2,8 @@
"name": "typescript",
"author": "Microsoft Corp.",
"homepage": "http://typescriptlang.org/",
"version": "1.5.2",
"licenses": [
{
"type": "Apache License 2.0",
"url": "https://github.com/Microsoft/TypeScript/blob/master/LICENSE.txt"
}
],
"version": "1.5.3",
"license": "Apache-2.0",
"description": "TypeScript is a language for application scale JavaScript development",
"keywords": [
"TypeScript",

View file

@ -52,13 +52,38 @@ module ts {
}
}
export function bindSourceFile(file: SourceFile): void {
const enum ContainerFlags {
// The current node is not a container, and no container manipulation should happen before
// recursing into it.
None = 0,
// The current node is a container. It should be set as the current container (and block-
// container) before recursing into it. The current node does not have locals. Examples:
//
// Classes, ObjectLiterals, TypeLiterals, Interfaces...
IsContainer = 1 << 0,
// The current node is a block-scoped-container. It should be set as the current block-
// container before recursing into it. Examples:
//
// Blocks (when not parented by functions), Catch clauses, For/For-in/For-of statements...
IsBlockScopedContainer = 1 << 1,
HasLocals = 1 << 2,
// If the current node is a container that also container that also contains locals. Examples:
//
// Functions, Methods, Modules, Source-files.
IsContainerWithLocals = IsContainer | HasLocals
}
export function bindSourceFile(file: SourceFile) {
let start = new Date().getTime();
bindSourceFileWorker(file);
bindTime += new Date().getTime() - start;
}
function bindSourceFileWorker(file: SourceFile): void {
function bindSourceFileWorker(file: SourceFile) {
let parent: Node;
let container: Node;
let blockScopeContainer: Node;
@ -67,33 +92,38 @@ module ts {
let Symbol = objectAllocator.getSymbolConstructor();
if (!file.locals) {
file.locals = {};
container = file;
setBlockScopeContainer(file, /*cleanLocals*/ false);
bind(file);
file.symbolCount = symbolCount;
}
return;
function createSymbol(flags: SymbolFlags, name: string): Symbol {
symbolCount++;
return new Symbol(flags, name);
}
function setBlockScopeContainer(node: Node, cleanLocals: boolean) {
blockScopeContainer = node;
if (cleanLocals) {
blockScopeContainer.locals = undefined;
}
}
function addDeclarationToSymbol(symbol: Symbol, node: Declaration, symbolFlags: SymbolFlags) {
symbol.flags |= symbolFlags;
function addDeclarationToSymbol(symbol: Symbol, node: Declaration, symbolKind: SymbolFlags) {
symbol.flags |= symbolKind;
if (!symbol.declarations) symbol.declarations = [];
symbol.declarations.push(node);
if (symbolKind & SymbolFlags.HasExports && !symbol.exports) symbol.exports = {};
if (symbolKind & SymbolFlags.HasMembers && !symbol.members) symbol.members = {};
node.symbol = symbol;
if (symbolKind & SymbolFlags.Value && !symbol.valueDeclaration) symbol.valueDeclaration = node;
if (!symbol.declarations) {
symbol.declarations = [];
}
symbol.declarations.push(node);
if (symbolFlags & SymbolFlags.HasExports && !symbol.exports) {
symbol.exports = {};
}
if (symbolFlags & SymbolFlags.HasMembers && !symbol.members) {
symbol.members = {};
}
if (symbolFlags & SymbolFlags.Value && !symbol.valueDeclaration) {
symbol.valueDeclaration = node;
}
}
// Should not be called on a declaration with a computed property name,
@ -111,12 +141,12 @@ module ts {
return (<Identifier | LiteralExpression>node.name).text;
}
switch (node.kind) {
case SyntaxKind.ConstructorType:
case SyntaxKind.Constructor:
return "__constructor";
case SyntaxKind.FunctionType:
case SyntaxKind.CallSignature:
return "__call";
case SyntaxKind.ConstructorType:
case SyntaxKind.ConstructSignature:
return "__new";
case SyntaxKind.IndexSignature:
@ -135,7 +165,7 @@ module ts {
return node.name ? declarationNameToString(node.name) : getDeclarationName(node);
}
function declareSymbol(symbols: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol {
function declareSymbol(symbolTable: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol {
Debug.assert(!hasDynamicName(node));
// The exported symbol for an export default function/class node is always named "default"
@ -143,7 +173,27 @@ module ts {
let symbol: Symbol;
if (name !== undefined) {
symbol = hasProperty(symbols, name) ? symbols[name] : (symbols[name] = createSymbol(0, name));
// Check and see if the symbol table already has a symbol with this name. If not,
// create a new symbol with this name and add it to the table. Note that we don't
// give the new symbol any flags *yet*. This ensures that it will not conflict
// witht he 'excludes' flags we pass in.
//
// If we do get an existing symbol, see if it conflicts with the new symbol we're
// creating. For example, a 'var' symbol and a 'class' symbol will conflict within
// the same symbol table. If we have a conflict, report the issue on each
// declaration we have for this symbol, and then create a new symbol for this
// declaration.
//
// If we created a new symbol, either because we didn't have a symbol with this name
// in the symbol table, or we conflicted with an existing symbol, then just add this
// node as the sole declaration of the new symbol.
//
// Otherwise, we'll be merging into a compatible existing symbol (for example when
// you have multiple 'vars' with the same name in the same container). In this case
// just add this node into the declarations list of the symbol.
symbol = hasProperty(symbolTable, name)
? symbolTable[name]
: (symbolTable[name] = createSymbol(SymbolFlags.None, name));
if (symbol.flags & excludes) {
if (node.name) {
node.name.parent = node;
@ -152,51 +202,34 @@ module ts {
// Report errors every position with duplicate declaration
// Report errors on previous encountered declarations
let message = symbol.flags & SymbolFlags.BlockScopedVariable
? Diagnostics.Cannot_redeclare_block_scoped_variable_0
? Diagnostics.Cannot_redeclare_block_scoped_variable_0
: Diagnostics.Duplicate_identifier_0;
forEach(symbol.declarations, declaration => {
file.bindDiagnostics.push(createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration)));
});
file.bindDiagnostics.push(createDiagnosticForNode(node.name || node, message, getDisplayName(node)));
symbol = createSymbol(0, name);
symbol = createSymbol(SymbolFlags.None, name);
}
}
else {
symbol = createSymbol(0, "__missing");
symbol = createSymbol(SymbolFlags.None, "__missing");
}
addDeclarationToSymbol(symbol, node, includes);
symbol.parent = parent;
if ((node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression) && symbol.exports) {
// TypeScript 1.0 spec (April 2014): 8.4
// Every class automatically contains a static property member named 'prototype',
// the type of which is an instantiation of the class type with type Any supplied as a type argument for each type parameter.
// It is an error to explicitly declare a static property member with the name 'prototype'.
let prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype");
if (hasProperty(symbol.exports, prototypeSymbol.name)) {
if (node.name) {
node.name.parent = node;
}
file.bindDiagnostics.push(createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0],
Diagnostics.Duplicate_identifier_0, prototypeSymbol.name));
}
symbol.exports[prototypeSymbol.name] = prototypeSymbol;
prototypeSymbol.parent = symbol;
}
return symbol;
}
function declareModuleMember(node: Declaration, symbolKind: SymbolFlags, symbolExcludes: SymbolFlags) {
function declareModuleMember(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): Symbol {
let hasExportModifier = getCombinedNodeFlags(node) & NodeFlags.Export;
if (symbolKind & SymbolFlags.Alias) {
if (symbolFlags & SymbolFlags.Alias) {
if (node.kind === SyntaxKind.ExportSpecifier || (node.kind === SyntaxKind.ImportEqualsDeclaration && hasExportModifier)) {
declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes);
return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
}
else {
declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes);
return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes);
}
}
else {
@ -212,70 +245,172 @@ module ts {
// but return the export symbol (by calling getExportSymbolOfValueSymbolIfExported). That way
// when the emitter comes back to it, it knows not to qualify the name if it was found in a containing scope.
if (hasExportModifier || container.flags & NodeFlags.ExportContext) {
let exportKind = (symbolKind & SymbolFlags.Value ? SymbolFlags.ExportValue : 0) |
(symbolKind & SymbolFlags.Type ? SymbolFlags.ExportType : 0) |
(symbolKind & SymbolFlags.Namespace ? SymbolFlags.ExportNamespace : 0);
let exportKind =
(symbolFlags & SymbolFlags.Value ? SymbolFlags.ExportValue : 0) |
(symbolFlags & SymbolFlags.Type ? SymbolFlags.ExportType : 0) |
(symbolFlags & SymbolFlags.Namespace ? SymbolFlags.ExportNamespace : 0);
let local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes);
local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes);
local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
node.localSymbol = local;
return local;
}
else {
declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes);
return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes);
}
}
}
// All container nodes are kept on a linked list in declaration order. This list is used by the getLocalNameOfContainer function
// in the type checker to validate that the local name used for a container is unique.
function bindChildren(node: Node, symbolKind: SymbolFlags, isBlockScopeContainer: boolean) {
if (symbolKind & SymbolFlags.HasLocals) {
node.locals = {};
}
// All container nodes are kept on a linked list in declaration order. This list is used by
// the getLocalNameOfContainer function in the type checker to validate that the local name
// used for a container is unique.
function bindChildren(node: Node) {
// Before we recurse into a node's chilren, we first save the existing parent, container
// and block-container. Then after we pop out of processing the children, we restore
// these saved values.
let saveParent = parent;
let saveContainer = container;
let savedBlockScopeContainer = blockScopeContainer;
// This node will now be set as the parent of all of its children as we recurse into them.
parent = node;
if (symbolKind & SymbolFlags.IsContainer) {
container = node;
// Depending on what kind of node this is, we may have to adjust the current container
// and block-container. If the current node is a container, then it is automatically
// considered the current block-container as well. Also, for containers that we know
// may contain locals, we proactively initialize the .locals field. We do this because
// it's highly likely that the .locals will be needed to place some child in (for example,
// a parameter, or variable declaration).
//
// However, we do not proactively create the .locals for block-containers because it's
// totally normal and common for block-containers to never actually have a block-scoped
// variable in them. We don't want to end up allocating an object for every 'block' we
// run into when most of them won't be necessary.
//
// Finally, if this is a block-container, then we clear out any existing .locals object
// it may contain within it. This happens in incremental scenarios. Because we can be
// reusing a node from a previous compilation, that node may have had 'locals' created
// for it. We must clear this so we don't accidently move any stale data forward from
// a previous compilation.
let containerFlags = getContainerFlags(node);
if (containerFlags & ContainerFlags.IsContainer) {
container = blockScopeContainer = node;
if (containerFlags & ContainerFlags.HasLocals) {
container.locals = {};
}
addToContainerChain(container);
}
if (isBlockScopeContainer) {
// in incremental scenarios we might reuse nodes that already have locals being allocated
// during the bind step these locals should be dropped to prevent using stale data.
// locals should always be dropped unless they were previously initialized by the binder
// these cases are:
// - node has locals (symbolKind & HasLocals) !== 0
// - node is a source file
setBlockScopeContainer(node, /*cleanLocals*/ (symbolKind & SymbolFlags.HasLocals) === 0 && node.kind !== SyntaxKind.SourceFile);
else if (containerFlags & ContainerFlags.IsBlockScopedContainer) {
blockScopeContainer = node;
blockScopeContainer.locals = undefined;
}
forEachChild(node, bind);
container = saveContainer;
parent = saveParent;
blockScopeContainer = savedBlockScopeContainer;
}
function addToContainerChain(node: Node) {
if (lastContainer) {
lastContainer.nextContainer = node;
function getContainerFlags(node: Node): ContainerFlags {
switch (node.kind) {
case SyntaxKind.ClassExpression:
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.TypeLiteral:
case SyntaxKind.ObjectLiteralExpression:
return ContainerFlags.IsContainer;
case SyntaxKind.CallSignature:
case SyntaxKind.ConstructSignature:
case SyntaxKind.IndexSignature:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.Constructor:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.FunctionType:
case SyntaxKind.ConstructorType:
case SyntaxKind.FunctionExpression:
case SyntaxKind.ArrowFunction:
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.SourceFile:
return ContainerFlags.IsContainerWithLocals;
case SyntaxKind.CatchClause:
case SyntaxKind.ForStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.ForOfStatement:
case SyntaxKind.CaseBlock:
return ContainerFlags.IsBlockScopedContainer;
case SyntaxKind.Block:
// do not treat blocks directly inside a function as a block-scoped-container.
// Locals that reside in this block should go to the function locals. Othewise 'x'
// would not appear to be a redeclaration of a block scoped local in the following
// example:
//
// function foo() {
// var x;
// let x;
// }
//
// If we placed 'var x' into the function locals and 'let x' into the locals of
// the block, then there would be no collision.
//
// By not creating a new block-scoped-container here, we ensure that both 'var x'
// and 'let x' go into the Function-container's locals, and we do get a collision
// conflict.
return isFunctionLike(node.parent) ? ContainerFlags.None : ContainerFlags.IsBlockScopedContainer;
}
lastContainer = node;
return ContainerFlags.None;
}
function bindDeclaration(node: Declaration, symbolKind: SymbolFlags, symbolExcludes: SymbolFlags, isBlockScopeContainer: boolean) {
function addToContainerChain(next: Node) {
if (lastContainer) {
lastContainer.nextContainer = next;
}
lastContainer = next;
}
function declareSymbolAndAddToSymbolTable(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): void {
// Just call this directly so that the return type of this function stays "void".
declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes);
}
function declareSymbolAndAddToSymbolTableWorker(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): Symbol {
switch (container.kind) {
// Modules, source files, and classes need specialized handling for how their
// members are declared (for example, a member of a class will go into a specific
// symbol table depending on if it is static or not). As such, we defer to
// specialized handlers to take care of declaring these child members.
case SyntaxKind.ModuleDeclaration:
declareModuleMember(node, symbolKind, symbolExcludes);
break;
return declareModuleMember(node, symbolFlags, symbolExcludes);
case SyntaxKind.SourceFile:
if (isExternalModule(<SourceFile>container)) {
declareModuleMember(node, symbolKind, symbolExcludes);
break;
}
return declareSourceFileMember(node, symbolFlags, symbolExcludes);
case SyntaxKind.ClassExpression:
case SyntaxKind.ClassDeclaration:
return declareClassMember(node, symbolFlags, symbolExcludes);
case SyntaxKind.EnumDeclaration:
return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
case SyntaxKind.TypeLiteral:
case SyntaxKind.ObjectLiteralExpression:
case SyntaxKind.InterfaceDeclaration:
// Interface/Object-types always have their children added to the 'members' of
// their container. They are only accessible through an instance of their
// container, and are never in scope otherwise (even inside the body of the
// object / type / interface declaring them).
return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes);
case SyntaxKind.FunctionType:
case SyntaxKind.ConstructorType:
case SyntaxKind.CallSignature:
@ -289,29 +424,34 @@ module ts {
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
case SyntaxKind.ArrowFunction:
declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes);
break;
case SyntaxKind.ClassExpression:
case SyntaxKind.ClassDeclaration:
if (node.flags & NodeFlags.Static) {
declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes);
break;
}
case SyntaxKind.TypeLiteral:
case SyntaxKind.ObjectLiteralExpression:
case SyntaxKind.InterfaceDeclaration:
declareSymbol(container.symbol.members, container.symbol, node, symbolKind, symbolExcludes);
break;
case SyntaxKind.EnumDeclaration:
declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes);
break;
// All the children of these container types are never visible through another
// symbol (i.e. through another symbol's 'exports' or 'members'). Instead,
// they're only accessed 'lexically' (i.e. from code that exists underneath
// their container in the tree. To accomplish this, we simply add their declared
// symbol to the 'locals' of the container. These symbols can then be found as
// the type checker walks up the containers, checking them for matching names.
return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes);
}
bindChildren(node, symbolKind, isBlockScopeContainer);
}
function declareClassMember(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) {
return node.flags & NodeFlags.Static
? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes)
: declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes);
}
function declareSourceFileMember(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) {
return isExternalModule(file)
? declareModuleMember(node, symbolFlags, symbolExcludes)
: declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes);
}
function isAmbientContext(node: Node): boolean {
while (node) {
if (node.flags & NodeFlags.Ambient) return true;
if (node.flags & NodeFlags.Ambient) {
return true;
}
node = node.parent;
}
return false;
@ -343,15 +483,16 @@ module ts {
function bindModuleDeclaration(node: ModuleDeclaration) {
setExportContextFlag(node);
if (node.name.kind === SyntaxKind.StringLiteral) {
bindDeclaration(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes, /*isBlockScopeContainer*/ true);
declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes);
}
else {
let state = getModuleInstanceState(node);
if (state === ModuleInstanceState.NonInstantiated) {
bindDeclaration(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes, /*isBlockScopeContainer*/ true);
declareSymbolAndAddToSymbolTable(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes);
}
else {
bindDeclaration(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes, /*isBlockScopeContainer*/ true);
declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes);
let currentModuleIsConstEnumOnly = state === ModuleInstanceState.ConstEnumOnly;
if (node.symbol.constEnumOnlyModule === undefined) {
// non-merged case - use the current state
@ -372,35 +513,27 @@ module ts {
// We do that by making an anonymous type literal symbol, and then setting the function
// symbol as its sole member. To the rest of the system, this symbol will be indistinguishable
// from an actual type literal symbol you would have gotten had you used the long form.
let symbol = createSymbol(SymbolFlags.Signature, getDeclarationName(node));
addDeclarationToSymbol(symbol, node, SymbolFlags.Signature);
bindChildren(node, SymbolFlags.Signature, /*isBlockScopeContainer:*/ false);
let typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type");
addDeclarationToSymbol(typeLiteralSymbol, node, SymbolFlags.TypeLiteral);
typeLiteralSymbol.members = {};
typeLiteralSymbol.members[node.kind === SyntaxKind.FunctionType ? "__call" : "__new"] = symbol
typeLiteralSymbol.members = { [symbol.name]: symbol };
}
function bindAnonymousDeclaration(node: Declaration, symbolKind: SymbolFlags, name: string, isBlockScopeContainer: boolean) {
let symbol = createSymbol(symbolKind, name);
addDeclarationToSymbol(symbol, node, symbolKind);
bindChildren(node, symbolKind, isBlockScopeContainer);
function bindAnonymousDeclaration(node: Declaration, symbolFlags: SymbolFlags, name: string) {
let symbol = createSymbol(symbolFlags, name);
addDeclarationToSymbol(symbol, node, symbolFlags);
}
function bindCatchVariableDeclaration(node: CatchClause) {
bindChildren(node, /*symbolKind:*/ 0, /*isBlockScopeContainer:*/ true);
}
function bindBlockScopedDeclaration(node: Declaration, symbolKind: SymbolFlags, symbolExcludes: SymbolFlags) {
function bindBlockScopedDeclaration(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) {
switch (blockScopeContainer.kind) {
case SyntaxKind.ModuleDeclaration:
declareModuleMember(node, symbolKind, symbolExcludes);
declareModuleMember(node, symbolFlags, symbolExcludes);
break;
case SyntaxKind.SourceFile:
if (isExternalModule(<SourceFile>container)) {
declareModuleMember(node, symbolKind, symbolExcludes);
declareModuleMember(node, symbolFlags, symbolExcludes);
break;
}
// fall through.
@ -409,9 +542,8 @@ module ts {
blockScopeContainer.locals = {};
addToContainerChain(blockScopeContainer);
}
declareSymbol(blockScopeContainer.locals, undefined, node, symbolKind, symbolExcludes);
declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes);
}
bindChildren(node, symbolKind, /*isBlockScopeContainer*/ false);
}
function bindBlockScopedVariableDeclaration(node: Declaration) {
@ -424,187 +556,197 @@ module ts {
function bind(node: Node) {
node.parent = parent;
// First we bind declaration nodes to a symbol if possible. We'll both create a symbol
// and then potentially add the symbol to an appropriate symbol table. Possible
// destination symbol tables are:
//
// 1) The 'exports' table of the current container's symbol.
// 2) The 'members' table of the current container's symbol.
// 3) The 'locals' table of the current container.
//
// However, not all symbols will end up in any of these tables. 'Anonymous' symbols
// (like TypeLiterals for example) will not be put in any table.
bindWorker(node);
// Then we recurse into the children of the node to bind them as well. For certain
// symbols we do specialized work when we recurse. For example, we'll keep track of
// the current 'container' node when it changes. This helps us know which symbol table
// a local should go into for example.
bindChildren(node);
}
function bindWorker(node: Node) {
switch (node.kind) {
case SyntaxKind.TypeParameter:
bindDeclaration(<Declaration>node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes, /*isBlockScopeContainer*/ false);
break;
return declareSymbolAndAddToSymbolTable(<Declaration>node, SymbolFlags.TypeParameter, SymbolFlags.TypeParameterExcludes);
case SyntaxKind.Parameter:
bindParameter(<ParameterDeclaration>node);
break;
return bindParameter(<ParameterDeclaration>node);
case SyntaxKind.VariableDeclaration:
case SyntaxKind.BindingElement:
if (isBindingPattern((<Declaration>node).name)) {
bindChildren(node, 0, /*isBlockScopeContainer*/ false);
}
else if (isBlockOrCatchScoped(<Declaration>node)) {
bindBlockScopedVariableDeclaration(<Declaration>node);
}
else if (isParameterDeclaration(<VariableLikeDeclaration>node)) {
// It is safe to walk up parent chain to find whether the node is a destructing parameter declaration
// because its parent chain has already been set up, since parents are set before descending into children.
//
// If node is a binding element in parameter declaration, we need to use ParameterExcludes.
// Using ParameterExcludes flag allows the compiler to report an error on duplicate identifiers in Parameter Declaration
// For example:
// function foo([a,a]) {} // Duplicate Identifier error
// function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter
// // which correctly set excluded symbols
bindDeclaration(<Declaration>node, SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes, /*isBlockScopeContainer*/ false);
}
else {
bindDeclaration(<Declaration>node, SymbolFlags.FunctionScopedVariable, SymbolFlags.FunctionScopedVariableExcludes, /*isBlockScopeContainer*/ false);
}
break;
return bindVariableDeclarationOrBindingElement(<VariableDeclaration | BindingElement>node);
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertySignature:
bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.Property | ((<PropertyDeclaration>node).questionToken ? SymbolFlags.Optional : 0), SymbolFlags.PropertyExcludes, /*isBlockScopeContainer*/ false);
break;
return bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.Property | ((<PropertyDeclaration>node).questionToken ? SymbolFlags.Optional : SymbolFlags.None), SymbolFlags.PropertyExcludes);
case SyntaxKind.PropertyAssignment:
case SyntaxKind.ShorthandPropertyAssignment:
bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.Property, SymbolFlags.PropertyExcludes, /*isBlockScopeContainer*/ false);
break;
return bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.Property, SymbolFlags.PropertyExcludes);
case SyntaxKind.EnumMember:
bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.EnumMember, SymbolFlags.EnumMemberExcludes, /*isBlockScopeContainer*/ false);
break;
return bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.EnumMember, SymbolFlags.EnumMemberExcludes);
case SyntaxKind.CallSignature:
case SyntaxKind.ConstructSignature:
case SyntaxKind.IndexSignature:
bindDeclaration(<Declaration>node, SymbolFlags.Signature, 0, /*isBlockScopeContainer*/ false);
break;
return declareSymbolAndAddToSymbolTable(<Declaration>node, SymbolFlags.Signature, SymbolFlags.None);
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
// If this is an ObjectLiteralExpression method, then it sits in the same space
// as other properties in the object literal. So we use SymbolFlags.PropertyExcludes
// so that it will conflict with any other object literal members with the same
// name.
bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.Method | ((<MethodDeclaration>node).questionToken ? SymbolFlags.Optional : 0),
isObjectLiteralMethod(node) ? SymbolFlags.PropertyExcludes : SymbolFlags.MethodExcludes, /*isBlockScopeContainer*/ true);
break;
return bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.Method | ((<MethodDeclaration>node).questionToken ? SymbolFlags.Optional : SymbolFlags.None),
isObjectLiteralMethod(node) ? SymbolFlags.PropertyExcludes : SymbolFlags.MethodExcludes);
case SyntaxKind.FunctionDeclaration:
bindDeclaration(<Declaration>node, SymbolFlags.Function, SymbolFlags.FunctionExcludes, /*isBlockScopeContainer*/ true);
break;
return declareSymbolAndAddToSymbolTable(<Declaration>node, SymbolFlags.Function, SymbolFlags.FunctionExcludes);
case SyntaxKind.Constructor:
bindDeclaration(<Declaration>node, SymbolFlags.Constructor, /*symbolExcludes:*/ 0, /*isBlockScopeContainer:*/ true);
break;
return declareSymbolAndAddToSymbolTable(<Declaration>node, SymbolFlags.Constructor, /*symbolExcludes:*/ SymbolFlags.None);
case SyntaxKind.GetAccessor:
bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.GetAccessor, SymbolFlags.GetAccessorExcludes, /*isBlockScopeContainer*/ true);
break;
return bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.GetAccessor, SymbolFlags.GetAccessorExcludes);
case SyntaxKind.SetAccessor:
bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.SetAccessor, SymbolFlags.SetAccessorExcludes, /*isBlockScopeContainer*/ true);
break;
return bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.SetAccessor, SymbolFlags.SetAccessorExcludes);
case SyntaxKind.FunctionType:
case SyntaxKind.ConstructorType:
bindFunctionOrConstructorType(<SignatureDeclaration>node);
break;
return bindFunctionOrConstructorType(<SignatureDeclaration>node);
case SyntaxKind.TypeLiteral:
bindAnonymousDeclaration(<TypeLiteralNode>node, SymbolFlags.TypeLiteral, "__type", /*isBlockScopeContainer*/ false);
break;
return bindAnonymousDeclaration(<TypeLiteralNode>node, SymbolFlags.TypeLiteral, "__type");
case SyntaxKind.ObjectLiteralExpression:
bindAnonymousDeclaration(<ObjectLiteralExpression>node, SymbolFlags.ObjectLiteral, "__object", /*isBlockScopeContainer*/ false);
break;
return bindAnonymousDeclaration(<ObjectLiteralExpression>node, SymbolFlags.ObjectLiteral, "__object");
case SyntaxKind.FunctionExpression:
case SyntaxKind.ArrowFunction:
bindAnonymousDeclaration(<FunctionExpression>node, SymbolFlags.Function, "__function", /*isBlockScopeContainer*/ true);
break;
return bindAnonymousDeclaration(<FunctionExpression>node, SymbolFlags.Function, "__function");
case SyntaxKind.ClassExpression:
bindAnonymousDeclaration(<ClassExpression>node, SymbolFlags.Class, "__class", /*isBlockScopeContainer*/ false);
break;
case SyntaxKind.CatchClause:
bindCatchVariableDeclaration(<CatchClause>node);
break;
case SyntaxKind.ClassDeclaration:
bindBlockScopedDeclaration(<Declaration>node, SymbolFlags.Class, SymbolFlags.ClassExcludes);
break;
return bindClassLikeDeclaration(<ClassLikeDeclaration>node);
case SyntaxKind.InterfaceDeclaration:
bindDeclaration(<Declaration>node, SymbolFlags.Interface, SymbolFlags.InterfaceExcludes, /*isBlockScopeContainer*/ false);
break;
return bindBlockScopedDeclaration(<Declaration>node, SymbolFlags.Interface, SymbolFlags.InterfaceExcludes);
case SyntaxKind.TypeAliasDeclaration:
bindDeclaration(<Declaration>node, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes, /*isBlockScopeContainer*/ false);
break;
return bindBlockScopedDeclaration(<Declaration>node, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes);
case SyntaxKind.EnumDeclaration:
if (isConst(node)) {
bindDeclaration(<Declaration>node, SymbolFlags.ConstEnum, SymbolFlags.ConstEnumExcludes, /*isBlockScopeContainer*/ false);
}
else {
bindDeclaration(<Declaration>node, SymbolFlags.RegularEnum, SymbolFlags.RegularEnumExcludes, /*isBlockScopeContainer*/ false);
}
break;
return bindEnumDeclaration(<EnumDeclaration>node);
case SyntaxKind.ModuleDeclaration:
bindModuleDeclaration(<ModuleDeclaration>node);
break;
return bindModuleDeclaration(<ModuleDeclaration>node);
case SyntaxKind.ImportEqualsDeclaration:
case SyntaxKind.NamespaceImport:
case SyntaxKind.ImportSpecifier:
case SyntaxKind.ExportSpecifier:
bindDeclaration(<Declaration>node, SymbolFlags.Alias, SymbolFlags.AliasExcludes, /*isBlockScopeContainer*/ false);
break;
return declareSymbolAndAddToSymbolTable(<Declaration>node, SymbolFlags.Alias, SymbolFlags.AliasExcludes);
case SyntaxKind.ImportClause:
if ((<ImportClause>node).name) {
bindDeclaration(<Declaration>node, SymbolFlags.Alias, SymbolFlags.AliasExcludes, /*isBlockScopeContainer*/ false);
}
else {
bindChildren(node, 0, /*isBlockScopeContainer*/ false);
}
break;
return bindImportClause(<ImportClause>node);
case SyntaxKind.ExportDeclaration:
if (!(<ExportDeclaration>node).exportClause) {
// All export * declarations are collected in an __export symbol
declareSymbol(container.symbol.exports, container.symbol, <Declaration>node, SymbolFlags.ExportStar, 0);
}
bindChildren(node, 0, /*isBlockScopeContainer*/ false);
break;
return bindExportDeclaration(<ExportDeclaration>node);
case SyntaxKind.ExportAssignment:
if ((<ExportAssignment>node).expression.kind === SyntaxKind.Identifier) {
// An export default clause with an identifier exports all meanings of that identifier
declareSymbol(container.symbol.exports, container.symbol, <Declaration>node, SymbolFlags.Alias, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes);
}
else {
// An export default clause with an expression exports a value
declareSymbol(container.symbol.exports, container.symbol, <Declaration>node, SymbolFlags.Property, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes);
}
bindChildren(node, 0, /*isBlockScopeContainer*/ false);
break;
return bindExportAssignment(<ExportAssignment>node);
case SyntaxKind.SourceFile:
setExportContextFlag(<SourceFile>node);
if (isExternalModule(<SourceFile>node)) {
bindAnonymousDeclaration(<SourceFile>node, SymbolFlags.ValueModule, '"' + removeFileExtension((<SourceFile>node).fileName) + '"', /*isBlockScopeContainer*/ true);
break;
}
case SyntaxKind.Block:
// do not treat function block a block-scope container
// all block-scope locals that reside in this block should go to the function locals.
// Otherwise this won't be considered as redeclaration of a block scoped local:
// function foo() {
// let x;
// let x;
// }
// 'let x' will be placed into the function locals and 'let x' - into the locals of the block
bindChildren(node, 0, /*isBlockScopeContainer*/ !isFunctionLike(node.parent));
break;
case SyntaxKind.CatchClause:
case SyntaxKind.ForStatement:
case SyntaxKind.ForInStatement:
case SyntaxKind.ForOfStatement:
case SyntaxKind.CaseBlock:
bindChildren(node, 0, /*isBlockScopeContainer*/ true);
break;
default:
let saveParent = parent;
parent = node;
forEachChild(node, bind);
parent = saveParent;
return bindSourceFileIfExternalModule();
}
}
function bindSourceFileIfExternalModule() {
setExportContextFlag(file);
if (isExternalModule(file)) {
bindAnonymousDeclaration(file, SymbolFlags.ValueModule, '"' + removeFileExtension(file.fileName) + '"');
}
}
function bindExportAssignment(node: ExportAssignment) {
if (node.expression.kind === SyntaxKind.Identifier) {
// An export default clause with an identifier exports all meanings of that identifier
declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.Alias, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes);
}
else {
// An export default clause with an expression exports a value
declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes);
}
}
function bindExportDeclaration(node: ExportDeclaration) {
if (!node.exportClause) {
// All export * declarations are collected in an __export symbol
declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.ExportStar, SymbolFlags.None);
}
}
function bindImportClause(node: ImportClause) {
if (node.name) {
declareSymbolAndAddToSymbolTable(node, SymbolFlags.Alias, SymbolFlags.AliasExcludes);
}
}
function bindClassLikeDeclaration(node: ClassLikeDeclaration) {
if (node.kind === SyntaxKind.ClassDeclaration) {
bindBlockScopedDeclaration(node, SymbolFlags.Class, SymbolFlags.ClassExcludes);
}
else {
bindAnonymousDeclaration(node, SymbolFlags.Class, "__class");
}
let symbol = node.symbol;
// TypeScript 1.0 spec (April 2014): 8.4
// Every class automatically contains a static property member named 'prototype', the
// type of which is an instantiation of the class type with type Any supplied as a type
// argument for each type parameter. It is an error to explicitly declare a static
// property member with the name 'prototype'.
//
// Note: we check for this here because this class may be merging into a module. The
// module might have an exported variable called 'prototype'. We can't allow that as
// that would clash with the built-in 'prototype' for the class.
let prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype");
if (hasProperty(symbol.exports, prototypeSymbol.name)) {
if (node.name) {
node.name.parent = node;
}
file.bindDiagnostics.push(createDiagnosticForNode(symbol.exports[prototypeSymbol.name].declarations[0],
Diagnostics.Duplicate_identifier_0, prototypeSymbol.name));
}
symbol.exports[prototypeSymbol.name] = prototypeSymbol;
prototypeSymbol.parent = symbol;
}
function bindEnumDeclaration(node: EnumDeclaration) {
return isConst(node)
? bindBlockScopedDeclaration(node, SymbolFlags.ConstEnum, SymbolFlags.ConstEnumExcludes)
: bindBlockScopedDeclaration(node, SymbolFlags.RegularEnum, SymbolFlags.RegularEnumExcludes);
}
function bindVariableDeclarationOrBindingElement(node: VariableDeclaration | BindingElement) {
if (!isBindingPattern(node.name)) {
if (isBlockOrCatchScoped(node)) {
bindBlockScopedVariableDeclaration(node);
}
else if (isParameterDeclaration(node)) {
// It is safe to walk up parent chain to find whether the node is a destructing parameter declaration
// because its parent chain has already been set up, since parents are set before descending into children.
//
// If node is a binding element in parameter declaration, we need to use ParameterExcludes.
// Using ParameterExcludes flag allows the compiler to report an error on duplicate identifiers in Parameter Declaration
// For example:
// function foo([a,a]) {} // Duplicate Identifier error
// function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter
// // which correctly set excluded symbols
declareSymbolAndAddToSymbolTable(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes);
}
else {
declareSymbolAndAddToSymbolTable(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.FunctionScopedVariableExcludes);
}
}
}
function bindParameter(node: ParameterDeclaration) {
if (isBindingPattern(node.name)) {
bindAnonymousDeclaration(node, SymbolFlags.FunctionScopedVariable, getDestructuringParameterName(node), /*isBlockScopeContainer*/ false);
bindAnonymousDeclaration(node, SymbolFlags.FunctionScopedVariable, getDestructuringParameterName(node));
}
else {
bindDeclaration(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes, /*isBlockScopeContainer*/ false);
declareSymbolAndAddToSymbolTable(node, SymbolFlags.FunctionScopedVariable, SymbolFlags.ParameterExcludes);
}
// If this is a property-parameter, then also declare the property symbol into the
@ -618,13 +760,10 @@ module ts {
}
}
function bindPropertyOrMethodOrAccessor(node: Declaration, symbolKind: SymbolFlags, symbolExcludes: SymbolFlags, isBlockScopeContainer: boolean) {
if (hasDynamicName(node)) {
bindAnonymousDeclaration(node, symbolKind, "__computed", isBlockScopeContainer);
}
else {
bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer);
}
function bindPropertyOrMethodOrAccessor(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) {
return hasDynamicName(node)
? bindAnonymousDeclaration(node, symbolFlags, "__computed")
: declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -142,7 +142,7 @@ module ts {
paramType: Diagnostics.LOCATION,
},
{
name: "separateCompilation",
name: "isolatedModules",
type: "boolean",
},
{
@ -188,10 +188,16 @@ module ts {
type: "boolean",
description: Diagnostics.Watch_input_files,
},
{
name: "experimentalDecorators",
type: "boolean",
description: Diagnostics.Enables_experimental_support_for_ES7_decorators
},
{
name: "emitDecoratorMetadata",
type: "boolean",
experimental: true
experimental: true,
description: Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators
}
];

View file

@ -129,6 +129,16 @@ module ts {
}
}
export function rangeEquals<T>(array1: T[], array2: T[], pos: number, end: number) {
while (pos < end) {
if (array1[pos] !== array2[pos]) {
return false;
}
pos++;
}
return true;
}
/**
* Returns the last element of an array if non-empty, undefined otherwise.
*/
@ -312,8 +322,11 @@ module ts {
Debug.assert(start >= 0, "start must be non-negative, is " + start);
Debug.assert(length >= 0, "length must be non-negative, is " + length);
Debug.assert(start <= file.text.length, `start must be within the bounds of the file. ${ start } > ${ file.text.length }`);
Debug.assert(end <= file.text.length, `end must be the bounds of the file. ${ end } > ${ file.text.length }`);
if (file) {
Debug.assert(start <= file.text.length, `start must be within the bounds of the file. ${ start } > ${ file.text.length }`);
Debug.assert(end <= file.text.length, `end must be the bounds of the file. ${ end } > ${ file.text.length }`);
}
let text = getLocaleSpecificMessage(message.key);

View file

@ -120,7 +120,7 @@ module ts {
Unterminated_template_literal: { code: 1160, category: DiagnosticCategory.Error, key: "Unterminated template literal." },
Unterminated_regular_expression_literal: { code: 1161, category: DiagnosticCategory.Error, key: "Unterminated regular expression literal." },
An_object_member_cannot_be_declared_optional: { code: 1162, category: DiagnosticCategory.Error, key: "An object member cannot be declared optional." },
yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: DiagnosticCategory.Error, key: "'yield' expression must be contained_within a generator declaration." },
A_yield_expression_is_only_allowed_in_a_generator_body: { code: 1163, category: DiagnosticCategory.Error, key: "A 'yield' expression is only allowed in a generator body." },
Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." },
A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: DiagnosticCategory.Error, key: "A computed property name in an ambient context must directly refer to a built-in symbol." },
A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: DiagnosticCategory.Error, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." },
@ -165,8 +165,8 @@ module ts {
Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." },
Decorators_are_not_valid_here: { code: 1206, category: DiagnosticCategory.Error, key: "Decorators are not valid here." },
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." },
Cannot_compile_namespaces_when_the_separateCompilation_flag_is_provided: { code: 1208, category: DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--separateCompilation' flag is provided." },
Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." },
Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: DiagnosticCategory.Error, key: "Cannot compile namespaces when the '--isolatedModules' flag is provided." },
Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { code: 1209, category: DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--isolatedModules' flag is provided." },
Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." },
A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" },
Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: DiagnosticCategory.Error, key: "Identifier expected. '{0}' is a reserved word in strict mode" },
@ -174,6 +174,11 @@ module ts {
Type_expected_0_is_a_reserved_word_in_strict_mode: { code: 1215, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode" },
Type_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1216, category: DiagnosticCategory.Error, key: "Type expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." },
Export_assignment_is_not_supported_when_module_flag_is_system: { code: 1218, category: DiagnosticCategory.Error, key: "Export assignment is not supported when '--module' flag is 'system'." },
Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning: { code: 1219, category: DiagnosticCategory.Error, key: "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning." },
Generators_are_only_available_when_targeting_ECMAScript_6_or_higher: { code: 1220, category: DiagnosticCategory.Error, key: "Generators are only available when targeting ECMAScript 6 or higher." },
Generators_are_not_allowed_in_an_ambient_context: { code: 1221, category: DiagnosticCategory.Error, key: "Generators are not allowed in an ambient context." },
An_overload_signature_cannot_be_declared_as_a_generator: { code: 1222, category: DiagnosticCategory.Error, key: "An overload signature cannot be declared as a generator." },
_0_tag_already_specified: { code: 1223, category: DiagnosticCategory.Error, key: "'{0}' tag already specified." },
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },
@ -334,7 +339,7 @@ module ts {
The_0_operator_cannot_be_applied_to_type_symbol: { code: 2469, category: DiagnosticCategory.Error, key: "The '{0}' operator cannot be applied to type 'symbol'." },
Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: { code: 2470, category: DiagnosticCategory.Error, key: "'Symbol' reference does not refer to the global Symbol constructor object." },
A_computed_property_name_of_the_form_0_must_be_of_type_symbol: { code: 2471, category: DiagnosticCategory.Error, key: "A computed property name of the form '{0}' must be of type 'symbol'." },
Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_6_and_higher: { code: 2472, category: DiagnosticCategory.Error, key: "Spread operator in 'new' expressions is only available when targeting ECMAScript 6 and higher." },
Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher: { code: 2472, category: DiagnosticCategory.Error, key: "Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher." },
Enum_declarations_must_all_be_const_or_non_const: { code: 2473, category: DiagnosticCategory.Error, key: "Enum declarations must all be const or non-const." },
In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 2474, category: DiagnosticCategory.Error, key: "In 'const' enum declarations member initializer must be constant expression." },
const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 2475, category: DiagnosticCategory.Error, key: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." },
@ -365,6 +370,8 @@ module ts {
A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: DiagnosticCategory.Error, key: "A rest element cannot contain a binding pattern." },
_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: DiagnosticCategory.Error, key: "'{0}' is referenced directly or indirectly in its own type annotation." },
Cannot_find_namespace_0: { code: 2503, category: DiagnosticCategory.Error, key: "Cannot find namespace '{0}'." },
No_best_common_type_exists_among_yield_expressions: { code: 2504, category: DiagnosticCategory.Error, key: "No best common type exists among yield expressions." },
A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: DiagnosticCategory.Error, key: "A generator cannot have a 'void' type annotation." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
@ -449,11 +456,11 @@ module ts {
Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." },
Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." },
Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." },
Option_sourceMap_cannot_be_specified_with_option_separateCompilation: { code: 5043, category: DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'separateCompilation'." },
Option_declaration_cannot_be_specified_with_option_separateCompilation: { code: 5044, category: DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'separateCompilation'." },
Option_noEmitOnError_cannot_be_specified_with_option_separateCompilation: { code: 5045, category: DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'separateCompilation'." },
Option_out_cannot_be_specified_with_option_separateCompilation: { code: 5046, category: DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'separateCompilation'." },
Option_separateCompilation_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: DiagnosticCategory.Error, key: "Option 'separateCompilation' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." },
Option_sourceMap_cannot_be_specified_with_option_isolatedModules: { code: 5043, category: DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'isolatedModules'." },
Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." },
Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." },
Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'isolatedModules'." },
Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." },
Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap: { code: 5048, category: DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." },
Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." },
Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'." },
@ -507,6 +514,9 @@ module ts {
Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." },
NEWLINE: { code: 6061, category: DiagnosticCategory.Message, key: "NEWLINE" },
Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." },
Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." },
Enables_experimental_support_for_ES7_decorators: { code: 6065, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." },
Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
@ -519,9 +529,10 @@ module ts {
Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: DiagnosticCategory.Error, key: "Object literal's property '{0}' implicitly has an '{1}' type." },
Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: DiagnosticCategory.Error, key: "Rest parameter '{0}' implicitly has an 'any[]' type." },
Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: DiagnosticCategory.Error, key: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." },
_0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer." },
_0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer." },
_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: DiagnosticCategory.Error, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." },
Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." },
Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: DiagnosticCategory.Error, key: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." },
You_cannot_rename_this_element: { code: 8000, category: DiagnosticCategory.Error, key: "You cannot rename this element." },
You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." },
import_can_only_be_used_in_a_ts_file: { code: 8002, category: DiagnosticCategory.Error, key: "'import ... =' can only be used in a .ts file." },
@ -535,15 +546,11 @@ module ts {
types_can_only_be_used_in_a_ts_file: { code: 8010, category: DiagnosticCategory.Error, key: "'types' can only be used in a .ts file." },
type_arguments_can_only_be_used_in_a_ts_file: { code: 8011, category: DiagnosticCategory.Error, key: "'type arguments' can only be used in a .ts file." },
parameter_modifiers_can_only_be_used_in_a_ts_file: { code: 8012, category: DiagnosticCategory.Error, key: "'parameter modifiers' can only be used in a .ts file." },
can_only_be_used_in_a_ts_file: { code: 8013, category: DiagnosticCategory.Error, key: "'?' can only be used in a .ts file." },
property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: DiagnosticCategory.Error, key: "'property declarations' can only be used in a .ts file." },
enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: DiagnosticCategory.Error, key: "'enum declarations' can only be used in a .ts file." },
type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: DiagnosticCategory.Error, key: "'type assertion expressions' can only be used in a .ts file." },
decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." },
yield_expressions_are_not_currently_supported: { code: 9000, category: DiagnosticCategory.Error, key: "'yield' expressions are not currently supported." },
Generators_are_not_currently_supported: { code: 9001, category: DiagnosticCategory.Error, key: "Generators are not currently supported." },
Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." },
class_expressions_are_not_currently_supported: { code: 9003, category: DiagnosticCategory.Error, key: "'class' expressions are not currently supported." },
class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration: { code: 9004, category: DiagnosticCategory.Error, key: "'class' declarations are only supported directly inside a module or as a top level declaration." },
};
}

View file

@ -467,7 +467,7 @@
"category": "Error",
"code": 1162
},
"'yield' expression must be contained_within a generator declaration.": {
"A 'yield' expression is only allowed in a generator body.": {
"category": "Error",
"code": 1163
},
@ -647,11 +647,11 @@
"category": "Error",
"code": 1207
},
"Cannot compile namespaces when the '--separateCompilation' flag is provided.": {
"Cannot compile namespaces when the '--isolatedModules' flag is provided.": {
"category": "Error",
"code": 1208
},
"Ambient const enums are not allowed when the '--separateCompilation' flag is provided.": {
"Ambient const enums are not allowed when the '--isolatedModules' flag is provided.": {
"category": "Error",
"code": 1209
},
@ -683,6 +683,26 @@
"category": "Error",
"code": 1218
},
"Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning.": {
"category": "Error",
"code": 1219
},
"Generators are only available when targeting ECMAScript 6 or higher.": {
"category": "Error",
"code": 1220
},
"Generators are not allowed in an ambient context.": {
"category": "Error",
"code": 1221
},
"An overload signature cannot be declared as a generator.": {
"category": "Error",
"code": 1222
},
"'{0}' tag already specified.": {
"category": "Error",
"code": 1223
},
"Duplicate identifier '{0}'.": {
"category": "Error",
@ -1324,7 +1344,7 @@
"category": "Error",
"code": 2471
},
"Spread operator in 'new' expressions is only available when targeting ECMAScript 6 and higher.": {
"Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher.": {
"category": "Error",
"code": 2472
},
@ -1448,6 +1468,14 @@
"category": "Error",
"code": 2503
},
"No best common type exists among yield expressions.": {
"category": "Error",
"code": 2504
},
"A generator cannot have a 'void' type annotation.": {
"category": "Error",
"code": 2505
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
@ -1785,23 +1813,23 @@
"category": "Error",
"code": 5042
},
"Option 'sourceMap' cannot be specified with option 'separateCompilation'.": {
"Option 'sourceMap' cannot be specified with option 'isolatedModules'.": {
"category": "Error",
"code": 5043
},
"Option 'declaration' cannot be specified with option 'separateCompilation'.": {
"Option 'declaration' cannot be specified with option 'isolatedModules'.": {
"category": "Error",
"code": 5044
},
"Option 'noEmitOnError' cannot be specified with option 'separateCompilation'.": {
"Option 'noEmitOnError' cannot be specified with option 'isolatedModules'.": {
"category": "Error",
"code": 5045
},
"Option 'out' cannot be specified with option 'separateCompilation'.": {
"Option 'out' cannot be specified with option 'isolatedModules'.": {
"category": "Error",
"code": 5046
},
"Option 'separateCompilation' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher.": {
"Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher.": {
"category": "Error",
"code": 5047
},
@ -2018,7 +2046,18 @@
"category": "Error",
"code": 6062
},
"Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified.": {
"category": "Error",
"code": 6064
},
"Enables experimental support for ES7 decorators.": {
"category": "Message",
"code": 6065
},
"Enables experimental support for emitting type metadata for decorators.": {
"category": "Message",
"code": 6066
},
"Variable '{0}' implicitly has an '{1}' type.": {
"category": "Error",
@ -2068,7 +2107,7 @@
"category": "Error",
"code": 7020
},
"'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer.": {
"'{0}' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.": {
"category": "Error",
"code": 7022
},
@ -2080,6 +2119,10 @@
"category": "Error",
"code": 7024
},
"Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type.": {
"category": "Error",
"code": 7025
},
"You cannot rename this element.": {
"category": "Error",
"code": 8000
@ -2132,10 +2175,6 @@
"category": "Error",
"code": 8012
},
"'?' can only be used in a .ts file.": {
"category": "Error",
"code": 8013
},
"'property declarations' can only be used in a .ts file.": {
"category": "Error",
"code": 8014
@ -2153,14 +2192,6 @@
"code": 8017
},
"'yield' expressions are not currently supported.": {
"category": "Error",
"code": 9000
},
"Generators are not currently supported.": {
"category": "Error",
"code": 9001
},
"Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses.": {
"category": "Error",
"code": 9002
@ -2168,9 +2199,5 @@
"'class' expressions are not currently supported.": {
"category": "Error",
"code": 9003
},
"'class' declarations are only supported directly inside a module or as a top level declaration.": {
"category": "Error",
"code": 9004
}
}

View file

@ -1366,16 +1366,16 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
return true;
}
function emitListWithSpread(elements: Expression[], alwaysCopy: boolean, multiLine: boolean, trailingComma: boolean) {
function emitListWithSpread(elements: Expression[], needsUniqueCopy: boolean, multiLine: boolean, trailingComma: boolean, useConcat: boolean) {
let pos = 0;
let group = 0;
let length = elements.length;
while (pos < length) {
// Emit using the pattern <group0>.concat(<group1>, <group2>, ...)
if (group === 1) {
if (group === 1 && useConcat) {
write(".concat(");
}
else if (group > 1) {
else if (group > 0) {
write(", ");
}
let e = elements[pos];
@ -1383,7 +1383,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
e = (<SpreadElementExpression>e).expression;
emitParenthesizedIf(e, /*parenthesized*/ group === 0 && needsParenthesisForPropertyAccessOrInvocation(e));
pos++;
if (pos === length && group === 0 && alwaysCopy && e.kind !== SyntaxKind.ArrayLiteralExpression) {
if (pos === length && group === 0 && needsUniqueCopy && e.kind !== SyntaxKind.ArrayLiteralExpression) {
write(".slice()");
}
}
@ -1406,7 +1406,9 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
group++;
}
if (group > 1) {
write(")");
if(useConcat) {
write(")");
}
}
}
@ -1425,8 +1427,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
write("]");
}
else {
emitListWithSpread(elements, /*alwaysCopy*/ true, /*multiLine*/(node.flags & NodeFlags.MultiLine) !== 0,
/*trailingComma*/ elements.hasTrailingComma);
emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/(node.flags & NodeFlags.MultiLine) !== 0,
/*trailingComma*/ elements.hasTrailingComma, /*useConcat*/ true);
}
}
@ -1717,7 +1719,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
}
function tryEmitConstantValue(node: PropertyAccessExpression | ElementAccessExpression): boolean {
if (compilerOptions.separateCompilation) {
if (compilerOptions.isolatedModules) {
// do not inline enum values in separate compilation mode
return false;
}
@ -1850,7 +1852,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
write("void 0");
}
write(", ");
emitListWithSpread(node.arguments, /*alwaysCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false);
emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*trailingComma*/ false, /*useConcat*/ true);
write(")");
}
@ -1886,11 +1888,44 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
function emitNewExpression(node: NewExpression) {
write("new ");
emit(node.expression);
if (node.arguments) {
// Spread operator logic can be supported in new expressions in ES5 using a combination
// of Function.prototype.bind() and Function.prototype.apply().
//
// Example:
//
// var arguments = [1, 2, 3, 4, 5];
// new Array(...arguments);
//
// Could be transpiled into ES5:
//
// var arguments = [1, 2, 3, 4, 5];
// new (Array.bind.apply(Array, [void 0].concat(arguments)));
//
// `[void 0]` is the first argument which represents `thisArg` to the bind method above.
// And `thisArg` will be set to the return value of the constructor when instantiated
// with the new operator — regardless of any value we set `thisArg` to. Thus, we set it
// to an undefined, `void 0`.
if (languageVersion === ScriptTarget.ES5 &&
node.arguments &&
hasSpreadElement(node.arguments)) {
write("(");
emitCommaList(node.arguments);
write(")");
let target = emitCallTarget(node.expression);
write(".bind.apply(");
emit(target);
write(", [void 0].concat(");
emitListWithSpread(node.arguments, /*needsUniqueCopy*/ false, /*multiline*/ false, /*trailingComma*/ false, /*useConcat*/ false);
write(")))");
write("()");
}
else {
emit(node.expression);
if (node.arguments) {
write("(");
emitCommaList(node.arguments);
write(")");
}
}
}
@ -2229,9 +2264,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
emitEmbeddedStatement(node.statement);
}
/* Returns true if start of variable declaration list was emitted.
* Return false if nothing was written - this can happen for source file level variable declarations
* in system modules - such variable declarations are hoisted.
/**
* Returns true if start of variable declaration list was emitted.
* Returns false if nothing was written - this can happen for source file level variable declarations
* in system modules where such variable declarations are hoisted.
*/
function tryEmitStartOfVariableDeclarationList(decl: VariableDeclarationList, startPos?: number): boolean {
if (shouldHoistVariable(decl, /*checkIfSourceFileLevelDecl*/ true)) {
@ -2500,7 +2536,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
write(";");
}
function emitWithStatement(node: WhileStatement) {
function emitWithStatement(node: WithStatement) {
write("with (");
emit(node.expression);
write(")");
@ -3060,6 +3096,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
function emitVariableStatement(node: VariableStatement) {
let startIsEmitted = false;
if (node.flags & NodeFlags.Export) {
if (isES6ExportedDeclaration(node)) {
// Exported ES6 module member
@ -3070,6 +3107,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
else {
startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList);
}
if (startIsEmitted) {
emitCommaList(node.declarationList.declarations);
write(";");
@ -3085,6 +3123,28 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
}
}
function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node: VariableStatement) {
// If we're not exporting the variables, there's nothing special here.
// Always emit comments for these nodes.
if (!(node.flags & NodeFlags.Export)) {
return true;
}
// If we are exporting, but it's a top-level ES6 module exports,
// we'll emit the declaration list verbatim, so emit comments too.
if (isES6ExportedDeclaration(node)) {
return true;
}
// Otherwise, only emit if we have at least one initializer present.
for (let declaration of node.declarationList.declarations) {
if (declaration.initializer) {
return true;
}
}
return false;
}
function emitParameter(node: ParameterDeclaration) {
if (languageVersion < ScriptTarget.ES6) {
if (isBindingPattern(node.name)) {
@ -3145,7 +3205,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
}
function emitRestParameter(node: FunctionLikeDeclaration) {
if (languageVersion < ScriptTarget.ES6 && hasRestParameters(node)) {
if (languageVersion < ScriptTarget.ES6 && hasRestParameter(node)) {
let restIndex = node.parameters.length - 1;
let restParam = node.parameters[restIndex];
@ -3273,7 +3333,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
write("(");
if (node) {
let parameters = node.parameters;
let omitCount = languageVersion < ScriptTarget.ES6 && hasRestParameters(node) ? 1 : 0;
let omitCount = languageVersion < ScriptTarget.ES6 && hasRestParameter(node) ? 1 : 0;
emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false);
}
write(")");
@ -4370,7 +4430,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
function shouldEmitEnumDeclaration(node: EnumDeclaration) {
let isConstEnum = isConst(node);
return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.separateCompilation;
return !isConstEnum || compilerOptions.preserveConstEnums || compilerOptions.isolatedModules;
}
function emitEnumDeclaration(node: EnumDeclaration) {
@ -4475,7 +4535,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
}
function shouldEmitModuleDeclaration(node: ModuleDeclaration) {
return isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.separateCompilation);
return isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules);
}
function isModuleMergedWithES6Class(node: ModuleDeclaration) {
@ -5684,7 +5744,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
}
}
if (isExternalModule(node) || compilerOptions.separateCompilation) {
if (isExternalModule(node) || compilerOptions.isolatedModules) {
if (languageVersion >= ScriptTarget.ES6) {
emitES6Module(node, startIndex);
}
@ -5747,6 +5807,9 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
case SyntaxKind.ExportAssignment:
return false;
case SyntaxKind.VariableStatement:
return shouldEmitLeadingAndTrailingCommentsForVariableStatement(<VariableStatement>node);
case SyntaxKind.ModuleDeclaration:
// Only emit the leading/trailing comments for a module if we're actually
// emitting the module as well.

File diff suppressed because it is too large Load diff

View file

@ -8,7 +8,7 @@ module ts {
/* @internal */ export let ioWriteTime = 0;
/** The version of the TypeScript compiler release */
export const version = "1.5.2";
export const version = "1.5.3";
const carriageReturnLineFeed = "\r\n";
const lineFeed = "\n";
@ -534,21 +534,21 @@ module ts {
}
function verifyCompilerOptions() {
if (options.separateCompilation) {
if (options.isolatedModules) {
if (options.sourceMap) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceMap_cannot_be_specified_with_option_separateCompilation));
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceMap_cannot_be_specified_with_option_isolatedModules));
}
if (options.declaration) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_declaration_cannot_be_specified_with_option_separateCompilation));
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules));
}
if (options.noEmitOnError) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_separateCompilation));
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules));
}
if (options.out) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_out_cannot_be_specified_with_option_separateCompilation));
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_out_cannot_be_specified_with_option_isolatedModules));
}
}
@ -585,15 +585,15 @@ module ts {
let languageVersion = options.target || ScriptTarget.ES3;
let firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined);
if (options.separateCompilation) {
if (options.isolatedModules) {
if (!options.module && languageVersion < ScriptTarget.ES6) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_separateCompilation_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher));
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher));
}
let firstNonExternalModuleSourceFile = forEach(files, f => !isExternalModule(f) && !isDeclarationFile(f) ? f : undefined);
if (firstNonExternalModuleSourceFile) {
let span = getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
diagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_separateCompilation_flag_is_provided));
diagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
}
}
else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && !options.module) {
@ -640,6 +640,11 @@ module ts {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration));
}
}
if (options.emitDecoratorMetadata &&
!options.experimentalDecorators) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified));
}
}
}
}

View file

@ -598,12 +598,26 @@ module ts {
ch > CharacterCodes.maxAsciiCharacter && isUnicodeIdentifierPart(ch, languageVersion);
}
/** Creates a scanner over a (possibly unspecified) range of a piece of text. */
export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner {
let pos: number; // Current position (end position of text of current token)
let end: number; // end of text
let startPos: number; // Start position of whitespace before current token
let tokenPos: number; // Start position of text of current token
/* @internal */
// Creates a scanner over a (possibly unspecified) range of a piece of text.
export function createScanner(languageVersion: ScriptTarget,
skipTrivia: boolean,
text?: string,
onError?: ErrorCallback,
start?: number,
length?: number): Scanner {
// Current position (end position of text of current token)
let pos: number;
// end of text
let end: number;
// Start position of whitespace before current token
let startPos: number;
// Start position of text of current token
let tokenPos: number;
let token: SyntaxKind;
let tokenValue: string;
let precedingLineBreak: boolean;

View file

@ -246,7 +246,7 @@ module ts {
for (let current of files) {
var name = combinePaths(path, current);
if (!contains(exclude, getCanonicalPath(name))) {
var stat = _fs.lstatSync(name);
var stat = _fs.statSync(name);
if (stat.isFile()) {
if (!extension || fileExtensionIs(name, extension)) {
result.push(name);

View file

@ -270,6 +270,32 @@ module ts {
// Top-level nodes
SourceFile,
// JSDoc nodes.
JSDocTypeExpression,
// The * type.
JSDocAllType,
// The ? type.
JSDocUnknownType,
JSDocArrayType,
JSDocUnionType,
JSDocTupleType,
JSDocNullableType,
JSDocNonNullableType,
JSDocRecordType,
JSDocRecordMember,
JSDocTypeReference,
JSDocOptionalType,
JSDocFunctionType,
JSDocVariadicType,
JSDocConstructorType,
JSDocThisType,
JSDocComment,
JSDocTag,
JSDocParameterTag,
JSDocReturnTag,
JSDocTypeTag,
JSDocTemplateTag,
// Synthesized list
SyntaxList,
// Enum value count
@ -324,6 +350,8 @@ module ts {
/* @internal */
export const enum ParserContextFlags {
None = 0,
// Set if this node was parsed in strict mode. Used for grammar error checks, as well as
// checking if the node can be reused in incremental settings.
StrictMode = 1 << 0,
@ -345,6 +373,10 @@ module ts {
// error.
ThisNodeHasError = 1 << 5,
// This node was parsed in a JavaScript file and can be processed differently. For example
// its type can be specified usign a JSDoc comment.
JavaScriptFile = 1 << 6,
// Context flags set directly by the parser.
ParserGeneratedFlags = StrictMode | DisallowIn | Yield | GeneratorParameter | Decorator | ThisNodeHasError,
@ -352,10 +384,10 @@ module ts {
// Used during incremental parsing to determine if this node or any of its children had an
// error. Computed only once and then cached.
ThisNodeOrAnySubNodesHasError = 1 << 6,
ThisNodeOrAnySubNodesHasError = 1 << 7,
// Used to know if we've computed data from children and cached it in this node.
HasAggregatedChildData = 1 << 7
HasAggregatedChildData = 1 << 8
}
/* @internal */
@ -371,14 +403,15 @@ module ts {
// Specific context the parser was in when this node was created. Normally undefined.
// Only set when the parser was in some interesting context (like async/yield).
/* @internal */ parserContextFlags?: ParserContextFlags;
decorators?: NodeArray<Decorator>; // Array of decorators (in document order)
modifiers?: ModifiersArray; // Array of modifiers
/* @internal */ id?: number; // Unique id (used to look up NodeLinks)
parent?: Node; // Parent node (initialized by binding)
/* @internal */ symbol?: Symbol; // Symbol declared by node (initialized by binding)
/* @internal */ locals?: SymbolTable; // Locals associated with node (initialized by binding)
/* @internal */ nextContainer?: Node; // Next container in declaration order (initialized by binding)
/* @internal */ localSymbol?: Symbol; // Local symbol declared by node (initialized by binding only for exported nodes)
decorators?: NodeArray<Decorator>; // Array of decorators (in document order)
modifiers?: ModifiersArray; // Array of modifiers
/* @internal */ id?: number; // Unique id (used to look up NodeLinks)
parent?: Node; // Parent node (initialized by binding
/* @internal */ jsDocComment?: JSDocComment; // JSDoc for the node, if it has any. Only for .js files.
/* @internal */ symbol?: Symbol; // Symbol declared by node (initialized by binding)
/* @internal */ locals?: SymbolTable; // Locals associated with node (initialized by binding)
/* @internal */ nextContainer?: Node; // Next container in declaration order (initialized by binding)
/* @internal */ localSymbol?: Symbol; // Local symbol declared by node (initialized by binding only for exported nodes)
}
export interface NodeArray<T> extends Array<T>, TextRange {
@ -660,7 +693,7 @@ module ts {
export interface YieldExpression extends Expression {
asteriskToken?: Node;
expression: Expression;
expression?: Expression;
}
export interface BinaryExpression extends Expression {
@ -884,7 +917,7 @@ module ts {
_classElementBrand: any;
}
export interface InterfaceDeclaration extends Declaration, ModuleElement {
export interface InterfaceDeclaration extends Declaration, Statement {
name: Identifier;
typeParameters?: NodeArray<TypeParameterDeclaration>;
heritageClauses?: NodeArray<HeritageClause>;
@ -896,7 +929,7 @@ module ts {
types?: NodeArray<ExpressionWithTypeArguments>;
}
export interface TypeAliasDeclaration extends Declaration, ModuleElement {
export interface TypeAliasDeclaration extends Declaration, Statement {
name: Identifier;
type: TypeNode;
}
@ -908,7 +941,7 @@ module ts {
initializer?: Expression;
}
export interface EnumDeclaration extends Declaration, ModuleElement {
export interface EnumDeclaration extends Declaration, Statement {
name: Identifier;
members: NodeArray<EnumMember>;
}
@ -992,6 +1025,106 @@ module ts {
kind: SyntaxKind;
}
// represents a top level: { type } expression in a JSDoc comment.
export interface JSDocTypeExpression extends Node {
type: JSDocType;
}
export interface JSDocType extends TypeNode {
_jsDocTypeBrand: any;
}
export interface JSDocAllType extends JSDocType {
_JSDocAllTypeBrand: any;
}
export interface JSDocUnknownType extends JSDocType {
_JSDocUnknownTypeBrand: any;
}
export interface JSDocArrayType extends JSDocType {
elementType: JSDocType;
}
export interface JSDocUnionType extends JSDocType {
types: NodeArray<JSDocType>;
}
export interface JSDocTupleType extends JSDocType {
types: NodeArray<JSDocType>;
}
export interface JSDocNonNullableType extends JSDocType {
type: JSDocType;
}
export interface JSDocNullableType extends JSDocType {
type: JSDocType;
}
export interface JSDocRecordType extends JSDocType, TypeLiteralNode {
members: NodeArray<JSDocRecordMember>;
}
export interface JSDocTypeReference extends JSDocType {
name: EntityName;
typeArguments: NodeArray<JSDocType>
}
export interface JSDocOptionalType extends JSDocType {
type: JSDocType;
}
export interface JSDocFunctionType extends JSDocType, SignatureDeclaration {
parameters: NodeArray<ParameterDeclaration>;
type: JSDocType;
}
export interface JSDocVariadicType extends JSDocType {
type: JSDocType;
}
export interface JSDocConstructorType extends JSDocType {
type: JSDocType;
}
export interface JSDocThisType extends JSDocType {
type: JSDocType;
}
export interface JSDocRecordMember extends PropertyDeclaration {
name: Identifier | LiteralExpression,
type?: JSDocType
}
export interface JSDocComment extends Node {
tags: NodeArray<JSDocTag>;
}
export interface JSDocTag extends Node {
atToken: Node;
tagName: Identifier;
}
export interface JSDocTemplateTag extends JSDocTag {
typeParameters: NodeArray<TypeParameterDeclaration>;
}
export interface JSDocReturnTag extends JSDocTag {
typeExpression: JSDocTypeExpression;
}
export interface JSDocTypeTag extends JSDocTag {
typeExpression: JSDocTypeExpression;
}
export interface JSDocParameterTag extends JSDocTag {
preParameterName?: Identifier;
typeExpression?: JSDocTypeExpression;
postParameterName?: Identifier;
isBracketed: boolean;
}
// Source files are declarations when they are external modules.
export interface SourceFile extends Declaration {
statements: NodeArray<ModuleElement>;
@ -1287,6 +1420,7 @@ module ts {
}
export const enum SymbolFlags {
None = 0,
FunctionScopedVariable = 0x00000001, // Variable (var) or parameter
BlockScopedVariable = 0x00000002, // A block-scoped variable (let or const)
Property = 0x00000004, // Property or enum member
@ -1356,11 +1490,9 @@ module ts {
ExportHasLocal = Function | Class | Enum | ValueModule,
HasLocals = Function | Module | Method | Constructor | Accessor | Signature,
HasExports = Class | Enum | Module,
HasMembers = Class | Interface | TypeLiteral | ObjectLiteral,
IsContainer = HasLocals | HasExports | HasMembers,
PropertyOrAccessor = Property | Accessor,
Export = ExportNamespace | ExportType | ExportValue,
}
@ -1368,14 +1500,15 @@ module ts {
export interface Symbol {
flags: SymbolFlags; // Symbol flags
name: string; // Name of symbol
/* @internal */ id?: number; // Unique id (used to look up SymbolLinks)
/* @internal */ mergeId?: number; // Merge id (used to look up merged symbol)
declarations?: Declaration[]; // Declarations associated with this symbol
/* @internal */ parent?: Symbol; // Parent symbol
valueDeclaration?: Declaration; // First value declaration of the symbol
members?: SymbolTable; // Class, interface or literal instance members
exports?: SymbolTable; // Module exports
/* @internal */ id?: number; // Unique id (used to look up SymbolLinks)
/* @internal */ mergeId?: number; // Merge id (used to look up merged symbol)
/* @internal */ parent?: Symbol; // Parent symbol
/* @internal */ exportSymbol?: Symbol; // Exported symbol associated with this symbol
valueDeclaration?: Declaration; // First value declaration of the symbol
/* @internal */ constEnumOnlyModule?: boolean; // True if module contains only const enums or other modules with only const enums
}
@ -1449,14 +1582,15 @@ module ts {
Tuple = 0x00002000, // Tuple
Union = 0x00004000, // Union
Anonymous = 0x00008000, // Anonymous
Instantiated = 0x00010000, // Instantiated anonymous type
/* @internal */
FromSignature = 0x00010000, // Created for signature assignment check
ObjectLiteral = 0x00020000, // Originates in an object literal
FromSignature = 0x00020000, // Created for signature assignment check
ObjectLiteral = 0x00040000, // Originates in an object literal
/* @internal */
ContainsUndefinedOrNull = 0x00040000, // Type is or contains Undefined or Null type
ContainsUndefinedOrNull = 0x00080000, // Type is or contains Undefined or Null type
/* @internal */
ContainsObjectLiteral = 0x00080000, // Type is or contains object literal type
ESSymbol = 0x00100000, // Type of symbol primitive introduced in ES6
ContainsObjectLiteral = 0x00100000, // Type is or contains object literal type
ESSymbol = 0x00200000, // Type of symbol primitive introduced in ES6
/* @internal */
Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null,
@ -1493,6 +1627,8 @@ module ts {
// Class and interface types (TypeFlags.Class and TypeFlags.Interface)
export interface InterfaceType extends ObjectType {
typeParameters: TypeParameter[]; // Type parameters (undefined if non-generic)
outerTypeParameters: TypeParameter[]; // Outer type parameters (undefined if none)
localTypeParameters: TypeParameter[]; // Local type parameters (undefined if none)
}
export interface InterfaceTypeWithBaseTypes extends InterfaceType {
@ -1539,8 +1675,15 @@ module ts {
properties: Symbol[]; // Properties
callSignatures: Signature[]; // Call signatures of type
constructSignatures: Signature[]; // Construct signatures of type
stringIndexType: Type; // String index type
numberIndexType: Type; // Numeric index type
stringIndexType?: Type; // String index type
numberIndexType?: Type; // Numeric index type
}
// Just a place to cache element types of iterables and iterators
/* @internal */
export interface IterableOrIteratorType extends ObjectType, UnionType {
iterableElementType?: Type;
iteratorElementType?: Type;
}
// Type parameters (TypeFlags.TypeParameter)
@ -1676,7 +1819,8 @@ module ts {
target?: ScriptTarget;
version?: boolean;
watch?: boolean;
separateCompilation?: boolean;
isolatedModules?: boolean;
experimentalDecorators?: boolean;
emitDecoratorMetadata?: boolean;
/* @internal */ stripInternal?: boolean;
[option: string]: string | number | boolean;

View file

@ -408,6 +408,93 @@ module ts {
export let fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)('|")(.+?)\2.*?\/>/
export function isTypeNode(node: Node): boolean {
if (SyntaxKind.FirstTypeNode <= node.kind && node.kind <= SyntaxKind.LastTypeNode) {
return true;
}
switch (node.kind) {
case SyntaxKind.AnyKeyword:
case SyntaxKind.NumberKeyword:
case SyntaxKind.StringKeyword:
case SyntaxKind.BooleanKeyword:
case SyntaxKind.SymbolKeyword:
return true;
case SyntaxKind.VoidKeyword:
return node.parent.kind !== SyntaxKind.VoidExpression;
case SyntaxKind.StringLiteral:
// Specialized signatures can have string literals as their parameters' type names
return node.parent.kind === SyntaxKind.Parameter;
case SyntaxKind.ExpressionWithTypeArguments:
return true;
// Identifiers and qualified names may be type nodes, depending on their context. Climb
// above them to find the lowest container
case SyntaxKind.Identifier:
// If the identifier is the RHS of a qualified name, then it's a type iff its parent is.
if (node.parent.kind === SyntaxKind.QualifiedName && (<QualifiedName>node.parent).right === node) {
node = node.parent;
}
else if (node.parent.kind === SyntaxKind.PropertyAccessExpression && (<PropertyAccessExpression>node.parent).name === node) {
node = node.parent;
}
// fall through
case SyntaxKind.QualifiedName:
case SyntaxKind.PropertyAccessExpression:
// At this point, node is either a qualified name or an identifier
Debug.assert(node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName || node.kind === SyntaxKind.PropertyAccessExpression,
"'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'.");
let parent = node.parent;
if (parent.kind === SyntaxKind.TypeQuery) {
return false;
}
// Do not recursively call isTypeNode on the parent. In the example:
//
// let a: A.B.C;
//
// Calling isTypeNode would consider the qualified name A.B a type node. Only C or
// A.B.C is a type node.
if (SyntaxKind.FirstTypeNode <= parent.kind && parent.kind <= SyntaxKind.LastTypeNode) {
return true;
}
switch (parent.kind) {
case SyntaxKind.ExpressionWithTypeArguments:
return true;
case SyntaxKind.TypeParameter:
return node === (<TypeParameterDeclaration>parent).constraint;
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertySignature:
case SyntaxKind.Parameter:
case SyntaxKind.VariableDeclaration:
return node === (<VariableLikeDeclaration>parent).type;
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
case SyntaxKind.ArrowFunction:
case SyntaxKind.Constructor:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
return node === (<FunctionLikeDeclaration>parent).type;
case SyntaxKind.CallSignature:
case SyntaxKind.ConstructSignature:
case SyntaxKind.IndexSignature:
return node === (<SignatureDeclaration>parent).type;
case SyntaxKind.TypeAssertionExpression:
return node === (<TypeAssertion>parent).type;
case SyntaxKind.CallExpression:
case SyntaxKind.NewExpression:
return (<CallExpression>parent).typeArguments && indexOf((<CallExpression>parent).typeArguments, node) >= 0;
case SyntaxKind.TaggedTemplateExpression:
// TODO (drosen): TaggedTemplateExpressions may eventually support type arguments.
return false;
}
}
return false;
}
// Warning: This has the same semantics as the forEach family of functions,
// in that traversal terminates in the event that 'visitor' supplies a truthy value.
export function forEachReturnStatement<T>(body: Block, visitor: (stmt: ReturnStatement) => T): T {
@ -438,6 +525,46 @@ module ts {
}
}
export function forEachYieldExpression(body: Block, visitor: (expr: YieldExpression) => void): void {
return traverse(body);
function traverse(node: Node): void {
switch (node.kind) {
case SyntaxKind.YieldExpression:
visitor(<YieldExpression>node);
let operand = (<YieldExpression>node).expression;
if (operand) {
traverse(operand);
}
case SyntaxKind.EnumDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.TypeAliasDeclaration:
case SyntaxKind.ClassDeclaration:
// These are not allowed inside a generator now, but eventually they may be allowed
// as local types. Regardless, any yield statements contained within them should be
// skipped in this traversal.
return;
default:
if (isFunctionLike(node)) {
let name = (<FunctionLikeDeclaration>node).name;
if (name && name.kind === SyntaxKind.ComputedPropertyName) {
// Note that we will not include methods/accessors of a class because they would require
// first descending into the class. This is by design.
traverse((<ComputedPropertyName>name).expression);
return;
}
}
else if (!isTypeNode(node)) {
// This is the general case, which should include mostly expressions and statements.
// Also includes NodeArrays.
forEachChild(node, traverse);
}
}
}
}
export function isVariableLike(node: Node): boolean {
if (node) {
switch (node.kind) {
@ -468,6 +595,12 @@ module ts {
return false;
}
export function isClassLike(node: Node): boolean {
if (node) {
return node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression;
}
}
export function isFunctionLike(node: Node): boolean {
if (node) {
switch (node.kind) {
@ -733,6 +866,7 @@ module ts {
case SyntaxKind.TemplateExpression:
case SyntaxKind.NoSubstitutionTemplateLiteral:
case SyntaxKind.OmittedExpression:
case SyntaxKind.YieldExpression:
return true;
case SyntaxKind.QualifiedName:
while (node.parent.kind === SyntaxKind.QualifiedName) {
@ -829,10 +963,6 @@ module ts {
}
}
export function hasDotDotDotToken(node: Node) {
return node && node.kind === SyntaxKind.Parameter && (<ParameterDeclaration>node).dotDotDotToken !== undefined;
}
export function hasQuestionToken(node: Node) {
if (node) {
switch (node.kind) {
@ -852,8 +982,76 @@ module ts {
return false;
}
export function hasRestParameters(s: SignatureDeclaration): boolean {
return s.parameters.length > 0 && lastOrUndefined(s.parameters).dotDotDotToken !== undefined;
export function isJSDocConstructSignature(node: Node) {
return node.kind === SyntaxKind.JSDocFunctionType &&
(<JSDocFunctionType>node).parameters.length > 0 &&
(<JSDocFunctionType>node).parameters[0].type.kind === SyntaxKind.JSDocConstructorType;
}
function getJSDocTag(node: Node, kind: SyntaxKind): JSDocTag {
if (node && node.jsDocComment) {
for (let tag of node.jsDocComment.tags) {
if (tag.kind === kind) {
return tag;
}
}
}
}
export function getJSDocTypeTag(node: Node): JSDocTypeTag {
return <JSDocTypeTag>getJSDocTag(node, SyntaxKind.JSDocTypeTag);
}
export function getJSDocReturnTag(node: Node): JSDocReturnTag {
return <JSDocReturnTag>getJSDocTag(node, SyntaxKind.JSDocReturnTag);
}
export function getJSDocTemplateTag(node: Node): JSDocTemplateTag {
return <JSDocTemplateTag>getJSDocTag(node, SyntaxKind.JSDocTemplateTag);
}
export function getCorrespondingJSDocParameterTag(parameter: ParameterDeclaration): JSDocParameterTag {
if (parameter.name && parameter.name.kind === SyntaxKind.Identifier) {
// If it's a parameter, see if the parent has a jsdoc comment with an @param
// annotation.
let parameterName = (<Identifier>parameter.name).text;
let docComment = parameter.parent.jsDocComment;
if (docComment) {
return <JSDocParameterTag>forEach(docComment.tags, t => {
if (t.kind === SyntaxKind.JSDocParameterTag) {
let parameterTag = <JSDocParameterTag>t;
let name = parameterTag.preParameterName || parameterTag.postParameterName;
if (name.text === parameterName) {
return t;
}
}
});
}
}
}
export function hasRestParameter(s: SignatureDeclaration): boolean {
return isRestParameter(lastOrUndefined(s.parameters));
}
export function isRestParameter(node: ParameterDeclaration) {
if (node) {
if (node.parserContextFlags & ParserContextFlags.JavaScriptFile) {
if (node.type && node.type.kind === SyntaxKind.JSDocVariadicType) {
return true;
}
let paramTag = getCorrespondingJSDocParameterTag(node);
if (paramTag && paramTag.typeExpression) {
return paramTag.typeExpression.type.kind === SyntaxKind.JSDocVariadicType;
}
}
return node.dotDotDotToken !== undefined;
}
return false;
}
export function isLiteralKind(kind: SyntaxKind): boolean {
@ -1447,7 +1645,7 @@ module ts {
if ((isExternalModule(sourceFile) || !compilerOptions.out)) {
// 1. in-browser single file compilation scenario
// 2. non .js file
return compilerOptions.separateCompilation || !fileExtensionIs(sourceFile.fileName, ".js");
return compilerOptions.isolatedModules || !fileExtensionIs(sourceFile.fileName, ".js");
}
return false;
}
@ -1707,6 +1905,10 @@ module ts {
return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & NodeFlags.Default) ? symbol.valueDeclaration.localSymbol : undefined;
}
export function isJavaScript(fileName: string) {
return fileExtensionIs(fileName, ".js");
}
/**
* Replace each instance of non-ascii characters by one, two, three, or four escape sequences
* representing the UTF-8 encoding of the character, and return the expanded char code list.
@ -2000,4 +2202,14 @@ module ts {
return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength:*/ newEndN - oldStartN);
}
export function getTypeParameterOwner(d: Declaration): Declaration {
if (d && d.kind === SyntaxKind.TypeParameter) {
for (let current: Node = d; current; current = current.parent) {
if (isFunctionLike(current) || isClassLike(current) || current.kind === SyntaxKind.InterfaceDeclaration) {
return <Declaration>current;
}
}
}
}
}

View file

@ -798,8 +798,17 @@ module FourSlash {
return "\nActual " + name + ":\n\t" + actualValue + "\nExpected value:\n\t" + expectedValue;
}
public getSyntacticDiagnostics(expected: string) {
var diagnostics = this.languageService.getSyntacticDiagnostics(this.activeFile.fileName);
this.testDiagnostics(expected, diagnostics);
}
public getSemanticDiagnostics(expected: string) {
var diagnostics = this.languageService.getSemanticDiagnostics(this.activeFile.fileName);
this.testDiagnostics(expected, diagnostics);
}
private testDiagnostics(expected: string, diagnostics: ts.Diagnostic[]) {
var realized = ts.realizeDiagnostics(diagnostics, "\r\n");
var actual = JSON.stringify(realized, null, " ");
assert.equal(actual, expected);
@ -1809,6 +1818,21 @@ module FourSlash {
}
}
private verifyProjectInfo(expected: string[]) {
if (this.testType == FourSlashTestType.Server) {
let actual = (<ts.server.SessionClient>this.languageService).getProjectInfo(
this.activeFile.fileName,
/* needFileNameList */ true
);
assert.equal(
expected.join(","),
actual.fileNameList.map( file => {
return file.replace(this.basePath + "/", "")
}).join(",")
);
}
}
public verifySemanticClassifications(expected: { classificationType: string; text: string }[]) {
var actual = this.languageService.getSemanticClassifications(this.activeFile.fileName,
ts.createTextSpan(0, this.activeFile.content.length));

View file

@ -193,12 +193,16 @@ module Utils {
};
}
export function sourceFileToJSON(file: ts.SourceFile): string {
export function sourceFileToJSON(file: ts.Node): string {
return JSON.stringify(file,(k, v) => {
return isNodeOrArray(v) ? serializeNode(v) : v;
}, " ");
function getKindName(k: number): string {
function getKindName(k: number | string): string {
if (typeof k === "string") {
return k;
}
return (<any>ts).SyntaxKind[k]
}
@ -231,7 +235,9 @@ module Utils {
function serializeNode(n: ts.Node): any {
var o: any = { kind: getKindName(n.kind) };
o.containsParseError = ts.containsParseError(n);
if (ts.containsParseError(n)) {
o.containsParseError = true;
}
ts.forEach(Object.getOwnPropertyNames(n), propertyName => {
switch (propertyName) {
@ -249,6 +255,10 @@ module Utils {
// Blacklist of items we never put in the baseline file.
break;
case "originalKeywordKind":
o[propertyName] = getKindName((<any>n)[propertyName]);
break;
case "flags":
// Print out flags with their enum names.
o[propertyName] = getNodeFlagName(n.flags);
@ -1001,6 +1011,10 @@ module Harness {
options.target = <any>setting.value;
}
break;
case 'experimentaldecorators':
options.experimentalDecorators = setting.value === 'true';
break;
case 'emitdecoratormetadata':
options.emitDecoratorMetadata = setting.value === 'true';
@ -1095,8 +1109,8 @@ module Harness {
options.preserveConstEnums = setting.value === 'true';
break;
case 'separatecompilation':
options.separateCompilation = setting.value === 'true';
case 'isolatedmodules':
options.isolatedModules = setting.value === 'true';
break;
case 'suppressimplicitanyindexerrors':
@ -1512,8 +1526,8 @@ module Harness {
"noimplicitany", "noresolve", "newline", "normalizenewline", "emitbom",
"errortruncation", "usecasesensitivefilenames", "preserveconstenums",
"includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal",
"separatecompilation", "inlinesourcemap", "maproot", "sourceroot",
"inlinesources", "emitdecoratormetadata"];
"isolatedmodules", "inlinesourcemap", "maproot", "sourceroot",
"inlinesources", "emitdecoratormetadata", "experimentaldecorators"];
function extractCompilerSettings(content: string): CompilerSetting[] {

13
src/lib/es6.d.ts vendored
View file

@ -316,6 +316,11 @@ interface Array<T> {
copyWithin(target: number, start: number, end?: number): T[];
}
interface IArguments {
/** Iterator */
[Symbol.iterator](): IterableIterator<any>;
}
interface ArrayConstructor {
/**
* Creates an array from an array-like object.
@ -500,14 +505,6 @@ interface GeneratorFunctionConstructor {
}
declare var GeneratorFunction: GeneratorFunctionConstructor;
interface Generator<T> extends IterableIterator<T> {
next(value?: any): IteratorResult<T>;
throw(exception: any): IteratorResult<T>;
return(value: T): IteratorResult<T>;
[Symbol.iterator](): Generator<T>;
[Symbol.toStringTag]: string;
}
interface Math {
/**
* Returns the number of leading zero bits in the 32-bit binary representation of a number.

16
src/lib/intl.d.ts vendored
View file

@ -62,10 +62,10 @@ declare module Intl {
resolvedOptions(): ResolvedNumberFormatOptions;
}
var NumberFormat: {
new (locales?: string[], options?: NumberFormatOptions): Collator;
new (locale?: string, options?: NumberFormatOptions): Collator;
(locales?: string[], options?: NumberFormatOptions): Collator;
(locale?: string, options?: NumberFormatOptions): Collator;
new (locales?: string[], options?: NumberFormatOptions): NumberFormat;
new (locale?: string, options?: NumberFormatOptions): NumberFormat;
(locales?: string[], options?: NumberFormatOptions): NumberFormat;
(locale?: string, options?: NumberFormatOptions): NumberFormat;
supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[];
supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[];
}
@ -107,10 +107,10 @@ declare module Intl {
resolvedOptions(): ResolvedDateTimeFormatOptions;
}
var DateTimeFormat: {
new (locales?: string[], options?: DateTimeFormatOptions): Collator;
new (locale?: string, options?: DateTimeFormatOptions): Collator;
(locales?: string[], options?: DateTimeFormatOptions): Collator;
(locale?: string, options?: DateTimeFormatOptions): Collator;
new (locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat;
new (locale?: string, options?: DateTimeFormatOptions): DateTimeFormat;
(locales?: string[], options?: DateTimeFormatOptions): DateTimeFormat;
(locale?: string, options?: DateTimeFormatOptions): DateTimeFormat;
supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[];
supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[];
}

View file

@ -171,6 +171,21 @@ module ts.server {
documentation: [{ kind: "text", text: response.body.documentation }]
};
}
getProjectInfo(fileName: string, needFileNameList: boolean): protocol.ProjectInfo {
var args: protocol.ProjectInfoRequestArgs = {
file: fileName,
needFileNameList: needFileNameList
};
var request = this.processRequest<protocol.ProjectInfoRequest>(CommandNames.ProjectInfo, args);
var response = this.processResponse<protocol.ProjectInfoResponse>(request);
return {
configFileName: response.body.configFileName,
fileNameList: response.body.fileNameList
};
}
getCompletionsAtPosition(fileName: string, position: number): CompletionInfo {
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);

View file

@ -305,6 +305,11 @@ module ts.server {
return this.projectService.openFile(filename, false);
}
getFileNameList() {
let sourceFiles = this.program.getSourceFiles();
return sourceFiles.map(sourceFile => sourceFile.fileName);
}
getSourceFile(info: ScriptInfo) {
return this.filenameToSourceFile[info.fileName];
}

View file

@ -87,6 +87,45 @@ declare module ts.server.protocol {
file: string;
}
/**
* Arguments for ProjectInfoRequest request.
*/
export interface ProjectInfoRequestArgs extends FileRequestArgs {
/**
* Indicate if the file name list of the project is needed
*/
needFileNameList: boolean;
}
/**
* A request to get the project information of the current file
*/
export interface ProjectInfoRequest extends Request {
arguments: ProjectInfoRequestArgs
}
/**
* Response message body for "projectInfo" request
*/
export interface ProjectInfo {
/**
* For configured project, this is the normalized path of the 'tsconfig.json' file
* For inferred project, this is undefined
*/
configFileName: string;
/**
* The list of normalized file name in the project, including 'lib.d.ts'
*/
fileNameList?: string[];
}
/**
* Response message for "projectInfo" request
*/
export interface ProjectInfoResponse extends Response {
body?: ProjectInfo;
}
/**
* Request whose sole parameter is a file name.
*/

View file

@ -76,29 +76,30 @@ module ts.server {
}
export module CommandNames {
export var Brace = "brace";
export var Change = "change";
export var Close = "close";
export var Completions = "completions";
export var CompletionDetails = "completionEntryDetails";
export var Configure = "configure";
export var Definition = "definition";
export var Exit = "exit";
export var Format = "format";
export var Formatonkey = "formatonkey";
export var Geterr = "geterr";
export var NavBar = "navbar";
export var Navto = "navto";
export var Occurrences = "occurrences";
export var Open = "open";
export var Quickinfo = "quickinfo";
export var References = "references";
export var Reload = "reload";
export var Rename = "rename";
export var Saveto = "saveto";
export var SignatureHelp = "signatureHelp";
export var TypeDefinition = "typeDefinition";
export var Unknown = "unknown";
export const Brace = "brace";
export const Change = "change";
export const Close = "close";
export const Completions = "completions";
export const CompletionDetails = "completionEntryDetails";
export const Configure = "configure";
export const Definition = "definition";
export const Exit = "exit";
export const Format = "format";
export const Formatonkey = "formatonkey";
export const Geterr = "geterr";
export const NavBar = "navbar";
export const Navto = "navto";
export const Occurrences = "occurrences";
export const Open = "open";
export const Quickinfo = "quickinfo";
export const References = "references";
export const Reload = "reload";
export const Rename = "rename";
export const Saveto = "saveto";
export const SignatureHelp = "signatureHelp";
export const TypeDefinition = "typeDefinition";
export const ProjectInfo = "projectInfo";
export const Unknown = "unknown";
}
module Errors {
@ -338,6 +339,21 @@ module ts.server {
});
}
getProjectInfo(fileName: string, needFileNameList: boolean): protocol.ProjectInfo {
fileName = ts.normalizePath(fileName)
let project = this.projectService.getProjectForFile(fileName)
let projectInfo: protocol.ProjectInfo = {
configFileName: project.projectFilename
}
if (needFileNameList) {
projectInfo.fileNameList = project.getFileNameList();
}
return projectInfo;
}
getRenameLocations(line: number, offset: number, fileName: string,findInComments: boolean, findInStrings: boolean): protocol.RenameResponseBody {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
@ -951,6 +967,11 @@ module ts.server {
response = this.getOccurrences(line, offset, fileName);
break;
}
case CommandNames.ProjectInfo: {
var { file, needFileNameList } = <protocol.ProjectInfoRequestArgs>request.arguments;
response = this.getProjectInfo(file, needFileNameList);
break;
}
default: {
this.projectService.log("Unrecognized JSON command: " + message);
this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command);

View file

@ -193,12 +193,18 @@ module ts.formatting {
// Insert space after function keyword for anonymous functions
public SpaceAfterAnonymousFunctionKeyword: Rule;
public NoSpaceAfterAnonymousFunctionKeyword: Rule;
// Insert space after @ in decorator
public SpaceBeforeAt: Rule;
public NoSpaceAfterAt: Rule;
public SpaceAfterDecorator: Rule;
// Generator: function*
public NoSpaceBetweenFunctionKeywordAndStar: Rule;
public SpaceAfterStarInGeneratorDeclaration: Rule;
public NoSpaceBetweenYieldKeywordAndStar: Rule;
public SpaceBetweenYieldOrYieldStarAndOperand: Rule;
constructor() {
///
/// Common Rules
@ -231,7 +237,7 @@ module ts.formatting {
this.NoSpaceBeforeOpenBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
this.NoSpaceAfterOpenBracket = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
this.NoSpaceBeforeCloseBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
this.NoSpaceAfterCloseBracket = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
this.NoSpaceAfterCloseBracket = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), RuleAction.Delete));
// Place a space before open brace in a function declaration
this.FunctionOpenBraceLeftTokenRange = Shared.TokenRange.AnyIncludingMultilineComments;
@ -340,6 +346,11 @@ module ts.formatting {
this.NoSpaceAfterAt = new Rule(RuleDescriptor.create3(SyntaxKind.AtToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
this.SpaceAfterDecorator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.ExportKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.ClassKeyword, SyntaxKind.StaticKeyword, SyntaxKind.PublicKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.GetKeyword, SyntaxKind.SetKeyword, SyntaxKind.OpenBracketToken, SyntaxKind.AsteriskToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), RuleAction.Space));
this.NoSpaceBetweenFunctionKeywordAndStar = new Rule(RuleDescriptor.create1(SyntaxKind.FunctionKeyword, SyntaxKind.AsteriskToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), RuleAction.Delete));
this.SpaceAfterStarInGeneratorDeclaration = new Rule(RuleDescriptor.create3(SyntaxKind.AsteriskToken, Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.OpenParenToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), RuleAction.Space));
this.NoSpaceBetweenYieldKeywordAndStar = new Rule(RuleDescriptor.create1(SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), RuleAction.Delete));
this.SpaceBetweenYieldOrYieldStarAndOperand = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), RuleAction.Space));
// These rules are higher in priority than user-configurable rules.
this.HighPriorityCommonRules =
[
@ -357,7 +368,9 @@ module ts.formatting {
this.NoSpaceAfterCloseBrace,
this.SpaceAfterOpenBrace, this.SpaceBeforeCloseBrace, this.NewLineBeforeCloseBraceInBlockContext,
this.SpaceAfterCloseBrace, this.SpaceBetweenCloseBraceAndElse, this.SpaceBetweenCloseBraceAndWhile, this.NoSpaceBetweenEmptyBraceBrackets,
this.NoSpaceBetweenFunctionKeywordAndStar, this.SpaceAfterStarInGeneratorDeclaration,
this.SpaceAfterFunctionInFuncDecl, this.NewLineAfterOpenBraceInBlockContext, this.SpaceAfterGetSetInMember,
this.NoSpaceBetweenYieldKeywordAndStar, this.SpaceBetweenYieldOrYieldStarAndOperand,
this.NoSpaceBetweenReturnAndSemicolon,
this.SpaceAfterCertainKeywords,
this.SpaceAfterLetConstInVariableDeclaration,
@ -574,6 +587,10 @@ module ts.formatting {
return false;
}
static IsFunctionDeclarationOrFunctionExpressionContext(context: FormattingContext): boolean {
return context.contextNode.kind === SyntaxKind.FunctionDeclaration || context.contextNode.kind === SyntaxKind.FunctionExpression;
}
static IsTypeScriptDeclWithBlockContext(context: FormattingContext): boolean {
return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode);
}
@ -650,6 +667,10 @@ module ts.formatting {
return context.TokensAreOnSameLine();
}
static IsNotBeforeBlockInFunctionDeclarationContext(context: FormattingContext): boolean {
return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context)
}
static IsEndOfDecoratorContextOnSameLine(context: FormattingContext): boolean {
return context.TokensAreOnSameLine() &&
context.contextNode.decorators &&
@ -713,5 +734,9 @@ module ts.formatting {
static IsVoidOpContext(context: FormattingContext): boolean {
return context.currentTokenSpan.kind === SyntaxKind.VoidKeyword && context.currentTokenParent.kind === SyntaxKind.VoidExpression;
}
static IsYieldOrYieldStarWithOperand(context: FormattingContext): boolean {
return context.contextNode.kind === SyntaxKind.YieldExpression && (<YieldExpression>context.contextNode).expression !== undefined;
}
}
}

View file

@ -1510,6 +1510,7 @@ module ts {
public static typeParameterName = "type parameter name";
public static typeAliasName = "type alias name";
public static parameterName = "parameter name";
public static docCommentTagName = "doc comment tag name";
}
export const enum ClassificationType {
@ -1529,7 +1530,8 @@ module ts {
moduleName = 14,
typeParameterName = 15,
typeAliasName = 16,
parameterName = 17
parameterName = 17,
docCommentTagName = 18,
}
/// Language Service
@ -1761,13 +1763,13 @@ module ts {
* This function will compile source text from 'input' argument using specified compiler options.
* If not options are provided - it will use a set of default compiler options.
* Extra compiler options that will unconditionally be used bu this function are:
* - separateCompilation = true
* - isolatedModules = true
* - allowNonTsExtensions = true
*/
export function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string {
let options = compilerOptions ? clone(compilerOptions) : getDefaultCompilerOptions();
options.separateCompilation = true;
options.isolatedModules = true;
// Filename can be non-ts file.
options.allowNonTsExtensions = true;
@ -1813,7 +1815,8 @@ module ts {
}
export function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile {
let sourceFile = createSourceFile(fileName, scriptSnapshot.getText(0, scriptSnapshot.getLength()), scriptTarget, setNodeParents);
let text = scriptSnapshot.getText(0, scriptSnapshot.getLength());
let sourceFile = createSourceFile(fileName, text, scriptTarget, setNodeParents);
setSourceFileFields(sourceFile, scriptSnapshot, version);
// after full parsing we can use table with interned strings as name table
sourceFile.nameTable = sourceFile.identifiers;
@ -1829,7 +1832,34 @@ module ts {
if (version !== sourceFile.version) {
// Once incremental parsing is ready, then just call into this function.
if (!disableIncrementalParsing) {
let newSourceFile = updateSourceFile(sourceFile, scriptSnapshot.getText(0, scriptSnapshot.getLength()), textChangeRange, aggressiveChecks);
let newText: string;
// grab the fragment from the beginning of the original text to the beginning of the span
let prefix = textChangeRange.span.start !== 0
? sourceFile.text.substr(0, textChangeRange.span.start)
: "";
// grab the fragment from the end of the span till the end of the original text
let suffix = textSpanEnd(textChangeRange.span) !== sourceFile.text.length
? sourceFile.text.substr(textSpanEnd(textChangeRange.span))
: "";
if (textChangeRange.newLength === 0) {
// edit was a deletion - just combine prefix and suffix
newText = prefix && suffix ? prefix + suffix : prefix || suffix;
}
else {
// it was actual edit, fetch the fragment of new text that correspond to new span
let changedText = scriptSnapshot.getText(textChangeRange.span.start, textChangeRange.span.start + textChangeRange.newLength);
// combine prefix, changed text and suffix
newText = prefix && suffix
? prefix + changedText + suffix
: prefix
? (prefix + changedText)
: (changedText + suffix);
}
let newSourceFile = updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
setSourceFileFields(newSourceFile, scriptSnapshot, version);
// after incremental parsing nameTable might not be up-to-date
// drop it so it can be lazily recreated later
@ -2448,6 +2478,10 @@ module ts {
}
}
// hostCache is captured in the closure for 'getOrCreateSourceFile' but it should not be used past this point.
// It needs to be cleared to allow all collected snapshots to be released
hostCache = undefined;
program = newProgram;
// Make sure all the nodes in the program are both bound, and have their parent
@ -2456,6 +2490,7 @@ module ts {
return;
function getOrCreateSourceFile(fileName: string): SourceFile {
Debug.assert(hostCache !== undefined);
// The program is asking for this file, check first if the host can locate it.
// If the host can not locate the file, then it does not exist. return undefined
// to the program to allow reporting of errors for missing files.
@ -2671,7 +2706,7 @@ module ts {
return true;
}
if (parameter.questionToken) {
diagnostics.push(createDiagnosticForNode(parameter.questionToken, Diagnostics.can_only_be_used_in_a_ts_file));
diagnostics.push(createDiagnosticForNode(parameter.questionToken, Diagnostics._0_can_only_be_used_in_a_ts_file, '?'));
return true;
}
if (parameter.type) {
@ -2805,6 +2840,7 @@ module ts {
let typeChecker = program.getTypeChecker();
let syntacticStart = new Date().getTime();
let sourceFile = getValidSourceFile(fileName);
let isJavaScriptFile = isJavaScript(fileName);
let start = new Date().getTime();
let currentToken = getTokenAtPosition(sourceFile, position);
@ -2905,13 +2941,29 @@ module ts {
}
let type = typeChecker.getTypeAtLocation(node);
addTypeProperties(type);
}
function addTypeProperties(type: Type) {
if (type) {
// Filter private properties
forEach(type.getApparentProperties(), symbol => {
for (let symbol of type.getApparentProperties()) {
if (typeChecker.isValidPropertyAccess(<PropertyAccessExpression>(node.parent), symbol.name)) {
symbols.push(symbol);
}
});
}
if (isJavaScriptFile && type.flags & TypeFlags.Union) {
// In javascript files, for union types, we don't just get the members that
// the individual types have in common, we also include all the members that
// each individual type has. This is because we're going to add all identifiers
// anyways. So we might as well elevate the members that were at least part
// of the individual types to a higher status since we know what they are.
let unionType = <UnionType>type;
for (let elementType of unionType.types) {
addTypeProperties(elementType);
}
}
}
}
@ -3098,16 +3150,20 @@ module ts {
if (previousToken.kind === SyntaxKind.StringLiteral
|| previousToken.kind === SyntaxKind.RegularExpressionLiteral
|| isTemplateLiteralKind(previousToken.kind)) {
// The position has to be either: 1. entirely within the token text, or
// 2. at the end position of an unterminated token.
let start = previousToken.getStart();
let end = previousToken.getEnd();
// To be "in" one of these literals, the position has to be:
// 1. entirely within the token text.
// 2. at the end position of an unterminated token.
// 3. at the end of a regular expression (due to trailing flags like '/foo/g').
if (start < position && position < end) {
return true;
}
else if (position === end) {
return !!(<LiteralExpression>previousToken).isUnterminated;
if (position === end) {
return !!(<LiteralExpression>previousToken).isUnterminated ||
previousToken.kind === SyntaxKind.RegularExpressionLiteral;
}
}
@ -6004,6 +6060,7 @@ module ts {
case ClassificationType.typeParameterName: return ClassificationTypeNames.typeParameterName;
case ClassificationType.typeAliasName: return ClassificationTypeNames.typeAliasName;
case ClassificationType.parameterName: return ClassificationTypeNames.parameterName;
case ClassificationType.docCommentTagName: return ClassificationTypeNames.docCommentTagName;
}
}
@ -6066,8 +6123,7 @@ module ts {
// Only bother with the trivia if it at least intersects the span of interest.
if (textSpanIntersectsWith(span, start, width)) {
if (isComment(kind)) {
// Simple comment. Just add as is.
pushClassification(start, width, ClassificationType.comment);
classifyComment(token, kind, start, width);
continue;
}
@ -6091,6 +6147,92 @@ module ts {
}
}
function classifyComment(token: Node, kind: SyntaxKind, start: number, width: number) {
if (kind === SyntaxKind.MultiLineCommentTrivia) {
// See if this is a doc comment. If so, we'll classify certain portions of it
// specially.
let docCommentAndDiagnostics = parseIsolatedJSDocComment(sourceFile.text, start, width);
if (docCommentAndDiagnostics && docCommentAndDiagnostics.jsDocComment) {
docCommentAndDiagnostics.jsDocComment.parent = token;
classifyJSDocComment(docCommentAndDiagnostics.jsDocComment);
return;
}
}
// Simple comment. Just add as is.
pushCommentRange(start, width);
}
function pushCommentRange(start: number, width: number) {
pushClassification(start, width, ClassificationType.comment);
}
function classifyJSDocComment(docComment: JSDocComment) {
let pos = docComment.pos;
for (let tag of docComment.tags) {
// As we walk through each tag, classify the portion of text from the end of
// the last tag (or the start of the entire doc comment) as 'comment'.
if (tag.pos !== pos) {
pushCommentRange(pos, tag.pos - pos);
}
pushClassification(tag.atToken.pos, tag.atToken.end - tag.atToken.pos, ClassificationType.punctuation);
pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, ClassificationType.docCommentTagName);
pos = tag.tagName.end;
switch (tag.kind) {
case SyntaxKind.JSDocParameterTag:
processJSDocParameterTag(<JSDocParameterTag>tag);
break;
case SyntaxKind.JSDocTemplateTag:
processJSDocTemplateTag(<JSDocTemplateTag>tag);
break;
case SyntaxKind.JSDocTypeTag:
processElement((<JSDocTypeTag>tag).typeExpression);
break;
case SyntaxKind.JSDocReturnTag:
processElement((<JSDocReturnTag>tag).typeExpression);
break;
}
pos = tag.end;
}
if (pos !== docComment.end) {
pushCommentRange(pos, docComment.end - pos);
}
return;
function processJSDocParameterTag(tag: JSDocParameterTag) {
if (tag.preParameterName) {
pushCommentRange(pos, tag.preParameterName.pos - pos);
pushClassification(tag.preParameterName.pos, tag.preParameterName.end - tag.preParameterName.pos, ClassificationType.parameterName);
pos = tag.preParameterName.end;
}
if (tag.typeExpression) {
pushCommentRange(pos, tag.typeExpression.pos - pos);
processElement(tag.typeExpression);
pos = tag.typeExpression.end;
}
if (tag.postParameterName) {
pushCommentRange(pos, tag.postParameterName.pos - pos);
pushClassification(tag.postParameterName.pos, tag.postParameterName.end - tag.postParameterName.pos, ClassificationType.parameterName);
pos = tag.postParameterName.end;
}
}
}
function processJSDocTemplateTag(tag: JSDocTemplateTag) {
for (let child of tag.getChildren()) {
processElement(child);
}
}
function classifyDisabledMergeCode(text: string, start: number, end: number) {
// Classify the line that the ======= marker is on as a comment. Then just lex
// all further tokens and add them to the result.
@ -6224,9 +6366,13 @@ module ts {
}
function processElement(element: Node) {
if (!element) {
return;
}
// Ignore nodes that don't intersect the original span to classify.
if (textSpanIntersectsWith(span, element.getFullStart(), element.getFullWidth())) {
let children = element.getChildren();
let children = element.getChildren(sourceFile);
for (let child of children) {
if (isToken(child)) {
classifyToken(child);

View file

@ -989,4 +989,4 @@ module TypeScript.Services {
}
/* @internal */
let toolsVersion = "1.4";
let toolsVersion = "1.5";

View file

@ -652,8 +652,4 @@ module ts {
typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags);
});
}
export function isJavaScript(fileName: string) {
return fileExtensionIs(fileName, ".js");
}
}

View file

@ -1,8 +1,8 @@
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,10): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,10): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts (1 errors) ====
function * foo(a = yield => yield) {
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
}

View file

@ -1,8 +1,8 @@
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts(1,10): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts(1,10): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration11_es6.ts (1 errors) ====
function * yield() {
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
}

View file

@ -1,11 +1,11 @@
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts(1,10): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts(1,10): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts(3,11): error TS2304: Cannot find name 'yield'.
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts (2 errors) ====
function * foo() {
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
// Legal to use 'yield' in a type context.
var v: yield;
~~~~~

View file

@ -1,8 +1,8 @@
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts(1,10): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts(1,10): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration1_es6.ts (1 errors) ====
function * foo() {
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
}

View file

@ -1,11 +1,11 @@
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,9): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts(1,18): error TS2304: Cannot find name 'yield'.
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts (2 errors) ====
function*foo(a = yield) {
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
~~~~~
!!! error TS2304: Cannot find name 'yield'.
}

View file

@ -1,16 +1,16 @@
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(1,9): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,11): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,11): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts(3,20): error TS2304: Cannot find name 'yield'.
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts (3 errors) ====
function*bar() {
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
// 'yield' here is an identifier, and not a yield expression.
function*foo(a = yield) {
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
~~~~~
!!! error TS2304: Cannot find name 'yield'.
}

View file

@ -1,12 +1,9 @@
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(1,10): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(2,14): error TS9000: 'yield' expressions are not currently supported.
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(1,10): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (2 errors) ====
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (1 errors) ====
function * foo() {
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
var v = { [yield]: foo }
~~~~~
!!! error TS9000: 'yield' expressions are not currently supported.
}

View file

@ -1,7 +1,7 @@
tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts(1,18): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts(1,18): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/es6/functionExpressions/FunctionExpression1_es6.ts (1 errors) ====
var v = function * () { }
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.

View file

@ -1,7 +1,7 @@
tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts(1,18): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts(1,18): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/es6/functionExpressions/FunctionExpression2_es6.ts (1 errors) ====
var v = function * foo() { }
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.

View file

@ -1,7 +1,7 @@
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts(1,11): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts(1,11): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments1_es6.ts (1 errors) ====
var v = { *foo() { } }
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.

View file

@ -1,10 +1,10 @@
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,11): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,11): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,13): error TS2304: Cannot find name 'foo'.
==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (2 errors) ====
var v = { *[foo()]() { } }
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
~~~
!!! error TS2304: Cannot find name 'foo'.

View file

@ -1,9 +1,9 @@
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts(2,4): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts(2,4): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration1_es6.ts (1 errors) ====
class C {
*foo() { }
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
}

View file

@ -1,9 +1,9 @@
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts(2,11): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts(2,11): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration2_es6.ts (1 errors) ====
class C {
public * foo() { }
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
}

View file

@ -1,4 +1,4 @@
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,4): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,4): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts(2,6): error TS2304: Cannot find name 'foo'.
@ -6,7 +6,7 @@ tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration
class C {
*[foo]() { }
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
~~~
!!! error TS2304: Cannot find name 'foo'.
}

View file

@ -1,9 +1,9 @@
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts(2,4): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts(2,4): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration7_es6.ts (1 errors) ====
class C {
*foo<T>() { }
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
}

View file

@ -1,14 +1,14 @@
tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts(1,11): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts(2,5): error TS9000: 'yield' expressions are not currently supported.
tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts(1,11): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts(2,11): error TS2304: Cannot find name 'foo'.
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts (2 errors) ====
var v = { * foo() {
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
yield(foo);
~~~~~
!!! error TS9000: 'yield' expressions are not currently supported.
~~~
!!! error TS2304: Cannot find name 'foo'.
}
}

View file

@ -1,14 +1,14 @@
tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(2,3): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(3,5): error TS9000: 'yield' expressions are not currently supported.
tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(2,3): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts(3,11): error TS2304: Cannot find name 'foo'.
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts (2 errors) ====
class C {
*foo() {
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
yield(foo);
~~~~~
!!! error TS9000: 'yield' expressions are not currently supported.
~~~
!!! error TS2304: Cannot find name 'foo'.
}
}

View file

@ -1,4 +1,4 @@
tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts(3,6): error TS1163: 'yield' expression must be contained_within a generator declaration.
tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts(3,6): error TS1163: A 'yield' expression is only allowed in a generator body.
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts (1 errors) ====
@ -6,6 +6,6 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts(3,6): erro
constructor() {
yield foo
~~~~~
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
}
}

View file

@ -1,10 +1,7 @@
tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts(1,9): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts(1,19): error TS9000: 'yield' expressions are not currently supported.
tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts (2 errors) ====
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression13_es6.ts (1 errors) ====
function* foo() { yield }
~
!!! error TS9001: Generators are not currently supported.
~~~~~
!!! error TS9000: 'yield' expressions are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.

View file

@ -1,4 +1,4 @@
tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts(3,6): error TS1163: 'yield' expression must be contained_within a generator declaration.
tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts(3,6): error TS1163: A 'yield' expression is only allowed in a generator body.
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts (1 errors) ====
@ -6,6 +6,6 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts(3,6): erro
foo() {
yield foo
~~~~~
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
}
}

View file

@ -1,9 +1,9 @@
tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts(2,6): error TS1163: 'yield' expression must be contained_within a generator declaration.
tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts(2,6): error TS1163: A 'yield' expression is only allowed in a generator body.
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts (1 errors) ====
var v = () => {
yield foo
~~~~~
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
}

View file

@ -1,14 +1,14 @@
tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(1,9): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(3,5): error TS1163: 'yield' expression must be contained_within a generator declaration.
tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts(3,5): error TS1163: A 'yield' expression is only allowed in a generator body.
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts (2 errors) ====
function* foo() {
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
function bar() {
yield foo;
~~~~~
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
}
}

View file

@ -1,6 +1,6 @@
tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,15): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,15): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,23): error TS1163: 'yield' expression must be contained_within a generator declaration.
tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,23): error TS1163: A 'yield' expression is only allowed in a generator body.
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts (3 errors) ====
@ -10,4 +10,4 @@ tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts(1,23): err
~~~
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
~~~~~
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
!!! error TS1163: A 'yield' expression is only allowed in a generator body.

View file

@ -1,8 +1,8 @@
tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts(2,1): error TS1163: 'yield' expression must be contained_within a generator declaration.
tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts(2,1): error TS1163: A 'yield' expression is only allowed in a generator body.
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts (1 errors) ====
"use strict";
yield(foo);
~~~~~
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
!!! error TS1163: A 'yield' expression is only allowed in a generator body.

View file

@ -1,19 +1,16 @@
tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(1,9): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(3,13): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(4,7): error TS9000: 'yield' expressions are not currently supported.
tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts(3,13): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts (3 errors) ====
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression19_es6.ts (2 errors) ====
function*foo() {
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
function bar() {
function* quux() {
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
yield(foo);
~~~~~
!!! error TS9000: 'yield' expressions are not currently supported.
}
}
}

View file

@ -1,7 +1,7 @@
tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts(1,1): error TS1163: 'yield' expression must be contained_within a generator declaration.
tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts(1,1): error TS1163: A 'yield' expression is only allowed in a generator body.
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts (1 errors) ====
yield foo;
~~~~~
!!! error TS1163: 'yield' expression must be contained_within a generator declaration.
!!! error TS1163: A 'yield' expression is only allowed in a generator body.

View file

@ -1,16 +1,10 @@
tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts(1,9): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts(2,3): error TS9000: 'yield' expressions are not currently supported.
tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts(3,3): error TS9000: 'yield' expressions are not currently supported.
tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts (3 errors) ====
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression3_es6.ts (1 errors) ====
function* foo() {
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
yield
~~~~~
!!! error TS9000: 'yield' expressions are not currently supported.
yield
~~~~~
!!! error TS9000: 'yield' expressions are not currently supported.
}

View file

@ -1,16 +1,10 @@
tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts(1,9): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts(2,3): error TS9000: 'yield' expressions are not currently supported.
tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts(3,3): error TS9000: 'yield' expressions are not currently supported.
tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts (3 errors) ====
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression4_es6.ts (1 errors) ====
function* foo() {
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
yield;
~~~~~
!!! error TS9000: 'yield' expressions are not currently supported.
yield;
~~~~~
!!! error TS9000: 'yield' expressions are not currently supported.
}

View file

@ -1,12 +1,12 @@
tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts(1,9): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts(2,3): error TS9000: 'yield' expressions are not currently supported.
tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts(2,9): error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts (2 errors) ====
function* foo() {
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
yield*foo
~~~~~
!!! error TS9000: 'yield' expressions are not currently supported.
~~~
!!! error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.
}

View file

@ -1,12 +1,9 @@
tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts(1,9): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts(2,3): error TS9000: 'yield' expressions are not currently supported.
tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts(1,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts (2 errors) ====
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression7_es6.ts (1 errors) ====
function* foo() {
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
yield foo
~~~~~
!!! error TS9000: 'yield' expressions are not currently supported.
}

View file

@ -1,16 +1,13 @@
tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(1,1): error TS2304: Cannot find name 'yield'.
tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(2,9): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(3,3): error TS9000: 'yield' expressions are not currently supported.
tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts(2,9): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts (3 errors) ====
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts (2 errors) ====
yield(foo);
~~~~~
!!! error TS2304: Cannot find name 'yield'.
function* foo() {
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
yield(foo);
~~~~~
!!! error TS9000: 'yield' expressions are not currently supported.
}

View file

@ -1,12 +1,12 @@
tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts(1,17): error TS9001: Generators are not currently supported.
tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts(2,3): error TS9000: 'yield' expressions are not currently supported.
tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts(1,17): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts(2,9): error TS2304: Cannot find name 'foo'.
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts (2 errors) ====
var v = function*() {
~
!!! error TS9001: Generators are not currently supported.
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
yield(foo);
~~~~~
!!! error TS9000: 'yield' expressions are not currently supported.
~~~
!!! error TS2304: Cannot find name 'foo'.
}

View file

@ -0,0 +1,10 @@
tests/cases/conformance/es6/yieldExpressions/YieldStarExpression1_es6.ts(1,1): error TS2304: Cannot find name 'yield'.
tests/cases/conformance/es6/yieldExpressions/YieldStarExpression1_es6.ts(1,9): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
==== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression1_es6.ts (2 errors) ====
yield * [];
~~~~~
!!! error TS2304: Cannot find name 'yield'.
~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.

View file

@ -0,0 +1,5 @@
//// [YieldStarExpression1_es6.ts]
yield * [];
//// [YieldStarExpression1_es6.js]
yield * [];

View file

@ -0,0 +1,10 @@
tests/cases/conformance/es6/yieldExpressions/YieldStarExpression2_es6.ts(1,1): error TS2304: Cannot find name 'yield'.
tests/cases/conformance/es6/yieldExpressions/YieldStarExpression2_es6.ts(1,8): error TS1109: Expression expected.
==== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression2_es6.ts (2 errors) ====
yield *;
~~~~~
!!! error TS2304: Cannot find name 'yield'.
~
!!! error TS1109: Expression expected.

View file

@ -0,0 +1,5 @@
//// [YieldStarExpression2_es6.ts]
yield *;
//// [YieldStarExpression2_es6.js]
yield * ;

View file

@ -0,0 +1,9 @@
tests/cases/conformance/es6/yieldExpressions/YieldStarExpression3_es6.ts(2,12): error TS1109: Expression expected.
==== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression3_es6.ts (1 errors) ====
function *g() {
yield *;
~
!!! error TS1109: Expression expected.
}

View file

@ -0,0 +1,9 @@
//// [YieldStarExpression3_es6.ts]
function *g() {
yield *;
}
//// [YieldStarExpression3_es6.js]
function g() {
yield* ;
}

View file

@ -0,0 +1,12 @@
tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts(1,10): error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts(2,13): error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.
==== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression4_es6.ts (2 errors) ====
function *g() {
~
!!! error TS1220: Generators are only available when targeting ECMAScript 6 or higher.
yield * [];
~~
!!! error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.
}

View file

@ -0,0 +1,9 @@
//// [YieldStarExpression4_es6.ts]
function *g() {
yield * [];
}
//// [YieldStarExpression4_es6.js]
function g() {
yield* [];
}

View file

@ -0,0 +1,14 @@
tests/cases/compiler/argumentsObjectIterator01_ES5.ts(4,21): error TS2495: Type 'IArguments' is not an array type or a string type.
==== tests/cases/compiler/argumentsObjectIterator01_ES5.ts (1 errors) ====
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
let result = [];
for (let arg of arguments) {
~~~~~~~~~
!!! error TS2495: Type 'IArguments' is not an array type or a string type.
result.push(arg + arg);
}
return <[any, any, any]>result;
}

View file

@ -0,0 +1,19 @@
//// [argumentsObjectIterator01_ES5.ts]
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
let result = [];
for (let arg of arguments) {
result.push(arg + arg);
}
return <[any, any, any]>result;
}
//// [argumentsObjectIterator01_ES5.js]
function doubleAndReturnAsArray(x, y, z) {
var result = [];
for (var _i = 0; _i < arguments.length; _i++) {
var arg = arguments[_i];
result.push(arg + arg);
}
return result;
}

View file

@ -0,0 +1,18 @@
//// [argumentsObjectIterator01_ES6.ts]
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
let result = [];
for (let arg of arguments) {
result.push(arg + arg);
}
return <[any, any, any]>result;
}
//// [argumentsObjectIterator01_ES6.js]
function doubleAndReturnAsArray(x, y, z) {
let result = [];
for (let arg of arguments) {
result.push(arg + arg);
}
return result;
}

View file

@ -0,0 +1,25 @@
=== tests/cases/compiler/argumentsObjectIterator01_ES6.ts ===
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
>doubleAndReturnAsArray : Symbol(doubleAndReturnAsArray, Decl(argumentsObjectIterator01_ES6.ts, 0, 0))
>x : Symbol(x, Decl(argumentsObjectIterator01_ES6.ts, 1, 32))
>y : Symbol(y, Decl(argumentsObjectIterator01_ES6.ts, 1, 42))
>z : Symbol(z, Decl(argumentsObjectIterator01_ES6.ts, 1, 53))
let result = [];
>result : Symbol(result, Decl(argumentsObjectIterator01_ES6.ts, 2, 7))
for (let arg of arguments) {
>arg : Symbol(arg, Decl(argumentsObjectIterator01_ES6.ts, 3, 12))
>arguments : Symbol(arguments)
result.push(arg + arg);
>result.push : Symbol(Array.push, Decl(lib.d.ts, 1016, 29))
>result : Symbol(result, Decl(argumentsObjectIterator01_ES6.ts, 2, 7))
>push : Symbol(Array.push, Decl(lib.d.ts, 1016, 29))
>arg : Symbol(arg, Decl(argumentsObjectIterator01_ES6.ts, 3, 12))
>arg : Symbol(arg, Decl(argumentsObjectIterator01_ES6.ts, 3, 12))
}
return <[any, any, any]>result;
>result : Symbol(result, Decl(argumentsObjectIterator01_ES6.ts, 2, 7))
}

View file

@ -0,0 +1,29 @@
=== tests/cases/compiler/argumentsObjectIterator01_ES6.ts ===
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
>doubleAndReturnAsArray : (x: number, y: number, z: number) => [number, number, number]
>x : number
>y : number
>z : number
let result = [];
>result : any[]
>[] : undefined[]
for (let arg of arguments) {
>arg : any
>arguments : IArguments
result.push(arg + arg);
>result.push(arg + arg) : number
>result.push : (...items: any[]) => number
>result : any[]
>push : (...items: any[]) => number
>arg + arg : any
>arg : any
>arg : any
}
return <[any, any, any]>result;
><[any, any, any]>result : [any, any, any]
>result : any[]
}

View file

@ -0,0 +1,18 @@
tests/cases/compiler/argumentsObjectIterator02_ES5.ts(3,26): error TS2304: Cannot find name 'Symbol'.
==== tests/cases/compiler/argumentsObjectIterator02_ES5.ts (1 errors) ====
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
let blah = arguments[Symbol.iterator];
~~~~~~
!!! error TS2304: Cannot find name 'Symbol'.
let result = [];
for (let arg of blah()) {
result.push(arg + arg);
}
return <[any, any, any]>result;
}

View file

@ -0,0 +1,24 @@
//// [argumentsObjectIterator02_ES5.ts]
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
let blah = arguments[Symbol.iterator];
let result = [];
for (let arg of blah()) {
result.push(arg + arg);
}
return <[any, any, any]>result;
}
//// [argumentsObjectIterator02_ES5.js]
function doubleAndReturnAsArray(x, y, z) {
var blah = arguments[Symbol.iterator];
var result = [];
for (var _i = 0, _a = blah(); _i < _a.length; _i++) {
var arg = _a[_i];
result.push(arg + arg);
}
return result;
}

View file

@ -0,0 +1,23 @@
//// [argumentsObjectIterator02_ES6.ts]
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
let blah = arguments[Symbol.iterator];
let result = [];
for (let arg of blah()) {
result.push(arg + arg);
}
return <[any, any, any]>result;
}
//// [argumentsObjectIterator02_ES6.js]
function doubleAndReturnAsArray(x, y, z) {
let blah = arguments[Symbol.iterator];
let result = [];
for (let arg of blah()) {
result.push(arg + arg);
}
return result;
}

View file

@ -0,0 +1,34 @@
=== tests/cases/compiler/argumentsObjectIterator02_ES6.ts ===
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
>doubleAndReturnAsArray : Symbol(doubleAndReturnAsArray, Decl(argumentsObjectIterator02_ES6.ts, 0, 0))
>x : Symbol(x, Decl(argumentsObjectIterator02_ES6.ts, 1, 32))
>y : Symbol(y, Decl(argumentsObjectIterator02_ES6.ts, 1, 42))
>z : Symbol(z, Decl(argumentsObjectIterator02_ES6.ts, 1, 53))
let blah = arguments[Symbol.iterator];
>blah : Symbol(blah, Decl(argumentsObjectIterator02_ES6.ts, 2, 7))
>arguments : Symbol(arguments)
>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31))
>Symbol : Symbol(Symbol, Decl(lib.d.ts, 1186, 52), Decl(lib.d.ts, 1292, 11))
>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.d.ts, 1236, 31))
let result = [];
>result : Symbol(result, Decl(argumentsObjectIterator02_ES6.ts, 4, 7))
for (let arg of blah()) {
>arg : Symbol(arg, Decl(argumentsObjectIterator02_ES6.ts, 5, 12))
>blah : Symbol(blah, Decl(argumentsObjectIterator02_ES6.ts, 2, 7))
result.push(arg + arg);
>result.push : Symbol(Array.push, Decl(lib.d.ts, 1016, 29))
>result : Symbol(result, Decl(argumentsObjectIterator02_ES6.ts, 4, 7))
>push : Symbol(Array.push, Decl(lib.d.ts, 1016, 29))
>arg : Symbol(arg, Decl(argumentsObjectIterator02_ES6.ts, 5, 12))
>arg : Symbol(arg, Decl(argumentsObjectIterator02_ES6.ts, 5, 12))
}
return <[any, any, any]>result;
>result : Symbol(result, Decl(argumentsObjectIterator02_ES6.ts, 4, 7))
}

View file

@ -0,0 +1,40 @@
=== tests/cases/compiler/argumentsObjectIterator02_ES6.ts ===
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
>doubleAndReturnAsArray : (x: number, y: number, z: number) => [number, number, number]
>x : number
>y : number
>z : number
let blah = arguments[Symbol.iterator];
>blah : () => IterableIterator<any>
>arguments[Symbol.iterator] : () => IterableIterator<any>
>arguments : IArguments
>Symbol.iterator : symbol
>Symbol : SymbolConstructor
>iterator : symbol
let result = [];
>result : any[]
>[] : undefined[]
for (let arg of blah()) {
>arg : any
>blah() : IterableIterator<any>
>blah : () => IterableIterator<any>
result.push(arg + arg);
>result.push(arg + arg) : number
>result.push : (...items: any[]) => number
>result : any[]
>push : (...items: any[]) => number
>arg + arg : any
>arg : any
>arg : any
}
return <[any, any, any]>result;
><[any, any, any]>result : [any, any, any]
>result : any[]
}

View file

@ -0,0 +1,14 @@
tests/cases/compiler/argumentsObjectIterator03_ES5.ts(3,9): error TS2461: Type 'IArguments' is not an array type.
==== tests/cases/compiler/argumentsObjectIterator03_ES5.ts (1 errors) ====
function asReversedTuple(a: number, b: string, c: boolean): [boolean, string, number] {
let [x, y, z] = arguments;
~~~~~~~~~
!!! error TS2461: Type 'IArguments' is not an array type.
return [z, y, x];
}

View file

@ -0,0 +1,15 @@
//// [argumentsObjectIterator03_ES5.ts]
function asReversedTuple(a: number, b: string, c: boolean): [boolean, string, number] {
let [x, y, z] = arguments;
return [z, y, x];
}
//// [argumentsObjectIterator03_ES5.js]
function asReversedTuple(a, b, c) {
var x = arguments[0], y = arguments[1], z = arguments[2];
return [z, y, x];
}

View file

@ -0,0 +1,15 @@
//// [argumentsObjectIterator03_ES6.ts]
function asReversedTuple(a: number, b: string, c: boolean): [boolean, string, number] {
let [x, y, z] = arguments;
return [z, y, x];
}
//// [argumentsObjectIterator03_ES6.js]
function asReversedTuple(a, b, c) {
let [x, y, z] = arguments;
return [z, y, x];
}

View file

@ -0,0 +1,21 @@
=== tests/cases/compiler/argumentsObjectIterator03_ES6.ts ===
function asReversedTuple(a: number, b: string, c: boolean): [boolean, string, number] {
>asReversedTuple : Symbol(asReversedTuple, Decl(argumentsObjectIterator03_ES6.ts, 0, 0))
>a : Symbol(a, Decl(argumentsObjectIterator03_ES6.ts, 1, 25))
>b : Symbol(b, Decl(argumentsObjectIterator03_ES6.ts, 1, 35))
>c : Symbol(c, Decl(argumentsObjectIterator03_ES6.ts, 1, 46))
let [x, y, z] = arguments;
>x : Symbol(x, Decl(argumentsObjectIterator03_ES6.ts, 2, 9))
>y : Symbol(y, Decl(argumentsObjectIterator03_ES6.ts, 2, 11))
>z : Symbol(z, Decl(argumentsObjectIterator03_ES6.ts, 2, 14))
>arguments : Symbol(arguments)
return [z, y, x];
>z : Symbol(z, Decl(argumentsObjectIterator03_ES6.ts, 2, 14))
>y : Symbol(y, Decl(argumentsObjectIterator03_ES6.ts, 2, 11))
>x : Symbol(x, Decl(argumentsObjectIterator03_ES6.ts, 2, 9))
}

View file

@ -0,0 +1,22 @@
=== tests/cases/compiler/argumentsObjectIterator03_ES6.ts ===
function asReversedTuple(a: number, b: string, c: boolean): [boolean, string, number] {
>asReversedTuple : (a: number, b: string, c: boolean) => [boolean, string, number]
>a : number
>b : string
>c : boolean
let [x, y, z] = arguments;
>x : any
>y : any
>z : any
>arguments : IArguments
return [z, y, x];
>[z, y, x] : [any, any, any]
>z : any
>y : any
>x : any
}

View file

@ -79,7 +79,7 @@ interface myArray2 extends Array<Number|String> { }
>myArray2 : Symbol(myArray2, Decl(arrayLiterals2ES6.ts, 42, 43))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1439, 1))
>Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1538, 1))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1543, 1))
var d0 = [1, true, ...temp, ]; // has type (string|number|boolean)[]
>d0 : Symbol(d0, Decl(arrayLiterals2ES6.ts, 44, 3))

View file

@ -1,59 +0,0 @@
tests/cases/conformance/expressions/functionCalls/callWithSpread.ts(52,21): error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 6 and higher.
==== tests/cases/conformance/expressions/functionCalls/callWithSpread.ts (1 errors) ====
interface X {
foo(x: number, y: number, ...z: string[]);
}
function foo(x: number, y: number, ...z: string[]) {
}
var a: string[];
var z: number[];
var obj: X;
var xa: X[];
foo(1, 2, "abc");
foo(1, 2, ...a);
foo(1, 2, ...a, "abc");
obj.foo(1, 2, "abc");
obj.foo(1, 2, ...a);
obj.foo(1, 2, ...a, "abc");
(obj.foo)(1, 2, "abc");
(obj.foo)(1, 2, ...a);
(obj.foo)(1, 2, ...a, "abc");
xa[1].foo(1, 2, "abc");
xa[1].foo(1, 2, ...a);
xa[1].foo(1, 2, ...a, "abc");
(<Function>xa[1].foo)(...[1, 2, "abc"]);
class C {
constructor(x: number, y: number, ...z: string[]) {
this.foo(x, y);
this.foo(x, y, ...z);
}
foo(x: number, y: number, ...z: string[]) {
}
}
class D extends C {
constructor() {
super(1, 2);
super(1, 2, ...a);
}
foo() {
super.foo(1, 2);
super.foo(1, 2, ...a);
}
}
// Only supported in when target is ES6
var c = new C(1, 2, ...a);
~~~~
!!! error TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 6 and higher.

View file

@ -48,9 +48,6 @@ class D extends C {
super.foo(1, 2, ...a);
}
}
// Only supported in when target is ES6
var c = new C(1, 2, ...a);
//// [callWithSpread.js]
@ -112,6 +109,4 @@ var D = (function (_super) {
};
return D;
})(C);
// Only supported in when target is ES6
var c = new C(1, 2, ...a);
var _a, _b, _c;

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