Merge branch 'master' into preserveNewLines3

Conflicts:
	tests/baselines/reference/ES5For-of22.js
This commit is contained in:
Cyrus Najmabadi 2015-03-28 23:45:47 -07:00
commit 62460aed4b
21 changed files with 31195 additions and 23664 deletions

1
.gitignore vendored
View file

@ -21,6 +21,7 @@ tests/services/baselines/local/*
tests/baselines/prototyping/local/*
tests/baselines/rwc/*
tests/baselines/test262/*
tests/baselines/local/projectOutput/*
tests/services/baselines/prototyping/local/*
tests/services/browser/typescriptServices.js
scripts/processDiagnosticMessages.d.ts

14
bin/lib.core.d.ts vendored
View file

@ -1170,3 +1170,17 @@ interface ArrayConstructor {
}
declare var Array: ArrayConstructor;
interface TypedPropertyDescriptor<T> {
enumerable?: boolean;
configurable?: boolean;
writable?: boolean;
value?: T;
get?: () => T;
set?: (value: T) => void;
}
declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
declare type ParameterDecorator = (target: Function, propertyKey: string | symbol, parameterIndex: number) => void;

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

@ -1170,6 +1170,20 @@ interface ArrayConstructor {
}
declare var Array: ArrayConstructor;
interface TypedPropertyDescriptor<T> {
enumerable?: boolean;
configurable?: boolean;
writable?: boolean;
value?: T;
get?: () => T;
set?: (value: T) => void;
}
declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
declare type ParameterDecorator = (target: Function, propertyKey: string | symbol, parameterIndex: number) => void;
declare type PropertyKey = string | number | symbol;
interface Symbol {

14
bin/lib.d.ts vendored
View file

@ -1171,6 +1171,20 @@ interface ArrayConstructor {
declare var Array: ArrayConstructor;
interface TypedPropertyDescriptor<T> {
enumerable?: boolean;
configurable?: boolean;
writable?: boolean;
value?: T;
get?: () => T;
set?: (value: T) => void;
}
declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
declare type ParameterDecorator = (target: Function, propertyKey: string | symbol, parameterIndex: number) => void;
/////////////////////////////
/// IE10 ECMAScript Extensions
/////////////////////////////

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

@ -1170,6 +1170,20 @@ interface ArrayConstructor {
}
declare var Array: ArrayConstructor;
interface TypedPropertyDescriptor<T> {
enumerable?: boolean;
configurable?: boolean;
writable?: boolean;
value?: T;
get?: () => T;
set?: (value: T) => void;
}
declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
declare type ParameterDecorator = (target: Function, propertyKey: string | symbol, parameterIndex: number) => void;
declare type PropertyKey = string | number | symbol;
interface Symbol {

9125
bin/tsc.js

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

440
bin/typescript.d.ts vendored
View file

@ -74,192 +74,195 @@ declare module "typescript" {
BarBarToken = 49,
QuestionToken = 50,
ColonToken = 51,
EqualsToken = 52,
PlusEqualsToken = 53,
MinusEqualsToken = 54,
AsteriskEqualsToken = 55,
SlashEqualsToken = 56,
PercentEqualsToken = 57,
LessThanLessThanEqualsToken = 58,
GreaterThanGreaterThanEqualsToken = 59,
GreaterThanGreaterThanGreaterThanEqualsToken = 60,
AmpersandEqualsToken = 61,
BarEqualsToken = 62,
CaretEqualsToken = 63,
Identifier = 64,
BreakKeyword = 65,
CaseKeyword = 66,
CatchKeyword = 67,
ClassKeyword = 68,
ConstKeyword = 69,
ContinueKeyword = 70,
DebuggerKeyword = 71,
DefaultKeyword = 72,
DeleteKeyword = 73,
DoKeyword = 74,
ElseKeyword = 75,
EnumKeyword = 76,
ExportKeyword = 77,
ExtendsKeyword = 78,
FalseKeyword = 79,
FinallyKeyword = 80,
ForKeyword = 81,
FunctionKeyword = 82,
IfKeyword = 83,
ImportKeyword = 84,
InKeyword = 85,
InstanceOfKeyword = 86,
NewKeyword = 87,
NullKeyword = 88,
ReturnKeyword = 89,
SuperKeyword = 90,
SwitchKeyword = 91,
ThisKeyword = 92,
ThrowKeyword = 93,
TrueKeyword = 94,
TryKeyword = 95,
TypeOfKeyword = 96,
VarKeyword = 97,
VoidKeyword = 98,
WhileKeyword = 99,
WithKeyword = 100,
AsKeyword = 101,
ImplementsKeyword = 102,
InterfaceKeyword = 103,
LetKeyword = 104,
PackageKeyword = 105,
PrivateKeyword = 106,
ProtectedKeyword = 107,
PublicKeyword = 108,
StaticKeyword = 109,
YieldKeyword = 110,
AnyKeyword = 111,
BooleanKeyword = 112,
ConstructorKeyword = 113,
DeclareKeyword = 114,
GetKeyword = 115,
ModuleKeyword = 116,
RequireKeyword = 117,
NumberKeyword = 118,
SetKeyword = 119,
StringKeyword = 120,
SymbolKeyword = 121,
TypeKeyword = 122,
FromKeyword = 123,
OfKeyword = 124,
QualifiedName = 125,
ComputedPropertyName = 126,
TypeParameter = 127,
Parameter = 128,
PropertySignature = 129,
PropertyDeclaration = 130,
MethodSignature = 131,
MethodDeclaration = 132,
Constructor = 133,
GetAccessor = 134,
SetAccessor = 135,
CallSignature = 136,
ConstructSignature = 137,
IndexSignature = 138,
TypeReference = 139,
FunctionType = 140,
ConstructorType = 141,
TypeQuery = 142,
TypeLiteral = 143,
ArrayType = 144,
TupleType = 145,
UnionType = 146,
ParenthesizedType = 147,
ObjectBindingPattern = 148,
ArrayBindingPattern = 149,
BindingElement = 150,
ArrayLiteralExpression = 151,
ObjectLiteralExpression = 152,
PropertyAccessExpression = 153,
ElementAccessExpression = 154,
CallExpression = 155,
NewExpression = 156,
TaggedTemplateExpression = 157,
TypeAssertionExpression = 158,
ParenthesizedExpression = 159,
FunctionExpression = 160,
ArrowFunction = 161,
DeleteExpression = 162,
TypeOfExpression = 163,
VoidExpression = 164,
PrefixUnaryExpression = 165,
PostfixUnaryExpression = 166,
BinaryExpression = 167,
ConditionalExpression = 168,
TemplateExpression = 169,
YieldExpression = 170,
SpreadElementExpression = 171,
OmittedExpression = 172,
TemplateSpan = 173,
Block = 174,
VariableStatement = 175,
EmptyStatement = 176,
ExpressionStatement = 177,
IfStatement = 178,
DoStatement = 179,
WhileStatement = 180,
ForStatement = 181,
ForInStatement = 182,
ForOfStatement = 183,
ContinueStatement = 184,
BreakStatement = 185,
ReturnStatement = 186,
WithStatement = 187,
SwitchStatement = 188,
LabeledStatement = 189,
ThrowStatement = 190,
TryStatement = 191,
DebuggerStatement = 192,
VariableDeclaration = 193,
VariableDeclarationList = 194,
FunctionDeclaration = 195,
ClassDeclaration = 196,
InterfaceDeclaration = 197,
TypeAliasDeclaration = 198,
EnumDeclaration = 199,
ModuleDeclaration = 200,
ModuleBlock = 201,
CaseBlock = 202,
ImportEqualsDeclaration = 203,
ImportDeclaration = 204,
ImportClause = 205,
NamespaceImport = 206,
NamedImports = 207,
ImportSpecifier = 208,
ExportAssignment = 209,
ExportDeclaration = 210,
NamedExports = 211,
ExportSpecifier = 212,
ExternalModuleReference = 213,
CaseClause = 214,
DefaultClause = 215,
HeritageClause = 216,
CatchClause = 217,
PropertyAssignment = 218,
ShorthandPropertyAssignment = 219,
EnumMember = 220,
SourceFile = 221,
SyntaxList = 222,
Count = 223,
FirstAssignment = 52,
LastAssignment = 63,
FirstReservedWord = 65,
LastReservedWord = 100,
FirstKeyword = 65,
LastKeyword = 124,
FirstFutureReservedWord = 102,
LastFutureReservedWord = 110,
FirstTypeNode = 139,
LastTypeNode = 147,
AtToken = 52,
EqualsToken = 53,
PlusEqualsToken = 54,
MinusEqualsToken = 55,
AsteriskEqualsToken = 56,
SlashEqualsToken = 57,
PercentEqualsToken = 58,
LessThanLessThanEqualsToken = 59,
GreaterThanGreaterThanEqualsToken = 60,
GreaterThanGreaterThanGreaterThanEqualsToken = 61,
AmpersandEqualsToken = 62,
BarEqualsToken = 63,
CaretEqualsToken = 64,
Identifier = 65,
BreakKeyword = 66,
CaseKeyword = 67,
CatchKeyword = 68,
ClassKeyword = 69,
ConstKeyword = 70,
ContinueKeyword = 71,
DebuggerKeyword = 72,
DefaultKeyword = 73,
DeleteKeyword = 74,
DoKeyword = 75,
ElseKeyword = 76,
EnumKeyword = 77,
ExportKeyword = 78,
ExtendsKeyword = 79,
FalseKeyword = 80,
FinallyKeyword = 81,
ForKeyword = 82,
FunctionKeyword = 83,
IfKeyword = 84,
ImportKeyword = 85,
InKeyword = 86,
InstanceOfKeyword = 87,
NewKeyword = 88,
NullKeyword = 89,
ReturnKeyword = 90,
SuperKeyword = 91,
SwitchKeyword = 92,
ThisKeyword = 93,
ThrowKeyword = 94,
TrueKeyword = 95,
TryKeyword = 96,
TypeOfKeyword = 97,
VarKeyword = 98,
VoidKeyword = 99,
WhileKeyword = 100,
WithKeyword = 101,
AsKeyword = 102,
ImplementsKeyword = 103,
InterfaceKeyword = 104,
LetKeyword = 105,
PackageKeyword = 106,
PrivateKeyword = 107,
ProtectedKeyword = 108,
PublicKeyword = 109,
StaticKeyword = 110,
YieldKeyword = 111,
AnyKeyword = 112,
BooleanKeyword = 113,
ConstructorKeyword = 114,
DeclareKeyword = 115,
GetKeyword = 116,
ModuleKeyword = 117,
RequireKeyword = 118,
NumberKeyword = 119,
SetKeyword = 120,
StringKeyword = 121,
SymbolKeyword = 122,
TypeKeyword = 123,
FromKeyword = 124,
OfKeyword = 125,
QualifiedName = 126,
ComputedPropertyName = 127,
TypeParameter = 128,
Parameter = 129,
Decorator = 130,
PropertySignature = 131,
PropertyDeclaration = 132,
MethodSignature = 133,
MethodDeclaration = 134,
Constructor = 135,
GetAccessor = 136,
SetAccessor = 137,
CallSignature = 138,
ConstructSignature = 139,
IndexSignature = 140,
TypeReference = 141,
FunctionType = 142,
ConstructorType = 143,
TypeQuery = 144,
TypeLiteral = 145,
ArrayType = 146,
TupleType = 147,
UnionType = 148,
ParenthesizedType = 149,
ObjectBindingPattern = 150,
ArrayBindingPattern = 151,
BindingElement = 152,
ArrayLiteralExpression = 153,
ObjectLiteralExpression = 154,
PropertyAccessExpression = 155,
ElementAccessExpression = 156,
CallExpression = 157,
NewExpression = 158,
TaggedTemplateExpression = 159,
TypeAssertionExpression = 160,
ParenthesizedExpression = 161,
FunctionExpression = 162,
ArrowFunction = 163,
DeleteExpression = 164,
TypeOfExpression = 165,
VoidExpression = 166,
PrefixUnaryExpression = 167,
PostfixUnaryExpression = 168,
BinaryExpression = 169,
ConditionalExpression = 170,
TemplateExpression = 171,
YieldExpression = 172,
SpreadElementExpression = 173,
OmittedExpression = 174,
TemplateSpan = 175,
Block = 176,
VariableStatement = 177,
EmptyStatement = 178,
ExpressionStatement = 179,
IfStatement = 180,
DoStatement = 181,
WhileStatement = 182,
ForStatement = 183,
ForInStatement = 184,
ForOfStatement = 185,
ContinueStatement = 186,
BreakStatement = 187,
ReturnStatement = 188,
WithStatement = 189,
SwitchStatement = 190,
LabeledStatement = 191,
ThrowStatement = 192,
TryStatement = 193,
DebuggerStatement = 194,
VariableDeclaration = 195,
VariableDeclarationList = 196,
FunctionDeclaration = 197,
ClassDeclaration = 198,
InterfaceDeclaration = 199,
TypeAliasDeclaration = 200,
EnumDeclaration = 201,
ModuleDeclaration = 202,
ModuleBlock = 203,
CaseBlock = 204,
ImportEqualsDeclaration = 205,
ImportDeclaration = 206,
ImportClause = 207,
NamespaceImport = 208,
NamedImports = 209,
ImportSpecifier = 210,
ExportAssignment = 211,
ExportDeclaration = 212,
NamedExports = 213,
ExportSpecifier = 214,
MissingDeclaration = 215,
ExternalModuleReference = 216,
CaseClause = 217,
DefaultClause = 218,
HeritageClause = 219,
CatchClause = 220,
PropertyAssignment = 221,
ShorthandPropertyAssignment = 222,
EnumMember = 223,
SourceFile = 224,
SyntaxList = 225,
Count = 226,
FirstAssignment = 53,
LastAssignment = 64,
FirstReservedWord = 66,
LastReservedWord = 101,
FirstKeyword = 66,
LastKeyword = 125,
FirstFutureReservedWord = 103,
LastFutureReservedWord = 111,
FirstTypeNode = 141,
LastTypeNode = 149,
FirstPunctuation = 14,
LastPunctuation = 63,
LastPunctuation = 64,
FirstToken = 0,
LastToken = 124,
LastToken = 125,
FirstTriviaToken = 2,
LastTriviaToken = 6,
FirstLiteralToken = 7,
@ -267,8 +270,8 @@ declare module "typescript" {
FirstTemplateToken = 10,
LastTemplateToken = 13,
FirstBinaryOperator = 24,
LastBinaryOperator = 63,
FirstNode = 125,
LastBinaryOperator = 64,
FirstNode = 126,
}
const enum NodeFlags {
Export = 1,
@ -284,6 +287,7 @@ declare module "typescript" {
Let = 4096,
Const = 8192,
OctalLiteral = 16384,
ExportContext = 32768,
Modifier = 499,
AccessibilityModifier = 112,
BlockScoped = 12288,
@ -293,10 +297,11 @@ declare module "typescript" {
DisallowIn = 2,
Yield = 4,
GeneratorParameter = 8,
ThisNodeHasError = 16,
ParserGeneratedFlags = 31,
ThisNodeOrAnySubNodesHasError = 32,
HasAggregatedChildData = 64,
Decorator = 16,
ThisNodeHasError = 32,
ParserGeneratedFlags = 63,
ThisNodeOrAnySubNodesHasError = 64,
HasAggregatedChildData = 128,
}
const enum RelationComparisonResult {
Succeeded = 1,
@ -307,6 +312,7 @@ declare module "typescript" {
kind: SyntaxKind;
flags: NodeFlags;
parserContextFlags?: ParserContextFlags;
decorators?: NodeArray<Decorator>;
modifiers?: ModifiersArray;
id?: number;
parent?: Node;
@ -337,6 +343,9 @@ declare module "typescript" {
interface ComputedPropertyName extends Node {
expression: Expression;
}
interface Decorator extends Node {
expression: LeftHandSideExpression;
}
interface TypeParameterDeclaration extends Declaration {
name: Identifier;
constraint?: TypeNode;
@ -516,6 +525,9 @@ declare module "typescript" {
name?: Identifier;
body: Block | Expression;
}
interface ArrowFunction extends Expression, FunctionLikeDeclaration {
equalsGreaterThanToken: Node;
}
interface LiteralExpression extends PrimaryExpression {
text: string;
isUnterminated?: boolean;
@ -725,7 +737,8 @@ declare module "typescript" {
type ExportSpecifier = ImportOrExportSpecifier;
interface ExportAssignment extends Declaration, ModuleElement {
isExportEquals?: boolean;
expression: Expression;
expression?: Expression;
type?: TypeNode;
}
interface FileReference extends TextRange {
fileName: string;
@ -760,14 +773,14 @@ declare module "typescript" {
interface Program extends ScriptReferenceHost {
getSourceFiles(): SourceFile[];
/**
* Emits the javascript and declaration files. If targetSourceFile is not specified, then
* the javascript and declaration files will be produced for all the files in this program.
* If targetSourceFile is specified, then only the javascript and declaration for that
* Emits the JavaScript and declaration files. If targetSourceFile is not specified, then
* the JavaScript and declaration files will be produced for all the files in this program.
* If targetSourceFile is specified, then only the JavaScript and declaration for that
* specific file will be generated.
*
* If writeFile is not specified then the writeFile callback from the compiler host will be
* used for writing the javascript and declaration files. Otherwise, the writeFile parameter
* will be invoked when writing the javascript and declaration files.
* used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter
* will be invoked when writing the JavaScript and declaration files.
*/
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
@ -886,9 +899,10 @@ declare module "typescript" {
NotAccessible = 1,
CannotBeNamed = 2,
}
type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration;
interface SymbolVisibilityResult {
accessibility: SymbolAccessibility;
aliasesToMakeVisible?: ImportEqualsDeclaration[];
aliasesToMakeVisible?: AnyImportSyntax[];
errorSymbolName?: string;
errorNode?: Node;
}
@ -896,20 +910,22 @@ declare module "typescript" {
errorModuleName?: string;
}
interface EmitResolver {
getGeneratedNameForNode(node: Node): string;
getExpressionNameSubstitution(node: Identifier): string;
hasExportDefaultValue(node: SourceFile): boolean;
isReferencedAliasDeclaration(node: Node): boolean;
hasGlobalName(name: string): boolean;
getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string;
isValueAliasDeclaration(node: Node): boolean;
isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean;
isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean;
getNodeCheckFlags(node: Node): NodeCheckFlags;
isDeclarationVisible(node: Declaration): boolean;
collectLinkedAliases(node: Identifier): Node[];
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult;
isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult;
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
isUnknownIdentifier(location: Node, name: string): boolean;
resolvesToSomeValue(location: Node, name: string): boolean;
getBlockScopedVariableId(node: Identifier): number;
}
const enum SymbolFlags {
@ -1016,6 +1032,7 @@ declare module "typescript" {
ContextChecked = 64,
EnumValuesComputed = 128,
BlockScopedBindingInLoop = 256,
EmitDecorate = 512,
}
interface NodeLinks {
resolvedType?: Type;
@ -1135,17 +1152,6 @@ declare module "typescript" {
interface TypeMapper {
(t: Type): Type;
}
interface TypeInferences {
primary: Type[];
secondary: Type[];
}
interface InferenceContext {
typeParameters: TypeParameter[];
inferUnionTypes: boolean;
inferences: TypeInferences[];
inferredTypes: Type[];
failedTypeParameterIndex?: number;
}
interface DiagnosticMessage {
key: string;
category: DiagnosticCategory;
@ -1442,7 +1448,8 @@ declare module "typescript" {
declare module "typescript" {
/** The version of the TypeScript compiler release */
let version: string;
function createCompilerHost(options: CompilerOptions): CompilerHost;
function findConfigFile(searchPath: string): string;
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
function getPreEmitDiagnostics(program: Program): Diagnostic[];
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
@ -1556,6 +1563,7 @@ declare module "typescript" {
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
findReferences(fileName: string, position: number): ReferencedSymbol[];
getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
getNavigationBarItems(fileName: string): NavigationBarItem[];
getOutliningSpans(fileName: string): OutliningSpan[];
@ -1642,6 +1650,10 @@ declare module "typescript" {
containerKind: string;
containerName: string;
}
interface ReferencedSymbol {
definition: DefinitionInfo;
references: ReferenceEntry[];
}
enum SymbolDisplayPartKind {
aliasName = 0,
className = 1,

File diff suppressed because it is too large Load diff

View file

@ -74,192 +74,195 @@ declare module ts {
BarBarToken = 49,
QuestionToken = 50,
ColonToken = 51,
EqualsToken = 52,
PlusEqualsToken = 53,
MinusEqualsToken = 54,
AsteriskEqualsToken = 55,
SlashEqualsToken = 56,
PercentEqualsToken = 57,
LessThanLessThanEqualsToken = 58,
GreaterThanGreaterThanEqualsToken = 59,
GreaterThanGreaterThanGreaterThanEqualsToken = 60,
AmpersandEqualsToken = 61,
BarEqualsToken = 62,
CaretEqualsToken = 63,
Identifier = 64,
BreakKeyword = 65,
CaseKeyword = 66,
CatchKeyword = 67,
ClassKeyword = 68,
ConstKeyword = 69,
ContinueKeyword = 70,
DebuggerKeyword = 71,
DefaultKeyword = 72,
DeleteKeyword = 73,
DoKeyword = 74,
ElseKeyword = 75,
EnumKeyword = 76,
ExportKeyword = 77,
ExtendsKeyword = 78,
FalseKeyword = 79,
FinallyKeyword = 80,
ForKeyword = 81,
FunctionKeyword = 82,
IfKeyword = 83,
ImportKeyword = 84,
InKeyword = 85,
InstanceOfKeyword = 86,
NewKeyword = 87,
NullKeyword = 88,
ReturnKeyword = 89,
SuperKeyword = 90,
SwitchKeyword = 91,
ThisKeyword = 92,
ThrowKeyword = 93,
TrueKeyword = 94,
TryKeyword = 95,
TypeOfKeyword = 96,
VarKeyword = 97,
VoidKeyword = 98,
WhileKeyword = 99,
WithKeyword = 100,
AsKeyword = 101,
ImplementsKeyword = 102,
InterfaceKeyword = 103,
LetKeyword = 104,
PackageKeyword = 105,
PrivateKeyword = 106,
ProtectedKeyword = 107,
PublicKeyword = 108,
StaticKeyword = 109,
YieldKeyword = 110,
AnyKeyword = 111,
BooleanKeyword = 112,
ConstructorKeyword = 113,
DeclareKeyword = 114,
GetKeyword = 115,
ModuleKeyword = 116,
RequireKeyword = 117,
NumberKeyword = 118,
SetKeyword = 119,
StringKeyword = 120,
SymbolKeyword = 121,
TypeKeyword = 122,
FromKeyword = 123,
OfKeyword = 124,
QualifiedName = 125,
ComputedPropertyName = 126,
TypeParameter = 127,
Parameter = 128,
PropertySignature = 129,
PropertyDeclaration = 130,
MethodSignature = 131,
MethodDeclaration = 132,
Constructor = 133,
GetAccessor = 134,
SetAccessor = 135,
CallSignature = 136,
ConstructSignature = 137,
IndexSignature = 138,
TypeReference = 139,
FunctionType = 140,
ConstructorType = 141,
TypeQuery = 142,
TypeLiteral = 143,
ArrayType = 144,
TupleType = 145,
UnionType = 146,
ParenthesizedType = 147,
ObjectBindingPattern = 148,
ArrayBindingPattern = 149,
BindingElement = 150,
ArrayLiteralExpression = 151,
ObjectLiteralExpression = 152,
PropertyAccessExpression = 153,
ElementAccessExpression = 154,
CallExpression = 155,
NewExpression = 156,
TaggedTemplateExpression = 157,
TypeAssertionExpression = 158,
ParenthesizedExpression = 159,
FunctionExpression = 160,
ArrowFunction = 161,
DeleteExpression = 162,
TypeOfExpression = 163,
VoidExpression = 164,
PrefixUnaryExpression = 165,
PostfixUnaryExpression = 166,
BinaryExpression = 167,
ConditionalExpression = 168,
TemplateExpression = 169,
YieldExpression = 170,
SpreadElementExpression = 171,
OmittedExpression = 172,
TemplateSpan = 173,
Block = 174,
VariableStatement = 175,
EmptyStatement = 176,
ExpressionStatement = 177,
IfStatement = 178,
DoStatement = 179,
WhileStatement = 180,
ForStatement = 181,
ForInStatement = 182,
ForOfStatement = 183,
ContinueStatement = 184,
BreakStatement = 185,
ReturnStatement = 186,
WithStatement = 187,
SwitchStatement = 188,
LabeledStatement = 189,
ThrowStatement = 190,
TryStatement = 191,
DebuggerStatement = 192,
VariableDeclaration = 193,
VariableDeclarationList = 194,
FunctionDeclaration = 195,
ClassDeclaration = 196,
InterfaceDeclaration = 197,
TypeAliasDeclaration = 198,
EnumDeclaration = 199,
ModuleDeclaration = 200,
ModuleBlock = 201,
CaseBlock = 202,
ImportEqualsDeclaration = 203,
ImportDeclaration = 204,
ImportClause = 205,
NamespaceImport = 206,
NamedImports = 207,
ImportSpecifier = 208,
ExportAssignment = 209,
ExportDeclaration = 210,
NamedExports = 211,
ExportSpecifier = 212,
ExternalModuleReference = 213,
CaseClause = 214,
DefaultClause = 215,
HeritageClause = 216,
CatchClause = 217,
PropertyAssignment = 218,
ShorthandPropertyAssignment = 219,
EnumMember = 220,
SourceFile = 221,
SyntaxList = 222,
Count = 223,
FirstAssignment = 52,
LastAssignment = 63,
FirstReservedWord = 65,
LastReservedWord = 100,
FirstKeyword = 65,
LastKeyword = 124,
FirstFutureReservedWord = 102,
LastFutureReservedWord = 110,
FirstTypeNode = 139,
LastTypeNode = 147,
AtToken = 52,
EqualsToken = 53,
PlusEqualsToken = 54,
MinusEqualsToken = 55,
AsteriskEqualsToken = 56,
SlashEqualsToken = 57,
PercentEqualsToken = 58,
LessThanLessThanEqualsToken = 59,
GreaterThanGreaterThanEqualsToken = 60,
GreaterThanGreaterThanGreaterThanEqualsToken = 61,
AmpersandEqualsToken = 62,
BarEqualsToken = 63,
CaretEqualsToken = 64,
Identifier = 65,
BreakKeyword = 66,
CaseKeyword = 67,
CatchKeyword = 68,
ClassKeyword = 69,
ConstKeyword = 70,
ContinueKeyword = 71,
DebuggerKeyword = 72,
DefaultKeyword = 73,
DeleteKeyword = 74,
DoKeyword = 75,
ElseKeyword = 76,
EnumKeyword = 77,
ExportKeyword = 78,
ExtendsKeyword = 79,
FalseKeyword = 80,
FinallyKeyword = 81,
ForKeyword = 82,
FunctionKeyword = 83,
IfKeyword = 84,
ImportKeyword = 85,
InKeyword = 86,
InstanceOfKeyword = 87,
NewKeyword = 88,
NullKeyword = 89,
ReturnKeyword = 90,
SuperKeyword = 91,
SwitchKeyword = 92,
ThisKeyword = 93,
ThrowKeyword = 94,
TrueKeyword = 95,
TryKeyword = 96,
TypeOfKeyword = 97,
VarKeyword = 98,
VoidKeyword = 99,
WhileKeyword = 100,
WithKeyword = 101,
AsKeyword = 102,
ImplementsKeyword = 103,
InterfaceKeyword = 104,
LetKeyword = 105,
PackageKeyword = 106,
PrivateKeyword = 107,
ProtectedKeyword = 108,
PublicKeyword = 109,
StaticKeyword = 110,
YieldKeyword = 111,
AnyKeyword = 112,
BooleanKeyword = 113,
ConstructorKeyword = 114,
DeclareKeyword = 115,
GetKeyword = 116,
ModuleKeyword = 117,
RequireKeyword = 118,
NumberKeyword = 119,
SetKeyword = 120,
StringKeyword = 121,
SymbolKeyword = 122,
TypeKeyword = 123,
FromKeyword = 124,
OfKeyword = 125,
QualifiedName = 126,
ComputedPropertyName = 127,
TypeParameter = 128,
Parameter = 129,
Decorator = 130,
PropertySignature = 131,
PropertyDeclaration = 132,
MethodSignature = 133,
MethodDeclaration = 134,
Constructor = 135,
GetAccessor = 136,
SetAccessor = 137,
CallSignature = 138,
ConstructSignature = 139,
IndexSignature = 140,
TypeReference = 141,
FunctionType = 142,
ConstructorType = 143,
TypeQuery = 144,
TypeLiteral = 145,
ArrayType = 146,
TupleType = 147,
UnionType = 148,
ParenthesizedType = 149,
ObjectBindingPattern = 150,
ArrayBindingPattern = 151,
BindingElement = 152,
ArrayLiteralExpression = 153,
ObjectLiteralExpression = 154,
PropertyAccessExpression = 155,
ElementAccessExpression = 156,
CallExpression = 157,
NewExpression = 158,
TaggedTemplateExpression = 159,
TypeAssertionExpression = 160,
ParenthesizedExpression = 161,
FunctionExpression = 162,
ArrowFunction = 163,
DeleteExpression = 164,
TypeOfExpression = 165,
VoidExpression = 166,
PrefixUnaryExpression = 167,
PostfixUnaryExpression = 168,
BinaryExpression = 169,
ConditionalExpression = 170,
TemplateExpression = 171,
YieldExpression = 172,
SpreadElementExpression = 173,
OmittedExpression = 174,
TemplateSpan = 175,
Block = 176,
VariableStatement = 177,
EmptyStatement = 178,
ExpressionStatement = 179,
IfStatement = 180,
DoStatement = 181,
WhileStatement = 182,
ForStatement = 183,
ForInStatement = 184,
ForOfStatement = 185,
ContinueStatement = 186,
BreakStatement = 187,
ReturnStatement = 188,
WithStatement = 189,
SwitchStatement = 190,
LabeledStatement = 191,
ThrowStatement = 192,
TryStatement = 193,
DebuggerStatement = 194,
VariableDeclaration = 195,
VariableDeclarationList = 196,
FunctionDeclaration = 197,
ClassDeclaration = 198,
InterfaceDeclaration = 199,
TypeAliasDeclaration = 200,
EnumDeclaration = 201,
ModuleDeclaration = 202,
ModuleBlock = 203,
CaseBlock = 204,
ImportEqualsDeclaration = 205,
ImportDeclaration = 206,
ImportClause = 207,
NamespaceImport = 208,
NamedImports = 209,
ImportSpecifier = 210,
ExportAssignment = 211,
ExportDeclaration = 212,
NamedExports = 213,
ExportSpecifier = 214,
MissingDeclaration = 215,
ExternalModuleReference = 216,
CaseClause = 217,
DefaultClause = 218,
HeritageClause = 219,
CatchClause = 220,
PropertyAssignment = 221,
ShorthandPropertyAssignment = 222,
EnumMember = 223,
SourceFile = 224,
SyntaxList = 225,
Count = 226,
FirstAssignment = 53,
LastAssignment = 64,
FirstReservedWord = 66,
LastReservedWord = 101,
FirstKeyword = 66,
LastKeyword = 125,
FirstFutureReservedWord = 103,
LastFutureReservedWord = 111,
FirstTypeNode = 141,
LastTypeNode = 149,
FirstPunctuation = 14,
LastPunctuation = 63,
LastPunctuation = 64,
FirstToken = 0,
LastToken = 124,
LastToken = 125,
FirstTriviaToken = 2,
LastTriviaToken = 6,
FirstLiteralToken = 7,
@ -267,8 +270,8 @@ declare module ts {
FirstTemplateToken = 10,
LastTemplateToken = 13,
FirstBinaryOperator = 24,
LastBinaryOperator = 63,
FirstNode = 125,
LastBinaryOperator = 64,
FirstNode = 126,
}
const enum NodeFlags {
Export = 1,
@ -284,6 +287,7 @@ declare module ts {
Let = 4096,
Const = 8192,
OctalLiteral = 16384,
ExportContext = 32768,
Modifier = 499,
AccessibilityModifier = 112,
BlockScoped = 12288,
@ -293,10 +297,11 @@ declare module ts {
DisallowIn = 2,
Yield = 4,
GeneratorParameter = 8,
ThisNodeHasError = 16,
ParserGeneratedFlags = 31,
ThisNodeOrAnySubNodesHasError = 32,
HasAggregatedChildData = 64,
Decorator = 16,
ThisNodeHasError = 32,
ParserGeneratedFlags = 63,
ThisNodeOrAnySubNodesHasError = 64,
HasAggregatedChildData = 128,
}
const enum RelationComparisonResult {
Succeeded = 1,
@ -307,6 +312,7 @@ declare module ts {
kind: SyntaxKind;
flags: NodeFlags;
parserContextFlags?: ParserContextFlags;
decorators?: NodeArray<Decorator>;
modifiers?: ModifiersArray;
id?: number;
parent?: Node;
@ -337,6 +343,9 @@ declare module ts {
interface ComputedPropertyName extends Node {
expression: Expression;
}
interface Decorator extends Node {
expression: LeftHandSideExpression;
}
interface TypeParameterDeclaration extends Declaration {
name: Identifier;
constraint?: TypeNode;
@ -516,6 +525,9 @@ declare module ts {
name?: Identifier;
body: Block | Expression;
}
interface ArrowFunction extends Expression, FunctionLikeDeclaration {
equalsGreaterThanToken: Node;
}
interface LiteralExpression extends PrimaryExpression {
text: string;
isUnterminated?: boolean;
@ -725,7 +737,8 @@ declare module ts {
type ExportSpecifier = ImportOrExportSpecifier;
interface ExportAssignment extends Declaration, ModuleElement {
isExportEquals?: boolean;
expression: Expression;
expression?: Expression;
type?: TypeNode;
}
interface FileReference extends TextRange {
fileName: string;
@ -760,14 +773,14 @@ declare module ts {
interface Program extends ScriptReferenceHost {
getSourceFiles(): SourceFile[];
/**
* Emits the javascript and declaration files. If targetSourceFile is not specified, then
* the javascript and declaration files will be produced for all the files in this program.
* If targetSourceFile is specified, then only the javascript and declaration for that
* Emits the JavaScript and declaration files. If targetSourceFile is not specified, then
* the JavaScript and declaration files will be produced for all the files in this program.
* If targetSourceFile is specified, then only the JavaScript and declaration for that
* specific file will be generated.
*
* If writeFile is not specified then the writeFile callback from the compiler host will be
* used for writing the javascript and declaration files. Otherwise, the writeFile parameter
* will be invoked when writing the javascript and declaration files.
* used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter
* will be invoked when writing the JavaScript and declaration files.
*/
emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult;
getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[];
@ -886,9 +899,10 @@ declare module ts {
NotAccessible = 1,
CannotBeNamed = 2,
}
type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration;
interface SymbolVisibilityResult {
accessibility: SymbolAccessibility;
aliasesToMakeVisible?: ImportEqualsDeclaration[];
aliasesToMakeVisible?: AnyImportSyntax[];
errorSymbolName?: string;
errorNode?: Node;
}
@ -896,20 +910,22 @@ declare module ts {
errorModuleName?: string;
}
interface EmitResolver {
getGeneratedNameForNode(node: Node): string;
getExpressionNameSubstitution(node: Identifier): string;
hasExportDefaultValue(node: SourceFile): boolean;
isReferencedAliasDeclaration(node: Node): boolean;
hasGlobalName(name: string): boolean;
getExpressionNameSubstitution(node: Identifier, getGeneratedNameForNode: (node: Node) => string): string;
isValueAliasDeclaration(node: Node): boolean;
isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean;
isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean;
getNodeCheckFlags(node: Node): NodeCheckFlags;
isDeclarationVisible(node: Declaration): boolean;
collectLinkedAliases(node: Identifier): Node[];
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult;
isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult;
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
isUnknownIdentifier(location: Node, name: string): boolean;
resolvesToSomeValue(location: Node, name: string): boolean;
getBlockScopedVariableId(node: Identifier): number;
}
const enum SymbolFlags {
@ -1016,6 +1032,7 @@ declare module ts {
ContextChecked = 64,
EnumValuesComputed = 128,
BlockScopedBindingInLoop = 256,
EmitDecorate = 512,
}
interface NodeLinks {
resolvedType?: Type;
@ -1135,17 +1152,6 @@ declare module ts {
interface TypeMapper {
(t: Type): Type;
}
interface TypeInferences {
primary: Type[];
secondary: Type[];
}
interface InferenceContext {
typeParameters: TypeParameter[];
inferUnionTypes: boolean;
inferences: TypeInferences[];
inferredTypes: Type[];
failedTypeParameterIndex?: number;
}
interface DiagnosticMessage {
key: string;
category: DiagnosticCategory;
@ -1442,7 +1448,8 @@ declare module ts {
declare module ts {
/** The version of the TypeScript compiler release */
let version: string;
function createCompilerHost(options: CompilerOptions): CompilerHost;
function findConfigFile(searchPath: string): string;
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
function getPreEmitDiagnostics(program: Program): Diagnostic[];
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
@ -1556,6 +1563,7 @@ declare module ts {
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
findReferences(fileName: string, position: number): ReferencedSymbol[];
getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
getNavigationBarItems(fileName: string): NavigationBarItem[];
getOutliningSpans(fileName: string): OutliningSpan[];
@ -1642,6 +1650,10 @@ declare module ts {
containerKind: string;
containerName: string;
}
interface ReferencedSymbol {
definition: DefinitionInfo;
references: ReferenceEntry[];
}
enum SymbolDisplayPartKind {
aliasName = 0,
className = 1,

File diff suppressed because it is too large Load diff

View file

@ -41,6 +41,10 @@ declare module ts {
*/
function lastOrUndefined<T>(array: T[]): T;
function binarySearch(array: number[], value: number): number;
function reduceLeft<T>(array: T[], f: (a: T, x: T) => T): T;
function reduceLeft<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
function reduceRight<T>(array: T[], f: (a: T, x: T) => T): T;
function reduceRight<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
function hasProperty<T>(map: Map<T>, key: string): boolean;
function getProperty<T>(map: Map<T>, key: string): T;
function isEmpty<T>(map: Map<T>): boolean;
@ -49,7 +53,6 @@ declare module ts {
function forEachValue<T, U>(map: Map<T>, callback: (value: T) => U): U;
function forEachKey<T, U>(map: Map<T>, callback: (key: string) => U): U;
function lookUp<T>(map: Map<T>, key: string): T;
function mapToArray<T>(map: Map<T>): T[];
function copyMap<T>(source: Map<T>, target: Map<T>): void;
/**
* Creates a map from the elements of an array.
@ -184,7 +187,7 @@ declare module ts {
function isConst(node: Node): boolean;
function isLet(node: Node): boolean;
function isPrologueDirective(node: Node): boolean;
function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode?: SourceFile): CommentRange[];
function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode: SourceFile): CommentRange[];
function getJsDocComments(node: Node, sourceFileOfNode: SourceFile): CommentRange[];
let fullTripleSlashReferencePathRegEx: RegExp;
function forEachReturnStatement<T>(body: Block, visitor: (stmt: ReturnStatement) => T): T;
@ -195,6 +198,10 @@ declare module ts {
function getThisContainer(node: Node, includeArrowFunctions: boolean): Node;
function getSuperContainer(node: Node, includeFunctions: boolean): Node;
function getInvokedExpression(node: CallLikeExpression): Expression;
function nodeCanBeDecorated(node: Node): boolean;
function nodeIsDecorated(node: Node): boolean;
function childIsDecorated(node: Node): boolean;
function nodeOrChildIsDecorated(node: Node): boolean;
function isExpression(node: Node): boolean;
function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean): boolean;
function isExternalModuleImportEqualsDeclaration(node: Node): boolean;
@ -211,7 +218,9 @@ declare module ts {
function isInAmbientContext(node: Node): boolean;
function isDeclaration(node: Node): boolean;
function isStatement(n: Node): boolean;
function isClassElement(n: Node): boolean;
function isDeclarationName(name: Node): boolean;
function isAliasSymbolDeclaration(node: Node): boolean;
function getClassBaseTypeNode(node: ClassDeclaration): TypeReferenceNode;
function getClassImplementedTypeNodes(node: ClassDeclaration): NodeArray<TypeReferenceNode>;
function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray<TypeReferenceNode>;
@ -270,7 +279,6 @@ declare module ts {
function nodeStartsNewLexicalEnvironment(n: Node): boolean;
function nodeIsSynthesized(node: Node): boolean;
function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node;
function generateUniqueName(baseName: string, isExistingName: (name: string) => boolean): string;
/**
* Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
* but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
@ -278,6 +286,38 @@ declare module ts {
*/
function escapeString(s: string): string;
function escapeNonAsciiCharacters(s: string): string;
interface EmitTextWriter {
write(s: string): void;
writeTextOfNode(sourceFile: SourceFile, node: Node): void;
writeLine(): void;
increaseIndent(): void;
decreaseIndent(): void;
getText(): string;
rawWrite(s: string): void;
writeLiteral(s: string): void;
getTextPos(): number;
getLine(): number;
getColumn(): number;
getIndent(): number;
}
function getIndentString(level: number): string;
function getIndentSize(): number;
function createTextWriter(newLine: String): EmitTextWriter;
function getOwnEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost, extension: string): string;
function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string): string;
function writeFile(host: EmitHost, diagnostics: Diagnostic[], fileName: string, data: string, writeByteOrderMark: boolean): void;
function getLineOfLocalPosition(currentSourceFile: SourceFile, pos: number): number;
function getFirstConstructorWithBody(node: ClassDeclaration): ConstructorDeclaration;
function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean;
function getAllAccessorDeclarations(declarations: NodeArray<Declaration>, accessor: AccessorDeclaration): {
firstAccessor: AccessorDeclaration;
secondAccessor: AccessorDeclaration;
getAccessor: AccessorDeclaration;
setAccessor: AccessorDeclaration;
};
function emitNewLineBeforeLeadingComments(currentSourceFile: SourceFile, writer: EmitTextWriter, node: TextRange, leadingComments: CommentRange[]): void;
function emitComments(currentSourceFile: SourceFile, writer: EmitTextWriter, comments: CommentRange[], trailingSeparator: boolean, newLine: string, writeComment: (currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string) => void): void;
function writeCommentRange(currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string): void;
}
declare module ts {
var optionDeclarations: CommandLineOption[];
@ -297,7 +337,10 @@ declare module ts {
function rangeContainsStartEnd(range: TextRange, start: number, end: number): boolean;
function rangeOverlapsWithStartEnd(r1: TextRange, start: number, end: number): boolean;
function startEndOverlapsWithStartEnd(start1: number, end1: number, start2: number, end2: number): boolean;
function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean;
function isCompletedNode(n: Node, sourceFile: SourceFile): boolean;
function findListItemInfo(node: Node): ListItemInfo;
function hasChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): boolean;
function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node;
function findContainingList(node: Node): Node;
function getTouchingWord(sourceFile: SourceFile, position: number): Node;
@ -320,9 +363,11 @@ declare module ts {
function getNodeModifiers(node: Node): string;
function getTypeArgumentOrTypeParameterList(node: Node): NodeArray<Node>;
function isToken(n: Node): boolean;
function isWord(kind: SyntaxKind): boolean;
function isComment(kind: SyntaxKind): boolean;
function isPunctuation(kind: SyntaxKind): boolean;
function isInsideTemplateLiteral(node: LiteralExpression, position: number): boolean;
function isAccessibilityModifier(kind: SyntaxKind): boolean;
function compareDataObjects(dst: any, src: any): boolean;
}
declare module ts {
@ -333,6 +378,7 @@ declare module ts {
function keywordPart(kind: SyntaxKind): SymbolDisplayPart;
function punctuationPart(kind: SyntaxKind): SymbolDisplayPart;
function operatorPart(kind: SyntaxKind): SymbolDisplayPart;
function textOrKeywordPart(text: string): SymbolDisplayPart;
function textPart(text: string): SymbolDisplayPart;
function lineBreakPart(): SymbolDisplayPart;
function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[];

View file

@ -41,6 +41,10 @@ declare module "typescript" {
*/
function lastOrUndefined<T>(array: T[]): T;
function binarySearch(array: number[], value: number): number;
function reduceLeft<T>(array: T[], f: (a: T, x: T) => T): T;
function reduceLeft<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
function reduceRight<T>(array: T[], f: (a: T, x: T) => T): T;
function reduceRight<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
function hasProperty<T>(map: Map<T>, key: string): boolean;
function getProperty<T>(map: Map<T>, key: string): T;
function isEmpty<T>(map: Map<T>): boolean;
@ -49,7 +53,6 @@ declare module "typescript" {
function forEachValue<T, U>(map: Map<T>, callback: (value: T) => U): U;
function forEachKey<T, U>(map: Map<T>, callback: (key: string) => U): U;
function lookUp<T>(map: Map<T>, key: string): T;
function mapToArray<T>(map: Map<T>): T[];
function copyMap<T>(source: Map<T>, target: Map<T>): void;
/**
* Creates a map from the elements of an array.
@ -184,7 +187,7 @@ declare module "typescript" {
function isConst(node: Node): boolean;
function isLet(node: Node): boolean;
function isPrologueDirective(node: Node): boolean;
function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode?: SourceFile): CommentRange[];
function getLeadingCommentRangesOfNode(node: Node, sourceFileOfNode: SourceFile): CommentRange[];
function getJsDocComments(node: Node, sourceFileOfNode: SourceFile): CommentRange[];
let fullTripleSlashReferencePathRegEx: RegExp;
function forEachReturnStatement<T>(body: Block, visitor: (stmt: ReturnStatement) => T): T;
@ -195,6 +198,10 @@ declare module "typescript" {
function getThisContainer(node: Node, includeArrowFunctions: boolean): Node;
function getSuperContainer(node: Node, includeFunctions: boolean): Node;
function getInvokedExpression(node: CallLikeExpression): Expression;
function nodeCanBeDecorated(node: Node): boolean;
function nodeIsDecorated(node: Node): boolean;
function childIsDecorated(node: Node): boolean;
function nodeOrChildIsDecorated(node: Node): boolean;
function isExpression(node: Node): boolean;
function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean): boolean;
function isExternalModuleImportEqualsDeclaration(node: Node): boolean;
@ -211,7 +218,9 @@ declare module "typescript" {
function isInAmbientContext(node: Node): boolean;
function isDeclaration(node: Node): boolean;
function isStatement(n: Node): boolean;
function isClassElement(n: Node): boolean;
function isDeclarationName(name: Node): boolean;
function isAliasSymbolDeclaration(node: Node): boolean;
function getClassBaseTypeNode(node: ClassDeclaration): TypeReferenceNode;
function getClassImplementedTypeNodes(node: ClassDeclaration): NodeArray<TypeReferenceNode>;
function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray<TypeReferenceNode>;
@ -270,7 +279,6 @@ declare module "typescript" {
function nodeStartsNewLexicalEnvironment(n: Node): boolean;
function nodeIsSynthesized(node: Node): boolean;
function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node;
function generateUniqueName(baseName: string, isExistingName: (name: string) => boolean): string;
/**
* Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2),
* but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine)
@ -278,6 +286,38 @@ declare module "typescript" {
*/
function escapeString(s: string): string;
function escapeNonAsciiCharacters(s: string): string;
interface EmitTextWriter {
write(s: string): void;
writeTextOfNode(sourceFile: SourceFile, node: Node): void;
writeLine(): void;
increaseIndent(): void;
decreaseIndent(): void;
getText(): string;
rawWrite(s: string): void;
writeLiteral(s: string): void;
getTextPos(): number;
getLine(): number;
getColumn(): number;
getIndent(): number;
}
function getIndentString(level: number): string;
function getIndentSize(): number;
function createTextWriter(newLine: String): EmitTextWriter;
function getOwnEmitOutputFilePath(sourceFile: SourceFile, host: EmitHost, extension: string): string;
function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string): string;
function writeFile(host: EmitHost, diagnostics: Diagnostic[], fileName: string, data: string, writeByteOrderMark: boolean): void;
function getLineOfLocalPosition(currentSourceFile: SourceFile, pos: number): number;
function getFirstConstructorWithBody(node: ClassDeclaration): ConstructorDeclaration;
function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean;
function getAllAccessorDeclarations(declarations: NodeArray<Declaration>, accessor: AccessorDeclaration): {
firstAccessor: AccessorDeclaration;
secondAccessor: AccessorDeclaration;
getAccessor: AccessorDeclaration;
setAccessor: AccessorDeclaration;
};
function emitNewLineBeforeLeadingComments(currentSourceFile: SourceFile, writer: EmitTextWriter, node: TextRange, leadingComments: CommentRange[]): void;
function emitComments(currentSourceFile: SourceFile, writer: EmitTextWriter, comments: CommentRange[], trailingSeparator: boolean, newLine: string, writeComment: (currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string) => void): void;
function writeCommentRange(currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string): void;
}
declare module "typescript" {
var optionDeclarations: CommandLineOption[];
@ -297,7 +337,10 @@ declare module "typescript" {
function rangeContainsStartEnd(range: TextRange, start: number, end: number): boolean;
function rangeOverlapsWithStartEnd(r1: TextRange, start: number, end: number): boolean;
function startEndOverlapsWithStartEnd(start1: number, end1: number, start2: number, end2: number): boolean;
function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean;
function isCompletedNode(n: Node, sourceFile: SourceFile): boolean;
function findListItemInfo(node: Node): ListItemInfo;
function hasChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): boolean;
function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node;
function findContainingList(node: Node): Node;
function getTouchingWord(sourceFile: SourceFile, position: number): Node;
@ -320,9 +363,11 @@ declare module "typescript" {
function getNodeModifiers(node: Node): string;
function getTypeArgumentOrTypeParameterList(node: Node): NodeArray<Node>;
function isToken(n: Node): boolean;
function isWord(kind: SyntaxKind): boolean;
function isComment(kind: SyntaxKind): boolean;
function isPunctuation(kind: SyntaxKind): boolean;
function isInsideTemplateLiteral(node: LiteralExpression, position: number): boolean;
function isAccessibilityModifier(kind: SyntaxKind): boolean;
function compareDataObjects(dst: any, src: any): boolean;
}
declare module "typescript" {
@ -333,6 +378,7 @@ declare module "typescript" {
function keywordPart(kind: SyntaxKind): SymbolDisplayPart;
function punctuationPart(kind: SyntaxKind): SymbolDisplayPart;
function operatorPart(kind: SyntaxKind): SymbolDisplayPart;
function textOrKeywordPart(text: string): SymbolDisplayPart;
function textPart(text: string): SymbolDisplayPart;
function lineBreakPart(): SymbolDisplayPart;
function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[];

View file

@ -12,12 +12,12 @@ module ts {
return isExternalModule(sourceFile) || isDeclarationFile(sourceFile);
}
// flag enum used to request and track usages of few dedicated temp variables
// enum values are used to set/check bit values and thus should not have bit collisions.
const enum TempVariableKind {
auto = 0,
_i = 1,
_n = 2,
// Flags enum to track count of temp variables and a few dedicated names
const enum TempFlags {
Auto = 0x00000000, // No preferred name
CountMask = 0x0FFFFFFF, // Temp variable counter
_i = 0x10000000, // Use/preference flag for '_i'
_n = 0x20000000, // Use/preference flag for '_n'
}
// @internal
@ -91,18 +91,17 @@ module ts {
let currentSourceFile: SourceFile;
let generatedNameSet: Map<string>;
let nodeToGeneratedName: string[];
let generatedNameSet: Map<string> = {};
let nodeToGeneratedName: string[] = [];
let blockScopedVariableToGeneratedName: string[];
let computedPropertyNamesToGeneratedNames: string[];
let extendsEmitted = false;
let decorateEmitted = false;
let tempCount = 0;
let tempFlags = 0;
let tempVariables: Identifier[];
let tempParameters: Identifier[];
let externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[];
let predefinedTempsInUse = TempVariableKind.auto;
let exportSpecifiers: Map<ExportSpecifier[]>;
let exportEquals: ExportAssignment;
let hasExportStars: boolean;
@ -167,6 +166,98 @@ module ts {
emit(sourceFile);
}
function isUniqueName(name: string): boolean {
return !resolver.hasGlobalName(name) &&
!hasProperty(currentSourceFile.identifiers, name) &&
!hasProperty(generatedNameSet, name);
}
// Return the next available name in the pattern _a ... _z, _0, _1, ...
// TempFlags._i or TempFlags._n may be used to express a preference for that dedicated name.
// Note that names generated by makeTempVariableName and makeUniqueName will never conflict.
function makeTempVariableName(flags: TempFlags): string {
if (flags && !(tempFlags & flags)) {
var name = flags === TempFlags._i ? "_i" : "_n"
if (isUniqueName(name)) {
tempFlags |= flags;
return name;
}
}
while (true) {
let count = tempFlags & TempFlags.CountMask;
tempFlags++;
// Skip over 'i' and 'n'
if (count !== 8 && count !== 13) {
let name = count < 26 ? "_" + String.fromCharCode(CharacterCodes.a + count) : "_" + (count - 26);
if (isUniqueName(name)) {
return name;
}
}
}
}
// Generate a name that is unique within the current file and doesn't conflict with any names
// in global scope. The name is formed by adding an '_n' suffix to the specified base name,
// where n is a positive integer. Note that names generated by makeTempVariableName and
// makeUniqueName are guaranteed to never conflict.
function makeUniqueName(baseName: string): string {
// Find the first unique 'name_n', where n is a positive number
if (baseName.charCodeAt(baseName.length - 1) !== CharacterCodes._) {
baseName += "_";
}
let i = 1;
while (true) {
let generatedName = baseName + i;
if (isUniqueName(generatedName)) {
return generatedNameSet[generatedName] = generatedName;
}
i++;
}
}
function assignGeneratedName(node: Node, name: string) {
nodeToGeneratedName[getNodeId(node)] = unescapeIdentifier(name);
}
function generateNameForFunctionOrClassDeclaration(node: Declaration) {
if (!node.name) {
assignGeneratedName(node, makeUniqueName("default"));
}
}
function generateNameForModuleOrEnum(node: ModuleDeclaration | EnumDeclaration) {
if (node.name.kind === SyntaxKind.Identifier) {
let name = node.name.text;
// Use module/enum name itself if it is unique, otherwise make a unique variation
assignGeneratedName(node, isUniqueLocalName(name, node) ? name : makeUniqueName(name));
}
}
function generateNameForImportOrExportDeclaration(node: ImportDeclaration | ExportDeclaration) {
let expr = getExternalModuleName(node);
let baseName = expr.kind === SyntaxKind.StringLiteral ?
escapeIdentifier(makeIdentifierFromModuleName((<LiteralExpression>expr).text)) : "module";
assignGeneratedName(node, makeUniqueName(baseName));
}
function generateNameForImportDeclaration(node: ImportDeclaration) {
if (node.importClause) {
generateNameForImportOrExportDeclaration(node);
}
}
function generateNameForExportDeclaration(node: ExportDeclaration) {
if (node.moduleSpecifier) {
generateNameForImportOrExportDeclaration(node);
}
}
function generateNameForExportAssignment(node: ExportAssignment) {
if (node.expression && node.expression.kind !== SyntaxKind.Identifier) {
assignGeneratedName(node, makeUniqueName("default"));
}
}
function generateNameForNode(node: Node) {
switch (node.kind) {
case SyntaxKind.FunctionDeclaration:
@ -189,175 +280,15 @@ module ts {
case SyntaxKind.ExportAssignment:
generateNameForExportAssignment(<ExportAssignment>node);
break;
case SyntaxKind.SourceFile:
case SyntaxKind.ModuleBlock:
forEach((<SourceFile | ModuleBlock>node).statements, generateNameForNode);
break;
}
}
function isUniqueName(name: string): boolean {
return !resolver.hasGlobalName(name) &&
!hasProperty(currentSourceFile.identifiers, name) &&
(!generatedNameSet || !hasProperty(generatedNameSet, name))
}
// in cases like
// for (var x of []) {
// _i;
// }
// we should be able to detect if let _i was shadowed by some temp variable that was allocated in scope
function nameConflictsWithSomeTempVariable(name: string): boolean {
// temp variable names always start with '_'
if (name.length < 2 || name.charCodeAt(0) !== CharacterCodes._) {
return false;
}
if (name === "_i") {
return !!(predefinedTempsInUse & TempVariableKind._i);
}
if (name === "_n") {
return !!(predefinedTempsInUse & TempVariableKind._n);
}
if (name.length === 2 && name.charCodeAt(1) >= CharacterCodes.a && name.charCodeAt(1) <= CharacterCodes.z) {
// handles _a .. _z
let n = name.charCodeAt(1) - CharacterCodes.a;
return n < tempCount;
}
else {
// handles _1, _2...
let n = +name.substring(1);
return !isNaN(n) && n >= 0 && n < (tempCount - 26);
}
}
// This function generates a name using the following pattern:
// _a .. _h, _j ... _z, _0, _1, ...
// It is guaranteed that generated name will not shadow any existing user-defined names,
// however it can hide another name generated by this function higher in the scope.
// NOTE: names generated by 'makeTempVariableName' and 'makeUniqueName' will never conflict.
// see comment for 'makeTempVariableName' for more information.
function makeTempVariableName(location: Node, tempVariableKind: TempVariableKind): string {
let tempName: string;
if (tempVariableKind !== TempVariableKind.auto && !(predefinedTempsInUse & tempVariableKind)) {
tempName = tempVariableKind === TempVariableKind._i ? "_i" : "_n";
if (!resolver.resolvesToSomeValue(location, tempName)) {
predefinedTempsInUse |= tempVariableKind;
return tempName;
}
}
do {
// Note: we avoid generating _i and _n as those are common names we want in other places.
var char = CharacterCodes.a + tempCount;
if (char !== CharacterCodes.i && char !== CharacterCodes.n) {
if (tempCount < 26) {
tempName = "_" + String.fromCharCode(char);
}
else {
tempName = "_" + (tempCount - 26);
}
}
tempCount++;
}
while (resolver.resolvesToSomeValue(location, tempName));
return tempName;
}
// Generates a name that is unique within current file and does not collide with
// any names in global scope.
// NOTE: names generated by 'makeTempVariableName' and 'makeUniqueName' will never conflict
// because of the way how these names are generated
// - makeUniqueName builds a name by picking a base name (which should not be empty string)
// and appending suffix '_<number>'
// - makeTempVariableName creates a name using the following pattern:
// _a .. _h, _j ... _z, _0, _1, ...
// This means that names from 'makeTempVariableName' will have only one underscore at the beginning
// and names from 'makeUniqieName' will have at least one underscore in the middle
// so they will never collide.
function makeUniqueName(baseName: string): string {
Debug.assert(!!baseName);
// Find the first unique 'name_n', where n is a positive number
if (baseName.charCodeAt(baseName.length - 1) !== CharacterCodes._) {
baseName += "_";
}
let i = 1;
let generatedName: string;
while (true) {
generatedName = baseName + i;
if (isUniqueName(generatedName)) {
break;
}
i++;
}
if (!generatedNameSet) {
generatedNameSet = {};
}
return generatedNameSet[generatedName] = generatedName;
}
function renameNode(node: Node, name: string): string {
var nodeId = getNodeId(node);
if (!nodeToGeneratedName) {
nodeToGeneratedName = [];
}
return nodeToGeneratedName[nodeId] = unescapeIdentifier(name);
}
function generateNameForFunctionOrClassDeclaration(node: Declaration) {
if (!node.name) {
renameNode(node, makeUniqueName("default"));
}
}
function generateNameForModuleOrEnum(node: ModuleDeclaration | EnumDeclaration) {
if (node.name.kind === SyntaxKind.Identifier) {
let name = node.name.text;
// Use module/enum name itself if it is unique, otherwise make a unique variation
renameNode(node, isUniqueLocalName(name, node) ? name : makeUniqueName(name));
}
}
function generateNameForImportOrExportDeclaration(node: ImportDeclaration | ExportDeclaration) {
let expr = getExternalModuleName(node);
let baseName = expr.kind === SyntaxKind.StringLiteral ?
escapeIdentifier(makeIdentifierFromModuleName((<LiteralExpression>expr).text)) : "module";
renameNode(node, makeUniqueName(baseName));
}
function generateNameForImportDeclaration(node: ImportDeclaration) {
if (node.importClause) {
generateNameForImportOrExportDeclaration(node);
}
}
function generateNameForExportDeclaration(node: ExportDeclaration) {
if (node.moduleSpecifier) {
generateNameForImportOrExportDeclaration(node);
}
}
function generateNameForExportAssignment(node: ExportAssignment) {
if (node.expression && node.expression.kind !== SyntaxKind.Identifier) {
renameNode(node, makeUniqueName("default"));
}
}
function getGeneratedNameForNode(node: Node) {
let nodeId = getNodeId(node);
if (!nodeToGeneratedName || !nodeToGeneratedName[nodeId]) {
if (!nodeToGeneratedName[nodeId]) {
generateNameForNode(node);
}
return nodeToGeneratedName ? nodeToGeneratedName[nodeId] : undefined;
return nodeToGeneratedName[nodeId];
}
function initializeEmitterWithSourceMaps() {
@ -725,9 +656,9 @@ module ts {
}
// Create a temporary variable with a unique unused name.
function createTempVariable(location: Node, tempVariableKind = TempVariableKind.auto): Identifier {
function createTempVariable(flags: TempFlags): Identifier {
let result = <Identifier>createSynthesizedNode(SyntaxKind.Identifier);
result.text = makeTempVariableName(location, tempVariableKind);
result.text = makeTempVariableName(flags);
return result;
}
@ -738,8 +669,8 @@ module ts {
tempVariables.push(name);
}
function createAndRecordTempVariable(location: Node, tempVariableKind?: TempVariableKind): Identifier {
let temp = createTempVariable(location, tempVariableKind);
function createAndRecordTempVariable(flags: TempFlags): Identifier {
let temp = createTempVariable(flags);
recordTempDeclaration(temp);
return temp;
@ -981,7 +912,7 @@ module ts {
}
function emitDownlevelTaggedTemplate(node: TaggedTemplateExpression) {
let tempVariable = createAndRecordTempVariable(node);
let tempVariable = createAndRecordTempVariable(TempFlags.Auto);
write("(");
emit(tempVariable);
write(" = ");
@ -1177,7 +1108,7 @@ module ts {
return;
}
let generatedVariable = createTempVariable(node);
let generatedVariable = createTempVariable(TempFlags.Auto);
generatedName = generatedVariable.text;
recordTempDeclaration(generatedVariable);
computedPropertyNamesToGeneratedNames[node.id] = generatedName;
@ -1424,7 +1355,7 @@ module ts {
function createDownlevelObjectLiteralWithComputedProperties(originalObjectLiteral: ObjectLiteralExpression, firstComputedPropertyIndex: number): ParenthesizedExpression {
// For computed properties, we need to create a unique handle to the object
// literal so we can modify it without risking internal assignments tainting the object.
let tempVar = createAndRecordTempVariable(originalObjectLiteral);
let tempVar = createAndRecordTempVariable(TempFlags.Auto);
// Hold onto the initial non-computed properties in a new object literal,
// then create the rest through property accesses on the temp variable.
@ -1789,7 +1720,7 @@ module ts {
emit(node);
return node;
}
let temp = createAndRecordTempVariable(node);
let temp = createAndRecordTempVariable(TempFlags.Auto);
write("(");
emit(temp);
@ -2233,10 +2164,10 @@ module ts {
//
// we don't want to emit a temporary variable for the RHS, just use it directly.
let rhsIsIdentifier = node.expression.kind === SyntaxKind.Identifier;
let counter = createTempVariable(node, TempVariableKind._i);
let rhsReference = rhsIsIdentifier ? <Identifier>node.expression : createTempVariable(node);
let counter = createTempVariable(TempFlags._i);
let rhsReference = rhsIsIdentifier ? <Identifier>node.expression : createTempVariable(TempFlags.Auto);
var cachedLength = compilerOptions.cacheDownlevelForOfLength ? createTempVariable(node, TempVariableKind._n) : undefined;
var cachedLength = compilerOptions.cacheDownlevelForOfLength ? createTempVariable(TempFlags._n) : undefined;
// This is the let keyword for the counter and rhsReference. The let keyword for
// the LHS will be emitted inside the body.
@ -2321,7 +2252,7 @@ module ts {
else {
// It's an empty declaration list. This can only happen in an error case, if the user wrote
// for (let of []) {}
emitNodeWithoutSourceMap(createTempVariable(node));
emitNodeWithoutSourceMap(createTempVariable(TempFlags.Auto));
write(" = ");
emitNodeWithoutSourceMap(rhsIterationValue);
}
@ -2580,7 +2511,7 @@ module ts {
// In case the root is a synthesized node, we need to pass lowestNonSynthesizedAncestor
// as the location for determining uniqueness of the variable we are about to
// generate.
let identifier = createTempVariable(lowestNonSynthesizedAncestor || root);
let identifier = createTempVariable(TempFlags.Auto);
if (!isDeclaration) {
recordTempDeclaration(identifier);
}
@ -2859,11 +2790,7 @@ module ts {
? blockScopeContainer
: blockScopeContainer.parent;
var hasConflictsInEnclosingScope =
resolver.resolvesToSomeValue(parent, (<Identifier>node).text) ||
nameConflictsWithSomeTempVariable((<Identifier>node).text);
if (hasConflictsInEnclosingScope) {
if (resolver.resolvesToSomeValue(parent, (<Identifier>node).text)) {
let variableId = resolver.getBlockScopedVariableId(<Identifier>node);
if (!blockScopedVariableToGeneratedName) {
blockScopedVariableToGeneratedName = [];
@ -2899,7 +2826,7 @@ module ts {
function emitParameter(node: ParameterDeclaration) {
if (languageVersion < ScriptTarget.ES6) {
if (isBindingPattern(node.name)) {
let name = createTempVariable(node);
let name = createTempVariable(TempFlags.Auto);
if (!tempParameters) {
tempParameters = [];
}
@ -2953,7 +2880,7 @@ module ts {
if (languageVersion < ScriptTarget.ES6 && hasRestParameters(node)) {
let restIndex = node.parameters.length - 1;
let restParam = node.parameters[restIndex];
let tempName = createTempVariable(node, TempVariableKind._i).text;
let tempName = createTempVariable(TempFlags._i).text;
writeLine();
emitLeadingComments(restParam);
emitStart(restParam);
@ -3086,15 +3013,12 @@ module ts {
}
function emitSignatureAndBody(node: FunctionLikeDeclaration) {
let saveTempCount = tempCount;
let saveTempFlags = tempFlags;
let saveTempVariables = tempVariables;
let saveTempParameters = tempParameters;
let savePredefinedTempsInUse = predefinedTempsInUse;
tempCount = 0;
tempFlags = 0;
tempVariables = undefined;
tempParameters = undefined;
predefinedTempsInUse = TempVariableKind.auto;
// When targeting ES6, emit arrow function natively in ES6
if (shouldEmitAsArrowFunction(node)) {
@ -3121,8 +3045,7 @@ module ts {
emitExportMemberAssignment(node);
}
predefinedTempsInUse = savePredefinedTempsInUse;
tempCount = saveTempCount;
tempFlags = saveTempFlags;
tempVariables = saveTempVariables;
tempParameters = saveTempParameters;
}
@ -3409,14 +3332,12 @@ module ts {
}
function emitConstructor(node: ClassDeclaration, baseTypeNode: TypeReferenceNode) {
let saveTempCount = tempCount;
let saveTempFlags = tempFlags;
let saveTempVariables = tempVariables;
let saveTempParameters = tempParameters;
let savePredefinedTempsInUse = predefinedTempsInUse;
tempCount = 0;
tempFlags = 0;
tempVariables = undefined;
tempParameters = undefined;
predefinedTempsInUse = TempVariableKind.auto;
// Check if we have property assignment inside class declaration.
// If there is property assignment, we need to emit constructor whether users define it or not
@ -3526,8 +3447,7 @@ module ts {
emitTrailingComments(ctor);
}
predefinedTempsInUse = savePredefinedTempsInUse;
tempCount = saveTempCount;
tempFlags = saveTempFlags;
tempVariables = saveTempVariables;
tempParameters = saveTempParameters;
}
@ -3694,11 +3614,11 @@ module ts {
write("_super");
}
write(") {");
let saveTempCount = tempCount;
let saveTempFlags = tempFlags;
let saveTempVariables = tempVariables;
let saveTempParameters = tempParameters;
let saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames;
tempCount = 0;
tempFlags = 0;
tempVariables = undefined;
tempParameters = undefined;
computedPropertyNamesToGeneratedNames = undefined;
@ -3725,7 +3645,7 @@ module ts {
});
write(";");
emitTempDeclarations(/*newLine*/ true);
tempCount = saveTempCount;
tempFlags = saveTempFlags;
tempVariables = saveTempVariables;
tempParameters = saveTempParameters;
computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames;
@ -4088,17 +4008,14 @@ module ts {
emitEnd(node.name);
write(") ");
if (node.body.kind === SyntaxKind.ModuleBlock) {
let saveTempCount = tempCount;
let saveTempFlags = tempFlags;
let saveTempVariables = tempVariables;
let savePredefinedTempsInUse = predefinedTempsInUse;
tempCount = 0;
tempFlags = 0;
tempVariables = undefined;
predefinedTempsInUse = TempVariableKind.auto;
emit(node.body);
predefinedTempsInUse = savePredefinedTempsInUse;
tempCount = saveTempCount;
tempFlags = saveTempFlags;
tempVariables = saveTempVariables;
}
else {

View file

@ -276,6 +276,7 @@ module ts {
// If a source file changes, mark it as unwatched and start the recompilation timer
function sourceFileChanged(sourceFile: SourceFile) {
sourceFile.fileWatcher.close();
sourceFile.fileWatcher = undefined;
startTimer();
}

View file

@ -1699,6 +1699,14 @@ module Harness {
return (Path.getFileName(filePath) === 'lib.d.ts') || (Path.getFileName(filePath) === 'lib.core.d.ts');
}
export function getDefaultLibraryFile(): { unitName: string, content: string } {
var libFile = Harness.userSpecifiedroot + Harness.libFolder + "/" + "lib.d.ts";
return {
unitName: libFile,
content: IO.readFile(libFile)
}
}
if (Error) (<any>Error).stackTraceLimit = 1;
}

View file

@ -15,6 +15,7 @@ interface IOLog {
arguments: string[];
executingPath: string;
currentDirectory: string;
useCustomLibraryFile?: boolean;
filesRead: {
path: string;
codepage: number;

View file

@ -32,6 +32,7 @@ module RWC {
};
var baseName = /(.*)\/(.*).json/.exec(ts.normalizeSlashes(jsonPath))[2];
var currentDirectory: string;
var useCustomLibraryFile: boolean;
after(() => {
// Mocha holds onto the closure environment of the describe callback even after the test is done.
@ -43,6 +44,10 @@ module RWC {
baselineOpts = undefined;
baseName = undefined;
currentDirectory = undefined;
// useCustomLibraryFile is a flag specified in the json object to indicate whether to use built/local/lib.d.ts
// or to use lib.d.ts inside the json object. If the flag is true, use the lib.d.ts inside json file
// otherwise use the lib.d.ts from built/local
useCustomLibraryFile = undefined;
});
it('can compile', () => {
@ -51,34 +56,52 @@ module RWC {
var ioLog: IOLog = JSON.parse(Harness.IO.readFile(jsonPath));
currentDirectory = ioLog.currentDirectory;
useCustomLibraryFile = ioLog.useCustomLibraryFile;
runWithIOLog(ioLog, () => {
opts = ts.parseCommandLine(ioLog.arguments);
assert.equal(opts.errors.length, 0);
// To provide test coverage of output javascript file,
// we will set noEmitOnError flag to be false.
opts.options.noEmitOnError = false;
});
runWithIOLog(ioLog, () => {
harnessCompiler.reset();
// Load the files
ts.forEach(opts.fileNames, fileName => {
inputFiles.push(getHarnessCompilerInputUnit(fileName));
});
if (!opts.options.noLib) {
// Find the lib.d.ts file in the input file and add it to the input files list
var libFile = ts.forEach(ioLog.filesRead, fileRead=> Harness.isLibraryFile(fileRead.path) ? fileRead.path : undefined);
if (libFile) {
inputFiles.push(getHarnessCompilerInputUnit(libFile));
}
}
ts.forEach(ioLog.filesRead, fileRead => {
// Add files to compilation
for(let fileRead of ioLog.filesRead) {
// Check if the file is already added into the set of input files.
var resolvedPath = ts.normalizeSlashes(ts.sys.resolvePath(fileRead.path));
var inInputList = ts.forEach(inputFiles, inputFile=> inputFile.unitName === resolvedPath);
if (!inInputList) {
// Add the file to other files
var inInputList = ts.forEach(inputFiles, inputFile => inputFile.unitName === resolvedPath);
if (!Harness.isLibraryFile(fileRead.path)) {
if (inInputList) {
continue;
}
otherFiles.push(getHarnessCompilerInputUnit(fileRead.path));
}
});
else if (!opts.options.noLib && Harness.isLibraryFile(fileRead.path)){
if (!inInputList) {
// If useCustomLibraryFile is true, we will use lib.d.ts from json object
// otherwise use the lib.d.ts from built/local
// Majority of RWC code will be using built/local/lib.d.ts instead of
// lib.d.ts inside json file. However, some RWC cases will still use
// their own version of lib.d.ts because they have customized lib.d.ts
if (useCustomLibraryFile) {
inputFiles.push(getHarnessCompilerInputUnit(fileRead.path));
}
else {
inputFiles.push(Harness.getDefaultLibraryFile());
}
}
}
}
// do not use lib since we already read it in above
opts.options.noLib = true;
@ -115,9 +138,10 @@ module RWC {
it('has the expected declaration file content', () => {
Harness.Baseline.runBaseline('has the expected declaration file content', baseName + '.d.ts', () => {
if (compilerResult.errors.length || !compilerResult.declFilesCode.length) {
if (!compilerResult.declFilesCode.length) {
return null;
}
return Harness.Compiler.collateOutputs(compilerResult.declFilesCode);
}, false, baselineOpts);
});

View file

@ -764,6 +764,26 @@ module ts.server {
return info;
}
// This is different from the method the compiler uses because
// the compiler can assume it will always start searching in the
// current directory (the directory in which tsc was invoked).
// The server must start searching from the directory containing
// the newly opened file.
findConfigFile(searchPath: string): string {
while (true) {
var fileName = ts.combinePaths(searchPath, "tsconfig.json");
if (sys.fileExists(fileName)) {
return fileName;
}
var parentPath = ts.getDirectoryPath(searchPath);
if (parentPath === searchPath) {
break;
}
searchPath = parentPath;
}
return undefined;
}
/**
* Open file whose contents is managed by the client
* @param filename is absolute pathname
@ -771,7 +791,13 @@ module ts.server {
openClientFile(fileName: string) {
var searchPath = ts.normalizePath(getDirectoryPath(fileName));
var configFileName = ts.findConfigFile(searchPath);
this.log("Search path: " + searchPath,"Info");
var configFileName = this.findConfigFile(searchPath);
if (configFileName) {
this.log("Config file name: " + configFileName, "Info");
} else {
this.log("no config file");
}
if (configFileName) {
configFileName = getAbsolutePath(configFileName, searchPath);
}

View file

@ -4,9 +4,9 @@ for (let v of []) {
}
//// [ES5For-of21.js]
for (var _i = 0, _a = []; _i < _a.length; _i++) {
var v = _a[_i];
for (var _b = 0, _c = []; _b < _c.length; _b++) {
var _i_1 = _c[_b];
for (var _a = 0, _b = []; _a < _b.length; _a++) {
var v = _b[_a];
for (var _c = 0, _d = []; _c < _d.length; _c++) {
var _i = _d[_c];
}
}

View file

@ -5,8 +5,8 @@ for (var x of [1, 2, 3]) {
}
//// [ES5For-of22.js]
for (var _i = 0, _a = [1, 2, 3]; _i < _a.length; _i++) {
var x = _a[_i];
var _a_1 = 0;
for (var _i = 0, _b = [1, 2, 3]; _i < _b.length; _i++) {
var x = _b[_i];
var _a = 0;
console.log(x);
}