Merge branch 'release-1.4'

Conflicts:
	bin/lib.core.es6.d.ts
	bin/lib.es6.d.ts
	bin/tsc.js
	bin/typescript.d.ts
	bin/typescriptServices.d.ts
	bin/typescriptServices.js
	bin/typescriptServices_internal.d.ts
	bin/typescript_internal.d.ts
This commit is contained in:
Jason Freeman
2015-01-05 15:08:17 -08:00
46 changed files with 12500 additions and 9256 deletions
+12 -3
View File
@@ -192,7 +192,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 +205,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOu
options += " --declaration";
}
if (useDebugMode) {
if (useDebugMode || preserveConstEnums) {
options += " --preserveConstEnums";
}
@@ -321,7 +321,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 +342,7 @@ compileFile(nodeDefinitionsFile, servicesSources,[builtLocalDirectory, copyright
/*noOutFile*/ true,
/*generateDeclarations*/ true,
/*outDir*/ tempDirPath,
/*preserveConstEnums*/ true,
/*keepComments*/ true,
/*noResolve*/ true,
/*callback*/ function () {
+5128 -4245
View File
File diff suppressed because it is too large Load Diff
+71 -143
View File
@@ -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 {
@@ -1119,6 +1128,7 @@ declare module "typescript" {
locale?: string;
mapRoot?: string;
module?: ModuleKind;
noEmit?: boolean;
noEmitOnError?: boolean;
noErrorTruncation?: boolean;
noImplicitAny?: boolean;
@@ -1303,13 +1313,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;
@@ -1356,16 +1371,18 @@ 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 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 +1429,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 +1512,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 +1803,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;
+71 -143
View File
@@ -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 {
@@ -1119,6 +1128,7 @@ declare module ts {
locale?: string;
mapRoot?: string;
module?: ModuleKind;
noEmit?: boolean;
noEmitOnError?: boolean;
noErrorTruncation?: boolean;
noImplicitAny?: boolean;
@@ -1303,13 +1313,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;
@@ -1356,16 +1371,18 @@ 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 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 +1429,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 +1512,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 +1803,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;
+6207 -4703
View File
File diff suppressed because it is too large Load Diff
+31 -3
View File
@@ -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;
@@ -149,7 +149,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 +164,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;
@@ -196,12 +198,38 @@ 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 {
interface ListItemInfo {
+31 -3
View File
@@ -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;
@@ -149,7 +149,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 +164,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;
@@ -196,12 +198,38 @@ 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" {
interface ListItemInfo {
+34 -9
View File
@@ -5057,17 +5057,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;
@@ -5205,7 +5213,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:
@@ -5216,6 +5224,9 @@ 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);
}
return undefined;
}
@@ -5876,7 +5887,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
@@ -9247,6 +9258,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:
@@ -9790,8 +9803,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;
+4 -4
View File
@@ -3480,16 +3480,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:
@@ -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 = {}));
@@ -0,0 +1,36 @@
//// [moduleSharesNameWithImportDeclarationInsideIt4.ts]
module Z.M {
export function bar() {
return "";
}
}
module A.M {
interface M { }
import M = Z.M;
export function bar() {
}
M.bar(); // Should call Z.M.bar
}
//// [moduleSharesNameWithImportDeclarationInsideIt4.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,32 @@
=== tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt4.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
interface M { }
>M : 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,25 @@
tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt5.ts(10,12): error TS2300: Duplicate identifier 'M'.
tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt5.ts(11,12): error TS2300: Duplicate identifier 'M'.
==== tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt5.ts (2 errors) ====
module Z {
export module M {
export function bar() {
return "";
}
}
export interface I { }
}
module A.M {
import M = Z.I;
~
!!! error TS2300: Duplicate identifier 'M'.
import M = Z.M;
~
!!! error TS2300: Duplicate identifier 'M'.
export function bar() {
}
M.bar(); // Should call Z.M.bar
}
@@ -0,0 +1,39 @@
//// [moduleSharesNameWithImportDeclarationInsideIt5.ts]
module Z {
export module M {
export function bar() {
return "";
}
}
export interface I { }
}
module A.M {
import M = Z.I;
import M = Z.M;
export function bar() {
}
M.bar(); // Should call Z.M.bar
}
//// [moduleSharesNameWithImportDeclarationInsideIt5.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) {
function bar() {
}
M.bar = bar;
M.bar(); // Should call Z.M.bar
})(M = A.M || (A.M = {}));
})(A || (A = {}));
@@ -0,0 +1,32 @@
//// [moduleSharesNameWithImportDeclarationInsideIt6.ts]
module Z.M {
export function bar() {
return "";
}
}
module A.M {
import M = Z.M;
export function bar() {
}
}
//// [moduleSharesNameWithImportDeclarationInsideIt6.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) {
function bar() {
}
M.bar = bar;
})(M = A.M || (A.M = {}));
})(A || (A = {}));
@@ -0,0 +1,24 @@
=== tests/cases/compiler/moduleSharesNameWithImportDeclarationInsideIt6.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
}
}
@@ -0,0 +1,48 @@
//// [taggedTemplateContextualTyping1.ts]
type FuncType = (x: <T>(p: T) => T) => typeof x;
function tempTag1<T>(templateStrs: TemplateStringsArray, f: FuncType, x: T): T;
function tempTag1<T>(templateStrs: TemplateStringsArray, f: FuncType, h: FuncType, x: T): T;
function tempTag1<T>(...rest: any[]): T {
return undefined;
}
// If contextual typing takes place, these functions should work.
// Otherwise, the arrow functions' parameters will be typed as 'any',
// and it is an error to invoke an any-typed value with type arguments,
// so this test will error.
tempTag1 `${ x => { x<number>(undefined); return x; } }${ y => { y<number>(undefined); return y; } }${ 10 }`;
tempTag1 `${ x => { x<number>(undefined); return x; } }${ (y: <T>(p: T) => T) => { y<number>(undefined); return y } }${ undefined }`;
tempTag1 `${ (x: <T>(p: T) => T) => { x<number>(undefined); return x; } }${ y => { y<number>(undefined); return y; } }${ undefined }`;
//// [taggedTemplateContextualTyping1.js]
function tempTag1(...rest) {
return undefined;
}
// If contextual typing takes place, these functions should work.
// Otherwise, the arrow functions' parameters will be typed as 'any',
// and it is an error to invoke an any-typed value with type arguments,
// so this test will error.
tempTag1 `${function (x) {
x(undefined);
return x;
}}${function (y) {
y(undefined);
return y;
}}${10}`;
tempTag1 `${function (x) {
x(undefined);
return x;
}}${function (y) {
y(undefined);
return y;
}}${undefined}`;
tempTag1 `${function (x) {
x(undefined);
return x;
}}${function (y) {
y(undefined);
return y;
}}${undefined}`;
@@ -0,0 +1,104 @@
=== tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping1.ts ===
type FuncType = (x: <T>(p: T) => T) => typeof x;
>FuncType : (x: <T>(p: T) => T) => <T>(p: T) => T
>x : <T>(p: T) => T
>T : T
>p : T
>T : T
>T : T
>x : <T>(p: T) => T
function tempTag1<T>(templateStrs: TemplateStringsArray, f: FuncType, x: T): T;
>tempTag1 : { <T>(templateStrs: TemplateStringsArray, f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(templateStrs: TemplateStringsArray, f: (x: <T>(p: T) => T) => <T>(p: T) => T, h: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
>T : T
>templateStrs : TemplateStringsArray
>TemplateStringsArray : TemplateStringsArray
>f : (x: <T>(p: T) => T) => <T>(p: T) => T
>FuncType : (x: <T>(p: T) => T) => <T>(p: T) => T
>x : T
>T : T
>T : T
function tempTag1<T>(templateStrs: TemplateStringsArray, f: FuncType, h: FuncType, x: T): T;
>tempTag1 : { <T>(templateStrs: TemplateStringsArray, f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(templateStrs: TemplateStringsArray, f: (x: <T>(p: T) => T) => <T>(p: T) => T, h: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
>T : T
>templateStrs : TemplateStringsArray
>TemplateStringsArray : TemplateStringsArray
>f : (x: <T>(p: T) => T) => <T>(p: T) => T
>FuncType : (x: <T>(p: T) => T) => <T>(p: T) => T
>h : (x: <T>(p: T) => T) => <T>(p: T) => T
>FuncType : (x: <T>(p: T) => T) => <T>(p: T) => T
>x : T
>T : T
>T : T
function tempTag1<T>(...rest: any[]): T {
>tempTag1 : { <T>(templateStrs: TemplateStringsArray, f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(templateStrs: TemplateStringsArray, f: (x: <T>(p: T) => T) => <T>(p: T) => T, h: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
>T : T
>rest : any[]
>T : T
return undefined;
>undefined : undefined
}
// If contextual typing takes place, these functions should work.
// Otherwise, the arrow functions' parameters will be typed as 'any',
// and it is an error to invoke an any-typed value with type arguments,
// so this test will error.
tempTag1 `${ x => { x<number>(undefined); return x; } }${ y => { y<number>(undefined); return y; } }${ 10 }`;
>tempTag1 : { <T>(templateStrs: TemplateStringsArray, f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(templateStrs: TemplateStringsArray, f: (x: <T>(p: T) => T) => <T>(p: T) => T, h: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
>x => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
>x : <T>(p: T) => T
>x<number>(undefined) : number
>x : <T>(p: T) => T
>undefined : undefined
>x : <T>(p: T) => T
>y => { y<number>(undefined); return y; } : (y: <T>(p: T) => T) => <T>(p: T) => T
>y : <T>(p: T) => T
>y<number>(undefined) : number
>y : <T>(p: T) => T
>undefined : undefined
>y : <T>(p: T) => T
tempTag1 `${ x => { x<number>(undefined); return x; } }${ (y: <T>(p: T) => T) => { y<number>(undefined); return y } }${ undefined }`;
>tempTag1 : { <T>(templateStrs: TemplateStringsArray, f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(templateStrs: TemplateStringsArray, f: (x: <T>(p: T) => T) => <T>(p: T) => T, h: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
>x => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
>x : <T>(p: T) => T
>x<number>(undefined) : number
>x : <T>(p: T) => T
>undefined : undefined
>x : <T>(p: T) => T
>(y: <T>(p: T) => T) => { y<number>(undefined); return y } : (y: <T>(p: T) => T) => <T>(p: T) => T
>y : <T>(p: T) => T
>T : T
>p : T
>T : T
>T : T
>y<number>(undefined) : number
>y : <T>(p: T) => T
>undefined : undefined
>y : <T>(p: T) => T
>undefined : undefined
tempTag1 `${ (x: <T>(p: T) => T) => { x<number>(undefined); return x; } }${ y => { y<number>(undefined); return y; } }${ undefined }`;
>tempTag1 : { <T>(templateStrs: TemplateStringsArray, f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(templateStrs: TemplateStringsArray, f: (x: <T>(p: T) => T) => <T>(p: T) => T, h: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
>(x: <T>(p: T) => T) => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
>x : <T>(p: T) => T
>T : T
>p : T
>T : T
>T : T
>x<number>(undefined) : number
>x : <T>(p: T) => T
>undefined : undefined
>x : <T>(p: T) => T
>y => { y<number>(undefined); return y; } : (y: <T>(p: T) => T) => <T>(p: T) => T
>y : <T>(p: T) => T
>y<number>(undefined) : number
>y : <T>(p: T) => T
>undefined : undefined
>y : <T>(p: T) => T
>undefined : undefined
@@ -0,0 +1,42 @@
//// [taggedTemplateContextualTyping2.ts]
type FuncType1 = (x: <T>(p: T) => T) => typeof x;
type FuncType2 = (x: <S, T>(p: T) => T) => typeof x;
function tempTag2(templateStrs: TemplateStringsArray, f: FuncType1, x: number): number;
function tempTag2(templateStrs: TemplateStringsArray, f: FuncType2, h: FuncType2, x: string): string;
function tempTag2(...rest: any[]): any {
return undefined;
}
// If contextual typing takes place, these functions should work.
// Otherwise, the arrow functions' parameters will be typed as 'any',
// and it is an error to invoke an any-typed value with type arguments,
// so this test will error.
tempTag2 `${ x => { x<number>(undefined); return x; } }${ 0 }`;
tempTag2 `${ x => { x<number, string>(undefined); return x; } }${ y => { y<string, number>(null); return y; } }${ "hello" }`;
tempTag2 `${ x => { x<number, string>(undefined); return x; } }${ undefined }${ "hello" }`;
//// [taggedTemplateContextualTyping2.js]
function tempTag2(...rest) {
return undefined;
}
// If contextual typing takes place, these functions should work.
// Otherwise, the arrow functions' parameters will be typed as 'any',
// and it is an error to invoke an any-typed value with type arguments,
// so this test will error.
tempTag2 `${function (x) {
x(undefined);
return x;
}}${0}`;
tempTag2 `${function (x) {
x(undefined);
return x;
}}${function (y) {
y(null);
return y;
}}${"hello"}`;
tempTag2 `${function (x) {
x(undefined);
return x;
}}${undefined}${"hello"}`;
@@ -0,0 +1,84 @@
=== tests/cases/conformance/expressions/contextualTyping/taggedTemplateContextualTyping2.ts ===
type FuncType1 = (x: <T>(p: T) => T) => typeof x;
>FuncType1 : (x: <T>(p: T) => T) => <T>(p: T) => T
>x : <T>(p: T) => T
>T : T
>p : T
>T : T
>T : T
>x : <T>(p: T) => T
type FuncType2 = (x: <S, T>(p: T) => T) => typeof x;
>FuncType2 : (x: <S, T>(p: T) => T) => <S, T>(p: T) => T
>x : <S, T>(p: T) => T
>S : S
>T : T
>p : T
>T : T
>T : T
>x : <S, T>(p: T) => T
function tempTag2(templateStrs: TemplateStringsArray, f: FuncType1, x: number): number;
>tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: number): number; (templateStrs: TemplateStringsArray, f: (x: <S, T>(p: T) => T) => <S, T>(p: T) => T, h: (x: <S, T>(p: T) => T) => <S, T>(p: T) => T, x: string): string; }
>templateStrs : TemplateStringsArray
>TemplateStringsArray : TemplateStringsArray
>f : (x: <T>(p: T) => T) => <T>(p: T) => T
>FuncType1 : (x: <T>(p: T) => T) => <T>(p: T) => T
>x : number
function tempTag2(templateStrs: TemplateStringsArray, f: FuncType2, h: FuncType2, x: string): string;
>tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: number): number; (templateStrs: TemplateStringsArray, f: (x: <S, T>(p: T) => T) => <S, T>(p: T) => T, h: (x: <S, T>(p: T) => T) => <S, T>(p: T) => T, x: string): string; }
>templateStrs : TemplateStringsArray
>TemplateStringsArray : TemplateStringsArray
>f : (x: <S, T>(p: T) => T) => <S, T>(p: T) => T
>FuncType2 : (x: <S, T>(p: T) => T) => <S, T>(p: T) => T
>h : (x: <S, T>(p: T) => T) => <S, T>(p: T) => T
>FuncType2 : (x: <S, T>(p: T) => T) => <S, T>(p: T) => T
>x : string
function tempTag2(...rest: any[]): any {
>tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: number): number; (templateStrs: TemplateStringsArray, f: (x: <S, T>(p: T) => T) => <S, T>(p: T) => T, h: (x: <S, T>(p: T) => T) => <S, T>(p: T) => T, x: string): string; }
>rest : any[]
return undefined;
>undefined : undefined
}
// If contextual typing takes place, these functions should work.
// Otherwise, the arrow functions' parameters will be typed as 'any',
// and it is an error to invoke an any-typed value with type arguments,
// so this test will error.
tempTag2 `${ x => { x<number>(undefined); return x; } }${ 0 }`;
>tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: number): number; (templateStrs: TemplateStringsArray, f: (x: <S, T>(p: T) => T) => <S, T>(p: T) => T, h: (x: <S, T>(p: T) => T) => <S, T>(p: T) => T, x: string): string; }
>x => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
>x : <T>(p: T) => T
>x<number>(undefined) : number
>x : <T>(p: T) => T
>undefined : undefined
>x : <T>(p: T) => T
tempTag2 `${ x => { x<number, string>(undefined); return x; } }${ y => { y<string, number>(null); return y; } }${ "hello" }`;
>tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: number): number; (templateStrs: TemplateStringsArray, f: (x: <S, T>(p: T) => T) => <S, T>(p: T) => T, h: (x: <S, T>(p: T) => T) => <S, T>(p: T) => T, x: string): string; }
>x => { x<number, string>(undefined); return x; } : (x: <S, T>(p: T) => T) => <S, T>(p: T) => T
>x : <S, T>(p: T) => T
>x<number, string>(undefined) : string
>x : <S, T>(p: T) => T
>undefined : undefined
>x : <S, T>(p: T) => T
>y => { y<string, number>(null); return y; } : (y: <S, T>(p: T) => T) => <S, T>(p: T) => T
>y : <S, T>(p: T) => T
>y<string, number>(null) : number
>y : <S, T>(p: T) => T
>y : <S, T>(p: T) => T
tempTag2 `${ x => { x<number, string>(undefined); return x; } }${ undefined }${ "hello" }`;
>tempTag2 : { (templateStrs: TemplateStringsArray, f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: number): number; (templateStrs: TemplateStringsArray, f: (x: <S, T>(p: T) => T) => <S, T>(p: T) => T, h: (x: <S, T>(p: T) => T) => <S, T>(p: T) => T, x: string): string; }
>x => { x<number, string>(undefined); return x; } : (x: <S, T>(p: T) => T) => <S, T>(p: T) => T
>x : <S, T>(p: T) => T
>x<number, string>(undefined) : string
>x : <S, T>(p: T) => T
>undefined : undefined
>x : <S, T>(p: T) => T
>undefined : undefined
@@ -0,0 +1,15 @@
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts(6,5): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts(6,31): error TS2322: Type 'string' is not assignable to type 'number'.
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts (2 errors) ====
function foo(...rest: any[]) {
}
foo `${function (x: number) { x = "bad"; } }`;
~~~
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
~
!!! error TS2322: Type 'string' is not assignable to type 'number'.
@@ -0,0 +1,11 @@
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts(5,31): error TS2322: Type 'string' is not assignable to type 'number'.
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts (1 errors) ====
function foo(...rest: any[]) {
}
foo `${function (x: number) { x = "bad"; } }`;
~
!!! error TS2322: Type 'string' is not assignable to type 'number'.
@@ -0,0 +1,13 @@
//// [taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts]
function foo(...rest: any[]) {
}
foo `${function (x: number) { x = "bad"; } }`;
//// [taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.js]
function foo(...rest) {
}
foo `${function (x) {
x = "bad";
}}`;
@@ -0,0 +1,9 @@
tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts(3,27): error TS2322: Type 'string' is not assignable to type 'number'.
==== tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts (1 errors) ====
`${function (x: number) { x = "bad"; } }`;
~
!!! error TS2322: Type 'string' is not assignable to type 'number'.
@@ -0,0 +1,9 @@
//// [templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts]
`${function (x: number) { x = "bad"; } }`;
//// [templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.js]
"" + function (x) {
x = "bad";
};
@@ -0,0 +1,8 @@
tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts(2,27): error TS2322: Type 'string' is not assignable to type 'number'.
==== tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts (1 errors) ====
`${function (x: number) { x = "bad"; } }`;
~
!!! error TS2322: Type 'string' is not assignable to type 'number'.
@@ -0,0 +1,8 @@
//// [templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts]
`${function (x: number) { x = "bad"; } }`;
//// [templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.js]
`${function (x) {
x = "bad";
}}`;
@@ -0,0 +1,11 @@
module Z.M {
export function bar() {
return "";
}
}
module A.M {
import M = Z.M;
export function bar() {
}
M.bar(); // Should call Z.M.bar
}
@@ -0,0 +1,11 @@
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
}
@@ -0,0 +1,16 @@
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
}
@@ -0,0 +1,12 @@
module Z.M {
export function bar() {
return "";
}
}
module A.M {
interface M { }
import M = Z.M;
export function bar() {
}
M.bar(); // Should call Z.M.bar
}
@@ -0,0 +1,16 @@
module Z {
export module M {
export function bar() {
return "";
}
}
export interface I { }
}
module A.M {
import M = Z.I;
import M = Z.M;
export function bar() {
}
M.bar(); // Should call Z.M.bar
}
@@ -0,0 +1,10 @@
module Z.M {
export function bar() {
return "";
}
}
module A.M {
import M = Z.M;
export function bar() {
}
}
@@ -0,0 +1,6 @@
function foo(...rest: any[]) {
}
foo `${function (x: number) { x = "bad"; } }`;
@@ -0,0 +1,6 @@
//@target: es6
function foo(...rest: any[]) {
}
foo `${function (x: number) { x = "bad"; } }`;
@@ -0,0 +1,3 @@
`${function (x: number) { x = "bad"; } }`;
@@ -0,0 +1,3 @@
//@target: es6
`${function (x: number) { x = "bad"; } }`;
@@ -0,0 +1,17 @@
// @target: ES6
type FuncType = (x: <T>(p: T) => T) => typeof x;
function tempTag1<T>(templateStrs: TemplateStringsArray, f: FuncType, x: T): T;
function tempTag1<T>(templateStrs: TemplateStringsArray, f: FuncType, h: FuncType, x: T): T;
function tempTag1<T>(...rest: any[]): T {
return undefined;
}
// If contextual typing takes place, these functions should work.
// Otherwise, the arrow functions' parameters will be typed as 'any',
// and it is an error to invoke an any-typed value with type arguments,
// so this test will error.
tempTag1 `${ x => { x<number>(undefined); return x; } }${ y => { y<number>(undefined); return y; } }${ 10 }`;
tempTag1 `${ x => { x<number>(undefined); return x; } }${ (y: <T>(p: T) => T) => { y<number>(undefined); return y } }${ undefined }`;
tempTag1 `${ (x: <T>(p: T) => T) => { x<number>(undefined); return x; } }${ y => { y<number>(undefined); return y; } }${ undefined }`;
@@ -0,0 +1,18 @@
// @target: ES6
type FuncType1 = (x: <T>(p: T) => T) => typeof x;
type FuncType2 = (x: <S, T>(p: T) => T) => typeof x;
function tempTag2(templateStrs: TemplateStringsArray, f: FuncType1, x: number): number;
function tempTag2(templateStrs: TemplateStringsArray, f: FuncType2, h: FuncType2, x: string): string;
function tempTag2(...rest: any[]): any {
return undefined;
}
// If contextual typing takes place, these functions should work.
// Otherwise, the arrow functions' parameters will be typed as 'any',
// and it is an error to invoke an any-typed value with type arguments,
// so this test will error.
tempTag2 `${ x => { x<number>(undefined); return x; } }${ 0 }`;
tempTag2 `${ x => { x<number, string>(undefined); return x; } }${ y => { y<string, number>(null); return y; } }${ "hello" }`;
tempTag2 `${ x => { x<number, string>(undefined); return x; } }${ undefined }${ "hello" }`;
@@ -0,0 +1,19 @@
/// <reference path="fourslash.ts" />
////function tempTag1<T>(templateStrs: TemplateStringsArray, f: (x: T) => T, x: T): T;
////function tempTag1<T>(templateStrs: TemplateStringsArray, f: (x: T) => T, h: (y: T) => T, x: T): T;
////function tempTag1<T>(...rest: any[]): T {
//// return undefined;
////}
////
////tempTag1 `${ x => /*0*/x }${ 10 }`;
////tempTag1 `${ x => /*1*/x }${ x => /*2*/x }${ 10 }`;
////tempTag1 `${ x => /*3*/x }${ (x: number) => /*4*/x }${ undefined }`;
////tempTag1 `${ (x: number) => /*5*/x }${ x => /*6*/x }${ undefined }`;
var markers = test.markers();
markers.forEach(marker => {
goTo.position(marker.position);
verify.quickInfoIs("(parameter) x: number");
});
@@ -0,0 +1,31 @@
/// <reference path="fourslash.ts" />
////function tempTag2(templateStrs: TemplateStringsArray, f: (x: number) => number, x: number): number;
////function tempTag2(templateStrs: TemplateStringsArray, f: (x: string) => string, h: (y: string) => string, x: string): string;
////function tempTag2(...rest: any[]): any {
//// return undefined;
////}
////
////tempTag2 `${ x => /*0*/x }${ 0 }`;
////tempTag2 `${ /*1*/x => /*2*/x }${ undefined }`;
////tempTag2 `${ x => /*3*/x }${ x => /*4*/x }${ "hello" }`;
////tempTag2 `${ x => /*5*/x }${ undefined }${ "hello" }`;
// The first group of parameters, [0, 2], should all be contextually typed as 'number'.
// The second group, [3, 5], should be typed as 'string'.
var numTypedVariableCount = 3;
var strTypedVariableCount = 3;
if (numTypedVariableCount + strTypedVariableCount !== test.markers().length) {
throw "Unexpected number of markers in file.";
}
for (var i = 0; i < numTypedVariableCount; i++) {
goTo.marker("" + i);
verify.quickInfoIs("(parameter) x: number");
}
for (var i = 0; i < strTypedVariableCount; i++) {
goTo.marker("" + (i + numTypedVariableCount));
verify.quickInfoIs("(parameter) x: string");
}