mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into emitArrowFunctionES6
This commit is contained in:
@@ -58,6 +58,7 @@ var servicesSources = [
|
||||
"checker.ts",
|
||||
"emitter.ts",
|
||||
"program.ts",
|
||||
"commandLineParser.ts",
|
||||
"diagnosticInformationMap.generated.ts"
|
||||
].map(function (f) {
|
||||
return path.join(compilerDirectory, f);
|
||||
@@ -102,6 +103,7 @@ var internalDefinitionsRoots = [
|
||||
"compiler/core.d.ts",
|
||||
"compiler/sys.d.ts",
|
||||
"compiler/utilities.d.ts",
|
||||
"compiler/commandLineParser.d.ts",
|
||||
"services/utilities.d.ts",
|
||||
];
|
||||
|
||||
@@ -192,7 +194,7 @@ var compilerFilename = "tsc.js";
|
||||
* @param keepComments: false to compile using --removeComments
|
||||
* @param callback: a function to execute after the compilation process ends
|
||||
*/
|
||||
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, keepComments, noResolve, callback) {
|
||||
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, callback) {
|
||||
file(outFile, prereqs, function() {
|
||||
var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory;
|
||||
var options = "--module commonjs -noImplicitAny";
|
||||
@@ -205,7 +207,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOu
|
||||
options += " --declaration";
|
||||
}
|
||||
|
||||
if (useDebugMode) {
|
||||
if (useDebugMode || preserveConstEnums) {
|
||||
options += " --preserveConstEnums";
|
||||
}
|
||||
|
||||
@@ -321,7 +323,15 @@ var tscFile = path.join(builtLocalDirectory, compilerFilename);
|
||||
compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false);
|
||||
|
||||
var servicesFile = path.join(builtLocalDirectory, "typescriptServices.js");
|
||||
compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources), [copyright], /*useBuiltCompiler*/ true);
|
||||
compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources),
|
||||
/*prefixes*/ [copyright],
|
||||
/*useBuiltCompiler*/ true,
|
||||
/*noOutFile*/ false,
|
||||
/*generateDeclarations*/ false,
|
||||
/*outDir*/ undefined,
|
||||
/*preserveConstEnums*/ true,
|
||||
/*keepComments*/ false,
|
||||
/*noResolve*/ false);
|
||||
|
||||
var nodeDefinitionsFile = path.join(builtLocalDirectory, "typescript.d.ts");
|
||||
var standaloneDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts");
|
||||
@@ -334,6 +344,7 @@ compileFile(nodeDefinitionsFile, servicesSources,[builtLocalDirectory, copyright
|
||||
/*noOutFile*/ true,
|
||||
/*generateDeclarations*/ true,
|
||||
/*outDir*/ tempDirPath,
|
||||
/*preserveConstEnums*/ true,
|
||||
/*keepComments*/ true,
|
||||
/*noResolve*/ true,
|
||||
/*callback*/ function () {
|
||||
|
||||
+5238
-4328
File diff suppressed because it is too large
Load Diff
Vendored
+72
-146
@@ -189,29 +189,29 @@ declare module "typescript" {
|
||||
ConditionalExpression = 164,
|
||||
TemplateExpression = 165,
|
||||
YieldExpression = 166,
|
||||
OmittedExpression = 167,
|
||||
TemplateSpan = 168,
|
||||
Block = 169,
|
||||
VariableStatement = 170,
|
||||
EmptyStatement = 171,
|
||||
ExpressionStatement = 172,
|
||||
IfStatement = 173,
|
||||
DoStatement = 174,
|
||||
WhileStatement = 175,
|
||||
ForStatement = 176,
|
||||
ForInStatement = 177,
|
||||
ContinueStatement = 178,
|
||||
BreakStatement = 179,
|
||||
ReturnStatement = 180,
|
||||
WithStatement = 181,
|
||||
SwitchStatement = 182,
|
||||
LabeledStatement = 183,
|
||||
ThrowStatement = 184,
|
||||
TryStatement = 185,
|
||||
TryBlock = 186,
|
||||
FinallyBlock = 187,
|
||||
DebuggerStatement = 188,
|
||||
VariableDeclaration = 189,
|
||||
SpreadElementExpression = 167,
|
||||
OmittedExpression = 168,
|
||||
TemplateSpan = 169,
|
||||
Block = 170,
|
||||
VariableStatement = 171,
|
||||
EmptyStatement = 172,
|
||||
ExpressionStatement = 173,
|
||||
IfStatement = 174,
|
||||
DoStatement = 175,
|
||||
WhileStatement = 176,
|
||||
ForStatement = 177,
|
||||
ForInStatement = 178,
|
||||
ContinueStatement = 179,
|
||||
BreakStatement = 180,
|
||||
ReturnStatement = 181,
|
||||
WithStatement = 182,
|
||||
SwitchStatement = 183,
|
||||
LabeledStatement = 184,
|
||||
ThrowStatement = 185,
|
||||
TryStatement = 186,
|
||||
DebuggerStatement = 187,
|
||||
VariableDeclaration = 188,
|
||||
VariableDeclarationList = 189,
|
||||
FunctionDeclaration = 190,
|
||||
ClassDeclaration = 191,
|
||||
InterfaceDeclaration = 192,
|
||||
@@ -230,9 +230,8 @@ declare module "typescript" {
|
||||
ShorthandPropertyAssignment = 205,
|
||||
EnumMember = 206,
|
||||
SourceFile = 207,
|
||||
Program = 208,
|
||||
SyntaxList = 209,
|
||||
Count = 210,
|
||||
SyntaxList = 208,
|
||||
Count = 209,
|
||||
FirstAssignment = 52,
|
||||
LastAssignment = 63,
|
||||
FirstReservedWord = 65,
|
||||
@@ -253,8 +252,6 @@ declare module "typescript" {
|
||||
LastLiteralToken = 10,
|
||||
FirstTemplateToken = 10,
|
||||
LastTemplateToken = 13,
|
||||
FirstOperator = 22,
|
||||
LastOperator = 63,
|
||||
FirstBinaryOperator = 24,
|
||||
LastBinaryOperator = 63,
|
||||
FirstNode = 121,
|
||||
@@ -331,10 +328,14 @@ declare module "typescript" {
|
||||
type?: TypeNode;
|
||||
}
|
||||
interface VariableDeclaration extends Declaration {
|
||||
parent?: VariableDeclarationList;
|
||||
name: Identifier | BindingPattern;
|
||||
type?: TypeNode;
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface VariableDeclarationList extends Node {
|
||||
declarations: NodeArray<VariableDeclaration>;
|
||||
}
|
||||
interface ParameterDeclaration extends Declaration {
|
||||
dotDotDotToken?: Node;
|
||||
name: Identifier | BindingPattern;
|
||||
@@ -514,6 +515,9 @@ declare module "typescript" {
|
||||
interface ArrayLiteralExpression extends PrimaryExpression {
|
||||
elements: NodeArray<Expression>;
|
||||
}
|
||||
interface SpreadElementExpression extends Expression {
|
||||
expression: Expression;
|
||||
}
|
||||
interface ObjectLiteralExpression extends PrimaryExpression, Declaration {
|
||||
properties: NodeArray<ObjectLiteralElement>;
|
||||
}
|
||||
@@ -548,7 +552,7 @@ declare module "typescript" {
|
||||
statements: NodeArray<Statement>;
|
||||
}
|
||||
interface VariableStatement extends Statement {
|
||||
declarations: NodeArray<VariableDeclaration>;
|
||||
declarationList: VariableDeclarationList;
|
||||
}
|
||||
interface ExpressionStatement extends Statement {
|
||||
expression: Expression;
|
||||
@@ -568,14 +572,12 @@ declare module "typescript" {
|
||||
expression: Expression;
|
||||
}
|
||||
interface ForStatement extends IterationStatement {
|
||||
declarations?: NodeArray<VariableDeclaration>;
|
||||
initializer?: Expression;
|
||||
initializer?: VariableDeclarationList | Expression;
|
||||
condition?: Expression;
|
||||
iterator?: Expression;
|
||||
}
|
||||
interface ForInStatement extends IterationStatement {
|
||||
declarations?: NodeArray<VariableDeclaration>;
|
||||
variable?: Expression;
|
||||
initializer: VariableDeclarationList | Expression;
|
||||
expression: Expression;
|
||||
}
|
||||
interface BreakOrContinueStatement extends Statement {
|
||||
@@ -682,12 +684,12 @@ declare module "typescript" {
|
||||
getLineAndCharacterFromPosition(position: number): LineAndCharacter;
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getLineStarts(): number[];
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
amdDependencies: string[];
|
||||
amdModuleName: string;
|
||||
referencedFiles: FileReference[];
|
||||
referenceDiagnostics: Diagnostic[];
|
||||
parseDiagnostics: Diagnostic[];
|
||||
grammarDiagnostics: Diagnostic[];
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
semanticDiagnostics: Diagnostic[];
|
||||
hasNoDefaultLib: boolean;
|
||||
@@ -698,15 +700,21 @@ declare module "typescript" {
|
||||
languageVersion: ScriptTarget;
|
||||
identifiers: Map<string>;
|
||||
}
|
||||
interface Program {
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
getSourceFiles(): SourceFile[];
|
||||
interface ScriptReferenceHost {
|
||||
getCompilerOptions(): CompilerOptions;
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
getCurrentDirectory(): string;
|
||||
}
|
||||
interface Program extends ScriptReferenceHost {
|
||||
getSourceFiles(): SourceFile[];
|
||||
getCompilerHost(): CompilerHost;
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getTypeChecker(fullTypeCheckMode: boolean): TypeChecker;
|
||||
getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
getTypeChecker(produceDiagnostics: boolean): TypeChecker;
|
||||
getCommonSourceDirectory(): string;
|
||||
emitFiles(targetSourceFile?: SourceFile): EmitResult;
|
||||
isEmitBlocked(sourceFile?: SourceFile): boolean;
|
||||
}
|
||||
interface SourceMapSpan {
|
||||
emittedLine: number;
|
||||
@@ -740,16 +748,20 @@ declare module "typescript" {
|
||||
diagnostics: Diagnostic[];
|
||||
sourceMaps: SourceMapData[];
|
||||
}
|
||||
interface TypeCheckerHost {
|
||||
getCompilerOptions(): CompilerOptions;
|
||||
getCompilerHost(): CompilerHost;
|
||||
getSourceFiles(): SourceFile[];
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
}
|
||||
interface TypeChecker {
|
||||
getProgram(): Program;
|
||||
getEmitResolver(): EmitResolver;
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getNodeCount(): number;
|
||||
getIdentifierCount(): number;
|
||||
getSymbolCount(): number;
|
||||
getTypeCount(): number;
|
||||
emitFiles(targetSourceFile?: SourceFile): EmitResult;
|
||||
getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;
|
||||
getDeclaredTypeOfSymbol(symbol: Symbol): Type;
|
||||
getPropertiesOfType(type: Type): Symbol[];
|
||||
@@ -773,7 +785,6 @@ declare module "typescript" {
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
|
||||
isUndefinedSymbol(symbol: Symbol): boolean;
|
||||
isArgumentsSymbol(symbol: Symbol): boolean;
|
||||
isEmitBlocked(sourceFile?: SourceFile): boolean;
|
||||
getEnumMemberValue(node: EnumMember): number;
|
||||
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
|
||||
getAliasedSymbol(symbol: Symbol): Symbol;
|
||||
@@ -833,7 +844,6 @@ declare module "typescript" {
|
||||
errorModuleName?: string;
|
||||
}
|
||||
interface EmitResolver {
|
||||
getProgram(): Program;
|
||||
getLocalNameOfContainer(container: ModuleDeclaration | EnumDeclaration): string;
|
||||
getExpressionNamePrefix(node: Identifier): string;
|
||||
getExportAssignmentName(node: SourceFile): string;
|
||||
@@ -849,7 +859,6 @@ declare module "typescript" {
|
||||
isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult;
|
||||
isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult;
|
||||
getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number;
|
||||
isEmitBlocked(sourceFile?: SourceFile): boolean;
|
||||
isUnknownIdentifier(location: Node, name: string): boolean;
|
||||
}
|
||||
const enum SymbolFlags {
|
||||
@@ -1019,8 +1028,6 @@ declare module "typescript" {
|
||||
}
|
||||
interface GenericType extends InterfaceType, TypeReference {
|
||||
instantiations: Map<TypeReference>;
|
||||
openReferenceTargets: GenericType[];
|
||||
openReferenceChecks: Map<boolean>;
|
||||
}
|
||||
interface TupleType extends ObjectType {
|
||||
elementTypes: Type[];
|
||||
@@ -1119,6 +1126,7 @@ declare module "typescript" {
|
||||
locale?: string;
|
||||
mapRoot?: string;
|
||||
module?: ModuleKind;
|
||||
noEmit?: boolean;
|
||||
noEmitOnError?: boolean;
|
||||
noErrorTruncation?: boolean;
|
||||
noImplicitAny?: boolean;
|
||||
@@ -1303,13 +1311,18 @@ declare module "typescript" {
|
||||
useCaseSensitiveFileNames(): boolean;
|
||||
getNewLine(): string;
|
||||
}
|
||||
interface TextSpan {
|
||||
start: number;
|
||||
length: number;
|
||||
}
|
||||
interface TextChangeRange {
|
||||
span: TextSpan;
|
||||
newLength: number;
|
||||
}
|
||||
}
|
||||
declare module "typescript" {
|
||||
interface ErrorCallback {
|
||||
(message: DiagnosticMessage): void;
|
||||
}
|
||||
interface CommentCallback {
|
||||
(pos: number, end: number): void;
|
||||
(message: DiagnosticMessage, length: number): void;
|
||||
}
|
||||
interface Scanner {
|
||||
getStartPos(): number;
|
||||
@@ -1355,17 +1368,19 @@ declare module "typescript" {
|
||||
declare module "typescript" {
|
||||
function getNodeConstructor(kind: SyntaxKind): new () => Node;
|
||||
function createNode(kind: SyntaxKind): Node;
|
||||
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodes?: (nodes: Node[]) => T): T;
|
||||
function createCompilerHost(options: CompilerOptions): CompilerHost;
|
||||
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
|
||||
function modifierToFlag(token: SyntaxKind): NodeFlags;
|
||||
function isEvalOrArgumentsIdentifier(node: Node): boolean;
|
||||
function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
function isLeftHandSideExpression(expr: Expression): boolean;
|
||||
function isAssignmentOperator(token: SyntaxKind): boolean;
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host: CompilerHost): Program;
|
||||
}
|
||||
declare module "typescript" {
|
||||
function createTypeChecker(program: Program, fullTypeCheck: boolean): TypeChecker;
|
||||
function createTypeChecker(host: TypeCheckerHost, produceDiagnostics: boolean): TypeChecker;
|
||||
}
|
||||
declare module "typescript" {
|
||||
function createCompilerHost(options: CompilerOptions): CompilerHost;
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host: CompilerHost): Program;
|
||||
}
|
||||
declare module "typescript" {
|
||||
var servicesVersion: string;
|
||||
@@ -1412,9 +1427,8 @@ declare module "typescript" {
|
||||
interface SourceFile {
|
||||
isOpen: boolean;
|
||||
version: string;
|
||||
getScriptSnapshot(): IScriptSnapshot;
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
getNamedDeclarations(): Declaration[];
|
||||
update(scriptSnapshot: IScriptSnapshot, version: string, isOpen: boolean, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
/**
|
||||
* Represents an immutable snapshot of a script at a specified time.Once acquired, the
|
||||
@@ -1496,96 +1510,6 @@ declare module "typescript" {
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
dispose(): void;
|
||||
}
|
||||
class TextSpan {
|
||||
private _start;
|
||||
private _length;
|
||||
/**
|
||||
* Creates a TextSpan instance beginning with the position Start and having the Length
|
||||
* specified with length.
|
||||
*/
|
||||
constructor(start: number, length: number);
|
||||
toJSON(key: any): any;
|
||||
start(): number;
|
||||
length(): number;
|
||||
end(): number;
|
||||
isEmpty(): boolean;
|
||||
/**
|
||||
* Determines whether the position lies within the span. Returns true if the position is greater than or equal to Start and strictly less
|
||||
* than End, otherwise false.
|
||||
* @param position The position to check.
|
||||
*/
|
||||
containsPosition(position: number): boolean;
|
||||
/**
|
||||
* Determines whether span falls completely within this span. Returns true if the specified span falls completely within this span, otherwise false.
|
||||
* @param span The span to check.
|
||||
*/
|
||||
containsTextSpan(span: TextSpan): boolean;
|
||||
/**
|
||||
* Determines whether the given span overlaps this span. Two spans are considered to overlap
|
||||
* if they have positions in common and neither is empty. Empty spans do not overlap with any
|
||||
* other span. Returns true if the spans overlap, false otherwise.
|
||||
* @param span The span to check.
|
||||
*/
|
||||
overlapsWith(span: TextSpan): boolean;
|
||||
/**
|
||||
* Returns the overlap with the given span, or undefined if there is no overlap.
|
||||
* @param span The span to check.
|
||||
*/
|
||||
overlap(span: TextSpan): TextSpan;
|
||||
/**
|
||||
* Determines whether span intersects this span. Two spans are considered to
|
||||
* intersect if they have positions in common or the end of one span
|
||||
* coincides with the start of the other span. Returns true if the spans intersect, false otherwise.
|
||||
* @param The span to check.
|
||||
*/
|
||||
intersectsWithTextSpan(span: TextSpan): boolean;
|
||||
intersectsWith(start: number, length: number): boolean;
|
||||
/**
|
||||
* Determines whether the given position intersects this span.
|
||||
* A position is considered to intersect if it is between the start and
|
||||
* end positions (inclusive) of this span. Returns true if the position intersects, false otherwise.
|
||||
* @param position The position to check.
|
||||
*/
|
||||
intersectsWithPosition(position: number): boolean;
|
||||
/**
|
||||
* Returns the intersection with the given span, or undefined if there is no intersection.
|
||||
* @param span The span to check.
|
||||
*/
|
||||
intersection(span: TextSpan): TextSpan;
|
||||
/**
|
||||
* Creates a new TextSpan from the given start and end positions
|
||||
* as opposed to a position and length.
|
||||
*/
|
||||
static fromBounds(start: number, end: number): TextSpan;
|
||||
}
|
||||
class TextChangeRange {
|
||||
static unchanged: TextChangeRange;
|
||||
private _span;
|
||||
private _newLength;
|
||||
/**
|
||||
* Initializes a new instance of TextChangeRange.
|
||||
*/
|
||||
constructor(span: TextSpan, newLength: number);
|
||||
/**
|
||||
* The span of text before the edit which is being changed
|
||||
*/
|
||||
span(): TextSpan;
|
||||
/**
|
||||
* Width of the span after the edit. A 0 here would represent a delete
|
||||
*/
|
||||
newLength(): number;
|
||||
newSpan(): TextSpan;
|
||||
isUnchanged(): boolean;
|
||||
/**
|
||||
* Called to merge all the changes that occurred across several versions of a script snapshot
|
||||
* into a single change. i.e. if a user keeps making successive edits to a script we will
|
||||
* have a text change from V1 to V2, V2 to V3, ..., Vn.
|
||||
*
|
||||
* This function will then merge those changes into a single change range valid between V1 and
|
||||
* Vn.
|
||||
*/
|
||||
static collapseChangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
|
||||
}
|
||||
interface ClassifiedSpan {
|
||||
textSpan: TextSpan;
|
||||
classificationType: string;
|
||||
@@ -1877,6 +1801,8 @@ declare module "typescript" {
|
||||
throwIfCancellationRequested(): void;
|
||||
}
|
||||
function createLanguageServiceSourceFile(filename: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, isOpen: boolean, setNodeParents: boolean): SourceFile;
|
||||
var disableIncrementalParsing: boolean;
|
||||
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, isOpen: boolean, textChangeRange: TextChangeRange): SourceFile;
|
||||
function createDocumentRegistry(): DocumentRegistry;
|
||||
function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo;
|
||||
function createLanguageService(host: LanguageServiceHost, documentRegistry: DocumentRegistry): LanguageService;
|
||||
|
||||
Vendored
+72
-146
@@ -189,29 +189,29 @@ declare module ts {
|
||||
ConditionalExpression = 164,
|
||||
TemplateExpression = 165,
|
||||
YieldExpression = 166,
|
||||
OmittedExpression = 167,
|
||||
TemplateSpan = 168,
|
||||
Block = 169,
|
||||
VariableStatement = 170,
|
||||
EmptyStatement = 171,
|
||||
ExpressionStatement = 172,
|
||||
IfStatement = 173,
|
||||
DoStatement = 174,
|
||||
WhileStatement = 175,
|
||||
ForStatement = 176,
|
||||
ForInStatement = 177,
|
||||
ContinueStatement = 178,
|
||||
BreakStatement = 179,
|
||||
ReturnStatement = 180,
|
||||
WithStatement = 181,
|
||||
SwitchStatement = 182,
|
||||
LabeledStatement = 183,
|
||||
ThrowStatement = 184,
|
||||
TryStatement = 185,
|
||||
TryBlock = 186,
|
||||
FinallyBlock = 187,
|
||||
DebuggerStatement = 188,
|
||||
VariableDeclaration = 189,
|
||||
SpreadElementExpression = 167,
|
||||
OmittedExpression = 168,
|
||||
TemplateSpan = 169,
|
||||
Block = 170,
|
||||
VariableStatement = 171,
|
||||
EmptyStatement = 172,
|
||||
ExpressionStatement = 173,
|
||||
IfStatement = 174,
|
||||
DoStatement = 175,
|
||||
WhileStatement = 176,
|
||||
ForStatement = 177,
|
||||
ForInStatement = 178,
|
||||
ContinueStatement = 179,
|
||||
BreakStatement = 180,
|
||||
ReturnStatement = 181,
|
||||
WithStatement = 182,
|
||||
SwitchStatement = 183,
|
||||
LabeledStatement = 184,
|
||||
ThrowStatement = 185,
|
||||
TryStatement = 186,
|
||||
DebuggerStatement = 187,
|
||||
VariableDeclaration = 188,
|
||||
VariableDeclarationList = 189,
|
||||
FunctionDeclaration = 190,
|
||||
ClassDeclaration = 191,
|
||||
InterfaceDeclaration = 192,
|
||||
@@ -230,9 +230,8 @@ declare module ts {
|
||||
ShorthandPropertyAssignment = 205,
|
||||
EnumMember = 206,
|
||||
SourceFile = 207,
|
||||
Program = 208,
|
||||
SyntaxList = 209,
|
||||
Count = 210,
|
||||
SyntaxList = 208,
|
||||
Count = 209,
|
||||
FirstAssignment = 52,
|
||||
LastAssignment = 63,
|
||||
FirstReservedWord = 65,
|
||||
@@ -253,8 +252,6 @@ declare module ts {
|
||||
LastLiteralToken = 10,
|
||||
FirstTemplateToken = 10,
|
||||
LastTemplateToken = 13,
|
||||
FirstOperator = 22,
|
||||
LastOperator = 63,
|
||||
FirstBinaryOperator = 24,
|
||||
LastBinaryOperator = 63,
|
||||
FirstNode = 121,
|
||||
@@ -331,10 +328,14 @@ declare module ts {
|
||||
type?: TypeNode;
|
||||
}
|
||||
interface VariableDeclaration extends Declaration {
|
||||
parent?: VariableDeclarationList;
|
||||
name: Identifier | BindingPattern;
|
||||
type?: TypeNode;
|
||||
initializer?: Expression;
|
||||
}
|
||||
interface VariableDeclarationList extends Node {
|
||||
declarations: NodeArray<VariableDeclaration>;
|
||||
}
|
||||
interface ParameterDeclaration extends Declaration {
|
||||
dotDotDotToken?: Node;
|
||||
name: Identifier | BindingPattern;
|
||||
@@ -514,6 +515,9 @@ declare module ts {
|
||||
interface ArrayLiteralExpression extends PrimaryExpression {
|
||||
elements: NodeArray<Expression>;
|
||||
}
|
||||
interface SpreadElementExpression extends Expression {
|
||||
expression: Expression;
|
||||
}
|
||||
interface ObjectLiteralExpression extends PrimaryExpression, Declaration {
|
||||
properties: NodeArray<ObjectLiteralElement>;
|
||||
}
|
||||
@@ -548,7 +552,7 @@ declare module ts {
|
||||
statements: NodeArray<Statement>;
|
||||
}
|
||||
interface VariableStatement extends Statement {
|
||||
declarations: NodeArray<VariableDeclaration>;
|
||||
declarationList: VariableDeclarationList;
|
||||
}
|
||||
interface ExpressionStatement extends Statement {
|
||||
expression: Expression;
|
||||
@@ -568,14 +572,12 @@ declare module ts {
|
||||
expression: Expression;
|
||||
}
|
||||
interface ForStatement extends IterationStatement {
|
||||
declarations?: NodeArray<VariableDeclaration>;
|
||||
initializer?: Expression;
|
||||
initializer?: VariableDeclarationList | Expression;
|
||||
condition?: Expression;
|
||||
iterator?: Expression;
|
||||
}
|
||||
interface ForInStatement extends IterationStatement {
|
||||
declarations?: NodeArray<VariableDeclaration>;
|
||||
variable?: Expression;
|
||||
initializer: VariableDeclarationList | Expression;
|
||||
expression: Expression;
|
||||
}
|
||||
interface BreakOrContinueStatement extends Statement {
|
||||
@@ -682,12 +684,12 @@ declare module ts {
|
||||
getLineAndCharacterFromPosition(position: number): LineAndCharacter;
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getLineStarts(): number[];
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
amdDependencies: string[];
|
||||
amdModuleName: string;
|
||||
referencedFiles: FileReference[];
|
||||
referenceDiagnostics: Diagnostic[];
|
||||
parseDiagnostics: Diagnostic[];
|
||||
grammarDiagnostics: Diagnostic[];
|
||||
getSyntacticDiagnostics(): Diagnostic[];
|
||||
semanticDiagnostics: Diagnostic[];
|
||||
hasNoDefaultLib: boolean;
|
||||
@@ -698,15 +700,21 @@ declare module ts {
|
||||
languageVersion: ScriptTarget;
|
||||
identifiers: Map<string>;
|
||||
}
|
||||
interface Program {
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
getSourceFiles(): SourceFile[];
|
||||
interface ScriptReferenceHost {
|
||||
getCompilerOptions(): CompilerOptions;
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
getCurrentDirectory(): string;
|
||||
}
|
||||
interface Program extends ScriptReferenceHost {
|
||||
getSourceFiles(): SourceFile[];
|
||||
getCompilerHost(): CompilerHost;
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getTypeChecker(fullTypeCheckMode: boolean): TypeChecker;
|
||||
getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
getTypeChecker(produceDiagnostics: boolean): TypeChecker;
|
||||
getCommonSourceDirectory(): string;
|
||||
emitFiles(targetSourceFile?: SourceFile): EmitResult;
|
||||
isEmitBlocked(sourceFile?: SourceFile): boolean;
|
||||
}
|
||||
interface SourceMapSpan {
|
||||
emittedLine: number;
|
||||
@@ -740,16 +748,20 @@ declare module ts {
|
||||
diagnostics: Diagnostic[];
|
||||
sourceMaps: SourceMapData[];
|
||||
}
|
||||
interface TypeCheckerHost {
|
||||
getCompilerOptions(): CompilerOptions;
|
||||
getCompilerHost(): CompilerHost;
|
||||
getSourceFiles(): SourceFile[];
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
}
|
||||
interface TypeChecker {
|
||||
getProgram(): Program;
|
||||
getEmitResolver(): EmitResolver;
|
||||
getDiagnostics(sourceFile?: SourceFile): Diagnostic[];
|
||||
getDeclarationDiagnostics(sourceFile: SourceFile): Diagnostic[];
|
||||
getGlobalDiagnostics(): Diagnostic[];
|
||||
getNodeCount(): number;
|
||||
getIdentifierCount(): number;
|
||||
getSymbolCount(): number;
|
||||
getTypeCount(): number;
|
||||
emitFiles(targetSourceFile?: SourceFile): EmitResult;
|
||||
getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;
|
||||
getDeclaredTypeOfSymbol(symbol: Symbol): Type;
|
||||
getPropertiesOfType(type: Type): Symbol[];
|
||||
@@ -773,7 +785,6 @@ declare module ts {
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
|
||||
isUndefinedSymbol(symbol: Symbol): boolean;
|
||||
isArgumentsSymbol(symbol: Symbol): boolean;
|
||||
isEmitBlocked(sourceFile?: SourceFile): boolean;
|
||||
getEnumMemberValue(node: EnumMember): number;
|
||||
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
|
||||
getAliasedSymbol(symbol: Symbol): Symbol;
|
||||
@@ -833,7 +844,6 @@ declare module ts {
|
||||
errorModuleName?: string;
|
||||
}
|
||||
interface EmitResolver {
|
||||
getProgram(): Program;
|
||||
getLocalNameOfContainer(container: ModuleDeclaration | EnumDeclaration): string;
|
||||
getExpressionNamePrefix(node: Identifier): string;
|
||||
getExportAssignmentName(node: SourceFile): string;
|
||||
@@ -849,7 +859,6 @@ declare module ts {
|
||||
isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult;
|
||||
isEntityNameVisible(entityName: EntityName, enclosingDeclaration: Node): SymbolVisibilityResult;
|
||||
getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number;
|
||||
isEmitBlocked(sourceFile?: SourceFile): boolean;
|
||||
isUnknownIdentifier(location: Node, name: string): boolean;
|
||||
}
|
||||
const enum SymbolFlags {
|
||||
@@ -1019,8 +1028,6 @@ declare module ts {
|
||||
}
|
||||
interface GenericType extends InterfaceType, TypeReference {
|
||||
instantiations: Map<TypeReference>;
|
||||
openReferenceTargets: GenericType[];
|
||||
openReferenceChecks: Map<boolean>;
|
||||
}
|
||||
interface TupleType extends ObjectType {
|
||||
elementTypes: Type[];
|
||||
@@ -1119,6 +1126,7 @@ declare module ts {
|
||||
locale?: string;
|
||||
mapRoot?: string;
|
||||
module?: ModuleKind;
|
||||
noEmit?: boolean;
|
||||
noEmitOnError?: boolean;
|
||||
noErrorTruncation?: boolean;
|
||||
noImplicitAny?: boolean;
|
||||
@@ -1303,13 +1311,18 @@ declare module ts {
|
||||
useCaseSensitiveFileNames(): boolean;
|
||||
getNewLine(): string;
|
||||
}
|
||||
interface TextSpan {
|
||||
start: number;
|
||||
length: number;
|
||||
}
|
||||
interface TextChangeRange {
|
||||
span: TextSpan;
|
||||
newLength: number;
|
||||
}
|
||||
}
|
||||
declare module ts {
|
||||
interface ErrorCallback {
|
||||
(message: DiagnosticMessage): void;
|
||||
}
|
||||
interface CommentCallback {
|
||||
(pos: number, end: number): void;
|
||||
(message: DiagnosticMessage, length: number): void;
|
||||
}
|
||||
interface Scanner {
|
||||
getStartPos(): number;
|
||||
@@ -1355,17 +1368,19 @@ declare module ts {
|
||||
declare module ts {
|
||||
function getNodeConstructor(kind: SyntaxKind): new () => Node;
|
||||
function createNode(kind: SyntaxKind): Node;
|
||||
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodes?: (nodes: Node[]) => T): T;
|
||||
function createCompilerHost(options: CompilerOptions): CompilerHost;
|
||||
function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
|
||||
function modifierToFlag(token: SyntaxKind): NodeFlags;
|
||||
function isEvalOrArgumentsIdentifier(node: Node): boolean;
|
||||
function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean): SourceFile;
|
||||
function isLeftHandSideExpression(expr: Expression): boolean;
|
||||
function isAssignmentOperator(token: SyntaxKind): boolean;
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host: CompilerHost): Program;
|
||||
}
|
||||
declare module ts {
|
||||
function createTypeChecker(program: Program, fullTypeCheck: boolean): TypeChecker;
|
||||
function createTypeChecker(host: TypeCheckerHost, produceDiagnostics: boolean): TypeChecker;
|
||||
}
|
||||
declare module ts {
|
||||
function createCompilerHost(options: CompilerOptions): CompilerHost;
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host: CompilerHost): Program;
|
||||
}
|
||||
declare module ts {
|
||||
var servicesVersion: string;
|
||||
@@ -1412,9 +1427,8 @@ declare module ts {
|
||||
interface SourceFile {
|
||||
isOpen: boolean;
|
||||
version: string;
|
||||
getScriptSnapshot(): IScriptSnapshot;
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
getNamedDeclarations(): Declaration[];
|
||||
update(scriptSnapshot: IScriptSnapshot, version: string, isOpen: boolean, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
/**
|
||||
* Represents an immutable snapshot of a script at a specified time.Once acquired, the
|
||||
@@ -1496,96 +1510,6 @@ declare module ts {
|
||||
getSourceFile(filename: string): SourceFile;
|
||||
dispose(): void;
|
||||
}
|
||||
class TextSpan {
|
||||
private _start;
|
||||
private _length;
|
||||
/**
|
||||
* Creates a TextSpan instance beginning with the position Start and having the Length
|
||||
* specified with length.
|
||||
*/
|
||||
constructor(start: number, length: number);
|
||||
toJSON(key: any): any;
|
||||
start(): number;
|
||||
length(): number;
|
||||
end(): number;
|
||||
isEmpty(): boolean;
|
||||
/**
|
||||
* Determines whether the position lies within the span. Returns true if the position is greater than or equal to Start and strictly less
|
||||
* than End, otherwise false.
|
||||
* @param position The position to check.
|
||||
*/
|
||||
containsPosition(position: number): boolean;
|
||||
/**
|
||||
* Determines whether span falls completely within this span. Returns true if the specified span falls completely within this span, otherwise false.
|
||||
* @param span The span to check.
|
||||
*/
|
||||
containsTextSpan(span: TextSpan): boolean;
|
||||
/**
|
||||
* Determines whether the given span overlaps this span. Two spans are considered to overlap
|
||||
* if they have positions in common and neither is empty. Empty spans do not overlap with any
|
||||
* other span. Returns true if the spans overlap, false otherwise.
|
||||
* @param span The span to check.
|
||||
*/
|
||||
overlapsWith(span: TextSpan): boolean;
|
||||
/**
|
||||
* Returns the overlap with the given span, or undefined if there is no overlap.
|
||||
* @param span The span to check.
|
||||
*/
|
||||
overlap(span: TextSpan): TextSpan;
|
||||
/**
|
||||
* Determines whether span intersects this span. Two spans are considered to
|
||||
* intersect if they have positions in common or the end of one span
|
||||
* coincides with the start of the other span. Returns true if the spans intersect, false otherwise.
|
||||
* @param The span to check.
|
||||
*/
|
||||
intersectsWithTextSpan(span: TextSpan): boolean;
|
||||
intersectsWith(start: number, length: number): boolean;
|
||||
/**
|
||||
* Determines whether the given position intersects this span.
|
||||
* A position is considered to intersect if it is between the start and
|
||||
* end positions (inclusive) of this span. Returns true if the position intersects, false otherwise.
|
||||
* @param position The position to check.
|
||||
*/
|
||||
intersectsWithPosition(position: number): boolean;
|
||||
/**
|
||||
* Returns the intersection with the given span, or undefined if there is no intersection.
|
||||
* @param span The span to check.
|
||||
*/
|
||||
intersection(span: TextSpan): TextSpan;
|
||||
/**
|
||||
* Creates a new TextSpan from the given start and end positions
|
||||
* as opposed to a position and length.
|
||||
*/
|
||||
static fromBounds(start: number, end: number): TextSpan;
|
||||
}
|
||||
class TextChangeRange {
|
||||
static unchanged: TextChangeRange;
|
||||
private _span;
|
||||
private _newLength;
|
||||
/**
|
||||
* Initializes a new instance of TextChangeRange.
|
||||
*/
|
||||
constructor(span: TextSpan, newLength: number);
|
||||
/**
|
||||
* The span of text before the edit which is being changed
|
||||
*/
|
||||
span(): TextSpan;
|
||||
/**
|
||||
* Width of the span after the edit. A 0 here would represent a delete
|
||||
*/
|
||||
newLength(): number;
|
||||
newSpan(): TextSpan;
|
||||
isUnchanged(): boolean;
|
||||
/**
|
||||
* Called to merge all the changes that occurred across several versions of a script snapshot
|
||||
* into a single change. i.e. if a user keeps making successive edits to a script we will
|
||||
* have a text change from V1 to V2, V2 to V3, ..., Vn.
|
||||
*
|
||||
* This function will then merge those changes into a single change range valid between V1 and
|
||||
* Vn.
|
||||
*/
|
||||
static collapseChangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
|
||||
}
|
||||
interface ClassifiedSpan {
|
||||
textSpan: TextSpan;
|
||||
classificationType: string;
|
||||
@@ -1877,6 +1801,8 @@ declare module ts {
|
||||
throwIfCancellationRequested(): void;
|
||||
}
|
||||
function createLanguageServiceSourceFile(filename: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, isOpen: boolean, setNodeParents: boolean): SourceFile;
|
||||
var disableIncrementalParsing: boolean;
|
||||
function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, isOpen: boolean, textChangeRange: TextChangeRange): SourceFile;
|
||||
function createDocumentRegistry(): DocumentRegistry;
|
||||
function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo;
|
||||
function createLanguageService(host: LanguageServiceHost, documentRegistry: DocumentRegistry): LanguageService;
|
||||
|
||||
+6559
-4785
File diff suppressed because it is too large
Load Diff
Vendored
+45
-3
@@ -26,7 +26,7 @@ declare module ts {
|
||||
}
|
||||
interface StringSet extends Map<any> {
|
||||
}
|
||||
function forEach<T, U>(array: T[], callback: (element: T) => U): U;
|
||||
function forEach<T, U>(array: T[], callback: (element: T, index: number) => U): U;
|
||||
function contains<T>(array: T[], value: T): boolean;
|
||||
function indexOf<T>(array: T[], value: T): number;
|
||||
function countWhere<T>(array: T[], predicate: (x: T) => boolean): number;
|
||||
@@ -48,6 +48,7 @@ declare module ts {
|
||||
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.
|
||||
*
|
||||
@@ -142,6 +143,14 @@ declare module ts {
|
||||
interface StringSymbolWriter extends SymbolWriter {
|
||||
string(): string;
|
||||
}
|
||||
interface EmitHost extends ScriptReferenceHost {
|
||||
getSourceFiles(): SourceFile[];
|
||||
isEmitBlocked(sourceFile?: SourceFile): boolean;
|
||||
getCommonSourceDirectory(): string;
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
getNewLine(): string;
|
||||
writeFile(filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
}
|
||||
function getSingleLineStringWriter(): StringSymbolWriter;
|
||||
function releaseStringWriter(writer: StringSymbolWriter): void;
|
||||
function getFullWidth(node: Node): number;
|
||||
@@ -149,7 +158,8 @@ declare module ts {
|
||||
function getSourceFileOfNode(node: Node): SourceFile;
|
||||
function nodePosToString(node: Node): string;
|
||||
function getStartPosOfNode(node: Node): number;
|
||||
function isMissingNode(node: Node): boolean;
|
||||
function nodeIsMissing(node: Node): boolean;
|
||||
function nodeIsPresent(node: Node): boolean;
|
||||
function getTokenPosOfNode(node: Node, sourceFile?: SourceFile): number;
|
||||
function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node): string;
|
||||
function getTextOfNodeFromSourceText(sourceText: string, node: Node): string;
|
||||
@@ -163,6 +173,7 @@ declare module ts {
|
||||
function isExternalModule(file: SourceFile): boolean;
|
||||
function isDeclarationFile(file: SourceFile): boolean;
|
||||
function isConstEnumDeclaration(node: Node): boolean;
|
||||
function getCombinedNodeFlags(node: Node): NodeFlags;
|
||||
function isConst(node: Node): boolean;
|
||||
function isLet(node: Node): boolean;
|
||||
function isPrologueDirective(node: Node): boolean;
|
||||
@@ -178,6 +189,7 @@ declare module ts {
|
||||
function getSuperContainer(node: Node): Node;
|
||||
function getInvokedExpression(node: CallLikeExpression): Expression;
|
||||
function isExpression(node: Node): boolean;
|
||||
function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean): boolean;
|
||||
function isExternalModuleImportDeclaration(node: Node): boolean;
|
||||
function getExternalModuleImportDeclarationExpression(node: Node): Expression;
|
||||
function isInternalModuleImportDeclaration(node: Node): boolean;
|
||||
@@ -196,12 +208,42 @@ declare module ts {
|
||||
function getClassImplementedTypeNodes(node: ClassDeclaration): NodeArray<TypeReferenceNode>;
|
||||
function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray<TypeReferenceNode>;
|
||||
function getHeritageClause(clauses: NodeArray<HeritageClause>, kind: SyntaxKind): HeritageClause;
|
||||
function tryResolveScriptReference(program: Program, sourceFile: SourceFile, reference: FileReference): SourceFile;
|
||||
function tryResolveScriptReference(host: ScriptReferenceHost, sourceFile: SourceFile, reference: FileReference): SourceFile;
|
||||
function getAncestor(node: Node, kind: SyntaxKind): Node;
|
||||
function getFileReferenceFromReferencePath(comment: string, commentRange: CommentRange): ReferencePathMatchResult;
|
||||
function isKeyword(token: SyntaxKind): boolean;
|
||||
function isTrivia(token: SyntaxKind): boolean;
|
||||
function isModifier(token: SyntaxKind): boolean;
|
||||
function createEmitHostFromProgram(program: Program): EmitHost;
|
||||
function textSpanEnd(span: TextSpan): number;
|
||||
function textSpanIsEmpty(span: TextSpan): boolean;
|
||||
function textSpanContainsPosition(span: TextSpan, position: number): boolean;
|
||||
function textSpanContainsTextSpan(span: TextSpan, other: TextSpan): boolean;
|
||||
function textSpanOverlapsWith(span: TextSpan, other: TextSpan): boolean;
|
||||
function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan;
|
||||
function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean;
|
||||
function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean;
|
||||
function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean;
|
||||
function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan;
|
||||
function createTextSpan(start: number, length: number): TextSpan;
|
||||
function createTextSpanFromBounds(start: number, end: number): TextSpan;
|
||||
function textChangeRangeNewSpan(range: TextChangeRange): TextSpan;
|
||||
function textChangeRangeIsUnchanged(range: TextChangeRange): boolean;
|
||||
function createTextChangeRange(span: TextSpan, newLength: number): TextChangeRange;
|
||||
var unchangedTextChangeRange: TextChangeRange;
|
||||
/**
|
||||
* Called to merge all the changes that occurred across several versions of a script snapshot
|
||||
* into a single change. i.e. if a user keeps making successive edits to a script we will
|
||||
* have a text change from V1 to V2, V2 to V3, ..., Vn.
|
||||
*
|
||||
* This function will then merge those changes into a single change range valid between V1 and
|
||||
* Vn.
|
||||
*/
|
||||
function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
|
||||
}
|
||||
declare module ts {
|
||||
var optionDeclarations: CommandLineOption[];
|
||||
function parseCommandLine(commandLine: string[]): ParsedCommandLine;
|
||||
}
|
||||
declare module ts {
|
||||
interface ListItemInfo {
|
||||
|
||||
Vendored
+45
-3
@@ -26,7 +26,7 @@ declare module "typescript" {
|
||||
}
|
||||
interface StringSet extends Map<any> {
|
||||
}
|
||||
function forEach<T, U>(array: T[], callback: (element: T) => U): U;
|
||||
function forEach<T, U>(array: T[], callback: (element: T, index: number) => U): U;
|
||||
function contains<T>(array: T[], value: T): boolean;
|
||||
function indexOf<T>(array: T[], value: T): number;
|
||||
function countWhere<T>(array: T[], predicate: (x: T) => boolean): number;
|
||||
@@ -48,6 +48,7 @@ declare module "typescript" {
|
||||
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.
|
||||
*
|
||||
@@ -142,6 +143,14 @@ declare module "typescript" {
|
||||
interface StringSymbolWriter extends SymbolWriter {
|
||||
string(): string;
|
||||
}
|
||||
interface EmitHost extends ScriptReferenceHost {
|
||||
getSourceFiles(): SourceFile[];
|
||||
isEmitBlocked(sourceFile?: SourceFile): boolean;
|
||||
getCommonSourceDirectory(): string;
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
getNewLine(): string;
|
||||
writeFile(filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
}
|
||||
function getSingleLineStringWriter(): StringSymbolWriter;
|
||||
function releaseStringWriter(writer: StringSymbolWriter): void;
|
||||
function getFullWidth(node: Node): number;
|
||||
@@ -149,7 +158,8 @@ declare module "typescript" {
|
||||
function getSourceFileOfNode(node: Node): SourceFile;
|
||||
function nodePosToString(node: Node): string;
|
||||
function getStartPosOfNode(node: Node): number;
|
||||
function isMissingNode(node: Node): boolean;
|
||||
function nodeIsMissing(node: Node): boolean;
|
||||
function nodeIsPresent(node: Node): boolean;
|
||||
function getTokenPosOfNode(node: Node, sourceFile?: SourceFile): number;
|
||||
function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node): string;
|
||||
function getTextOfNodeFromSourceText(sourceText: string, node: Node): string;
|
||||
@@ -163,6 +173,7 @@ declare module "typescript" {
|
||||
function isExternalModule(file: SourceFile): boolean;
|
||||
function isDeclarationFile(file: SourceFile): boolean;
|
||||
function isConstEnumDeclaration(node: Node): boolean;
|
||||
function getCombinedNodeFlags(node: Node): NodeFlags;
|
||||
function isConst(node: Node): boolean;
|
||||
function isLet(node: Node): boolean;
|
||||
function isPrologueDirective(node: Node): boolean;
|
||||
@@ -178,6 +189,7 @@ declare module "typescript" {
|
||||
function getSuperContainer(node: Node): Node;
|
||||
function getInvokedExpression(node: CallLikeExpression): Expression;
|
||||
function isExpression(node: Node): boolean;
|
||||
function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean): boolean;
|
||||
function isExternalModuleImportDeclaration(node: Node): boolean;
|
||||
function getExternalModuleImportDeclarationExpression(node: Node): Expression;
|
||||
function isInternalModuleImportDeclaration(node: Node): boolean;
|
||||
@@ -196,12 +208,42 @@ declare module "typescript" {
|
||||
function getClassImplementedTypeNodes(node: ClassDeclaration): NodeArray<TypeReferenceNode>;
|
||||
function getInterfaceBaseTypeNodes(node: InterfaceDeclaration): NodeArray<TypeReferenceNode>;
|
||||
function getHeritageClause(clauses: NodeArray<HeritageClause>, kind: SyntaxKind): HeritageClause;
|
||||
function tryResolveScriptReference(program: Program, sourceFile: SourceFile, reference: FileReference): SourceFile;
|
||||
function tryResolveScriptReference(host: ScriptReferenceHost, sourceFile: SourceFile, reference: FileReference): SourceFile;
|
||||
function getAncestor(node: Node, kind: SyntaxKind): Node;
|
||||
function getFileReferenceFromReferencePath(comment: string, commentRange: CommentRange): ReferencePathMatchResult;
|
||||
function isKeyword(token: SyntaxKind): boolean;
|
||||
function isTrivia(token: SyntaxKind): boolean;
|
||||
function isModifier(token: SyntaxKind): boolean;
|
||||
function createEmitHostFromProgram(program: Program): EmitHost;
|
||||
function textSpanEnd(span: TextSpan): number;
|
||||
function textSpanIsEmpty(span: TextSpan): boolean;
|
||||
function textSpanContainsPosition(span: TextSpan, position: number): boolean;
|
||||
function textSpanContainsTextSpan(span: TextSpan, other: TextSpan): boolean;
|
||||
function textSpanOverlapsWith(span: TextSpan, other: TextSpan): boolean;
|
||||
function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan;
|
||||
function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean;
|
||||
function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean;
|
||||
function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean;
|
||||
function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan;
|
||||
function createTextSpan(start: number, length: number): TextSpan;
|
||||
function createTextSpanFromBounds(start: number, end: number): TextSpan;
|
||||
function textChangeRangeNewSpan(range: TextChangeRange): TextSpan;
|
||||
function textChangeRangeIsUnchanged(range: TextChangeRange): boolean;
|
||||
function createTextChangeRange(span: TextSpan, newLength: number): TextChangeRange;
|
||||
var unchangedTextChangeRange: TextChangeRange;
|
||||
/**
|
||||
* Called to merge all the changes that occurred across several versions of a script snapshot
|
||||
* into a single change. i.e. if a user keeps making successive edits to a script we will
|
||||
* have a text change from V1 to V2, V2 to V3, ..., Vn.
|
||||
*
|
||||
* This function will then merge those changes into a single change range valid between V1 and
|
||||
* Vn.
|
||||
*/
|
||||
function collapseTextChangeRangesAcrossMultipleVersions(changes: TextChangeRange[]): TextChangeRange;
|
||||
}
|
||||
declare module "typescript" {
|
||||
var optionDeclarations: CommandLineOption[];
|
||||
function parseCommandLine(commandLine: string[]): ParsedCommandLine;
|
||||
}
|
||||
declare module "typescript" {
|
||||
interface ListItemInfo {
|
||||
|
||||
+118
-49
@@ -16,6 +16,8 @@ module ts {
|
||||
var emptySymbols: SymbolTable = {};
|
||||
|
||||
var compilerOptions = host.getCompilerOptions();
|
||||
var languageVersion = compilerOptions.target || ScriptTarget.ES3;
|
||||
|
||||
var emitResolver = createResolver();
|
||||
|
||||
var checker: TypeChecker = {
|
||||
@@ -1575,7 +1577,6 @@ module ts {
|
||||
case SyntaxKind.IndexSignature:
|
||||
case SyntaxKind.Parameter:
|
||||
case SyntaxKind.ModuleBlock:
|
||||
case SyntaxKind.TypeParameter:
|
||||
case SyntaxKind.FunctionType:
|
||||
case SyntaxKind.ConstructorType:
|
||||
case SyntaxKind.TypeLiteral:
|
||||
@@ -1585,7 +1586,9 @@ module ts {
|
||||
case SyntaxKind.UnionType:
|
||||
case SyntaxKind.ParenthesizedType:
|
||||
return isDeclarationVisible(<Declaration>node.parent);
|
||||
|
||||
|
||||
// Type parameters are always visible
|
||||
case SyntaxKind.TypeParameter:
|
||||
// Source file is always visible
|
||||
case SyntaxKind.SourceFile:
|
||||
return true;
|
||||
@@ -3336,6 +3339,8 @@ module ts {
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
return isContextSensitiveFunctionLikeDeclaration(<MethodDeclaration>node);
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
return isContextSensitive((<ParenthesizedExpression>node).expression);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -3651,9 +3656,7 @@ module ts {
|
||||
var maybeCache = maybeStack[depth];
|
||||
// If result is definitely true, copy assumptions to global cache, else copy to next level up
|
||||
var destinationCache = result === Ternary.True || depth === 0 ? relation : maybeStack[depth - 1];
|
||||
for (var p in maybeCache) {
|
||||
destinationCache[p] = maybeCache[p];
|
||||
}
|
||||
copyMap(/*source*/maybeCache, /*target*/destinationCache);
|
||||
}
|
||||
else {
|
||||
// A false result goes straight into global cache (when something is false under assumptions it
|
||||
@@ -4591,8 +4594,8 @@ module ts {
|
||||
// Get the narrowed type of a given symbol at a given location
|
||||
function getNarrowedTypeOfSymbol(symbol: Symbol, node: Node) {
|
||||
var type = getTypeOfSymbol(symbol);
|
||||
// Only narrow when symbol is variable of an object, union, or type parameter type
|
||||
if (node && symbol.flags & SymbolFlags.Variable && type.flags & (TypeFlags.ObjectType | TypeFlags.Union | TypeFlags.TypeParameter)) {
|
||||
// Only narrow when symbol is variable of type any or an object, union, or type parameter type
|
||||
if (node && symbol.flags & SymbolFlags.Variable && type.flags & (TypeFlags.Any | TypeFlags.ObjectType | TypeFlags.Union | TypeFlags.TypeParameter)) {
|
||||
loop: while (node.parent) {
|
||||
var child = node;
|
||||
node = node.parent;
|
||||
@@ -4648,21 +4651,16 @@ module ts {
|
||||
if (expr.left.kind !== SyntaxKind.TypeOfExpression || expr.right.kind !== SyntaxKind.StringLiteral) {
|
||||
return type;
|
||||
}
|
||||
|
||||
var left = <TypeOfExpression>expr.left;
|
||||
var right = <LiteralExpression>expr.right;
|
||||
if (left.expression.kind !== SyntaxKind.Identifier ||
|
||||
getResolvedSymbol(<Identifier>left.expression) !== symbol) {
|
||||
|
||||
if (left.expression.kind !== SyntaxKind.Identifier || getResolvedSymbol(<Identifier>left.expression) !== symbol) {
|
||||
return type;
|
||||
}
|
||||
|
||||
var t = right.text;
|
||||
var checkType: Type = t === "string" ? stringType : t === "number" ? numberType : t === "boolean" ? booleanType : emptyObjectType;
|
||||
if (expr.operator === SyntaxKind.ExclamationEqualsEqualsToken) {
|
||||
assumeTrue = !assumeTrue;
|
||||
}
|
||||
|
||||
if (assumeTrue) {
|
||||
// The assumed result is true. If check was for a primitive type, that type is the narrowed type. Otherwise we can
|
||||
// remove the primitive types from the narrowed type.
|
||||
@@ -4706,8 +4704,8 @@ module ts {
|
||||
}
|
||||
|
||||
function narrowTypeByInstanceof(type: Type, expr: BinaryExpression, assumeTrue: boolean): Type {
|
||||
// Check that assumed result is true and we have variable symbol on the left
|
||||
if (!assumeTrue || expr.left.kind !== SyntaxKind.Identifier || getResolvedSymbol(<Identifier>expr.left) !== symbol) {
|
||||
// Check that type is not any, assumed result is true, and we have variable symbol on the left
|
||||
if (type.flags & TypeFlags.Any || !assumeTrue || expr.left.kind !== SyntaxKind.Identifier || getResolvedSymbol(<Identifier>expr.left) !== symbol) {
|
||||
return type;
|
||||
}
|
||||
// Check that right operand is a function type with a prototype property
|
||||
@@ -4715,13 +4713,21 @@ module ts {
|
||||
if (!isTypeSubtypeOf(rightType, globalFunctionType)) {
|
||||
return type;
|
||||
}
|
||||
// Target type is type of prototype property
|
||||
var prototypeProperty = getPropertyOfType(rightType, "prototype");
|
||||
if (!prototypeProperty) {
|
||||
return type;
|
||||
}
|
||||
var prototypeType = getTypeOfSymbol(prototypeProperty);
|
||||
// Narrow to type of prototype property if it is a subtype of current type
|
||||
return isTypeSubtypeOf(prototypeType, type) ? prototypeType : type;
|
||||
var targetType = getTypeOfSymbol(prototypeProperty);
|
||||
// Narrow to target type if it is a subtype of current type
|
||||
if (isTypeSubtypeOf(targetType, type)) {
|
||||
return targetType;
|
||||
}
|
||||
// If current type is a union type, remove all constituents that aren't subtypes of target type
|
||||
if (type.flags & TypeFlags.Union) {
|
||||
return getUnionType(filter((<UnionType>type).types, t => isTypeSubtypeOf(t, targetType)));
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
// Narrow the given type based on the given expression having the assumed boolean value
|
||||
@@ -5061,17 +5067,25 @@ module ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// In a typed function call, an argument expression is contextually typed by the type of the corresponding parameter.
|
||||
function getContextualTypeForArgument(node: Expression): Type {
|
||||
var callExpression = <CallExpression>node.parent;
|
||||
var argIndex = indexOf(callExpression.arguments, node);
|
||||
// In a typed function call, an argument or substitution expression is contextually typed by the type of the corresponding parameter.
|
||||
function getContextualTypeForArgument(callTarget: CallLikeExpression, arg: Expression): Type {
|
||||
var args = getEffectiveCallArguments(callTarget);
|
||||
var argIndex = indexOf(args, arg);
|
||||
if (argIndex >= 0) {
|
||||
var signature = getResolvedSignature(callExpression);
|
||||
var signature = getResolvedSignature(callTarget);
|
||||
return getTypeAtPosition(signature, argIndex);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getContextualTypeForSubstitutionExpression(template: TemplateExpression, substitutionExpression: Expression) {
|
||||
if (template.parent.kind === SyntaxKind.TaggedTemplateExpression) {
|
||||
return getContextualTypeForArgument(<TaggedTemplateExpression>template.parent, substitutionExpression);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getContextualTypeForBinaryOperand(node: Expression): Type {
|
||||
var binaryExpression = <BinaryExpression>node.parent;
|
||||
var operator = binaryExpression.operator;
|
||||
@@ -5209,7 +5223,7 @@ module ts {
|
||||
return getContextualTypeForReturnExpression(node);
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.NewExpression:
|
||||
return getContextualTypeForArgument(node);
|
||||
return getContextualTypeForArgument(<CallExpression>parent, node);
|
||||
case SyntaxKind.TypeAssertionExpression:
|
||||
return getTypeFromTypeNode((<TypeAssertion>parent).type);
|
||||
case SyntaxKind.BinaryExpression:
|
||||
@@ -5220,6 +5234,11 @@ module ts {
|
||||
return getContextualTypeForElementExpression(node);
|
||||
case SyntaxKind.ConditionalExpression:
|
||||
return getContextualTypeForConditionalOperand(node);
|
||||
case SyntaxKind.TemplateSpan:
|
||||
Debug.assert(parent.parent.kind === SyntaxKind.TemplateExpression);
|
||||
return getContextualTypeForSubstitutionExpression(<TemplateExpression>parent.parent, node);
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
return getContextualType(<ParenthesizedExpression>parent);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@@ -5604,8 +5623,11 @@ module ts {
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
if (isConstEnumObjectType(objectType) && node.argumentExpression && node.argumentExpression.kind !== SyntaxKind.StringLiteral) {
|
||||
error(node.argumentExpression, Diagnostics.Index_expression_arguments_in_const_enums_must_be_of_type_string);
|
||||
var isConstEnum = isConstEnumObjectType(objectType);
|
||||
if (isConstEnum &&
|
||||
(!node.argumentExpression || node.argumentExpression.kind !== SyntaxKind.StringLiteral)) {
|
||||
error(node.argumentExpression, Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal);
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
// TypeScript 1.0 spec (April 2014): 4.10 Property Access
|
||||
@@ -5626,6 +5648,10 @@ module ts {
|
||||
getNodeLinks(node).resolvedSymbol = prop;
|
||||
return getTypeOfSymbol(prop);
|
||||
}
|
||||
else if (isConstEnum) {
|
||||
error(node.argumentExpression, Diagnostics.Property_0_does_not_exist_on_const_enum_1, name, symbolToString(objectType.symbol));
|
||||
return unknownType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5880,7 +5906,7 @@ module ts {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the effective arguments for an expression that works like a function invokation.
|
||||
* Returns the effective arguments for an expression that works like a function invocation.
|
||||
*
|
||||
* If 'node' is a CallExpression or a NewExpression, then its argument list is returned.
|
||||
* If 'node' is a TaggedTemplateExpression, a new argument list is constructed from the substitution
|
||||
@@ -6114,8 +6140,10 @@ module ts {
|
||||
var result = candidates;
|
||||
var lastParent: Node;
|
||||
var lastSymbol: Symbol;
|
||||
var cutoffPos: number = 0;
|
||||
var pos: number;
|
||||
var cutoffIndex: number = 0;
|
||||
var index: number;
|
||||
var specializedIndex: number = -1;
|
||||
var spliceIndex: number;
|
||||
Debug.assert(!result.length);
|
||||
for (var i = 0; i < signatures.length; i++) {
|
||||
var signature = signatures[i];
|
||||
@@ -6123,25 +6151,36 @@ module ts {
|
||||
var parent = signature.declaration && signature.declaration.parent;
|
||||
if (!lastSymbol || symbol === lastSymbol) {
|
||||
if (lastParent && parent === lastParent) {
|
||||
pos++;
|
||||
index++;
|
||||
}
|
||||
else {
|
||||
lastParent = parent;
|
||||
pos = cutoffPos;
|
||||
index = cutoffIndex;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// current declaration belongs to a different symbol
|
||||
// set cutoffPos so re-orderings in the future won't change result set from 0 to cutoffPos
|
||||
pos = cutoffPos = result.length;
|
||||
// set cutoffIndex so re-orderings in the future won't change result set from 0 to cutoffIndex
|
||||
index = cutoffIndex = result.length;
|
||||
lastParent = parent;
|
||||
}
|
||||
lastSymbol = symbol;
|
||||
|
||||
for (var j = result.length; j > pos; j--) {
|
||||
result[j] = result[j - 1];
|
||||
// specialized signatures always need to be placed before non-specialized signatures regardless
|
||||
// of the cutoff position; see GH#1133
|
||||
if (signature.hasStringLiterals) {
|
||||
specializedIndex++;
|
||||
spliceIndex = specializedIndex;
|
||||
// The cutoff index always needs to be greater than or equal to the specialized signature index
|
||||
// in order to prevent non-specialized signatures from being added before a specialized
|
||||
// signature.
|
||||
cutoffIndex++;
|
||||
}
|
||||
result[pos] = signature;
|
||||
else {
|
||||
spliceIndex = index;
|
||||
}
|
||||
|
||||
result.splice(spliceIndex, 0, signature);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6324,7 +6363,7 @@ module ts {
|
||||
|
||||
function checkTaggedTemplateExpression(node: TaggedTemplateExpression): Type {
|
||||
// Grammar checking
|
||||
if (compilerOptions.target < ScriptTarget.ES6) {
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
grammarErrorOnFirstToken(node.template, Diagnostics.Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher);
|
||||
}
|
||||
|
||||
@@ -7173,12 +7212,15 @@ module ts {
|
||||
|
||||
checkVariableLikeDeclaration(node);
|
||||
var func = getContainingFunction(node);
|
||||
if (node.flags & (NodeFlags.Public | NodeFlags.Private | NodeFlags.Protected)) {
|
||||
if (node.flags & NodeFlags.AccessibilityModifier) {
|
||||
func = getContainingFunction(node);
|
||||
if (!(func.kind === SyntaxKind.Constructor && nodeIsPresent(func.body))) {
|
||||
error(node, Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation);
|
||||
}
|
||||
}
|
||||
if (node.questionToken && isBindingPattern(node.name) && func.body) {
|
||||
error(node, Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature);
|
||||
}
|
||||
if (node.dotDotDotToken) {
|
||||
if (!isArrayType(getTypeOfSymbol(node.symbol))) {
|
||||
error(node, Diagnostics.A_rest_parameter_must_be_of_an_array_type);
|
||||
@@ -7192,17 +7234,20 @@ module ts {
|
||||
checkGrammarIndexSignature(<SignatureDeclaration>node);
|
||||
}
|
||||
// TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled
|
||||
else if (node.kind === SyntaxKind.FunctionType || node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.ConstructorType ||
|
||||
else if (node.kind === SyntaxKind.FunctionType || node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.ConstructorType ||
|
||||
node.kind === SyntaxKind.CallSignature || node.kind === SyntaxKind.Constructor ||
|
||||
node.kind === SyntaxKind.ConstructSignature){
|
||||
checkGrammarFunctionLikeDeclaration(<FunctionLikeDeclaration>node);
|
||||
}
|
||||
|
||||
checkTypeParameters(node.typeParameters);
|
||||
|
||||
forEach(node.parameters, checkParameter);
|
||||
|
||||
if (node.type) {
|
||||
checkSourceElement(node.type);
|
||||
}
|
||||
|
||||
if (produceDiagnostics) {
|
||||
checkCollisionWithArgumentsInGeneratedCode(node);
|
||||
if (compilerOptions.noImplicitAny && !node.type) {
|
||||
@@ -8993,7 +9038,12 @@ module ts {
|
||||
checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
|
||||
checkExportsOnMergedDeclarations(node);
|
||||
var symbol = getSymbolOfNode(node);
|
||||
if (symbol.flags & SymbolFlags.ValueModule && symbol.declarations.length > 1 && !isInAmbientContext(node)) {
|
||||
|
||||
// The following checks only apply on a non-ambient instantiated module declaration.
|
||||
if (symbol.flags & SymbolFlags.ValueModule
|
||||
&& symbol.declarations.length > 1
|
||||
&& !isInAmbientContext(node)
|
||||
&& isInstantiatedModule(node, compilerOptions.preserveConstEnums)) {
|
||||
var classOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol);
|
||||
if (classOrFunc) {
|
||||
if (getSourceFileOfNode(node) !== getSourceFileOfNode(classOrFunc)) {
|
||||
@@ -9004,6 +9054,8 @@ module ts {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Checks for ambient external modules.
|
||||
if (node.name.kind === SyntaxKind.StringLiteral) {
|
||||
if (!isGlobalSourceFile(node.parent)) {
|
||||
error(node.name, Diagnostics.Ambient_external_modules_cannot_be_nested_in_other_modules);
|
||||
@@ -9251,6 +9303,8 @@ module ts {
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.NewExpression:
|
||||
case SyntaxKind.TaggedTemplateExpression:
|
||||
case SyntaxKind.TemplateExpression:
|
||||
case SyntaxKind.TemplateSpan:
|
||||
case SyntaxKind.TypeAssertionExpression:
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
case SyntaxKind.TypeOfExpression:
|
||||
@@ -9794,8 +9848,20 @@ module ts {
|
||||
|
||||
function isUniqueLocalName(name: string, container: Node): boolean {
|
||||
for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) {
|
||||
if (node.locals && hasProperty(node.locals, name) && node.locals[name].flags & (SymbolFlags.Value | SymbolFlags.ExportValue)) {
|
||||
return false;
|
||||
if (node.locals && hasProperty(node.locals, name)) {
|
||||
var symbolWithRelevantName = node.locals[name];
|
||||
if (symbolWithRelevantName.flags & (SymbolFlags.Value | SymbolFlags.ExportValue)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// An import can be emitted too, if it is referenced as a value.
|
||||
// Make sure the name in question does not collide with an import.
|
||||
if (symbolWithRelevantName.flags & SymbolFlags.Import) {
|
||||
var importDeclarationWithRelevantName = <ImportDeclaration>getDeclarationOfKind(symbolWithRelevantName, SyntaxKind.ImportDeclaration);
|
||||
if (isReferencedImportDeclaration(importDeclarationWithRelevantName)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -9995,7 +10061,7 @@ module ts {
|
||||
globalRegExpType = getGlobalType("RegExp");
|
||||
// If we're in ES6 mode, load the TemplateStringsArray.
|
||||
// Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios.
|
||||
globalTemplateStringsArrayType = compilerOptions.target >= ScriptTarget.ES6
|
||||
globalTemplateStringsArrayType = languageVersion >= ScriptTarget.ES6
|
||||
? getGlobalType("TemplateStringsArray")
|
||||
: unknownType;
|
||||
anyArrayType = createArrayType(anyType);
|
||||
@@ -10132,6 +10198,9 @@ module ts {
|
||||
else if (node.kind === SyntaxKind.InterfaceDeclaration && flags & NodeFlags.Ambient) {
|
||||
return grammarErrorOnNode(lastDeclare, Diagnostics.A_declare_modifier_cannot_be_used_with_an_interface_declaration, "declare");
|
||||
}
|
||||
else if (node.kind === SyntaxKind.Parameter && (flags & NodeFlags.AccessibilityModifier) && isBindingPattern((<ParameterDeclaration>node).name)) {
|
||||
return grammarErrorOnNode(node, Diagnostics.A_parameter_property_may_not_be_a_binding_pattern);
|
||||
}
|
||||
}
|
||||
|
||||
function checkGrammarForDisallowedTrailingComma(list: NodeArray<Node>): boolean {
|
||||
@@ -10364,7 +10433,7 @@ module ts {
|
||||
return;
|
||||
|
||||
var computedPropertyName = <ComputedPropertyName>node;
|
||||
if (compilerOptions.target < ScriptTarget.ES6) {
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher);
|
||||
}
|
||||
else if (computedPropertyName.expression.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>computedPropertyName.expression).operator === SyntaxKind.CommaToken) {
|
||||
@@ -10464,7 +10533,7 @@ module ts {
|
||||
|
||||
function checkGrammarAccessor(accessor: MethodDeclaration): boolean {
|
||||
var kind = accessor.kind;
|
||||
if (compilerOptions.target < ScriptTarget.ES5) {
|
||||
if (languageVersion < ScriptTarget.ES5) {
|
||||
return grammarErrorOnNode(accessor.name, Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher);
|
||||
}
|
||||
else if (isInAmbientContext(accessor)) {
|
||||
@@ -10669,7 +10738,7 @@ module ts {
|
||||
return grammarErrorAtPos(getSourceFileOfNode(declarationList), declarations.pos, declarations.end - declarations.pos, Diagnostics.Variable_declaration_list_cannot_be_empty);
|
||||
}
|
||||
|
||||
if (compilerOptions.target < ScriptTarget.ES6) {
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
if (isLet(declarationList)) {
|
||||
return grammarErrorOnFirstToken(declarationList, Diagnostics.let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher);
|
||||
}
|
||||
@@ -10771,7 +10840,7 @@ module ts {
|
||||
function grammarErrorOnFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean {
|
||||
var sourceFile = getSourceFileOfNode(node);
|
||||
if (!hasParseDiagnostics(sourceFile)) {
|
||||
var scanner = createScanner(compilerOptions.target, /*skipTrivia*/ true, sourceFile.text);
|
||||
var scanner = createScanner(languageVersion, /*skipTrivia*/ true, sourceFile.text);
|
||||
var start = scanToken(scanner, node.pos);
|
||||
diagnostics.push(createFileDiagnostic(sourceFile, start, scanner.getTextPos() - start, message, arg0, arg1, arg2));
|
||||
return true;
|
||||
@@ -10913,7 +10982,7 @@ module ts {
|
||||
if (node.parserContextFlags & ParserContextFlags.StrictMode) {
|
||||
return grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_allowed_in_strict_mode);
|
||||
}
|
||||
else if (compilerOptions.target >= ScriptTarget.ES5) {
|
||||
else if (languageVersion >= ScriptTarget.ES5) {
|
||||
return grammarErrorOnNode(node, Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher);
|
||||
}
|
||||
}
|
||||
@@ -10922,7 +10991,7 @@ module ts {
|
||||
function grammarErrorAfterFirstToken(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean {
|
||||
var sourceFile = getSourceFileOfNode(node);
|
||||
if (!hasParseDiagnostics(sourceFile)) {
|
||||
var scanner = createScanner(compilerOptions.target, /*skipTrivia*/ true, sourceFile.text);
|
||||
var scanner = createScanner(languageVersion, /*skipTrivia*/ true, sourceFile.text);
|
||||
scanToken(scanner, node.pos);
|
||||
diagnostics.push(createFileDiagnostic(sourceFile, scanner.getTextPos(), 0, message, arg0, arg1, arg2));
|
||||
return true;
|
||||
|
||||
@@ -33,6 +33,10 @@ module ts {
|
||||
type: "boolean",
|
||||
description: Diagnostics.Print_this_message,
|
||||
},
|
||||
{
|
||||
name: "listFiles",
|
||||
type: "boolean",
|
||||
},
|
||||
{
|
||||
name: "locale",
|
||||
type: "string",
|
||||
@@ -40,6 +44,7 @@ module ts {
|
||||
{
|
||||
name: "mapRoot",
|
||||
type: "string",
|
||||
isFilePath: true,
|
||||
description: Diagnostics.Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations,
|
||||
paramType: Diagnostics.LOCATION,
|
||||
},
|
||||
@@ -67,7 +72,7 @@ module ts {
|
||||
{
|
||||
name: "noImplicitAny",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Warn_on_expressions_and_declarations_with_an_implied_any_type,
|
||||
description: Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type,
|
||||
},
|
||||
{
|
||||
name: "noLib",
|
||||
@@ -90,6 +95,7 @@ module ts {
|
||||
{
|
||||
name: "outDir",
|
||||
type: "string",
|
||||
isFilePath: true,
|
||||
description: Diagnostics.Redirect_output_structure_to_the_directory,
|
||||
paramType: Diagnostics.DIRECTORY,
|
||||
},
|
||||
@@ -98,6 +104,14 @@ module ts {
|
||||
type: "boolean",
|
||||
description: Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code
|
||||
},
|
||||
{
|
||||
name: "project",
|
||||
shortName: "p",
|
||||
type: "string",
|
||||
isFilePath: true,
|
||||
description: Diagnostics.Compile_the_project_in_the_given_directory,
|
||||
paramType: Diagnostics.DIRECTORY
|
||||
},
|
||||
{
|
||||
name: "removeComments",
|
||||
type: "boolean",
|
||||
@@ -111,6 +125,7 @@ module ts {
|
||||
{
|
||||
name: "sourceRoot",
|
||||
type: "string",
|
||||
isFilePath: true,
|
||||
description: Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations,
|
||||
paramType: Diagnostics.LOCATION,
|
||||
},
|
||||
@@ -141,26 +156,19 @@ module ts {
|
||||
}
|
||||
];
|
||||
|
||||
var shortOptionNames: Map<string> = {};
|
||||
var optionNameMap: Map<CommandLineOption> = {};
|
||||
|
||||
forEach(optionDeclarations, option => {
|
||||
optionNameMap[option.name.toLowerCase()] = option;
|
||||
|
||||
if (option.shortName) {
|
||||
shortOptionNames[option.shortName] = option.name;
|
||||
}
|
||||
});
|
||||
|
||||
export function parseCommandLine(commandLine: string[]): ParsedCommandLine {
|
||||
// Set default compiler option values
|
||||
var options: CompilerOptions = {
|
||||
target: ScriptTarget.ES3,
|
||||
module: ModuleKind.None
|
||||
};
|
||||
var options: CompilerOptions = {};
|
||||
var filenames: string[] = [];
|
||||
var errors: Diagnostic[] = [];
|
||||
var shortOptionNames: Map<string> = {};
|
||||
var optionNameMap: Map<CommandLineOption> = {};
|
||||
|
||||
forEach(optionDeclarations, option => {
|
||||
optionNameMap[option.name.toLowerCase()] = option;
|
||||
if (option.shortName) {
|
||||
shortOptionNames[option.shortName] = option.name;
|
||||
}
|
||||
});
|
||||
parseStrings(commandLine);
|
||||
return {
|
||||
options,
|
||||
@@ -256,4 +264,84 @@ module ts {
|
||||
parseStrings(args);
|
||||
}
|
||||
}
|
||||
|
||||
export function readConfigFile(filename: string): any {
|
||||
try {
|
||||
var text = sys.readFile(filename);
|
||||
return /\S/.test(text) ? JSON.parse(text) : {};
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
export function parseConfigFile(json: any, basePath?: string): ParsedCommandLine {
|
||||
var errors: Diagnostic[] = [];
|
||||
|
||||
return {
|
||||
options: getCompilerOptions(),
|
||||
filenames: getFiles(),
|
||||
errors
|
||||
};
|
||||
|
||||
function getCompilerOptions(): CompilerOptions {
|
||||
var options: CompilerOptions = {};
|
||||
var optionNameMap: Map<CommandLineOption> = {};
|
||||
forEach(optionDeclarations, option => {
|
||||
optionNameMap[option.name] = option;
|
||||
});
|
||||
var jsonOptions = json["compilerOptions"];
|
||||
if (jsonOptions) {
|
||||
for (var id in jsonOptions) {
|
||||
if (hasProperty(optionNameMap, id)) {
|
||||
var opt = optionNameMap[id];
|
||||
var optType = opt.type;
|
||||
var value = jsonOptions[id];
|
||||
var expectedType = typeof optType === "string" ? optType : "string";
|
||||
if (typeof value === expectedType) {
|
||||
if (typeof optType !== "string") {
|
||||
var key = value.toLowerCase();
|
||||
if (hasProperty(optType, key)) {
|
||||
value = optType[key];
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic(opt.error));
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
if (opt.isFilePath) {
|
||||
value = normalizePath(combinePaths(basePath, value));
|
||||
}
|
||||
options[opt.name] = value;
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, id, expectedType));
|
||||
}
|
||||
}
|
||||
else {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Unknown_compiler_option_0, id));
|
||||
}
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
function getFiles(): string[] {
|
||||
var files: string[] = [];
|
||||
if (hasProperty(json, "files")) {
|
||||
if (json["files"] instanceof Array) {
|
||||
var files = map(<string[]>json["files"], s => combinePaths(basePath, s));
|
||||
}
|
||||
}
|
||||
else {
|
||||
var sysFiles = sys.readDirectory(basePath, ".ts");
|
||||
for (var i = 0; i < sysFiles.length; i++) {
|
||||
var name = sysFiles[i];
|
||||
if (!fileExtensionIs(name, ".d.ts") || !contains(sysFiles, name.substr(0, name.length - 5) + ".ts")) {
|
||||
files.push(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+20
-1
@@ -178,6 +178,19 @@ module ts {
|
||||
return <T>result;
|
||||
}
|
||||
|
||||
export function extend<T>(first: Map<T>, second: Map<T>): Map<T> {
|
||||
var result: Map<T> = {};
|
||||
for (var id in first) {
|
||||
result[id] = first[id];
|
||||
}
|
||||
for (var id in second) {
|
||||
if (!hasProperty(result, id)) {
|
||||
result[id] = second[id];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function forEachValue<T, U>(map: Map<T>, callback: (value: T) => U): U {
|
||||
var result: U;
|
||||
for (var id in map) {
|
||||
@@ -208,6 +221,12 @@ module ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function copyMap<T>(source: Map<T>, target: Map<T>): void {
|
||||
for (var p in source) {
|
||||
target[p] = source[p];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a map from the elements of an array.
|
||||
*
|
||||
@@ -562,7 +581,7 @@ module ts {
|
||||
export function combinePaths(path1: string, path2: string) {
|
||||
if (!(path1 && path1.length)) return path2;
|
||||
if (!(path2 && path2.length)) return path1;
|
||||
if (path2.charAt(0) === directorySeparator) return path2;
|
||||
if (getRootLength(path2) !== 0) return path2;
|
||||
if (path1.charAt(path1.length - 1) === directorySeparator) return path1 + path2;
|
||||
return path1 + directorySeparator + path2;
|
||||
}
|
||||
|
||||
@@ -146,6 +146,7 @@ module ts {
|
||||
Modifiers_cannot_appear_here: { code: 1184, category: DiagnosticCategory.Error, key: "Modifiers cannot appear here." },
|
||||
Merge_conflict_marker_encountered: { code: 1185, category: DiagnosticCategory.Error, key: "Merge conflict marker encountered." },
|
||||
A_rest_element_cannot_have_an_initializer: { code: 1186, category: DiagnosticCategory.Error, key: "A rest element cannot have an initializer." },
|
||||
A_parameter_property_may_not_be_a_binding_pattern: { code: 1187, category: DiagnosticCategory.Error, key: "A parameter property may not be a binding pattern." },
|
||||
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." },
|
||||
@@ -297,6 +298,7 @@ module ts {
|
||||
Type_0_has_no_property_1: { code: 2460, category: DiagnosticCategory.Error, key: "Type '{0}' has no property '{1}'." },
|
||||
Type_0_is_not_an_array_type: { code: 2461, category: DiagnosticCategory.Error, key: "Type '{0}' is not an array type." },
|
||||
A_rest_element_must_be_last_in_an_array_destructuring_pattern: { code: 2462, category: DiagnosticCategory.Error, key: "A rest element must be last in an array destructuring pattern" },
|
||||
A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: DiagnosticCategory.Error, key: "A binding pattern parameter cannot be optional in an implementation signature." },
|
||||
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}'." },
|
||||
@@ -369,19 +371,22 @@ module ts {
|
||||
Enum_declarations_must_all_be_const_or_non_const: { code: 4082, category: DiagnosticCategory.Error, key: "Enum declarations must all be const or non-const." },
|
||||
In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 4083, category: DiagnosticCategory.Error, key: "In 'const' enum declarations member initializer must be constant expression.", isEarly: true },
|
||||
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: 4084, 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." },
|
||||
Index_expression_arguments_in_const_enums_must_be_of_type_string: { code: 4085, category: DiagnosticCategory.Error, key: "Index expression arguments in 'const' enums must be of type 'string'." },
|
||||
A_const_enum_member_can_only_be_accessed_using_a_string_literal: { code: 4085, category: DiagnosticCategory.Error, key: "A const enum member can only be accessed using a string literal.", isEarly: true },
|
||||
const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 4086, category: DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to a non-finite value." },
|
||||
const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 4087, category: DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to disallowed value 'NaN'." },
|
||||
Property_0_does_not_exist_on_const_enum_1: { code: 4088, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on 'const' enum '{1}'.", isEarly: true },
|
||||
The_current_host_does_not_support_the_0_option: { code: 5001, category: DiagnosticCategory.Error, key: "The current host does not support the '{0}' option." },
|
||||
Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." },
|
||||
Cannot_read_file_0_Colon_1: { code: 5012, category: DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" },
|
||||
Unsupported_file_encoding: { code: 5013, category: DiagnosticCategory.Error, key: "Unsupported file encoding." },
|
||||
Unknown_compiler_option_0: { code: 5023, category: DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." },
|
||||
Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." },
|
||||
Could_not_write_file_0_Colon_1: { code: 5033, category: DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" },
|
||||
Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5038, category: DiagnosticCategory.Error, key: "Option mapRoot cannot be specified without specifying sourcemap option." },
|
||||
Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5039, category: DiagnosticCategory.Error, key: "Option sourceRoot cannot be specified without specifying sourcemap option." },
|
||||
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_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5038, category: DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified without specifying 'sourcemap' option." },
|
||||
Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5039, category: DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option." },
|
||||
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." },
|
||||
Concatenate_and_emit_output_to_single_file: { code: 6001, category: DiagnosticCategory.Message, key: "Concatenate and emit output to single file." },
|
||||
Generates_corresponding_d_ts_file: { code: 6002, category: DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." },
|
||||
Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." },
|
||||
@@ -396,6 +401,7 @@ module ts {
|
||||
Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs' or 'amd'" },
|
||||
Print_this_message: { code: 6017, category: DiagnosticCategory.Message, key: "Print this message." },
|
||||
Print_the_compiler_s_version: { code: 6019, category: DiagnosticCategory.Message, key: "Print the compiler's version." },
|
||||
Compile_the_project_in_the_given_directory: { code: 6020, category: DiagnosticCategory.Message, key: "Compile the project in the given directory." },
|
||||
Syntax_Colon_0: { code: 6023, category: DiagnosticCategory.Message, key: "Syntax: {0}" },
|
||||
options: { code: 6024, category: DiagnosticCategory.Message, key: "options" },
|
||||
file: { code: 6025, category: DiagnosticCategory.Message, key: "file" },
|
||||
@@ -403,7 +409,7 @@ module ts {
|
||||
Options_Colon: { code: 6027, category: DiagnosticCategory.Message, key: "Options:" },
|
||||
Version_0: { code: 6029, category: DiagnosticCategory.Message, key: "Version {0}" },
|
||||
Insert_command_line_options_and_files_from_a_file: { code: 6030, category: DiagnosticCategory.Message, key: "Insert command line options and files from a file." },
|
||||
File_change_detected_Compiling: { code: 6032, category: DiagnosticCategory.Message, key: "File change detected. Compiling..." },
|
||||
File_change_detected_Starting_incremental_compilation: { code: 6032, category: DiagnosticCategory.Message, key: "File change detected. Starting incremental compilation..." },
|
||||
KIND: { code: 6034, category: DiagnosticCategory.Message, key: "KIND" },
|
||||
FILE: { code: 6035, category: DiagnosticCategory.Message, key: "FILE" },
|
||||
VERSION: { code: 6036, category: DiagnosticCategory.Message, key: "VERSION" },
|
||||
@@ -419,7 +425,7 @@ module ts {
|
||||
Unsupported_locale_0: { code: 6049, category: DiagnosticCategory.Error, key: "Unsupported locale '{0}'." },
|
||||
Unable_to_open_file_0: { code: 6050, category: DiagnosticCategory.Error, key: "Unable to open file '{0}'." },
|
||||
Corrupted_locale_file_0: { code: 6051, category: DiagnosticCategory.Error, key: "Corrupted locale file {0}." },
|
||||
Warn_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: DiagnosticCategory.Message, key: "Warn on expressions and declarations with an implied 'any' type." },
|
||||
Raise_error_on_expressions_and_declarations_with_an_implied_any_type: { code: 6052, category: DiagnosticCategory.Message, key: "Raise error on expressions and declarations with an implied 'any' type." },
|
||||
File_0_not_found: { code: 6053, category: DiagnosticCategory.Error, key: "File '{0}' not found." },
|
||||
File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: DiagnosticCategory.Error, key: "File '{0}' must have extension '.ts' or '.d.ts'." },
|
||||
Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." },
|
||||
|
||||
@@ -224,7 +224,7 @@
|
||||
"A 'declare' modifier cannot be used with an import declaration.": {
|
||||
"category": "Error",
|
||||
"code": 1079,
|
||||
"isEarly": true
|
||||
"isEarly": true
|
||||
},
|
||||
"Invalid 'reference' directive syntax.": {
|
||||
"category": "Error",
|
||||
@@ -659,7 +659,7 @@
|
||||
"An implementation cannot be declared in ambient contexts.": {
|
||||
"category": "Error",
|
||||
"code": 1184,
|
||||
"isEarly": true
|
||||
"isEarly": true
|
||||
},
|
||||
"Modifiers cannot appear here.": {
|
||||
"category": "Error",
|
||||
@@ -673,6 +673,10 @@
|
||||
"category": "Error",
|
||||
"code": 1186
|
||||
},
|
||||
"A parameter property may not be a binding pattern.": {
|
||||
"category": "Error",
|
||||
"code": 1187
|
||||
},
|
||||
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
@@ -1282,6 +1286,10 @@
|
||||
"category": "Error",
|
||||
"code": 2462
|
||||
},
|
||||
"A binding pattern parameter cannot be optional in an implementation signature.": {
|
||||
"category": "Error",
|
||||
"code": 2463
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
@@ -1572,9 +1580,10 @@
|
||||
"category": "Error",
|
||||
"code": 4084
|
||||
},
|
||||
"Index expression arguments in 'const' enums must be of type 'string'.": {
|
||||
"A const enum member can only be accessed using a string literal.": {
|
||||
"category": "Error",
|
||||
"code": 4085
|
||||
"code": 4085,
|
||||
"isEarly": true
|
||||
},
|
||||
"'const' enum member initializer was evaluated to a non-finite value.": {
|
||||
"category": "Error",
|
||||
@@ -1584,6 +1593,11 @@
|
||||
"category": "Error",
|
||||
"code": 4087
|
||||
},
|
||||
"Property '{0}' does not exist on 'const' enum '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 4088,
|
||||
"isEarly": true
|
||||
},
|
||||
"The current host does not support the '{0}' option.": {
|
||||
"category": "Error",
|
||||
"code": 5001
|
||||
@@ -1604,26 +1618,34 @@
|
||||
"category": "Error",
|
||||
"code": 5023
|
||||
},
|
||||
"Compiler option '{0}' requires a value of type {1}.": {
|
||||
"category": "Error",
|
||||
"code": 5024
|
||||
},
|
||||
"Could not write file '{0}': {1}": {
|
||||
"category": "Error",
|
||||
"code": 5033
|
||||
},
|
||||
"Option mapRoot cannot be specified without specifying sourcemap option.": {
|
||||
"Option 'mapRoot' cannot be specified without specifying 'sourcemap' option.": {
|
||||
"category": "Error",
|
||||
"code": 5038
|
||||
},
|
||||
"Option sourceRoot cannot be specified without specifying sourcemap option.": {
|
||||
"Option 'sourceRoot' cannot be specified without specifying 'sourcemap' option.": {
|
||||
"category": "Error",
|
||||
"code": 5039
|
||||
},
|
||||
"Option noEmit cannot be specified with option out or outDir.": {
|
||||
"Option 'noEmit' cannot be specified with option 'out' or 'outDir'.": {
|
||||
"category": "Error",
|
||||
"code": 5040
|
||||
},
|
||||
"Option noEmit cannot be specified with option declaration.": {
|
||||
"Option 'noEmit' cannot be specified with option 'declaration'.": {
|
||||
"category": "Error",
|
||||
"code": 5041
|
||||
},
|
||||
"Option 'project' cannot be mixed with source files on a command line.": {
|
||||
"category": "Error",
|
||||
"code": 5042
|
||||
},
|
||||
"Concatenate and emit output to single file.": {
|
||||
"category": "Message",
|
||||
"code": 6001
|
||||
@@ -1680,6 +1702,10 @@
|
||||
"category": "Message",
|
||||
"code": 6019
|
||||
},
|
||||
"Compile the project in the given directory.": {
|
||||
"category": "Message",
|
||||
"code": 6020
|
||||
},
|
||||
"Syntax: {0}": {
|
||||
"category": "Message",
|
||||
"code": 6023
|
||||
@@ -1708,7 +1734,7 @@
|
||||
"category": "Message",
|
||||
"code": 6030
|
||||
},
|
||||
"File change detected. Compiling...": {
|
||||
"File change detected. Starting incremental compilation...": {
|
||||
"category": "Message",
|
||||
"code": 6032
|
||||
},
|
||||
@@ -1772,7 +1798,7 @@
|
||||
"category": "Error",
|
||||
"code": 6051
|
||||
},
|
||||
"Warn on expressions and declarations with an implied 'any' type.": {
|
||||
"Raise error on expressions and declarations with an implied 'any' type.": {
|
||||
"category": "Message",
|
||||
"code": 6052
|
||||
},
|
||||
|
||||
+64
-35
@@ -170,9 +170,10 @@ module ts {
|
||||
function writeCommentRange(currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string){
|
||||
if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) {
|
||||
var firstCommentLineAndCharacter = currentSourceFile.getLineAndCharacterFromPosition(comment.pos);
|
||||
var lastLine = currentSourceFile.getLineStarts().length;
|
||||
var firstCommentLineIndent: number;
|
||||
for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) {
|
||||
var nextLineStart = currentSourceFile.getPositionFromLineAndCharacter(currentLine + 1, /*character*/1);
|
||||
var nextLineStart = currentLine === lastLine ? (comment.end + 1) : currentSourceFile.getPositionFromLineAndCharacter(currentLine + 1, /*character*/1);
|
||||
|
||||
if (pos !== comment.pos) {
|
||||
// If we are not emitting first line, we need to write the spaces to adjust the alignment
|
||||
@@ -339,6 +340,7 @@ module ts {
|
||||
function emitDeclarations(host: EmitHost, resolver: EmitResolver, diagnostics: Diagnostic[], jsFilePath: string, root?: SourceFile): DeclarationEmit {
|
||||
var newLine = host.getNewLine();
|
||||
var compilerOptions = host.getCompilerOptions();
|
||||
var languageVersion = compilerOptions.target || ScriptTarget.ES3;
|
||||
|
||||
var write: (s: string) => void;
|
||||
var writeLine: () => void;
|
||||
@@ -1461,18 +1463,7 @@ module ts {
|
||||
referencePathsOutput,
|
||||
}
|
||||
}
|
||||
|
||||
export interface EmitHost extends ScriptReferenceHost {
|
||||
getSourceFiles(): SourceFile[];
|
||||
isEmitBlocked(sourceFile?: SourceFile): boolean;
|
||||
|
||||
getCommonSourceDirectory(): string;
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
getNewLine(): string;
|
||||
|
||||
writeFile(filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
}
|
||||
|
||||
|
||||
export function getDeclarationDiagnostics(host: EmitHost, resolver: EmitResolver, targetSourceFile: SourceFile): Diagnostic[] {
|
||||
var diagnostics: Diagnostic[] = [];
|
||||
var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, ".js");
|
||||
@@ -1484,6 +1475,7 @@ module ts {
|
||||
export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile?: SourceFile): EmitResult {
|
||||
// var program = resolver.getProgram();
|
||||
var compilerOptions = host.getCompilerOptions();
|
||||
var languageVersion = compilerOptions.target || ScriptTarget.ES3;
|
||||
var sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap ? [] : undefined;
|
||||
var diagnostics: Diagnostic[] = [];
|
||||
var newLine = host.getNewLine();
|
||||
@@ -2032,14 +2024,14 @@ module ts {
|
||||
}
|
||||
|
||||
function emitLiteral(node: LiteralExpression) {
|
||||
var text = compilerOptions.target < ScriptTarget.ES6 && isTemplateLiteralKind(node.kind) ? getTemplateLiteralAsStringLiteral(node) :
|
||||
var text = languageVersion < ScriptTarget.ES6 && isTemplateLiteralKind(node.kind) ? getTemplateLiteralAsStringLiteral(node) :
|
||||
node.parent ? getSourceTextOfNodeFromSourceFile(currentSourceFile, node) :
|
||||
node.text;
|
||||
if (compilerOptions.sourceMap && (node.kind === SyntaxKind.StringLiteral || isTemplateLiteralKind(node.kind))) {
|
||||
writer.writeLiteral(text);
|
||||
}
|
||||
// For version below ES6, emit binary integer literal and octal integer literal in canonical form
|
||||
else if (compilerOptions.target < ScriptTarget.ES6 && node.kind === SyntaxKind.NumericLiteral && isBinaryOrOctalIntegerLiteral(text)) {
|
||||
else if (languageVersion < ScriptTarget.ES6 && node.kind === SyntaxKind.NumericLiteral && isBinaryOrOctalIntegerLiteral(text)) {
|
||||
write(node.text);
|
||||
}
|
||||
else {
|
||||
@@ -2054,7 +2046,7 @@ module ts {
|
||||
function emitTemplateExpression(node: TemplateExpression): void {
|
||||
// In ES6 mode and above, we can simply emit each portion of a template in order, but in
|
||||
// ES3 & ES5 we must convert the template expression into a series of string concatenations.
|
||||
if (compilerOptions.target >= ScriptTarget.ES6) {
|
||||
if (languageVersion >= ScriptTarget.ES6) {
|
||||
forEachChild(node, emit);
|
||||
return;
|
||||
}
|
||||
@@ -2068,9 +2060,15 @@ module ts {
|
||||
write("(");
|
||||
}
|
||||
|
||||
emitLiteral(node.head);
|
||||
var headEmitted = false;
|
||||
if (shouldEmitTemplateHead()) {
|
||||
emitLiteral(node.head);
|
||||
headEmitted = true;
|
||||
}
|
||||
|
||||
for (var i = 0; i < node.templateSpans.length; i++) {
|
||||
var templateSpan = node.templateSpans[i];
|
||||
|
||||
forEach(node.templateSpans, templateSpan => {
|
||||
// Check if the expression has operands and binds its operands less closely than binary '+'.
|
||||
// If it does, we need to wrap the expression in parentheses. Otherwise, something like
|
||||
// `abc${ 1 << 2 }`
|
||||
@@ -2082,7 +2080,14 @@ module ts {
|
||||
// "abc" + (1 << 2) + ""
|
||||
var needsParens = templateSpan.expression.kind !== SyntaxKind.ParenthesizedExpression
|
||||
&& comparePrecedenceToBinaryPlus(templateSpan.expression) !== Comparison.GreaterThan;
|
||||
write(" + ");
|
||||
|
||||
if (i > 0 || headEmitted) {
|
||||
// If this is the first span and the head was not emitted, then this templateSpan's
|
||||
// expression will be the first to be emitted. Don't emit the preceding ' + ' in that
|
||||
// case.
|
||||
write(" + ");
|
||||
}
|
||||
|
||||
emitParenthesized(templateSpan.expression, needsParens);
|
||||
// Only emit if the literal is non-empty.
|
||||
// The binary '+' operator is left-associative, so the first string concatenation
|
||||
@@ -2092,12 +2097,34 @@ module ts {
|
||||
write(" + ")
|
||||
emitLiteral(templateSpan.literal);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (emitOuterParens) {
|
||||
write(")");
|
||||
}
|
||||
|
||||
function shouldEmitTemplateHead() {
|
||||
// If this expression has an empty head literal and the first template span has a non-empty
|
||||
// literal, then emitting the empty head literal is not necessary.
|
||||
// `${ foo } and ${ bar }`
|
||||
// can be emitted as
|
||||
// foo + " and " + bar
|
||||
// This is because it is only required that one of the first two operands in the emit
|
||||
// output must be a string literal, so that the other operand and all following operands
|
||||
// are forced into strings.
|
||||
//
|
||||
// If the first template span has an empty literal, then the head must still be emitted.
|
||||
// `${ foo }${ bar }`
|
||||
// must still be emitted as
|
||||
// "" + foo + bar
|
||||
|
||||
// There is always atleast one templateSpan in this code path, since
|
||||
// NoSubstitutionTemplateLiterals are directly emitted via emitLiteral()
|
||||
Debug.assert(node.templateSpans.length !== 0);
|
||||
|
||||
return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0;
|
||||
}
|
||||
|
||||
function templateNeedsParens(template: TemplateExpression, parent: Expression) {
|
||||
switch (parent.kind) {
|
||||
case SyntaxKind.CallExpression:
|
||||
@@ -2117,7 +2144,8 @@ module ts {
|
||||
* or equal precedence to the binary '+' operator
|
||||
*/
|
||||
function comparePrecedenceToBinaryPlus(expression: Expression): Comparison {
|
||||
// All binary expressions have lower precedence than '+' apart from '*', '/', and '%'.
|
||||
// All binary expressions have lower precedence than '+' apart from '*', '/', and '%'
|
||||
// which have greater precedence and '-' which has equal precedence.
|
||||
// All unary operators have a higher precedence apart from yield.
|
||||
// Arrow functions and conditionals have a lower precedence,
|
||||
// although we convert the former into regular function expressions in ES5 mode,
|
||||
@@ -2125,7 +2153,7 @@ module ts {
|
||||
//
|
||||
// TODO (drosen): Note that we need to account for the upcoming 'yield' and
|
||||
// spread ('...') unary operators that are anticipated for ES6.
|
||||
Debug.assert(compilerOptions.target <= ScriptTarget.ES5);
|
||||
Debug.assert(languageVersion < ScriptTarget.ES6);
|
||||
switch (expression.kind) {
|
||||
case SyntaxKind.BinaryExpression:
|
||||
switch ((<BinaryExpression>expression).operator) {
|
||||
@@ -2134,6 +2162,7 @@ module ts {
|
||||
case SyntaxKind.PercentToken:
|
||||
return Comparison.GreaterThan;
|
||||
case SyntaxKind.PlusToken:
|
||||
case SyntaxKind.MinusToken:
|
||||
return Comparison.EqualTo;
|
||||
default:
|
||||
return Comparison.LessThan;
|
||||
@@ -2309,7 +2338,7 @@ module ts {
|
||||
write("[]");
|
||||
return;
|
||||
}
|
||||
if (compilerOptions.target >= ScriptTarget.ES6) {
|
||||
if (languageVersion >= ScriptTarget.ES6) {
|
||||
write("[");
|
||||
emitList(elements, 0, elements.length, /*multiLine*/(node.flags & NodeFlags.MultiLine) !== 0,
|
||||
/*trailingComma*/ elements.hasTrailingComma);
|
||||
@@ -2359,7 +2388,7 @@ module ts {
|
||||
write(" ");
|
||||
}
|
||||
emitList(properties, 0, properties.length, /*multiLine*/ multiLine,
|
||||
/*trailingComma*/ properties.hasTrailingComma && compilerOptions.target >= ScriptTarget.ES5);
|
||||
/*trailingComma*/ properties.hasTrailingComma && languageVersion >= ScriptTarget.ES5);
|
||||
if (!multiLine) {
|
||||
write(" ");
|
||||
}
|
||||
@@ -2379,7 +2408,7 @@ module ts {
|
||||
}
|
||||
emitLeadingComments(node);
|
||||
emit(node.name);
|
||||
if (compilerOptions.target < ScriptTarget.ES6) {
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
write(": function ");
|
||||
}
|
||||
emitSignatureAndBody(node);
|
||||
@@ -2405,7 +2434,7 @@ module ts {
|
||||
// export var obj = { y };
|
||||
// }
|
||||
// The short-hand property in obj need to emit as such ... = { y : m.y } regardless of the TargetScript version
|
||||
if (compilerOptions.target < ScriptTarget.ES6 || resolver.getExpressionNamePrefix(node.name)) {
|
||||
if (languageVersion < ScriptTarget.ES6 || resolver.getExpressionNamePrefix(node.name)) {
|
||||
// Emit identifier as an identifier
|
||||
write(": ");
|
||||
// Even though this is stored as identifier treat it as an expression
|
||||
@@ -2487,7 +2516,7 @@ module ts {
|
||||
}
|
||||
|
||||
function emitTaggedTemplateExpression(node: TaggedTemplateExpression): void {
|
||||
Debug.assert(compilerOptions.target >= ScriptTarget.ES6, "Trying to emit a tagged template in pre-ES6 mode.");
|
||||
Debug.assert(languageVersion >= ScriptTarget.ES6, "Trying to emit a tagged template in pre-ES6 mode.");
|
||||
emit(node.tag);
|
||||
write(" ");
|
||||
emit(node.template);
|
||||
@@ -2579,7 +2608,7 @@ module ts {
|
||||
|
||||
|
||||
function emitBinaryExpression(node: BinaryExpression) {
|
||||
if (compilerOptions.target < ScriptTarget.ES6 && node.operator === SyntaxKind.EqualsToken &&
|
||||
if (languageVersion < ScriptTarget.ES6 && node.operator === SyntaxKind.EqualsToken &&
|
||||
(node.left.kind === SyntaxKind.ObjectLiteralExpression || node.left.kind === SyntaxKind.ArrayLiteralExpression)) {
|
||||
emitDestructuring(node);
|
||||
}
|
||||
@@ -3075,7 +3104,7 @@ module ts {
|
||||
function emitVariableDeclaration(node: VariableDeclaration) {
|
||||
emitLeadingComments(node);
|
||||
if (isBindingPattern(node.name)) {
|
||||
if (compilerOptions.target < ScriptTarget.ES6) {
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
emitDestructuring(node);
|
||||
}
|
||||
else {
|
||||
@@ -3110,7 +3139,7 @@ module ts {
|
||||
|
||||
function emitParameter(node: ParameterDeclaration) {
|
||||
emitLeadingComments(node);
|
||||
if (compilerOptions.target < ScriptTarget.ES6) {
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
if (isBindingPattern(node.name)) {
|
||||
var name = createTempVariable(node);
|
||||
if (!tempParameters) {
|
||||
@@ -3134,7 +3163,7 @@ module ts {
|
||||
}
|
||||
|
||||
function emitDefaultValueAssignments(node: FunctionLikeDeclaration) {
|
||||
if (compilerOptions.target < ScriptTarget.ES6) {
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
var tempIndex = 0;
|
||||
forEach(node.parameters, p => {
|
||||
if (isBindingPattern(p.name)) {
|
||||
@@ -3164,7 +3193,7 @@ module ts {
|
||||
}
|
||||
|
||||
function emitRestParameter(node: FunctionLikeDeclaration) {
|
||||
if (compilerOptions.target < ScriptTarget.ES6 && hasRestParameters(node)) {
|
||||
if (languageVersion < ScriptTarget.ES6 && hasRestParameters(node)) {
|
||||
var restIndex = node.parameters.length - 1;
|
||||
var restParam = node.parameters[restIndex];
|
||||
var tempName = createTempVariable(node, /*forLoopVariable*/ true).text;
|
||||
@@ -3253,7 +3282,7 @@ module ts {
|
||||
write("(");
|
||||
if (node) {
|
||||
var parameters = node.parameters;
|
||||
var omitCount = compilerOptions.target < ScriptTarget.ES6 && hasRestParameters(node) ? 1 : 0;
|
||||
var omitCount = languageVersion < ScriptTarget.ES6 && hasRestParameters(node) ? 1 : 0;
|
||||
emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false);
|
||||
}
|
||||
write(")");
|
||||
@@ -3701,8 +3730,8 @@ module ts {
|
||||
}
|
||||
|
||||
function emitModuleDeclaration(node: ModuleDeclaration) {
|
||||
var shouldEmit = getModuleInstanceState(node) === ModuleInstanceState.Instantiated ||
|
||||
(getModuleInstanceState(node) === ModuleInstanceState.ConstEnumOnly && compilerOptions.preserveConstEnums);
|
||||
// Emit only if this module is non-ambient.
|
||||
var shouldEmit = isInstantiatedModule(node, compilerOptions.preserveConstEnums);
|
||||
|
||||
if (!shouldEmit) {
|
||||
return emitPinnedOrTripleSlashComments(node);
|
||||
|
||||
+167
-157
@@ -12,43 +12,50 @@ module ts {
|
||||
return new (getNodeConstructor(kind))();
|
||||
}
|
||||
|
||||
function visitNode<T>(cbNode: (node: Node) => T, node: Node): T {
|
||||
if (node) {
|
||||
return cbNode(node);
|
||||
}
|
||||
}
|
||||
|
||||
function visitNodeArray<T>(cbNodes: (nodes: Node[]) => T, nodes: Node[]) {
|
||||
if (nodes) {
|
||||
return cbNodes(nodes);
|
||||
}
|
||||
}
|
||||
|
||||
function visitEachNode<T>(cbNode: (node: Node) => T, nodes: Node[]) {
|
||||
if (nodes) {
|
||||
for (var i = 0, len = nodes.length; i < len; i++) {
|
||||
var result = cbNode(nodes[i]);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes
|
||||
// stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise,
|
||||
// embedded arrays are flattened and the 'cbNode' callback is invoked for each element. If a callback returns
|
||||
// a truthy value, iteration stops and that value is returned. Otherwise, undefined is returned.
|
||||
export function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodes?: (nodes: Node[]) => T): T {
|
||||
function child(node: Node): T {
|
||||
if (node) {
|
||||
return cbNode(node);
|
||||
}
|
||||
}
|
||||
function children(nodes: Node[]) {
|
||||
if (nodes) {
|
||||
if (cbNodes) {
|
||||
return cbNodes(nodes);
|
||||
}
|
||||
|
||||
for (var i = 0, len = nodes.length; i < len; i++) {
|
||||
var result = cbNode(nodes[i])
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
export function forEachChild<T>(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T {
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
// The visitXXX functions could be written as local functions that close over the cbNode and cbNodeArray
|
||||
// callback parameters, but that causes a closure allocation for each invocation with noticeable effects
|
||||
// on performance.
|
||||
var visitNodes: (cb: (node: Node | Node[]) => T, nodes: Node[]) => T = cbNodeArray ? visitNodeArray : visitEachNode;
|
||||
var cbNodes = cbNodeArray || cbNode;
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.QualifiedName:
|
||||
return child((<QualifiedName>node).left) ||
|
||||
child((<QualifiedName>node).right);
|
||||
return visitNode(cbNode, (<QualifiedName>node).left) ||
|
||||
visitNode(cbNode, (<QualifiedName>node).right);
|
||||
case SyntaxKind.TypeParameter:
|
||||
return child((<TypeParameterDeclaration>node).name) ||
|
||||
child((<TypeParameterDeclaration>node).constraint) ||
|
||||
child((<TypeParameterDeclaration>node).expression);
|
||||
return visitNode(cbNode, (<TypeParameterDeclaration>node).name) ||
|
||||
visitNode(cbNode, (<TypeParameterDeclaration>node).constraint) ||
|
||||
visitNode(cbNode, (<TypeParameterDeclaration>node).expression);
|
||||
case SyntaxKind.Parameter:
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
@@ -56,22 +63,22 @@ module ts {
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
case SyntaxKind.BindingElement:
|
||||
return children(node.modifiers) ||
|
||||
child((<VariableLikeDeclaration>node).propertyName) ||
|
||||
child((<VariableLikeDeclaration>node).dotDotDotToken) ||
|
||||
child((<VariableLikeDeclaration>node).name) ||
|
||||
child((<VariableLikeDeclaration>node).questionToken) ||
|
||||
child((<VariableLikeDeclaration>node).type) ||
|
||||
child((<VariableLikeDeclaration>node).initializer);
|
||||
return visitNodes(cbNodes, node.modifiers) ||
|
||||
visitNode(cbNode, (<VariableLikeDeclaration>node).propertyName) ||
|
||||
visitNode(cbNode, (<VariableLikeDeclaration>node).dotDotDotToken) ||
|
||||
visitNode(cbNode, (<VariableLikeDeclaration>node).name) ||
|
||||
visitNode(cbNode, (<VariableLikeDeclaration>node).questionToken) ||
|
||||
visitNode(cbNode, (<VariableLikeDeclaration>node).type) ||
|
||||
visitNode(cbNode, (<VariableLikeDeclaration>node).initializer);
|
||||
case SyntaxKind.FunctionType:
|
||||
case SyntaxKind.ConstructorType:
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
case SyntaxKind.IndexSignature:
|
||||
return children(node.modifiers) ||
|
||||
children((<SignatureDeclaration>node).typeParameters) ||
|
||||
children((<SignatureDeclaration>node).parameters) ||
|
||||
child((<SignatureDeclaration>node).type);
|
||||
return visitNodes(cbNodes, node.modifiers) ||
|
||||
visitNodes(cbNodes, (<SignatureDeclaration>node).typeParameters) ||
|
||||
visitNodes(cbNodes, (<SignatureDeclaration>node).parameters) ||
|
||||
visitNode(cbNode, (<SignatureDeclaration>node).type);
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.Constructor:
|
||||
@@ -80,182 +87,182 @@ module ts {
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
return children(node.modifiers) ||
|
||||
child((<FunctionLikeDeclaration>node).asteriskToken) ||
|
||||
child((<FunctionLikeDeclaration>node).name) ||
|
||||
child((<FunctionLikeDeclaration>node).questionToken) ||
|
||||
children((<FunctionLikeDeclaration>node).typeParameters) ||
|
||||
children((<FunctionLikeDeclaration>node).parameters) ||
|
||||
child((<FunctionLikeDeclaration>node).type) ||
|
||||
child((<FunctionLikeDeclaration>node).body);
|
||||
return visitNodes(cbNodes, node.modifiers) ||
|
||||
visitNode(cbNode, (<FunctionLikeDeclaration>node).asteriskToken) ||
|
||||
visitNode(cbNode, (<FunctionLikeDeclaration>node).name) ||
|
||||
visitNode(cbNode, (<FunctionLikeDeclaration>node).questionToken) ||
|
||||
visitNodes(cbNodes, (<FunctionLikeDeclaration>node).typeParameters) ||
|
||||
visitNodes(cbNodes, (<FunctionLikeDeclaration>node).parameters) ||
|
||||
visitNode(cbNode, (<FunctionLikeDeclaration>node).type) ||
|
||||
visitNode(cbNode, (<FunctionLikeDeclaration>node).body);
|
||||
case SyntaxKind.TypeReference:
|
||||
return child((<TypeReferenceNode>node).typeName) ||
|
||||
children((<TypeReferenceNode>node).typeArguments);
|
||||
return visitNode(cbNode, (<TypeReferenceNode>node).typeName) ||
|
||||
visitNodes(cbNodes, (<TypeReferenceNode>node).typeArguments);
|
||||
case SyntaxKind.TypeQuery:
|
||||
return child((<TypeQueryNode>node).exprName);
|
||||
return visitNode(cbNode, (<TypeQueryNode>node).exprName);
|
||||
case SyntaxKind.TypeLiteral:
|
||||
return children((<TypeLiteralNode>node).members);
|
||||
return visitNodes(cbNodes, (<TypeLiteralNode>node).members);
|
||||
case SyntaxKind.ArrayType:
|
||||
return child((<ArrayTypeNode>node).elementType);
|
||||
return visitNode(cbNode, (<ArrayTypeNode>node).elementType);
|
||||
case SyntaxKind.TupleType:
|
||||
return children((<TupleTypeNode>node).elementTypes);
|
||||
return visitNodes(cbNodes, (<TupleTypeNode>node).elementTypes);
|
||||
case SyntaxKind.UnionType:
|
||||
return children((<UnionTypeNode>node).types);
|
||||
return visitNodes(cbNodes, (<UnionTypeNode>node).types);
|
||||
case SyntaxKind.ParenthesizedType:
|
||||
return child((<ParenthesizedTypeNode>node).type);
|
||||
return visitNode(cbNode, (<ParenthesizedTypeNode>node).type);
|
||||
case SyntaxKind.ObjectBindingPattern:
|
||||
case SyntaxKind.ArrayBindingPattern:
|
||||
return children((<BindingPattern>node).elements);
|
||||
return visitNodes(cbNodes, (<BindingPattern>node).elements);
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
return children((<ArrayLiteralExpression>node).elements);
|
||||
return visitNodes(cbNodes, (<ArrayLiteralExpression>node).elements);
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
return children((<ObjectLiteralExpression>node).properties);
|
||||
return visitNodes(cbNodes, (<ObjectLiteralExpression>node).properties);
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
return child((<PropertyAccessExpression>node).expression) ||
|
||||
child((<PropertyAccessExpression>node).name);
|
||||
return visitNode(cbNode, (<PropertyAccessExpression>node).expression) ||
|
||||
visitNode(cbNode, (<PropertyAccessExpression>node).name);
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
return child((<ElementAccessExpression>node).expression) ||
|
||||
child((<ElementAccessExpression>node).argumentExpression);
|
||||
return visitNode(cbNode, (<ElementAccessExpression>node).expression) ||
|
||||
visitNode(cbNode, (<ElementAccessExpression>node).argumentExpression);
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.NewExpression:
|
||||
return child((<CallExpression>node).expression) ||
|
||||
children((<CallExpression>node).typeArguments) ||
|
||||
children((<CallExpression>node).arguments);
|
||||
return visitNode(cbNode, (<CallExpression>node).expression) ||
|
||||
visitNodes(cbNodes, (<CallExpression>node).typeArguments) ||
|
||||
visitNodes(cbNodes, (<CallExpression>node).arguments);
|
||||
case SyntaxKind.TaggedTemplateExpression:
|
||||
return child((<TaggedTemplateExpression>node).tag) ||
|
||||
child((<TaggedTemplateExpression>node).template);
|
||||
return visitNode(cbNode, (<TaggedTemplateExpression>node).tag) ||
|
||||
visitNode(cbNode, (<TaggedTemplateExpression>node).template);
|
||||
case SyntaxKind.TypeAssertionExpression:
|
||||
return child((<TypeAssertion>node).type) ||
|
||||
child((<TypeAssertion>node).expression);
|
||||
return visitNode(cbNode, (<TypeAssertion>node).type) ||
|
||||
visitNode(cbNode, (<TypeAssertion>node).expression);
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
return child((<ParenthesizedExpression>node).expression);
|
||||
return visitNode(cbNode, (<ParenthesizedExpression>node).expression);
|
||||
case SyntaxKind.DeleteExpression:
|
||||
return child((<DeleteExpression>node).expression);
|
||||
return visitNode(cbNode, (<DeleteExpression>node).expression);
|
||||
case SyntaxKind.TypeOfExpression:
|
||||
return child((<TypeOfExpression>node).expression);
|
||||
return visitNode(cbNode, (<TypeOfExpression>node).expression);
|
||||
case SyntaxKind.VoidExpression:
|
||||
return child((<VoidExpression>node).expression);
|
||||
return visitNode(cbNode, (<VoidExpression>node).expression);
|
||||
case SyntaxKind.PrefixUnaryExpression:
|
||||
return child((<PrefixUnaryExpression>node).operand);
|
||||
return visitNode(cbNode, (<PrefixUnaryExpression>node).operand);
|
||||
case SyntaxKind.YieldExpression:
|
||||
return child((<YieldExpression>node).asteriskToken) ||
|
||||
child((<YieldExpression>node).expression);
|
||||
return visitNode(cbNode, (<YieldExpression>node).asteriskToken) ||
|
||||
visitNode(cbNode, (<YieldExpression>node).expression);
|
||||
case SyntaxKind.PostfixUnaryExpression:
|
||||
return child((<PostfixUnaryExpression>node).operand);
|
||||
return visitNode(cbNode, (<PostfixUnaryExpression>node).operand);
|
||||
case SyntaxKind.BinaryExpression:
|
||||
return child((<BinaryExpression>node).left) ||
|
||||
child((<BinaryExpression>node).right);
|
||||
return visitNode(cbNode, (<BinaryExpression>node).left) ||
|
||||
visitNode(cbNode, (<BinaryExpression>node).right);
|
||||
case SyntaxKind.ConditionalExpression:
|
||||
return child((<ConditionalExpression>node).condition) ||
|
||||
child((<ConditionalExpression>node).whenTrue) ||
|
||||
child((<ConditionalExpression>node).whenFalse);
|
||||
return visitNode(cbNode, (<ConditionalExpression>node).condition) ||
|
||||
visitNode(cbNode, (<ConditionalExpression>node).whenTrue) ||
|
||||
visitNode(cbNode, (<ConditionalExpression>node).whenFalse);
|
||||
case SyntaxKind.SpreadElementExpression:
|
||||
return child((<SpreadElementExpression>node).expression);
|
||||
return visitNode(cbNode, (<SpreadElementExpression>node).expression);
|
||||
case SyntaxKind.Block:
|
||||
case SyntaxKind.ModuleBlock:
|
||||
return children((<Block>node).statements);
|
||||
return visitNodes(cbNodes, (<Block>node).statements);
|
||||
case SyntaxKind.SourceFile:
|
||||
return children((<SourceFile>node).statements) ||
|
||||
child((<SourceFile>node).endOfFileToken);
|
||||
return visitNodes(cbNodes, (<SourceFile>node).statements) ||
|
||||
visitNode(cbNode, (<SourceFile>node).endOfFileToken);
|
||||
case SyntaxKind.VariableStatement:
|
||||
return children(node.modifiers) ||
|
||||
child((<VariableStatement>node).declarationList);
|
||||
return visitNodes(cbNodes, node.modifiers) ||
|
||||
visitNode(cbNode, (<VariableStatement>node).declarationList);
|
||||
case SyntaxKind.VariableDeclarationList:
|
||||
return children((<VariableDeclarationList>node).declarations);
|
||||
return visitNodes(cbNodes, (<VariableDeclarationList>node).declarations);
|
||||
case SyntaxKind.ExpressionStatement:
|
||||
return child((<ExpressionStatement>node).expression);
|
||||
return visitNode(cbNode, (<ExpressionStatement>node).expression);
|
||||
case SyntaxKind.IfStatement:
|
||||
return child((<IfStatement>node).expression) ||
|
||||
child((<IfStatement>node).thenStatement) ||
|
||||
child((<IfStatement>node).elseStatement);
|
||||
return visitNode(cbNode, (<IfStatement>node).expression) ||
|
||||
visitNode(cbNode, (<IfStatement>node).thenStatement) ||
|
||||
visitNode(cbNode, (<IfStatement>node).elseStatement);
|
||||
case SyntaxKind.DoStatement:
|
||||
return child((<DoStatement>node).statement) ||
|
||||
child((<DoStatement>node).expression);
|
||||
return visitNode(cbNode, (<DoStatement>node).statement) ||
|
||||
visitNode(cbNode, (<DoStatement>node).expression);
|
||||
case SyntaxKind.WhileStatement:
|
||||
return child((<WhileStatement>node).expression) ||
|
||||
child((<WhileStatement>node).statement);
|
||||
return visitNode(cbNode, (<WhileStatement>node).expression) ||
|
||||
visitNode(cbNode, (<WhileStatement>node).statement);
|
||||
case SyntaxKind.ForStatement:
|
||||
return child((<ForStatement>node).initializer) ||
|
||||
child((<ForStatement>node).condition) ||
|
||||
child((<ForStatement>node).iterator) ||
|
||||
child((<ForStatement>node).statement);
|
||||
return visitNode(cbNode, (<ForStatement>node).initializer) ||
|
||||
visitNode(cbNode, (<ForStatement>node).condition) ||
|
||||
visitNode(cbNode, (<ForStatement>node).iterator) ||
|
||||
visitNode(cbNode, (<ForStatement>node).statement);
|
||||
case SyntaxKind.ForInStatement:
|
||||
return child((<ForInStatement>node).initializer) ||
|
||||
child((<ForInStatement>node).expression) ||
|
||||
child((<ForInStatement>node).statement);
|
||||
return visitNode(cbNode, (<ForInStatement>node).initializer) ||
|
||||
visitNode(cbNode, (<ForInStatement>node).expression) ||
|
||||
visitNode(cbNode, (<ForInStatement>node).statement);
|
||||
case SyntaxKind.ContinueStatement:
|
||||
case SyntaxKind.BreakStatement:
|
||||
return child((<BreakOrContinueStatement>node).label);
|
||||
return visitNode(cbNode, (<BreakOrContinueStatement>node).label);
|
||||
case SyntaxKind.ReturnStatement:
|
||||
return child((<ReturnStatement>node).expression);
|
||||
return visitNode(cbNode, (<ReturnStatement>node).expression);
|
||||
case SyntaxKind.WithStatement:
|
||||
return child((<WithStatement>node).expression) ||
|
||||
child((<WithStatement>node).statement);
|
||||
return visitNode(cbNode, (<WithStatement>node).expression) ||
|
||||
visitNode(cbNode, (<WithStatement>node).statement);
|
||||
case SyntaxKind.SwitchStatement:
|
||||
return child((<SwitchStatement>node).expression) ||
|
||||
children((<SwitchStatement>node).clauses);
|
||||
return visitNode(cbNode, (<SwitchStatement>node).expression) ||
|
||||
visitNodes(cbNodes, (<SwitchStatement>node).clauses);
|
||||
case SyntaxKind.CaseClause:
|
||||
return child((<CaseClause>node).expression) ||
|
||||
children((<CaseClause>node).statements);
|
||||
return visitNode(cbNode, (<CaseClause>node).expression) ||
|
||||
visitNodes(cbNodes, (<CaseClause>node).statements);
|
||||
case SyntaxKind.DefaultClause:
|
||||
return children((<DefaultClause>node).statements);
|
||||
return visitNodes(cbNodes, (<DefaultClause>node).statements);
|
||||
case SyntaxKind.LabeledStatement:
|
||||
return child((<LabeledStatement>node).label) ||
|
||||
child((<LabeledStatement>node).statement);
|
||||
return visitNode(cbNode, (<LabeledStatement>node).label) ||
|
||||
visitNode(cbNode, (<LabeledStatement>node).statement);
|
||||
case SyntaxKind.ThrowStatement:
|
||||
return child((<ThrowStatement>node).expression);
|
||||
return visitNode(cbNode, (<ThrowStatement>node).expression);
|
||||
case SyntaxKind.TryStatement:
|
||||
return child((<TryStatement>node).tryBlock) ||
|
||||
child((<TryStatement>node).catchClause) ||
|
||||
child((<TryStatement>node).finallyBlock);
|
||||
return visitNode(cbNode, (<TryStatement>node).tryBlock) ||
|
||||
visitNode(cbNode, (<TryStatement>node).catchClause) ||
|
||||
visitNode(cbNode, (<TryStatement>node).finallyBlock);
|
||||
case SyntaxKind.CatchClause:
|
||||
return child((<CatchClause>node).name) ||
|
||||
child((<CatchClause>node).type) ||
|
||||
child((<CatchClause>node).block);
|
||||
return visitNode(cbNode, (<CatchClause>node).name) ||
|
||||
visitNode(cbNode, (<CatchClause>node).type) ||
|
||||
visitNode(cbNode, (<CatchClause>node).block);
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
return children(node.modifiers) ||
|
||||
child((<ClassDeclaration>node).name) ||
|
||||
children((<ClassDeclaration>node).typeParameters) ||
|
||||
children((<ClassDeclaration>node).heritageClauses) ||
|
||||
children((<ClassDeclaration>node).members);
|
||||
return visitNodes(cbNodes, node.modifiers) ||
|
||||
visitNode(cbNode, (<ClassDeclaration>node).name) ||
|
||||
visitNodes(cbNodes, (<ClassDeclaration>node).typeParameters) ||
|
||||
visitNodes(cbNodes, (<ClassDeclaration>node).heritageClauses) ||
|
||||
visitNodes(cbNodes, (<ClassDeclaration>node).members);
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
return children(node.modifiers) ||
|
||||
child((<InterfaceDeclaration>node).name) ||
|
||||
children((<InterfaceDeclaration>node).typeParameters) ||
|
||||
children((<ClassDeclaration>node).heritageClauses) ||
|
||||
children((<InterfaceDeclaration>node).members);
|
||||
return visitNodes(cbNodes, node.modifiers) ||
|
||||
visitNode(cbNode, (<InterfaceDeclaration>node).name) ||
|
||||
visitNodes(cbNodes, (<InterfaceDeclaration>node).typeParameters) ||
|
||||
visitNodes(cbNodes, (<ClassDeclaration>node).heritageClauses) ||
|
||||
visitNodes(cbNodes, (<InterfaceDeclaration>node).members);
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
return children(node.modifiers) ||
|
||||
child((<TypeAliasDeclaration>node).name) ||
|
||||
child((<TypeAliasDeclaration>node).type);
|
||||
return visitNodes(cbNodes, node.modifiers) ||
|
||||
visitNode(cbNode, (<TypeAliasDeclaration>node).name) ||
|
||||
visitNode(cbNode, (<TypeAliasDeclaration>node).type);
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
return children(node.modifiers) ||
|
||||
child((<EnumDeclaration>node).name) ||
|
||||
children((<EnumDeclaration>node).members);
|
||||
return visitNodes(cbNodes, node.modifiers) ||
|
||||
visitNode(cbNode, (<EnumDeclaration>node).name) ||
|
||||
visitNodes(cbNodes, (<EnumDeclaration>node).members);
|
||||
case SyntaxKind.EnumMember:
|
||||
return child((<EnumMember>node).name) ||
|
||||
child((<EnumMember>node).initializer);
|
||||
return visitNode(cbNode, (<EnumMember>node).name) ||
|
||||
visitNode(cbNode, (<EnumMember>node).initializer);
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
return children(node.modifiers) ||
|
||||
child((<ModuleDeclaration>node).name) ||
|
||||
child((<ModuleDeclaration>node).body);
|
||||
return visitNodes(cbNodes, node.modifiers) ||
|
||||
visitNode(cbNode, (<ModuleDeclaration>node).name) ||
|
||||
visitNode(cbNode, (<ModuleDeclaration>node).body);
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
return children(node.modifiers) ||
|
||||
child((<ImportDeclaration>node).name) ||
|
||||
child((<ImportDeclaration>node).moduleReference);
|
||||
return visitNodes(cbNodes, node.modifiers) ||
|
||||
visitNode(cbNode, (<ImportDeclaration>node).name) ||
|
||||
visitNode(cbNode, (<ImportDeclaration>node).moduleReference);
|
||||
case SyntaxKind.ExportAssignment:
|
||||
return children(node.modifiers) ||
|
||||
child((<ExportAssignment>node).exportName);
|
||||
return visitNodes(cbNodes, node.modifiers) ||
|
||||
visitNode(cbNode, (<ExportAssignment>node).exportName);
|
||||
case SyntaxKind.TemplateExpression:
|
||||
return child((<TemplateExpression>node).head) || children((<TemplateExpression>node).templateSpans);
|
||||
return visitNode(cbNode, (<TemplateExpression>node).head) || visitNodes(cbNodes, (<TemplateExpression>node).templateSpans);
|
||||
case SyntaxKind.TemplateSpan:
|
||||
return child((<TemplateSpan>node).expression) || child((<TemplateSpan>node).literal);
|
||||
return visitNode(cbNode, (<TemplateSpan>node).expression) || visitNode(cbNode, (<TemplateSpan>node).literal);
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
return child((<ComputedPropertyName>node).expression);
|
||||
return visitNode(cbNode, (<ComputedPropertyName>node).expression);
|
||||
case SyntaxKind.HeritageClause:
|
||||
return children((<HeritageClause>node).types);
|
||||
return visitNodes(cbNodes, (<HeritageClause>node).types);
|
||||
case SyntaxKind.ExternalModuleReference:
|
||||
return child((<ExternalModuleReference>node).expression);
|
||||
return visitNode(cbNode, (<ExternalModuleReference>node).expression);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1388,7 +1395,10 @@ module ts {
|
||||
}
|
||||
|
||||
function canFollowModifier(): boolean {
|
||||
return token === SyntaxKind.OpenBracketToken || token === SyntaxKind.AsteriskToken || isLiteralPropertyName();
|
||||
return token === SyntaxKind.OpenBracketToken
|
||||
|| token === SyntaxKind.OpenBraceToken
|
||||
|| token === SyntaxKind.AsteriskToken
|
||||
|| isLiteralPropertyName();
|
||||
}
|
||||
|
||||
// True if positioned at the start of a list element
|
||||
@@ -3480,16 +3490,16 @@ module ts {
|
||||
|
||||
function parsePrimaryExpression(): PrimaryExpression {
|
||||
switch (token) {
|
||||
case SyntaxKind.NumericLiteral:
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
return parseLiteralNode();
|
||||
case SyntaxKind.ThisKeyword:
|
||||
case SyntaxKind.SuperKeyword:
|
||||
case SyntaxKind.NullKeyword:
|
||||
case SyntaxKind.TrueKeyword:
|
||||
case SyntaxKind.FalseKeyword:
|
||||
return parseTokenNode<PrimaryExpression>();
|
||||
case SyntaxKind.NumericLiteral:
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
return parseLiteralNode();
|
||||
case SyntaxKind.OpenParenToken:
|
||||
return parseParenthesizedExpression();
|
||||
case SyntaxKind.OpenBracketToken:
|
||||
|
||||
@@ -146,7 +146,9 @@ module ts {
|
||||
function invokeEmitter(targetSourceFile?: SourceFile) {
|
||||
var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver();
|
||||
return emitFiles(resolver, getEmitHost(), targetSourceFile);
|
||||
} function getSourceFile(filename: string) {
|
||||
}
|
||||
|
||||
function getSourceFile(filename: string) {
|
||||
filename = host.getCanonicalFileName(filename);
|
||||
return hasProperty(filesByName, filename) ? filesByName[filename] : undefined;
|
||||
}
|
||||
@@ -185,7 +187,10 @@ module ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!(findSourceFile(filename + ".ts", isDefaultLib, refFile, refPos, refEnd) || findSourceFile(filename + ".d.ts", isDefaultLib, refFile, refPos, refEnd))) {
|
||||
if (options.allowNonTsExtensions && !findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
}
|
||||
else if (!findSourceFile(filename + ".ts", isDefaultLib, refFile, refPos, refEnd) && !findSourceFile(filename + ".d.ts", isDefaultLib, refFile, refPos, refEnd)) {
|
||||
diagnostic = Diagnostics.File_0_not_found;
|
||||
filename += ".ts";
|
||||
}
|
||||
@@ -337,7 +342,7 @@ module ts {
|
||||
}
|
||||
|
||||
var firstExternalModule = forEach(files, f => isExternalModule(f) ? f : undefined);
|
||||
if (firstExternalModule && options.module === ModuleKind.None) {
|
||||
if (firstExternalModule && !options.module) {
|
||||
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
|
||||
var externalModuleErrorSpan = getErrorSpanForNode(firstExternalModule.externalModuleIndicator);
|
||||
var errorStart = skipTrivia(firstExternalModule.text, externalModuleErrorSpan.pos);
|
||||
|
||||
@@ -224,15 +224,15 @@ module ts {
|
||||
}
|
||||
|
||||
function isUnicodeIdentifierStart(code: number, languageVersion: ScriptTarget) {
|
||||
return languageVersion === ScriptTarget.ES3 ?
|
||||
lookupInUnicodeMap(code, unicodeES3IdentifierStart) :
|
||||
lookupInUnicodeMap(code, unicodeES5IdentifierStart);
|
||||
return languageVersion >= ScriptTarget.ES5 ?
|
||||
lookupInUnicodeMap(code, unicodeES5IdentifierStart) :
|
||||
lookupInUnicodeMap(code, unicodeES3IdentifierStart);
|
||||
}
|
||||
|
||||
function isUnicodeIdentifierPart(code: number, languageVersion: ScriptTarget) {
|
||||
return languageVersion === ScriptTarget.ES3 ?
|
||||
lookupInUnicodeMap(code, unicodeES3IdentifierPart) :
|
||||
lookupInUnicodeMap(code, unicodeES5IdentifierPart);
|
||||
return languageVersion >= ScriptTarget.ES5 ?
|
||||
lookupInUnicodeMap(code, unicodeES5IdentifierPart) :
|
||||
lookupInUnicodeMap(code, unicodeES3IdentifierPart);
|
||||
}
|
||||
|
||||
function makeReverseMap(source: Map<number>): string[] {
|
||||
@@ -279,7 +279,7 @@ module ts {
|
||||
}
|
||||
|
||||
export function getPositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number {
|
||||
Debug.assert(line > 0);
|
||||
Debug.assert(line > 0 && line <= lineStarts.length );
|
||||
return lineStarts[line - 1] + character - 1;
|
||||
}
|
||||
|
||||
@@ -1039,7 +1039,7 @@ module ts {
|
||||
value = 0;
|
||||
}
|
||||
tokenValue = "" + value;
|
||||
return SyntaxKind.NumericLiteral;
|
||||
return token = SyntaxKind.NumericLiteral;
|
||||
}
|
||||
else if (pos + 2 < len && (text.charCodeAt(pos + 1) === CharacterCodes.O || text.charCodeAt(pos + 1) === CharacterCodes.o)) {
|
||||
pos += 2;
|
||||
@@ -1049,7 +1049,7 @@ module ts {
|
||||
value = 0;
|
||||
}
|
||||
tokenValue = "" + value;
|
||||
return SyntaxKind.NumericLiteral;
|
||||
return token = SyntaxKind.NumericLiteral;
|
||||
}
|
||||
// Try to parse as an octal
|
||||
if (pos + 1 < len && isOctalDigit(text.charCodeAt(pos + 1))) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/// <reference path="core.ts"/>
|
||||
|
||||
module ts {
|
||||
export interface System {
|
||||
@@ -14,6 +15,7 @@ module ts {
|
||||
createDirectory(directoryName: string): void;
|
||||
getExecutingFilePath(): string;
|
||||
getCurrentDirectory(): string;
|
||||
readDirectory(path: string, extension?: string): string[];
|
||||
getMemoryUsage? (): number;
|
||||
exit(exitCode?: number): void;
|
||||
}
|
||||
@@ -28,6 +30,13 @@ module ts {
|
||||
declare var global: any;
|
||||
declare var __filename: string;
|
||||
|
||||
declare class Enumerator {
|
||||
public atEnd(): boolean;
|
||||
public moveNext(): boolean;
|
||||
public item(): any;
|
||||
constructor(o: any);
|
||||
}
|
||||
|
||||
export var sys: System = (function () {
|
||||
|
||||
function getWScriptSystem(): System {
|
||||
@@ -100,6 +109,34 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getNames(collection: any): string[] {
|
||||
var result: string[] = [];
|
||||
for (var e = new Enumerator(collection); !e.atEnd(); e.moveNext()) {
|
||||
result.push(e.item().Name);
|
||||
}
|
||||
return result.sort();
|
||||
}
|
||||
|
||||
function readDirectory(path: string, extension?: string): string[] {
|
||||
var result: string[] = [];
|
||||
visitDirectory(path);
|
||||
return result;
|
||||
function visitDirectory(path: string) {
|
||||
var folder = fso.GetFolder(path || ".");
|
||||
var files = getNames(folder.files);
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
var name = files[i];
|
||||
if (!extension || fileExtensionIs(name, extension)) {
|
||||
result.push(combinePaths(path, name));
|
||||
}
|
||||
}
|
||||
var subfolders = getNames(folder.subfolders);
|
||||
for (var i = 0; i < subfolders.length; i++) {
|
||||
visitDirectory(combinePaths(path, subfolders[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
args,
|
||||
newLine: "\r\n",
|
||||
@@ -129,6 +166,7 @@ module ts {
|
||||
getCurrentDirectory() {
|
||||
return new ActiveXObject("WScript.Shell").CurrentDirectory;
|
||||
},
|
||||
readDirectory,
|
||||
exit(exitCode?: number): void {
|
||||
try {
|
||||
WScript.Quit(exitCode);
|
||||
@@ -185,6 +223,31 @@ module ts {
|
||||
_fs.writeFileSync(fileName, data, "utf8");
|
||||
}
|
||||
|
||||
function readDirectory(path: string, extension?: string): string[] {
|
||||
var result: string[] = [];
|
||||
visitDirectory(path);
|
||||
return result;
|
||||
function visitDirectory(path: string) {
|
||||
var files = _fs.readdirSync(path || ".").sort();
|
||||
var directories: string[] = [];
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
var name = combinePaths(path, files[i]);
|
||||
var stat = _fs.lstatSync(name);
|
||||
if (stat.isFile()) {
|
||||
if (!extension || fileExtensionIs(name, extension)) {
|
||||
result.push(name);
|
||||
}
|
||||
}
|
||||
else if (stat.isDirectory()) {
|
||||
directories.push(name);
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < directories.length; i++) {
|
||||
visitDirectory(directories[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
args: process.argv.slice(2),
|
||||
newLine: _os.EOL,
|
||||
@@ -231,6 +294,7 @@ module ts {
|
||||
getCurrentDirectory() {
|
||||
return process.cwd();
|
||||
},
|
||||
readDirectory,
|
||||
getMemoryUsage() {
|
||||
if (global.gc) {
|
||||
global.gc();
|
||||
|
||||
+158
-98
@@ -4,6 +4,10 @@
|
||||
module ts {
|
||||
var version = "1.4.0.0";
|
||||
|
||||
export interface SourceFile {
|
||||
fileWatcher: FileWatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the locale is in the appropriate format,
|
||||
* and if it is, attempts to set the appropriate language.
|
||||
@@ -126,16 +130,43 @@ module ts {
|
||||
reportStatisticalValue(name, (time / 1000).toFixed(2) + "s");
|
||||
}
|
||||
|
||||
function isJSONSupported() {
|
||||
return typeof JSON === "object" && typeof JSON.parse === "function";
|
||||
}
|
||||
|
||||
function findConfigFile(): string {
|
||||
var searchPath = normalizePath(sys.getCurrentDirectory());
|
||||
var filename = "tsconfig.json";
|
||||
while (true) {
|
||||
if (sys.fileExists(filename)) {
|
||||
return filename;
|
||||
}
|
||||
var parentPath = getDirectoryPath(searchPath);
|
||||
if (parentPath === searchPath) {
|
||||
break;
|
||||
}
|
||||
searchPath = parentPath;
|
||||
filename = "../" + filename;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function executeCommandLine(args: string[]): void {
|
||||
var commandLine = parseCommandLine(args);
|
||||
var compilerOptions = commandLine.options;
|
||||
var configFilename: string; // Configuration file name (if any)
|
||||
var configFileWatcher: FileWatcher; // Configuration file watcher
|
||||
var cachedProgram: Program; // Program cached from last compilation
|
||||
var rootFilenames: string[]; // Root filenames for compilation
|
||||
var compilerOptions: CompilerOptions; // Compiler options for compilation
|
||||
var compilerHost: CompilerHost; // Compiler host
|
||||
var hostGetSourceFile: typeof compilerHost.getSourceFile; // getSourceFile method from default host
|
||||
var timerHandle: number; // Handle for 0.25s wait timer
|
||||
|
||||
if (compilerOptions.locale) {
|
||||
if (typeof JSON === "undefined") {
|
||||
if (commandLine.options.locale) {
|
||||
if (!isJSONSupported()) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--locale"));
|
||||
return sys.exit(1);
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
}
|
||||
|
||||
validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors);
|
||||
}
|
||||
|
||||
@@ -146,131 +177,153 @@ module ts {
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
}
|
||||
|
||||
if (compilerOptions.version) {
|
||||
if (commandLine.options.version) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Version_0, version));
|
||||
return sys.exit(EmitReturnStatus.Succeeded);
|
||||
}
|
||||
|
||||
if (compilerOptions.help) {
|
||||
if (commandLine.options.help) {
|
||||
printVersion();
|
||||
printHelp();
|
||||
return sys.exit(EmitReturnStatus.Succeeded);
|
||||
}
|
||||
|
||||
if (commandLine.filenames.length === 0) {
|
||||
if (commandLine.options.project) {
|
||||
if (!isJSONSupported()) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--project"));
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
}
|
||||
configFilename = normalizePath(combinePaths(commandLine.options.project, "tsconfig.json"));
|
||||
if (commandLine.filenames.length !== 0) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line));
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
}
|
||||
}
|
||||
else if (commandLine.filenames.length === 0 && isJSONSupported()) {
|
||||
configFilename = findConfigFile();
|
||||
}
|
||||
|
||||
if (commandLine.filenames.length === 0 && !configFilename) {
|
||||
printVersion();
|
||||
printHelp();
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
}
|
||||
|
||||
var defaultCompilerHost = createCompilerHost(compilerOptions);
|
||||
|
||||
if (compilerOptions.watch) {
|
||||
if (commandLine.options.watch) {
|
||||
if (!sys.watchFile) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"));
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
}
|
||||
|
||||
watchProgram(commandLine, defaultCompilerHost);
|
||||
}
|
||||
else {
|
||||
var result = compile(commandLine, defaultCompilerHost).exitStatus
|
||||
return sys.exit(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles the program once, and then watches all given and referenced files for changes.
|
||||
* Upon detecting a file change, watchProgram will queue up file modification events for the next
|
||||
* 250ms and then perform a recompilation. The reasoning is that in some cases, an editor can
|
||||
* save all files at once, and we'd like to just perform a single recompilation.
|
||||
*/
|
||||
function watchProgram(commandLine: ParsedCommandLine, compilerHost: CompilerHost): void {
|
||||
var watchers: Map<FileWatcher> = {};
|
||||
var updatedFiles: Map<boolean> = {};
|
||||
|
||||
// Compile the program the first time and watch all given/referenced files.
|
||||
var program = compile(commandLine, compilerHost).program;
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes));
|
||||
addWatchers(program);
|
||||
return;
|
||||
|
||||
function addWatchers(program: Program) {
|
||||
forEach(program.getSourceFiles(), f => {
|
||||
var filename = getCanonicalName(f.filename);
|
||||
watchers[filename] = sys.watchFile(filename, fileUpdated);
|
||||
});
|
||||
}
|
||||
|
||||
function removeWatchers(program: Program) {
|
||||
forEach(program.getSourceFiles(), f => {
|
||||
var filename = getCanonicalName(f.filename);
|
||||
if (hasProperty(watchers, filename)) {
|
||||
watchers[filename].close();
|
||||
}
|
||||
});
|
||||
|
||||
watchers = {};
|
||||
}
|
||||
|
||||
// Fired off whenever a file is changed.
|
||||
function fileUpdated(filename: string) {
|
||||
var firstNotification = isEmpty(updatedFiles);
|
||||
updatedFiles[getCanonicalName(filename)] = true;
|
||||
|
||||
// Only start this off when the first file change comes in,
|
||||
// so that we can batch up all further changes.
|
||||
if (firstNotification) {
|
||||
setTimeout(() => {
|
||||
var changedFiles = updatedFiles;
|
||||
updatedFiles = {};
|
||||
|
||||
recompile(changedFiles);
|
||||
}, 250);
|
||||
if (configFilename) {
|
||||
configFileWatcher = sys.watchFile(configFilename, configFileChanged);
|
||||
}
|
||||
}
|
||||
|
||||
function recompile(changedFiles: Map<boolean>) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.File_change_detected_Compiling));
|
||||
// Remove all the watchers, as we may not be watching every file
|
||||
// specified since the last compilation cycle.
|
||||
removeWatchers(program);
|
||||
performCompilation();
|
||||
|
||||
// Reuse source files from the last compilation so long as they weren't changed.
|
||||
var oldSourceFiles = arrayToMap(
|
||||
filter(program.getSourceFiles(), file => !hasProperty(changedFiles, getCanonicalName(file.filename))),
|
||||
file => getCanonicalName(file.filename));
|
||||
// Invoked to perform initial compilation or re-compilation in watch mode
|
||||
function performCompilation() {
|
||||
|
||||
// We create a new compiler host for this compilation cycle.
|
||||
// This new host is effectively the same except that 'getSourceFile'
|
||||
// will try to reuse the SourceFiles from the last compilation cycle
|
||||
// so long as they were not modified.
|
||||
var newCompilerHost = clone(compilerHost);
|
||||
newCompilerHost.getSourceFile = (fileName, languageVersion, onError) => {
|
||||
fileName = getCanonicalName(fileName);
|
||||
|
||||
var sourceFile = lookUp(oldSourceFiles, fileName);
|
||||
if (sourceFile) {
|
||||
return sourceFile;
|
||||
if (!cachedProgram) {
|
||||
if (configFilename) {
|
||||
var configObject = readConfigFile(configFilename);
|
||||
if (!configObject) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Unable_to_open_file_0, configFilename));
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
}
|
||||
var configParseResult = parseConfigFile(configObject, getDirectoryPath(configFilename));
|
||||
if (configParseResult.errors.length > 0) {
|
||||
reportDiagnostics(configParseResult.errors);
|
||||
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
|
||||
}
|
||||
rootFilenames = configParseResult.filenames;
|
||||
compilerOptions = extend(commandLine.options, configParseResult.options);
|
||||
}
|
||||
else {
|
||||
rootFilenames = commandLine.filenames;
|
||||
compilerOptions = commandLine.options;
|
||||
}
|
||||
compilerHost = createCompilerHost(compilerOptions);
|
||||
hostGetSourceFile = compilerHost.getSourceFile;
|
||||
compilerHost.getSourceFile = getSourceFile;
|
||||
}
|
||||
|
||||
return compilerHost.getSourceFile(fileName, languageVersion, onError);
|
||||
};
|
||||
var compileResult = compile(rootFilenames, compilerOptions, compilerHost);
|
||||
|
||||
program = compile(commandLine, newCompilerHost).program;
|
||||
if (!commandLine.options.watch) {
|
||||
return sys.exit(compileResult.exitStatus);
|
||||
}
|
||||
|
||||
setCachedProgram(compileResult.program);
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes));
|
||||
addWatchers(program);
|
||||
}
|
||||
|
||||
function getCanonicalName(fileName: string) {
|
||||
return compilerHost.getCanonicalFileName(fileName);
|
||||
function getSourceFile(filename: string, languageVersion: ScriptTarget, onError ?: (message: string) => void) {
|
||||
// Return existing SourceFile object if one is available
|
||||
if (cachedProgram) {
|
||||
var sourceFile = cachedProgram.getSourceFile(filename);
|
||||
// A modified source file has no watcher and should not be reused
|
||||
if (sourceFile && sourceFile.fileWatcher) {
|
||||
return sourceFile;
|
||||
}
|
||||
}
|
||||
// Use default host function
|
||||
var sourceFile = hostGetSourceFile(filename, languageVersion, onError);
|
||||
if (sourceFile && commandLine.options.watch) {
|
||||
// Attach a file watcher
|
||||
sourceFile.fileWatcher = sys.watchFile(sourceFile.filename, () => sourceFileChanged(sourceFile));
|
||||
}
|
||||
return sourceFile;
|
||||
}
|
||||
|
||||
// Change cached program to the given program
|
||||
function setCachedProgram(program: Program) {
|
||||
if (cachedProgram) {
|
||||
var newSourceFiles = program ? program.getSourceFiles() : undefined;
|
||||
forEach(cachedProgram.getSourceFiles(), sourceFile => {
|
||||
if (!(newSourceFiles && contains(newSourceFiles, sourceFile))) {
|
||||
if (sourceFile.fileWatcher) {
|
||||
sourceFile.fileWatcher.close();
|
||||
sourceFile.fileWatcher = undefined;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
cachedProgram = program;
|
||||
}
|
||||
|
||||
// If a source file changes, mark it as unwatched and start the recompilation timer
|
||||
function sourceFileChanged(sourceFile: SourceFile) {
|
||||
sourceFile.fileWatcher = undefined;
|
||||
startTimer();
|
||||
}
|
||||
|
||||
// If the configuration file changes, forget cached program and start the recompilation timer
|
||||
function configFileChanged() {
|
||||
setCachedProgram(undefined);
|
||||
startTimer();
|
||||
}
|
||||
|
||||
// Upon detecting a file change, wait for 250ms and then perform a recompilation. This gives batch
|
||||
// operations (such as saving all modified files in an editor) a chance to complete before we kick
|
||||
// off a new compilation.
|
||||
function startTimer() {
|
||||
if (timerHandle) {
|
||||
clearTimeout(timerHandle);
|
||||
}
|
||||
timerHandle = setTimeout(recompile, 250);
|
||||
}
|
||||
|
||||
function recompile() {
|
||||
timerHandle = undefined;
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.File_change_detected_Starting_incremental_compilation));
|
||||
performCompilation();
|
||||
}
|
||||
}
|
||||
|
||||
function compile(commandLine: ParsedCommandLine, compilerHost: CompilerHost) {
|
||||
function compile(filenames: string[], compilerOptions: CompilerOptions, compilerHost: CompilerHost) {
|
||||
var parseStart = new Date().getTime();
|
||||
var compilerOptions = commandLine.options;
|
||||
var program = createProgram(commandLine.filenames, compilerOptions, compilerHost);
|
||||
var program = createProgram(filenames, compilerOptions, compilerHost);
|
||||
|
||||
var bindStart = new Date().getTime();
|
||||
var errors: Diagnostic[] = program.getDiagnostics();
|
||||
@@ -303,7 +356,14 @@ module ts {
|
||||
}
|
||||
|
||||
reportDiagnostics(errors);
|
||||
if (commandLine.options.diagnostics) {
|
||||
|
||||
if (compilerOptions.listFiles) {
|
||||
forEach(program.getSourceFiles(), file => {
|
||||
sys.write(file.filename + sys.newLine);
|
||||
});
|
||||
}
|
||||
|
||||
if (compilerOptions.diagnostics) {
|
||||
var memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1;
|
||||
reportCountStatistic("Files", program.getSourceFiles().length);
|
||||
reportCountStatistic("Lines", countLines(program));
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"noImplicitAny": true,
|
||||
"removeComments": true,
|
||||
"preserveConstEnums": true,
|
||||
"out": "../../built/local/tsc.js",
|
||||
"sourceMap": true
|
||||
},
|
||||
"files": [
|
||||
"core.ts",
|
||||
"sys.ts",
|
||||
"types.ts",
|
||||
"scanner.ts",
|
||||
"parser.ts",
|
||||
"utilities.ts",
|
||||
"binder.ts",
|
||||
"checker.ts",
|
||||
"emitter.ts",
|
||||
"program.ts",
|
||||
"commandLineParser.ts",
|
||||
"tsc.ts",
|
||||
"diagnosticInformationMap.generated.ts"
|
||||
]
|
||||
}
|
||||
@@ -1331,8 +1331,6 @@ module ts {
|
||||
// Generic class and interface types
|
||||
export interface GenericType extends InterfaceType, TypeReference {
|
||||
instantiations: Map<TypeReference>; // Generic instantiation cache
|
||||
openReferenceTargets: GenericType[]; // Open type reference targets
|
||||
openReferenceChecks: Map<boolean>; // Open type reference check cache
|
||||
}
|
||||
|
||||
export interface TupleType extends ObjectType {
|
||||
@@ -1450,6 +1448,7 @@ module ts {
|
||||
diagnostics?: boolean;
|
||||
emitBOM?: boolean;
|
||||
help?: boolean;
|
||||
listFiles?: boolean;
|
||||
locale?: string;
|
||||
mapRoot?: string;
|
||||
module?: ModuleKind;
|
||||
@@ -1463,6 +1462,7 @@ module ts {
|
||||
out?: string;
|
||||
outDir?: string;
|
||||
preserveConstEnums?: boolean;
|
||||
project?: string;
|
||||
removeComments?: boolean;
|
||||
sourceMap?: boolean;
|
||||
sourceRoot?: string;
|
||||
@@ -1503,10 +1503,11 @@ module ts {
|
||||
export interface CommandLineOption {
|
||||
name: string;
|
||||
type: string | Map<number>; // "string", "number", "boolean", or an object literal mapping named values to actual values
|
||||
shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help'.
|
||||
isFilePath?: boolean; // True if option value is a path or filename
|
||||
shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help'
|
||||
description?: DiagnosticMessage; // The message describing what the command line switch does
|
||||
paramType?: DiagnosticMessage; // The name to be used for a non-boolean option's parameter.
|
||||
error?: DiagnosticMessage; // The error given when the argument does not fit a customized 'type'.
|
||||
paramType?: DiagnosticMessage; // The name to be used for a non-boolean option's parameter
|
||||
error?: DiagnosticMessage; // The error given when the argument does not fit a customized 'type'
|
||||
}
|
||||
|
||||
export const enum CharacterCodes {
|
||||
|
||||
@@ -23,6 +23,17 @@ module ts {
|
||||
string(): string;
|
||||
}
|
||||
|
||||
export interface EmitHost extends ScriptReferenceHost {
|
||||
getSourceFiles(): SourceFile[];
|
||||
isEmitBlocked(sourceFile?: SourceFile): boolean;
|
||||
|
||||
getCommonSourceDirectory(): string;
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
getNewLine(): string;
|
||||
|
||||
writeFile(filename: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void;
|
||||
}
|
||||
|
||||
// Pool writers to avoid needing to allocate them for every symbol we write.
|
||||
var stringWriters: StringSymbolWriter[] = [];
|
||||
export function getSingleLineStringWriter(): StringSymbolWriter {
|
||||
@@ -525,6 +536,12 @@ module ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isInstantiatedModule(node: ModuleDeclaration, preserveConstEnums: boolean) {
|
||||
var moduleState = getModuleInstanceState(node)
|
||||
return moduleState === ModuleInstanceState.Instantiated ||
|
||||
(preserveConstEnums && moduleState === ModuleInstanceState.ConstEnumOnly);
|
||||
}
|
||||
|
||||
export function isExternalModuleImportDeclaration(node: Node) {
|
||||
return node.kind === SyntaxKind.ImportDeclaration && (<ImportDeclaration>node).moduleReference.kind === SyntaxKind.ExternalModuleReference;
|
||||
}
|
||||
|
||||
@@ -61,12 +61,6 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
var otherFiles: { unitName: string; content: string }[];
|
||||
var harnessCompiler: Harness.Compiler.HarnessCompiler;
|
||||
|
||||
var declFileCompilationResult: {
|
||||
declInputFiles: { unitName: string; content: string }[];
|
||||
declOtherFiles: { unitName: string; content: string }[];
|
||||
declResult: Harness.Compiler.CompilerResult;
|
||||
};
|
||||
|
||||
var createNewInstance = false;
|
||||
|
||||
before(() => {
|
||||
@@ -143,7 +137,6 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
toBeCompiled = undefined;
|
||||
otherFiles = undefined;
|
||||
harnessCompiler = undefined;
|
||||
declFileCompilationResult = undefined;
|
||||
});
|
||||
|
||||
function getByteOrderMarkText(file: Harness.Compiler.GeneratedFile): string {
|
||||
@@ -179,13 +172,6 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
}
|
||||
});
|
||||
|
||||
// Compile .d.ts files
|
||||
it('Correct compiler generated.d.ts for ' + fileName, () => {
|
||||
declFileCompilationResult = harnessCompiler.compileDeclarationFiles(toBeCompiled, otherFiles, result, function (settings) {
|
||||
harnessCompiler.setCompilerSettings(tcSettings);
|
||||
}, options);
|
||||
});
|
||||
|
||||
|
||||
it('Correct JS output for ' + fileName, () => {
|
||||
if (!ts.fileExtensionIs(lastUnit.name, '.d.ts') && this.emit) {
|
||||
@@ -223,6 +209,10 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
}
|
||||
}
|
||||
|
||||
var declFileCompilationResult = harnessCompiler.compileDeclarationFiles(toBeCompiled, otherFiles, result, function (settings) {
|
||||
harnessCompiler.setCompilerSettings(tcSettings);
|
||||
}, options);
|
||||
|
||||
if (declFileCompilationResult && declFileCompilationResult.declResult.errors.length) {
|
||||
jsCode += '\r\n\r\n//// [DtsFileErrors]\r\n';
|
||||
jsCode += '\r\n\r\n';
|
||||
|
||||
+47
-33
@@ -22,6 +22,7 @@
|
||||
|
||||
declare var require: any;
|
||||
declare var process: any;
|
||||
var Buffer = require('buffer').Buffer;
|
||||
|
||||
// this will work in the browser via browserify
|
||||
var _chai: typeof chai = require('chai');
|
||||
@@ -810,7 +811,9 @@ module Harness {
|
||||
export function createCompilerHost(inputFiles: { unitName: string; content: string; }[],
|
||||
writeFile: (fn: string, contents: string, writeByteOrderMark: boolean) => void,
|
||||
scriptTarget: ts.ScriptTarget,
|
||||
useCaseSensitiveFileNames: boolean): ts.CompilerHost {
|
||||
useCaseSensitiveFileNames: boolean,
|
||||
// the currentDirectory is needed for rwcRunner to passed in specified current directory to compiler host
|
||||
currentDirectory?: string): ts.CompilerHost {
|
||||
|
||||
// Local get canonical file name function, that depends on passed in parameter for useCaseSensitiveFileNames
|
||||
function getCanonicalFileName(fileName: string): string {
|
||||
@@ -818,6 +821,8 @@ module Harness {
|
||||
}
|
||||
|
||||
var filemap: { [filename: string]: ts.SourceFile; } = {};
|
||||
var getCurrentDirectory = currentDirectory === undefined ? ts.sys.getCurrentDirectory : () => currentDirectory;
|
||||
|
||||
// Register input files
|
||||
function register(file: { unitName: string; content: string; }) {
|
||||
if (file.content !== undefined) {
|
||||
@@ -828,11 +833,15 @@ module Harness {
|
||||
inputFiles.forEach(register);
|
||||
|
||||
return {
|
||||
getCurrentDirectory: ts.sys.getCurrentDirectory,
|
||||
getCurrentDirectory,
|
||||
getSourceFile: (fn, languageVersion) => {
|
||||
if (Object.prototype.hasOwnProperty.call(filemap, getCanonicalFileName(fn))) {
|
||||
return filemap[getCanonicalFileName(fn)];
|
||||
}
|
||||
else if (currentDirectory) {
|
||||
var canonicalAbsolutePath = getCanonicalFileName(ts.getNormalizedAbsolutePath(fn, currentDirectory));
|
||||
return Object.prototype.hasOwnProperty.call(filemap, getCanonicalFileName(canonicalAbsolutePath)) ? filemap[canonicalAbsolutePath] : undefined;
|
||||
}
|
||||
else if (fn === fourslashFilename) {
|
||||
var tsFn = 'tests/cases/fourslash/' + fourslashFilename;
|
||||
fourslashSourceFile = fourslashSourceFile || ts.createSourceFile(tsFn, Harness.IO.readFile(tsFn), scriptTarget);
|
||||
@@ -909,7 +918,9 @@ module Harness {
|
||||
otherFiles: { unitName: string; content: string }[],
|
||||
onComplete: (result: CompilerResult, program: ts.Program) => void,
|
||||
settingsCallback?: (settings: ts.CompilerOptions) => void,
|
||||
options?: ts.CompilerOptions) {
|
||||
options?: ts.CompilerOptions,
|
||||
// Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file
|
||||
currentDirectory?: string) {
|
||||
|
||||
options = options || { noResolve: false };
|
||||
options.target = options.target || ts.ScriptTarget.ES3;
|
||||
@@ -1063,8 +1074,7 @@ module Harness {
|
||||
var programFiles = inputFiles.map(file => file.unitName);
|
||||
var program = ts.createProgram(programFiles, options, createCompilerHost(inputFiles.concat(otherFiles),
|
||||
(fn, contents, writeByteOrderMark) => fileOutputs.push({ fileName: fn, code: contents, writeByteOrderMark: writeByteOrderMark }),
|
||||
options.target,
|
||||
useCaseSensitiveFileNames));
|
||||
options.target, useCaseSensitiveFileNames, currentDirectory));
|
||||
|
||||
var checker = program.getTypeChecker(/*produceDiagnostics*/ true);
|
||||
|
||||
@@ -1095,7 +1105,9 @@ module Harness {
|
||||
otherFiles: { unitName: string; content: string; }[],
|
||||
result: CompilerResult,
|
||||
settingsCallback?: (settings: ts.CompilerOptions) => void,
|
||||
options?: ts.CompilerOptions) {
|
||||
options?: ts.CompilerOptions,
|
||||
// Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file
|
||||
currentDirectory?: string) {
|
||||
if (options.declaration && result.errors.length === 0 && result.declFilesCode.length !== result.files.length) {
|
||||
throw new Error('There were no errors and declFiles generated did not match number of js files generated');
|
||||
}
|
||||
@@ -1108,9 +1120,8 @@ module Harness {
|
||||
|
||||
ts.forEach(inputFiles, file => addDtsFile(file, declInputFiles));
|
||||
ts.forEach(otherFiles, file => addDtsFile(file, declOtherFiles));
|
||||
this.compileFiles(declInputFiles, declOtherFiles, function (compileResult) {
|
||||
declResult = compileResult;
|
||||
}, settingsCallback, options);
|
||||
this.compileFiles(declInputFiles, declOtherFiles, function (compileResult) { declResult = compileResult; },
|
||||
settingsCallback, options, currentDirectory);
|
||||
|
||||
return { declInputFiles, declOtherFiles, declResult };
|
||||
}
|
||||
@@ -1127,29 +1138,27 @@ module Harness {
|
||||
}
|
||||
|
||||
function findResultCodeFile(fileName: string) {
|
||||
var dTsFileName = ts.forEach(result.program.getSourceFiles(), sourceFile => {
|
||||
if (sourceFile.filename === fileName) {
|
||||
// Is this file going to be emitted separately
|
||||
var sourceFileName: string;
|
||||
if (ts.isExternalModule(sourceFile) || !options.out) {
|
||||
if (options.outDir) {
|
||||
var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.filename, result.currentDirectoryForProgram);
|
||||
sourceFilePath = sourceFilePath.replace(result.program.getCommonSourceDirectory(), "");
|
||||
sourceFileName = ts.combinePaths(options.outDir, sourceFilePath);
|
||||
}
|
||||
else {
|
||||
sourceFileName = sourceFile.filename;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Goes to single --out file
|
||||
sourceFileName = options.out;
|
||||
}
|
||||
|
||||
return ts.removeFileExtension(sourceFileName) + ".d.ts";
|
||||
var sourceFile = result.program.getSourceFile(fileName);
|
||||
assert(sourceFile, "Program has no source file with name '" + fileName + "'");
|
||||
// Is this file going to be emitted separately
|
||||
var sourceFileName: string;
|
||||
if (ts.isExternalModule(sourceFile) || !options.out) {
|
||||
if (options.outDir) {
|
||||
var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.filename, result.currentDirectoryForProgram);
|
||||
sourceFilePath = sourceFilePath.replace(result.program.getCommonSourceDirectory(), "");
|
||||
sourceFileName = ts.combinePaths(options.outDir, sourceFilePath);
|
||||
}
|
||||
});
|
||||
else {
|
||||
sourceFileName = sourceFile.filename;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Goes to single --out file
|
||||
sourceFileName = options.out;
|
||||
}
|
||||
|
||||
var dTsFileName = ts.removeFileExtension(sourceFileName) + ".d.ts";
|
||||
|
||||
return ts.forEach(result.declFilesCode, declFile => declFile.fileName === dTsFileName ? declFile : undefined);
|
||||
}
|
||||
|
||||
@@ -1199,7 +1208,6 @@ module Harness {
|
||||
|
||||
export function getErrorBaseline(inputFiles: { unitName: string; content: string }[], diagnostics: HarnessDiagnostic[]) {
|
||||
diagnostics.sort(compareDiagnostics);
|
||||
|
||||
var outputLines: string[] = [];
|
||||
// Count up all the errors we find so we don't miss any
|
||||
var totalErrorsReported = 0;
|
||||
@@ -1290,8 +1298,13 @@ module Harness {
|
||||
return diagnostic.filename && isLibraryFile(diagnostic.filename);
|
||||
});
|
||||
|
||||
var numTest262HarnessDiagnostics = ts.countWhere(diagnostics, diagnostic => {
|
||||
// Count an error generated from tests262-harness folder.This should only apply for test262
|
||||
return diagnostic.filename && diagnostic.filename.indexOf("test262-harness") >= 0;
|
||||
});
|
||||
|
||||
// Verify we didn't miss any errors in total
|
||||
assert.equal(totalErrorsReported + numLibraryDiagnostics, diagnostics.length, 'total number of errors');
|
||||
assert.equal(totalErrorsReported + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length, 'total number of errors');
|
||||
|
||||
return minimalDiagnosticsToString(diagnostics) +
|
||||
ts.sys.newLine + ts.sys.newLine + outputLines.join('\r\n');
|
||||
@@ -1634,7 +1647,8 @@ module Harness {
|
||||
}
|
||||
|
||||
function writeComparison(expected: string, actual: string, relativeFilename: string, actualFilename: string, descriptionForDescribe: string) {
|
||||
if (expected != actual) {
|
||||
var encoded_actual = (new Buffer(actual)).toString('utf8')
|
||||
if (expected != encoded_actual) {
|
||||
// Overwrite & issue error
|
||||
var errMsg = 'The baseline file ' + relativeFilename + ' has changed';
|
||||
throw new Error(errMsg);
|
||||
|
||||
@@ -3,11 +3,11 @@ var fs: any = require('fs');
|
||||
var path: any = require('path');
|
||||
|
||||
function instrumentForRecording(fn: string, tscPath: string) {
|
||||
instrument(tscPath, 'sys = Playback.wrapSystem(sys); sys.startRecord("' + fn + '");', 'sys.endRecord();');
|
||||
instrument(tscPath, 'ts.sys = Playback.wrapSystem(ts.sys); ts.sys.startRecord("' + fn + '");', 'ts.sys.endRecord();');
|
||||
}
|
||||
|
||||
function instrumentForReplay(logFilename: string, tscPath: string) {
|
||||
instrument(tscPath, 'sys = Playback.wrapSystem(sys); sys.startReplay("' + logFilename + '");');
|
||||
instrument(tscPath, 'ts.sys = Playback.wrapSystem(ts.sys); ts.sys.startReplay("' + logFilename + '");');
|
||||
}
|
||||
|
||||
function instrument(tscPath: string, prepareCode: string, cleanupCode: string = '') {
|
||||
@@ -27,8 +27,12 @@ function instrument(tscPath: string, prepareCode: string, cleanupCode: string =
|
||||
fs.readFile(path.resolve(path.dirname(tscPath) + '/loggedIO.js'), 'utf-8', (err: any, loggerContent: string) => {
|
||||
if (err) throw err;
|
||||
|
||||
var invocationLine = 'ts.executeCommandLine(sys.args);';
|
||||
var invocationLine = 'ts.executeCommandLine(ts.sys.args);';
|
||||
var index1 = tscContent.indexOf(invocationLine);
|
||||
if (index1 < 0) {
|
||||
throw new Error("Could not find " + invocationLine);
|
||||
}
|
||||
|
||||
var index2 = index1 + invocationLine.length;
|
||||
var newContent = tscContent.substr(0, index1) + loggerContent + prepareCode + invocationLine + cleanupCode + tscContent.substr(index2) + '\r\n';
|
||||
fs.writeFile(tscPath, newContent);
|
||||
|
||||
+14
-16
@@ -28,12 +28,7 @@ module RWC {
|
||||
var compilerOptions: ts.CompilerOptions;
|
||||
var baselineOpts: Harness.Baseline.BaselineOptions = { Subfolder: 'rwc' };
|
||||
var baseName = /(.*)\/(.*).json/.exec(ts.normalizeSlashes(jsonPath))[2];
|
||||
// Compile .d.ts files
|
||||
var declFileCompilationResult: {
|
||||
declInputFiles: { unitName: string; content: string }[];
|
||||
declOtherFiles: { unitName: string; content: string }[];
|
||||
declResult: Harness.Compiler.CompilerResult;
|
||||
};
|
||||
var currentDirectory: string;
|
||||
|
||||
after(() => {
|
||||
// Mocha holds onto the closure environment of the describe callback even after the test is done.
|
||||
@@ -44,7 +39,7 @@ module RWC {
|
||||
compilerOptions = undefined;
|
||||
baselineOpts = undefined;
|
||||
baseName = undefined;
|
||||
declFileCompilationResult = undefined;
|
||||
currentDirectory = undefined;
|
||||
});
|
||||
|
||||
it('can compile', () => {
|
||||
@@ -52,6 +47,7 @@ module RWC {
|
||||
var opts: ts.ParsedCommandLine;
|
||||
|
||||
var ioLog: IOLog = JSON.parse(Harness.IO.readFile(jsonPath));
|
||||
currentDirectory = ioLog.currentDirectory;
|
||||
runWithIOLog(ioLog, () => {
|
||||
opts = ts.parseCommandLine(ioLog.arguments);
|
||||
assert.equal(opts.errors.length, 0);
|
||||
@@ -59,7 +55,6 @@ module RWC {
|
||||
|
||||
runWithIOLog(ioLog, () => {
|
||||
harnessCompiler.reset();
|
||||
|
||||
// Load the files
|
||||
ts.forEach(opts.filenames, fileName => {
|
||||
inputFiles.push(getHarnessCompilerInputUnit(fileName));
|
||||
@@ -88,7 +83,11 @@ module RWC {
|
||||
// Emit the results
|
||||
compilerOptions = harnessCompiler.compileFiles(inputFiles, otherFiles, compileResult => {
|
||||
compilerResult = compileResult;
|
||||
}, /*settingsCallback*/ undefined, opts.options);
|
||||
},
|
||||
/*settingsCallback*/ undefined, opts.options,
|
||||
// Since all Rwc json file specified current directory in its json file, we need to pass this information to compilerHost
|
||||
// so that when the host is asked for current directory, it should give the value from json rather than from process
|
||||
currentDirectory);
|
||||
});
|
||||
|
||||
function getHarnessCompilerInputUnit(fileName: string) {
|
||||
@@ -103,11 +102,6 @@ module RWC {
|
||||
}
|
||||
});
|
||||
|
||||
// Baselines
|
||||
it('Correct compiler generated.d.ts', () => {
|
||||
declFileCompilationResult = Harness.Compiler.getCompiler().compileDeclarationFiles(inputFiles, otherFiles, compilerResult, /*settingscallback*/ undefined, compilerOptions);
|
||||
});
|
||||
|
||||
|
||||
it('has the expected emitted code', () => {
|
||||
Harness.Baseline.runBaseline('has the expected emitted code', baseName + '.output.js', () => {
|
||||
@@ -152,9 +146,13 @@ module RWC {
|
||||
}, false, baselineOpts);
|
||||
});
|
||||
|
||||
it('has no errors in generated declaration files', () => {
|
||||
// Ideally, a generated declaration file will have no errors. But we allow generated
|
||||
// declaration file errors as part of the baseline.
|
||||
it('has the expected errors in generated declaration files', () => {
|
||||
if (compilerOptions.declaration && !compilerResult.errors.length) {
|
||||
Harness.Baseline.runBaseline('has no errors in generated declaration files', baseName + '.dts.errors.txt', () => {
|
||||
Harness.Baseline.runBaseline('has the expected errors in generated declaration files', baseName + '.dts.errors.txt', () => {
|
||||
var declFileCompilationResult = Harness.Compiler.getCompiler().compileDeclarationFiles(inputFiles, otherFiles, compilerResult,
|
||||
/*settingscallback*/ undefined, compilerOptions, currentDirectory);
|
||||
if (declFileCompilationResult.declResult.errors.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ module TypeScript {
|
||||
|
||||
opts.flag('noImplicitAny', {
|
||||
usage: {
|
||||
locCode: DiagnosticCode.Warn_on_expressions_and_declarations_with_an_implied_any_type,
|
||||
locCode: DiagnosticCode.Raise_error_on_expressions_and_declarations_with_an_implied_any_type,
|
||||
args: null
|
||||
},
|
||||
set: () => {
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
var global: any = <any>Function("return this").call(null);
|
||||
|
||||
module TypeScript {
|
||||
module Clock {
|
||||
export var now: () => number;
|
||||
export var resolution: number;
|
||||
|
||||
declare module WScript {
|
||||
export function InitializeProjection(): void;
|
||||
}
|
||||
|
||||
declare module TestUtilities {
|
||||
export function QueryPerformanceCounter(): number;
|
||||
export function QueryPerformanceFrequency(): number;
|
||||
}
|
||||
|
||||
if (typeof WScript !== "undefined" && typeof global['WScript'].InitializeProjection !== "undefined") {
|
||||
// Running in JSHost.
|
||||
global['WScript'].InitializeProjection();
|
||||
|
||||
now = function () {
|
||||
return TestUtilities.QueryPerformanceCounter();
|
||||
};
|
||||
|
||||
resolution = TestUtilities.QueryPerformanceFrequency();
|
||||
}
|
||||
else {
|
||||
now = function () {
|
||||
return Date.now();
|
||||
};
|
||||
|
||||
resolution = 1000;
|
||||
}
|
||||
}
|
||||
|
||||
export class Timer {
|
||||
public startTime: number;
|
||||
public time = 0;
|
||||
|
||||
public start() {
|
||||
this.time = 0;
|
||||
this.startTime = Clock.now();
|
||||
}
|
||||
|
||||
public end() {
|
||||
// Set time to MS.
|
||||
this.time = (Clock.now() - this.startTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,9 @@ module ts.formatting {
|
||||
|
||||
export function formatOnEnter(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[] {
|
||||
var line = sourceFile.getLineAndCharacterFromPosition(position).line;
|
||||
Debug.assert(line >= 2);
|
||||
if (line === 1) {
|
||||
return [];
|
||||
}
|
||||
// get the span for the previous\current line
|
||||
var span = {
|
||||
// get start position for the previous line
|
||||
@@ -241,8 +243,18 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
var precedingToken = findPrecedingToken(originalRange.pos, sourceFile);
|
||||
// no preceding token found - start from the beginning of enclosing node
|
||||
return precedingToken ? precedingToken.end : enclosingNode.pos;
|
||||
if (!precedingToken) {
|
||||
// no preceding token found - start from the beginning of enclosing node
|
||||
return enclosingNode.pos;
|
||||
}
|
||||
|
||||
// preceding token ends after the start of original range (i.e when originaRange.pos falls in the middle of literal)
|
||||
// start from the beginning of enclosingNode to handle the entire 'originalRange'
|
||||
if (precedingToken.end >= originalRange.pos) {
|
||||
return enclosingNode.pos;
|
||||
}
|
||||
|
||||
return precedingToken.end;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -597,7 +609,11 @@ module ts.formatting {
|
||||
if (listEndToken !== SyntaxKind.Unknown) {
|
||||
if (formattingScanner.isOnToken()) {
|
||||
var tokenInfo = formattingScanner.readTokenInfo(parent);
|
||||
if (tokenInfo.token.kind === listEndToken) {
|
||||
// consume the list end token only if it is still belong to the parent
|
||||
// there might be the case when current token matches end token but does not considered as one
|
||||
// function (x: function) <--
|
||||
// without this check close paren will be interpreted as list end token for function expression which is wrong
|
||||
if (tokenInfo.token.kind === listEndToken && rangeContainsRange(parent, tokenInfo.token)) {
|
||||
// consume list end token
|
||||
consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation);
|
||||
}
|
||||
|
||||
@@ -187,6 +187,9 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
// consume trailing trivia
|
||||
if (trailingTrivia) {
|
||||
trailingTrivia = undefined;
|
||||
}
|
||||
while(scanner.getStartPos() < endPos) {
|
||||
currentToken = scanner.scan();
|
||||
if (!isTrivia(currentToken)) {
|
||||
|
||||
@@ -12,10 +12,15 @@ module ts.formatting {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// no indentation in string \regex literals
|
||||
if ((precedingToken.kind === SyntaxKind.StringLiteral || precedingToken.kind === SyntaxKind.RegularExpressionLiteral) &&
|
||||
precedingToken.getStart(sourceFile) <= position &&
|
||||
precedingToken.end > position) {
|
||||
// no indentation in string \regex\template literals
|
||||
var precedingTokenIsLiteral =
|
||||
precedingToken.kind === SyntaxKind.StringLiteral ||
|
||||
precedingToken.kind === SyntaxKind.RegularExpressionLiteral ||
|
||||
precedingToken.kind === SyntaxKind.NoSubstitutionTemplateLiteral ||
|
||||
precedingToken.kind === SyntaxKind.TemplateHead ||
|
||||
precedingToken.kind === SyntaxKind.TemplateMiddle ||
|
||||
precedingToken.kind === SyntaxKind.TemplateTail;
|
||||
if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -436,7 +436,7 @@ module TypeScript {
|
||||
This_version_of_the_Javascript_runtime_does_not_support_the_0_function: "This version of the Javascript runtime does not support the '{0}' function.",
|
||||
Unknown_rule: "Unknown rule.",
|
||||
Invalid_line_number_0: "Invalid line number ({0})",
|
||||
Warn_on_expressions_and_declarations_with_an_implied_any_type: "Warn on expressions and declarations with an implied 'any' type.",
|
||||
Raise_error_on_expressions_and_declarations_with_an_implied_any_type: "Raise error on expressions and declarations with an implied 'any' type.",
|
||||
Variable_0_implicitly_has_an_any_type: "Variable '{0}' implicitly has an 'any' type.",
|
||||
Parameter_0_of_1_implicitly_has_an_any_type: "Parameter '{0}' of '{1}' implicitly has an 'any' type.",
|
||||
Parameter_0_of_function_type_implicitly_has_an_any_type: "Parameter '{0}' of function type implicitly has an 'any' type.",
|
||||
|
||||
@@ -1743,7 +1743,7 @@
|
||||
"category": "Error",
|
||||
"code": 7003
|
||||
},
|
||||
"Warn on expressions and declarations with an implied 'any' type.": {
|
||||
"Raise error on expressions and declarations with an implied 'any' type.": {
|
||||
"category": "Message",
|
||||
"code": 7004
|
||||
},
|
||||
|
||||
@@ -852,6 +852,7 @@ module ts {
|
||||
//
|
||||
export interface LanguageServiceHost extends Logger {
|
||||
getCompilationSettings(): CompilerOptions;
|
||||
getNewLine?(): string;
|
||||
getScriptFileNames(): string[];
|
||||
getScriptVersion(fileName: string): string;
|
||||
getScriptIsOpen(fileName: string): boolean;
|
||||
@@ -1962,7 +1963,9 @@ module ts {
|
||||
getCancellationToken: () => cancellationToken,
|
||||
getCanonicalFileName: (filename) => useCaseSensitivefilenames ? filename : filename.toLowerCase(),
|
||||
useCaseSensitiveFileNames: () => useCaseSensitivefilenames,
|
||||
getNewLine: () => "\r\n",
|
||||
getNewLine: () => {
|
||||
return host.getNewLine ? host.getNewLine() : "\r\n";
|
||||
},
|
||||
getDefaultLibFilename: (options): string => {
|
||||
return host.getDefaultLibFilename(options);
|
||||
},
|
||||
|
||||
+1
-1
@@ -417,7 +417,7 @@ declare module TypeScript {
|
||||
This_version_of_the_Javascript_runtime_does_not_support_the_0_function: string;
|
||||
Unknown_rule: string;
|
||||
Invalid_line_number_0: string;
|
||||
Warn_on_expressions_and_declarations_with_an_implied_any_type: string;
|
||||
Raise_error_on_expressions_and_declarations_with_an_implied_any_type: string;
|
||||
Variable_0_implicitly_has_an_any_type: string;
|
||||
Parameter_0_of_1_implicitly_has_an_any_type: string;
|
||||
Parameter_0_of_function_type_implicitly_has_an_any_type: string;
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"noImplicitAny": true,
|
||||
"removeComments": true,
|
||||
"preserveConstEnums": true,
|
||||
"out": "../../built/local/typescriptServices.js",
|
||||
"sourceMap": true
|
||||
},
|
||||
"files": [
|
||||
"../compiler/core.ts",
|
||||
"../compiler/sys.ts",
|
||||
"../compiler/types.ts",
|
||||
"../compiler/scanner.ts",
|
||||
"../compiler/parser.ts",
|
||||
"../compiler/utilities.ts",
|
||||
"../compiler/binder.ts",
|
||||
"../compiler/checker.ts",
|
||||
"../compiler/emitter.ts",
|
||||
"../compiler/program.ts",
|
||||
"../compiler/commandLineParser.ts",
|
||||
"../compiler/diagnosticInformationMap.generated.ts",
|
||||
"breakpoints.ts",
|
||||
"navigationBar.ts",
|
||||
"outliningElementsCollector.ts",
|
||||
"services.ts",
|
||||
"shims.ts",
|
||||
"signatureHelp.ts",
|
||||
"utilities.ts",
|
||||
"formatting/formatting.ts",
|
||||
"formatting/formattingContext.ts",
|
||||
"formatting/formattingRequestKind.ts",
|
||||
"formatting/formattingScanner.ts",
|
||||
"formatting/references.ts",
|
||||
"formatting/rule.ts",
|
||||
"formatting/ruleAction.ts",
|
||||
"formatting/ruleDescriptor.ts",
|
||||
"formatting/ruleFlag.ts",
|
||||
"formatting/ruleOperation.ts",
|
||||
"formatting/ruleOperationContext.ts",
|
||||
"formatting/rules.ts",
|
||||
"formatting/rulesMap.ts",
|
||||
"formatting/rulesProvider.ts",
|
||||
"formatting/smartIndenter.ts",
|
||||
"formatting/tokenRange.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
//// [TypeGuardWithArrayUnion.ts]
|
||||
class Message {
|
||||
value: string;
|
||||
}
|
||||
|
||||
function saySize(message: Message | Message[]) {
|
||||
if (message instanceof Array) {
|
||||
return message.length; // Should have type Message[] here
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [TypeGuardWithArrayUnion.js]
|
||||
var Message = (function () {
|
||||
function Message() {
|
||||
}
|
||||
return Message;
|
||||
})();
|
||||
function saySize(message) {
|
||||
if (message instanceof Array) {
|
||||
return message.length; // Should have type Message[] here
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
=== tests/cases/conformance/expressions/typeGuards/TypeGuardWithArrayUnion.ts ===
|
||||
class Message {
|
||||
>Message : Message
|
||||
|
||||
value: string;
|
||||
>value : string
|
||||
}
|
||||
|
||||
function saySize(message: Message | Message[]) {
|
||||
>saySize : (message: Message | Message[]) => number
|
||||
>message : Message | Message[]
|
||||
>Message : Message
|
||||
>Message : Message
|
||||
|
||||
if (message instanceof Array) {
|
||||
>message instanceof Array : boolean
|
||||
>message : Message | Message[]
|
||||
>Array : ArrayConstructor
|
||||
|
||||
return message.length; // Should have type Message[] here
|
||||
>message.length : number
|
||||
>message : Message[]
|
||||
>length : number
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,27 +55,4 @@ interface B<TBase extends Base> extends A {
|
||||
}
|
||||
var b: B<Derived> = null;
|
||||
var z: Derived = b.foo();
|
||||
class Base { private a: string; }
|
||||
class Derived extends Base { private b: string; }
|
||||
|
||||
// Note - commmenting "extends Foo" prevents the error
|
||||
interface Foo {
|
||||
[i: number]: Base;
|
||||
}
|
||||
interface FooOf<TBase extends Base> extends Foo {
|
||||
[i: number]: TBase;
|
||||
}
|
||||
var x: FooOf<Derived> = null;
|
||||
var y: Derived = x[0];
|
||||
|
||||
/*
|
||||
// Note - the equivalent for normal interface methods works fine:
|
||||
interface A {
|
||||
foo(): Base;
|
||||
}
|
||||
interface B<TBase extends Base> extends A {
|
||||
foo(): TBase;
|
||||
}
|
||||
var b: B<Derived> = null;
|
||||
var z: Derived = b.foo();
|
||||
|
||||
*/
|
||||
|
||||
@@ -65,8 +65,8 @@ var p_cast = <Point> ({
|
||||
>p_cast : Point
|
||||
><Point> ({ x: 0, y: 0, add: function(dx, dy) { return new Point(this.x + dx, this.y + dy); }, mult: function(p) { return p; }}) : Point
|
||||
>Point : Point
|
||||
>({ x: 0, y: 0, add: function(dx, dy) { return new Point(this.x + dx, this.y + dy); }, mult: function(p) { return p; }}) : { x: number; y: number; add: (dx: any, dy: any) => Point; mult: (p: any) => any; }
|
||||
>{ x: 0, y: 0, add: function(dx, dy) { return new Point(this.x + dx, this.y + dy); }, mult: function(p) { return p; }} : { x: number; y: number; add: (dx: any, dy: any) => Point; mult: (p: any) => any; }
|
||||
>({ x: 0, y: 0, add: function(dx, dy) { return new Point(this.x + dx, this.y + dy); }, mult: function(p) { return p; }}) : { x: number; y: number; add: (dx: number, dy: number) => Point; mult: (p: Point) => Point; }
|
||||
>{ x: 0, y: 0, add: function(dx, dy) { return new Point(this.x + dx, this.y + dy); }, mult: function(p) { return p; }} : { x: number; y: number; add: (dx: number, dy: number) => Point; mult: (p: Point) => Point; }
|
||||
|
||||
x: 0,
|
||||
>x : number
|
||||
@@ -75,10 +75,10 @@ var p_cast = <Point> ({
|
||||
>y : number
|
||||
|
||||
add: function(dx, dy) {
|
||||
>add : (dx: any, dy: any) => Point
|
||||
>function(dx, dy) { return new Point(this.x + dx, this.y + dy); } : (dx: any, dy: any) => Point
|
||||
>dx : any
|
||||
>dy : any
|
||||
>add : (dx: number, dy: number) => Point
|
||||
>function(dx, dy) { return new Point(this.x + dx, this.y + dy); } : (dx: number, dy: number) => Point
|
||||
>dx : number
|
||||
>dy : number
|
||||
|
||||
return new Point(this.x + dx, this.y + dy);
|
||||
>new Point(this.x + dx, this.y + dy) : Point
|
||||
@@ -87,19 +87,19 @@ var p_cast = <Point> ({
|
||||
>this.x : any
|
||||
>this : any
|
||||
>x : any
|
||||
>dx : any
|
||||
>dx : number
|
||||
>this.y + dy : any
|
||||
>this.y : any
|
||||
>this : any
|
||||
>y : any
|
||||
>dy : any
|
||||
>dy : number
|
||||
|
||||
},
|
||||
mult: function(p) { return p; }
|
||||
>mult : (p: any) => any
|
||||
>function(p) { return p; } : (p: any) => any
|
||||
>p : any
|
||||
>p : any
|
||||
>mult : (p: Point) => Point
|
||||
>function(p) { return p; } : (p: Point) => Point
|
||||
>p : Point
|
||||
>p : Point
|
||||
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
tests/cases/compiler/cloduleWithPriorInstantiatedModule.ts(2,8): error TS2434: A module declaration cannot be located prior to a class or function with which it is merged
|
||||
|
||||
|
||||
==== tests/cases/compiler/cloduleWithPriorInstantiatedModule.ts (1 errors) ====
|
||||
// Non-ambient & instantiated module.
|
||||
module Moclodule {
|
||||
~~~~~~~~~
|
||||
!!! error TS2434: A module declaration cannot be located prior to a class or function with which it is merged
|
||||
export interface Someinterface {
|
||||
foo(): void;
|
||||
}
|
||||
var x = 10;
|
||||
}
|
||||
|
||||
class Moclodule {
|
||||
}
|
||||
|
||||
// Instantiated module.
|
||||
module Moclodule {
|
||||
export class Manager {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
//// [cloduleWithPriorInstantiatedModule.ts]
|
||||
// Non-ambient & instantiated module.
|
||||
module Moclodule {
|
||||
export interface Someinterface {
|
||||
foo(): void;
|
||||
}
|
||||
var x = 10;
|
||||
}
|
||||
|
||||
class Moclodule {
|
||||
}
|
||||
|
||||
// Instantiated module.
|
||||
module Moclodule {
|
||||
export class Manager {
|
||||
}
|
||||
}
|
||||
|
||||
//// [cloduleWithPriorInstantiatedModule.js]
|
||||
// Non-ambient & instantiated module.
|
||||
var Moclodule;
|
||||
(function (Moclodule) {
|
||||
var x = 10;
|
||||
})(Moclodule || (Moclodule = {}));
|
||||
var Moclodule = (function () {
|
||||
function Moclodule() {
|
||||
}
|
||||
return Moclodule;
|
||||
})();
|
||||
// Instantiated module.
|
||||
var Moclodule;
|
||||
(function (Moclodule) {
|
||||
var Manager = (function () {
|
||||
function Manager() {
|
||||
}
|
||||
return Manager;
|
||||
})();
|
||||
Moclodule.Manager = Manager;
|
||||
})(Moclodule || (Moclodule = {}));
|
||||
@@ -0,0 +1,33 @@
|
||||
//// [cloduleWithPriorUninstantiatedModule.ts]
|
||||
// Non-ambient & uninstantiated module.
|
||||
module Moclodule {
|
||||
export interface Someinterface {
|
||||
foo(): void;
|
||||
}
|
||||
}
|
||||
|
||||
class Moclodule {
|
||||
}
|
||||
|
||||
// Instantiated module.
|
||||
module Moclodule {
|
||||
export class Manager {
|
||||
}
|
||||
}
|
||||
|
||||
//// [cloduleWithPriorUninstantiatedModule.js]
|
||||
var Moclodule = (function () {
|
||||
function Moclodule() {
|
||||
}
|
||||
return Moclodule;
|
||||
})();
|
||||
// Instantiated module.
|
||||
var Moclodule;
|
||||
(function (Moclodule) {
|
||||
var Manager = (function () {
|
||||
function Manager() {
|
||||
}
|
||||
return Manager;
|
||||
})();
|
||||
Moclodule.Manager = Manager;
|
||||
})(Moclodule || (Moclodule = {}));
|
||||
@@ -0,0 +1,25 @@
|
||||
=== tests/cases/compiler/cloduleWithPriorUninstantiatedModule.ts ===
|
||||
// Non-ambient & uninstantiated module.
|
||||
module Moclodule {
|
||||
>Moclodule : typeof Moclodule
|
||||
|
||||
export interface Someinterface {
|
||||
>Someinterface : Someinterface
|
||||
|
||||
foo(): void;
|
||||
>foo : () => void
|
||||
}
|
||||
}
|
||||
|
||||
class Moclodule {
|
||||
>Moclodule : Moclodule
|
||||
}
|
||||
|
||||
// Instantiated module.
|
||||
module Moclodule {
|
||||
>Moclodule : typeof Moclodule
|
||||
|
||||
export class Manager {
|
||||
>Manager : Manager
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
//// [commentEmitWithCommentOnLastLine.ts]
|
||||
var x: any;
|
||||
/*
|
||||
var bar;
|
||||
*/
|
||||
|
||||
//// [commentEmitWithCommentOnLastLine.js]
|
||||
var x;
|
||||
/*
|
||||
var bar;
|
||||
*/
|
||||
@@ -0,0 +1,7 @@
|
||||
=== tests/cases/compiler/commentEmitWithCommentOnLastLine.ts ===
|
||||
var x: any;
|
||||
>x : any
|
||||
|
||||
/*
|
||||
var bar;
|
||||
*/
|
||||
@@ -57,34 +57,4 @@ var c: C<number>;
|
||||
var cc: C<C<number>>;
|
||||
|
||||
c = c.m(cc);
|
||||
var n1: number[];
|
||||
/*
|
||||
interface Array<T> {
|
||||
concat(...items: T[][]): T[]; // Note: This overload needs to be picked for arrays of arrays, even though both are applicable
|
||||
concat(...items: T[]): T[];
|
||||
}
|
||||
*/
|
||||
var fa: number[];
|
||||
|
||||
fa = fa.concat([0]);
|
||||
fa = fa.concat(0);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
|
||||
|
||||
declare class C<T> {
|
||||
public m(p1: C<C<T>>): C<T>;
|
||||
//public p: T;
|
||||
}
|
||||
|
||||
var c: C<number>;
|
||||
var cc: C<C<number>>;
|
||||
|
||||
c = c.m(cc);
|
||||
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
tests/cases/compiler/constEnumBadPropertyNames.ts(2,11): error TS4088: Property 'B' does not exist on 'const' enum 'E'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/constEnumBadPropertyNames.ts (1 errors) ====
|
||||
const enum E { A }
|
||||
var x = E["B"]
|
||||
~~~
|
||||
!!! error TS4088: Property 'B' does not exist on 'const' enum 'E'.
|
||||
@@ -3,8 +3,8 @@ tests/cases/compiler/constEnumErrors.ts(5,8): error TS2300: Duplicate identifier
|
||||
tests/cases/compiler/constEnumErrors.ts(12,9): error TS4083: In 'const' enum declarations member initializer must be constant expression.
|
||||
tests/cases/compiler/constEnumErrors.ts(14,9): error TS4083: In 'const' enum declarations member initializer must be constant expression.
|
||||
tests/cases/compiler/constEnumErrors.ts(15,10): error TS4083: In 'const' enum declarations member initializer must be constant expression.
|
||||
tests/cases/compiler/constEnumErrors.ts(22,13): error TS4085: Index expression arguments in 'const' enums must be of type 'string'.
|
||||
tests/cases/compiler/constEnumErrors.ts(24,13): error TS4085: Index expression arguments in 'const' enums must be of type 'string'.
|
||||
tests/cases/compiler/constEnumErrors.ts(22,13): error TS4085: A const enum member can only be accessed using a string literal.
|
||||
tests/cases/compiler/constEnumErrors.ts(24,13): error TS4085: A const enum member can only be accessed using a string literal.
|
||||
tests/cases/compiler/constEnumErrors.ts(26,9): error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment.
|
||||
tests/cases/compiler/constEnumErrors.ts(27,10): error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment.
|
||||
tests/cases/compiler/constEnumErrors.ts(32,5): error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment.
|
||||
@@ -47,11 +47,11 @@ tests/cases/compiler/constEnumErrors.ts(42,9): error TS4087: 'const' enum member
|
||||
|
||||
var y0 = E2[1]
|
||||
~
|
||||
!!! error TS4085: Index expression arguments in 'const' enums must be of type 'string'.
|
||||
!!! error TS4085: A const enum member can only be accessed using a string literal.
|
||||
var name = "A";
|
||||
var y1 = E2[name];
|
||||
~~~~
|
||||
!!! error TS4085: Index expression arguments in 'const' enums must be of type 'string'.
|
||||
!!! error TS4085: A const enum member can only be accessed using a string literal.
|
||||
|
||||
var x = E2;
|
||||
~~
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(2,22): error TS2339: Property 'foo' does not exist on type 'string'.
|
||||
tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(3,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
||||
Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'T'.
|
||||
tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(3,32): error TS2339: Property 'foo' does not exist on type 'T'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts (1 errors) ====
|
||||
==== tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts (3 errors) ====
|
||||
var f10: <T>(x: T, b: () => (a: T) => void, y: T) => T;
|
||||
f10('', () => a => a.foo, ''); // a is string
|
||||
~~~
|
||||
!!! error TS2339: Property 'foo' does not exist on type 'string'.
|
||||
var r9 = f10('', () => (a => a.foo), 1); // error
|
||||
var r9 = f10('', () => (a => a.foo), 1); // error
|
||||
~~~
|
||||
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
||||
!!! error TS2453: Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'T'.
|
||||
~~~
|
||||
!!! error TS2339: Property 'foo' does not exist on type 'T'.
|
||||
@@ -0,0 +1,71 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(2,17): error TS1187: A parameter property may not be a binding pattern.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(9,17): error TS1187: A parameter property may not be a binding pattern.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(16,17): error TS1187: A parameter property may not be a binding pattern.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(22,26): error TS2339: Property 'x' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(22,35): error TS2339: Property 'y' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(22,43): error TS2339: Property 'y' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(22,52): error TS2339: Property 'z' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(25,30): error TS2339: Property 'x' does not exist on type 'C2'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(25,36): error TS2339: Property 'y' does not exist on type 'C2'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(25,42): error TS2339: Property 'z' does not exist on type 'C2'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(29,30): error TS2339: Property 'x' does not exist on type 'C3'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(29,36): error TS2339: Property 'y' does not exist on type 'C3'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(29,42): error TS2339: Property 'z' does not exist on type 'C3'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts (13 errors) ====
|
||||
class C1 {
|
||||
constructor(public [x, y, z]: string[]) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1187: A parameter property may not be a binding pattern.
|
||||
}
|
||||
}
|
||||
|
||||
type TupleType1 = [string, number, boolean];
|
||||
|
||||
class C2 {
|
||||
constructor(public [x, y, z]: TupleType1) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1187: A parameter property may not be a binding pattern.
|
||||
}
|
||||
}
|
||||
|
||||
type ObjType1 = { x: number; y: string; z: boolean }
|
||||
|
||||
class C3 {
|
||||
constructor(public { x, y, z }: ObjType1) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1187: A parameter property may not be a binding pattern.
|
||||
}
|
||||
}
|
||||
|
||||
var c1 = new C1([]);
|
||||
c1 = new C1(["larry", "{curly}", "moe"]);
|
||||
var useC1Properties = c1.x === c1.y && c1.y === c1.z;
|
||||
~
|
||||
!!! error TS2339: Property 'x' does not exist on type 'C1'.
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'C1'.
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'C1'.
|
||||
~
|
||||
!!! error TS2339: Property 'z' does not exist on type 'C1'.
|
||||
|
||||
var c2 = new C2(["10", 10, !!10]);
|
||||
var [c2_x, c2_y, c2_z] = [c2.x, c2.y, c2.z];
|
||||
~
|
||||
!!! error TS2339: Property 'x' does not exist on type 'C2'.
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'C2'.
|
||||
~
|
||||
!!! error TS2339: Property 'z' does not exist on type 'C2'.
|
||||
|
||||
var c3 = new C3({x: 0, y: "", z: false});
|
||||
c3 = new C3({x: 0, "y": "y", z: true});
|
||||
var [c3_x, c3_y, c3_z] = [c3.x, c3.y, c3.z];
|
||||
~
|
||||
!!! error TS2339: Property 'x' does not exist on type 'C3'.
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'C3'.
|
||||
~
|
||||
!!! error TS2339: Property 'z' does not exist on type 'C3'.
|
||||
@@ -0,0 +1,61 @@
|
||||
//// [destructuringParameterProperties1.ts]
|
||||
class C1 {
|
||||
constructor(public [x, y, z]: string[]) {
|
||||
}
|
||||
}
|
||||
|
||||
type TupleType1 = [string, number, boolean];
|
||||
|
||||
class C2 {
|
||||
constructor(public [x, y, z]: TupleType1) {
|
||||
}
|
||||
}
|
||||
|
||||
type ObjType1 = { x: number; y: string; z: boolean }
|
||||
|
||||
class C3 {
|
||||
constructor(public { x, y, z }: ObjType1) {
|
||||
}
|
||||
}
|
||||
|
||||
var c1 = new C1([]);
|
||||
c1 = new C1(["larry", "{curly}", "moe"]);
|
||||
var useC1Properties = c1.x === c1.y && c1.y === c1.z;
|
||||
|
||||
var c2 = new C2(["10", 10, !!10]);
|
||||
var [c2_x, c2_y, c2_z] = [c2.x, c2.y, c2.z];
|
||||
|
||||
var c3 = new C3({x: 0, y: "", z: false});
|
||||
c3 = new C3({x: 0, "y": "y", z: true});
|
||||
var [c3_x, c3_y, c3_z] = [c3.x, c3.y, c3.z];
|
||||
|
||||
//// [destructuringParameterProperties1.js]
|
||||
var C1 = (function () {
|
||||
function C1(_a) {
|
||||
var x = _a[0], y = _a[1], z = _a[2];
|
||||
this.[x, y, z] = [x, y, z];
|
||||
}
|
||||
return C1;
|
||||
})();
|
||||
var C2 = (function () {
|
||||
function C2(_a) {
|
||||
var x = _a[0], y = _a[1], z = _a[2];
|
||||
this.[x, y, z] = [x, y, z];
|
||||
}
|
||||
return C2;
|
||||
})();
|
||||
var C3 = (function () {
|
||||
function C3(_a) {
|
||||
var x = _a.x, y = _a.y, z = _a.z;
|
||||
this.{ x, y, z } = { x, y, z };
|
||||
}
|
||||
return C3;
|
||||
})();
|
||||
var c1 = new C1([]);
|
||||
c1 = new C1(["larry", "{curly}", "moe"]);
|
||||
var useC1Properties = c1.x === c1.y && c1.y === c1.z;
|
||||
var c2 = new C2(["10", 10, !!10]);
|
||||
var _a = [c2.x, c2.y, c2.z], c2_x = _a[0], c2_y = _a[1], c2_z = _a[2];
|
||||
var c3 = new C3({ x: 0, y: "", z: false });
|
||||
c3 = new C3({ x: 0, "y": "y", z: true });
|
||||
var _b = [c3.x, c3.y, c3.z], c3_x = _b[0], c3_y = _b[1], c3_z = _b[2];
|
||||
@@ -0,0 +1,56 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(2,36): error TS1187: A parameter property may not be a binding pattern.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(3,59): error TS2339: Property 'b' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(3,83): error TS2339: Property 'c' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(4,18): error TS2339: Property 'a' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(9,21): error TS2339: Property 'a' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(13,21): error TS2339: Property 'b' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(17,21): error TS2339: Property 'c' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(21,27): error TS2345: Argument of type '[number, undefined, string]' is not assignable to parameter of type '[number, string, boolean]'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts (8 errors) ====
|
||||
class C1 {
|
||||
constructor(private k: number, private [a, b, c]: [number, string, boolean]) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1187: A parameter property may not be a binding pattern.
|
||||
if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) {
|
||||
~
|
||||
!!! error TS2339: Property 'b' does not exist on type 'C1'.
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'C1'.
|
||||
this.a = a || k;
|
||||
~
|
||||
!!! error TS2339: Property 'a' does not exist on type 'C1'.
|
||||
}
|
||||
}
|
||||
|
||||
public getA() {
|
||||
return this.a
|
||||
~
|
||||
!!! error TS2339: Property 'a' does not exist on type 'C1'.
|
||||
}
|
||||
|
||||
public getB() {
|
||||
return this.b
|
||||
~
|
||||
!!! error TS2339: Property 'b' does not exist on type 'C1'.
|
||||
}
|
||||
|
||||
public getC() {
|
||||
return this.c;
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'C1'.
|
||||
}
|
||||
}
|
||||
|
||||
var x = new C1(undefined, [0, undefined, ""]);
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '[number, undefined, string]' is not assignable to parameter of type '[number, string, boolean]'.
|
||||
var [x_a, x_b, x_c] = [x.getA(), x.getB(), x.getC()];
|
||||
|
||||
var y = new C1(10, [0, "", true]);
|
||||
var [y_a, y_b, y_c] = [y.getA(), y.getB(), y.getC()];
|
||||
|
||||
var z = new C1(10, [undefined, "", null]);
|
||||
var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()];
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
//// [destructuringParameterProperties2.ts]
|
||||
class C1 {
|
||||
constructor(private k: number, private [a, b, c]: [number, string, boolean]) {
|
||||
if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) {
|
||||
this.a = a || k;
|
||||
}
|
||||
}
|
||||
|
||||
public getA() {
|
||||
return this.a
|
||||
}
|
||||
|
||||
public getB() {
|
||||
return this.b
|
||||
}
|
||||
|
||||
public getC() {
|
||||
return this.c;
|
||||
}
|
||||
}
|
||||
|
||||
var x = new C1(undefined, [0, undefined, ""]);
|
||||
var [x_a, x_b, x_c] = [x.getA(), x.getB(), x.getC()];
|
||||
|
||||
var y = new C1(10, [0, "", true]);
|
||||
var [y_a, y_b, y_c] = [y.getA(), y.getB(), y.getC()];
|
||||
|
||||
var z = new C1(10, [undefined, "", null]);
|
||||
var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()];
|
||||
|
||||
|
||||
//// [destructuringParameterProperties2.js]
|
||||
var C1 = (function () {
|
||||
function C1(k, _a) {
|
||||
var a = _a[0], b = _a[1], c = _a[2];
|
||||
this.k = k;
|
||||
this.[a, b, c] = [a, b, c];
|
||||
if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) {
|
||||
this.a = a || k;
|
||||
}
|
||||
}
|
||||
C1.prototype.getA = function () {
|
||||
return this.a;
|
||||
};
|
||||
C1.prototype.getB = function () {
|
||||
return this.b;
|
||||
};
|
||||
C1.prototype.getC = function () {
|
||||
return this.c;
|
||||
};
|
||||
return C1;
|
||||
})();
|
||||
var x = new C1(undefined, [0, undefined, ""]);
|
||||
var _a = [x.getA(), x.getB(), x.getC()], x_a = _a[0], x_b = _a[1], x_c = _a[2];
|
||||
var y = new C1(10, [0, "", true]);
|
||||
var _b = [y.getA(), y.getB(), y.getC()], y_a = _b[0], y_b = _b[1], y_c = _b[2];
|
||||
var z = new C1(10, [undefined, "", null]);
|
||||
var _c = [z.getA(), z.getB(), z.getC()], z_a = _c[0], z_b = _c[1], z_c = _c[2];
|
||||
@@ -0,0 +1,56 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(2,31): error TS1187: A parameter property may not be a binding pattern.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(3,59): error TS2339: Property 'b' does not exist on type 'C1<T, U, V>'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(3,83): error TS2339: Property 'c' does not exist on type 'C1<T, U, V>'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(4,18): error TS2339: Property 'a' does not exist on type 'C1<T, U, V>'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(9,21): error TS2339: Property 'a' does not exist on type 'C1<T, U, V>'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(13,21): error TS2339: Property 'b' does not exist on type 'C1<T, U, V>'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(17,21): error TS2339: Property 'c' does not exist on type 'C1<T, U, V>'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts (7 errors) ====
|
||||
class C1<T, U, V> {
|
||||
constructor(private k: T, private [a, b, c]: [T,U,V]) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1187: A parameter property may not be a binding pattern.
|
||||
if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) {
|
||||
~
|
||||
!!! error TS2339: Property 'b' does not exist on type 'C1<T, U, V>'.
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'C1<T, U, V>'.
|
||||
this.a = a || k;
|
||||
~
|
||||
!!! error TS2339: Property 'a' does not exist on type 'C1<T, U, V>'.
|
||||
}
|
||||
}
|
||||
|
||||
public getA() {
|
||||
return this.a
|
||||
~
|
||||
!!! error TS2339: Property 'a' does not exist on type 'C1<T, U, V>'.
|
||||
}
|
||||
|
||||
public getB() {
|
||||
return this.b
|
||||
~
|
||||
!!! error TS2339: Property 'b' does not exist on type 'C1<T, U, V>'.
|
||||
}
|
||||
|
||||
public getC() {
|
||||
return this.c;
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'C1<T, U, V>'.
|
||||
}
|
||||
}
|
||||
|
||||
var x = new C1(undefined, [0, true, ""]);
|
||||
var [x_a, x_b, x_c] = [x.getA(), x.getB(), x.getC()];
|
||||
|
||||
var y = new C1(10, [0, true, true]);
|
||||
var [y_a, y_b, y_c] = [y.getA(), y.getB(), y.getC()];
|
||||
|
||||
var z = new C1(10, [undefined, "", ""]);
|
||||
var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()];
|
||||
|
||||
var w = new C1(10, [undefined, undefined, undefined]);
|
||||
var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()];
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
//// [destructuringParameterProperties3.ts]
|
||||
class C1<T, U, V> {
|
||||
constructor(private k: T, private [a, b, c]: [T,U,V]) {
|
||||
if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) {
|
||||
this.a = a || k;
|
||||
}
|
||||
}
|
||||
|
||||
public getA() {
|
||||
return this.a
|
||||
}
|
||||
|
||||
public getB() {
|
||||
return this.b
|
||||
}
|
||||
|
||||
public getC() {
|
||||
return this.c;
|
||||
}
|
||||
}
|
||||
|
||||
var x = new C1(undefined, [0, true, ""]);
|
||||
var [x_a, x_b, x_c] = [x.getA(), x.getB(), x.getC()];
|
||||
|
||||
var y = new C1(10, [0, true, true]);
|
||||
var [y_a, y_b, y_c] = [y.getA(), y.getB(), y.getC()];
|
||||
|
||||
var z = new C1(10, [undefined, "", ""]);
|
||||
var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()];
|
||||
|
||||
var w = new C1(10, [undefined, undefined, undefined]);
|
||||
var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()];
|
||||
|
||||
|
||||
//// [destructuringParameterProperties3.js]
|
||||
var C1 = (function () {
|
||||
function C1(k, _a) {
|
||||
var a = _a[0], b = _a[1], c = _a[2];
|
||||
this.k = k;
|
||||
this.[a, b, c] = [a, b, c];
|
||||
if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) {
|
||||
this.a = a || k;
|
||||
}
|
||||
}
|
||||
C1.prototype.getA = function () {
|
||||
return this.a;
|
||||
};
|
||||
C1.prototype.getB = function () {
|
||||
return this.b;
|
||||
};
|
||||
C1.prototype.getC = function () {
|
||||
return this.c;
|
||||
};
|
||||
return C1;
|
||||
})();
|
||||
var x = new C1(undefined, [0, true, ""]);
|
||||
var _a = [x.getA(), x.getB(), x.getC()], x_a = _a[0], x_b = _a[1], x_c = _a[2];
|
||||
var y = new C1(10, [0, true, true]);
|
||||
var _b = [y.getA(), y.getB(), y.getC()], y_a = _b[0], y_b = _b[1], y_c = _b[2];
|
||||
var z = new C1(10, [undefined, "", ""]);
|
||||
var _c = [z.getA(), z.getB(), z.getC()], z_a = _c[0], z_b = _c[1], z_c = _c[2];
|
||||
var w = new C1(10, [undefined, undefined, undefined]);
|
||||
var _d = [z.getA(), z.getB(), z.getC()], z_a = _d[0], z_b = _d[1], z_c = _d[2];
|
||||
@@ -0,0 +1,60 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(3,31): error TS1187: A parameter property may not be a binding pattern.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(4,59): error TS2339: Property 'b' does not exist on type 'C1<T, U, V>'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(4,83): error TS2339: Property 'c' does not exist on type 'C1<T, U, V>'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(5,18): error TS2339: Property 'a' does not exist on type 'C1<T, U, V>'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(10,21): error TS2339: Property 'a' does not exist on type 'C1<T, U, V>'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(14,21): error TS2339: Property 'b' does not exist on type 'C1<T, U, V>'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(18,21): error TS2339: Property 'c' does not exist on type 'C1<T, U, V>'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(24,24): error TS2339: Property 'a' does not exist on type 'C2'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(24,34): error TS2339: Property 'b' does not exist on type 'C2'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(24,44): error TS2339: Property 'c' does not exist on type 'C2'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts (10 errors) ====
|
||||
|
||||
class C1<T, U, V> {
|
||||
constructor(private k: T, protected [a, b, c]: [T,U,V]) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1187: A parameter property may not be a binding pattern.
|
||||
if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) {
|
||||
~
|
||||
!!! error TS2339: Property 'b' does not exist on type 'C1<T, U, V>'.
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'C1<T, U, V>'.
|
||||
this.a = a || k;
|
||||
~
|
||||
!!! error TS2339: Property 'a' does not exist on type 'C1<T, U, V>'.
|
||||
}
|
||||
}
|
||||
|
||||
public getA() {
|
||||
return this.a
|
||||
~
|
||||
!!! error TS2339: Property 'a' does not exist on type 'C1<T, U, V>'.
|
||||
}
|
||||
|
||||
public getB() {
|
||||
return this.b
|
||||
~
|
||||
!!! error TS2339: Property 'b' does not exist on type 'C1<T, U, V>'.
|
||||
}
|
||||
|
||||
public getC() {
|
||||
return this.c;
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'C1<T, U, V>'.
|
||||
}
|
||||
}
|
||||
|
||||
class C2 extends C1<number, string, boolean> {
|
||||
public doSomethingWithSuperProperties() {
|
||||
return `${this.a} ${this.b} ${this.c}`;
|
||||
~
|
||||
!!! error TS2339: Property 'a' does not exist on type 'C2'.
|
||||
~
|
||||
!!! error TS2339: Property 'b' does not exist on type 'C2'.
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'C2'.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
//// [destructuringParameterProperties4.ts]
|
||||
|
||||
class C1<T, U, V> {
|
||||
constructor(private k: T, protected [a, b, c]: [T,U,V]) {
|
||||
if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) {
|
||||
this.a = a || k;
|
||||
}
|
||||
}
|
||||
|
||||
public getA() {
|
||||
return this.a
|
||||
}
|
||||
|
||||
public getB() {
|
||||
return this.b
|
||||
}
|
||||
|
||||
public getC() {
|
||||
return this.c;
|
||||
}
|
||||
}
|
||||
|
||||
class C2 extends C1<number, string, boolean> {
|
||||
public doSomethingWithSuperProperties() {
|
||||
return `${this.a} ${this.b} ${this.c}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [destructuringParameterProperties4.js]
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var C1 = (function () {
|
||||
function C1(k, [a, b, c]) {
|
||||
this.k = k;
|
||||
this.[a, b, c] = [a, b, c];
|
||||
if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) {
|
||||
this.a = a || k;
|
||||
}
|
||||
}
|
||||
C1.prototype.getA = function () {
|
||||
return this.a;
|
||||
};
|
||||
C1.prototype.getB = function () {
|
||||
return this.b;
|
||||
};
|
||||
C1.prototype.getC = function () {
|
||||
return this.c;
|
||||
};
|
||||
return C1;
|
||||
})();
|
||||
var C2 = (function (_super) {
|
||||
__extends(C2, _super);
|
||||
function C2() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
C2.prototype.doSomethingWithSuperProperties = function () {
|
||||
return `${this.a} ${this.b} ${this.c}`;
|
||||
};
|
||||
return C2;
|
||||
})(C1);
|
||||
@@ -0,0 +1,51 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(5,17): error TS1187: A parameter property may not be a binding pattern.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(5,27): error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x1' and no string index signature.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(5,31): error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x2' and no string index signature.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(5,35): error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x3' and no string index signature.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,29): error TS2339: Property 'x1' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,40): error TS2339: Property 'x2' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,51): error TS2339: Property 'x3' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,62): error TS2339: Property 'y' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,72): error TS2339: Property 'z' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(11,16): error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'.
|
||||
Types of property '0' are incompatible.
|
||||
Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'.
|
||||
Property 'x' is missing in type '{ x1: number; x2: string; x3: boolean; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts (10 errors) ====
|
||||
type ObjType1 = { x: number; y: string; z: boolean }
|
||||
type TupleType1 = [ObjType1, number, string]
|
||||
|
||||
class C1 {
|
||||
constructor(public [{ x1, x2, x3 }, y, z]: TupleType1) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1187: A parameter property may not be a binding pattern.
|
||||
~~
|
||||
!!! error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x1' and no string index signature.
|
||||
~~
|
||||
!!! error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x2' and no string index signature.
|
||||
~~
|
||||
!!! error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x3' and no string index signature.
|
||||
var foo: any = x1 || x2 || x3 || y || z;
|
||||
var bar: any = this.x1 || this.x2 || this.x3 || this.y || this.z;
|
||||
~~
|
||||
!!! error TS2339: Property 'x1' does not exist on type 'C1'.
|
||||
~~
|
||||
!!! error TS2339: Property 'x2' does not exist on type 'C1'.
|
||||
~~
|
||||
!!! error TS2339: Property 'x3' does not exist on type 'C1'.
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'C1'.
|
||||
~
|
||||
!!! error TS2339: Property 'z' does not exist on type 'C1'.
|
||||
}
|
||||
}
|
||||
|
||||
var a = new C1([{ x1: 10, x2: "", x3: true }, "", false]);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'.
|
||||
!!! error TS2345: Types of property '0' are incompatible.
|
||||
!!! error TS2345: Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'.
|
||||
!!! error TS2345: Property 'x' is missing in type '{ x1: number; x2: string; x3: boolean; }'.
|
||||
var [a_x1, a_x2, a_x3, a_y, a_z] = [a.x1, a.x2, a.x3, a.y, a.z];
|
||||
@@ -0,0 +1,26 @@
|
||||
//// [destructuringParameterProperties5.ts]
|
||||
type ObjType1 = { x: number; y: string; z: boolean }
|
||||
type TupleType1 = [ObjType1, number, string]
|
||||
|
||||
class C1 {
|
||||
constructor(public [{ x1, x2, x3 }, y, z]: TupleType1) {
|
||||
var foo: any = x1 || x2 || x3 || y || z;
|
||||
var bar: any = this.x1 || this.x2 || this.x3 || this.y || this.z;
|
||||
}
|
||||
}
|
||||
|
||||
var a = new C1([{ x1: 10, x2: "", x3: true }, "", false]);
|
||||
var [a_x1, a_x2, a_x3, a_y, a_z] = [a.x1, a.x2, a.x3, a.y, a.z];
|
||||
|
||||
//// [destructuringParameterProperties5.js]
|
||||
var C1 = (function () {
|
||||
function C1(_a) {
|
||||
var _b = _a[0], x1 = _b.x1, x2 = _b.x2, x3 = _b.x3, y = _a[1], z = _a[2];
|
||||
this.[{ x1, x2, x3 }, y, z] = [{ x1, x2, x3 }, y, z];
|
||||
var foo = x1 || x2 || x3 || y || z;
|
||||
var bar = this.x1 || this.x2 || this.x3 || this.y || this.z;
|
||||
}
|
||||
return C1;
|
||||
})();
|
||||
var a = new C1([{ x1: 10, x2: "", x3: true }, "", false]);
|
||||
var _a = [a.x1, a.x2, a.x3, a.y, a.z], a_x1 = _a[0], a_x2 = _a[1], a_x3 = _a[2], a_y = _a[3], a_z = _a[4];
|
||||
@@ -0,0 +1,27 @@
|
||||
//// [emitDefaultParametersFunction.ts]
|
||||
function foo(x: string, y = 10) { }
|
||||
function baz(x: string, y = 5, ...rest) { }
|
||||
function bar(y = 10) { }
|
||||
function bar1(y = 10, ...rest) { }
|
||||
|
||||
//// [emitDefaultParametersFunction.js]
|
||||
function foo(x, y) {
|
||||
if (y === void 0) { y = 10; }
|
||||
}
|
||||
function baz(x, y) {
|
||||
if (y === void 0) { y = 5; }
|
||||
var rest = [];
|
||||
for (var _i = 2; _i < arguments.length; _i++) {
|
||||
rest[_i - 2] = arguments[_i];
|
||||
}
|
||||
}
|
||||
function bar(y) {
|
||||
if (y === void 0) { y = 10; }
|
||||
}
|
||||
function bar1(y) {
|
||||
if (y === void 0) { y = 10; }
|
||||
var rest = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
rest[_i - 1] = arguments[_i];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
=== tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunction.ts ===
|
||||
function foo(x: string, y = 10) { }
|
||||
>foo : (x: string, y?: number) => void
|
||||
>x : string
|
||||
>y : number
|
||||
|
||||
function baz(x: string, y = 5, ...rest) { }
|
||||
>baz : (x: string, y?: number, ...rest: any[]) => void
|
||||
>x : string
|
||||
>y : number
|
||||
>rest : any[]
|
||||
|
||||
function bar(y = 10) { }
|
||||
>bar : (y?: number) => void
|
||||
>y : number
|
||||
|
||||
function bar1(y = 10, ...rest) { }
|
||||
>bar1 : (y?: number, ...rest: any[]) => void
|
||||
>y : number
|
||||
>rest : any[]
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
//// [emitDefaultParametersFunctionES6.ts]
|
||||
function foo(x: string, y = 10) { }
|
||||
function baz(x: string, y = 5, ...rest) { }
|
||||
function bar(y = 10) { }
|
||||
function bar1(y = 10, ...rest) { }
|
||||
|
||||
//// [emitDefaultParametersFunctionES6.js]
|
||||
function foo(x, y = 10) {
|
||||
}
|
||||
function baz(x, y = 5, ...rest) {
|
||||
}
|
||||
function bar(y = 10) {
|
||||
}
|
||||
function bar1(y = 10, ...rest) {
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
=== tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionES6.ts ===
|
||||
function foo(x: string, y = 10) { }
|
||||
>foo : (x: string, y?: number) => void
|
||||
>x : string
|
||||
>y : number
|
||||
|
||||
function baz(x: string, y = 5, ...rest) { }
|
||||
>baz : (x: string, y?: number, ...rest: any[]) => void
|
||||
>x : string
|
||||
>y : number
|
||||
>rest : any[]
|
||||
|
||||
function bar(y = 10) { }
|
||||
>bar : (y?: number) => void
|
||||
>y : number
|
||||
|
||||
function bar1(y = 10, ...rest) { }
|
||||
>bar1 : (y?: number, ...rest: any[]) => void
|
||||
>y : number
|
||||
>rest : any[]
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
//// [emitDefaultParametersFunctionExpression.ts]
|
||||
var lambda1 = (y = "hello") => { }
|
||||
var lambda2 = (x: number, y = "hello") => { }
|
||||
var lambda3 = (x: number, y = "hello", ...rest) => { }
|
||||
var lambda4 = (y = "hello", ...rest) => { }
|
||||
|
||||
var x = function (str = "hello", ...rest) { }
|
||||
var y = (function (num = 10, boo = false, ...rest) { })()
|
||||
var z = (function (num: number, boo = false, ...rest) { })(10)
|
||||
|
||||
|
||||
//// [emitDefaultParametersFunctionExpression.js]
|
||||
var lambda1 = function (y) {
|
||||
if (y === void 0) { y = "hello"; }
|
||||
};
|
||||
var lambda2 = function (x, y) {
|
||||
if (y === void 0) { y = "hello"; }
|
||||
};
|
||||
var lambda3 = function (x, y) {
|
||||
if (y === void 0) { y = "hello"; }
|
||||
var rest = [];
|
||||
for (var _i = 2; _i < arguments.length; _i++) {
|
||||
rest[_i - 2] = arguments[_i];
|
||||
}
|
||||
};
|
||||
var lambda4 = function (y) {
|
||||
if (y === void 0) { y = "hello"; }
|
||||
var rest = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
rest[_i - 1] = arguments[_i];
|
||||
}
|
||||
};
|
||||
var x = function (str) {
|
||||
if (str === void 0) { str = "hello"; }
|
||||
var rest = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
rest[_i - 1] = arguments[_i];
|
||||
}
|
||||
};
|
||||
var y = (function (num, boo) {
|
||||
if (num === void 0) { num = 10; }
|
||||
if (boo === void 0) { boo = false; }
|
||||
var rest = [];
|
||||
for (var _i = 2; _i < arguments.length; _i++) {
|
||||
rest[_i - 2] = arguments[_i];
|
||||
}
|
||||
})();
|
||||
var z = (function (num, boo) {
|
||||
if (boo === void 0) { boo = false; }
|
||||
var rest = [];
|
||||
for (var _i = 2; _i < arguments.length; _i++) {
|
||||
rest[_i - 2] = arguments[_i];
|
||||
}
|
||||
})(10);
|
||||
@@ -0,0 +1,49 @@
|
||||
=== tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionExpression.ts ===
|
||||
var lambda1 = (y = "hello") => { }
|
||||
>lambda1 : (y?: string) => void
|
||||
>(y = "hello") => { } : (y?: string) => void
|
||||
>y : string
|
||||
|
||||
var lambda2 = (x: number, y = "hello") => { }
|
||||
>lambda2 : (x: number, y?: string) => void
|
||||
>(x: number, y = "hello") => { } : (x: number, y?: string) => void
|
||||
>x : number
|
||||
>y : string
|
||||
|
||||
var lambda3 = (x: number, y = "hello", ...rest) => { }
|
||||
>lambda3 : (x: number, y?: string, ...rest: any[]) => void
|
||||
>(x: number, y = "hello", ...rest) => { } : (x: number, y?: string, ...rest: any[]) => void
|
||||
>x : number
|
||||
>y : string
|
||||
>rest : any[]
|
||||
|
||||
var lambda4 = (y = "hello", ...rest) => { }
|
||||
>lambda4 : (y?: string, ...rest: any[]) => void
|
||||
>(y = "hello", ...rest) => { } : (y?: string, ...rest: any[]) => void
|
||||
>y : string
|
||||
>rest : any[]
|
||||
|
||||
var x = function (str = "hello", ...rest) { }
|
||||
>x : (str?: string, ...rest: any[]) => void
|
||||
>function (str = "hello", ...rest) { } : (str?: string, ...rest: any[]) => void
|
||||
>str : string
|
||||
>rest : any[]
|
||||
|
||||
var y = (function (num = 10, boo = false, ...rest) { })()
|
||||
>y : void
|
||||
>(function (num = 10, boo = false, ...rest) { })() : void
|
||||
>(function (num = 10, boo = false, ...rest) { }) : (num?: number, boo?: boolean, ...rest: any[]) => void
|
||||
>function (num = 10, boo = false, ...rest) { } : (num?: number, boo?: boolean, ...rest: any[]) => void
|
||||
>num : number
|
||||
>boo : boolean
|
||||
>rest : any[]
|
||||
|
||||
var z = (function (num: number, boo = false, ...rest) { })(10)
|
||||
>z : void
|
||||
>(function (num: number, boo = false, ...rest) { })(10) : void
|
||||
>(function (num: number, boo = false, ...rest) { }) : (num: number, boo?: boolean, ...rest: any[]) => void
|
||||
>function (num: number, boo = false, ...rest) { } : (num: number, boo?: boolean, ...rest: any[]) => void
|
||||
>num : number
|
||||
>boo : boolean
|
||||
>rest : any[]
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//// [emitDefaultParametersFunctionExpressionES6.ts]
|
||||
var lambda1 = (y = "hello") => { }
|
||||
var lambda2 = (x: number, y = "hello") => { }
|
||||
var lambda3 = (x: number, y = "hello", ...rest) => { }
|
||||
var lambda4 = (y = "hello", ...rest) => { }
|
||||
|
||||
var x = function (str = "hello", ...rest) { }
|
||||
var y = (function (num = 10, boo = false, ...rest) { })()
|
||||
var z = (function (num: number, boo = false, ...rest) { })(10)
|
||||
|
||||
//// [emitDefaultParametersFunctionExpressionES6.js]
|
||||
var lambda1 = function (y = "hello") {
|
||||
};
|
||||
var lambda2 = function (x, y = "hello") {
|
||||
};
|
||||
var lambda3 = function (x, y = "hello", ...rest) {
|
||||
};
|
||||
var lambda4 = function (y = "hello", ...rest) {
|
||||
};
|
||||
var x = function (str = "hello", ...rest) {
|
||||
};
|
||||
var y = (function (num = 10, boo = false, ...rest) {
|
||||
})();
|
||||
var z = (function (num, boo = false, ...rest) {
|
||||
})(10);
|
||||
@@ -0,0 +1,49 @@
|
||||
=== tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionExpressionES6.ts ===
|
||||
var lambda1 = (y = "hello") => { }
|
||||
>lambda1 : (y?: string) => void
|
||||
>(y = "hello") => { } : (y?: string) => void
|
||||
>y : string
|
||||
|
||||
var lambda2 = (x: number, y = "hello") => { }
|
||||
>lambda2 : (x: number, y?: string) => void
|
||||
>(x: number, y = "hello") => { } : (x: number, y?: string) => void
|
||||
>x : number
|
||||
>y : string
|
||||
|
||||
var lambda3 = (x: number, y = "hello", ...rest) => { }
|
||||
>lambda3 : (x: number, y?: string, ...rest: any[]) => void
|
||||
>(x: number, y = "hello", ...rest) => { } : (x: number, y?: string, ...rest: any[]) => void
|
||||
>x : number
|
||||
>y : string
|
||||
>rest : any[]
|
||||
|
||||
var lambda4 = (y = "hello", ...rest) => { }
|
||||
>lambda4 : (y?: string, ...rest: any[]) => void
|
||||
>(y = "hello", ...rest) => { } : (y?: string, ...rest: any[]) => void
|
||||
>y : string
|
||||
>rest : any[]
|
||||
|
||||
var x = function (str = "hello", ...rest) { }
|
||||
>x : (str?: string, ...rest: any[]) => void
|
||||
>function (str = "hello", ...rest) { } : (str?: string, ...rest: any[]) => void
|
||||
>str : string
|
||||
>rest : any[]
|
||||
|
||||
var y = (function (num = 10, boo = false, ...rest) { })()
|
||||
>y : void
|
||||
>(function (num = 10, boo = false, ...rest) { })() : void
|
||||
>(function (num = 10, boo = false, ...rest) { }) : (num?: number, boo?: boolean, ...rest: any[]) => void
|
||||
>function (num = 10, boo = false, ...rest) { } : (num?: number, boo?: boolean, ...rest: any[]) => void
|
||||
>num : number
|
||||
>boo : boolean
|
||||
>rest : any[]
|
||||
|
||||
var z = (function (num: number, boo = false, ...rest) { })(10)
|
||||
>z : void
|
||||
>(function (num: number, boo = false, ...rest) { })(10) : void
|
||||
>(function (num: number, boo = false, ...rest) { }) : (num: number, boo?: boolean, ...rest: any[]) => void
|
||||
>function (num: number, boo = false, ...rest) { } : (num: number, boo?: boolean, ...rest: any[]) => void
|
||||
>num : number
|
||||
>boo : boolean
|
||||
>rest : any[]
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
//// [emitDefaultParametersFunctionProperty.ts]
|
||||
var obj2 = {
|
||||
func1(y = 10, ...rest) { },
|
||||
func2(x = "hello") { },
|
||||
func3(x: string, z: number, y = "hello") { },
|
||||
func4(x: string, z: number, y = "hello", ...rest) { },
|
||||
}
|
||||
|
||||
|
||||
//// [emitDefaultParametersFunctionProperty.js]
|
||||
var obj2 = {
|
||||
func1: function (y) {
|
||||
if (y === void 0) { y = 10; }
|
||||
var rest = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
rest[_i - 1] = arguments[_i];
|
||||
}
|
||||
},
|
||||
func2: function (x) {
|
||||
if (x === void 0) { x = "hello"; }
|
||||
},
|
||||
func3: function (x, z, y) {
|
||||
if (y === void 0) { y = "hello"; }
|
||||
},
|
||||
func4: function (x, z, y) {
|
||||
if (y === void 0) { y = "hello"; }
|
||||
var rest = [];
|
||||
for (var _i = 3; _i < arguments.length; _i++) {
|
||||
rest[_i - 3] = arguments[_i];
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
=== tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionProperty.ts ===
|
||||
var obj2 = {
|
||||
>obj2 : { func1(y?: number, ...rest: any[]): void; func2(x?: string): void; func3(x: string, z: number, y?: string): void; func4(x: string, z: number, y?: string, ...rest: any[]): void; }
|
||||
>{ func1(y = 10, ...rest) { }, func2(x = "hello") { }, func3(x: string, z: number, y = "hello") { }, func4(x: string, z: number, y = "hello", ...rest) { },} : { func1(y?: number, ...rest: any[]): void; func2(x?: string): void; func3(x: string, z: number, y?: string): void; func4(x: string, z: number, y?: string, ...rest: any[]): void; }
|
||||
|
||||
func1(y = 10, ...rest) { },
|
||||
>func1 : (y?: number, ...rest: any[]) => void
|
||||
>y : number
|
||||
>rest : any[]
|
||||
|
||||
func2(x = "hello") { },
|
||||
>func2 : (x?: string) => void
|
||||
>x : string
|
||||
|
||||
func3(x: string, z: number, y = "hello") { },
|
||||
>func3 : (x: string, z: number, y?: string) => void
|
||||
>x : string
|
||||
>z : number
|
||||
>y : string
|
||||
|
||||
func4(x: string, z: number, y = "hello", ...rest) { },
|
||||
>func4 : (x: string, z: number, y?: string, ...rest: any[]) => void
|
||||
>x : string
|
||||
>z : number
|
||||
>y : string
|
||||
>rest : any[]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//// [emitDefaultParametersFunctionPropertyES6.ts]
|
||||
var obj2 = {
|
||||
func1(y = 10, ...rest) { },
|
||||
func2(x = "hello") { },
|
||||
func3(x: string, z: number, y = "hello") { },
|
||||
func4(x: string, z: number, y = "hello", ...rest) { },
|
||||
}
|
||||
|
||||
//// [emitDefaultParametersFunctionPropertyES6.js]
|
||||
var obj2 = {
|
||||
func1(y = 10, ...rest) {
|
||||
},
|
||||
func2(x = "hello") {
|
||||
},
|
||||
func3(x, z, y = "hello") {
|
||||
},
|
||||
func4(x, z, y = "hello", ...rest) {
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
=== tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionPropertyES6.ts ===
|
||||
var obj2 = {
|
||||
>obj2 : { func1(y?: number, ...rest: any[]): void; func2(x?: string): void; func3(x: string, z: number, y?: string): void; func4(x: string, z: number, y?: string, ...rest: any[]): void; }
|
||||
>{ func1(y = 10, ...rest) { }, func2(x = "hello") { }, func3(x: string, z: number, y = "hello") { }, func4(x: string, z: number, y = "hello", ...rest) { },} : { func1(y?: number, ...rest: any[]): void; func2(x?: string): void; func3(x: string, z: number, y?: string): void; func4(x: string, z: number, y?: string, ...rest: any[]): void; }
|
||||
|
||||
func1(y = 10, ...rest) { },
|
||||
>func1 : (y?: number, ...rest: any[]) => void
|
||||
>y : number
|
||||
>rest : any[]
|
||||
|
||||
func2(x = "hello") { },
|
||||
>func2 : (x?: string) => void
|
||||
>x : string
|
||||
|
||||
func3(x: string, z: number, y = "hello") { },
|
||||
>func3 : (x: string, z: number, y?: string) => void
|
||||
>x : string
|
||||
>z : number
|
||||
>y : string
|
||||
|
||||
func4(x: string, z: number, y = "hello", ...rest) { },
|
||||
>func4 : (x: string, z: number, y?: string, ...rest: any[]) => void
|
||||
>x : string
|
||||
>z : number
|
||||
>y : string
|
||||
>rest : any[]
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
//// [emitDefaultParametersMethod.ts]
|
||||
class C {
|
||||
constructor(t: boolean, z: string, x: number, y = "hello") { }
|
||||
|
||||
public foo(x: string, t = false) { }
|
||||
public foo1(x: string, t = false, ...rest) { }
|
||||
public bar(t = false) { }
|
||||
public boo(t = false, ...rest) { }
|
||||
}
|
||||
|
||||
class D {
|
||||
constructor(y = "hello") { }
|
||||
}
|
||||
|
||||
class E {
|
||||
constructor(y = "hello", ...rest) { }
|
||||
}
|
||||
|
||||
|
||||
//// [emitDefaultParametersMethod.js]
|
||||
var C = (function () {
|
||||
function C(t, z, x, y) {
|
||||
if (y === void 0) { y = "hello"; }
|
||||
}
|
||||
C.prototype.foo = function (x, t) {
|
||||
if (t === void 0) { t = false; }
|
||||
};
|
||||
C.prototype.foo1 = function (x, t) {
|
||||
if (t === void 0) { t = false; }
|
||||
var rest = [];
|
||||
for (var _i = 2; _i < arguments.length; _i++) {
|
||||
rest[_i - 2] = arguments[_i];
|
||||
}
|
||||
};
|
||||
C.prototype.bar = function (t) {
|
||||
if (t === void 0) { t = false; }
|
||||
};
|
||||
C.prototype.boo = function (t) {
|
||||
if (t === void 0) { t = false; }
|
||||
var rest = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
rest[_i - 1] = arguments[_i];
|
||||
}
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
var D = (function () {
|
||||
function D(y) {
|
||||
if (y === void 0) { y = "hello"; }
|
||||
}
|
||||
return D;
|
||||
})();
|
||||
var E = (function () {
|
||||
function E(y) {
|
||||
if (y === void 0) { y = "hello"; }
|
||||
var rest = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
rest[_i - 1] = arguments[_i];
|
||||
}
|
||||
}
|
||||
return E;
|
||||
})();
|
||||
@@ -0,0 +1,46 @@
|
||||
=== tests/cases/conformance/es6/defaultParameters/emitDefaultParametersMethod.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
constructor(t: boolean, z: string, x: number, y = "hello") { }
|
||||
>t : boolean
|
||||
>z : string
|
||||
>x : number
|
||||
>y : string
|
||||
|
||||
public foo(x: string, t = false) { }
|
||||
>foo : (x: string, t?: boolean) => void
|
||||
>x : string
|
||||
>t : boolean
|
||||
|
||||
public foo1(x: string, t = false, ...rest) { }
|
||||
>foo1 : (x: string, t?: boolean, ...rest: any[]) => void
|
||||
>x : string
|
||||
>t : boolean
|
||||
>rest : any[]
|
||||
|
||||
public bar(t = false) { }
|
||||
>bar : (t?: boolean) => void
|
||||
>t : boolean
|
||||
|
||||
public boo(t = false, ...rest) { }
|
||||
>boo : (t?: boolean, ...rest: any[]) => void
|
||||
>t : boolean
|
||||
>rest : any[]
|
||||
}
|
||||
|
||||
class D {
|
||||
>D : D
|
||||
|
||||
constructor(y = "hello") { }
|
||||
>y : string
|
||||
}
|
||||
|
||||
class E {
|
||||
>E : E
|
||||
|
||||
constructor(y = "hello", ...rest) { }
|
||||
>y : string
|
||||
>rest : any[]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
//// [emitDefaultParametersMethodES6.ts]
|
||||
class C {
|
||||
constructor(t: boolean, z: string, x: number, y = "hello") { }
|
||||
|
||||
public foo(x: string, t = false) { }
|
||||
public foo1(x: string, t = false, ...rest) { }
|
||||
public bar(t = false) { }
|
||||
public boo(t = false, ...rest) { }
|
||||
}
|
||||
|
||||
class D {
|
||||
constructor(y = "hello") { }
|
||||
}
|
||||
|
||||
class E {
|
||||
constructor(y = "hello", ...rest) { }
|
||||
}
|
||||
|
||||
//// [emitDefaultParametersMethodES6.js]
|
||||
var C = (function () {
|
||||
function C(t, z, x, y = "hello") {
|
||||
}
|
||||
C.prototype.foo = function (x, t = false) {
|
||||
};
|
||||
C.prototype.foo1 = function (x, t = false, ...rest) {
|
||||
};
|
||||
C.prototype.bar = function (t = false) {
|
||||
};
|
||||
C.prototype.boo = function (t = false, ...rest) {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
var D = (function () {
|
||||
function D(y = "hello") {
|
||||
}
|
||||
return D;
|
||||
})();
|
||||
var E = (function () {
|
||||
function E(y = "hello", ...rest) {
|
||||
}
|
||||
return E;
|
||||
})();
|
||||
@@ -0,0 +1,45 @@
|
||||
=== tests/cases/conformance/es6/defaultParameters/emitDefaultParametersMethodES6.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
constructor(t: boolean, z: string, x: number, y = "hello") { }
|
||||
>t : boolean
|
||||
>z : string
|
||||
>x : number
|
||||
>y : string
|
||||
|
||||
public foo(x: string, t = false) { }
|
||||
>foo : (x: string, t?: boolean) => void
|
||||
>x : string
|
||||
>t : boolean
|
||||
|
||||
public foo1(x: string, t = false, ...rest) { }
|
||||
>foo1 : (x: string, t?: boolean, ...rest: any[]) => void
|
||||
>x : string
|
||||
>t : boolean
|
||||
>rest : any[]
|
||||
|
||||
public bar(t = false) { }
|
||||
>bar : (t?: boolean) => void
|
||||
>t : boolean
|
||||
|
||||
public boo(t = false, ...rest) { }
|
||||
>boo : (t?: boolean, ...rest: any[]) => void
|
||||
>t : boolean
|
||||
>rest : any[]
|
||||
}
|
||||
|
||||
class D {
|
||||
>D : D
|
||||
|
||||
constructor(y = "hello") { }
|
||||
>y : string
|
||||
}
|
||||
|
||||
class E {
|
||||
>E : E
|
||||
|
||||
constructor(y = "hello", ...rest) { }
|
||||
>y : string
|
||||
>rest : any[]
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
//// [emitRestParametersFunction.ts]
|
||||
function bar(...rest) { }
|
||||
function foo(x: number, y: string, ...rest) { }
|
||||
|
||||
//// [emitRestParametersFunction.js]
|
||||
function bar() {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
}
|
||||
}
|
||||
function foo(x, y) {
|
||||
var rest = [];
|
||||
for (var _i = 2; _i < arguments.length; _i++) {
|
||||
rest[_i - 2] = arguments[_i];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
=== tests/cases/conformance/es6/restParameters/emitRestParametersFunction.ts ===
|
||||
function bar(...rest) { }
|
||||
>bar : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
|
||||
function foo(x: number, y: string, ...rest) { }
|
||||
>foo : (x: number, y: string, ...rest: any[]) => void
|
||||
>x : number
|
||||
>y : string
|
||||
>rest : any[]
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
//// [emitRestParametersFunctionES6.ts]
|
||||
function bar(...rest) { }
|
||||
function foo(x: number, y: string, ...rest) { }
|
||||
|
||||
//// [emitRestParametersFunctionES6.js]
|
||||
function bar(...rest) {
|
||||
}
|
||||
function foo(x, y, ...rest) {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
=== tests/cases/conformance/es6/restParameters/emitRestParametersFunctionES6.ts ===
|
||||
function bar(...rest) { }
|
||||
>bar : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
|
||||
function foo(x: number, y: string, ...rest) { }
|
||||
>foo : (x: number, y: string, ...rest: any[]) => void
|
||||
>x : number
|
||||
>y : string
|
||||
>rest : any[]
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
//// [emitRestParametersFunctionExpression.ts]
|
||||
var funcExp = (...rest) => { }
|
||||
var funcExp1 = (X: number, ...rest) => { }
|
||||
var funcExp2 = function (...rest) { }
|
||||
var funcExp3 = (function (...rest) { })()
|
||||
|
||||
|
||||
//// [emitRestParametersFunctionExpression.js]
|
||||
var funcExp = function () {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
}
|
||||
};
|
||||
var funcExp1 = function (X) {
|
||||
var rest = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
rest[_i - 1] = arguments[_i];
|
||||
}
|
||||
};
|
||||
var funcExp2 = function () {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
}
|
||||
};
|
||||
var funcExp3 = (function () {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,24 @@
|
||||
=== tests/cases/conformance/es6/restParameters/emitRestParametersFunctionExpression.ts ===
|
||||
var funcExp = (...rest) => { }
|
||||
>funcExp : (...rest: any[]) => void
|
||||
>(...rest) => { } : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
|
||||
var funcExp1 = (X: number, ...rest) => { }
|
||||
>funcExp1 : (X: number, ...rest: any[]) => void
|
||||
>(X: number, ...rest) => { } : (X: number, ...rest: any[]) => void
|
||||
>X : number
|
||||
>rest : any[]
|
||||
|
||||
var funcExp2 = function (...rest) { }
|
||||
>funcExp2 : (...rest: any[]) => void
|
||||
>function (...rest) { } : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
|
||||
var funcExp3 = (function (...rest) { })()
|
||||
>funcExp3 : void
|
||||
>(function (...rest) { })() : void
|
||||
>(function (...rest) { }) : (...rest: any[]) => void
|
||||
>function (...rest) { } : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
//// [emitRestParametersFunctionExpressionES6.ts]
|
||||
var funcExp = (...rest) => { }
|
||||
var funcExp1 = (X: number, ...rest) => { }
|
||||
var funcExp2 = function (...rest) { }
|
||||
var funcExp3 = (function (...rest) { })()
|
||||
|
||||
//// [emitRestParametersFunctionExpressionES6.js]
|
||||
var funcExp = function (...rest) {
|
||||
};
|
||||
var funcExp1 = function (X, ...rest) {
|
||||
};
|
||||
var funcExp2 = function (...rest) {
|
||||
};
|
||||
var funcExp3 = (function (...rest) {
|
||||
})();
|
||||
@@ -0,0 +1,24 @@
|
||||
=== tests/cases/conformance/es6/restParameters/emitRestParametersFunctionExpressionES6.ts ===
|
||||
var funcExp = (...rest) => { }
|
||||
>funcExp : (...rest: any[]) => void
|
||||
>(...rest) => { } : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
|
||||
var funcExp1 = (X: number, ...rest) => { }
|
||||
>funcExp1 : (X: number, ...rest: any[]) => void
|
||||
>(X: number, ...rest) => { } : (X: number, ...rest: any[]) => void
|
||||
>X : number
|
||||
>rest : any[]
|
||||
|
||||
var funcExp2 = function (...rest) { }
|
||||
>funcExp2 : (...rest: any[]) => void
|
||||
>function (...rest) { } : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
|
||||
var funcExp3 = (function (...rest) { })()
|
||||
>funcExp3 : void
|
||||
>(function (...rest) { })() : void
|
||||
>(function (...rest) { }) : (...rest: any[]) => void
|
||||
>function (...rest) { } : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//// [emitRestParametersFunctionProperty.ts]
|
||||
var obj: {
|
||||
func1: (...rest) => void
|
||||
}
|
||||
|
||||
var obj2 = {
|
||||
func(...rest) { }
|
||||
}
|
||||
|
||||
//// [emitRestParametersFunctionProperty.js]
|
||||
var obj;
|
||||
var obj2 = {
|
||||
func: function () {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/es6/restParameters/emitRestParametersFunctionProperty.ts ===
|
||||
var obj: {
|
||||
>obj : { func1: (...rest: any[]) => void; }
|
||||
|
||||
func1: (...rest) => void
|
||||
>func1 : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
}
|
||||
|
||||
var obj2 = {
|
||||
>obj2 : { func(...rest: any[]): void; }
|
||||
>{ func(...rest) { }} : { func(...rest: any[]): void; }
|
||||
|
||||
func(...rest) { }
|
||||
>func : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//// [emitRestParametersFunctionPropertyES6.ts]
|
||||
var obj: {
|
||||
func1: (...rest) => void
|
||||
}
|
||||
|
||||
var obj2 = {
|
||||
func(...rest) { }
|
||||
}
|
||||
|
||||
//// [emitRestParametersFunctionPropertyES6.js]
|
||||
var obj;
|
||||
var obj2 = {
|
||||
func(...rest) {
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/es6/restParameters/emitRestParametersFunctionPropertyES6.ts ===
|
||||
var obj: {
|
||||
>obj : { func1: (...rest: any[]) => void; }
|
||||
|
||||
func1: (...rest) => void
|
||||
>func1 : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
}
|
||||
|
||||
var obj2 = {
|
||||
>obj2 : { func(...rest: any[]): void; }
|
||||
>{ func(...rest) { }} : { func(...rest: any[]): void; }
|
||||
|
||||
func(...rest) { }
|
||||
>func : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
//// [emitRestParametersMethod.ts]
|
||||
class C {
|
||||
constructor(name: string, ...rest) { }
|
||||
|
||||
public bar(...rest) { }
|
||||
public foo(x: number, ...rest) { }
|
||||
}
|
||||
|
||||
class D {
|
||||
constructor(...rest) { }
|
||||
|
||||
public bar(...rest) { }
|
||||
public foo(x: number, ...rest) { }
|
||||
}
|
||||
|
||||
//// [emitRestParametersMethod.js]
|
||||
var C = (function () {
|
||||
function C(name) {
|
||||
var rest = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
rest[_i - 1] = arguments[_i];
|
||||
}
|
||||
}
|
||||
C.prototype.bar = function () {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
}
|
||||
};
|
||||
C.prototype.foo = function (x) {
|
||||
var rest = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
rest[_i - 1] = arguments[_i];
|
||||
}
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
var D = (function () {
|
||||
function D() {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
}
|
||||
}
|
||||
D.prototype.bar = function () {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
}
|
||||
};
|
||||
D.prototype.foo = function (x) {
|
||||
var rest = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
rest[_i - 1] = arguments[_i];
|
||||
}
|
||||
};
|
||||
return D;
|
||||
})();
|
||||
@@ -0,0 +1,33 @@
|
||||
=== tests/cases/conformance/es6/restParameters/emitRestParametersMethod.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
constructor(name: string, ...rest) { }
|
||||
>name : string
|
||||
>rest : any[]
|
||||
|
||||
public bar(...rest) { }
|
||||
>bar : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
|
||||
public foo(x: number, ...rest) { }
|
||||
>foo : (x: number, ...rest: any[]) => void
|
||||
>x : number
|
||||
>rest : any[]
|
||||
}
|
||||
|
||||
class D {
|
||||
>D : D
|
||||
|
||||
constructor(...rest) { }
|
||||
>rest : any[]
|
||||
|
||||
public bar(...rest) { }
|
||||
>bar : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
|
||||
public foo(x: number, ...rest) { }
|
||||
>foo : (x: number, ...rest: any[]) => void
|
||||
>x : number
|
||||
>rest : any[]
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
//// [emitRestParametersMethodES6.ts]
|
||||
class C {
|
||||
constructor(name: string, ...rest) { }
|
||||
|
||||
public bar(...rest) { }
|
||||
public foo(x: number, ...rest) { }
|
||||
}
|
||||
|
||||
class D {
|
||||
constructor(...rest) { }
|
||||
|
||||
public bar(...rest) { }
|
||||
public foo(x: number, ...rest) { }
|
||||
}
|
||||
|
||||
|
||||
//// [emitRestParametersMethodES6.js]
|
||||
var C = (function () {
|
||||
function C(name, ...rest) {
|
||||
}
|
||||
C.prototype.bar = function (...rest) {
|
||||
};
|
||||
C.prototype.foo = function (x, ...rest) {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
var D = (function () {
|
||||
function D(...rest) {
|
||||
}
|
||||
D.prototype.bar = function (...rest) {
|
||||
};
|
||||
D.prototype.foo = function (x, ...rest) {
|
||||
};
|
||||
return D;
|
||||
})();
|
||||
@@ -0,0 +1,34 @@
|
||||
=== tests/cases/conformance/es6/restParameters/emitRestParametersMethodES6.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
constructor(name: string, ...rest) { }
|
||||
>name : string
|
||||
>rest : any[]
|
||||
|
||||
public bar(...rest) { }
|
||||
>bar : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
|
||||
public foo(x: number, ...rest) { }
|
||||
>foo : (x: number, ...rest: any[]) => void
|
||||
>x : number
|
||||
>rest : any[]
|
||||
}
|
||||
|
||||
class D {
|
||||
>D : D
|
||||
|
||||
constructor(...rest) { }
|
||||
>rest : any[]
|
||||
|
||||
public bar(...rest) { }
|
||||
>bar : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
|
||||
public foo(x: number, ...rest) { }
|
||||
>foo : (x: number, ...rest: any[]) => void
|
||||
>x : number
|
||||
>rest : any[]
|
||||
}
|
||||
|
||||
@@ -28,22 +28,43 @@ interface B {
|
||||
(x: 'B2'): string[];
|
||||
}
|
||||
|
||||
var b: B;
|
||||
// non of these lines should error
|
||||
var x1: string[] = b('B2');
|
||||
var x2: number = b('B1');
|
||||
var x3: boolean = b('A2');
|
||||
var x4: string = b('A1');
|
||||
var x5: void = b('A0');
|
||||
interface C1 extends B {
|
||||
(x: 'C1'): number[];
|
||||
}
|
||||
|
||||
interface C2 extends B {
|
||||
(x: 'C2'): boolean[];
|
||||
}
|
||||
|
||||
interface C extends C1, C2 {
|
||||
(x: 'C'): string;
|
||||
}
|
||||
|
||||
var c: C;
|
||||
// none of these lines should error
|
||||
var x1: string[] = c('B2');
|
||||
var x2: number = c('B1');
|
||||
var x3: boolean = c('A2');
|
||||
var x4: string = c('A1');
|
||||
var x5: void = c('A0');
|
||||
var x6: number[] = c('C1');
|
||||
var x7: boolean[] = c('C2');
|
||||
var x8: string = c('C');
|
||||
var x9: void = c('generic');
|
||||
|
||||
|
||||
//// [inheritedOverloadedSpecializedSignatures.js]
|
||||
var b;
|
||||
// Should not error
|
||||
b('foo').charAt(0);
|
||||
var b;
|
||||
// non of these lines should error
|
||||
var x1 = b('B2');
|
||||
var x2 = b('B1');
|
||||
var x3 = b('A2');
|
||||
var x4 = b('A1');
|
||||
var x5 = b('A0');
|
||||
var c;
|
||||
// none of these lines should error
|
||||
var x1 = c('B2');
|
||||
var x2 = c('B1');
|
||||
var x3 = c('A2');
|
||||
var x4 = c('A1');
|
||||
var x5 = c('A0');
|
||||
var x6 = c('C1');
|
||||
var x7 = c('C2');
|
||||
var x8 = c('C');
|
||||
var x9 = c('generic');
|
||||
|
||||
@@ -58,33 +58,78 @@ interface B {
|
||||
>x : 'B2'
|
||||
}
|
||||
|
||||
var b: B;
|
||||
>b : B
|
||||
interface C1 extends B {
|
||||
>C1 : C1
|
||||
>B : B
|
||||
|
||||
// non of these lines should error
|
||||
var x1: string[] = b('B2');
|
||||
(x: 'C1'): number[];
|
||||
>x : 'C1'
|
||||
}
|
||||
|
||||
interface C2 extends B {
|
||||
>C2 : C2
|
||||
>B : B
|
||||
|
||||
(x: 'C2'): boolean[];
|
||||
>x : 'C2'
|
||||
}
|
||||
|
||||
interface C extends C1, C2 {
|
||||
>C : C
|
||||
>C1 : C1
|
||||
>C2 : C2
|
||||
|
||||
(x: 'C'): string;
|
||||
>x : 'C'
|
||||
}
|
||||
|
||||
var c: C;
|
||||
>c : C
|
||||
>C : C
|
||||
|
||||
// none of these lines should error
|
||||
var x1: string[] = c('B2');
|
||||
>x1 : string[]
|
||||
>b('B2') : string[]
|
||||
>b : B
|
||||
>c('B2') : string[]
|
||||
>c : C
|
||||
|
||||
var x2: number = b('B1');
|
||||
var x2: number = c('B1');
|
||||
>x2 : number
|
||||
>b('B1') : number
|
||||
>b : B
|
||||
>c('B1') : number
|
||||
>c : C
|
||||
|
||||
var x3: boolean = b('A2');
|
||||
var x3: boolean = c('A2');
|
||||
>x3 : boolean
|
||||
>b('A2') : boolean
|
||||
>b : B
|
||||
>c('A2') : boolean
|
||||
>c : C
|
||||
|
||||
var x4: string = b('A1');
|
||||
var x4: string = c('A1');
|
||||
>x4 : string
|
||||
>b('A1') : string
|
||||
>b : B
|
||||
>c('A1') : string
|
||||
>c : C
|
||||
|
||||
var x5: void = b('A0');
|
||||
var x5: void = c('A0');
|
||||
>x5 : void
|
||||
>b('A0') : void
|
||||
>b : B
|
||||
>c('A0') : void
|
||||
>c : C
|
||||
|
||||
var x6: number[] = c('C1');
|
||||
>x6 : number[]
|
||||
>c('C1') : number[]
|
||||
>c : C
|
||||
|
||||
var x7: boolean[] = c('C2');
|
||||
>x7 : boolean[]
|
||||
>c('C2') : boolean[]
|
||||
>c : C
|
||||
|
||||
var x8: string = c('C');
|
||||
>x8 : string
|
||||
>c('C') : string
|
||||
>c : C
|
||||
|
||||
var x9: void = c('generic');
|
||||
>x9 : void
|
||||
>c('generic') : void
|
||||
>c : C
|
||||
|
||||
|
||||
@@ -11,14 +11,14 @@ var a: (a: string) => string;
|
||||
|
||||
// bug 786110
|
||||
var r = a || ((a) => a.toLowerCase());
|
||||
>r : (a: any) => any
|
||||
>a || ((a) => a.toLowerCase()) : (a: any) => any
|
||||
>r : (a: string) => string
|
||||
>a || ((a) => a.toLowerCase()) : (a: string) => string
|
||||
>a : (a: string) => string
|
||||
>((a) => a.toLowerCase()) : (a: any) => any
|
||||
>(a) => a.toLowerCase() : (a: any) => any
|
||||
>a : any
|
||||
>a.toLowerCase() : any
|
||||
>a.toLowerCase : any
|
||||
>a : any
|
||||
>toLowerCase : any
|
||||
>((a) => a.toLowerCase()) : (a: string) => string
|
||||
>(a) => a.toLowerCase() : (a: string) => string
|
||||
>a : string
|
||||
>a.toLowerCase() : string
|
||||
>a.toLowerCase : () => string
|
||||
>a : string
|
||||
>toLowerCase : () => string
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
//// [moduleSharesNameWithImportDeclarationInsideIt.ts]
|
||||
module Z.M {
|
||||
export function bar() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
module A.M {
|
||||
import M = Z.M;
|
||||
export function bar() {
|
||||
}
|
||||
M.bar(); // Should call Z.M.bar
|
||||
}
|
||||
|
||||
//// [moduleSharesNameWithImportDeclarationInsideIt.js]
|
||||
var Z;
|
||||
(function (Z) {
|
||||
var M;
|
||||
(function (M) {
|
||||
function bar() {
|
||||
return "";
|
||||
}
|
||||
M.bar = bar;
|
||||
})(M = Z.M || (Z.M = {}));
|
||||
})(Z || (Z = {}));
|
||||
var A;
|
||||
(function (A) {
|
||||
var M;
|
||||
(function (_M) {
|
||||
var M = Z.M;
|
||||
function bar() {
|
||||
}
|
||||
_M.bar = bar;
|
||||
M.bar(); // Should call Z.M.bar
|
||||
})(M = A.M || (A.M = {}));
|
||||
})(A || (A = {}));
|
||||
@@ -0,0 +1,29 @@
|
||||
=== tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt.ts ===
|
||||
module Z.M {
|
||||
>Z : typeof Z
|
||||
>M : typeof M
|
||||
|
||||
export function bar() {
|
||||
>bar : () => string
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
module A.M {
|
||||
>A : typeof A
|
||||
>M : typeof A.M
|
||||
|
||||
import M = Z.M;
|
||||
>M : typeof M
|
||||
>Z : typeof Z
|
||||
>M : typeof M
|
||||
|
||||
export function bar() {
|
||||
>bar : () => void
|
||||
}
|
||||
M.bar(); // Should call Z.M.bar
|
||||
>M.bar() : string
|
||||
>M.bar : () => string
|
||||
>M : typeof M
|
||||
>bar : () => string
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
//// [moduleSharesNameWithImportDeclarationInsideIt2.ts]
|
||||
module Z.M {
|
||||
export function bar() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
module A.M {
|
||||
export import M = Z.M;
|
||||
export function bar() {
|
||||
}
|
||||
M.bar(); // Should call Z.M.bar
|
||||
}
|
||||
|
||||
//// [moduleSharesNameWithImportDeclarationInsideIt2.js]
|
||||
var Z;
|
||||
(function (Z) {
|
||||
var M;
|
||||
(function (M) {
|
||||
function bar() {
|
||||
return "";
|
||||
}
|
||||
M.bar = bar;
|
||||
})(M = Z.M || (Z.M = {}));
|
||||
})(Z || (Z = {}));
|
||||
var A;
|
||||
(function (A) {
|
||||
var M;
|
||||
(function (M) {
|
||||
M.M = Z.M;
|
||||
function bar() {
|
||||
}
|
||||
M.bar = bar;
|
||||
M.M.bar(); // Should call Z.M.bar
|
||||
})(M = A.M || (A.M = {}));
|
||||
})(A || (A = {}));
|
||||
@@ -0,0 +1,29 @@
|
||||
=== tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt2.ts ===
|
||||
module Z.M {
|
||||
>Z : typeof Z
|
||||
>M : typeof M
|
||||
|
||||
export function bar() {
|
||||
>bar : () => string
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
module A.M {
|
||||
>A : typeof A
|
||||
>M : typeof A.M
|
||||
|
||||
export import M = Z.M;
|
||||
>M : typeof M
|
||||
>Z : typeof Z
|
||||
>M : typeof M
|
||||
|
||||
export function bar() {
|
||||
>bar : () => void
|
||||
}
|
||||
M.bar(); // Should call Z.M.bar
|
||||
>M.bar() : string
|
||||
>M.bar : () => string
|
||||
>M : typeof M
|
||||
>bar : () => string
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt3.ts(10,12): error TS2300: Duplicate identifier 'M'.
|
||||
tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt3.ts(11,12): error TS2300: Duplicate identifier 'M'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt3.ts (2 errors) ====
|
||||
module Z {
|
||||
export module M {
|
||||
export function bar() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
export interface I { }
|
||||
}
|
||||
module A.M {
|
||||
import M = Z.M;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'M'.
|
||||
import M = Z.I;
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'M'.
|
||||
|
||||
export function bar() {
|
||||
}
|
||||
M.bar(); // Should call Z.M.bar
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
//// [moduleSharesNameWithImportDeclarationInsideIt3.ts]
|
||||
module Z {
|
||||
export module M {
|
||||
export function bar() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
export interface I { }
|
||||
}
|
||||
module A.M {
|
||||
import M = Z.M;
|
||||
import M = Z.I;
|
||||
|
||||
export function bar() {
|
||||
}
|
||||
M.bar(); // Should call Z.M.bar
|
||||
}
|
||||
|
||||
//// [moduleSharesNameWithImportDeclarationInsideIt3.js]
|
||||
var Z;
|
||||
(function (Z) {
|
||||
var M;
|
||||
(function (M) {
|
||||
function bar() {
|
||||
return "";
|
||||
}
|
||||
M.bar = bar;
|
||||
})(M = Z.M || (Z.M = {}));
|
||||
})(Z || (Z = {}));
|
||||
var A;
|
||||
(function (A) {
|
||||
var M;
|
||||
(function (_M) {
|
||||
var M = Z.M;
|
||||
function bar() {
|
||||
}
|
||||
_M.bar = bar;
|
||||
M.bar(); // Should call Z.M.bar
|
||||
})(M = A.M || (A.M = {}));
|
||||
})(A || (A = {}));
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user