Merge branch 'master' into addTestsForRestAndDefault

This commit is contained in:
Yui T
2015-01-15 13:57:25 -08:00
148 changed files with 18106 additions and 9941 deletions
+14 -3
View File
@@ -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
View File
File diff suppressed because it is too large Load Diff
+72 -146
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 {
@@ -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;
+72 -146
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 {
@@ -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
View File
File diff suppressed because it is too large Load Diff
+45 -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;
@@ -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 {
+45 -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;
@@ -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 {
+105 -41
View File
@@ -1575,7 +1575,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 +1584,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 +3337,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 +3654,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 +4592,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 +4649,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 +4702,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 +4711,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
@@ -5057,17 +5061,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 +5217,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 +5228,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;
}
@@ -5600,8 +5617,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
@@ -5622,6 +5642,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;
}
}
}
@@ -5876,7 +5900,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
@@ -6110,8 +6134,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];
@@ -6119,25 +6145,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);
}
}
}
@@ -7169,7 +7206,7 @@ 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);
@@ -7188,17 +7225,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) {
@@ -8989,7 +9029,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)) {
@@ -9000,6 +9045,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);
@@ -9247,6 +9294,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 +9839,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;
@@ -10128,6 +10189,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 {
+1 -1
View File
@@ -67,7 +67,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",
+6
View File
@@ -208,6 +208,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.
*
@@ -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." },
@@ -369,9 +370,10 @@ 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}" },
@@ -419,7 +421,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." },
+15 -5
View File
@@ -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",
@@ -1572,9 +1576,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 +1589,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
@@ -1772,7 +1782,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
},
+45 -19
View File
@@ -1461,18 +1461,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");
@@ -2068,9 +2057,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 +2077,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 +2094,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 +2141,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,
@@ -2134,6 +2159,7 @@ module ts {
case SyntaxKind.PercentToken:
return Comparison.GreaterThan;
case SyntaxKind.PlusToken:
case SyntaxKind.MinusToken:
return Comparison.EqualTo;
default:
return Comparison.LessThan;
@@ -3684,8 +3710,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
View File
@@ -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:
+4 -1
View File
@@ -185,7 +185,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";
}
+2 -2
View File
@@ -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))) {
-2
View File
@@ -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 {
+17
View File
@@ -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;
}
+4 -14
View File
@@ -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';
+38 -30
View File
@@ -810,7 +810,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 +820,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 +832,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 +917,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 +1073,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 +1104,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 +1119,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 +1137,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);
}
+14 -16
View File
@@ -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;
}
+1 -1
View File
@@ -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: () => {
-52
View File
@@ -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);
}
}
}
+8 -2
View File
@@ -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
@@ -597,7 +599,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);
}
@@ -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
},
+1 -1
View File
@@ -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,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
}
}
+12 -12
View File
@@ -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,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];
@@ -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 = {}));
@@ -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,52 @@
//// [parenthesizedContexualTyping1.ts]
function fun<T>(g: (x: T) => T, x: T): T;
function fun<T>(g: (x: T) => T, h: (y: T) => T, x: T): T;
function fun<T>(g: (x: T) => T, x: T): T {
return g(x);
}
var a = fun(x => x, 10);
var b = fun((x => x), 10);
var c = fun(((x => x)), 10);
var d = fun((((x => x))), 10);
var e = fun(x => x, x => x, 10);
var f = fun((x => x), (x => x), 10);
var g = fun(((x => x)), ((x => x)), 10);
var h = fun((((x => x))), ((x => x)), 10);
// Ternaries in parens
var i = fun((Math.random() < 0.5 ? x => x : x => undefined), 10);
var j = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10);
var k = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10);
var l = fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x)), 10);
var lambda1: (x: number) => number = x => x;
var lambda2: (x: number) => number = (x => x);
type ObjType = { x: (p: number) => string; y: (p: string) => number };
var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) };
var obj2: ObjType = ({ x: x => (x, undefined), y: y => (y, undefined) });
//// [parenthesizedContexualTyping1.js]
function fun(g, x) {
return g(x);
}
var a = fun(function (x) { return x; }, 10);
var b = fun((function (x) { return x; }), 10);
var c = fun(((function (x) { return x; })), 10);
var d = fun((((function (x) { return x; }))), 10);
var e = fun(function (x) { return x; }, function (x) { return x; }, 10);
var f = fun((function (x) { return x; }), (function (x) { return x; }), 10);
var g = fun(((function (x) { return x; })), ((function (x) { return x; })), 10);
var h = fun((((function (x) { return x; }))), ((function (x) { return x; })), 10);
// Ternaries in parens
var i = fun((Math.random() < 0.5 ? function (x) { return x; } : function (x) { return undefined; }), 10);
var j = fun((Math.random() < 0.5 ? (function (x) { return x; }) : (function (x) { return undefined; })), 10);
var k = fun((Math.random() < 0.5 ? (function (x) { return x; }) : (function (x) { return undefined; })), function (x) { return x; }, 10);
var l = fun(((Math.random() < 0.5 ? ((function (x) { return x; })) : ((function (x) { return undefined; })))), ((function (x) { return x; })), 10);
var lambda1 = function (x) { return x; };
var lambda2 = (function (x) { return x; });
var obj1 = { x: function (x) { return (x, undefined); }, y: function (y) { return (y, undefined); } };
var obj2 = ({ x: function (x) { return (x, undefined); }, y: function (y) { return (y, undefined); } });
@@ -0,0 +1,289 @@
=== tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping1.ts ===
function fun<T>(g: (x: T) => T, x: T): T;
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
>T : T
>g : (x: T) => T
>x : T
>T : T
>T : T
>x : T
>T : T
>T : T
function fun<T>(g: (x: T) => T, h: (y: T) => T, x: T): T;
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
>T : T
>g : (x: T) => T
>x : T
>T : T
>T : T
>h : (y: T) => T
>y : T
>T : T
>T : T
>x : T
>T : T
>T : T
function fun<T>(g: (x: T) => T, x: T): T {
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
>T : T
>g : (x: T) => T
>x : T
>T : T
>T : T
>x : T
>T : T
>T : T
return g(x);
>g(x) : T
>g : (x: T) => T
>x : T
}
var a = fun(x => x, 10);
>a : number
>fun(x => x, 10) : number
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
>x => x : (x: number) => number
>x : number
>x : number
var b = fun((x => x), 10);
>b : number
>fun((x => x), 10) : number
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
>(x => x) : (x: number) => number
>x => x : (x: number) => number
>x : number
>x : number
var c = fun(((x => x)), 10);
>c : number
>fun(((x => x)), 10) : number
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
>((x => x)) : (x: number) => number
>(x => x) : (x: number) => number
>x => x : (x: number) => number
>x : number
>x : number
var d = fun((((x => x))), 10);
>d : number
>fun((((x => x))), 10) : number
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
>(((x => x))) : (x: number) => number
>((x => x)) : (x: number) => number
>(x => x) : (x: number) => number
>x => x : (x: number) => number
>x : number
>x : number
var e = fun(x => x, x => x, 10);
>e : number
>fun(x => x, x => x, 10) : number
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
>x => x : (x: number) => number
>x : number
>x : number
>x => x : (x: number) => number
>x : number
>x : number
var f = fun((x => x), (x => x), 10);
>f : number
>fun((x => x), (x => x), 10) : number
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
>(x => x) : (x: number) => number
>x => x : (x: number) => number
>x : number
>x : number
>(x => x) : (x: number) => number
>x => x : (x: number) => number
>x : number
>x : number
var g = fun(((x => x)), ((x => x)), 10);
>g : number
>fun(((x => x)), ((x => x)), 10) : number
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
>((x => x)) : (x: number) => number
>(x => x) : (x: number) => number
>x => x : (x: number) => number
>x : number
>x : number
>((x => x)) : (x: number) => number
>(x => x) : (x: number) => number
>x => x : (x: number) => number
>x : number
>x : number
var h = fun((((x => x))), ((x => x)), 10);
>h : number
>fun((((x => x))), ((x => x)), 10) : number
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
>(((x => x))) : (x: number) => number
>((x => x)) : (x: number) => number
>(x => x) : (x: number) => number
>x => x : (x: number) => number
>x : number
>x : number
>((x => x)) : (x: number) => number
>(x => x) : (x: number) => number
>x => x : (x: number) => number
>x : number
>x : number
// Ternaries in parens
var i = fun((Math.random() < 0.5 ? x => x : x => undefined), 10);
>i : any
>fun((Math.random() < 0.5 ? x => x : x => undefined), 10) : any
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
>(Math.random() < 0.5 ? x => x : x => undefined) : (x: number) => any
>Math.random() < 0.5 ? x => x : x => undefined : (x: number) => any
>Math.random() < 0.5 : boolean
>Math.random() : number
>Math.random : () => number
>Math : Math
>random : () => number
>x => x : (x: number) => number
>x : number
>x : number
>x => undefined : (x: number) => any
>x : number
>undefined : undefined
var j = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10);
>j : any
>fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10) : any
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
>(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: number) => any
>Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: number) => any
>Math.random() < 0.5 : boolean
>Math.random() : number
>Math.random : () => number
>Math : Math
>random : () => number
>(x => x) : (x: number) => number
>x => x : (x: number) => number
>x : number
>x : number
>(x => undefined) : (x: number) => any
>x => undefined : (x: number) => any
>x : number
>undefined : undefined
var k = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10);
>k : any
>fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10) : any
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
>(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: number) => any
>Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: number) => any
>Math.random() < 0.5 : boolean
>Math.random() : number
>Math.random : () => number
>Math : Math
>random : () => number
>(x => x) : (x: number) => number
>x => x : (x: number) => number
>x : number
>x : number
>(x => undefined) : (x: number) => any
>x => undefined : (x: number) => any
>x : number
>undefined : undefined
>x => x : (x: any) => any
>x : any
>x : any
var l = fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x)), 10);
>l : any
>fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x)), 10) : any
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
>((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))) : (x: number) => any
>(Math.random() < 0.5 ? ((x => x)) : ((x => undefined))) : (x: number) => any
>Math.random() < 0.5 ? ((x => x)) : ((x => undefined)) : (x: number) => any
>Math.random() < 0.5 : boolean
>Math.random() : number
>Math.random : () => number
>Math : Math
>random : () => number
>((x => x)) : (x: number) => number
>(x => x) : (x: number) => number
>x => x : (x: number) => number
>x : number
>x : number
>((x => undefined)) : (x: number) => any
>(x => undefined) : (x: number) => any
>x => undefined : (x: number) => any
>x : number
>undefined : undefined
>((x => x)) : (x: number) => number
>(x => x) : (x: number) => number
>x => x : (x: number) => number
>x : number
>x : number
var lambda1: (x: number) => number = x => x;
>lambda1 : (x: number) => number
>x : number
>x => x : (x: number) => number
>x : number
>x : number
var lambda2: (x: number) => number = (x => x);
>lambda2 : (x: number) => number
>x : number
>(x => x) : (x: number) => number
>x => x : (x: number) => number
>x : number
>x : number
type ObjType = { x: (p: number) => string; y: (p: string) => number };
>ObjType : { x: (p: number) => string; y: (p: string) => number; }
>x : (p: number) => string
>p : number
>y : (p: string) => number
>p : string
var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) };
>obj1 : { x: (p: number) => string; y: (p: string) => number; }
>ObjType : { x: (p: number) => string; y: (p: string) => number; }
>{ x: x => (x, undefined), y: y => (y, undefined) } : { x: (x: number) => any; y: (y: string) => any; }
>x : (x: number) => any
>x => (x, undefined) : (x: number) => any
>x : number
>(x, undefined) : undefined
>x, undefined : undefined
>x : number
>undefined : undefined
>y : (y: string) => any
>y => (y, undefined) : (y: string) => any
>y : string
>(y, undefined) : undefined
>y, undefined : undefined
>y : string
>undefined : undefined
var obj2: ObjType = ({ x: x => (x, undefined), y: y => (y, undefined) });
>obj2 : { x: (p: number) => string; y: (p: string) => number; }
>ObjType : { x: (p: number) => string; y: (p: string) => number; }
>({ x: x => (x, undefined), y: y => (y, undefined) }) : { x: (x: number) => any; y: (y: string) => any; }
>{ x: x => (x, undefined), y: y => (y, undefined) } : { x: (x: number) => any; y: (y: string) => any; }
>x : (x: number) => any
>x => (x, undefined) : (x: number) => any
>x : number
>(x, undefined) : undefined
>x, undefined : undefined
>x : number
>undefined : undefined
>y : (y: string) => any
>y => (y, undefined) : (y: string) => any
>y : string
>(y, undefined) : undefined
>y, undefined : undefined
>y : string
>undefined : undefined
@@ -0,0 +1,128 @@
//// [parenthesizedContexualTyping2.ts]
// These tests ensure that in cases where it may *appear* that a value has a type,
// they actually are properly being contextually typed. The way we test this is
// that we invoke contextually typed arguments with type arguments.
// Since 'any' cannot be invoked with type arguments, we should get errors
// back if contextual typing is not taking effect.
type FuncType = (x: <T>(p: T) => T) => typeof x;
function fun<T>(f: FuncType, x: T): T;
function fun<T>(f: FuncType, g: FuncType, x: T): T;
function fun<T>(...rest: any[]): T {
return undefined;
}
var a = fun(x => { x<number>(undefined); return x; }, 10);
var b = fun((x => { x<number>(undefined); return x; }), 10);
var c = fun(((x => { x<number>(undefined); return x; })), 10);
var d = fun((((x => { x<number>(undefined); return x; }))), 10);
var e = fun(x => { x<number>(undefined); return x; }, x => { x<number>(undefined); return x; }, 10);
var f = fun((x => { x<number>(undefined); return x; }),(x => { x<number>(undefined); return x; }), 10);
var g = fun(((x => { x<number>(undefined); return x; })),((x => { x<number>(undefined); return x; })), 10);
var h = fun((((x => { x<number>(undefined); return x; }))),((x => { x<number>(undefined); return x; })), 10);
// Ternaries in parens
var i = fun((Math.random() < 0.5 ? x => { x<number>(undefined); return x; } : x => undefined), 10);
var j = fun((Math.random() < 0.5 ? (x => { x<number>(undefined); return x; }) : (x => undefined)), 10);
var k = fun((Math.random() < 0.5 ? (x => { x<number>(undefined); return x; }) : (x => undefined)), x => { x<number>(undefined); return x; }, 10);
var l = fun(((Math.random() < 0.5 ? ((x => { x<number>(undefined); return x; })) : ((x => undefined)))),((x => { x<number>(undefined); return x; })), 10);
var lambda1: FuncType = x => { x<number>(undefined); return x; };
var lambda2: FuncType = (x => { x<number>(undefined); return x; });
type ObjType = { x: (p: number) => string; y: (p: string) => number };
var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) };
var obj2: ObjType = ({ x: x => (x, undefined), y: y => (y, undefined) });
//// [parenthesizedContexualTyping2.js]
// These tests ensure that in cases where it may *appear* that a value has a type,
// they actually are properly being contextually typed. The way we test this is
// that we invoke contextually typed arguments with type arguments.
// Since 'any' cannot be invoked with type arguments, we should get errors
// back if contextual typing is not taking effect.
function fun() {
var rest = [];
for (var _i = 0; _i < arguments.length; _i++) {
rest[_i - 0] = arguments[_i];
}
return undefined;
}
var a = fun(function (x) {
x(undefined);
return x;
}, 10);
var b = fun((function (x) {
x(undefined);
return x;
}), 10);
var c = fun(((function (x) {
x(undefined);
return x;
})), 10);
var d = fun((((function (x) {
x(undefined);
return x;
}))), 10);
var e = fun(function (x) {
x(undefined);
return x;
}, function (x) {
x(undefined);
return x;
}, 10);
var f = fun((function (x) {
x(undefined);
return x;
}), (function (x) {
x(undefined);
return x;
}), 10);
var g = fun(((function (x) {
x(undefined);
return x;
})), ((function (x) {
x(undefined);
return x;
})), 10);
var h = fun((((function (x) {
x(undefined);
return x;
}))), ((function (x) {
x(undefined);
return x;
})), 10);
// Ternaries in parens
var i = fun((Math.random() < 0.5 ? function (x) {
x(undefined);
return x;
} : function (x) { return undefined; }), 10);
var j = fun((Math.random() < 0.5 ? (function (x) {
x(undefined);
return x;
}) : (function (x) { return undefined; })), 10);
var k = fun((Math.random() < 0.5 ? (function (x) {
x(undefined);
return x;
}) : (function (x) { return undefined; })), function (x) {
x(undefined);
return x;
}, 10);
var l = fun(((Math.random() < 0.5 ? ((function (x) {
x(undefined);
return x;
})) : ((function (x) { return undefined; })))), ((function (x) {
x(undefined);
return x;
})), 10);
var lambda1 = function (x) {
x(undefined);
return x;
};
var lambda2 = (function (x) {
x(undefined);
return x;
});
var obj1 = { x: function (x) { return (x, undefined); }, y: function (y) { return (y, undefined); } };
var obj2 = ({ x: function (x) { return (x, undefined); }, y: function (y) { return (y, undefined); } });
@@ -0,0 +1,350 @@
=== tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts ===
// These tests ensure that in cases where it may *appear* that a value has a type,
// they actually are properly being contextually typed. The way we test this is
// that we invoke contextually typed arguments with type arguments.
// Since 'any' cannot be invoked with type arguments, we should get errors
// back if contextual typing is not taking effect.
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 fun<T>(f: FuncType, x: T): T;
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
>T : T
>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 fun<T>(f: FuncType, g: FuncType, x: T): T;
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
>T : T
>f : (x: <T>(p: T) => T) => <T>(p: T) => T
>FuncType : (x: <T>(p: T) => T) => <T>(p: T) => T
>g : (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 fun<T>(...rest: any[]): T {
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
>T : T
>rest : any[]
>T : T
return undefined;
>undefined : undefined
}
var a = fun(x => { x<number>(undefined); return x; }, 10);
>a : number
>fun(x => { x<number>(undefined); return x; }, 10) : number
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (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
var b = fun((x => { x<number>(undefined); return x; }), 10);
>b : number
>fun((x => { x<number>(undefined); return x; }), 10) : number
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (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 => { 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
var c = fun(((x => { x<number>(undefined); return x; })), 10);
>c : number
>fun(((x => { x<number>(undefined); return x; })), 10) : number
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (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 => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: 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
var d = fun((((x => { x<number>(undefined); return x; }))), 10);
>d : number
>fun((((x => { x<number>(undefined); return x; }))), 10) : number
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (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 => { x<number>(undefined); return x; })) : (x: <T>(p: T) => T) => <T>(p: T) => T
>(x => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: 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
var e = fun(x => { x<number>(undefined); return x; }, x => { x<number>(undefined); return x; }, 10);
>e : number
>fun(x => { x<number>(undefined); return x; }, x => { x<number>(undefined); return x; }, 10) : number
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (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
>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
var f = fun((x => { x<number>(undefined); return x; }),(x => { x<number>(undefined); return x; }), 10);
>f : number
>fun((x => { x<number>(undefined); return x; }),(x => { x<number>(undefined); return x; }), 10) : number
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (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 => { 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
>(x => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: 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
var g = fun(((x => { x<number>(undefined); return x; })),((x => { x<number>(undefined); return x; })), 10);
>g : number
>fun(((x => { x<number>(undefined); return x; })),((x => { x<number>(undefined); return x; })), 10) : number
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (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 => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: 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
>((x => { x<number>(undefined); return x; })) : (x: <T>(p: T) => T) => <T>(p: T) => T
>(x => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: 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
var h = fun((((x => { x<number>(undefined); return x; }))),((x => { x<number>(undefined); return x; })), 10);
>h : number
>fun((((x => { x<number>(undefined); return x; }))),((x => { x<number>(undefined); return x; })), 10) : number
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (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 => { x<number>(undefined); return x; })) : (x: <T>(p: T) => T) => <T>(p: T) => T
>(x => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: 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
>((x => { x<number>(undefined); return x; })) : (x: <T>(p: T) => T) => <T>(p: T) => T
>(x => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: 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
// Ternaries in parens
var i = fun((Math.random() < 0.5 ? x => { x<number>(undefined); return x; } : x => undefined), 10);
>i : number
>fun((Math.random() < 0.5 ? x => { x<number>(undefined); return x; } : x => undefined), 10) : number
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
>(Math.random() < 0.5 ? x => { x<number>(undefined); return x; } : x => undefined) : (x: <T>(p: T) => T) => any
>Math.random() < 0.5 ? x => { x<number>(undefined); return x; } : x => undefined : (x: <T>(p: T) => T) => any
>Math.random() < 0.5 : boolean
>Math.random() : number
>Math.random : () => number
>Math : Math
>random : () => number
>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
>x => undefined : (x: <T>(p: T) => T) => any
>x : <T>(p: T) => T
>undefined : undefined
var j = fun((Math.random() < 0.5 ? (x => { x<number>(undefined); return x; }) : (x => undefined)), 10);
>j : number
>fun((Math.random() < 0.5 ? (x => { x<number>(undefined); return x; }) : (x => undefined)), 10) : number
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
>(Math.random() < 0.5 ? (x => { x<number>(undefined); return x; }) : (x => undefined)) : (x: <T>(p: T) => T) => any
>Math.random() < 0.5 ? (x => { x<number>(undefined); return x; }) : (x => undefined) : (x: <T>(p: T) => T) => any
>Math.random() < 0.5 : boolean
>Math.random() : number
>Math.random : () => number
>Math : Math
>random : () => number
>(x => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: 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
>(x => undefined) : (x: <T>(p: T) => T) => any
>x => undefined : (x: <T>(p: T) => T) => any
>x : <T>(p: T) => T
>undefined : undefined
var k = fun((Math.random() < 0.5 ? (x => { x<number>(undefined); return x; }) : (x => undefined)), x => { x<number>(undefined); return x; }, 10);
>k : number
>fun((Math.random() < 0.5 ? (x => { x<number>(undefined); return x; }) : (x => undefined)), x => { x<number>(undefined); return x; }, 10) : number
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
>(Math.random() < 0.5 ? (x => { x<number>(undefined); return x; }) : (x => undefined)) : (x: <T>(p: T) => T) => any
>Math.random() < 0.5 ? (x => { x<number>(undefined); return x; }) : (x => undefined) : (x: <T>(p: T) => T) => any
>Math.random() < 0.5 : boolean
>Math.random() : number
>Math.random : () => number
>Math : Math
>random : () => number
>(x => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: 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
>(x => undefined) : (x: <T>(p: T) => T) => any
>x => undefined : (x: <T>(p: T) => T) => any
>x : <T>(p: T) => T
>undefined : undefined
>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
var l = fun(((Math.random() < 0.5 ? ((x => { x<number>(undefined); return x; })) : ((x => undefined)))),((x => { x<number>(undefined); return x; })), 10);
>l : number
>fun(((Math.random() < 0.5 ? ((x => { x<number>(undefined); return x; })) : ((x => undefined)))),((x => { x<number>(undefined); return x; })), 10) : number
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
>((Math.random() < 0.5 ? ((x => { x<number>(undefined); return x; })) : ((x => undefined)))) : (x: <T>(p: T) => T) => any
>(Math.random() < 0.5 ? ((x => { x<number>(undefined); return x; })) : ((x => undefined))) : (x: <T>(p: T) => T) => any
>Math.random() < 0.5 ? ((x => { x<number>(undefined); return x; })) : ((x => undefined)) : (x: <T>(p: T) => T) => any
>Math.random() < 0.5 : boolean
>Math.random() : number
>Math.random : () => number
>Math : Math
>random : () => number
>((x => { x<number>(undefined); return x; })) : (x: <T>(p: T) => T) => <T>(p: T) => T
>(x => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: 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
>((x => undefined)) : (x: <T>(p: T) => T) => any
>(x => undefined) : (x: <T>(p: T) => T) => any
>x => undefined : (x: <T>(p: T) => T) => any
>x : <T>(p: T) => T
>undefined : undefined
>((x => { x<number>(undefined); return x; })) : (x: <T>(p: T) => T) => <T>(p: T) => T
>(x => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: 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
var lambda1: FuncType = x => { x<number>(undefined); return x; };
>lambda1 : (x: <T>(p: T) => T) => <T>(p: T) => T
>FuncType : (x: <T>(p: T) => T) => <T>(p: 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
var lambda2: FuncType = (x => { x<number>(undefined); return x; });
>lambda2 : (x: <T>(p: T) => T) => <T>(p: T) => T
>FuncType : (x: <T>(p: T) => T) => <T>(p: T) => T
>(x => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: 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
type ObjType = { x: (p: number) => string; y: (p: string) => number };
>ObjType : { x: (p: number) => string; y: (p: string) => number; }
>x : (p: number) => string
>p : number
>y : (p: string) => number
>p : string
var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) };
>obj1 : { x: (p: number) => string; y: (p: string) => number; }
>ObjType : { x: (p: number) => string; y: (p: string) => number; }
>{ x: x => (x, undefined), y: y => (y, undefined) } : { x: (x: number) => any; y: (y: string) => any; }
>x : (x: number) => any
>x => (x, undefined) : (x: number) => any
>x : number
>(x, undefined) : undefined
>x, undefined : undefined
>x : number
>undefined : undefined
>y : (y: string) => any
>y => (y, undefined) : (y: string) => any
>y : string
>(y, undefined) : undefined
>y, undefined : undefined
>y : string
>undefined : undefined
var obj2: ObjType = ({ x: x => (x, undefined), y: y => (y, undefined) });
>obj2 : { x: (p: number) => string; y: (p: string) => number; }
>ObjType : { x: (p: number) => string; y: (p: string) => number; }
>({ x: x => (x, undefined), y: y => (y, undefined) }) : { x: (x: number) => any; y: (y: string) => any; }
>{ x: x => (x, undefined), y: y => (y, undefined) } : { x: (x: number) => any; y: (y: string) => any; }
>x : (x: number) => any
>x => (x, undefined) : (x: number) => any
>x : number
>(x, undefined) : undefined
>x, undefined : undefined
>x : number
>undefined : undefined
>y : (y: string) => any
>y => (y, undefined) : (y: string) => any
>y : string
>(y, undefined) : undefined
>y, undefined : undefined
>y : string
>undefined : undefined
@@ -0,0 +1,35 @@
//// [parenthesizedContexualTyping3.ts]
// Contextual typing for parenthesized substitution expressions in tagged templates.
/**
* tempFun - Can't have fun for too long.
*/
function tempFun<T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T;
function tempFun<T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T;
function tempFun<T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T {
return g(x);
}
var a = tempFun `${ x => x } ${ 10 }`
var b = tempFun `${ (x => x) } ${ 10 }`
var c = tempFun `${ ((x => x)) } ${ 10 }`
var d = tempFun `${ x => x } ${ x => x } ${ 10 }`
var e = tempFun `${ x => x } ${ (x => x) } ${ 10 }`
var f = tempFun `${ x => x } ${ ((x => x)) } ${ 10 }`
var g = tempFun `${ (x => x) } ${ (((x => x))) } ${ 10 }`
var h = tempFun `${ (x => x) } ${ (((x => x))) } ${ undefined }`
//// [parenthesizedContexualTyping3.js]
// Contextual typing for parenthesized substitution expressions in tagged templates.
function tempFun(tempStrs, g, x) {
return g(x);
}
var a = tempFun `${function (x) { return x; }} ${10}`;
var b = tempFun `${(function (x) { return x; })} ${10}`;
var c = tempFun `${((function (x) { return x; }))} ${10}`;
var d = tempFun `${function (x) { return x; }} ${function (x) { return x; }} ${10}`;
var e = tempFun `${function (x) { return x; }} ${(function (x) { return x; })} ${10}`;
var f = tempFun `${function (x) { return x; }} ${((function (x) { return x; }))} ${10}`;
var g = tempFun `${(function (x) { return x; })} ${(((function (x) { return x; })))} ${10}`;
var h = tempFun `${(function (x) { return x; })} ${(((function (x) { return x; })))} ${undefined}`;
@@ -0,0 +1,142 @@
=== tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping3.ts ===
// Contextual typing for parenthesized substitution expressions in tagged templates.
/**
* tempFun - Can't have fun for too long.
*/
function tempFun<T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T;
>tempFun : { <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; }
>T : T
>tempStrs : TemplateStringsArray
>TemplateStringsArray : TemplateStringsArray
>g : (x: T) => T
>x : T
>T : T
>T : T
>x : T
>T : T
>T : T
function tempFun<T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T;
>tempFun : { <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; }
>T : T
>tempStrs : TemplateStringsArray
>TemplateStringsArray : TemplateStringsArray
>g : (x: T) => T
>x : T
>T : T
>T : T
>h : (y: T) => T
>y : T
>T : T
>T : T
>x : T
>T : T
>T : T
function tempFun<T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T {
>tempFun : { <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; }
>T : T
>tempStrs : TemplateStringsArray
>TemplateStringsArray : TemplateStringsArray
>g : (x: T) => T
>x : T
>T : T
>T : T
>x : T
>T : T
>T : T
return g(x);
>g(x) : T
>g : (x: T) => T
>x : T
}
var a = tempFun `${ x => x } ${ 10 }`
>a : number
>tempFun : { <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; }
>x => x : (x: number) => number
>x : number
>x : number
var b = tempFun `${ (x => x) } ${ 10 }`
>b : number
>tempFun : { <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; }
>(x => x) : (x: number) => number
>x => x : (x: number) => number
>x : number
>x : number
var c = tempFun `${ ((x => x)) } ${ 10 }`
>c : number
>tempFun : { <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; }
>((x => x)) : (x: number) => number
>(x => x) : (x: number) => number
>x => x : (x: number) => number
>x : number
>x : number
var d = tempFun `${ x => x } ${ x => x } ${ 10 }`
>d : number
>tempFun : { <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; }
>x => x : (x: number) => number
>x : number
>x : number
>x => x : (x: number) => number
>x : number
>x : number
var e = tempFun `${ x => x } ${ (x => x) } ${ 10 }`
>e : number
>tempFun : { <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; }
>x => x : (x: number) => number
>x : number
>x : number
>(x => x) : (x: number) => number
>x => x : (x: number) => number
>x : number
>x : number
var f = tempFun `${ x => x } ${ ((x => x)) } ${ 10 }`
>f : number
>tempFun : { <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; }
>x => x : (x: number) => number
>x : number
>x : number
>((x => x)) : (x: number) => number
>(x => x) : (x: number) => number
>x => x : (x: number) => number
>x : number
>x : number
var g = tempFun `${ (x => x) } ${ (((x => x))) } ${ 10 }`
>g : number
>tempFun : { <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; }
>(x => x) : (x: number) => number
>x => x : (x: number) => number
>x : number
>x : number
>(((x => x))) : (x: number) => number
>((x => x)) : (x: number) => number
>(x => x) : (x: number) => number
>x => x : (x: number) => number
>x : number
>x : number
var h = tempFun `${ (x => x) } ${ (((x => x))) } ${ undefined }`
>h : any
>tempFun : { <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; }
>(x => x) : (x: any) => any
>x => x : (x: any) => any
>x : any
>x : any
>(((x => x))) : (x: any) => any
>((x => x)) : (x: any) => any
>(x => x) : (x: any) => any
>x => x : (x: any) => any
>x : any
>x : any
>undefined : undefined
@@ -0,0 +1,53 @@
//// [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; } }${ 10 }`;
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;
}}${10}`;
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,113 @@
=== 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; } }${ 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
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,103 @@
//// [templateStringBinaryOperations.ts]
var a = 1 + `${ 3 }`;
var b = 1 + `2${ 3 }`;
var c = 1 + `${ 3 }4`;
var d = 1 + `2${ 3 }4`;
var e = `${ 3 }` + 5;
var f = `2${ 3 }` + 5;
var g = `${ 3 }4` + 5;
var h = `2${ 3 }4` + 5;
var i = 1 + `${ 3 }` + 5;
var j = 1 + `2${ 3 }` + 5;
var k = 1 + `${ 3 }4` + 5;
var l = 1 + `2${ 3 }4` + 5;
var a2 = 1 + `${ 3 - 4 }`;
var b2 = 1 + `2${ 3 - 4 }`;
var c2 = 1 + `${ 3 - 4 }5`;
var d2 = 1 + `2${ 3 - 4 }5`;
var e2 = `${ 3 - 4 }` + 6;
var f2 = `2${ 3 - 4 }` + 6;
var g2 = `${ 3 - 4 }5` + 6;
var h2 = `2${ 3 - 4 }5` + 6;
var i2 = 1 + `${ 3 - 4 }` + 6;
var j2 = 1 + `2${ 3 - 4 }` + 6;
var k2 = 1 + `${ 3 - 4 }5` + 6;
var l2 = 1 + `2${ 3 - 4 }5` + 6;
var a3 = 1 + `${ 3 * 4 }`;
var b3 = 1 + `2${ 3 * 4 }`;
var c3 = 1 + `${ 3 * 4 }5`;
var d3 = 1 + `2${ 3 * 4 }5`;
var e3 = `${ 3 * 4 }` + 6;
var f3 = `2${ 3 * 4 }` + 6;
var g3 = `${ 3 * 4 }5` + 6;
var h3 = `2${ 3 * 4 }5` + 6;
var i3 = 1 + `${ 3 * 4 }` + 6;
var j3 = 1 + `2${ 3 * 4 }` + 6;
var k3 = 1 + `${ 3 * 4 }5` + 6;
var l3 = 1 + `2${ 3 * 4 }5` + 6;
var a4 = 1 + `${ 3 & 4 }`;
var b4 = 1 + `2${ 3 & 4 }`;
var c4 = 1 + `${ 3 & 4 }5`;
var d4 = 1 + `2${ 3 & 4 }5`;
var e4 = `${ 3 & 4 }` + 6;
var f4 = `2${ 3 & 4 }` + 6;
var g4 = `${ 3 & 4 }5` + 6;
var h4 = `2${ 3 & 4 }5` + 6;
var i4 = 1 + `${ 3 & 4 }` + 6;
var j4 = 1 + `2${ 3 & 4 }` + 6;
var k4 = 1 + `${ 3 & 4 }5` + 6;
var l4 = 1 + `2${ 3 & 4 }5` + 6;
//// [templateStringBinaryOperations.js]
var a = 1 + ("" + 3);
var b = 1 + ("2" + 3);
var c = 1 + (3 + "4");
var d = 1 + ("2" + 3 + "4");
var e = ("" + 3) + 5;
var f = ("2" + 3) + 5;
var g = (3 + "4") + 5;
var h = ("2" + 3 + "4") + 5;
var i = 1 + ("" + 3) + 5;
var j = 1 + ("2" + 3) + 5;
var k = 1 + (3 + "4") + 5;
var l = 1 + ("2" + 3 + "4") + 5;
var a2 = 1 + ("" + (3 - 4));
var b2 = 1 + ("2" + (3 - 4));
var c2 = 1 + ((3 - 4) + "5");
var d2 = 1 + ("2" + (3 - 4) + "5");
var e2 = ("" + (3 - 4)) + 6;
var f2 = ("2" + (3 - 4)) + 6;
var g2 = ((3 - 4) + "5") + 6;
var h2 = ("2" + (3 - 4) + "5") + 6;
var i2 = 1 + ("" + (3 - 4)) + 6;
var j2 = 1 + ("2" + (3 - 4)) + 6;
var k2 = 1 + ((3 - 4) + "5") + 6;
var l2 = 1 + ("2" + (3 - 4) + "5") + 6;
var a3 = 1 + ("" + 3 * 4);
var b3 = 1 + ("2" + 3 * 4);
var c3 = 1 + (3 * 4 + "5");
var d3 = 1 + ("2" + 3 * 4 + "5");
var e3 = ("" + 3 * 4) + 6;
var f3 = ("2" + 3 * 4) + 6;
var g3 = (3 * 4 + "5") + 6;
var h3 = ("2" + 3 * 4 + "5") + 6;
var i3 = 1 + ("" + 3 * 4) + 6;
var j3 = 1 + ("2" + 3 * 4) + 6;
var k3 = 1 + (3 * 4 + "5") + 6;
var l3 = 1 + ("2" + 3 * 4 + "5") + 6;
var a4 = 1 + ("" + (3 & 4));
var b4 = 1 + ("2" + (3 & 4));
var c4 = 1 + ((3 & 4) + "5");
var d4 = 1 + ("2" + (3 & 4) + "5");
var e4 = ("" + (3 & 4)) + 6;
var f4 = ("2" + (3 & 4)) + 6;
var g4 = ((3 & 4) + "5") + 6;
var h4 = ("2" + (3 & 4) + "5") + 6;
var i4 = 1 + ("" + (3 & 4)) + 6;
var j4 = 1 + ("2" + (3 & 4)) + 6;
var k4 = 1 + ((3 & 4) + "5") + 6;
var l4 = 1 + ("2" + (3 & 4) + "5") + 6;
@@ -0,0 +1,245 @@
=== tests/cases/conformance/es6/templates/templateStringBinaryOperations.ts ===
var a = 1 + `${ 3 }`;
>a : string
>1 + `${ 3 }` : string
var b = 1 + `2${ 3 }`;
>b : string
>1 + `2${ 3 }` : string
var c = 1 + `${ 3 }4`;
>c : string
>1 + `${ 3 }4` : string
var d = 1 + `2${ 3 }4`;
>d : string
>1 + `2${ 3 }4` : string
var e = `${ 3 }` + 5;
>e : string
>`${ 3 }` + 5 : string
var f = `2${ 3 }` + 5;
>f : string
>`2${ 3 }` + 5 : string
var g = `${ 3 }4` + 5;
>g : string
>`${ 3 }4` + 5 : string
var h = `2${ 3 }4` + 5;
>h : string
>`2${ 3 }4` + 5 : string
var i = 1 + `${ 3 }` + 5;
>i : string
>1 + `${ 3 }` + 5 : string
>1 + `${ 3 }` : string
var j = 1 + `2${ 3 }` + 5;
>j : string
>1 + `2${ 3 }` + 5 : string
>1 + `2${ 3 }` : string
var k = 1 + `${ 3 }4` + 5;
>k : string
>1 + `${ 3 }4` + 5 : string
>1 + `${ 3 }4` : string
var l = 1 + `2${ 3 }4` + 5;
>l : string
>1 + `2${ 3 }4` + 5 : string
>1 + `2${ 3 }4` : string
var a2 = 1 + `${ 3 - 4 }`;
>a2 : string
>1 + `${ 3 - 4 }` : string
>3 - 4 : number
var b2 = 1 + `2${ 3 - 4 }`;
>b2 : string
>1 + `2${ 3 - 4 }` : string
>3 - 4 : number
var c2 = 1 + `${ 3 - 4 }5`;
>c2 : string
>1 + `${ 3 - 4 }5` : string
>3 - 4 : number
var d2 = 1 + `2${ 3 - 4 }5`;
>d2 : string
>1 + `2${ 3 - 4 }5` : string
>3 - 4 : number
var e2 = `${ 3 - 4 }` + 6;
>e2 : string
>`${ 3 - 4 }` + 6 : string
>3 - 4 : number
var f2 = `2${ 3 - 4 }` + 6;
>f2 : string
>`2${ 3 - 4 }` + 6 : string
>3 - 4 : number
var g2 = `${ 3 - 4 }5` + 6;
>g2 : string
>`${ 3 - 4 }5` + 6 : string
>3 - 4 : number
var h2 = `2${ 3 - 4 }5` + 6;
>h2 : string
>`2${ 3 - 4 }5` + 6 : string
>3 - 4 : number
var i2 = 1 + `${ 3 - 4 }` + 6;
>i2 : string
>1 + `${ 3 - 4 }` + 6 : string
>1 + `${ 3 - 4 }` : string
>3 - 4 : number
var j2 = 1 + `2${ 3 - 4 }` + 6;
>j2 : string
>1 + `2${ 3 - 4 }` + 6 : string
>1 + `2${ 3 - 4 }` : string
>3 - 4 : number
var k2 = 1 + `${ 3 - 4 }5` + 6;
>k2 : string
>1 + `${ 3 - 4 }5` + 6 : string
>1 + `${ 3 - 4 }5` : string
>3 - 4 : number
var l2 = 1 + `2${ 3 - 4 }5` + 6;
>l2 : string
>1 + `2${ 3 - 4 }5` + 6 : string
>1 + `2${ 3 - 4 }5` : string
>3 - 4 : number
var a3 = 1 + `${ 3 * 4 }`;
>a3 : string
>1 + `${ 3 * 4 }` : string
>3 * 4 : number
var b3 = 1 + `2${ 3 * 4 }`;
>b3 : string
>1 + `2${ 3 * 4 }` : string
>3 * 4 : number
var c3 = 1 + `${ 3 * 4 }5`;
>c3 : string
>1 + `${ 3 * 4 }5` : string
>3 * 4 : number
var d3 = 1 + `2${ 3 * 4 }5`;
>d3 : string
>1 + `2${ 3 * 4 }5` : string
>3 * 4 : number
var e3 = `${ 3 * 4 }` + 6;
>e3 : string
>`${ 3 * 4 }` + 6 : string
>3 * 4 : number
var f3 = `2${ 3 * 4 }` + 6;
>f3 : string
>`2${ 3 * 4 }` + 6 : string
>3 * 4 : number
var g3 = `${ 3 * 4 }5` + 6;
>g3 : string
>`${ 3 * 4 }5` + 6 : string
>3 * 4 : number
var h3 = `2${ 3 * 4 }5` + 6;
>h3 : string
>`2${ 3 * 4 }5` + 6 : string
>3 * 4 : number
var i3 = 1 + `${ 3 * 4 }` + 6;
>i3 : string
>1 + `${ 3 * 4 }` + 6 : string
>1 + `${ 3 * 4 }` : string
>3 * 4 : number
var j3 = 1 + `2${ 3 * 4 }` + 6;
>j3 : string
>1 + `2${ 3 * 4 }` + 6 : string
>1 + `2${ 3 * 4 }` : string
>3 * 4 : number
var k3 = 1 + `${ 3 * 4 }5` + 6;
>k3 : string
>1 + `${ 3 * 4 }5` + 6 : string
>1 + `${ 3 * 4 }5` : string
>3 * 4 : number
var l3 = 1 + `2${ 3 * 4 }5` + 6;
>l3 : string
>1 + `2${ 3 * 4 }5` + 6 : string
>1 + `2${ 3 * 4 }5` : string
>3 * 4 : number
var a4 = 1 + `${ 3 & 4 }`;
>a4 : string
>1 + `${ 3 & 4 }` : string
>3 & 4 : number
var b4 = 1 + `2${ 3 & 4 }`;
>b4 : string
>1 + `2${ 3 & 4 }` : string
>3 & 4 : number
var c4 = 1 + `${ 3 & 4 }5`;
>c4 : string
>1 + `${ 3 & 4 }5` : string
>3 & 4 : number
var d4 = 1 + `2${ 3 & 4 }5`;
>d4 : string
>1 + `2${ 3 & 4 }5` : string
>3 & 4 : number
var e4 = `${ 3 & 4 }` + 6;
>e4 : string
>`${ 3 & 4 }` + 6 : string
>3 & 4 : number
var f4 = `2${ 3 & 4 }` + 6;
>f4 : string
>`2${ 3 & 4 }` + 6 : string
>3 & 4 : number
var g4 = `${ 3 & 4 }5` + 6;
>g4 : string
>`${ 3 & 4 }5` + 6 : string
>3 & 4 : number
var h4 = `2${ 3 & 4 }5` + 6;
>h4 : string
>`2${ 3 & 4 }5` + 6 : string
>3 & 4 : number
var i4 = 1 + `${ 3 & 4 }` + 6;
>i4 : string
>1 + `${ 3 & 4 }` + 6 : string
>1 + `${ 3 & 4 }` : string
>3 & 4 : number
var j4 = 1 + `2${ 3 & 4 }` + 6;
>j4 : string
>1 + `2${ 3 & 4 }` + 6 : string
>1 + `2${ 3 & 4 }` : string
>3 & 4 : number
var k4 = 1 + `${ 3 & 4 }5` + 6;
>k4 : string
>1 + `${ 3 & 4 }5` + 6 : string
>1 + `${ 3 & 4 }5` : string
>3 & 4 : number
var l4 = 1 + `2${ 3 & 4 }5` + 6;
>l4 : string
>1 + `2${ 3 & 4 }5` + 6 : string
>1 + `2${ 3 & 4 }5` : string
>3 & 4 : number
@@ -0,0 +1,103 @@
//// [templateStringBinaryOperationsES6.ts]
var a = 1 + `${ 3 }`;
var b = 1 + `2${ 3 }`;
var c = 1 + `${ 3 }4`;
var d = 1 + `2${ 3 }4`;
var e = `${ 3 }` + 5;
var f = `2${ 3 }` + 5;
var g = `${ 3 }4` + 5;
var h = `2${ 3 }4` + 5;
var i = 1 + `${ 3 }` + 5;
var j = 1 + `2${ 3 }` + 5;
var k = 1 + `${ 3 }4` + 5;
var l = 1 + `2${ 3 }4` + 5;
var a2 = 1 + `${ 3 - 4 }`;
var b2 = 1 + `2${ 3 - 4 }`;
var c2 = 1 + `${ 3 - 4 }5`;
var d2 = 1 + `2${ 3 - 4 }5`;
var e2 = `${ 3 - 4 }` + 6;
var f2 = `2${ 3 - 4 }` + 6;
var g2 = `${ 3 - 4 }5` + 6;
var h2 = `2${ 3 - 4 }5` + 6;
var i2 = 1 + `${ 3 - 4 }` + 6;
var j2 = 1 + `2${ 3 - 4 }` + 6;
var k2 = 1 + `${ 3 - 4 }5` + 6;
var l2 = 1 + `2${ 3 - 4 }5` + 6;
var a3 = 1 + `${ 3 * 4 }`;
var b3 = 1 + `2${ 3 * 4 }`;
var c3 = 1 + `${ 3 * 4 }5`;
var d3 = 1 + `2${ 3 * 4 }5`;
var e3 = `${ 3 * 4 }` + 6;
var f3 = `2${ 3 * 4 }` + 6;
var g3 = `${ 3 * 4 }5` + 6;
var h3 = `2${ 3 * 4 }5` + 6;
var i3 = 1 + `${ 3 * 4 }` + 6;
var j3 = 1 + `2${ 3 * 4 }` + 6;
var k3 = 1 + `${ 3 * 4 }5` + 6;
var l3 = 1 + `2${ 3 * 4 }5` + 6;
var a4 = 1 + `${ 3 & 4 }`;
var b4 = 1 + `2${ 3 & 4 }`;
var c4 = 1 + `${ 3 & 4 }5`;
var d4 = 1 + `2${ 3 & 4 }5`;
var e4 = `${ 3 & 4 }` + 6;
var f4 = `2${ 3 & 4 }` + 6;
var g4 = `${ 3 & 4 }5` + 6;
var h4 = `2${ 3 & 4 }5` + 6;
var i4 = 1 + `${ 3 & 4 }` + 6;
var j4 = 1 + `2${ 3 & 4 }` + 6;
var k4 = 1 + `${ 3 & 4 }5` + 6;
var l4 = 1 + `2${ 3 & 4 }5` + 6;
//// [templateStringBinaryOperationsES6.js]
var a = 1 + `${3}`;
var b = 1 + `2${3}`;
var c = 1 + `${3}4`;
var d = 1 + `2${3}4`;
var e = `${3}` + 5;
var f = `2${3}` + 5;
var g = `${3}4` + 5;
var h = `2${3}4` + 5;
var i = 1 + `${3}` + 5;
var j = 1 + `2${3}` + 5;
var k = 1 + `${3}4` + 5;
var l = 1 + `2${3}4` + 5;
var a2 = 1 + `${3 - 4}`;
var b2 = 1 + `2${3 - 4}`;
var c2 = 1 + `${3 - 4}5`;
var d2 = 1 + `2${3 - 4}5`;
var e2 = `${3 - 4}` + 6;
var f2 = `2${3 - 4}` + 6;
var g2 = `${3 - 4}5` + 6;
var h2 = `2${3 - 4}5` + 6;
var i2 = 1 + `${3 - 4}` + 6;
var j2 = 1 + `2${3 - 4}` + 6;
var k2 = 1 + `${3 - 4}5` + 6;
var l2 = 1 + `2${3 - 4}5` + 6;
var a3 = 1 + `${3 * 4}`;
var b3 = 1 + `2${3 * 4}`;
var c3 = 1 + `${3 * 4}5`;
var d3 = 1 + `2${3 * 4}5`;
var e3 = `${3 * 4}` + 6;
var f3 = `2${3 * 4}` + 6;
var g3 = `${3 * 4}5` + 6;
var h3 = `2${3 * 4}5` + 6;
var i3 = 1 + `${3 * 4}` + 6;
var j3 = 1 + `2${3 * 4}` + 6;
var k3 = 1 + `${3 * 4}5` + 6;
var l3 = 1 + `2${3 * 4}5` + 6;
var a4 = 1 + `${3 & 4}`;
var b4 = 1 + `2${3 & 4}`;
var c4 = 1 + `${3 & 4}5`;
var d4 = 1 + `2${3 & 4}5`;
var e4 = `${3 & 4}` + 6;
var f4 = `2${3 & 4}` + 6;
var g4 = `${3 & 4}5` + 6;
var h4 = `2${3 & 4}5` + 6;
var i4 = 1 + `${3 & 4}` + 6;
var j4 = 1 + `2${3 & 4}` + 6;
var k4 = 1 + `${3 & 4}5` + 6;
var l4 = 1 + `2${3 & 4}5` + 6;
@@ -0,0 +1,245 @@
=== tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6.ts ===
var a = 1 + `${ 3 }`;
>a : string
>1 + `${ 3 }` : string
var b = 1 + `2${ 3 }`;
>b : string
>1 + `2${ 3 }` : string
var c = 1 + `${ 3 }4`;
>c : string
>1 + `${ 3 }4` : string
var d = 1 + `2${ 3 }4`;
>d : string
>1 + `2${ 3 }4` : string
var e = `${ 3 }` + 5;
>e : string
>`${ 3 }` + 5 : string
var f = `2${ 3 }` + 5;
>f : string
>`2${ 3 }` + 5 : string
var g = `${ 3 }4` + 5;
>g : string
>`${ 3 }4` + 5 : string
var h = `2${ 3 }4` + 5;
>h : string
>`2${ 3 }4` + 5 : string
var i = 1 + `${ 3 }` + 5;
>i : string
>1 + `${ 3 }` + 5 : string
>1 + `${ 3 }` : string
var j = 1 + `2${ 3 }` + 5;
>j : string
>1 + `2${ 3 }` + 5 : string
>1 + `2${ 3 }` : string
var k = 1 + `${ 3 }4` + 5;
>k : string
>1 + `${ 3 }4` + 5 : string
>1 + `${ 3 }4` : string
var l = 1 + `2${ 3 }4` + 5;
>l : string
>1 + `2${ 3 }4` + 5 : string
>1 + `2${ 3 }4` : string
var a2 = 1 + `${ 3 - 4 }`;
>a2 : string
>1 + `${ 3 - 4 }` : string
>3 - 4 : number
var b2 = 1 + `2${ 3 - 4 }`;
>b2 : string
>1 + `2${ 3 - 4 }` : string
>3 - 4 : number
var c2 = 1 + `${ 3 - 4 }5`;
>c2 : string
>1 + `${ 3 - 4 }5` : string
>3 - 4 : number
var d2 = 1 + `2${ 3 - 4 }5`;
>d2 : string
>1 + `2${ 3 - 4 }5` : string
>3 - 4 : number
var e2 = `${ 3 - 4 }` + 6;
>e2 : string
>`${ 3 - 4 }` + 6 : string
>3 - 4 : number
var f2 = `2${ 3 - 4 }` + 6;
>f2 : string
>`2${ 3 - 4 }` + 6 : string
>3 - 4 : number
var g2 = `${ 3 - 4 }5` + 6;
>g2 : string
>`${ 3 - 4 }5` + 6 : string
>3 - 4 : number
var h2 = `2${ 3 - 4 }5` + 6;
>h2 : string
>`2${ 3 - 4 }5` + 6 : string
>3 - 4 : number
var i2 = 1 + `${ 3 - 4 }` + 6;
>i2 : string
>1 + `${ 3 - 4 }` + 6 : string
>1 + `${ 3 - 4 }` : string
>3 - 4 : number
var j2 = 1 + `2${ 3 - 4 }` + 6;
>j2 : string
>1 + `2${ 3 - 4 }` + 6 : string
>1 + `2${ 3 - 4 }` : string
>3 - 4 : number
var k2 = 1 + `${ 3 - 4 }5` + 6;
>k2 : string
>1 + `${ 3 - 4 }5` + 6 : string
>1 + `${ 3 - 4 }5` : string
>3 - 4 : number
var l2 = 1 + `2${ 3 - 4 }5` + 6;
>l2 : string
>1 + `2${ 3 - 4 }5` + 6 : string
>1 + `2${ 3 - 4 }5` : string
>3 - 4 : number
var a3 = 1 + `${ 3 * 4 }`;
>a3 : string
>1 + `${ 3 * 4 }` : string
>3 * 4 : number
var b3 = 1 + `2${ 3 * 4 }`;
>b3 : string
>1 + `2${ 3 * 4 }` : string
>3 * 4 : number
var c3 = 1 + `${ 3 * 4 }5`;
>c3 : string
>1 + `${ 3 * 4 }5` : string
>3 * 4 : number
var d3 = 1 + `2${ 3 * 4 }5`;
>d3 : string
>1 + `2${ 3 * 4 }5` : string
>3 * 4 : number
var e3 = `${ 3 * 4 }` + 6;
>e3 : string
>`${ 3 * 4 }` + 6 : string
>3 * 4 : number
var f3 = `2${ 3 * 4 }` + 6;
>f3 : string
>`2${ 3 * 4 }` + 6 : string
>3 * 4 : number
var g3 = `${ 3 * 4 }5` + 6;
>g3 : string
>`${ 3 * 4 }5` + 6 : string
>3 * 4 : number
var h3 = `2${ 3 * 4 }5` + 6;
>h3 : string
>`2${ 3 * 4 }5` + 6 : string
>3 * 4 : number
var i3 = 1 + `${ 3 * 4 }` + 6;
>i3 : string
>1 + `${ 3 * 4 }` + 6 : string
>1 + `${ 3 * 4 }` : string
>3 * 4 : number
var j3 = 1 + `2${ 3 * 4 }` + 6;
>j3 : string
>1 + `2${ 3 * 4 }` + 6 : string
>1 + `2${ 3 * 4 }` : string
>3 * 4 : number
var k3 = 1 + `${ 3 * 4 }5` + 6;
>k3 : string
>1 + `${ 3 * 4 }5` + 6 : string
>1 + `${ 3 * 4 }5` : string
>3 * 4 : number
var l3 = 1 + `2${ 3 * 4 }5` + 6;
>l3 : string
>1 + `2${ 3 * 4 }5` + 6 : string
>1 + `2${ 3 * 4 }5` : string
>3 * 4 : number
var a4 = 1 + `${ 3 & 4 }`;
>a4 : string
>1 + `${ 3 & 4 }` : string
>3 & 4 : number
var b4 = 1 + `2${ 3 & 4 }`;
>b4 : string
>1 + `2${ 3 & 4 }` : string
>3 & 4 : number
var c4 = 1 + `${ 3 & 4 }5`;
>c4 : string
>1 + `${ 3 & 4 }5` : string
>3 & 4 : number
var d4 = 1 + `2${ 3 & 4 }5`;
>d4 : string
>1 + `2${ 3 & 4 }5` : string
>3 & 4 : number
var e4 = `${ 3 & 4 }` + 6;
>e4 : string
>`${ 3 & 4 }` + 6 : string
>3 & 4 : number
var f4 = `2${ 3 & 4 }` + 6;
>f4 : string
>`2${ 3 & 4 }` + 6 : string
>3 & 4 : number
var g4 = `${ 3 & 4 }5` + 6;
>g4 : string
>`${ 3 & 4 }5` + 6 : string
>3 & 4 : number
var h4 = `2${ 3 & 4 }5` + 6;
>h4 : string
>`2${ 3 & 4 }5` + 6 : string
>3 & 4 : number
var i4 = 1 + `${ 3 & 4 }` + 6;
>i4 : string
>1 + `${ 3 & 4 }` + 6 : string
>1 + `${ 3 & 4 }` : string
>3 & 4 : number
var j4 = 1 + `2${ 3 & 4 }` + 6;
>j4 : string
>1 + `2${ 3 & 4 }` + 6 : string
>1 + `2${ 3 & 4 }` : string
>3 & 4 : number
var k4 = 1 + `${ 3 & 4 }5` + 6;
>k4 : string
>1 + `${ 3 & 4 }5` + 6 : string
>1 + `${ 3 & 4 }5` : string
>3 & 4 : number
var l4 = 1 + `2${ 3 & 4 }5` + 6;
>l4 : string
>1 + `2${ 3 & 4 }5` + 6 : string
>1 + `2${ 3 & 4 }5` : string
>3 & 4 : number
@@ -0,0 +1,399 @@
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(1,13): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(2,13): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(3,13): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(4,13): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(5,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(6,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(7,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(8,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(10,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(11,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(12,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(13,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(14,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(15,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(16,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(17,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(19,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(20,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(21,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(22,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(23,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(24,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(25,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(26,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(28,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(29,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(30,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(31,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(32,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(33,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(34,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(35,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(37,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(38,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(39,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(40,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(41,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(42,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(43,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(44,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(46,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(47,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(48,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(49,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(50,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(51,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(52,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(53,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(55,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(56,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(57,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(58,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(59,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(60,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(61,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(62,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(64,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(65,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(66,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(67,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(68,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(69,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(70,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(71,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(73,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(74,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(75,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(76,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(77,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(78,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(79,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(80,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(82,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(83,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(84,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(85,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(86,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(87,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(88,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(89,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(91,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(92,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(93,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(94,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(95,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(96,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(97,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(98,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(100,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(101,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(102,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(103,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(104,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(105,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(106,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts(107,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
==== tests/cases/conformance/es6/templates/templateStringBinaryOperationsES6Invalid.ts (96 errors) ====
var a = 1 - `${ 3 }`;
~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var b = 1 - `2${ 3 }`;
~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var c = 1 - `${ 3 }4`;
~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var d = 1 - `2${ 3 }4`;
~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var e = `${ 3 }` - 5;
~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var f = `2${ 3 }` - 5;
~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var g = `${ 3 }4` - 5;
~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var h = `2${ 3 }4` - 5;
~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var a2 = 1 * `${ 3 }`;
~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var b2 = 1 * `2${ 3 }`;
~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var c2 = 1 * `${ 3 }4`;
~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var d2 = 1 * `2${ 3 }4`;
~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var e2 = `${ 3 }` * 5;
~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var f2 = `2${ 3 }` * 5;
~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var g2 = `${ 3 }4` * 5;
~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var h2 = `2${ 3 }4` * 5;
~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var a3 = 1 & `${ 3 }`;
~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var b3 = 1 & `2${ 3 }`;
~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var c3 = 1 & `${ 3 }4`;
~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var d3 = 1 & `2${ 3 }4`;
~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var e3 = `${ 3 }` & 5;
~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var f3 = `2${ 3 }` & 5;
~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var g3 = `${ 3 }4` & 5;
~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var h3 = `2${ 3 }4` & 5;
~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var a4 = 1 - `${ 3 - 4 }`;
~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var b4 = 1 - `2${ 3 - 4 }`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var c4 = 1 - `${ 3 - 4 }5`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var d4 = 1 - `2${ 3 - 4 }5`;
~~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var e4 = `${ 3 - 4 }` - 6;
~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var f4 = `2${ 3 - 4 }` - 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var g4 = `${ 3 - 4 }5` - 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var h4 = `2${ 3 - 4 }5` - 6;
~~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var a5 = 1 - `${ 3 * 4 }`;
~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var b5 = 1 - `2${ 3 * 4 }`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var c5 = 1 - `${ 3 * 4 }5`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var d5 = 1 - `2${ 3 * 4 }5`;
~~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var e5 = `${ 3 * 4 }` - 6;
~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var f5 = `2${ 3 * 4 }` - 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var g5 = `${ 3 * 4 }5` - 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var h5 = `2${ 3 * 4 }5` - 6;
~~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var a6 = 1 - `${ 3 & 4 }`;
~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var b6 = 1 - `2${ 3 & 4 }`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var c6 = 1 - `${ 3 & 4 }5`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var d6 = 1 - `2${ 3 & 4 }5`;
~~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var e6 = `${ 3 & 4 }` - 6;
~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var f6 = `2${ 3 & 4 }` - 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var g6 = `${ 3 & 4 }5` - 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var h6 = `2${ 3 & 4 }5` - 6;
~~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var a7 = 1 * `${ 3 - 4 }`;
~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var b7 = 1 * `2${ 3 - 4 }`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var c7 = 1 * `${ 3 - 4 }5`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var d7 = 1 * `2${ 3 - 4 }5`;
~~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var e7 = `${ 3 - 4 }` * 6;
~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var f7 = `2${ 3 - 4 }` * 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var g7 = `${ 3 - 4 }5` * 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var h7 = `2${ 3 - 4 }5` * 6;
~~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var a8 = 1 * `${ 3 * 4 }`;
~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var b8 = 1 * `2${ 3 * 4 }`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var c8 = 1 * `${ 3 * 4 }5`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var d8 = 1 * `2${ 3 * 4 }5`;
~~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var e8 = `${ 3 * 4 }` * 6;
~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var f8 = `2${ 3 * 4 }` * 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var g8 = `${ 3 * 4 }5` * 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var h8 = `2${ 3 * 4 }5` * 6;
~~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var a9 = 1 * `${ 3 & 4 }`;
~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var b9 = 1 * `2${ 3 & 4 }`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var c9 = 1 * `${ 3 & 4 }5`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var d9 = 1 * `2${ 3 & 4 }5`;
~~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var e9 = `${ 3 & 4 }` * 6;
~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var f9 = `2${ 3 & 4 }` * 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var g9 = `${ 3 & 4 }5` * 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var h9 = `2${ 3 & 4 }5` * 6;
~~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var aa = 1 & `${ 3 - 4 }`;
~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var ba = 1 & `2${ 3 - 4 }`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var ca = 1 & `${ 3 - 4 }5`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var da = 1 & `2${ 3 - 4 }5`;
~~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var ea = `${ 3 - 4 }` & 6;
~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var fa = `2${ 3 - 4 }` & 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var ga = `${ 3 - 4 }5` & 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var ha = `2${ 3 - 4 }5` & 6;
~~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var ab = 1 & `${ 3 * 4 }`;
~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var bb = 1 & `2${ 3 * 4 }`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var cb = 1 & `${ 3 * 4 }5`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var db = 1 & `2${ 3 * 4 }5`;
~~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var eb = `${ 3 * 4 }` & 6;
~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var fb = `2${ 3 * 4 }` & 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var gb = `${ 3 * 4 }5` & 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var hb = `2${ 3 * 4 }5` & 6;
~~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var ac = 1 & `${ 3 & 4 }`;
~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var bc = 1 & `2${ 3 & 4 }`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var cc = 1 & `${ 3 & 4 }5`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var dc = 1 & `2${ 3 & 4 }5`;
~~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var ec = `${ 3 & 4 }` & 6;
~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var fc = `2${ 3 & 4 }` & 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var gc = `${ 3 & 4 }5` & 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var hc = `2${ 3 & 4 }5` & 6;
~~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
@@ -0,0 +1,207 @@
//// [templateStringBinaryOperationsES6Invalid.ts]
var a = 1 - `${ 3 }`;
var b = 1 - `2${ 3 }`;
var c = 1 - `${ 3 }4`;
var d = 1 - `2${ 3 }4`;
var e = `${ 3 }` - 5;
var f = `2${ 3 }` - 5;
var g = `${ 3 }4` - 5;
var h = `2${ 3 }4` - 5;
var a2 = 1 * `${ 3 }`;
var b2 = 1 * `2${ 3 }`;
var c2 = 1 * `${ 3 }4`;
var d2 = 1 * `2${ 3 }4`;
var e2 = `${ 3 }` * 5;
var f2 = `2${ 3 }` * 5;
var g2 = `${ 3 }4` * 5;
var h2 = `2${ 3 }4` * 5;
var a3 = 1 & `${ 3 }`;
var b3 = 1 & `2${ 3 }`;
var c3 = 1 & `${ 3 }4`;
var d3 = 1 & `2${ 3 }4`;
var e3 = `${ 3 }` & 5;
var f3 = `2${ 3 }` & 5;
var g3 = `${ 3 }4` & 5;
var h3 = `2${ 3 }4` & 5;
var a4 = 1 - `${ 3 - 4 }`;
var b4 = 1 - `2${ 3 - 4 }`;
var c4 = 1 - `${ 3 - 4 }5`;
var d4 = 1 - `2${ 3 - 4 }5`;
var e4 = `${ 3 - 4 }` - 6;
var f4 = `2${ 3 - 4 }` - 6;
var g4 = `${ 3 - 4 }5` - 6;
var h4 = `2${ 3 - 4 }5` - 6;
var a5 = 1 - `${ 3 * 4 }`;
var b5 = 1 - `2${ 3 * 4 }`;
var c5 = 1 - `${ 3 * 4 }5`;
var d5 = 1 - `2${ 3 * 4 }5`;
var e5 = `${ 3 * 4 }` - 6;
var f5 = `2${ 3 * 4 }` - 6;
var g5 = `${ 3 * 4 }5` - 6;
var h5 = `2${ 3 * 4 }5` - 6;
var a6 = 1 - `${ 3 & 4 }`;
var b6 = 1 - `2${ 3 & 4 }`;
var c6 = 1 - `${ 3 & 4 }5`;
var d6 = 1 - `2${ 3 & 4 }5`;
var e6 = `${ 3 & 4 }` - 6;
var f6 = `2${ 3 & 4 }` - 6;
var g6 = `${ 3 & 4 }5` - 6;
var h6 = `2${ 3 & 4 }5` - 6;
var a7 = 1 * `${ 3 - 4 }`;
var b7 = 1 * `2${ 3 - 4 }`;
var c7 = 1 * `${ 3 - 4 }5`;
var d7 = 1 * `2${ 3 - 4 }5`;
var e7 = `${ 3 - 4 }` * 6;
var f7 = `2${ 3 - 4 }` * 6;
var g7 = `${ 3 - 4 }5` * 6;
var h7 = `2${ 3 - 4 }5` * 6;
var a8 = 1 * `${ 3 * 4 }`;
var b8 = 1 * `2${ 3 * 4 }`;
var c8 = 1 * `${ 3 * 4 }5`;
var d8 = 1 * `2${ 3 * 4 }5`;
var e8 = `${ 3 * 4 }` * 6;
var f8 = `2${ 3 * 4 }` * 6;
var g8 = `${ 3 * 4 }5` * 6;
var h8 = `2${ 3 * 4 }5` * 6;
var a9 = 1 * `${ 3 & 4 }`;
var b9 = 1 * `2${ 3 & 4 }`;
var c9 = 1 * `${ 3 & 4 }5`;
var d9 = 1 * `2${ 3 & 4 }5`;
var e9 = `${ 3 & 4 }` * 6;
var f9 = `2${ 3 & 4 }` * 6;
var g9 = `${ 3 & 4 }5` * 6;
var h9 = `2${ 3 & 4 }5` * 6;
var aa = 1 & `${ 3 - 4 }`;
var ba = 1 & `2${ 3 - 4 }`;
var ca = 1 & `${ 3 - 4 }5`;
var da = 1 & `2${ 3 - 4 }5`;
var ea = `${ 3 - 4 }` & 6;
var fa = `2${ 3 - 4 }` & 6;
var ga = `${ 3 - 4 }5` & 6;
var ha = `2${ 3 - 4 }5` & 6;
var ab = 1 & `${ 3 * 4 }`;
var bb = 1 & `2${ 3 * 4 }`;
var cb = 1 & `${ 3 * 4 }5`;
var db = 1 & `2${ 3 * 4 }5`;
var eb = `${ 3 * 4 }` & 6;
var fb = `2${ 3 * 4 }` & 6;
var gb = `${ 3 * 4 }5` & 6;
var hb = `2${ 3 * 4 }5` & 6;
var ac = 1 & `${ 3 & 4 }`;
var bc = 1 & `2${ 3 & 4 }`;
var cc = 1 & `${ 3 & 4 }5`;
var dc = 1 & `2${ 3 & 4 }5`;
var ec = `${ 3 & 4 }` & 6;
var fc = `2${ 3 & 4 }` & 6;
var gc = `${ 3 & 4 }5` & 6;
var hc = `2${ 3 & 4 }5` & 6;
//// [templateStringBinaryOperationsES6Invalid.js]
var a = 1 - `${3}`;
var b = 1 - `2${3}`;
var c = 1 - `${3}4`;
var d = 1 - `2${3}4`;
var e = `${3}` - 5;
var f = `2${3}` - 5;
var g = `${3}4` - 5;
var h = `2${3}4` - 5;
var a2 = 1 * `${3}`;
var b2 = 1 * `2${3}`;
var c2 = 1 * `${3}4`;
var d2 = 1 * `2${3}4`;
var e2 = `${3}` * 5;
var f2 = `2${3}` * 5;
var g2 = `${3}4` * 5;
var h2 = `2${3}4` * 5;
var a3 = 1 & `${3}`;
var b3 = 1 & `2${3}`;
var c3 = 1 & `${3}4`;
var d3 = 1 & `2${3}4`;
var e3 = `${3}` & 5;
var f3 = `2${3}` & 5;
var g3 = `${3}4` & 5;
var h3 = `2${3}4` & 5;
var a4 = 1 - `${3 - 4}`;
var b4 = 1 - `2${3 - 4}`;
var c4 = 1 - `${3 - 4}5`;
var d4 = 1 - `2${3 - 4}5`;
var e4 = `${3 - 4}` - 6;
var f4 = `2${3 - 4}` - 6;
var g4 = `${3 - 4}5` - 6;
var h4 = `2${3 - 4}5` - 6;
var a5 = 1 - `${3 * 4}`;
var b5 = 1 - `2${3 * 4}`;
var c5 = 1 - `${3 * 4}5`;
var d5 = 1 - `2${3 * 4}5`;
var e5 = `${3 * 4}` - 6;
var f5 = `2${3 * 4}` - 6;
var g5 = `${3 * 4}5` - 6;
var h5 = `2${3 * 4}5` - 6;
var a6 = 1 - `${3 & 4}`;
var b6 = 1 - `2${3 & 4}`;
var c6 = 1 - `${3 & 4}5`;
var d6 = 1 - `2${3 & 4}5`;
var e6 = `${3 & 4}` - 6;
var f6 = `2${3 & 4}` - 6;
var g6 = `${3 & 4}5` - 6;
var h6 = `2${3 & 4}5` - 6;
var a7 = 1 * `${3 - 4}`;
var b7 = 1 * `2${3 - 4}`;
var c7 = 1 * `${3 - 4}5`;
var d7 = 1 * `2${3 - 4}5`;
var e7 = `${3 - 4}` * 6;
var f7 = `2${3 - 4}` * 6;
var g7 = `${3 - 4}5` * 6;
var h7 = `2${3 - 4}5` * 6;
var a8 = 1 * `${3 * 4}`;
var b8 = 1 * `2${3 * 4}`;
var c8 = 1 * `${3 * 4}5`;
var d8 = 1 * `2${3 * 4}5`;
var e8 = `${3 * 4}` * 6;
var f8 = `2${3 * 4}` * 6;
var g8 = `${3 * 4}5` * 6;
var h8 = `2${3 * 4}5` * 6;
var a9 = 1 * `${3 & 4}`;
var b9 = 1 * `2${3 & 4}`;
var c9 = 1 * `${3 & 4}5`;
var d9 = 1 * `2${3 & 4}5`;
var e9 = `${3 & 4}` * 6;
var f9 = `2${3 & 4}` * 6;
var g9 = `${3 & 4}5` * 6;
var h9 = `2${3 & 4}5` * 6;
var aa = 1 & `${3 - 4}`;
var ba = 1 & `2${3 - 4}`;
var ca = 1 & `${3 - 4}5`;
var da = 1 & `2${3 - 4}5`;
var ea = `${3 - 4}` & 6;
var fa = `2${3 - 4}` & 6;
var ga = `${3 - 4}5` & 6;
var ha = `2${3 - 4}5` & 6;
var ab = 1 & `${3 * 4}`;
var bb = 1 & `2${3 * 4}`;
var cb = 1 & `${3 * 4}5`;
var db = 1 & `2${3 * 4}5`;
var eb = `${3 * 4}` & 6;
var fb = `2${3 * 4}` & 6;
var gb = `${3 * 4}5` & 6;
var hb = `2${3 * 4}5` & 6;
var ac = 1 & `${3 & 4}`;
var bc = 1 & `2${3 & 4}`;
var cc = 1 & `${3 & 4}5`;
var dc = 1 & `2${3 & 4}5`;
var ec = `${3 & 4}` & 6;
var fc = `2${3 & 4}` & 6;
var gc = `${3 & 4}5` & 6;
var hc = `2${3 & 4}5` & 6;
@@ -0,0 +1,399 @@
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(1,13): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(2,13): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(3,13): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(4,13): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(5,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(6,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(7,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(8,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(10,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(11,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(12,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(13,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(14,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(15,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(16,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(17,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(19,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(20,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(21,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(22,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(23,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(24,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(25,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(26,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(28,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(29,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(30,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(31,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(32,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(33,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(34,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(35,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(37,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(38,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(39,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(40,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(41,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(42,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(43,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(44,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(46,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(47,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(48,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(49,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(50,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(51,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(52,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(53,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(55,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(56,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(57,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(58,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(59,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(60,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(61,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(62,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(64,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(65,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(66,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(67,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(68,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(69,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(70,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(71,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(73,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(74,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(75,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(76,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(77,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(78,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(79,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(80,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(82,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(83,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(84,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(85,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(86,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(87,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(88,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(89,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(91,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(92,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(93,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(94,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(95,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(96,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(97,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(98,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(100,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(101,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(102,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(103,14): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(104,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(105,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(106,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts(107,10): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
==== tests/cases/conformance/es6/templates/templateStringBinaryOperationsInvalid.ts (96 errors) ====
var a = 1 - `${ 3 }`;
~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var b = 1 - `2${ 3 }`;
~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var c = 1 - `${ 3 }4`;
~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var d = 1 - `2${ 3 }4`;
~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var e = `${ 3 }` - 5;
~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var f = `2${ 3 }` - 5;
~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var g = `${ 3 }4` - 5;
~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var h = `2${ 3 }4` - 5;
~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var a2 = 1 * `${ 3 }`;
~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var b2 = 1 * `2${ 3 }`;
~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var c2 = 1 * `${ 3 }4`;
~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var d2 = 1 * `2${ 3 }4`;
~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var e2 = `${ 3 }` * 5;
~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var f2 = `2${ 3 }` * 5;
~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var g2 = `${ 3 }4` * 5;
~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var h2 = `2${ 3 }4` * 5;
~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var a3 = 1 & `${ 3 }`;
~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var b3 = 1 & `2${ 3 }`;
~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var c3 = 1 & `${ 3 }4`;
~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var d3 = 1 & `2${ 3 }4`;
~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var e3 = `${ 3 }` & 5;
~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var f3 = `2${ 3 }` & 5;
~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var g3 = `${ 3 }4` & 5;
~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var h3 = `2${ 3 }4` & 5;
~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var a4 = 1 - `${ 3 - 4 }`;
~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var b4 = 1 - `2${ 3 - 4 }`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var c4 = 1 - `${ 3 - 4 }5`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var d4 = 1 - `2${ 3 - 4 }5`;
~~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var e4 = `${ 3 - 4 }` - 6;
~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var f4 = `2${ 3 - 4 }` - 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var g4 = `${ 3 - 4 }5` - 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var h4 = `2${ 3 - 4 }5` - 6;
~~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var a5 = 1 - `${ 3 * 4 }`;
~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var b5 = 1 - `2${ 3 * 4 }`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var c5 = 1 - `${ 3 * 4 }5`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var d5 = 1 - `2${ 3 * 4 }5`;
~~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var e5 = `${ 3 * 4 }` - 6;
~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var f5 = `2${ 3 * 4 }` - 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var g5 = `${ 3 * 4 }5` - 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var h5 = `2${ 3 * 4 }5` - 6;
~~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var a6 = 1 - `${ 3 & 4 }`;
~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var b6 = 1 - `2${ 3 & 4 }`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var c6 = 1 - `${ 3 & 4 }5`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var d6 = 1 - `2${ 3 & 4 }5`;
~~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var e6 = `${ 3 & 4 }` - 6;
~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var f6 = `2${ 3 & 4 }` - 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var g6 = `${ 3 & 4 }5` - 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var h6 = `2${ 3 & 4 }5` - 6;
~~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var a7 = 1 * `${ 3 - 4 }`;
~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var b7 = 1 * `2${ 3 - 4 }`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var c7 = 1 * `${ 3 - 4 }5`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var d7 = 1 * `2${ 3 - 4 }5`;
~~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var e7 = `${ 3 - 4 }` * 6;
~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var f7 = `2${ 3 - 4 }` * 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var g7 = `${ 3 - 4 }5` * 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var h7 = `2${ 3 - 4 }5` * 6;
~~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var a8 = 1 * `${ 3 * 4 }`;
~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var b8 = 1 * `2${ 3 * 4 }`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var c8 = 1 * `${ 3 * 4 }5`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var d8 = 1 * `2${ 3 * 4 }5`;
~~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var e8 = `${ 3 * 4 }` * 6;
~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var f8 = `2${ 3 * 4 }` * 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var g8 = `${ 3 * 4 }5` * 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var h8 = `2${ 3 * 4 }5` * 6;
~~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var a9 = 1 * `${ 3 & 4 }`;
~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var b9 = 1 * `2${ 3 & 4 }`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var c9 = 1 * `${ 3 & 4 }5`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var d9 = 1 * `2${ 3 & 4 }5`;
~~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var e9 = `${ 3 & 4 }` * 6;
~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var f9 = `2${ 3 & 4 }` * 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var g9 = `${ 3 & 4 }5` * 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var h9 = `2${ 3 & 4 }5` * 6;
~~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var aa = 1 & `${ 3 - 4 }`;
~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var ba = 1 & `2${ 3 - 4 }`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var ca = 1 & `${ 3 - 4 }5`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var da = 1 & `2${ 3 - 4 }5`;
~~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var ea = `${ 3 - 4 }` & 6;
~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var fa = `2${ 3 - 4 }` & 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var ga = `${ 3 - 4 }5` & 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var ha = `2${ 3 - 4 }5` & 6;
~~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var ab = 1 & `${ 3 * 4 }`;
~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var bb = 1 & `2${ 3 * 4 }`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var cb = 1 & `${ 3 * 4 }5`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var db = 1 & `2${ 3 * 4 }5`;
~~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var eb = `${ 3 * 4 }` & 6;
~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var fb = `2${ 3 * 4 }` & 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var gb = `${ 3 * 4 }5` & 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var hb = `2${ 3 * 4 }5` & 6;
~~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var ac = 1 & `${ 3 & 4 }`;
~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var bc = 1 & `2${ 3 & 4 }`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var cc = 1 & `${ 3 & 4 }5`;
~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var dc = 1 & `2${ 3 & 4 }5`;
~~~~~~~~~~~~~~
!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var ec = `${ 3 & 4 }` & 6;
~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var fc = `2${ 3 & 4 }` & 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var gc = `${ 3 & 4 }5` & 6;
~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
var hc = `2${ 3 & 4 }5` & 6;
~~~~~~~~~~~~~~
!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
@@ -0,0 +1,207 @@
//// [templateStringBinaryOperationsInvalid.ts]
var a = 1 - `${ 3 }`;
var b = 1 - `2${ 3 }`;
var c = 1 - `${ 3 }4`;
var d = 1 - `2${ 3 }4`;
var e = `${ 3 }` - 5;
var f = `2${ 3 }` - 5;
var g = `${ 3 }4` - 5;
var h = `2${ 3 }4` - 5;
var a2 = 1 * `${ 3 }`;
var b2 = 1 * `2${ 3 }`;
var c2 = 1 * `${ 3 }4`;
var d2 = 1 * `2${ 3 }4`;
var e2 = `${ 3 }` * 5;
var f2 = `2${ 3 }` * 5;
var g2 = `${ 3 }4` * 5;
var h2 = `2${ 3 }4` * 5;
var a3 = 1 & `${ 3 }`;
var b3 = 1 & `2${ 3 }`;
var c3 = 1 & `${ 3 }4`;
var d3 = 1 & `2${ 3 }4`;
var e3 = `${ 3 }` & 5;
var f3 = `2${ 3 }` & 5;
var g3 = `${ 3 }4` & 5;
var h3 = `2${ 3 }4` & 5;
var a4 = 1 - `${ 3 - 4 }`;
var b4 = 1 - `2${ 3 - 4 }`;
var c4 = 1 - `${ 3 - 4 }5`;
var d4 = 1 - `2${ 3 - 4 }5`;
var e4 = `${ 3 - 4 }` - 6;
var f4 = `2${ 3 - 4 }` - 6;
var g4 = `${ 3 - 4 }5` - 6;
var h4 = `2${ 3 - 4 }5` - 6;
var a5 = 1 - `${ 3 * 4 }`;
var b5 = 1 - `2${ 3 * 4 }`;
var c5 = 1 - `${ 3 * 4 }5`;
var d5 = 1 - `2${ 3 * 4 }5`;
var e5 = `${ 3 * 4 }` - 6;
var f5 = `2${ 3 * 4 }` - 6;
var g5 = `${ 3 * 4 }5` - 6;
var h5 = `2${ 3 * 4 }5` - 6;
var a6 = 1 - `${ 3 & 4 }`;
var b6 = 1 - `2${ 3 & 4 }`;
var c6 = 1 - `${ 3 & 4 }5`;
var d6 = 1 - `2${ 3 & 4 }5`;
var e6 = `${ 3 & 4 }` - 6;
var f6 = `2${ 3 & 4 }` - 6;
var g6 = `${ 3 & 4 }5` - 6;
var h6 = `2${ 3 & 4 }5` - 6;
var a7 = 1 * `${ 3 - 4 }`;
var b7 = 1 * `2${ 3 - 4 }`;
var c7 = 1 * `${ 3 - 4 }5`;
var d7 = 1 * `2${ 3 - 4 }5`;
var e7 = `${ 3 - 4 }` * 6;
var f7 = `2${ 3 - 4 }` * 6;
var g7 = `${ 3 - 4 }5` * 6;
var h7 = `2${ 3 - 4 }5` * 6;
var a8 = 1 * `${ 3 * 4 }`;
var b8 = 1 * `2${ 3 * 4 }`;
var c8 = 1 * `${ 3 * 4 }5`;
var d8 = 1 * `2${ 3 * 4 }5`;
var e8 = `${ 3 * 4 }` * 6;
var f8 = `2${ 3 * 4 }` * 6;
var g8 = `${ 3 * 4 }5` * 6;
var h8 = `2${ 3 * 4 }5` * 6;
var a9 = 1 * `${ 3 & 4 }`;
var b9 = 1 * `2${ 3 & 4 }`;
var c9 = 1 * `${ 3 & 4 }5`;
var d9 = 1 * `2${ 3 & 4 }5`;
var e9 = `${ 3 & 4 }` * 6;
var f9 = `2${ 3 & 4 }` * 6;
var g9 = `${ 3 & 4 }5` * 6;
var h9 = `2${ 3 & 4 }5` * 6;
var aa = 1 & `${ 3 - 4 }`;
var ba = 1 & `2${ 3 - 4 }`;
var ca = 1 & `${ 3 - 4 }5`;
var da = 1 & `2${ 3 - 4 }5`;
var ea = `${ 3 - 4 }` & 6;
var fa = `2${ 3 - 4 }` & 6;
var ga = `${ 3 - 4 }5` & 6;
var ha = `2${ 3 - 4 }5` & 6;
var ab = 1 & `${ 3 * 4 }`;
var bb = 1 & `2${ 3 * 4 }`;
var cb = 1 & `${ 3 * 4 }5`;
var db = 1 & `2${ 3 * 4 }5`;
var eb = `${ 3 * 4 }` & 6;
var fb = `2${ 3 * 4 }` & 6;
var gb = `${ 3 * 4 }5` & 6;
var hb = `2${ 3 * 4 }5` & 6;
var ac = 1 & `${ 3 & 4 }`;
var bc = 1 & `2${ 3 & 4 }`;
var cc = 1 & `${ 3 & 4 }5`;
var dc = 1 & `2${ 3 & 4 }5`;
var ec = `${ 3 & 4 }` & 6;
var fc = `2${ 3 & 4 }` & 6;
var gc = `${ 3 & 4 }5` & 6;
var hc = `2${ 3 & 4 }5` & 6;
//// [templateStringBinaryOperationsInvalid.js]
var a = 1 - ("" + 3);
var b = 1 - ("2" + 3);
var c = 1 - (3 + "4");
var d = 1 - ("2" + 3 + "4");
var e = ("" + 3) - 5;
var f = ("2" + 3) - 5;
var g = (3 + "4") - 5;
var h = ("2" + 3 + "4") - 5;
var a2 = 1 * ("" + 3);
var b2 = 1 * ("2" + 3);
var c2 = 1 * (3 + "4");
var d2 = 1 * ("2" + 3 + "4");
var e2 = ("" + 3) * 5;
var f2 = ("2" + 3) * 5;
var g2 = (3 + "4") * 5;
var h2 = ("2" + 3 + "4") * 5;
var a3 = 1 & "" + 3;
var b3 = 1 & "2" + 3;
var c3 = 1 & 3 + "4";
var d3 = 1 & "2" + 3 + "4";
var e3 = "" + 3 & 5;
var f3 = "2" + 3 & 5;
var g3 = 3 + "4" & 5;
var h3 = "2" + 3 + "4" & 5;
var a4 = 1 - ("" + (3 - 4));
var b4 = 1 - ("2" + (3 - 4));
var c4 = 1 - ((3 - 4) + "5");
var d4 = 1 - ("2" + (3 - 4) + "5");
var e4 = ("" + (3 - 4)) - 6;
var f4 = ("2" + (3 - 4)) - 6;
var g4 = ((3 - 4) + "5") - 6;
var h4 = ("2" + (3 - 4) + "5") - 6;
var a5 = 1 - ("" + 3 * 4);
var b5 = 1 - ("2" + 3 * 4);
var c5 = 1 - (3 * 4 + "5");
var d5 = 1 - ("2" + 3 * 4 + "5");
var e5 = ("" + 3 * 4) - 6;
var f5 = ("2" + 3 * 4) - 6;
var g5 = (3 * 4 + "5") - 6;
var h5 = ("2" + 3 * 4 + "5") - 6;
var a6 = 1 - ("" + (3 & 4));
var b6 = 1 - ("2" + (3 & 4));
var c6 = 1 - ((3 & 4) + "5");
var d6 = 1 - ("2" + (3 & 4) + "5");
var e6 = ("" + (3 & 4)) - 6;
var f6 = ("2" + (3 & 4)) - 6;
var g6 = ((3 & 4) + "5") - 6;
var h6 = ("2" + (3 & 4) + "5") - 6;
var a7 = 1 * ("" + (3 - 4));
var b7 = 1 * ("2" + (3 - 4));
var c7 = 1 * ((3 - 4) + "5");
var d7 = 1 * ("2" + (3 - 4) + "5");
var e7 = ("" + (3 - 4)) * 6;
var f7 = ("2" + (3 - 4)) * 6;
var g7 = ((3 - 4) + "5") * 6;
var h7 = ("2" + (3 - 4) + "5") * 6;
var a8 = 1 * ("" + 3 * 4);
var b8 = 1 * ("2" + 3 * 4);
var c8 = 1 * (3 * 4 + "5");
var d8 = 1 * ("2" + 3 * 4 + "5");
var e8 = ("" + 3 * 4) * 6;
var f8 = ("2" + 3 * 4) * 6;
var g8 = (3 * 4 + "5") * 6;
var h8 = ("2" + 3 * 4 + "5") * 6;
var a9 = 1 * ("" + (3 & 4));
var b9 = 1 * ("2" + (3 & 4));
var c9 = 1 * ((3 & 4) + "5");
var d9 = 1 * ("2" + (3 & 4) + "5");
var e9 = ("" + (3 & 4)) * 6;
var f9 = ("2" + (3 & 4)) * 6;
var g9 = ((3 & 4) + "5") * 6;
var h9 = ("2" + (3 & 4) + "5") * 6;
var aa = 1 & "" + (3 - 4);
var ba = 1 & "2" + (3 - 4);
var ca = 1 & (3 - 4) + "5";
var da = 1 & "2" + (3 - 4) + "5";
var ea = "" + (3 - 4) & 6;
var fa = "2" + (3 - 4) & 6;
var ga = (3 - 4) + "5" & 6;
var ha = "2" + (3 - 4) + "5" & 6;
var ab = 1 & "" + 3 * 4;
var bb = 1 & "2" + 3 * 4;
var cb = 1 & 3 * 4 + "5";
var db = 1 & "2" + 3 * 4 + "5";
var eb = "" + 3 * 4 & 6;
var fb = "2" + 3 * 4 & 6;
var gb = 3 * 4 + "5" & 6;
var hb = "2" + 3 * 4 + "5" & 6;
var ac = 1 & "" + (3 & 4);
var bc = 1 & "2" + (3 & 4);
var cc = 1 & (3 & 4) + "5";
var dc = 1 & "2" + (3 & 4) + "5";
var ec = "" + (3 & 4) & 6;
var fc = "2" + (3 & 4) & 6;
var gc = (3 & 4) + "5" & 6;
var hc = "2" + (3 & 4) + "5" & 6;
@@ -1,5 +0,0 @@
//// [templateStringInBinaryAddition.ts]
var x = 10 + `abc${ 10 }def`;
//// [templateStringInBinaryAddition.js]
var x = 10 + ("abc" + 10 + "def");
@@ -1,5 +0,0 @@
=== tests/cases/conformance/es6/templates/templateStringInBinaryAddition.ts ===
var x = 10 + `abc${ 10 }def`;
>x : string
>10 + `abc${ 10 }def` : string
@@ -1,5 +0,0 @@
//// [templateStringInBinaryAdditionES6.ts]
var x = 10 + `abc${ 10 }def`;
//// [templateStringInBinaryAdditionES6.js]
var x = 10 + `abc${10}def`;
@@ -1,5 +0,0 @@
=== tests/cases/conformance/es6/templates/templateStringInBinaryAdditionES6.ts ===
var x = 10 + `abc${ 10 }def`;
>x : string
>10 + `abc${ 10 }def` : string
@@ -21,18 +21,22 @@ var j = `${ 0 }${ 0 }3`;
var k = `1${ 0 }${ 0 }3`;
var l = `1${ 0 }2${ 0 }3`;
var l = `${ 0 }2${ 0 }3`;
var m = `1${ 0 }2${ 0 }3`;
//// [templateStringWithEmptyLiteralPortions.js]
var a = "";
var b = "" + 0;
var c = "1" + 0;
var d = "" + 0 + "2";
var d = 0 + "2";
var e = "1" + 0 + "2";
var f = "" + 0 + 0;
var g = "1" + 0 + 0;
var h = "" + 0 + "2" + 0;
var h = 0 + "2" + 0;
var i = "1" + 0 + "2" + 0;
var j = "" + 0 + 0 + "3";
var k = "1" + 0 + 0 + "3";
var l = "1" + 0 + "2" + 0 + "3";
var l = 0 + "2" + 0 + "3";
var m = "1" + 0 + "2" + 0 + "3";
@@ -32,6 +32,9 @@ var j = `${ 0 }${ 0 }3`;
var k = `1${ 0 }${ 0 }3`;
>k : string
var l = `1${ 0 }2${ 0 }3`;
var l = `${ 0 }2${ 0 }3`;
>l : string
var m = `1${ 0 }2${ 0 }3`;
>m : string
@@ -21,7 +21,10 @@ var j = `${ 0 }${ 0 }3`;
var k = `1${ 0 }${ 0 }3`;
var l = `1${ 0 }2${ 0 }3`;
var l = `${ 0 }2${ 0 }3`;
var m = `1${ 0 }2${ 0 }3`;
//// [templateStringWithEmptyLiteralPortionsES6.js]
var a = ``;
@@ -35,4 +38,5 @@ var h = `${0}2${0}`;
var i = `1${0}2${0}`;
var j = `${0}${0}3`;
var k = `1${0}${0}3`;
var l = `1${0}2${0}3`;
var l = `${0}2${0}3`;
var m = `1${0}2${0}3`;
@@ -32,6 +32,9 @@ var j = `${ 0 }${ 0 }3`;
var k = `1${ 0 }${ 0 }3`;
>k : string
var l = `1${ 0 }2${ 0 }3`;
var l = `${ 0 }2${ 0 }3`;
>l : string
var m = `1${ 0 }2${ 0 }3`;
>m : string
@@ -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";
}}`;
@@ -124,9 +124,9 @@ var r2: D1 | C2 = c2Ord1 instanceof C1 && c2Ord1; // C2 | D1
>r2 : C2 | D1
>D1 : D1
>C2 : C2
>c2Ord1 instanceof C1 && c2Ord1 : C2 | D1
>c2Ord1 instanceof C1 && c2Ord1 : D1
>c2Ord1 instanceof C1 : boolean
>c2Ord1 : C2 | D1
>C1 : typeof C1
>c2Ord1 : C2 | D1
>c2Ord1 : D1
@@ -154,9 +154,9 @@ var r2: D1 | C2 = c2Ord1 instanceof c1 && c2Ord1; // C2 | D1
>r2 : C2 | D1
>D1 : D1
>C2 : C2
>c2Ord1 instanceof c1 && c2Ord1 : C2 | D1
>c2Ord1 instanceof c1 && c2Ord1 : D1
>c2Ord1 instanceof c1 : boolean
>c2Ord1 : C2 | D1
>c1 : C1
>c2Ord1 : C2 | D1
>c2Ord1 : D1
@@ -0,0 +1,49 @@
tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts(11,7): error TS2339: Property 'p' does not exist on type 'string'.
tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts(18,7): error TS2339: Property 'p' does not exist on type 'number'.
tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts(25,7): error TS2339: Property 'p' does not exist on type 'boolean'.
==== tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts (3 errors) ====
var x: any = { p: 0 };
if (x instanceof Object) {
x.p; // No error, type any unaffected by instanceof type guard
}
else {
x.p; // No error, type any unaffected by instanceof type guard
}
if (typeof x === "string") {
x.p; // Error, type any narrowed by primitive type check
~
!!! error TS2339: Property 'p' does not exist on type 'string'.
}
else {
x.p; // No error, type unaffected in this branch
}
if (typeof x === "number") {
x.p; // Error, type any narrowed by primitive type check
~
!!! error TS2339: Property 'p' does not exist on type 'number'.
}
else {
x.p; // No error, type unaffected in this branch
}
if (typeof x === "boolean") {
x.p; // Error, type any narrowed by primitive type check
~
!!! error TS2339: Property 'p' does not exist on type 'boolean'.
}
else {
x.p; // No error, type unaffected in this branch
}
if (typeof x === "object") {
x.p; // No error, type any only affected by primitive type check
}
else {
x.p; // No error, type unaffected in this branch
}
+57 -4
View File
@@ -1,18 +1,71 @@
//// [typeGuardsWithAny.ts]
var x: any = { p: 0 };
if (x instanceof Object) {
x.p; // No error, type any unaffected by type guard
x.p; // No error, type any unaffected by instanceof type guard
}
else {
x.p; // No error, type any unaffected by type guard
x.p; // No error, type any unaffected by instanceof type guard
}
if (typeof x === "string") {
x.p; // Error, type any narrowed by primitive type check
}
else {
x.p; // No error, type unaffected in this branch
}
if (typeof x === "number") {
x.p; // Error, type any narrowed by primitive type check
}
else {
x.p; // No error, type unaffected in this branch
}
if (typeof x === "boolean") {
x.p; // Error, type any narrowed by primitive type check
}
else {
x.p; // No error, type unaffected in this branch
}
if (typeof x === "object") {
x.p; // No error, type any only affected by primitive type check
}
else {
x.p; // No error, type unaffected in this branch
}
//// [typeGuardsWithAny.js]
var x = { p: 0 };
if (x instanceof Object) {
x.p; // No error, type any unaffected by type guard
x.p; // No error, type any unaffected by instanceof type guard
}
else {
x.p; // No error, type any unaffected by type guard
x.p; // No error, type any unaffected by instanceof type guard
}
if (typeof x === "string") {
x.p; // Error, type any narrowed by primitive type check
}
else {
x.p; // No error, type unaffected in this branch
}
if (typeof x === "number") {
x.p; // Error, type any narrowed by primitive type check
}
else {
x.p; // No error, type unaffected in this branch
}
if (typeof x === "boolean") {
x.p; // Error, type any narrowed by primitive type check
}
else {
x.p; // No error, type unaffected in this branch
}
if (typeof x === "object") {
x.p; // No error, type any only affected by primitive type check
}
else {
x.p; // No error, type unaffected in this branch
}
@@ -1,23 +0,0 @@
=== tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts ===
var x: any = { p: 0 };
>x : any
>{ p: 0 } : { p: number; }
>p : number
if (x instanceof Object) {
>x instanceof Object : boolean
>x : any
>Object : ObjectConstructor
x.p; // No error, type any unaffected by type guard
>x.p : any
>x : any
>p : any
}
else {
x.p; // No error, type any unaffected by type guard
>x.p : any
>x : any
>p : any
}

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