diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 83cc54e1acc90..9f612e11673b6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -427,7 +427,7 @@ module ts { if (result.flags & SymbolFlags.BlockScopedVariable) { // Block-scoped variables cannot be used before their definition var declaration = forEach(result.declarations, d => d.flags & NodeFlags.BlockScoped ? d : undefined); - Debug.assert(declaration, "Block-scoped variable declaration is undefined"); + Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); var declarationSourceFile = getSourceFileOfNode(declaration); var referenceSourceFile = getSourceFileOfNode(errorLocation); if (declarationSourceFile === referenceSourceFile) { @@ -472,7 +472,7 @@ module ts { function getSymbolOfPartOfRightHandSideOfImport(entityName: EntityName, importDeclaration?: ImportDeclaration): Symbol { if (!importDeclaration) { importDeclaration = getAncestor(entityName, SyntaxKind.ImportDeclaration); - Debug.assert(importDeclaration); + Debug.assert(importDeclaration !== undefined); } // There are three things we might try to look for. In the following examples, // the search term is enclosed in |...|: @@ -3334,7 +3334,6 @@ module ts { } if (reportErrors) { headMessage = headMessage || Diagnostics.Type_0_is_not_assignable_to_type_1; - Debug.assert(headMessage); reportError(headMessage, typeToString(source), typeToString(target)); } return Ternary.False; @@ -4912,7 +4911,7 @@ module ts { } return createArrayType(getUnionType(elementTypes)); } - + function isNumericName(name: string) { // The intent of numeric names is that // - they are names with text in a numeric form, and that @@ -4937,7 +4936,7 @@ module ts { // with the strings '"Infinity"', '"-Infinity"', and '"NaN"' respectively. return (+name).toString() === name; } - + function checkObjectLiteral(node: ObjectLiteral, contextualMapper?: TypeMapper): Type { var members = node.symbol.members; var properties: SymbolTable = {}; @@ -5660,6 +5659,13 @@ module ts { return getReturnTypeOfSignature(signature); } + function checkTaggedTemplateExpression(node: TaggedTemplateExpression): Type { + // TODO (drosen): Make sure substitutions are assignable to the tag's arguments. + checkExpression(node.tag); + checkExpression(node.template); + return anyType; + } + function checkTypeAssertion(node: TypeAssertion): Type { var exprType = checkExpression(node.operand); var targetType = getTypeFromTypeNode(node.type); @@ -6170,6 +6176,19 @@ module ts { return getUnionType([type1, type2]); } + function checkTemplateExpression(node: TemplateExpression): Type { + // We just want to check each expressions, but we are unconcerned with + // the type of each expression, as any value may be coerced into a string. + // It is worth asking whether this is what we really want though. + // A place where we actually *are* concerned with the expressions' types are + // in tagged templates. + forEach((node).templateSpans, templateSpan => { + checkExpression(templateSpan.expression); + }); + + return stringType; + } + function checkExpressionWithContextualType(node: Expression, contextualType: Type, contextualMapper?: TypeMapper): Type { var saveContextualType = node.contextualType; node.contextualType = contextualType; @@ -6223,7 +6242,10 @@ module ts { return booleanType; case SyntaxKind.NumericLiteral: return numberType; + case SyntaxKind.TemplateExpression: + return checkTemplateExpression(node); case SyntaxKind.StringLiteral: + case SyntaxKind.NoSubstitutionTemplateLiteral: return stringType; case SyntaxKind.RegularExpressionLiteral: return globalRegExpType; @@ -6240,6 +6262,8 @@ module ts { case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: return checkCallExpression(node); + case SyntaxKind.TaggedTemplateExpression: + return checkTaggedTemplateExpression(node); case SyntaxKind.TypeAssertion: return checkTypeAssertion(node); case SyntaxKind.ParenExpression: @@ -7549,17 +7573,17 @@ module ts { errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - Debug.assert(derived.flags & SymbolFlags.Property); + Debug.assert((derived.flags & SymbolFlags.Property) !== 0); errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; } } else if (base.flags & SymbolFlags.Property) { - Debug.assert(derived.flags & SymbolFlags.Method); + Debug.assert((derived.flags & SymbolFlags.Method) !== 0); errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; } else { - Debug.assert(base.flags & SymbolFlags.Accessor); - Debug.assert(derived.flags & SymbolFlags.Method); + Debug.assert((base.flags & SymbolFlags.Accessor) !== 0); + Debug.assert((derived.flags & SymbolFlags.Method) !== 0); errorMessage = Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; } @@ -8016,6 +8040,7 @@ module ts { case SyntaxKind.IndexedAccess: case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: + case SyntaxKind.TaggedTemplateExpression: case SyntaxKind.TypeAssertion: case SyntaxKind.ParenExpression: case SyntaxKind.PrefixOperator: @@ -8293,6 +8318,9 @@ module ts { case SyntaxKind.CallExpression: case SyntaxKind.NewExpression: return (parent).typeArguments && (parent).typeArguments.indexOf(node) >= 0; + case SyntaxKind.TaggedTemplateExpression: + // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. + return false; } } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index b233d3575b313..6fd07fe4a6a89 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -19,6 +19,12 @@ module ts { [index: string]: T; } + export enum Comparison { + LessThan = -1, + EqualTo = 0, + GreaterThan = 1 + } + export interface StringSet extends Map { } export function forEach(array: T[], callback: (element: T) => U): U { @@ -93,6 +99,7 @@ module ts { export function concatenate(array1: T[], array2: T[]): T[] { if (!array2 || !array2.length) return array1; if (!array1 || !array1.length) return array2; + return array1.concat(array2); } @@ -326,11 +333,11 @@ module ts { }; } - export function compareValues(a: T, b: T): number { - if (a === b) return 0; - if (a === undefined) return -1; - if (b === undefined) return 1; - return a < b ? -1 : 1; + export function compareValues(a: T, b: T): Comparison { + if (a === b) return Comparison.EqualTo; + if (a === undefined) return Comparison.LessThan; + if (b === undefined) return Comparison.GreaterThan; + return a < b ? Comparison.LessThan : Comparison.GreaterThan; } function getDiagnosticFilename(diagnostic: Diagnostic): string { @@ -355,7 +362,7 @@ module ts { var previousDiagnostic = diagnostics[0]; for (var i = 1; i < diagnostics.length; i++) { var currentDiagnostic = diagnostics[i]; - var isDupe = compareDiagnostics(currentDiagnostic, previousDiagnostic) === 0; + var isDupe = compareDiagnostics(currentDiagnostic, previousDiagnostic) === Comparison.EqualTo; if (!isDupe) { newDiagnostics.push(currentDiagnostic); previousDiagnostic = currentDiagnostic; @@ -644,7 +651,7 @@ module ts { return currentAssertionLevel >= level; } - export function assert(expression: any, message?: string, verboseDebugInfo?: () => string): void { + export function assert(expression: boolean, message?: string, verboseDebugInfo?: () => string): void { if (!expression) { var verboseDebugString = ""; if (verboseDebugInfo) { diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 82567f70ca6f0..7ab19bd5074e7 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -121,6 +121,8 @@ module ts { const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block." }, let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block." }, Aliased_type_cannot_be_an_object_type_literal_Use_an_interface_declaration_instead: { code: 1158, category: DiagnosticCategory.Error, key: "Aliased type cannot be an object type literal. Use an interface declaration instead." }, + Invalid_template_literal_expected: { code: 1159, category: DiagnosticCategory.Error, key: "Invalid template literal; expected '}'" }, + Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1160, category: DiagnosticCategory.Error, key: "Tagged templates are only available when targeting ECMAScript 6 and higher." }, 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." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 72d7c79a024fe..3e380ea5a67ae 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -475,6 +475,14 @@ "category": "Error", "code": 1158 }, + "Invalid template literal; expected '}'": { + "category": "Error", + "code": 1159 + }, + "Tagged templates are only available when targeting ECMAScript 6 and higher.": { + "category": "Error", + "code": 1160 + }, "Duplicate identifier '{0}'.": { "category": "Error", diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index bc27520d87c71..782d22a0bf462 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -786,14 +786,123 @@ module ts { } } - function emitLiteral(node: LiteralExpression) { - var text = getSourceTextOfLocalNode(node); - if (node.kind === SyntaxKind.StringLiteral && compilerOptions.sourceMap) { + function emitLiteral(node: LiteralExpression): void { + var text = getLiteralText(); + + if (compilerOptions.sourceMap && (node.kind === SyntaxKind.StringLiteral || isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } else { write(text); } + + function getLiteralText() { + if (compilerOptions.target < ScriptTarget.ES6 && isTemplateLiteralKind(node.kind)) { + return getTemplateLiteralAsStringLiteral(node) + } + + return getSourceTextOfLocalNode(node); + } + } + + function getTemplateLiteralAsStringLiteral(node: LiteralExpression): string { + return '"' + escapeString(node.text) + '"'; + } + + function emitTemplateExpression(node: TemplateExpression): void { + // In ES6 mode and above, we can simply emit each portion of a template in order, but in + // ES3 & ES5 we must convert the template expression into a series of string concatenations. + if (compilerOptions.target >= ScriptTarget.ES6) { + forEachChild(node, emit); + return; + } + + Debug.assert(node.parent.kind !== SyntaxKind.TaggedTemplateExpression); + + var templateNeedsParens = isExpression(node.parent) + && node.parent.kind !== SyntaxKind.ParenExpression + && comparePrecedenceToBinaryPlus(node.parent) !== Comparison.LessThan; + + if (templateNeedsParens) { + write("("); + } + + emitLiteral(node.head); + + 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}` + // becomes + // "abc" + 1 << 2 + "" + // which is really + // ("abc" + 1) << (2 + "") + // rather than + // "abc" + (1 << 2) + "" + var needsParens = templateSpan.expression.kind !== SyntaxKind.ParenExpression + && comparePrecedenceToBinaryPlus(templateSpan.expression) !== Comparison.GreaterThan; + + write(" + "); + + if (needsParens) { + write("("); + } + emit(templateSpan.expression); + if (needsParens) { + write(")"); + } + + // Only emit if the literal is non-empty. + // The binary '+' operator is left-associative, so the first string concatenation will force + // the result up to this point to be a string. Emitting a '+ ""' has no semantic effect. + if (templateSpan.literal.text.length !== 0) { + write(" + ") + emitLiteral(templateSpan.literal); + } + }); + + if (templateNeedsParens) { + write(")"); + } + + /** + * Returns whether the expression has lesser, greater, + * or equal precedence to the binary '+' operator + */ + function comparePrecedenceToBinaryPlus(expression: Expression): Comparison { + // All binary expressions have lower precedence than '+' apart from '*', '/', and '%'. + // 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, + // and in ES6 mode this function won't get called anyway. + // + // TODO (drosen): Note that we need to account for the upcoming 'yield' and + // spread ('...') unary operators that are anticipated for ES6. + Debug.assert(compilerOptions.target <= ScriptTarget.ES5); + switch (expression.kind) { + case SyntaxKind.BinaryExpression: + switch ((expression).operator) { + case SyntaxKind.AsteriskToken: + case SyntaxKind.SlashToken: + case SyntaxKind.PercentToken: + return Comparison.GreaterThan; + case SyntaxKind.PlusToken: + return Comparison.EqualTo; + default: + return Comparison.LessThan; + } + case SyntaxKind.ConditionalExpression: + return Comparison.LessThan; + default: + return Comparison.GreaterThan; + } + } + + } + + function emitTemplateSpan(span: TemplateSpan) { + emit(span.expression); + emit(span.literal); } // This function specifically handles numeric/string literals for enum and accessor 'identifiers'. @@ -977,6 +1086,13 @@ module ts { } } + function emitTaggedTemplateExpression(node: TaggedTemplateExpression): void { + Debug.assert(compilerOptions.target >= ScriptTarget.ES6, "Trying to emit a tagged template in pre-ES6 mode."); + emit(node.tag); + write(" "); + emit(node.template); + } + function emitParenExpression(node: ParenExpression) { if (node.expression.kind === SyntaxKind.TypeAssertion) { var operand = (node.expression).operand; @@ -2085,7 +2201,15 @@ module ts { case SyntaxKind.NumericLiteral: case SyntaxKind.StringLiteral: case SyntaxKind.RegularExpressionLiteral: + case SyntaxKind.NoSubstitutionTemplateLiteral: + case SyntaxKind.TemplateHead: + case SyntaxKind.TemplateMiddle: + case SyntaxKind.TemplateTail: return emitLiteral(node); + case SyntaxKind.TemplateExpression: + return emitTemplateExpression(node); + case SyntaxKind.TemplateSpan: + return emitTemplateSpan(node); case SyntaxKind.QualifiedName: return emitPropertyAccess(node); case SyntaxKind.ArrayLiteral: @@ -2102,6 +2226,8 @@ module ts { return emitCallExpression(node); case SyntaxKind.NewExpression: return emitNewExpression(node); + case SyntaxKind.TaggedTemplateExpression: + return emitTaggedTemplateExpression(node); case SyntaxKind.TypeAssertion: return emit((node).operand); case SyntaxKind.ParenExpression: diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 6c2207a08d22d..0c5af3660a2ae 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -67,77 +67,6 @@ module ts { return identifier.kind === SyntaxKind.Missing ? "(Missing)" : getTextOfNode(identifier); } - export function isExpression(node: Node): boolean { - switch (node.kind) { - case SyntaxKind.ThisKeyword: - case SyntaxKind.SuperKeyword: - case SyntaxKind.NullKeyword: - case SyntaxKind.TrueKeyword: - case SyntaxKind.FalseKeyword: - case SyntaxKind.RegularExpressionLiteral: - case SyntaxKind.ArrayLiteral: - case SyntaxKind.ObjectLiteral: - case SyntaxKind.PropertyAccess: - case SyntaxKind.IndexedAccess: - case SyntaxKind.CallExpression: - case SyntaxKind.NewExpression: - case SyntaxKind.TypeAssertion: - case SyntaxKind.ParenExpression: - case SyntaxKind.FunctionExpression: - case SyntaxKind.ArrowFunction: - case SyntaxKind.PrefixOperator: - case SyntaxKind.PostfixOperator: - case SyntaxKind.BinaryExpression: - case SyntaxKind.ConditionalExpression: - case SyntaxKind.OmittedExpression: - return true; - case SyntaxKind.QualifiedName: - while (node.parent.kind === SyntaxKind.QualifiedName) node = node.parent; - return node.parent.kind === SyntaxKind.TypeQuery; - case SyntaxKind.Identifier: - if (node.parent.kind === SyntaxKind.TypeQuery) { - return true; - } - // Fall through - case SyntaxKind.NumericLiteral: - case SyntaxKind.StringLiteral: - var parent = node.parent; - switch (parent.kind) { - case SyntaxKind.VariableDeclaration: - case SyntaxKind.Parameter: - case SyntaxKind.Property: - case SyntaxKind.EnumMember: - case SyntaxKind.PropertyAssignment: - return (parent).initializer === node; - case SyntaxKind.ExpressionStatement: - case SyntaxKind.IfStatement: - case SyntaxKind.DoStatement: - case SyntaxKind.WhileStatement: - case SyntaxKind.ReturnStatement: - case SyntaxKind.WithStatement: - case SyntaxKind.SwitchStatement: - case SyntaxKind.CaseClause: - case SyntaxKind.ThrowStatement: - case SyntaxKind.SwitchStatement: - return (parent).expression === node; - case SyntaxKind.ForStatement: - return (parent).initializer === node || - (parent).condition === node || - (parent).iterator === node; - case SyntaxKind.ForInStatement: - return (parent).variable === node || - (parent).expression === node; - case SyntaxKind.TypeAssertion: - return node === (parent).operand; - default: - if (isExpression(parent)) { - return true; - } - } - } - return false; - } - export function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): Diagnostic { node = getErrorSpanForNode(node); var file = getSourceFileOfNode(node); @@ -315,6 +244,9 @@ module ts { return child((node).func) || children((node).typeArguments) || children((node).arguments); + case SyntaxKind.TaggedTemplateExpression: + return child((node).tag) || + child((node).template); case SyntaxKind.TypeAssertion: return child((node).type) || child((node).operand); @@ -422,6 +354,10 @@ module ts { child((node).externalModuleName); case SyntaxKind.ExportAssignment: return child((node).exportName); + case SyntaxKind.TemplateExpression: + return child((node).head) || children((node).templateSpans); + case SyntaxKind.TemplateSpan: + return child((node).expression) || child((node).literal); } } @@ -526,10 +462,96 @@ module ts { } } + export function isExpression(node: Node): boolean { + switch (node.kind) { + case SyntaxKind.ThisKeyword: + case SyntaxKind.SuperKeyword: + case SyntaxKind.NullKeyword: + case SyntaxKind.TrueKeyword: + case SyntaxKind.FalseKeyword: + case SyntaxKind.RegularExpressionLiteral: + case SyntaxKind.ArrayLiteral: + case SyntaxKind.ObjectLiteral: + case SyntaxKind.PropertyAccess: + case SyntaxKind.IndexedAccess: + case SyntaxKind.CallExpression: + case SyntaxKind.NewExpression: + case SyntaxKind.TaggedTemplateExpression: + case SyntaxKind.TypeAssertion: + case SyntaxKind.ParenExpression: + case SyntaxKind.FunctionExpression: + case SyntaxKind.ArrowFunction: + case SyntaxKind.PrefixOperator: + case SyntaxKind.PostfixOperator: + case SyntaxKind.BinaryExpression: + case SyntaxKind.ConditionalExpression: + case SyntaxKind.TemplateExpression: + case SyntaxKind.OmittedExpression: + return true; + case SyntaxKind.QualifiedName: + while (node.parent.kind === SyntaxKind.QualifiedName) node = node.parent; + return node.parent.kind === SyntaxKind.TypeQuery; + case SyntaxKind.Identifier: + if (node.parent.kind === SyntaxKind.TypeQuery) { + return true; + } + // fall through + case SyntaxKind.NumericLiteral: + case SyntaxKind.StringLiteral: + case SyntaxKind.NoSubstitutionTemplateLiteral: + var parent = node.parent; + switch (parent.kind) { + case SyntaxKind.VariableDeclaration: + case SyntaxKind.Parameter: + case SyntaxKind.Property: + case SyntaxKind.EnumMember: + case SyntaxKind.PropertyAssignment: + return (parent).initializer === node; + case SyntaxKind.ExpressionStatement: + case SyntaxKind.IfStatement: + case SyntaxKind.DoStatement: + case SyntaxKind.WhileStatement: + case SyntaxKind.ReturnStatement: + case SyntaxKind.WithStatement: + case SyntaxKind.SwitchStatement: + case SyntaxKind.CaseClause: + case SyntaxKind.ThrowStatement: + case SyntaxKind.SwitchStatement: + return (parent).expression === node; + case SyntaxKind.ForStatement: + return (parent).initializer === node || + (parent).condition === node || + (parent).iterator === node; + case SyntaxKind.ForInStatement: + return (parent).variable === node || + (parent).expression === node; + case SyntaxKind.TypeAssertion: + return node === (parent).operand; + default: + if (isExpression(parent)) { + return true; + } + } + } + return false; + } + export function hasRestParameters(s: SignatureDeclaration): boolean { return s.parameters.length > 0 && (s.parameters[s.parameters.length - 1].flags & NodeFlags.Rest) !== 0; } + export function isLiteralKind(kind: SyntaxKind): boolean { + return SyntaxKind.FirstLiteralToken <= kind && kind <= SyntaxKind.LastLiteralToken; + } + + export function isTextualLiteralKind(kind: SyntaxKind): boolean { + return kind === SyntaxKind.StringLiteral || kind === SyntaxKind.NoSubstitutionTemplateLiteral; + } + + export function isTemplateLiteralKind(kind: SyntaxKind): boolean { + return SyntaxKind.FirstTemplateToken <= kind && kind <= SyntaxKind.LastTemplateToken; + } + export function isInAmbientContext(node: Node): boolean { while (node) { if (node.flags & (NodeFlags.Ambient | NodeFlags.DeclarationFile)) return true; @@ -538,6 +560,7 @@ module ts { return false; } + export function isDeclaration(node: Node): boolean { switch (node.kind) { case SyntaxKind.TypeParameter: @@ -955,6 +978,10 @@ module ts { return token = scanner.reScanSlashToken(); } + function reScanTemplateToken(): SyntaxKind { + return token = scanner.reScanTemplateToken(); + } + function lookAheadHelper(callback: () => T, alwaysResetState: boolean): T { // Keep track of the state we'll need to rollback to if lookahead fails (or if the // caller asked us to always reset our state). @@ -1100,7 +1127,9 @@ module ts { } function isPropertyName(): boolean { - return token >= SyntaxKind.Identifier || token === SyntaxKind.StringLiteral || token === SyntaxKind.NumericLiteral; + return token >= SyntaxKind.Identifier || + token === SyntaxKind.StringLiteral || + token === SyntaxKind.NumericLiteral; } function parsePropertyName(): Identifier { @@ -1136,7 +1165,7 @@ module ts { case ParsingContext.SwitchClauses: return token === SyntaxKind.CaseKeyword || token === SyntaxKind.DefaultKeyword; case ParsingContext.TypeMembers: - return isTypeMember(); + return isStartOfTypeMember(); case ParsingContext.ClassMembers: return lookAhead(isClassMemberStart); case ParsingContext.EnumMembers: @@ -1148,14 +1177,14 @@ module ts { case ParsingContext.TypeParameters: return isIdentifier(); case ParsingContext.ArgumentExpressions: - return token === SyntaxKind.CommaToken || isExpression(); + return token === SyntaxKind.CommaToken || isStartOfExpression(); case ParsingContext.ArrayLiteralMembers: - return token === SyntaxKind.CommaToken || isExpression(); + return token === SyntaxKind.CommaToken || isStartOfExpression(); case ParsingContext.Parameters: - return isParameter(); + return isStartOfParameter(); case ParsingContext.TypeArguments: case ParsingContext.TupleElementTypes: - return token === SyntaxKind.CommaToken || isType(); + return token === SyntaxKind.CommaToken || isStartOfType(); } Debug.fail("Non-exhaustive case in 'isListElement'."); @@ -1375,7 +1404,48 @@ module ts { return finishNode(node); } - function parseLiteralNode(internName?:boolean): LiteralExpression { + function parseTemplateExpression() { + var template = createNode(SyntaxKind.TemplateExpression); + + template.head = parseLiteralNode(); + Debug.assert(template.head.kind === SyntaxKind.TemplateHead, "Template head has wrong token kind"); + + var templateSpans = >[]; + templateSpans.pos = getNodePos(); + + do { + templateSpans.push(parseTemplateSpan()); + } + while (templateSpans[templateSpans.length - 1].literal.kind === SyntaxKind.TemplateMiddle) + + templateSpans.end = getNodeEnd(); + template.templateSpans = templateSpans; + + return finishNode(template); + } + + function parseTemplateSpan(): TemplateSpan { + var span = createNode(SyntaxKind.TemplateSpan); + span.expression = parseExpression(/*noIn*/ false); + + var literal: LiteralExpression; + + if (token === SyntaxKind.CloseBraceToken) { + reScanTemplateToken() + literal = parseLiteralNode(); + } + else { + error(Diagnostics.Invalid_template_literal_expected); + literal = createMissingNode(); + literal.text = ""; + } + + span.literal = literal; + + return finishNode(span); + } + + function parseLiteralNode(internName?: boolean): LiteralExpression { var node = createNode(token); var text = scanner.getTokenValue(); node.text = internName ? internIdentifier(text) : text; @@ -1387,7 +1457,7 @@ module ts { // Octal literals are not allowed in strict mode or ES5 // Note that theoretically the following condition would hold true literals like 009, // which is not octal.But because of how the scanner separates the tokens, we would - // never get a token like this.Instead, we would get 00 and 9 as two separate tokens. + // never get a token like this. Instead, we would get 00 and 9 as two separate tokens. // We also do not need to check for negatives because any prefix operator would be part of a // parent unary expression. if (node.kind === SyntaxKind.NumericLiteral @@ -1406,7 +1476,9 @@ module ts { } function parseStringLiteral(): LiteralExpression { - if (token === SyntaxKind.StringLiteral) return parseLiteralNode(/*internName:*/ true); + if (token === SyntaxKind.StringLiteral) { + return parseLiteralNode(/*internName:*/ true); + } error(Diagnostics.String_literal_expected); return createMissingNode(); } @@ -1437,7 +1509,7 @@ module ts { // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed // instead. - if (isType() || !isExpression()) { + if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } else { @@ -1473,7 +1545,7 @@ module ts { return parseOptional(SyntaxKind.ColonToken) ? token === SyntaxKind.StringLiteral ? parseStringLiteral() : parseType() : undefined; } - function isParameter(): boolean { + function isStartOfParameter(): boolean { return token === SyntaxKind.DotDotDotToken || isIdentifier() || isModifier(token); } @@ -1681,7 +1753,7 @@ module ts { return finishNode(node); } - function isTypeMember(): boolean { + function isStartOfTypeMember(): boolean { switch (token) { case SyntaxKind.OpenParenToken: case SyntaxKind.LessThanToken: @@ -1788,7 +1860,7 @@ module ts { return createMissingNode(); } - function isType(): boolean { + function isStartOfType(): boolean { switch (token) { case SyntaxKind.AnyKeyword: case SyntaxKind.StringKeyword: @@ -1806,7 +1878,7 @@ module ts { // or something that starts a type. We don't want to consider things like '(1)' a type. return lookAhead(() => { nextToken(); - return token === SyntaxKind.CloseParenToken || isParameter() || isType(); + return token === SyntaxKind.CloseParenToken || isStartOfParameter() || isStartOfType(); }); default: return isIdentifier(); @@ -1840,7 +1912,7 @@ module ts { return type; } - function isFunctionType(): boolean { + function isStartOfFunctionType(): boolean { return token === SyntaxKind.LessThanToken || token === SyntaxKind.OpenParenToken && lookAhead(() => { nextToken(); if (token === SyntaxKind.CloseParenToken || token === SyntaxKind.DotDotDotToken) { @@ -1873,7 +1945,7 @@ module ts { } function parseType(): TypeNode { - if (isFunctionType()) { + if (isStartOfFunctionType()) { return parseFunctionType(SyntaxKind.CallSignature); } if (token === SyntaxKind.NewKeyword) { @@ -1888,7 +1960,7 @@ module ts { // EXPRESSIONS - function isExpression(): boolean { + function isStartOfExpression(): boolean { switch (token) { case SyntaxKind.ThisKeyword: case SyntaxKind.SuperKeyword: @@ -1897,6 +1969,8 @@ module ts { case SyntaxKind.FalseKeyword: case SyntaxKind.NumericLiteral: case SyntaxKind.StringLiteral: + case SyntaxKind.NoSubstitutionTemplateLiteral: + case SyntaxKind.TemplateHead: case SyntaxKind.OpenParenToken: case SyntaxKind.OpenBracketToken: case SyntaxKind.OpenBraceToken: @@ -1921,9 +1995,9 @@ module ts { } } - function isExpressionStatement(): boolean { + function isStartOfExpressionStatement(): boolean { // As per the grammar, neither '{' nor 'function' can start an expression statement. - return token !== SyntaxKind.OpenBraceToken && token !== SyntaxKind.FunctionKeyword && isExpression(); + return token !== SyntaxKind.OpenBraceToken && token !== SyntaxKind.FunctionKeyword && isStartOfExpression(); } function parseExpression(noIn?: boolean): Expression { @@ -1944,7 +2018,7 @@ module ts { // it's more likely that a { would be a allowed (as an object literal). While this // is also allowed for parameters, the risk is that we consume the { as an object // literal when it really will be for the block following the parameter. - if (scanner.hasPrecedingLineBreak() || (inParameter && token === SyntaxKind.OpenBraceToken) || !isExpression()) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token === SyntaxKind.OpenBraceToken) || !isStartOfExpression()) { // preceding line break, open brace in a parameter (likely a function body) or current token is not an expression - // do not try to parse initializer return undefined; @@ -1988,8 +2062,8 @@ module ts { } // Now see if we might be in cases '2' or '3'. - // If the expression was a LHS expression, and we have an assignment operator, then - // we're in '2' or '3'. Consume the assignment and return. + // If the expression was a LHS expression, and we have an assignment operator, then + // we're in '2' or '3'. Consume the assignment and return. if (isLeftHandSideExpression(expr) && isAssignmentOperator()) { if (isInStrictMode && isEvalOrArgumentsIdentifier(expr)) { // ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an @@ -2012,6 +2086,7 @@ module ts { case SyntaxKind.IndexedAccess: case SyntaxKind.NewExpression: case SyntaxKind.CallExpression: + case SyntaxKind.TaggedTemplateExpression: case SyntaxKind.ArrayLiteral: case SyntaxKind.ParenExpression: case SyntaxKind.ObjectLiteral: @@ -2021,6 +2096,8 @@ module ts { case SyntaxKind.RegularExpressionLiteral: case SyntaxKind.NumericLiteral: case SyntaxKind.StringLiteral: + case SyntaxKind.NoSubstitutionTemplateLiteral: + case SyntaxKind.TemplateExpression: case SyntaxKind.FalseKeyword: case SyntaxKind.NullKeyword: case SyntaxKind.ThisKeyword: @@ -2189,7 +2266,7 @@ module ts { if (token === SyntaxKind.OpenBraceToken) { body = parseBody(/* ignoreMissingOpenBrace */ false); } - else if (isStatement(/* inErrorRecovery */ true) && !isExpressionStatement() && token !== SyntaxKind.FunctionKeyword) { + else if (isStatement(/* inErrorRecovery */ true) && !isStartOfExpressionStatement() && token !== SyntaxKind.FunctionKeyword) { // Check if we got a plain statement (i.e. no expression-statements, no functions expressions/declarations) // // Here we try to recover from a potential error situation in the case where the @@ -2376,7 +2453,7 @@ module ts { function parseCallAndAccess(expr: Expression, inNewExpression: boolean): Expression { while (true) { - var dotStart = scanner.getTokenPos(); + var dotOrBracketStart = scanner.getTokenPos(); if (parseOptional(SyntaxKind.DotToken)) { var propertyAccess = createNode(SyntaxKind.PropertyAccess, expr.pos); // Technically a keyword is valid here as all keywords are identifier names. @@ -2399,7 +2476,7 @@ module ts { // In the first case though, ASI will not take effect because there is not a // line terminator after the keyword. if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord() && lookAhead(() => scanner.isReservedWord())) { - grammarErrorAtPos(dotStart, scanner.getStartPos() - dotStart, Diagnostics.Identifier_expected); + grammarErrorAtPos(dotOrBracketStart, scanner.getStartPos() - dotOrBracketStart, Diagnostics.Identifier_expected); var id = createMissingNode(); } else { @@ -2412,7 +2489,6 @@ module ts { continue; } - var bracketStart = scanner.getTokenPos(); if (parseOptional(SyntaxKind.OpenBracketToken)) { var indexedAccess = createNode(SyntaxKind.IndexedAccess, expr.pos); @@ -2422,7 +2498,7 @@ module ts { // Check for that common pattern and report a better error message. if (inNewExpression && parseOptional(SyntaxKind.CloseBracketToken)) { indexedAccess.index = createMissingNode(); - grammarErrorAtPos(bracketStart, scanner.getStartPos() - bracketStart, Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); + grammarErrorAtPos(dotOrBracketStart, scanner.getStartPos() - dotOrBracketStart, Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); } else { indexedAccess.index = parseExpression(); @@ -2455,6 +2531,22 @@ module ts { expr = finishNode(callExpr); continue; } + + if (token === SyntaxKind.NoSubstitutionTemplateLiteral || token === SyntaxKind.TemplateHead) { + var tagExpression = createNode(SyntaxKind.TaggedTemplateExpression, expr.pos); + tagExpression.tag = expr; + tagExpression.template = token === SyntaxKind.NoSubstitutionTemplateLiteral + ? parseLiteralNode() + : parseTemplateExpression(); + expr = finishNode(tagExpression); + + if (languageVersion < ScriptTarget.ES6) { + grammarErrorOnNode(expr, Diagnostics.Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher); + } + + continue; + } + return expr; } } @@ -2501,6 +2593,7 @@ module ts { return parseTokenNode(); case SyntaxKind.NumericLiteral: case SyntaxKind.StringLiteral: + case SyntaxKind.NoSubstitutionTemplateLiteral: return parseLiteralNode(); case SyntaxKind.OpenParenToken: return parseParenExpression(); @@ -2518,6 +2611,9 @@ module ts { return parseLiteralNode(); } break; + case SyntaxKind.TemplateHead: + return parseTemplateExpression(); + default: if (isIdentifier()) { return parseIdentifier(); @@ -3176,7 +3272,7 @@ module ts { case SyntaxKind.TypeKeyword: // When followed by an identifier, these do not start a statement but might // instead be following declarations - if (isDeclaration()) { + if (isDeclarationStart()) { return false; } case SyntaxKind.PublicKeyword: @@ -3189,7 +3285,7 @@ module ts { return false; } default: - return isExpression(); + return isStartOfExpression(); } } @@ -3920,7 +4016,7 @@ module ts { return finishNode(node); } - function isDeclaration(): boolean { + function isDeclarationStart(): boolean { switch (token) { case SyntaxKind.VarKeyword: case SyntaxKind.LetKeyword: @@ -3939,14 +4035,14 @@ module ts { return lookAhead(() => nextToken() >= SyntaxKind.Identifier || token === SyntaxKind.StringLiteral); case SyntaxKind.ExportKeyword: // Check for export assignment or modifier on source element - return lookAhead(() => nextToken() === SyntaxKind.EqualsToken || isDeclaration()); + return lookAhead(() => nextToken() === SyntaxKind.EqualsToken || isDeclarationStart()); case SyntaxKind.DeclareKeyword: case SyntaxKind.PublicKeyword: case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: case SyntaxKind.StaticKeyword: // Check for modifier on source element - return lookAhead(() => { nextToken(); return isDeclaration(); }); + return lookAhead(() => { nextToken(); return isDeclarationStart(); }); } } @@ -4010,7 +4106,7 @@ module ts { } function isSourceElement(inErrorRecovery: boolean): boolean { - return isDeclaration() || isStatement(inErrorRecovery); + return isDeclarationStart() || isStatement(inErrorRecovery); } function parseSourceElement() { @@ -4022,7 +4118,7 @@ module ts { } function parseSourceElementOrModuleElement(modifierContext: ModifierContext): Statement { - if (isDeclaration()) { + if (isDeclarationStart()) { return parseDeclaration(modifierContext); } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 75b14801ae7ef..29593ddf92ee9 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -24,6 +24,7 @@ module ts { isReservedWord(): boolean; reScanGreaterToken(): SyntaxKind; reScanSlashToken(): SyntaxKind; + reScanTemplateToken(): SyntaxKind; scan(): SyntaxKind; setText(text: string): void; setTextPos(textPos: number): void; @@ -466,7 +467,7 @@ module ts { var len: number; // Length of text var startPos: number; // Start position of whitespace before current token var tokenPos: number; // Start position of text of current token - var token: number; + var token: SyntaxKind; var tokenValue: string; var precedingLineBreak: boolean; @@ -519,10 +520,10 @@ module ts { return +(text.substring(start, pos)); } - function scanHexDigits(count: number, exact?: boolean): number { + function scanHexDigits(count: number, mustMatchCount?: boolean): number { var digits = 0; var value = 0; - while (digits < count || !exact) { + while (digits < count || !mustMatchCount) { var ch = text.charCodeAt(pos); if (ch >= CharacterCodes._0 && ch <= CharacterCodes._9) { value = value * 16 + ch - CharacterCodes._0; @@ -563,60 +564,7 @@ module ts { } if (ch === CharacterCodes.backslash) { result += text.substring(start, pos); - pos++; - if (pos >= len) { - error(Diagnostics.Unexpected_end_of_text); - break; - } - ch = text.charCodeAt(pos++); - switch (ch) { - case CharacterCodes._0: - result += "\0"; - break; - case CharacterCodes.b: - result += "\b"; - break; - case CharacterCodes.t: - result += "\t"; - break; - case CharacterCodes.n: - result += "\n"; - break; - case CharacterCodes.v: - result += "\v"; - break; - case CharacterCodes.f: - result += "\f"; - break; - case CharacterCodes.r: - result += "\r"; - break; - case CharacterCodes.singleQuote: - result += "\'"; - break; - case CharacterCodes.doubleQuote: - result += "\""; - break; - case CharacterCodes.x: - case CharacterCodes.u: - var ch = scanHexDigits(ch === CharacterCodes.x ? 2 : 4, true); - if (ch >= 0) { - result += String.fromCharCode(ch); - } - else { - error(Diagnostics.Hexadecimal_digit_expected); - } - break; - case CharacterCodes.carriageReturn: - if (pos < len && text.charCodeAt(pos) === CharacterCodes.lineFeed) pos++; - break; - case CharacterCodes.lineFeed: - case CharacterCodes.lineSeparator: - case CharacterCodes.paragraphSeparator: - break; - default: - result += String.fromCharCode(ch); - } + result += scanEscapeSequence(); start = pos; continue; } @@ -630,13 +578,136 @@ module ts { return result; } + /** + * Sets the current 'tokenValue' and returns a NoSubstitutionTemplateLiteral or + * a literal component of a TemplateExpression. + */ + function scanTemplateAndSetTokenValue(): SyntaxKind { + var startedWithBacktick = text.charCodeAt(pos) === CharacterCodes.backtick; + + pos++; + var start = pos; + var contents = "" + var resultingToken: SyntaxKind; + + while (true) { + if (pos >= len) { + contents += text.substring(start, pos); + error(Diagnostics.Unexpected_end_of_text); + resultingToken = startedWithBacktick ? SyntaxKind.NoSubstitutionTemplateLiteral : SyntaxKind.TemplateTail; + break; + } + + var currChar = text.charCodeAt(pos); + + // '`' + if (currChar === CharacterCodes.backtick) { + contents += text.substring(start, pos); + pos++; + resultingToken = startedWithBacktick ? SyntaxKind.NoSubstitutionTemplateLiteral : SyntaxKind.TemplateTail; + break; + } + + // '${' + if (currChar === CharacterCodes.$ && pos + 1 < len && text.charCodeAt(pos + 1) === CharacterCodes.openBrace) { + contents += text.substring(start, pos); + pos += 2; + resultingToken = startedWithBacktick ? SyntaxKind.TemplateHead : SyntaxKind.TemplateMiddle; + break; + } + + // Escape character + if (currChar === CharacterCodes.backslash) { + contents += text.substring(start, pos); + contents += scanEscapeSequence(); + start = pos; + continue; + } + + // Speculated ECMAScript 6 Spec 11.8.6.1: + // and LineTerminatorSequences are normalized to for Template Values + // An explicit EscapeSequence is needed to include a or sequence. + if (currChar === CharacterCodes.carriageReturn) { + contents += text.substring(start, pos); + + if (pos + 1 < len && text.charCodeAt(pos + 1) === CharacterCodes.lineFeed) { + pos++; + } + pos++; + contents += "\n"; + start = pos; + continue; + } + + pos++; + } + + Debug.assert(resultingToken !== undefined); + + tokenValue = contents; + return resultingToken; + } + + function scanEscapeSequence(): string { + pos++; + if (pos >= len) { + error(Diagnostics.Unexpected_end_of_text); + return ""; + } + var ch = text.charCodeAt(pos++); + switch (ch) { + case CharacterCodes._0: + return "\0"; + case CharacterCodes.b: + return "\b"; + case CharacterCodes.t: + return "\t"; + case CharacterCodes.n: + return "\n"; + case CharacterCodes.v: + return "\v"; + case CharacterCodes.f: + return "\f"; + case CharacterCodes.r: + return "\r"; + case CharacterCodes.singleQuote: + return "\'"; + case CharacterCodes.doubleQuote: + return "\""; + case CharacterCodes.x: + case CharacterCodes.u: + var ch = scanHexDigits(ch === CharacterCodes.x ? 2 : 4, /*mustMatchCount*/ true); + if (ch >= 0) { + return String.fromCharCode(ch); + } + else { + error(Diagnostics.Hexadecimal_digit_expected); + return "" + } + + // when encountering a LineContinuation (i.e. a backslash and a line terminator sequence), + // the line terminator is interpreted to be "the empty code unit sequence". + case CharacterCodes.carriageReturn: + if (pos < len && text.charCodeAt(pos) === CharacterCodes.lineFeed) { + pos++; + } + // fall through + case CharacterCodes.lineFeed: + case CharacterCodes.lineSeparator: + case CharacterCodes.paragraphSeparator: + return "" + default: + return String.fromCharCode(ch); + } + } + // Current character is known to be a backslash. Check for Unicode escape of the form '\uXXXX' // and return code point value if valid Unicode escape is found. Otherwise return -1. function peekUnicodeEscape(): number { if (pos + 5 < len && text.charCodeAt(pos + 1) === CharacterCodes.u) { var start = pos; pos += 2; - var value = scanHexDigits(4, true); + var value = scanHexDigits(4, /*mustMatchCount*/ true); pos = start; return value; } @@ -735,6 +806,8 @@ module ts { case CharacterCodes.singleQuote: tokenValue = scanString(); return token = SyntaxKind.StringLiteral; + case CharacterCodes.backtick: + return token = scanTemplateAndSetTokenValue() case CharacterCodes.percent: if (text.charCodeAt(pos + 1) === CharacterCodes.equals) { return pos += 2, token = SyntaxKind.PercentEqualsToken; @@ -852,7 +925,7 @@ module ts { case CharacterCodes._0: if (pos + 2 < len && (text.charCodeAt(pos + 1) === CharacterCodes.X || text.charCodeAt(pos + 1) === CharacterCodes.x)) { pos += 2; - var value = scanHexDigits(1, false); + var value = scanHexDigits(1, /*mustMatchCount*/ false); if (value < 0) { error(Diagnostics.Hexadecimal_digit_expected); value = 0; @@ -1038,6 +1111,15 @@ module ts { return token; } + /** + * Unconditionally back up and scan a template expression portion. + */ + function reScanTemplateToken(): SyntaxKind { + Debug.assert(token === SyntaxKind.CloseBraceToken, "'reScanTemplateToken' should only be called on a '}'"); + pos = tokenPos; + return token = scanTemplateAndSetTokenValue(); + } + function tryScan(callback: () => T): T { var savePos = pos; var saveStartPos = startPos; @@ -1086,10 +1168,11 @@ module ts { isReservedWord: () => token >= SyntaxKind.FirstReservedWord && token <= SyntaxKind.LastReservedWord, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, + reScanTemplateToken: reScanTemplateToken, scan: scan, setText: setText, setTextPos: setTextPos, - tryScan: tryScan + tryScan: tryScan, }; } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 6a51691f1ab3b..ead8495773190 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -20,6 +20,11 @@ module ts { NumericLiteral, StringLiteral, RegularExpressionLiteral, + NoSubstitutionTemplateLiteral, + // Pseudo-literals + TemplateHead, + TemplateMiddle, + TemplateTail, // Punctuation OpenBraceToken, CloseBraceToken, @@ -165,6 +170,7 @@ module ts { IndexedAccess, CallExpression, NewExpression, + TaggedTemplateExpression, TypeAssertion, ParenExpression, FunctionExpression, @@ -173,6 +179,8 @@ module ts { PostfixOperator, BinaryExpression, ConditionalExpression, + TemplateExpression, + TemplateSpan, OmittedExpression, // Element Block, @@ -234,7 +242,11 @@ module ts { FirstToken = EndOfFileToken, LastToken = TypeKeyword, FirstTriviaToken = SingleLineCommentTrivia, - LastTriviaToken = WhitespaceTrivia + LastTriviaToken = WhitespaceTrivia, + FirstLiteralToken = NumericLiteral, + LastLiteralToken = NoSubstitutionTemplateLiteral, + FirstTemplateToken = NoSubstitutionTemplateLiteral, + LastTemplateToken = TemplateTail } export enum NodeFlags { @@ -379,13 +391,25 @@ module ts { body: Block | Expression; // Required, whereas the member inherited from FunctionDeclaration is optional } - // The text property of a LiteralExpression stores the interpreted value of the literal in text form. For a StringLiteral - // this means quotes have been removed and escapes have been converted to actual characters. For a NumericLiteral, the - // stored value is the toString() representation of the number. For example 1, 1.00, and 1e0 are all stored as just "1". + // The text property of a LiteralExpression stores the interpreted value of the literal in text form. For a StringLiteral, + // or any literal of a template, this means quotes have been removed and escapes have been converted to actual characters. + // For a NumericLiteral, the stored value is the toString() representation of the number. For example 1, 1.00, and 1e0 are all stored as just "1". export interface LiteralExpression extends Expression { text: string; } + export interface TemplateExpression extends Expression { + head: LiteralExpression; + templateSpans: NodeArray; + } + + // Each of these corresponds to a substitution expression and a template literal, in that order. + // The template literal must have kind TemplateMiddleLiteral or TemplateTailLiteral. + export interface TemplateSpan extends Node { + expression: Expression; + literal: LiteralExpression; + } + export interface ParenExpression extends Expression { expression: Expression; } @@ -416,6 +440,11 @@ module ts { export interface NewExpression extends CallExpression { } + export interface TaggedTemplateExpression extends Expression { + tag: Expression; + template: LiteralExpression | TemplateExpression; + } + export interface TypeAssertion extends Expression { type: TypeNode; operand: Expression; @@ -776,7 +805,6 @@ module ts { ExportValue = 0x00200000, // Exported value marker ExportType = 0x00400000, // Exported type marker ExportNamespace = 0x00800000, // Exported namespace marker - Import = 0x01000000, // Import Instantiated = 0x02000000, // Instantiated symbol Merged = 0x04000000, // Merged symbol (created during program binding) @@ -1218,6 +1246,7 @@ module ts { asterisk = 0x2A, // * at = 0x40, // @ backslash = 0x5C, // \ + backtick = 0x60, // ` bar = 0x7C, // | caret = 0x5E, // ^ closeBrace = 0x7D, // } diff --git a/src/harness/typeWriter.ts b/src/harness/typeWriter.ts index 5dfc75b29a5b4..6f7a7c335a03f 100644 --- a/src/harness/typeWriter.ts +++ b/src/harness/typeWriter.ts @@ -92,7 +92,7 @@ class TypeWriterWalker { private getTypeOfNode(node: ts.Node): ts.Type { var type = this.checker.getTypeOfNode(node); - ts.Debug.assert(type, "type doesn't exist"); + ts.Debug.assert(type !== undefined, "type doesn't exist"); return type; } } diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 12d36dd4d2b97..e31c6687428d3 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -175,7 +175,7 @@ module ts.formatting { function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: Node, childStartLine: number, sourceFile: SourceFile): boolean { if (parent.kind === SyntaxKind.IfStatement && (parent).elseStatement === child) { var elseKeyword = findChildOfKind(parent, SyntaxKind.ElseKeyword, sourceFile); - Debug.assert(elseKeyword); + Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; diff --git a/src/services/services.ts b/src/services/services.ts index 4d4a4f94ea58f..d208eb87e96ea 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1639,7 +1639,7 @@ module ts { } if (syntaxTree !== null) { - Debug.assert(sourceFile); + Debug.assert(sourceFile !== undefined); // All done, ensure state is up to date this.currentFileVersion = version; this.currentFilename = filename; @@ -1847,9 +1847,9 @@ module ts { ): SourceFile { var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ false); - Debug.assert(bucket); + Debug.assert(bucket !== undefined); var entry = lookUp(bucket, filename); - Debug.assert(entry); + Debug.assert(entry !== undefined); if (entry.sourceFile.isOpen === isOpen && entry.sourceFile.version === version) { return entry.sourceFile; @@ -1861,7 +1861,7 @@ module ts { function releaseDocument(filename: string, compilationSettings: CompilerOptions): void { var bucket = getBucketForCompilationSettings(compilationSettings, false); - Debug.assert(bucket); + Debug.assert(bucket !== undefined); var entry = lookUp(bucket, filename); entry.refCount--; @@ -2471,31 +2471,54 @@ module ts { } function isCompletionListBlocker(previousToken: Node): boolean { - return isInStringOrRegularExpressionLiteral(previousToken) || + return isInStringOrRegularExpressionOrTemplateLiteral(previousToken) || isIdentifierDefinitionLocation(previousToken) || isRightOfIllegalDot(previousToken); } - function isInStringOrRegularExpressionLiteral(previousToken: Node): boolean { - if (previousToken.kind === SyntaxKind.StringLiteral) { + function isInStringOrRegularExpressionOrTemplateLiteral(previousToken: Node): boolean { + if (previousToken.kind === SyntaxKind.StringLiteral || isTemplateLiteralKind(previousToken.kind)) { // The position has to be either: 1. entirely within the token text, or // 2. at the end position, and the string literal is not terminated + var start = previousToken.getStart(); var end = previousToken.getEnd(); + if (start < position && position < end) { return true; } else if (position === end) { var width = end - start; var text = previousToken.getSourceFile().text; - return width <= 1 || - text.charCodeAt(start) !== text.charCodeAt(end - 1) || - text.charCodeAt(end - 2) === CharacterCodes.backslash; + + // If the token is a single character, or its second-to-last charcter indicates an escape code, + // then we can immediately say that we are in the middle of an unclosed string. + if (width <= 1 || text.charCodeAt(end - 2) === CharacterCodes.backslash) { + return true; + } + + // Now check if the last character is a closing character for the token. + switch (previousToken.kind) { + case SyntaxKind.StringLiteral: + case SyntaxKind.NoSubstitutionTemplateLiteral: + return text.charCodeAt(start) !== text.charCodeAt(end - 1); + + case SyntaxKind.TemplateHead: + case SyntaxKind.TemplateMiddle: + return text.charCodeAt(end - 1) !== CharacterCodes.openBrace + || text.charCodeAt(end - 2) !== CharacterCodes.$; + + case SyntaxKind.TemplateTail: + return text.charCodeAt(end - 1) !== CharacterCodes.backtick; + } + + return false; } } else if (previousToken.kind === SyntaxKind.RegularExpressionLiteral) { return previousToken.getStart() < position && position < previousToken.getEnd(); } + return false; } @@ -2647,7 +2670,7 @@ module ts { var symbol = lookUp(activeCompletionSession.symbols, entryName); if (symbol) { var type = session.typeChecker.getTypeOfSymbol(symbol); - Debug.assert(type, "Could not find type for symbol"); + Debug.assert(type !== undefined, "Could not find type for symbol"); var completionEntry = createCompletionEntry(symbol, session.typeChecker); // TODO(drosen): Right now we just permit *all* semantic meanings when calling 'getSymbolKind' // which is permissible given that it is backwards compatible; but really we should consider @@ -2748,7 +2771,7 @@ module ts { } if (rootSymbolFlags & SymbolFlags.GetAccessor) return ScriptElementKind.memberVariableElement; if (rootSymbolFlags & SymbolFlags.SetAccessor) return ScriptElementKind.memberVariableElement; - Debug.assert(rootSymbolFlags & SymbolFlags.Method); + Debug.assert((rootSymbolFlags & SymbolFlags.Method) !== undefined); }) || ScriptElementKind.memberFunctionElement; } return ScriptElementKind.memberVariableElement; @@ -4927,6 +4950,10 @@ module ts { // TODO: we should get another classification type for these literals. return ClassificationTypeNames.stringLiteral; } + else if (isTemplateLiteralKind(tokenKind)) { + // TODO (drosen): we should *also* get another classification type for these literals. + return ClassificationTypeNames.stringLiteral; + } else if (tokenKind === SyntaxKind.Identifier) { switch (token.parent.kind) { case SyntaxKind.ClassDeclaration: @@ -5163,7 +5190,7 @@ module ts { descriptor = descriptors[i]; } } - Debug.assert(descriptor); + Debug.assert(descriptor !== undefined); // We don't want to match something like 'TODOBY', so we make sure a non // letter/digit follows the match. diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index a93cf2c276e75..f0b4ddc5ef79b 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -219,7 +219,7 @@ module ts.SignatureHelp { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. var list = getChildListThatStartsWithOpenerToken(parent, node, sourceFile); - Debug.assert(list); + Debug.assert(list !== undefined); return { list: list, listItemIndex: 0 diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 5fd90eb894a92..2cc5c827b4f5d 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -197,7 +197,7 @@ module ts { } } - Debug.assert(startNode || n.kind === SyntaxKind.SourceFile); + Debug.assert(startNode !== undefined || n.kind === SyntaxKind.SourceFile); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. diff --git a/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.errors.txt new file mode 100644 index 0000000000000..a9f4be155d9a4 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.errors.txt @@ -0,0 +1,64 @@ +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(12,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(14,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(16,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(18,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(20,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(22,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + +==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts (10 errors) ==== + interface I { + (stringParts: string[], ...rest: boolean[]): I; + g: I; + h: I; + member: I; + thisIsNotATag(x: string): void + [x: number]: I; + } + + var f: I; + + f `abc` + ~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f `abc${1}def${2}ghi`; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f `abc`.member + ~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f `abc${1}def${2}ghi`.member; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f `abc`["member"]; + ~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f `abc${1}def${2}ghi`["member"]; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f `abc`[0].member `abc${1}def${2}ghi`; + ~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f.thisIsNotATag(`abc`); + + f.thisIsNotATag(`abc${1}def${2}ghi`); + \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTagsES6.js b/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTagsES6.js new file mode 100644 index 0000000000000..db68e950c342c --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTagsES6.js @@ -0,0 +1,45 @@ +//// [taggedTemplateStringsWithIncompatibleTypedTagsES6.ts] +interface I { + (stringParts: string[], ...rest: boolean[]): I; + g: I; + h: I; + member: I; + thisIsNotATag(x: string): void + [x: number]: I; +} + +var f: I; + +f `abc` + +f `abc${1}def${2}ghi`; + +f `abc`.member + +f `abc${1}def${2}ghi`.member; + +f `abc`["member"]; + +f `abc${1}def${2}ghi`["member"]; + +f `abc`[0].member `abc${1}def${2}ghi`; + +f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; + +f.thisIsNotATag(`abc`); + +f.thisIsNotATag(`abc${1}def${2}ghi`); + + +//// [taggedTemplateStringsWithIncompatibleTypedTagsES6.js] +var f; +f `abc`; +f `abc${1}def${2}ghi`; +f `abc`.member; +f `abc${1}def${2}ghi`.member; +f `abc`["member"]; +f `abc${1}def${2}ghi`["member"]; +f `abc`[0].member `abc${1}def${2}ghi`; +f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; +f.thisIsNotATag(`abc`); +f.thisIsNotATag(`abc${1}def${2}ghi`); diff --git a/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTagsES6.types b/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTagsES6.types new file mode 100644 index 0000000000000..572c3c1a8d157 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTagsES6.types @@ -0,0 +1,82 @@ +=== tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts === +interface I { +>I : I + + (stringParts: string[], ...rest: boolean[]): I; +>stringParts : string[] +>rest : boolean[] +>I : I + + g: I; +>g : I +>I : I + + h: I; +>h : I +>I : I + + member: I; +>member : I +>I : I + + thisIsNotATag(x: string): void +>thisIsNotATag : (x: string) => void +>x : string + + [x: number]: I; +>x : number +>I : I +} + +var f: I; +>f : I +>I : I + +f `abc` +>f : I + +f `abc${1}def${2}ghi`; +>f : I + +f `abc`.member +>f `abc`.member : any +>f : I +>member : any + +f `abc${1}def${2}ghi`.member; +>f `abc${1}def${2}ghi`.member : any +>f : I +>member : any + +f `abc`["member"]; +>f `abc`["member"] : any +>f : I + +f `abc${1}def${2}ghi`["member"]; +>f `abc${1}def${2}ghi`["member"] : any +>f : I + +f `abc`[0].member `abc${1}def${2}ghi`; +>f `abc`[0].member : any +>f `abc`[0] : any +>f : I +>member : any + +f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; +>f `abc${1}def${2}ghi`["member"].member : any +>f `abc${1}def${2}ghi`["member"] : any +>f : I +>member : any + +f.thisIsNotATag(`abc`); +>f.thisIsNotATag(`abc`) : void +>f.thisIsNotATag : (x: string) => void +>f : I +>thisIsNotATag : (x: string) => void + +f.thisIsNotATag(`abc${1}def${2}ghi`); +>f.thisIsNotATag(`abc${1}def${2}ghi`) : void +>f.thisIsNotATag : (x: string) => void +>f : I +>thisIsNotATag : (x: string) => void + diff --git a/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.errors.txt new file mode 100644 index 0000000000000..4813fe5a23934 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.errors.txt @@ -0,0 +1,21 @@ +tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressions.ts(13,21): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + +==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressions.ts (1 errors) ==== + interface I { + (strs: string[], subs: number[]): I; + member: { + new (s: string): { + new (n: number): { + new (): boolean; + } + } + }; + } + var f: I; + + var x = new new new f `abc${ 0 }def`.member("hello")(42) === true; + ~~~~~~~~~~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressionsES6.js b/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressionsES6.js new file mode 100644 index 0000000000000..4d6a68a921a6c --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressionsES6.js @@ -0,0 +1,20 @@ +//// [taggedTemplateStringsWithManyCallAndMemberExpressionsES6.ts] +interface I { + (strs: string[], subs: number[]): I; + member: { + new (s: string): { + new (n: number): { + new (): boolean; + } + } + }; +} +var f: I; + +var x = new new new f `abc${ 0 }def`.member("hello")(42) === true; + + + +//// [taggedTemplateStringsWithManyCallAndMemberExpressionsES6.js] +var f; +var x = new new new f `abc${0}def`.member("hello")(42) === true; diff --git a/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressionsES6.types b/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressionsES6.types new file mode 100644 index 0000000000000..b8fb33771967c --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressionsES6.types @@ -0,0 +1,38 @@ +=== tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressionsES6.ts === +interface I { +>I : I + + (strs: string[], subs: number[]): I; +>strs : string[] +>subs : number[] +>I : I + + member: { +>member : new (s: string) => new (n: number) => new () => boolean + + new (s: string): { +>s : string + + new (n: number): { +>n : number + + new (): boolean; + } + } + }; +} +var f: I; +>f : I +>I : I + +var x = new new new f `abc${ 0 }def`.member("hello")(42) === true; +>x : boolean +>new new new f `abc${ 0 }def`.member("hello")(42) === true : boolean +>new new new f `abc${ 0 }def`.member("hello")(42) : any +>new new f `abc${ 0 }def`.member("hello")(42) : any +>new f `abc${ 0 }def`.member("hello") : any +>f `abc${ 0 }def`.member : any +>f : I +>member : any + + diff --git a/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.errors.txt new file mode 100644 index 0000000000000..f813e13e8b988 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.errors.txt @@ -0,0 +1,64 @@ +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(3,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(5,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(7,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(9,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(11,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(13,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(15,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(17,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(19,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(19,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(21,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(21,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + +==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts (12 errors) ==== + var f: any; + + f `abc` + ~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f `abc${1}def${2}ghi`; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f.g.h `abc` + ~~~~~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f.g.h `abc${1}def${2}ghi`; + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f `abc`.member + ~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f `abc${1}def${2}ghi`.member; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f `abc`["member"]; + ~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f `abc${1}def${2}ghi`["member"]; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f `abc`["member"].someOtherTag `abc${1}def${2}ghi`; + ~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f `abc${1}def${2}ghi`["member"].someOtherTag `abc${1}def${2}ghi`; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f.thisIsNotATag(`abc`); + + f.thisIsNotATag(`abc${1}def${2}ghi`); \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAnyES6.js b/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAnyES6.js new file mode 100644 index 0000000000000..997e1277442e6 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAnyES6.js @@ -0,0 +1,40 @@ +//// [taggedTemplateStringsWithTagsTypedAsAnyES6.ts] +var f: any; +f `abc` + +f `abc${1}def${2}ghi`; + +f.g.h `abc` + +f.g.h `abc${1}def${2}ghi`; + +f `abc`.member + +f `abc${1}def${2}ghi`.member; + +f `abc`["member"]; + +f `abc${1}def${2}ghi`["member"]; + +f `abc`["member"].someOtherTag `abc${1}def${2}ghi`; + +f `abc${1}def${2}ghi`["member"].someOtherTag `abc${1}def${2}ghi`; + +f.thisIsNotATag(`abc`); + +f.thisIsNotATag(`abc${1}def${2}ghi`); + +//// [taggedTemplateStringsWithTagsTypedAsAnyES6.js] +var f; +f `abc`; +f `abc${1}def${2}ghi`; +f.g.h `abc`; +f.g.h `abc${1}def${2}ghi`; +f `abc`.member; +f `abc${1}def${2}ghi`.member; +f `abc`["member"]; +f `abc${1}def${2}ghi`["member"]; +f `abc`["member"].someOtherTag `abc${1}def${2}ghi`; +f `abc${1}def${2}ghi`["member"].someOtherTag `abc${1}def${2}ghi`; +f.thisIsNotATag(`abc`); +f.thisIsNotATag(`abc${1}def${2}ghi`); diff --git a/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAnyES6.types b/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAnyES6.types new file mode 100644 index 0000000000000..bb651fe1d25a2 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAnyES6.types @@ -0,0 +1,66 @@ +=== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAnyES6.ts === +var f: any; +>f : any + +f `abc` +>f : any + +f `abc${1}def${2}ghi`; +>f : any + +f.g.h `abc` +>f.g.h : any +>f.g : any +>f : any +>g : any +>h : any + +f.g.h `abc${1}def${2}ghi`; +>f.g.h : any +>f.g : any +>f : any +>g : any +>h : any + +f `abc`.member +>f `abc`.member : any +>f : any +>member : any + +f `abc${1}def${2}ghi`.member; +>f `abc${1}def${2}ghi`.member : any +>f : any +>member : any + +f `abc`["member"]; +>f `abc`["member"] : any +>f : any + +f `abc${1}def${2}ghi`["member"]; +>f `abc${1}def${2}ghi`["member"] : any +>f : any + +f `abc`["member"].someOtherTag `abc${1}def${2}ghi`; +>f `abc`["member"].someOtherTag : any +>f `abc`["member"] : any +>f : any +>someOtherTag : any + +f `abc${1}def${2}ghi`["member"].someOtherTag `abc${1}def${2}ghi`; +>f `abc${1}def${2}ghi`["member"].someOtherTag : any +>f `abc${1}def${2}ghi`["member"] : any +>f : any +>someOtherTag : any + +f.thisIsNotATag(`abc`); +>f.thisIsNotATag(`abc`) : any +>f.thisIsNotATag : any +>f : any +>thisIsNotATag : any + +f.thisIsNotATag(`abc${1}def${2}ghi`); +>f.thisIsNotATag(`abc${1}def${2}ghi`) : any +>f.thisIsNotATag : any +>f : any +>thisIsNotATag : any + diff --git a/tests/baselines/reference/taggedTemplateStringsWithTypedTags.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithTypedTags.errors.txt new file mode 100644 index 0000000000000..6a38ddc278a38 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithTypedTags.errors.txt @@ -0,0 +1,64 @@ +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(12,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(14,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(16,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(18,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(20,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(22,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(24,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(24,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(26,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(26,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + +==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts (10 errors) ==== + interface I { + (stringParts: string[], ...rest: number[]): I; + g: I; + h: I; + member: I; + thisIsNotATag(x: string): void + [x: number]: I; + } + + var f: I; + + f `abc` + ~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f `abc${1}def${2}ghi`; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f `abc`.member + ~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f `abc${1}def${2}ghi`.member; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f `abc`["member"]; + ~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f `abc${1}def${2}ghi`["member"]; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f `abc`[0].member `abc${1}def${2}ghi`; + ~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + + f.thisIsNotATag(`abc`); + + f.thisIsNotATag(`abc${1}def${2}ghi`); + \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateStringsWithTypedTagsES6.js b/tests/baselines/reference/taggedTemplateStringsWithTypedTagsES6.js new file mode 100644 index 0000000000000..9eefc46ec302c --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithTypedTagsES6.js @@ -0,0 +1,45 @@ +//// [taggedTemplateStringsWithTypedTagsES6.ts] +interface I { + (stringParts: string[], ...rest: number[]): I; + g: I; + h: I; + member: I; + thisIsNotATag(x: string): void + [x: number]: I; +} + +var f: I; + +f `abc` + +f `abc${1}def${2}ghi`; + +f `abc`.member + +f `abc${1}def${2}ghi`.member; + +f `abc`["member"]; + +f `abc${1}def${2}ghi`["member"]; + +f `abc`[0].member `abc${1}def${2}ghi`; + +f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; + +f.thisIsNotATag(`abc`); + +f.thisIsNotATag(`abc${1}def${2}ghi`); + + +//// [taggedTemplateStringsWithTypedTagsES6.js] +var f; +f `abc`; +f `abc${1}def${2}ghi`; +f `abc`.member; +f `abc${1}def${2}ghi`.member; +f `abc`["member"]; +f `abc${1}def${2}ghi`["member"]; +f `abc`[0].member `abc${1}def${2}ghi`; +f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; +f.thisIsNotATag(`abc`); +f.thisIsNotATag(`abc${1}def${2}ghi`); diff --git a/tests/baselines/reference/taggedTemplateStringsWithTypedTagsES6.types b/tests/baselines/reference/taggedTemplateStringsWithTypedTagsES6.types new file mode 100644 index 0000000000000..9745320b39752 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithTypedTagsES6.types @@ -0,0 +1,82 @@ +=== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTagsES6.ts === +interface I { +>I : I + + (stringParts: string[], ...rest: number[]): I; +>stringParts : string[] +>rest : number[] +>I : I + + g: I; +>g : I +>I : I + + h: I; +>h : I +>I : I + + member: I; +>member : I +>I : I + + thisIsNotATag(x: string): void +>thisIsNotATag : (x: string) => void +>x : string + + [x: number]: I; +>x : number +>I : I +} + +var f: I; +>f : I +>I : I + +f `abc` +>f : I + +f `abc${1}def${2}ghi`; +>f : I + +f `abc`.member +>f `abc`.member : any +>f : I +>member : any + +f `abc${1}def${2}ghi`.member; +>f `abc${1}def${2}ghi`.member : any +>f : I +>member : any + +f `abc`["member"]; +>f `abc`["member"] : any +>f : I + +f `abc${1}def${2}ghi`["member"]; +>f `abc${1}def${2}ghi`["member"] : any +>f : I + +f `abc`[0].member `abc${1}def${2}ghi`; +>f `abc`[0].member : any +>f `abc`[0] : any +>f : I +>member : any + +f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; +>f `abc${1}def${2}ghi`["member"].member : any +>f `abc${1}def${2}ghi`["member"] : any +>f : I +>member : any + +f.thisIsNotATag(`abc`); +>f.thisIsNotATag(`abc`) : void +>f.thisIsNotATag : (x: string) => void +>f : I +>thisIsNotATag : (x: string) => void + +f.thisIsNotATag(`abc${1}def${2}ghi`); +>f.thisIsNotATag(`abc${1}def${2}ghi`) : void +>f.thisIsNotATag : (x: string) => void +>f : I +>thisIsNotATag : (x: string) => void + diff --git a/tests/baselines/reference/templateStringInArray.js b/tests/baselines/reference/templateStringInArray.js new file mode 100644 index 0000000000000..97d0b1a636b36 --- /dev/null +++ b/tests/baselines/reference/templateStringInArray.js @@ -0,0 +1,5 @@ +//// [templateStringInArray.ts] +var x = [1, 2, `abc${ 123 }def`]; + +//// [templateStringInArray.js] +var x = [1, 2, ("abc" + 123 + "def")]; diff --git a/tests/baselines/reference/templateStringInArray.types b/tests/baselines/reference/templateStringInArray.types new file mode 100644 index 0000000000000..ef727f59b240e --- /dev/null +++ b/tests/baselines/reference/templateStringInArray.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringInArray.ts === +var x = [1, 2, `abc${ 123 }def`]; +>x : (string | number)[] +>[1, 2, `abc${ 123 }def`] : (string | number)[] + diff --git a/tests/baselines/reference/templateStringInArrowFunction.js b/tests/baselines/reference/templateStringInArrowFunction.js new file mode 100644 index 0000000000000..4c4890633e179 --- /dev/null +++ b/tests/baselines/reference/templateStringInArrowFunction.js @@ -0,0 +1,5 @@ +//// [templateStringInArrowFunction.ts] +var x = x => `abc${ x }def`; + +//// [templateStringInArrowFunction.js] +var x = function (x) { return ("abc" + x + "def"); }; diff --git a/tests/baselines/reference/templateStringInArrowFunction.types b/tests/baselines/reference/templateStringInArrowFunction.types new file mode 100644 index 0000000000000..e17f4d6d2eaf4 --- /dev/null +++ b/tests/baselines/reference/templateStringInArrowFunction.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/templates/templateStringInArrowFunction.ts === +var x = x => `abc${ x }def`; +>x : (x: any) => string +>x => `abc${ x }def` : (x: any) => string +>x : any +>x : unknown + diff --git a/tests/baselines/reference/templateStringInArrowFunctionES6.js b/tests/baselines/reference/templateStringInArrowFunctionES6.js new file mode 100644 index 0000000000000..633b96e9da410 --- /dev/null +++ b/tests/baselines/reference/templateStringInArrowFunctionES6.js @@ -0,0 +1,5 @@ +//// [templateStringInArrowFunctionES6.ts] +var x = x => `abc${ x }def`; + +//// [templateStringInArrowFunctionES6.js] +var x = function (x) { return `abc${x}def`; }; diff --git a/tests/baselines/reference/templateStringInArrowFunctionES6.types b/tests/baselines/reference/templateStringInArrowFunctionES6.types new file mode 100644 index 0000000000000..38fca60e64758 --- /dev/null +++ b/tests/baselines/reference/templateStringInArrowFunctionES6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/templates/templateStringInArrowFunctionES6.ts === +var x = x => `abc${ x }def`; +>x : (x: any) => string +>x => `abc${ x }def` : (x: any) => string +>x : any +>x : unknown + diff --git a/tests/baselines/reference/templateStringInBinaryAddition.js b/tests/baselines/reference/templateStringInBinaryAddition.js new file mode 100644 index 0000000000000..0e1f728005ca1 --- /dev/null +++ b/tests/baselines/reference/templateStringInBinaryAddition.js @@ -0,0 +1,5 @@ +//// [templateStringInBinaryAddition.ts] +var x = 10 + `abc${ 10 }def`; + +//// [templateStringInBinaryAddition.js] +var x = 10 + ("abc" + 10 + "def"); diff --git a/tests/baselines/reference/templateStringInBinaryAddition.types b/tests/baselines/reference/templateStringInBinaryAddition.types new file mode 100644 index 0000000000000..f722ff696f490 --- /dev/null +++ b/tests/baselines/reference/templateStringInBinaryAddition.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringInBinaryAddition.ts === +var x = 10 + `abc${ 10 }def`; +>x : string +>10 + `abc${ 10 }def` : string + diff --git a/tests/baselines/reference/templateStringInBinaryAdditionES6.js b/tests/baselines/reference/templateStringInBinaryAdditionES6.js new file mode 100644 index 0000000000000..7a40d4cc54fa6 --- /dev/null +++ b/tests/baselines/reference/templateStringInBinaryAdditionES6.js @@ -0,0 +1,5 @@ +//// [templateStringInBinaryAdditionES6.ts] +var x = 10 + `abc${ 10 }def`; + +//// [templateStringInBinaryAdditionES6.js] +var x = 10 + `abc${10}def`; diff --git a/tests/baselines/reference/templateStringInBinaryAdditionES6.types b/tests/baselines/reference/templateStringInBinaryAdditionES6.types new file mode 100644 index 0000000000000..b421d7dc70ec9 --- /dev/null +++ b/tests/baselines/reference/templateStringInBinaryAdditionES6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringInBinaryAdditionES6.ts === +var x = 10 + `abc${ 10 }def`; +>x : string +>10 + `abc${ 10 }def` : string + diff --git a/tests/baselines/reference/templateStringInConditional.js b/tests/baselines/reference/templateStringInConditional.js new file mode 100644 index 0000000000000..8ffcf24e5f490 --- /dev/null +++ b/tests/baselines/reference/templateStringInConditional.js @@ -0,0 +1,5 @@ +//// [templateStringInConditional.ts] +var x = `abc${ " " }def` ? `abc${ " " }def` : `abc${ " " }def`; + +//// [templateStringInConditional.js] +var x = "abc" + " " + "def" ? "abc" + " " + "def" : "abc" + " " + "def"; diff --git a/tests/baselines/reference/templateStringInConditional.types b/tests/baselines/reference/templateStringInConditional.types new file mode 100644 index 0000000000000..b4ff36b3891dc --- /dev/null +++ b/tests/baselines/reference/templateStringInConditional.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringInConditional.ts === +var x = `abc${ " " }def` ? `abc${ " " }def` : `abc${ " " }def`; +>x : string +>`abc${ " " }def` ? `abc${ " " }def` : `abc${ " " }def` : string + diff --git a/tests/baselines/reference/templateStringInConditionalES6.js b/tests/baselines/reference/templateStringInConditionalES6.js new file mode 100644 index 0000000000000..d212b5c771751 --- /dev/null +++ b/tests/baselines/reference/templateStringInConditionalES6.js @@ -0,0 +1,5 @@ +//// [templateStringInConditionalES6.ts] +var x = `abc${ " " }def` ? `abc${ " " }def` : `abc${ " " }def`; + +//// [templateStringInConditionalES6.js] +var x = `abc${" "}def` ? `abc${" "}def` : `abc${" "}def`; diff --git a/tests/baselines/reference/templateStringInConditionalES6.types b/tests/baselines/reference/templateStringInConditionalES6.types new file mode 100644 index 0000000000000..c211ced258332 --- /dev/null +++ b/tests/baselines/reference/templateStringInConditionalES6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringInConditionalES6.ts === +var x = `abc${ " " }def` ? `abc${ " " }def` : `abc${ " " }def`; +>x : string +>`abc${ " " }def` ? `abc${ " " }def` : `abc${ " " }def` : string + diff --git a/tests/baselines/reference/templateStringInDeleteExpression.js b/tests/baselines/reference/templateStringInDeleteExpression.js new file mode 100644 index 0000000000000..e8da2e2ba32e2 --- /dev/null +++ b/tests/baselines/reference/templateStringInDeleteExpression.js @@ -0,0 +1,5 @@ +//// [templateStringInDeleteExpression.ts] +delete `abc${0}abc`; + +//// [templateStringInDeleteExpression.js] +delete ("abc" + 0 + "abc"); diff --git a/tests/baselines/reference/templateStringInDeleteExpression.types b/tests/baselines/reference/templateStringInDeleteExpression.types new file mode 100644 index 0000000000000..88693e5a9bbca --- /dev/null +++ b/tests/baselines/reference/templateStringInDeleteExpression.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/templates/templateStringInDeleteExpression.ts === +delete `abc${0}abc`; +>delete `abc${0}abc` : boolean + diff --git a/tests/baselines/reference/templateStringInDeleteExpressionES6.js b/tests/baselines/reference/templateStringInDeleteExpressionES6.js new file mode 100644 index 0000000000000..19f5d51b021f3 --- /dev/null +++ b/tests/baselines/reference/templateStringInDeleteExpressionES6.js @@ -0,0 +1,5 @@ +//// [templateStringInDeleteExpressionES6.ts] +delete `abc${0}abc`; + +//// [templateStringInDeleteExpressionES6.js] +delete `abc${0}abc`; diff --git a/tests/baselines/reference/templateStringInDeleteExpressionES6.types b/tests/baselines/reference/templateStringInDeleteExpressionES6.types new file mode 100644 index 0000000000000..d67d4d8c703b6 --- /dev/null +++ b/tests/baselines/reference/templateStringInDeleteExpressionES6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/templates/templateStringInDeleteExpressionES6.ts === +delete `abc${0}abc`; +>delete `abc${0}abc` : boolean + diff --git a/tests/baselines/reference/templateStringInDivision.errors.txt b/tests/baselines/reference/templateStringInDivision.errors.txt new file mode 100644 index 0000000000000..32cc483039939 --- /dev/null +++ b/tests/baselines/reference/templateStringInDivision.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/templates/templateStringInDivision.ts(1,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/templateStringInDivision.ts (1 errors) ==== + var x = `abc${ 1 }def` / 1; + ~~~~~~~~~~~~~~ +!!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInDivision.js b/tests/baselines/reference/templateStringInDivision.js new file mode 100644 index 0000000000000..d624d73f6bb66 --- /dev/null +++ b/tests/baselines/reference/templateStringInDivision.js @@ -0,0 +1,5 @@ +//// [templateStringInDivision.ts] +var x = `abc${ 1 }def` / 1; + +//// [templateStringInDivision.js] +var x = ("abc" + 1 + "def") / 1; diff --git a/tests/baselines/reference/templateStringInEqualityChecks.js b/tests/baselines/reference/templateStringInEqualityChecks.js new file mode 100644 index 0000000000000..54f5fa610c286 --- /dev/null +++ b/tests/baselines/reference/templateStringInEqualityChecks.js @@ -0,0 +1,8 @@ +//// [templateStringInEqualityChecks.ts] +var x = `abc${0}abc` === `abc` || + `abc` !== `abc${0}abc` && + `abc${0}abc` == "abc0abc" && + "abc0abc" !== `abc${0}abc`; + +//// [templateStringInEqualityChecks.js] +var x = "abc" + 0 + "abc" === "abc" || "abc" !== "abc" + 0 + "abc" && "abc" + 0 + "abc" == "abc0abc" && "abc0abc" !== "abc" + 0 + "abc"; diff --git a/tests/baselines/reference/templateStringInEqualityChecks.types b/tests/baselines/reference/templateStringInEqualityChecks.types new file mode 100644 index 0000000000000..a942d4bce98bd --- /dev/null +++ b/tests/baselines/reference/templateStringInEqualityChecks.types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/es6/templates/templateStringInEqualityChecks.ts === +var x = `abc${0}abc` === `abc` || +>x : boolean +>`abc${0}abc` === `abc` || `abc` !== `abc${0}abc` && `abc${0}abc` == "abc0abc" && "abc0abc" !== `abc${0}abc` : boolean +>`abc${0}abc` === `abc` : boolean + + `abc` !== `abc${0}abc` && +>`abc` !== `abc${0}abc` && `abc${0}abc` == "abc0abc" && "abc0abc" !== `abc${0}abc` : boolean +>`abc` !== `abc${0}abc` && `abc${0}abc` == "abc0abc" : boolean +>`abc` !== `abc${0}abc` : boolean + + `abc${0}abc` == "abc0abc" && +>`abc${0}abc` == "abc0abc" : boolean + + "abc0abc" !== `abc${0}abc`; +>"abc0abc" !== `abc${0}abc` : boolean + diff --git a/tests/baselines/reference/templateStringInEqualityChecksES6.js b/tests/baselines/reference/templateStringInEqualityChecksES6.js new file mode 100644 index 0000000000000..317db1ab366bd --- /dev/null +++ b/tests/baselines/reference/templateStringInEqualityChecksES6.js @@ -0,0 +1,8 @@ +//// [templateStringInEqualityChecksES6.ts] +var x = `abc${0}abc` === `abc` || + `abc` !== `abc${0}abc` && + `abc${0}abc` == "abc0abc" && + "abc0abc" !== `abc${0}abc`; + +//// [templateStringInEqualityChecksES6.js] +var x = `abc${0}abc` === `abc` || `abc` !== `abc${0}abc` && `abc${0}abc` == "abc0abc" && "abc0abc" !== `abc${0}abc`; diff --git a/tests/baselines/reference/templateStringInEqualityChecksES6.types b/tests/baselines/reference/templateStringInEqualityChecksES6.types new file mode 100644 index 0000000000000..ffe300ccd3816 --- /dev/null +++ b/tests/baselines/reference/templateStringInEqualityChecksES6.types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/es6/templates/templateStringInEqualityChecksES6.ts === +var x = `abc${0}abc` === `abc` || +>x : boolean +>`abc${0}abc` === `abc` || `abc` !== `abc${0}abc` && `abc${0}abc` == "abc0abc" && "abc0abc" !== `abc${0}abc` : boolean +>`abc${0}abc` === `abc` : boolean + + `abc` !== `abc${0}abc` && +>`abc` !== `abc${0}abc` && `abc${0}abc` == "abc0abc" && "abc0abc" !== `abc${0}abc` : boolean +>`abc` !== `abc${0}abc` && `abc${0}abc` == "abc0abc" : boolean +>`abc` !== `abc${0}abc` : boolean + + `abc${0}abc` == "abc0abc" && +>`abc${0}abc` == "abc0abc" : boolean + + "abc0abc" !== `abc${0}abc`; +>"abc0abc" !== `abc${0}abc` : boolean + diff --git a/tests/baselines/reference/templateStringInFunctionExpression.js b/tests/baselines/reference/templateStringInFunctionExpression.js new file mode 100644 index 0000000000000..9711b2edc3a36 --- /dev/null +++ b/tests/baselines/reference/templateStringInFunctionExpression.js @@ -0,0 +1,11 @@ +//// [templateStringInFunctionExpression.ts] +var x = function y() { + `abc${ 0 }def` + return `abc${ 0 }def`; +}; + +//// [templateStringInFunctionExpression.js] +var x = function y() { + "abc" + 0 + "def"; + return "abc" + 0 + "def"; +}; diff --git a/tests/baselines/reference/templateStringInFunctionExpression.types b/tests/baselines/reference/templateStringInFunctionExpression.types new file mode 100644 index 0000000000000..1ec389488ec90 --- /dev/null +++ b/tests/baselines/reference/templateStringInFunctionExpression.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/es6/templates/templateStringInFunctionExpression.ts === +var x = function y() { +>x : () => string +>function y() { `abc${ 0 }def` return `abc${ 0 }def`;} : () => string +>y : () => string + + `abc${ 0 }def` + return `abc${ 0 }def`; +}; diff --git a/tests/baselines/reference/templateStringInFunctionExpressionES6.js b/tests/baselines/reference/templateStringInFunctionExpressionES6.js new file mode 100644 index 0000000000000..e7cffe1471b9b --- /dev/null +++ b/tests/baselines/reference/templateStringInFunctionExpressionES6.js @@ -0,0 +1,11 @@ +//// [templateStringInFunctionExpressionES6.ts] +var x = function y() { + `abc${ 0 }def` + return `abc${ 0 }def`; +}; + +//// [templateStringInFunctionExpressionES6.js] +var x = function y() { + `abc${0}def`; + return `abc${0}def`; +}; diff --git a/tests/baselines/reference/templateStringInFunctionExpressionES6.types b/tests/baselines/reference/templateStringInFunctionExpressionES6.types new file mode 100644 index 0000000000000..a31558fbe373e --- /dev/null +++ b/tests/baselines/reference/templateStringInFunctionExpressionES6.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/es6/templates/templateStringInFunctionExpressionES6.ts === +var x = function y() { +>x : () => string +>function y() { `abc${ 0 }def` return `abc${ 0 }def`;} : () => string +>y : () => string + + `abc${ 0 }def` + return `abc${ 0 }def`; +}; diff --git a/tests/baselines/reference/templateStringInFunctionParameterType.errors.txt b/tests/baselines/reference/templateStringInFunctionParameterType.errors.txt new file mode 100644 index 0000000000000..e0c35e3f19fef --- /dev/null +++ b/tests/baselines/reference/templateStringInFunctionParameterType.errors.txt @@ -0,0 +1,20 @@ +tests/cases/conformance/es6/templates/templateStringInFunctionParameterType.ts(1,12): error TS1138: Parameter declaration expected. +tests/cases/conformance/es6/templates/templateStringInFunctionParameterType.ts(1,19): error TS1005: ';' expected. +tests/cases/conformance/es6/templates/templateStringInFunctionParameterType.ts(1,1): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/conformance/es6/templates/templateStringInFunctionParameterType.ts(1,10): error TS2391: Function implementation is missing or not immediately following the declaration. + + +==== tests/cases/conformance/es6/templates/templateStringInFunctionParameterType.ts (4 errors) ==== + function f(`hello`); + ~~~~~~~ +!!! error TS1138: Parameter declaration expected. + ~ +!!! error TS1005: ';' expected. + ~~~~~~~~~~~ +!!! error TS2394: Overload signature is not compatible with function implementation. + ~ +!!! error TS2391: Function implementation is missing or not immediately following the declaration. + function f(x: string); + function f(x: string) { + return x; + } \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInFunctionParameterTypeES6.errors.txt b/tests/baselines/reference/templateStringInFunctionParameterTypeES6.errors.txt new file mode 100644 index 0000000000000..948c9ccc6cd84 --- /dev/null +++ b/tests/baselines/reference/templateStringInFunctionParameterTypeES6.errors.txt @@ -0,0 +1,20 @@ +tests/cases/conformance/es6/templates/templateStringInFunctionParameterTypeES6.ts(1,12): error TS1138: Parameter declaration expected. +tests/cases/conformance/es6/templates/templateStringInFunctionParameterTypeES6.ts(1,19): error TS1005: ';' expected. +tests/cases/conformance/es6/templates/templateStringInFunctionParameterTypeES6.ts(1,1): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/conformance/es6/templates/templateStringInFunctionParameterTypeES6.ts(1,10): error TS2391: Function implementation is missing or not immediately following the declaration. + + +==== tests/cases/conformance/es6/templates/templateStringInFunctionParameterTypeES6.ts (4 errors) ==== + function f(`hello`); + ~~~~~~~ +!!! error TS1138: Parameter declaration expected. + ~ +!!! error TS1005: ';' expected. + ~~~~~~~~~~~ +!!! error TS2394: Overload signature is not compatible with function implementation. + ~ +!!! error TS2391: Function implementation is missing or not immediately following the declaration. + function f(x: string); + function f(x: string) { + return x; + } \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInInOperator.js b/tests/baselines/reference/templateStringInInOperator.js new file mode 100644 index 0000000000000..c496e335dd434 --- /dev/null +++ b/tests/baselines/reference/templateStringInInOperator.js @@ -0,0 +1,5 @@ +//// [templateStringInInOperator.ts] +var x = `${ "hi" }` in { hi: 10, hello: 20}; + +//// [templateStringInInOperator.js] +var x = "" + "hi" in { hi: 10, hello: 20 }; diff --git a/tests/baselines/reference/templateStringInInOperator.types b/tests/baselines/reference/templateStringInInOperator.types new file mode 100644 index 0000000000000..da35bdc499c3c --- /dev/null +++ b/tests/baselines/reference/templateStringInInOperator.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/templates/templateStringInInOperator.ts === +var x = `${ "hi" }` in { hi: 10, hello: 20}; +>x : boolean +>`${ "hi" }` in { hi: 10, hello: 20} : boolean +>{ hi: 10, hello: 20} : { hi: number; hello: number; } +>hi : number +>hello : number + diff --git a/tests/baselines/reference/templateStringInInOperatorES6.js b/tests/baselines/reference/templateStringInInOperatorES6.js new file mode 100644 index 0000000000000..bd4daef3b6d64 --- /dev/null +++ b/tests/baselines/reference/templateStringInInOperatorES6.js @@ -0,0 +1,5 @@ +//// [templateStringInInOperatorES6.ts] +var x = `${ "hi" }` in { hi: 10, hello: 20}; + +//// [templateStringInInOperatorES6.js] +var x = `${"hi"}` in { hi: 10, hello: 20 }; diff --git a/tests/baselines/reference/templateStringInInOperatorES6.types b/tests/baselines/reference/templateStringInInOperatorES6.types new file mode 100644 index 0000000000000..7af0d7a2f480a --- /dev/null +++ b/tests/baselines/reference/templateStringInInOperatorES6.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/templates/templateStringInInOperatorES6.ts === +var x = `${ "hi" }` in { hi: 10, hello: 20}; +>x : boolean +>`${ "hi" }` in { hi: 10, hello: 20} : boolean +>{ hi: 10, hello: 20} : { hi: number; hello: number; } +>hi : number +>hello : number + diff --git a/tests/baselines/reference/templateStringInIndexExpression.js b/tests/baselines/reference/templateStringInIndexExpression.js new file mode 100644 index 0000000000000..680cfb49f47e4 --- /dev/null +++ b/tests/baselines/reference/templateStringInIndexExpression.js @@ -0,0 +1,5 @@ +//// [templateStringInIndexExpression.ts] +`abc${0}abc`[`0`]; + +//// [templateStringInIndexExpression.js] +("abc" + 0 + "abc")["0"]; diff --git a/tests/baselines/reference/templateStringInIndexExpression.types b/tests/baselines/reference/templateStringInIndexExpression.types new file mode 100644 index 0000000000000..a0270b850ab16 --- /dev/null +++ b/tests/baselines/reference/templateStringInIndexExpression.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/templates/templateStringInIndexExpression.ts === +`abc${0}abc`[`0`]; +>`abc${0}abc`[`0`] : any + diff --git a/tests/baselines/reference/templateStringInIndexExpressionES6.js b/tests/baselines/reference/templateStringInIndexExpressionES6.js new file mode 100644 index 0000000000000..c1c87211a0561 --- /dev/null +++ b/tests/baselines/reference/templateStringInIndexExpressionES6.js @@ -0,0 +1,5 @@ +//// [templateStringInIndexExpressionES6.ts] +`abc${0}abc`[`0`]; + +//// [templateStringInIndexExpressionES6.js] +`abc${0}abc`[`0`]; diff --git a/tests/baselines/reference/templateStringInIndexExpressionES6.types b/tests/baselines/reference/templateStringInIndexExpressionES6.types new file mode 100644 index 0000000000000..aceb22da52977 --- /dev/null +++ b/tests/baselines/reference/templateStringInIndexExpressionES6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/templates/templateStringInIndexExpressionES6.ts === +`abc${0}abc`[`0`]; +>`abc${0}abc`[`0`] : any + diff --git a/tests/baselines/reference/templateStringInInstanceOf.errors.txt b/tests/baselines/reference/templateStringInInstanceOf.errors.txt new file mode 100644 index 0000000000000..04d2584712bc5 --- /dev/null +++ b/tests/baselines/reference/templateStringInInstanceOf.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/templates/templateStringInInstanceOf.ts(1,9): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter. + + +==== tests/cases/conformance/es6/templates/templateStringInInstanceOf.ts (1 errors) ==== + var x = `abc${ 0 }def` instanceof String; + ~~~~~~~~~~~~~~ +!!! error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInInstanceOf.js b/tests/baselines/reference/templateStringInInstanceOf.js new file mode 100644 index 0000000000000..ccf022cc70336 --- /dev/null +++ b/tests/baselines/reference/templateStringInInstanceOf.js @@ -0,0 +1,5 @@ +//// [templateStringInInstanceOf.ts] +var x = `abc${ 0 }def` instanceof String; + +//// [templateStringInInstanceOf.js] +var x = "abc" + 0 + "def" instanceof String; diff --git a/tests/baselines/reference/templateStringInInstanceOfES6.errors.txt b/tests/baselines/reference/templateStringInInstanceOfES6.errors.txt new file mode 100644 index 0000000000000..0fc8c81ab924c --- /dev/null +++ b/tests/baselines/reference/templateStringInInstanceOfES6.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/templates/templateStringInInstanceOfES6.ts(1,9): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter. + + +==== tests/cases/conformance/es6/templates/templateStringInInstanceOfES6.ts (1 errors) ==== + var x = `abc${ 0 }def` instanceof String; + ~~~~~~~~~~~~~~ +!!! error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInInstanceOfES6.js b/tests/baselines/reference/templateStringInInstanceOfES6.js new file mode 100644 index 0000000000000..793c183d13765 --- /dev/null +++ b/tests/baselines/reference/templateStringInInstanceOfES6.js @@ -0,0 +1,5 @@ +//// [templateStringInInstanceOfES6.ts] +var x = `abc${ 0 }def` instanceof String; + +//// [templateStringInInstanceOfES6.js] +var x = `abc${0}def` instanceof String; diff --git a/tests/baselines/reference/templateStringInModuleName.errors.txt b/tests/baselines/reference/templateStringInModuleName.errors.txt new file mode 100644 index 0000000000000..8b5e4eb8e1401 --- /dev/null +++ b/tests/baselines/reference/templateStringInModuleName.errors.txt @@ -0,0 +1,38 @@ +tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,9): error TS1005: ';' expected. +tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,21): error TS1005: ';' expected. +tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,9): error TS1005: ';' expected. +tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,24): error TS1005: ';' expected. +tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,1): error TS2304: Cannot find name 'declare'. +tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,9): error TS2304: Cannot find name 'module'. +tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,1): error TS2304: Cannot find name 'declare'. +tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,9): error TS2304: Cannot find name 'module'. + + +==== tests/cases/conformance/es6/templates/templateStringInModuleName.ts (10 errors) ==== + declare module `M1` { + ~~~~~~ +!!! error TS1005: ';' expected. + ~~~~~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + ~ +!!! error TS1005: ';' expected. + ~~~~~~~ +!!! error TS2304: Cannot find name 'declare'. + ~~~~~~ +!!! error TS2304: Cannot find name 'module'. + } + + declare module `M${2}` { + ~~~~~~ +!!! error TS1005: ';' expected. + ~~~~~~~~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + ~ +!!! error TS1005: ';' expected. + ~~~~~~~ +!!! error TS2304: Cannot find name 'declare'. + ~~~~~~ +!!! error TS2304: Cannot find name 'module'. + } \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInModuleNameES6.errors.txt b/tests/baselines/reference/templateStringInModuleNameES6.errors.txt new file mode 100644 index 0000000000000..228fd32357ce7 --- /dev/null +++ b/tests/baselines/reference/templateStringInModuleNameES6.errors.txt @@ -0,0 +1,32 @@ +tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(1,9): error TS1005: ';' expected. +tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(1,21): error TS1005: ';' expected. +tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(4,9): error TS1005: ';' expected. +tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(4,24): error TS1005: ';' expected. +tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(1,1): error TS2304: Cannot find name 'declare'. +tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(1,9): error TS2304: Cannot find name 'module'. +tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(4,1): error TS2304: Cannot find name 'declare'. +tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts(4,9): error TS2304: Cannot find name 'module'. + + +==== tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts (8 errors) ==== + declare module `M1` { + ~~~~~~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1005: ';' expected. + ~~~~~~~ +!!! error TS2304: Cannot find name 'declare'. + ~~~~~~ +!!! error TS2304: Cannot find name 'module'. + } + + declare module `M${2}` { + ~~~~~~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1005: ';' expected. + ~~~~~~~ +!!! error TS2304: Cannot find name 'declare'. + ~~~~~~ +!!! error TS2304: Cannot find name 'module'. + } \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInModulo.errors.txt b/tests/baselines/reference/templateStringInModulo.errors.txt new file mode 100644 index 0000000000000..f9f0b0257d66a --- /dev/null +++ b/tests/baselines/reference/templateStringInModulo.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/templates/templateStringInModulo.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/templateStringInModulo.ts (1 errors) ==== + var x = 1 % `abc${ 1 }def`; + ~~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInModulo.js b/tests/baselines/reference/templateStringInModulo.js new file mode 100644 index 0000000000000..65d5ec7eaab3a --- /dev/null +++ b/tests/baselines/reference/templateStringInModulo.js @@ -0,0 +1,5 @@ +//// [templateStringInModulo.ts] +var x = 1 % `abc${ 1 }def`; + +//// [templateStringInModulo.js] +var x = 1 % ("abc" + 1 + "def"); diff --git a/tests/baselines/reference/templateStringInModuloES6.errors.txt b/tests/baselines/reference/templateStringInModuloES6.errors.txt new file mode 100644 index 0000000000000..db410876b9153 --- /dev/null +++ b/tests/baselines/reference/templateStringInModuloES6.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/templates/templateStringInModuloES6.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/templateStringInModuloES6.ts (1 errors) ==== + var x = 1 % `abc${ 1 }def`; + ~~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInModuloES6.js b/tests/baselines/reference/templateStringInModuloES6.js new file mode 100644 index 0000000000000..2fae209b85fd0 --- /dev/null +++ b/tests/baselines/reference/templateStringInModuloES6.js @@ -0,0 +1,5 @@ +//// [templateStringInModuloES6.ts] +var x = 1 % `abc${ 1 }def`; + +//// [templateStringInModuloES6.js] +var x = 1 % `abc${1}def`; diff --git a/tests/baselines/reference/templateStringInMultiplication.errors.txt b/tests/baselines/reference/templateStringInMultiplication.errors.txt new file mode 100644 index 0000000000000..11a4ea9985e90 --- /dev/null +++ b/tests/baselines/reference/templateStringInMultiplication.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/templates/templateStringInMultiplication.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/templateStringInMultiplication.ts (1 errors) ==== + var x = 1 * `abc${ 1 }def`; + ~~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInMultiplication.js b/tests/baselines/reference/templateStringInMultiplication.js new file mode 100644 index 0000000000000..e48db6e1715a8 --- /dev/null +++ b/tests/baselines/reference/templateStringInMultiplication.js @@ -0,0 +1,5 @@ +//// [templateStringInMultiplication.ts] +var x = 1 * `abc${ 1 }def`; + +//// [templateStringInMultiplication.js] +var x = 1 * ("abc" + 1 + "def"); diff --git a/tests/baselines/reference/templateStringInMultiplicationES6.errors.txt b/tests/baselines/reference/templateStringInMultiplicationES6.errors.txt new file mode 100644 index 0000000000000..ee27091778f31 --- /dev/null +++ b/tests/baselines/reference/templateStringInMultiplicationES6.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/templates/templateStringInMultiplicationES6.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/templateStringInMultiplicationES6.ts (1 errors) ==== + var x = 1 * `abc${ 1 }def`; + ~~~~~~~~~~~~~~ +!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInMultiplicationES6.js b/tests/baselines/reference/templateStringInMultiplicationES6.js new file mode 100644 index 0000000000000..f890e900301ea --- /dev/null +++ b/tests/baselines/reference/templateStringInMultiplicationES6.js @@ -0,0 +1,5 @@ +//// [templateStringInMultiplicationES6.ts] +var x = 1 * `abc${ 1 }def`; + +//// [templateStringInMultiplicationES6.js] +var x = 1 * `abc${1}def`; diff --git a/tests/baselines/reference/templateStringInNewOperator.errors.txt b/tests/baselines/reference/templateStringInNewOperator.errors.txt new file mode 100644 index 0000000000000..eed7415e5d25e --- /dev/null +++ b/tests/baselines/reference/templateStringInNewOperator.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/templates/templateStringInNewOperator.ts(1,9): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. + + +==== tests/cases/conformance/es6/templates/templateStringInNewOperator.ts (1 errors) ==== + var x = new `abc${ 1 }def`; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInNewOperator.js b/tests/baselines/reference/templateStringInNewOperator.js new file mode 100644 index 0000000000000..8d76d59f7eecb --- /dev/null +++ b/tests/baselines/reference/templateStringInNewOperator.js @@ -0,0 +1,5 @@ +//// [templateStringInNewOperator.ts] +var x = new `abc${ 1 }def`; + +//// [templateStringInNewOperator.js] +var x = new ("abc" + 1 + "def"); diff --git a/tests/baselines/reference/templateStringInNewOperatorES6.errors.txt b/tests/baselines/reference/templateStringInNewOperatorES6.errors.txt new file mode 100644 index 0000000000000..f4363d9ff2056 --- /dev/null +++ b/tests/baselines/reference/templateStringInNewOperatorES6.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/templates/templateStringInNewOperatorES6.ts(1,9): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. + + +==== tests/cases/conformance/es6/templates/templateStringInNewOperatorES6.ts (1 errors) ==== + var x = new `abc${ 1 }def`; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInNewOperatorES6.js b/tests/baselines/reference/templateStringInNewOperatorES6.js new file mode 100644 index 0000000000000..066978f736b41 --- /dev/null +++ b/tests/baselines/reference/templateStringInNewOperatorES6.js @@ -0,0 +1,5 @@ +//// [templateStringInNewOperatorES6.ts] +var x = new `abc${ 1 }def`; + +//// [templateStringInNewOperatorES6.js] +var x = new `abc${1}def`; diff --git a/tests/baselines/reference/templateStringInObjectLiteral.errors.txt b/tests/baselines/reference/templateStringInObjectLiteral.errors.txt new file mode 100644 index 0000000000000..8604338d6788a --- /dev/null +++ b/tests/baselines/reference/templateStringInObjectLiteral.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts(1,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts(3,5): error TS1136: Property assignment expected. +tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts(3,8): error TS1005: ',' expected. +tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts(3,10): error TS1134: Variable declaration expected. +tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts(4,1): error TS1128: Declaration or statement expected. + + +==== tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts (5 errors) ==== + var x = { + ~ + a: `abc${ 123 }def`, + ~~~~~~~~~~~~~~~~~~~~~~~~ + `b`: 321 + ~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + ~~~ +!!! error TS1136: Property assignment expected. + ~ +!!! error TS1005: ',' expected. + ~~~ +!!! error TS1134: Variable declaration expected. + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInObjectLiteralES6.errors.txt b/tests/baselines/reference/templateStringInObjectLiteralES6.errors.txt new file mode 100644 index 0000000000000..ae21ecd4739c7 --- /dev/null +++ b/tests/baselines/reference/templateStringInObjectLiteralES6.errors.txt @@ -0,0 +1,19 @@ +tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts(3,5): error TS1136: Property assignment expected. +tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts(3,8): error TS1005: ',' expected. +tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts(3,10): error TS1134: Variable declaration expected. +tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts(4,1): error TS1128: Declaration or statement expected. + + +==== tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts (4 errors) ==== + var x = { + a: `abc${ 123 }def`, + `b`: 321 + ~~~ +!!! error TS1136: Property assignment expected. + ~ +!!! error TS1005: ',' expected. + ~~~ +!!! error TS1134: Variable declaration expected. + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInParentheses.js b/tests/baselines/reference/templateStringInParentheses.js new file mode 100644 index 0000000000000..6c5c678bf4e85 --- /dev/null +++ b/tests/baselines/reference/templateStringInParentheses.js @@ -0,0 +1,5 @@ +//// [templateStringInParentheses.ts] +var x = (`abc${0}abc`); + +//// [templateStringInParentheses.js] +var x = ("abc" + 0 + "abc"); diff --git a/tests/baselines/reference/templateStringInParentheses.types b/tests/baselines/reference/templateStringInParentheses.types new file mode 100644 index 0000000000000..7e597dc01088c --- /dev/null +++ b/tests/baselines/reference/templateStringInParentheses.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringInParentheses.ts === +var x = (`abc${0}abc`); +>x : string +>(`abc${0}abc`) : string + diff --git a/tests/baselines/reference/templateStringInParenthesesES6.js b/tests/baselines/reference/templateStringInParenthesesES6.js new file mode 100644 index 0000000000000..0776ea594d292 --- /dev/null +++ b/tests/baselines/reference/templateStringInParenthesesES6.js @@ -0,0 +1,5 @@ +//// [templateStringInParenthesesES6.ts] +var x = (`abc${0}abc`); + +//// [templateStringInParenthesesES6.js] +var x = (`abc${0}abc`); diff --git a/tests/baselines/reference/templateStringInParenthesesES6.types b/tests/baselines/reference/templateStringInParenthesesES6.types new file mode 100644 index 0000000000000..3afb3530dee74 --- /dev/null +++ b/tests/baselines/reference/templateStringInParenthesesES6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringInParenthesesES6.ts === +var x = (`abc${0}abc`); +>x : string +>(`abc${0}abc`) : string + diff --git a/tests/baselines/reference/templateStringInPropertyAssignment.js b/tests/baselines/reference/templateStringInPropertyAssignment.js new file mode 100644 index 0000000000000..99fb24712c017 --- /dev/null +++ b/tests/baselines/reference/templateStringInPropertyAssignment.js @@ -0,0 +1,9 @@ +//// [templateStringInPropertyAssignment.ts] +var x = { + a: `abc${ 123 }def${ 456 }ghi` +} + +//// [templateStringInPropertyAssignment.js] +var x = { + a: "abc" + 123 + "def" + 456 + "ghi" +}; diff --git a/tests/baselines/reference/templateStringInPropertyAssignment.types b/tests/baselines/reference/templateStringInPropertyAssignment.types new file mode 100644 index 0000000000000..ff5ecb410db04 --- /dev/null +++ b/tests/baselines/reference/templateStringInPropertyAssignment.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/templates/templateStringInPropertyAssignment.ts === +var x = { +>x : { a: string; } +>{ a: `abc${ 123 }def${ 456 }ghi`} : { a: string; } + + a: `abc${ 123 }def${ 456 }ghi` +>a : string +} diff --git a/tests/baselines/reference/templateStringInPropertyAssignmentES6.js b/tests/baselines/reference/templateStringInPropertyAssignmentES6.js new file mode 100644 index 0000000000000..fc35c0a831a2c --- /dev/null +++ b/tests/baselines/reference/templateStringInPropertyAssignmentES6.js @@ -0,0 +1,9 @@ +//// [templateStringInPropertyAssignmentES6.ts] +var x = { + a: `abc${ 123 }def${ 456 }ghi` +} + +//// [templateStringInPropertyAssignmentES6.js] +var x = { + a: `abc${123}def${456}ghi` +}; diff --git a/tests/baselines/reference/templateStringInPropertyAssignmentES6.types b/tests/baselines/reference/templateStringInPropertyAssignmentES6.types new file mode 100644 index 0000000000000..fafc9f12a482e --- /dev/null +++ b/tests/baselines/reference/templateStringInPropertyAssignmentES6.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/templates/templateStringInPropertyAssignmentES6.ts === +var x = { +>x : { a: string; } +>{ a: `abc${ 123 }def${ 456 }ghi`} : { a: string; } + + a: `abc${ 123 }def${ 456 }ghi` +>a : string +} diff --git a/tests/baselines/reference/templateStringInPropertyName1.errors.txt b/tests/baselines/reference/templateStringInPropertyName1.errors.txt new file mode 100644 index 0000000000000..0e7dc998046b4 --- /dev/null +++ b/tests/baselines/reference/templateStringInPropertyName1.errors.txt @@ -0,0 +1,22 @@ +tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts(1,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts(2,5): error TS1136: Property assignment expected. +tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts(2,8): error TS1005: ',' expected. +tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts(2,10): error TS1134: Variable declaration expected. +tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts(3,1): error TS1128: Declaration or statement expected. + + +==== tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts (5 errors) ==== + var x = { + ~ + `a`: 321 + ~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + ~~~ +!!! error TS1136: Property assignment expected. + ~ +!!! error TS1005: ',' expected. + ~~~ +!!! error TS1134: Variable declaration expected. + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInPropertyName2.errors.txt b/tests/baselines/reference/templateStringInPropertyName2.errors.txt new file mode 100644 index 0000000000000..a20d09f401f63 --- /dev/null +++ b/tests/baselines/reference/templateStringInPropertyName2.errors.txt @@ -0,0 +1,22 @@ +tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts(1,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts(2,5): error TS1136: Property assignment expected. +tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts(2,32): error TS1005: ',' expected. +tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts(2,34): error TS1134: Variable declaration expected. +tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts(3,1): error TS1128: Declaration or statement expected. + + +==== tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts (5 errors) ==== + var x = { + ~ + `abc${ 123 }def${ 456 }ghi`: 321 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + ~~~~~~ +!!! error TS1136: Property assignment expected. + ~ +!!! error TS1005: ',' expected. + ~~~ +!!! error TS1134: Variable declaration expected. + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInPropertyNameES6_1.errors.txt b/tests/baselines/reference/templateStringInPropertyNameES6_1.errors.txt new file mode 100644 index 0000000000000..b45de2faaa1d8 --- /dev/null +++ b/tests/baselines/reference/templateStringInPropertyNameES6_1.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts(2,5): error TS1136: Property assignment expected. +tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts(2,8): error TS1005: ',' expected. +tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts(2,10): error TS1134: Variable declaration expected. +tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts(3,1): error TS1128: Declaration or statement expected. + + +==== tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts (4 errors) ==== + var x = { + `a`: 321 + ~~~ +!!! error TS1136: Property assignment expected. + ~ +!!! error TS1005: ',' expected. + ~~~ +!!! error TS1134: Variable declaration expected. + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInPropertyNameES6_2.errors.txt b/tests/baselines/reference/templateStringInPropertyNameES6_2.errors.txt new file mode 100644 index 0000000000000..6b28fe2c71c06 --- /dev/null +++ b/tests/baselines/reference/templateStringInPropertyNameES6_2.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts(2,5): error TS1136: Property assignment expected. +tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts(2,32): error TS1005: ',' expected. +tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts(2,34): error TS1134: Variable declaration expected. +tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts(3,1): error TS1128: Declaration or statement expected. + + +==== tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts (4 errors) ==== + var x = { + `abc${ 123 }def${ 456 }ghi`: 321 + ~~~~~~ +!!! error TS1136: Property assignment expected. + ~ +!!! error TS1005: ',' expected. + ~~~ +!!! error TS1134: Variable declaration expected. + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInSwitchAndCase.js b/tests/baselines/reference/templateStringInSwitchAndCase.js new file mode 100644 index 0000000000000..67f182f8012d3 --- /dev/null +++ b/tests/baselines/reference/templateStringInSwitchAndCase.js @@ -0,0 +1,15 @@ +//// [templateStringInSwitchAndCase.ts] +switch (`abc${0}abc`) { + case `abc`: + case `123`: + case `abc${0}abc`: + `def${1}def`; +} + +//// [templateStringInSwitchAndCase.js] +switch ("abc" + 0 + "abc") { + case "abc": + case "123": + case "abc" + 0 + "abc": + "def" + 1 + "def"; +} diff --git a/tests/baselines/reference/templateStringInSwitchAndCase.types b/tests/baselines/reference/templateStringInSwitchAndCase.types new file mode 100644 index 0000000000000..26ec05dbca6f3 --- /dev/null +++ b/tests/baselines/reference/templateStringInSwitchAndCase.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/templates/templateStringInSwitchAndCase.ts === +switch (`abc${0}abc`) { +No type information for this code. case `abc`: +No type information for this code. case `123`: +No type information for this code. case `abc${0}abc`: +No type information for this code. `def${1}def`; +No type information for this code.} +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInSwitchAndCaseES6.js b/tests/baselines/reference/templateStringInSwitchAndCaseES6.js new file mode 100644 index 0000000000000..b52cb48cfdec3 --- /dev/null +++ b/tests/baselines/reference/templateStringInSwitchAndCaseES6.js @@ -0,0 +1,15 @@ +//// [templateStringInSwitchAndCaseES6.ts] +switch (`abc${0}abc`) { + case `abc`: + case `123`: + case `abc${0}abc`: + `def${1}def`; +} + +//// [templateStringInSwitchAndCaseES6.js] +switch (`abc${0}abc`) { + case `abc`: + case `123`: + case `abc${0}abc`: + `def${1}def`; +} diff --git a/tests/baselines/reference/templateStringInSwitchAndCaseES6.types b/tests/baselines/reference/templateStringInSwitchAndCaseES6.types new file mode 100644 index 0000000000000..6bd8772ff4942 --- /dev/null +++ b/tests/baselines/reference/templateStringInSwitchAndCaseES6.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/templates/templateStringInSwitchAndCaseES6.ts === +switch (`abc${0}abc`) { +No type information for this code. case `abc`: +No type information for this code. case `123`: +No type information for this code. case `abc${0}abc`: +No type information for this code. `def${1}def`; +No type information for this code.} +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInTypeAssertion.js b/tests/baselines/reference/templateStringInTypeAssertion.js new file mode 100644 index 0000000000000..94533248b6d43 --- /dev/null +++ b/tests/baselines/reference/templateStringInTypeAssertion.js @@ -0,0 +1,5 @@ +//// [templateStringInTypeAssertion.ts] +var x = `abc${ 123 }def`; + +//// [templateStringInTypeAssertion.js] +var x = ("abc" + 123 + "def"); diff --git a/tests/baselines/reference/templateStringInTypeAssertion.types b/tests/baselines/reference/templateStringInTypeAssertion.types new file mode 100644 index 0000000000000..006ba12c1c6e7 --- /dev/null +++ b/tests/baselines/reference/templateStringInTypeAssertion.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringInTypeAssertion.ts === +var x = `abc${ 123 }def`; +>x : any +>`abc${ 123 }def` : any + diff --git a/tests/baselines/reference/templateStringInTypeAssertionES6.js b/tests/baselines/reference/templateStringInTypeAssertionES6.js new file mode 100644 index 0000000000000..08331911c7d84 --- /dev/null +++ b/tests/baselines/reference/templateStringInTypeAssertionES6.js @@ -0,0 +1,5 @@ +//// [templateStringInTypeAssertionES6.ts] +var x = `abc${ 123 }def`; + +//// [templateStringInTypeAssertionES6.js] +var x = `abc${123}def`; diff --git a/tests/baselines/reference/templateStringInTypeAssertionES6.types b/tests/baselines/reference/templateStringInTypeAssertionES6.types new file mode 100644 index 0000000000000..26d7ccc2e6000 --- /dev/null +++ b/tests/baselines/reference/templateStringInTypeAssertionES6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringInTypeAssertionES6.ts === +var x = `abc${ 123 }def`; +>x : any +>`abc${ 123 }def` : any + diff --git a/tests/baselines/reference/templateStringInTypeOf.js b/tests/baselines/reference/templateStringInTypeOf.js new file mode 100644 index 0000000000000..2543091df8831 --- /dev/null +++ b/tests/baselines/reference/templateStringInTypeOf.js @@ -0,0 +1,5 @@ +//// [templateStringInTypeOf.ts] +var x = typeof `abc${ 123 }def`; + +//// [templateStringInTypeOf.js] +var x = typeof ("abc" + 123 + "def"); diff --git a/tests/baselines/reference/templateStringInTypeOf.types b/tests/baselines/reference/templateStringInTypeOf.types new file mode 100644 index 0000000000000..8b94bc7ea1a16 --- /dev/null +++ b/tests/baselines/reference/templateStringInTypeOf.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringInTypeOf.ts === +var x = typeof `abc${ 123 }def`; +>x : string +>typeof `abc${ 123 }def` : string + diff --git a/tests/baselines/reference/templateStringInTypeOfES6.js b/tests/baselines/reference/templateStringInTypeOfES6.js new file mode 100644 index 0000000000000..e8566277449d6 --- /dev/null +++ b/tests/baselines/reference/templateStringInTypeOfES6.js @@ -0,0 +1,5 @@ +//// [templateStringInTypeOfES6.ts] +var x = typeof `abc${ 123 }def`; + +//// [templateStringInTypeOfES6.js] +var x = typeof `abc${123}def`; diff --git a/tests/baselines/reference/templateStringInTypeOfES6.types b/tests/baselines/reference/templateStringInTypeOfES6.types new file mode 100644 index 0000000000000..457af8de0de4d --- /dev/null +++ b/tests/baselines/reference/templateStringInTypeOfES6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringInTypeOfES6.ts === +var x = typeof `abc${ 123 }def`; +>x : string +>typeof `abc${ 123 }def` : string + diff --git a/tests/baselines/reference/templateStringInUnaryPlus.js b/tests/baselines/reference/templateStringInUnaryPlus.js new file mode 100644 index 0000000000000..83f107b3ac2fd --- /dev/null +++ b/tests/baselines/reference/templateStringInUnaryPlus.js @@ -0,0 +1,5 @@ +//// [templateStringInUnaryPlus.ts] +var x = +`abc${ 123 }def`; + +//// [templateStringInUnaryPlus.js] +var x = +("abc" + 123 + "def"); diff --git a/tests/baselines/reference/templateStringInUnaryPlus.types b/tests/baselines/reference/templateStringInUnaryPlus.types new file mode 100644 index 0000000000000..4746f2c1fc7b0 --- /dev/null +++ b/tests/baselines/reference/templateStringInUnaryPlus.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringInUnaryPlus.ts === +var x = +`abc${ 123 }def`; +>x : number +>+`abc${ 123 }def` : number + diff --git a/tests/baselines/reference/templateStringInUnaryPlusES6.js b/tests/baselines/reference/templateStringInUnaryPlusES6.js new file mode 100644 index 0000000000000..efeed300f7c97 --- /dev/null +++ b/tests/baselines/reference/templateStringInUnaryPlusES6.js @@ -0,0 +1,5 @@ +//// [templateStringInUnaryPlusES6.ts] +var x = +`abc${ 123 }def`; + +//// [templateStringInUnaryPlusES6.js] +var x = +`abc${123}def`; diff --git a/tests/baselines/reference/templateStringInUnaryPlusES6.types b/tests/baselines/reference/templateStringInUnaryPlusES6.types new file mode 100644 index 0000000000000..67ad03fc53cb1 --- /dev/null +++ b/tests/baselines/reference/templateStringInUnaryPlusES6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringInUnaryPlusES6.ts === +var x = +`abc${ 123 }def`; +>x : number +>+`abc${ 123 }def` : number + diff --git a/tests/baselines/reference/templateStringInWhile.js b/tests/baselines/reference/templateStringInWhile.js new file mode 100644 index 0000000000000..31f7dba45d1da --- /dev/null +++ b/tests/baselines/reference/templateStringInWhile.js @@ -0,0 +1,9 @@ +//// [templateStringInWhile.ts] +while (`abc${0}abc`) { + `def${1}def`; +} + +//// [templateStringInWhile.js] +while ("abc" + 0 + "abc") { + "def" + 1 + "def"; +} diff --git a/tests/baselines/reference/templateStringInWhile.types b/tests/baselines/reference/templateStringInWhile.types new file mode 100644 index 0000000000000..1b080f31f1ca7 --- /dev/null +++ b/tests/baselines/reference/templateStringInWhile.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringInWhile.ts === +while (`abc${0}abc`) { +No type information for this code. `def${1}def`; +No type information for this code.} +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInWhileES6.js b/tests/baselines/reference/templateStringInWhileES6.js new file mode 100644 index 0000000000000..a4f19b80d0a6d --- /dev/null +++ b/tests/baselines/reference/templateStringInWhileES6.js @@ -0,0 +1,9 @@ +//// [templateStringInWhileES6.ts] +while (`abc${0}abc`) { + `def${1}def`; +} + +//// [templateStringInWhileES6.js] +while (`abc${0}abc`) { + `def${1}def`; +} diff --git a/tests/baselines/reference/templateStringInWhileES6.types b/tests/baselines/reference/templateStringInWhileES6.types new file mode 100644 index 0000000000000..d4ef3b02fe245 --- /dev/null +++ b/tests/baselines/reference/templateStringInWhileES6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringInWhileES6.ts === +while (`abc${0}abc`) { +No type information for this code. `def${1}def`; +No type information for this code.} +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInYieldKeyword.errors.txt b/tests/baselines/reference/templateStringInYieldKeyword.errors.txt new file mode 100644 index 0000000000000..be6fccbe1bcbe --- /dev/null +++ b/tests/baselines/reference/templateStringInYieldKeyword.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(1,9): error TS1003: Identifier expected. +tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(1,15): error TS1005: ';' expected. +tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(3,13): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(1,11): error TS2304: Cannot find name 'gen'. +tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(3,13): error TS2304: Cannot find name 'yield'. + + +==== tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts (5 errors) ==== + function* gen { + ~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS1005: ';' expected. + ~~~ +!!! error TS2304: Cannot find name 'gen'. + // Once this is supported, the inner expression does not need to be parenthesized. + var x = yield `abc${ x }def`; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + ~~~~~ +!!! error TS2304: Cannot find name 'yield'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/templateStringWithEmbeddedAddition.js b/tests/baselines/reference/templateStringWithEmbeddedAddition.js new file mode 100644 index 0000000000000..2cf74941600fd --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedAddition.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedAddition.ts] +var x = `abc${ 10 + 10 }def`; + +//// [templateStringWithEmbeddedAddition.js] +var x = "abc" + (10 + 10) + "def"; diff --git a/tests/baselines/reference/templateStringWithEmbeddedAddition.types b/tests/baselines/reference/templateStringWithEmbeddedAddition.types new file mode 100644 index 0000000000000..3a6bf864cb63e --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedAddition.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedAddition.ts === +var x = `abc${ 10 + 10 }def`; +>x : string +>10 + 10 : number + diff --git a/tests/baselines/reference/templateStringWithEmbeddedAdditionES6.js b/tests/baselines/reference/templateStringWithEmbeddedAdditionES6.js new file mode 100644 index 0000000000000..72beea32d5720 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedAdditionES6.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedAdditionES6.ts] +var x = `abc${ 10 + 10 }def`; + +//// [templateStringWithEmbeddedAdditionES6.js] +var x = `abc${10 + 10}def`; diff --git a/tests/baselines/reference/templateStringWithEmbeddedAdditionES6.types b/tests/baselines/reference/templateStringWithEmbeddedAdditionES6.types new file mode 100644 index 0000000000000..699162a378389 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedAdditionES6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedAdditionES6.ts === +var x = `abc${ 10 + 10 }def`; +>x : string +>10 + 10 : number + diff --git a/tests/baselines/reference/templateStringWithEmbeddedArray.js b/tests/baselines/reference/templateStringWithEmbeddedArray.js new file mode 100644 index 0000000000000..1fb6512db478b --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedArray.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedArray.ts] +var x = `abc${ [1,2,3] }def`; + +//// [templateStringWithEmbeddedArray.js] +var x = "abc" + [1, 2, 3] + "def"; diff --git a/tests/baselines/reference/templateStringWithEmbeddedArray.types b/tests/baselines/reference/templateStringWithEmbeddedArray.types new file mode 100644 index 0000000000000..4c022d8a4014b --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedArray.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedArray.ts === +var x = `abc${ [1,2,3] }def`; +>x : string +>[1,2,3] : number[] + diff --git a/tests/baselines/reference/templateStringWithEmbeddedArrayES6.js b/tests/baselines/reference/templateStringWithEmbeddedArrayES6.js new file mode 100644 index 0000000000000..804ef7a4e78ae --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedArrayES6.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedArrayES6.ts] +var x = `abc${ [1,2,3] }def`; + +//// [templateStringWithEmbeddedArrayES6.js] +var x = `abc${[1, 2, 3]}def`; diff --git a/tests/baselines/reference/templateStringWithEmbeddedArrayES6.types b/tests/baselines/reference/templateStringWithEmbeddedArrayES6.types new file mode 100644 index 0000000000000..06876fa3f0e51 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedArrayES6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedArrayES6.ts === +var x = `abc${ [1,2,3] }def`; +>x : string +>[1,2,3] : number[] + diff --git a/tests/baselines/reference/templateStringWithEmbeddedArrowFunction.js b/tests/baselines/reference/templateStringWithEmbeddedArrowFunction.js new file mode 100644 index 0000000000000..eb2579b0cc32b --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedArrowFunction.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedArrowFunction.ts] +var x = `abc${ x => x }def`; + +//// [templateStringWithEmbeddedArrowFunction.js] +var x = "abc" + function (x) { return x; } + "def"; diff --git a/tests/baselines/reference/templateStringWithEmbeddedArrowFunction.types b/tests/baselines/reference/templateStringWithEmbeddedArrowFunction.types new file mode 100644 index 0000000000000..d6f25761999fb --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedArrowFunction.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedArrowFunction.ts === +var x = `abc${ x => x }def`; +>x : string +>x => x : (x: any) => any +>x : any +>x : any + diff --git a/tests/baselines/reference/templateStringWithEmbeddedArrowFunctionES6.js b/tests/baselines/reference/templateStringWithEmbeddedArrowFunctionES6.js new file mode 100644 index 0000000000000..f6f068aaa371c --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedArrowFunctionES6.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedArrowFunctionES6.ts] +var x = `abc${ x => x }def`; + +//// [templateStringWithEmbeddedArrowFunctionES6.js] +var x = `abc${function (x) { return x; }}def`; diff --git a/tests/baselines/reference/templateStringWithEmbeddedArrowFunctionES6.types b/tests/baselines/reference/templateStringWithEmbeddedArrowFunctionES6.types new file mode 100644 index 0000000000000..748f457f22bbc --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedArrowFunctionES6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedArrowFunctionES6.ts === +var x = `abc${ x => x }def`; +>x : string +>x => x : (x: any) => any +>x : any +>x : any + diff --git a/tests/baselines/reference/templateStringWithEmbeddedComments.js b/tests/baselines/reference/templateStringWithEmbeddedComments.js new file mode 100644 index 0000000000000..58a73e89ba7a2 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedComments.js @@ -0,0 +1,16 @@ +//// [templateStringWithEmbeddedComments.ts] +`head${ // single line comment +10 +} +middle${ +/* Multi- + * line + * comment + */ + 20 + // closing comment +} +tail`; + +//// [templateStringWithEmbeddedComments.js] +"head" + 10 + "\nmiddle" + 20 + "\ntail"; diff --git a/tests/baselines/reference/templateStringWithEmbeddedComments.types b/tests/baselines/reference/templateStringWithEmbeddedComments.types new file mode 100644 index 0000000000000..a375ef6ab6ff4 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedComments.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedComments.ts === +`head${ // single line comment +No type information for this code.10 +No type information for this code.} +No type information for this code.middle${ +No type information for this code./* Multi- +No type information for this code. * line +No type information for this code. * comment +No type information for this code. */ +No type information for this code. 20 +No type information for this code. // closing comment +No type information for this code.} +No type information for this code.tail`; +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringWithEmbeddedCommentsES6.js b/tests/baselines/reference/templateStringWithEmbeddedCommentsES6.js new file mode 100644 index 0000000000000..c6b3649ad2aed --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedCommentsES6.js @@ -0,0 +1,16 @@ +//// [templateStringWithEmbeddedCommentsES6.ts] +`head${ // single line comment +10 +} +middle${ +/* Multi- + * line + * comment + */ + 20 + // closing comment +} +tail`; + +//// [templateStringWithEmbeddedCommentsES6.js] +"head" + 10 + "\nmiddle" + 20 + "\ntail"; diff --git a/tests/baselines/reference/templateStringWithEmbeddedCommentsES6.types b/tests/baselines/reference/templateStringWithEmbeddedCommentsES6.types new file mode 100644 index 0000000000000..0c79ee294d939 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedCommentsES6.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedCommentsES6.ts === +`head${ // single line comment +No type information for this code.10 +No type information for this code.} +No type information for this code.middle${ +No type information for this code./* Multi- +No type information for this code. * line +No type information for this code. * comment +No type information for this code. */ +No type information for this code. 20 +No type information for this code. // closing comment +No type information for this code.} +No type information for this code.tail`; +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringWithEmbeddedConditional.js b/tests/baselines/reference/templateStringWithEmbeddedConditional.js new file mode 100644 index 0000000000000..5b03f56a019fb --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedConditional.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedConditional.ts] +var x = `abc${ true ? false : " " }def`; + +//// [templateStringWithEmbeddedConditional.js] +var x = "abc" + (true ? false : " ") + "def"; diff --git a/tests/baselines/reference/templateStringWithEmbeddedConditional.types b/tests/baselines/reference/templateStringWithEmbeddedConditional.types new file mode 100644 index 0000000000000..de4249792e7f4 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedConditional.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedConditional.ts === +var x = `abc${ true ? false : " " }def`; +>x : string +>true ? false : " " : string | boolean + diff --git a/tests/baselines/reference/templateStringWithEmbeddedConditionalES6.js b/tests/baselines/reference/templateStringWithEmbeddedConditionalES6.js new file mode 100644 index 0000000000000..f6cae50a5117d --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedConditionalES6.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedConditionalES6.ts] +var x = `abc${ true ? false : " " }def`; + +//// [templateStringWithEmbeddedConditionalES6.js] +var x = `abc${true ? false : " "}def`; diff --git a/tests/baselines/reference/templateStringWithEmbeddedConditionalES6.types b/tests/baselines/reference/templateStringWithEmbeddedConditionalES6.types new file mode 100644 index 0000000000000..3fa96510f41d7 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedConditionalES6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedConditionalES6.ts === +var x = `abc${ true ? false : " " }def`; +>x : string +>true ? false : " " : string | boolean + diff --git a/tests/baselines/reference/templateStringWithEmbeddedDivision.js b/tests/baselines/reference/templateStringWithEmbeddedDivision.js new file mode 100644 index 0000000000000..f9996ae035d9d --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedDivision.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedDivision.ts] +var x = `abc${ 1 / 1 }def`; + +//// [templateStringWithEmbeddedDivision.js] +var x = "abc" + 1 / 1 + "def"; diff --git a/tests/baselines/reference/templateStringWithEmbeddedDivision.types b/tests/baselines/reference/templateStringWithEmbeddedDivision.types new file mode 100644 index 0000000000000..e742733a23cf5 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedDivision.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedDivision.ts === +var x = `abc${ 1 / 1 }def`; +>x : string +>1 / 1 : number + diff --git a/tests/baselines/reference/templateStringWithEmbeddedDivisionES6.js b/tests/baselines/reference/templateStringWithEmbeddedDivisionES6.js new file mode 100644 index 0000000000000..47715d3f31bb9 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedDivisionES6.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedDivisionES6.ts] +var x = `abc${ 1 / 1 }def`; + +//// [templateStringWithEmbeddedDivisionES6.js] +var x = `abc${1 / 1}def`; diff --git a/tests/baselines/reference/templateStringWithEmbeddedDivisionES6.types b/tests/baselines/reference/templateStringWithEmbeddedDivisionES6.types new file mode 100644 index 0000000000000..20bdc9449d116 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedDivisionES6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedDivisionES6.ts === +var x = `abc${ 1 / 1 }def`; +>x : string +>1 / 1 : number + diff --git a/tests/baselines/reference/templateStringWithEmbeddedFunctionExpression.js b/tests/baselines/reference/templateStringWithEmbeddedFunctionExpression.js new file mode 100644 index 0000000000000..3447ff87ac383 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedFunctionExpression.js @@ -0,0 +1,7 @@ +//// [templateStringWithEmbeddedFunctionExpression.ts] +var x = `abc${ function y() { return y; } }def`; + +//// [templateStringWithEmbeddedFunctionExpression.js] +var x = "abc" + function y() { + return y; +} + "def"; diff --git a/tests/baselines/reference/templateStringWithEmbeddedFunctionExpression.types b/tests/baselines/reference/templateStringWithEmbeddedFunctionExpression.types new file mode 100644 index 0000000000000..e66313848a606 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedFunctionExpression.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedFunctionExpression.ts === +var x = `abc${ function y() { return y; } }def`; +>x : string +>function y() { return y; } : () => any +>y : () => any +>y : () => any + diff --git a/tests/baselines/reference/templateStringWithEmbeddedFunctionExpressionES6.js b/tests/baselines/reference/templateStringWithEmbeddedFunctionExpressionES6.js new file mode 100644 index 0000000000000..46e37c0ac18fb --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedFunctionExpressionES6.js @@ -0,0 +1,7 @@ +//// [templateStringWithEmbeddedFunctionExpressionES6.ts] +var x = `abc${ function y() { return y; } }def`; + +//// [templateStringWithEmbeddedFunctionExpressionES6.js] +var x = `abc${function y() { + return y; +}}def`; diff --git a/tests/baselines/reference/templateStringWithEmbeddedFunctionExpressionES6.types b/tests/baselines/reference/templateStringWithEmbeddedFunctionExpressionES6.types new file mode 100644 index 0000000000000..e5c55c2736c38 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedFunctionExpressionES6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedFunctionExpressionES6.ts === +var x = `abc${ function y() { return y; } }def`; +>x : string +>function y() { return y; } : () => any +>y : () => any +>y : () => any + diff --git a/tests/baselines/reference/templateStringWithEmbeddedInOperator.js b/tests/baselines/reference/templateStringWithEmbeddedInOperator.js new file mode 100644 index 0000000000000..091843ea52e9a --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedInOperator.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedInOperator.ts] +var x = `abc${ "hi" in { hi: 10, hello: 20} }def`; + +//// [templateStringWithEmbeddedInOperator.js] +var x = "abc" + ("hi" in { hi: 10, hello: 20 }) + "def"; diff --git a/tests/baselines/reference/templateStringWithEmbeddedInOperator.types b/tests/baselines/reference/templateStringWithEmbeddedInOperator.types new file mode 100644 index 0000000000000..bff1ea66e1d99 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedInOperator.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedInOperator.ts === +var x = `abc${ "hi" in { hi: 10, hello: 20} }def`; +>x : string +>"hi" in { hi: 10, hello: 20} : boolean +>{ hi: 10, hello: 20} : { hi: number; hello: number; } +>hi : number +>hello : number + diff --git a/tests/baselines/reference/templateStringWithEmbeddedInOperatorES6.js b/tests/baselines/reference/templateStringWithEmbeddedInOperatorES6.js new file mode 100644 index 0000000000000..f6510c2fab989 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedInOperatorES6.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedInOperatorES6.ts] +var x = `abc${ "hi" in { hi: 10, hello: 20} }def`; + +//// [templateStringWithEmbeddedInOperatorES6.js] +var x = `abc${"hi" in { hi: 10, hello: 20 }}def`; diff --git a/tests/baselines/reference/templateStringWithEmbeddedInOperatorES6.types b/tests/baselines/reference/templateStringWithEmbeddedInOperatorES6.types new file mode 100644 index 0000000000000..6bba79af40da8 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedInOperatorES6.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedInOperatorES6.ts === +var x = `abc${ "hi" in { hi: 10, hello: 20} }def`; +>x : string +>"hi" in { hi: 10, hello: 20} : boolean +>{ hi: 10, hello: 20} : { hi: number; hello: number; } +>hi : number +>hello : number + diff --git a/tests/baselines/reference/templateStringWithEmbeddedInstanceOf.errors.txt b/tests/baselines/reference/templateStringWithEmbeddedInstanceOf.errors.txt new file mode 100644 index 0000000000000..08c8c21b5ee4d --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedInstanceOf.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/templates/templateStringWithEmbeddedInstanceOf.ts(1,16): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter. + + +==== tests/cases/conformance/es6/templates/templateStringWithEmbeddedInstanceOf.ts (1 errors) ==== + var x = `abc${ "hello" instanceof String }def`; + ~~~~~~~ +!!! error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringWithEmbeddedInstanceOf.js b/tests/baselines/reference/templateStringWithEmbeddedInstanceOf.js new file mode 100644 index 0000000000000..009f6bf988d0d --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedInstanceOf.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedInstanceOf.ts] +var x = `abc${ "hello" instanceof String }def`; + +//// [templateStringWithEmbeddedInstanceOf.js] +var x = "abc" + ("hello" instanceof String) + "def"; diff --git a/tests/baselines/reference/templateStringWithEmbeddedInstanceOfES6.errors.txt b/tests/baselines/reference/templateStringWithEmbeddedInstanceOfES6.errors.txt new file mode 100644 index 0000000000000..85ebb9966ca22 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedInstanceOfES6.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/es6/templates/templateStringWithEmbeddedInstanceOfES6.ts(1,16): error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter. + + +==== tests/cases/conformance/es6/templates/templateStringWithEmbeddedInstanceOfES6.ts (1 errors) ==== + var x = `abc${ "hello" instanceof String }def`; + ~~~~~~~ +!!! error TS2358: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringWithEmbeddedInstanceOfES6.js b/tests/baselines/reference/templateStringWithEmbeddedInstanceOfES6.js new file mode 100644 index 0000000000000..16a2d2c6797ce --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedInstanceOfES6.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedInstanceOfES6.ts] +var x = `abc${ "hello" instanceof String }def`; + +//// [templateStringWithEmbeddedInstanceOfES6.js] +var x = `abc${"hello" instanceof String}def`; diff --git a/tests/baselines/reference/templateStringWithEmbeddedModulo.js b/tests/baselines/reference/templateStringWithEmbeddedModulo.js new file mode 100644 index 0000000000000..6fe9be6431454 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedModulo.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedModulo.ts] +var x = `abc${ 1 % 1 }def`; + +//// [templateStringWithEmbeddedModulo.js] +var x = "abc" + 1 % 1 + "def"; diff --git a/tests/baselines/reference/templateStringWithEmbeddedModulo.types b/tests/baselines/reference/templateStringWithEmbeddedModulo.types new file mode 100644 index 0000000000000..0c24f56684677 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedModulo.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedModulo.ts === +var x = `abc${ 1 % 1 }def`; +>x : string +>1 % 1 : number + diff --git a/tests/baselines/reference/templateStringWithEmbeddedModuloES6.js b/tests/baselines/reference/templateStringWithEmbeddedModuloES6.js new file mode 100644 index 0000000000000..0226277d98754 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedModuloES6.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedModuloES6.ts] +var x = `abc${ 1 % 1 }def`; + +//// [templateStringWithEmbeddedModuloES6.js] +var x = `abc${1 % 1}def`; diff --git a/tests/baselines/reference/templateStringWithEmbeddedModuloES6.types b/tests/baselines/reference/templateStringWithEmbeddedModuloES6.types new file mode 100644 index 0000000000000..02f42a956b978 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedModuloES6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedModuloES6.ts === +var x = `abc${ 1 % 1 }def`; +>x : string +>1 % 1 : number + diff --git a/tests/baselines/reference/templateStringWithEmbeddedMultiplication.js b/tests/baselines/reference/templateStringWithEmbeddedMultiplication.js new file mode 100644 index 0000000000000..7ac4b1b534c78 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedMultiplication.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedMultiplication.ts] +var x = `abc${ 7 * 6 }def`; + +//// [templateStringWithEmbeddedMultiplication.js] +var x = "abc" + 7 * 6 + "def"; diff --git a/tests/baselines/reference/templateStringWithEmbeddedMultiplication.types b/tests/baselines/reference/templateStringWithEmbeddedMultiplication.types new file mode 100644 index 0000000000000..60c7bab0d1e27 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedMultiplication.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedMultiplication.ts === +var x = `abc${ 7 * 6 }def`; +>x : string +>7 * 6 : number + diff --git a/tests/baselines/reference/templateStringWithEmbeddedMultiplicationES6.js b/tests/baselines/reference/templateStringWithEmbeddedMultiplicationES6.js new file mode 100644 index 0000000000000..3624fe7878a6b --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedMultiplicationES6.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedMultiplicationES6.ts] +var x = `abc${ 7 * 6 }def`; + +//// [templateStringWithEmbeddedMultiplicationES6.js] +var x = `abc${7 * 6}def`; diff --git a/tests/baselines/reference/templateStringWithEmbeddedMultiplicationES6.types b/tests/baselines/reference/templateStringWithEmbeddedMultiplicationES6.types new file mode 100644 index 0000000000000..5c078b9c1ed3f --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedMultiplicationES6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedMultiplicationES6.ts === +var x = `abc${ 7 * 6 }def`; +>x : string +>7 * 6 : number + diff --git a/tests/baselines/reference/templateStringWithEmbeddedNewOperator.js b/tests/baselines/reference/templateStringWithEmbeddedNewOperator.js new file mode 100644 index 0000000000000..480fbe2573daf --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedNewOperator.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedNewOperator.ts] +var x = `abc${ new String("Hi") }def`; + +//// [templateStringWithEmbeddedNewOperator.js] +var x = "abc" + new String("Hi") + "def"; diff --git a/tests/baselines/reference/templateStringWithEmbeddedNewOperator.types b/tests/baselines/reference/templateStringWithEmbeddedNewOperator.types new file mode 100644 index 0000000000000..00bf35330037c --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedNewOperator.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedNewOperator.ts === +var x = `abc${ new String("Hi") }def`; +>x : string +>new String("Hi") : String +>String : { (value?: any): string; new (value?: any): String; prototype: String; fromCharCode(...codes: number[]): string; } + diff --git a/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.js b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.js new file mode 100644 index 0000000000000..8549e4c6e34fa --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedNewOperatorES6.ts] +var x = `abc${ new String("Hi") }def`; + +//// [templateStringWithEmbeddedNewOperatorES6.js] +var x = `abc${new String("Hi")}def`; diff --git a/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.types b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.types new file mode 100644 index 0000000000000..36c28473d56bd --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedNewOperatorES6.ts === +var x = `abc${ new String("Hi") }def`; +>x : string +>new String("Hi") : String +>String : { (value?: any): string; new (value?: any): String; prototype: String; fromCharCode(...codes: number[]): string; } + diff --git a/tests/baselines/reference/templateStringWithEmbeddedObjectLiteral.js b/tests/baselines/reference/templateStringWithEmbeddedObjectLiteral.js new file mode 100644 index 0000000000000..40ecf486245da --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedObjectLiteral.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedObjectLiteral.ts] +var x = `abc${ { x: 10, y: 20 } }def`; + +//// [templateStringWithEmbeddedObjectLiteral.js] +var x = "abc" + { x: 10, y: 20 } + "def"; diff --git a/tests/baselines/reference/templateStringWithEmbeddedObjectLiteral.types b/tests/baselines/reference/templateStringWithEmbeddedObjectLiteral.types new file mode 100644 index 0000000000000..0b053e532d81b --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedObjectLiteral.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedObjectLiteral.ts === +var x = `abc${ { x: 10, y: 20 } }def`; +>x : string +>{ x: 10, y: 20 } : { x: number; y: number; } +>x : number +>y : number + diff --git a/tests/baselines/reference/templateStringWithEmbeddedObjectLiteralES6.js b/tests/baselines/reference/templateStringWithEmbeddedObjectLiteralES6.js new file mode 100644 index 0000000000000..dbc3837e1330d --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedObjectLiteralES6.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedObjectLiteralES6.ts] +var x = `abc${ { x: 10, y: 20 } }def`; + +//// [templateStringWithEmbeddedObjectLiteralES6.js] +var x = `abc${{ x: 10, y: 20 }}def`; diff --git a/tests/baselines/reference/templateStringWithEmbeddedObjectLiteralES6.types b/tests/baselines/reference/templateStringWithEmbeddedObjectLiteralES6.types new file mode 100644 index 0000000000000..1cf1783fec835 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedObjectLiteralES6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedObjectLiteralES6.ts === +var x = `abc${ { x: 10, y: 20 } }def`; +>x : string +>{ x: 10, y: 20 } : { x: number; y: number; } +>x : number +>y : number + diff --git a/tests/baselines/reference/templateStringWithEmbeddedTemplateString.js b/tests/baselines/reference/templateStringWithEmbeddedTemplateString.js new file mode 100644 index 0000000000000..c0059dbb9508d --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedTemplateString.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedTemplateString.ts] +var x = `123${ `456 ${ " | " } 654` }321 123${ `456 ${ " | " } 654` }321`; + +//// [templateStringWithEmbeddedTemplateString.js] +var x = "123" + "456 " + " | " + " 654" + "321 123" + "456 " + " | " + " 654" + "321"; diff --git a/tests/baselines/reference/templateStringWithEmbeddedTemplateString.types b/tests/baselines/reference/templateStringWithEmbeddedTemplateString.types new file mode 100644 index 0000000000000..f63f684222ee3 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedTemplateString.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedTemplateString.ts === +var x = `123${ `456 ${ " | " } 654` }321 123${ `456 ${ " | " } 654` }321`; +>x : string + diff --git a/tests/baselines/reference/templateStringWithEmbeddedTemplateStringES6.js b/tests/baselines/reference/templateStringWithEmbeddedTemplateStringES6.js new file mode 100644 index 0000000000000..0d1fec18af16d --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedTemplateStringES6.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedTemplateStringES6.ts] +var x = `123${ `456 ${ " | " } 654` }321 123${ `456 ${ " | " } 654` }321`; + +//// [templateStringWithEmbeddedTemplateStringES6.js] +var x = `123${`456 ${" | "} 654`}321 123${`456 ${" | "} 654`}321`; diff --git a/tests/baselines/reference/templateStringWithEmbeddedTemplateStringES6.types b/tests/baselines/reference/templateStringWithEmbeddedTemplateStringES6.types new file mode 100644 index 0000000000000..05816bbcbcea0 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedTemplateStringES6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedTemplateStringES6.ts === +var x = `123${ `456 ${ " | " } 654` }321 123${ `456 ${ " | " } 654` }321`; +>x : string + diff --git a/tests/baselines/reference/templateStringWithEmbeddedTypeAssertionOnAddition.js b/tests/baselines/reference/templateStringWithEmbeddedTypeAssertionOnAddition.js new file mode 100644 index 0000000000000..89d9ba6940c8c --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedTypeAssertionOnAddition.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedTypeAssertionOnAddition.ts] +var x = `abc${ (10 + 10) }def`; + +//// [templateStringWithEmbeddedTypeAssertionOnAddition.js] +var x = "abc" + (10 + 10) + "def"; diff --git a/tests/baselines/reference/templateStringWithEmbeddedTypeAssertionOnAddition.types b/tests/baselines/reference/templateStringWithEmbeddedTypeAssertionOnAddition.types new file mode 100644 index 0000000000000..8b0b5ab37d08a --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedTypeAssertionOnAddition.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedTypeAssertionOnAddition.ts === +var x = `abc${ (10 + 10) }def`; +>x : string +>(10 + 10) : any +>(10 + 10) : number +>10 + 10 : number + diff --git a/tests/baselines/reference/templateStringWithEmbeddedTypeAssertionOnAdditionES6.js b/tests/baselines/reference/templateStringWithEmbeddedTypeAssertionOnAdditionES6.js new file mode 100644 index 0000000000000..c6422679f3fef --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedTypeAssertionOnAdditionES6.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedTypeAssertionOnAdditionES6.ts] +var x = `abc${ (10 + 10) }def`; + +//// [templateStringWithEmbeddedTypeAssertionOnAdditionES6.js] +var x = `abc${(10 + 10)}def`; diff --git a/tests/baselines/reference/templateStringWithEmbeddedTypeAssertionOnAdditionES6.types b/tests/baselines/reference/templateStringWithEmbeddedTypeAssertionOnAdditionES6.types new file mode 100644 index 0000000000000..007fdb6473642 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedTypeAssertionOnAdditionES6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedTypeAssertionOnAdditionES6.ts === +var x = `abc${ (10 + 10) }def`; +>x : string +>(10 + 10) : any +>(10 + 10) : number +>10 + 10 : number + diff --git a/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperator.js b/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperator.js new file mode 100644 index 0000000000000..10450707b11a3 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperator.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedTypeOfOperator.ts] +var x = `abc${ typeof "hi" }def`; + +//// [templateStringWithEmbeddedTypeOfOperator.js] +var x = "abc" + typeof "hi" + "def"; diff --git a/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperator.types b/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperator.types new file mode 100644 index 0000000000000..ebf391981f1cb --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperator.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedTypeOfOperator.ts === +var x = `abc${ typeof "hi" }def`; +>x : string +>typeof "hi" : string + diff --git a/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperatorES6.js b/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperatorES6.js new file mode 100644 index 0000000000000..8d148744fae36 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperatorES6.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedTypeOfOperatorES6.ts] +var x = `abc${ typeof "hi" }def`; + +//// [templateStringWithEmbeddedTypeOfOperatorES6.js] +var x = `abc${typeof "hi"}def`; diff --git a/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperatorES6.types b/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperatorES6.types new file mode 100644 index 0000000000000..cf14a0a0880a6 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperatorES6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedTypeOfOperatorES6.ts === +var x = `abc${ typeof "hi" }def`; +>x : string +>typeof "hi" : string + diff --git a/tests/baselines/reference/templateStringWithEmbeddedUnaryPlus.js b/tests/baselines/reference/templateStringWithEmbeddedUnaryPlus.js new file mode 100644 index 0000000000000..a4a9c1a850859 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedUnaryPlus.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedUnaryPlus.ts] +var x = `abc${ +Infinity }def`; + +//// [templateStringWithEmbeddedUnaryPlus.js] +var x = "abc" + +Infinity + "def"; diff --git a/tests/baselines/reference/templateStringWithEmbeddedUnaryPlus.types b/tests/baselines/reference/templateStringWithEmbeddedUnaryPlus.types new file mode 100644 index 0000000000000..62ffab420ad0b --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedUnaryPlus.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedUnaryPlus.ts === +var x = `abc${ +Infinity }def`; +>x : string +>+Infinity : number +>Infinity : number + diff --git a/tests/baselines/reference/templateStringWithEmbeddedUnaryPlusES6.js b/tests/baselines/reference/templateStringWithEmbeddedUnaryPlusES6.js new file mode 100644 index 0000000000000..4b42bc1083a64 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedUnaryPlusES6.js @@ -0,0 +1,5 @@ +//// [templateStringWithEmbeddedUnaryPlusES6.ts] +var x = `abc${ +Infinity }def`; + +//// [templateStringWithEmbeddedUnaryPlusES6.js] +var x = `abc${+Infinity}def`; diff --git a/tests/baselines/reference/templateStringWithEmbeddedUnaryPlusES6.types b/tests/baselines/reference/templateStringWithEmbeddedUnaryPlusES6.types new file mode 100644 index 0000000000000..7a002d79b6ffc --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedUnaryPlusES6.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmbeddedUnaryPlusES6.ts === +var x = `abc${ +Infinity }def`; +>x : string +>+Infinity : number +>Infinity : number + diff --git a/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.errors.txt b/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.errors.txt new file mode 100644 index 0000000000000..e5f159a0a130d --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.errors.txt @@ -0,0 +1,34 @@ +tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(1,9): error TS1003: Identifier expected. +tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(1,15): error TS1005: ';' expected. +tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(3,26): error TS1159: Invalid template literal; expected '}' +tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(3,30): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(5,1): error TS1126: Unexpected end of text. +tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(1,11): error TS2304: Cannot find name 'gen'. +tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(3,20): error TS2304: Cannot find name 'yield'. +tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(3,30): error TS2304: Cannot find name 'def'. + + +==== tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts (8 errors) ==== + function* gen { + ~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS1005: ';' expected. + ~~~ +!!! error TS2304: Cannot find name 'gen'. + // Once this is supported, yield *must* be parenthesized. + var x = `abc${ yield 10 }def`; + ~~ +!!! error TS1159: Invalid template literal; expected '}' + ~~~~~ + ~~~~~ +!!! error TS2304: Cannot find name 'yield'. + ~~~ +!!! error TS2304: Cannot find name 'def'. + } + ~ + + +!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. + +!!! error TS1126: Unexpected end of text. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.errors.txt b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.errors.txt new file mode 100644 index 0000000000000..45142cd02d900 --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.errors.txt @@ -0,0 +1,29 @@ +tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(1,9): error TS1003: Identifier expected. +tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(1,17): error TS1005: ';' expected. +tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(3,26): error TS1159: Invalid template literal; expected '}' +tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(5,1): error TS1126: Unexpected end of text. +tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(1,11): error TS2304: Cannot find name 'gen'. +tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(3,20): error TS2304: Cannot find name 'yield'. +tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(3,30): error TS2304: Cannot find name 'def'. + + +==== tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts (7 errors) ==== + function* gen() { + ~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS1005: ';' expected. + ~~~ +!!! error TS2304: Cannot find name 'gen'. + // Once this is supported, yield *must* be parenthesized. + var x = `abc${ yield 10 }def`; + ~~ +!!! error TS1159: Invalid template literal; expected '}' + ~~~~~ +!!! error TS2304: Cannot find name 'yield'. + ~~~ +!!! error TS2304: Cannot find name 'def'. + } + + +!!! error TS1126: Unexpected end of text. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringWithEmptyLiteralPortions.js b/tests/baselines/reference/templateStringWithEmptyLiteralPortions.js new file mode 100644 index 0000000000000..8bc6e2c42065d --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmptyLiteralPortions.js @@ -0,0 +1,38 @@ +//// [templateStringWithEmptyLiteralPortions.ts] +var a = ``; + +var b = `${ 0 }`; + +var c = `1${ 0 }`; + +var d = `${ 0 }2`; + +var e = `1${ 0 }2`; + +var f = `${ 0 }${ 0 }`; + +var g = `1${ 0 }${ 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`; + +//// [templateStringWithEmptyLiteralPortions.js] +var a = ""; +var b = "" + 0; +var c = "1" + 0; +var d = "" + 0 + "2"; +var e = "1" + 0 + "2"; +var f = "" + 0 + 0; +var g = "1" + 0 + 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"; diff --git a/tests/baselines/reference/templateStringWithEmptyLiteralPortions.types b/tests/baselines/reference/templateStringWithEmptyLiteralPortions.types new file mode 100644 index 0000000000000..a44bab8fe440e --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmptyLiteralPortions.types @@ -0,0 +1,37 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmptyLiteralPortions.ts === +var a = ``; +>a : string + +var b = `${ 0 }`; +>b : string + +var c = `1${ 0 }`; +>c : string + +var d = `${ 0 }2`; +>d : string + +var e = `1${ 0 }2`; +>e : string + +var f = `${ 0 }${ 0 }`; +>f : string + +var g = `1${ 0 }${ 0 }`; +>g : string + +var h = `${ 0 }2${ 0 }`; +>h : string + +var i = `1${ 0 }2${ 0 }`; +>i : string + +var j = `${ 0 }${ 0 }3`; +>j : string + +var k = `1${ 0 }${ 0 }3`; +>k : string + +var l = `1${ 0 }2${ 0 }3`; +>l : string + diff --git a/tests/baselines/reference/templateStringWithEmptyLiteralPortionsES6.js b/tests/baselines/reference/templateStringWithEmptyLiteralPortionsES6.js new file mode 100644 index 0000000000000..f0e827cde639d --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmptyLiteralPortionsES6.js @@ -0,0 +1,38 @@ +//// [templateStringWithEmptyLiteralPortionsES6.ts] +var a = ``; + +var b = `${ 0 }`; + +var c = `1${ 0 }`; + +var d = `${ 0 }2`; + +var e = `1${ 0 }2`; + +var f = `${ 0 }${ 0 }`; + +var g = `1${ 0 }${ 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`; + +//// [templateStringWithEmptyLiteralPortionsES6.js] +var a = ``; +var b = `${0}`; +var c = `1${0}`; +var d = `${0}2`; +var e = `1${0}2`; +var f = `${0}${0}`; +var g = `1${0}${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`; diff --git a/tests/baselines/reference/templateStringWithEmptyLiteralPortionsES6.types b/tests/baselines/reference/templateStringWithEmptyLiteralPortionsES6.types new file mode 100644 index 0000000000000..4074831d410ce --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmptyLiteralPortionsES6.types @@ -0,0 +1,37 @@ +=== tests/cases/conformance/es6/templates/templateStringWithEmptyLiteralPortionsES6.ts === +var a = ``; +>a : string + +var b = `${ 0 }`; +>b : string + +var c = `1${ 0 }`; +>c : string + +var d = `${ 0 }2`; +>d : string + +var e = `1${ 0 }2`; +>e : string + +var f = `${ 0 }${ 0 }`; +>f : string + +var g = `1${ 0 }${ 0 }`; +>g : string + +var h = `${ 0 }2${ 0 }`; +>h : string + +var i = `1${ 0 }2${ 0 }`; +>i : string + +var j = `${ 0 }${ 0 }3`; +>j : string + +var k = `1${ 0 }${ 0 }3`; +>k : string + +var l = `1${ 0 }2${ 0 }3`; +>l : string + diff --git a/tests/baselines/reference/templateStringWithOpenCommentInStringPortion.js b/tests/baselines/reference/templateStringWithOpenCommentInStringPortion.js new file mode 100644 index 0000000000000..233ab78a19538 --- /dev/null +++ b/tests/baselines/reference/templateStringWithOpenCommentInStringPortion.js @@ -0,0 +1,5 @@ +//// [templateStringWithOpenCommentInStringPortion.ts] +` /**head ${ 10 } // still middle ${ 20 } /* still tail ` + +//// [templateStringWithOpenCommentInStringPortion.js] +" /**head " + 10 + " // still middle " + 20 + " /* still tail "; diff --git a/tests/baselines/reference/templateStringWithOpenCommentInStringPortion.types b/tests/baselines/reference/templateStringWithOpenCommentInStringPortion.types new file mode 100644 index 0000000000000..66070a70ec769 --- /dev/null +++ b/tests/baselines/reference/templateStringWithOpenCommentInStringPortion.types @@ -0,0 +1,3 @@ +=== tests/cases/conformance/es6/templates/templateStringWithOpenCommentInStringPortion.ts === +` /**head ${ 10 } // still middle ${ 20 } /* still tail ` +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringWithOpenCommentInStringPortionES6.js b/tests/baselines/reference/templateStringWithOpenCommentInStringPortionES6.js new file mode 100644 index 0000000000000..45d2d86e97e7c --- /dev/null +++ b/tests/baselines/reference/templateStringWithOpenCommentInStringPortionES6.js @@ -0,0 +1,5 @@ +//// [templateStringWithOpenCommentInStringPortionES6.ts] +` /**head ${ 10 } // still middle ${ 20 } /* still tail ` + +//// [templateStringWithOpenCommentInStringPortionES6.js] +` /**head ${10} // still middle ${20} /* still tail `; diff --git a/tests/baselines/reference/templateStringWithOpenCommentInStringPortionES6.types b/tests/baselines/reference/templateStringWithOpenCommentInStringPortionES6.types new file mode 100644 index 0000000000000..08b5484f3ab7f --- /dev/null +++ b/tests/baselines/reference/templateStringWithOpenCommentInStringPortionES6.types @@ -0,0 +1,3 @@ +=== tests/cases/conformance/es6/templates/templateStringWithOpenCommentInStringPortionES6.ts === +` /**head ${ 10 } // still middle ${ 20 } /* still tail ` +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringWithPropertyAccess.js b/tests/baselines/reference/templateStringWithPropertyAccess.js new file mode 100644 index 0000000000000..9866b6bd53be5 --- /dev/null +++ b/tests/baselines/reference/templateStringWithPropertyAccess.js @@ -0,0 +1,5 @@ +//// [templateStringWithPropertyAccess.ts] +`abc${0}abc`.indexOf(`abc`); + +//// [templateStringWithPropertyAccess.js] +("abc" + 0 + "abc").indexOf("abc"); diff --git a/tests/baselines/reference/templateStringWithPropertyAccess.types b/tests/baselines/reference/templateStringWithPropertyAccess.types new file mode 100644 index 0000000000000..ae9dbb5249d1a --- /dev/null +++ b/tests/baselines/reference/templateStringWithPropertyAccess.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/templates/templateStringWithPropertyAccess.ts === +`abc${0}abc`.indexOf(`abc`); +>`abc${0}abc`.indexOf(`abc`) : number +>`abc${0}abc`.indexOf : (searchString: string, position?: number) => number +>indexOf : (searchString: string, position?: number) => number + diff --git a/tests/baselines/reference/templateStringWithPropertyAccessES6.js b/tests/baselines/reference/templateStringWithPropertyAccessES6.js new file mode 100644 index 0000000000000..72f3a16b5c4a4 --- /dev/null +++ b/tests/baselines/reference/templateStringWithPropertyAccessES6.js @@ -0,0 +1,5 @@ +//// [templateStringWithPropertyAccessES6.ts] +`abc${0}abc`.indexOf(`abc`); + +//// [templateStringWithPropertyAccessES6.js] +`abc${0}abc`.indexOf(`abc`); diff --git a/tests/baselines/reference/templateStringWithPropertyAccessES6.types b/tests/baselines/reference/templateStringWithPropertyAccessES6.types new file mode 100644 index 0000000000000..80ea8a0ef8b5f --- /dev/null +++ b/tests/baselines/reference/templateStringWithPropertyAccessES6.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/templates/templateStringWithPropertyAccessES6.ts === +`abc${0}abc`.indexOf(`abc`); +>`abc${0}abc`.indexOf(`abc`) : number +>`abc${0}abc`.indexOf : (searchString: string, position?: number) => number +>indexOf : (searchString: string, position?: number) => number + diff --git a/tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts b/tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts new file mode 100644 index 0000000000000..cd9da4e43e40b --- /dev/null +++ b/tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts @@ -0,0 +1,30 @@ +interface I { + (stringParts: string[], ...rest: boolean[]): I; + g: I; + h: I; + member: I; + thisIsNotATag(x: string): void + [x: number]: I; +} + +var f: I; + +f `abc` + +f `abc${1}def${2}ghi`; + +f `abc`.member + +f `abc${1}def${2}ghi`.member; + +f `abc`["member"]; + +f `abc${1}def${2}ghi`["member"]; + +f `abc`[0].member `abc${1}def${2}ghi`; + +f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; + +f.thisIsNotATag(`abc`); + +f.thisIsNotATag(`abc${1}def${2}ghi`); diff --git a/tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts b/tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts new file mode 100644 index 0000000000000..2e8cbf3a1fafe --- /dev/null +++ b/tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts @@ -0,0 +1,31 @@ +// @target: ES6 +interface I { + (stringParts: string[], ...rest: boolean[]): I; + g: I; + h: I; + member: I; + thisIsNotATag(x: string): void + [x: number]: I; +} + +var f: I; + +f `abc` + +f `abc${1}def${2}ghi`; + +f `abc`.member + +f `abc${1}def${2}ghi`.member; + +f `abc`["member"]; + +f `abc${1}def${2}ghi`["member"]; + +f `abc`[0].member `abc${1}def${2}ghi`; + +f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; + +f.thisIsNotATag(`abc`); + +f.thisIsNotATag(`abc${1}def${2}ghi`); diff --git a/tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressions.ts b/tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressions.ts new file mode 100644 index 0000000000000..b86996a53f3ac --- /dev/null +++ b/tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressions.ts @@ -0,0 +1,14 @@ +interface I { + (strs: string[], subs: number[]): I; + member: { + new (s: string): { + new (n: number): { + new (): boolean; + } + } + }; +} +var f: I; + +var x = new new new f `abc${ 0 }def`.member("hello")(42) === true; + diff --git a/tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressionsES6.ts b/tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressionsES6.ts new file mode 100644 index 0000000000000..0fe9ad566a9de --- /dev/null +++ b/tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressionsES6.ts @@ -0,0 +1,15 @@ +// @target: ES6 +interface I { + (strs: string[], subs: number[]): I; + member: { + new (s: string): { + new (n: number): { + new (): boolean; + } + } + }; +} +var f: I; + +var x = new new new f `abc${ 0 }def`.member("hello")(42) === true; + diff --git a/tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts b/tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts new file mode 100644 index 0000000000000..08d696cb28810 --- /dev/null +++ b/tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts @@ -0,0 +1,25 @@ +var f: any; + +f `abc` + +f `abc${1}def${2}ghi`; + +f.g.h `abc` + +f.g.h `abc${1}def${2}ghi`; + +f `abc`.member + +f `abc${1}def${2}ghi`.member; + +f `abc`["member"]; + +f `abc${1}def${2}ghi`["member"]; + +f `abc`["member"].someOtherTag `abc${1}def${2}ghi`; + +f `abc${1}def${2}ghi`["member"].someOtherTag `abc${1}def${2}ghi`; + +f.thisIsNotATag(`abc`); + +f.thisIsNotATag(`abc${1}def${2}ghi`); \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAnyES6.ts b/tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAnyES6.ts new file mode 100644 index 0000000000000..de75e1679ac2a --- /dev/null +++ b/tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAnyES6.ts @@ -0,0 +1,25 @@ +// @target: ES6 +var f: any; +f `abc` + +f `abc${1}def${2}ghi`; + +f.g.h `abc` + +f.g.h `abc${1}def${2}ghi`; + +f `abc`.member + +f `abc${1}def${2}ghi`.member; + +f `abc`["member"]; + +f `abc${1}def${2}ghi`["member"]; + +f `abc`["member"].someOtherTag `abc${1}def${2}ghi`; + +f `abc${1}def${2}ghi`["member"].someOtherTag `abc${1}def${2}ghi`; + +f.thisIsNotATag(`abc`); + +f.thisIsNotATag(`abc${1}def${2}ghi`); \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts b/tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts new file mode 100644 index 0000000000000..9b3852c2ddb23 --- /dev/null +++ b/tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts @@ -0,0 +1,30 @@ +interface I { + (stringParts: string[], ...rest: number[]): I; + g: I; + h: I; + member: I; + thisIsNotATag(x: string): void + [x: number]: I; +} + +var f: I; + +f `abc` + +f `abc${1}def${2}ghi`; + +f `abc`.member + +f `abc${1}def${2}ghi`.member; + +f `abc`["member"]; + +f `abc${1}def${2}ghi`["member"]; + +f `abc`[0].member `abc${1}def${2}ghi`; + +f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; + +f.thisIsNotATag(`abc`); + +f.thisIsNotATag(`abc${1}def${2}ghi`); diff --git a/tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTagsES6.ts b/tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTagsES6.ts new file mode 100644 index 0000000000000..0dc10820a98c1 --- /dev/null +++ b/tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTagsES6.ts @@ -0,0 +1,31 @@ +// @target: ES6 +interface I { + (stringParts: string[], ...rest: number[]): I; + g: I; + h: I; + member: I; + thisIsNotATag(x: string): void + [x: number]: I; +} + +var f: I; + +f `abc` + +f `abc${1}def${2}ghi`; + +f `abc`.member + +f `abc${1}def${2}ghi`.member; + +f `abc`["member"]; + +f `abc${1}def${2}ghi`["member"]; + +f `abc`[0].member `abc${1}def${2}ghi`; + +f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; + +f.thisIsNotATag(`abc`); + +f.thisIsNotATag(`abc${1}def${2}ghi`); diff --git a/tests/cases/conformance/es6/templates/templateStringInArray.ts b/tests/cases/conformance/es6/templates/templateStringInArray.ts new file mode 100644 index 0000000000000..2d2e5e323b5d7 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInArray.ts @@ -0,0 +1 @@ +var x = [1, 2, `abc${ 123 }def`]; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInArrowFunction.ts b/tests/cases/conformance/es6/templates/templateStringInArrowFunction.ts new file mode 100644 index 0000000000000..9820edb2ac329 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInArrowFunction.ts @@ -0,0 +1 @@ +var x = x => `abc${ x }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInArrowFunctionES6.ts b/tests/cases/conformance/es6/templates/templateStringInArrowFunctionES6.ts new file mode 100644 index 0000000000000..066fc1c74b120 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInArrowFunctionES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = x => `abc${ x }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInBinaryAddition.ts b/tests/cases/conformance/es6/templates/templateStringInBinaryAddition.ts new file mode 100644 index 0000000000000..7f00313ca868c --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInBinaryAddition.ts @@ -0,0 +1 @@ +var x = 10 + `abc${ 10 }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInBinaryAdditionES6.ts b/tests/cases/conformance/es6/templates/templateStringInBinaryAdditionES6.ts new file mode 100644 index 0000000000000..5f44e3cb9d47c --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInBinaryAdditionES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = 10 + `abc${ 10 }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInConditional.ts b/tests/cases/conformance/es6/templates/templateStringInConditional.ts new file mode 100644 index 0000000000000..aff80b60efc6e --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInConditional.ts @@ -0,0 +1 @@ +var x = `abc${ " " }def` ? `abc${ " " }def` : `abc${ " " }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInConditionalES6.ts b/tests/cases/conformance/es6/templates/templateStringInConditionalES6.ts new file mode 100644 index 0000000000000..c0b800259f322 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInConditionalES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = `abc${ " " }def` ? `abc${ " " }def` : `abc${ " " }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInDeleteExpression.ts b/tests/cases/conformance/es6/templates/templateStringInDeleteExpression.ts new file mode 100644 index 0000000000000..f3af01582a5d3 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInDeleteExpression.ts @@ -0,0 +1 @@ +delete `abc${0}abc`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInDeleteExpressionES6.ts b/tests/cases/conformance/es6/templates/templateStringInDeleteExpressionES6.ts new file mode 100644 index 0000000000000..cd81c11453a07 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInDeleteExpressionES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +delete `abc${0}abc`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInDivision.ts b/tests/cases/conformance/es6/templates/templateStringInDivision.ts new file mode 100644 index 0000000000000..9650f5e2455cc --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInDivision.ts @@ -0,0 +1 @@ +var x = `abc${ 1 }def` / 1; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInEqualityChecks.ts b/tests/cases/conformance/es6/templates/templateStringInEqualityChecks.ts new file mode 100644 index 0000000000000..37b8511368e3a --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInEqualityChecks.ts @@ -0,0 +1,4 @@ +var x = `abc${0}abc` === `abc` || + `abc` !== `abc${0}abc` && + `abc${0}abc` == "abc0abc" && + "abc0abc" !== `abc${0}abc`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInEqualityChecksES6.ts b/tests/cases/conformance/es6/templates/templateStringInEqualityChecksES6.ts new file mode 100644 index 0000000000000..5254474b82b28 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInEqualityChecksES6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +var x = `abc${0}abc` === `abc` || + `abc` !== `abc${0}abc` && + `abc${0}abc` == "abc0abc" && + "abc0abc" !== `abc${0}abc`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInFunctionExpression.ts b/tests/cases/conformance/es6/templates/templateStringInFunctionExpression.ts new file mode 100644 index 0000000000000..5f0c5a4c96fc6 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInFunctionExpression.ts @@ -0,0 +1,4 @@ +var x = function y() { + `abc${ 0 }def` + return `abc${ 0 }def`; +}; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInFunctionExpressionES6.ts b/tests/cases/conformance/es6/templates/templateStringInFunctionExpressionES6.ts new file mode 100644 index 0000000000000..729ecbd07442a --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInFunctionExpressionES6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +var x = function y() { + `abc${ 0 }def` + return `abc${ 0 }def`; +}; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInFunctionParameterType.ts b/tests/cases/conformance/es6/templates/templateStringInFunctionParameterType.ts new file mode 100644 index 0000000000000..628ba29081b2b --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInFunctionParameterType.ts @@ -0,0 +1,5 @@ +function f(`hello`); +function f(x: string); +function f(x: string) { + return x; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInFunctionParameterTypeES6.ts b/tests/cases/conformance/es6/templates/templateStringInFunctionParameterTypeES6.ts new file mode 100644 index 0000000000000..03fb0a7de88dd --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInFunctionParameterTypeES6.ts @@ -0,0 +1,6 @@ +// @target: ES6 +function f(`hello`); +function f(x: string); +function f(x: string) { + return x; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInInOperator.ts b/tests/cases/conformance/es6/templates/templateStringInInOperator.ts new file mode 100644 index 0000000000000..cc50b275144f3 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInInOperator.ts @@ -0,0 +1 @@ +var x = `${ "hi" }` in { hi: 10, hello: 20}; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInInOperatorES6.ts b/tests/cases/conformance/es6/templates/templateStringInInOperatorES6.ts new file mode 100644 index 0000000000000..5a23a0b4e3f07 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInInOperatorES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = `${ "hi" }` in { hi: 10, hello: 20}; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInIndexExpression.ts b/tests/cases/conformance/es6/templates/templateStringInIndexExpression.ts new file mode 100644 index 0000000000000..792e92a4dc787 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInIndexExpression.ts @@ -0,0 +1 @@ +`abc${0}abc`[`0`]; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInIndexExpressionES6.ts b/tests/cases/conformance/es6/templates/templateStringInIndexExpressionES6.ts new file mode 100644 index 0000000000000..6a431b3bb1325 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInIndexExpressionES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +`abc${0}abc`[`0`]; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInInstanceOf.ts b/tests/cases/conformance/es6/templates/templateStringInInstanceOf.ts new file mode 100644 index 0000000000000..12ec4e7baf73f --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInInstanceOf.ts @@ -0,0 +1 @@ +var x = `abc${ 0 }def` instanceof String; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInInstanceOfES6.ts b/tests/cases/conformance/es6/templates/templateStringInInstanceOfES6.ts new file mode 100644 index 0000000000000..6afe22b74b6bd --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInInstanceOfES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = `abc${ 0 }def` instanceof String; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInModuleName.ts b/tests/cases/conformance/es6/templates/templateStringInModuleName.ts new file mode 100644 index 0000000000000..8ed5038ffbfcd --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInModuleName.ts @@ -0,0 +1,5 @@ +declare module `M1` { +} + +declare module `M${2}` { +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts b/tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts new file mode 100644 index 0000000000000..44d3999febc5e --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInModuleNameES6.ts @@ -0,0 +1,6 @@ +// @target: ES6 +declare module `M1` { +} + +declare module `M${2}` { +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInModulo.ts b/tests/cases/conformance/es6/templates/templateStringInModulo.ts new file mode 100644 index 0000000000000..69d7faeda759f --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInModulo.ts @@ -0,0 +1 @@ +var x = 1 % `abc${ 1 }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInModuloES6.ts b/tests/cases/conformance/es6/templates/templateStringInModuloES6.ts new file mode 100644 index 0000000000000..0d05c3570babb --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInModuloES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = 1 % `abc${ 1 }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInMultiplication.ts b/tests/cases/conformance/es6/templates/templateStringInMultiplication.ts new file mode 100644 index 0000000000000..a8ba70bf10255 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInMultiplication.ts @@ -0,0 +1 @@ +var x = 1 * `abc${ 1 }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInMultiplicationES6.ts b/tests/cases/conformance/es6/templates/templateStringInMultiplicationES6.ts new file mode 100644 index 0000000000000..c0ffa96d98c19 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInMultiplicationES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = 1 * `abc${ 1 }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInNewOperator.ts b/tests/cases/conformance/es6/templates/templateStringInNewOperator.ts new file mode 100644 index 0000000000000..f53dd3023d236 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInNewOperator.ts @@ -0,0 +1 @@ +var x = new `abc${ 1 }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInNewOperatorES6.ts b/tests/cases/conformance/es6/templates/templateStringInNewOperatorES6.ts new file mode 100644 index 0000000000000..aad17d31ae2b2 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInNewOperatorES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = new `abc${ 1 }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts b/tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts new file mode 100644 index 0000000000000..e1ce34a20db0a --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts @@ -0,0 +1,4 @@ +var x = { + a: `abc${ 123 }def`, + `b`: 321 +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts b/tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts new file mode 100644 index 0000000000000..9ef032e4c88dc --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +var x = { + a: `abc${ 123 }def`, + `b`: 321 +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInParentheses.ts b/tests/cases/conformance/es6/templates/templateStringInParentheses.ts new file mode 100644 index 0000000000000..de5948e2bc203 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInParentheses.ts @@ -0,0 +1 @@ +var x = (`abc${0}abc`); \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInParenthesesES6.ts b/tests/cases/conformance/es6/templates/templateStringInParenthesesES6.ts new file mode 100644 index 0000000000000..856392e7c140f --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInParenthesesES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = (`abc${0}abc`); \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInPropertyAssignment.ts b/tests/cases/conformance/es6/templates/templateStringInPropertyAssignment.ts new file mode 100644 index 0000000000000..3b362d942d97b --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInPropertyAssignment.ts @@ -0,0 +1,3 @@ +var x = { + a: `abc${ 123 }def${ 456 }ghi` +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInPropertyAssignmentES6.ts b/tests/cases/conformance/es6/templates/templateStringInPropertyAssignmentES6.ts new file mode 100644 index 0000000000000..6a99df5b34fa6 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInPropertyAssignmentES6.ts @@ -0,0 +1,4 @@ +// @target: ES6 +var x = { + a: `abc${ 123 }def${ 456 }ghi` +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts b/tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts new file mode 100644 index 0000000000000..c3c4ca3ecb5cb --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts @@ -0,0 +1,3 @@ +var x = { + `a`: 321 +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts b/tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts new file mode 100644 index 0000000000000..d21ab30888f6a --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts @@ -0,0 +1,3 @@ +var x = { + `abc${ 123 }def${ 456 }ghi`: 321 +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts b/tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts new file mode 100644 index 0000000000000..9bb814d32cf3e --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts @@ -0,0 +1,4 @@ +// @target: ES6 +var x = { + `a`: 321 +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts b/tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts new file mode 100644 index 0000000000000..7179f217caab0 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts @@ -0,0 +1,4 @@ +// @target: ES6 +var x = { + `abc${ 123 }def${ 456 }ghi`: 321 +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInSwitchAndCase.ts b/tests/cases/conformance/es6/templates/templateStringInSwitchAndCase.ts new file mode 100644 index 0000000000000..3b88a23c2984d --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInSwitchAndCase.ts @@ -0,0 +1,6 @@ +switch (`abc${0}abc`) { + case `abc`: + case `123`: + case `abc${0}abc`: + `def${1}def`; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInSwitchAndCaseES6.ts b/tests/cases/conformance/es6/templates/templateStringInSwitchAndCaseES6.ts new file mode 100644 index 0000000000000..c1872816ccc76 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInSwitchAndCaseES6.ts @@ -0,0 +1,7 @@ +// @target: ES6 +switch (`abc${0}abc`) { + case `abc`: + case `123`: + case `abc${0}abc`: + `def${1}def`; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInTypeAssertion.ts b/tests/cases/conformance/es6/templates/templateStringInTypeAssertion.ts new file mode 100644 index 0000000000000..b5a29156f5650 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInTypeAssertion.ts @@ -0,0 +1 @@ +var x = `abc${ 123 }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInTypeAssertionES6.ts b/tests/cases/conformance/es6/templates/templateStringInTypeAssertionES6.ts new file mode 100644 index 0000000000000..e1fc20728a071 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInTypeAssertionES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = `abc${ 123 }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInTypeOf.ts b/tests/cases/conformance/es6/templates/templateStringInTypeOf.ts new file mode 100644 index 0000000000000..da69e86c0b705 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInTypeOf.ts @@ -0,0 +1 @@ +var x = typeof `abc${ 123 }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInTypeOfES6.ts b/tests/cases/conformance/es6/templates/templateStringInTypeOfES6.ts new file mode 100644 index 0000000000000..a5f96923daa5b --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInTypeOfES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = typeof `abc${ 123 }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInUnaryPlus.ts b/tests/cases/conformance/es6/templates/templateStringInUnaryPlus.ts new file mode 100644 index 0000000000000..3f9b667d51d3a --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInUnaryPlus.ts @@ -0,0 +1 @@ +var x = +`abc${ 123 }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInUnaryPlusES6.ts b/tests/cases/conformance/es6/templates/templateStringInUnaryPlusES6.ts new file mode 100644 index 0000000000000..4baba61696d1a --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInUnaryPlusES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = +`abc${ 123 }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInWhile.ts b/tests/cases/conformance/es6/templates/templateStringInWhile.ts new file mode 100644 index 0000000000000..8baeaeadc9723 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInWhile.ts @@ -0,0 +1,3 @@ +while (`abc${0}abc`) { + `def${1}def`; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInWhileES6.ts b/tests/cases/conformance/es6/templates/templateStringInWhileES6.ts new file mode 100644 index 0000000000000..d30cdb4ec2ac1 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInWhileES6.ts @@ -0,0 +1,4 @@ +// @target: ES6 +while (`abc${0}abc`) { + `def${1}def`; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts b/tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts new file mode 100644 index 0000000000000..4a80e452251b3 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts @@ -0,0 +1,4 @@ +function* gen { + // Once this is supported, the inner expression does not need to be parenthesized. + var x = yield `abc${ x }def`; +} diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedAddition.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedAddition.ts new file mode 100644 index 0000000000000..73f9c6b6b84c3 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedAddition.ts @@ -0,0 +1 @@ +var x = `abc${ 10 + 10 }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedAdditionES6.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedAdditionES6.ts new file mode 100644 index 0000000000000..12cda7856fa68 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedAdditionES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = `abc${ 10 + 10 }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedArray.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedArray.ts new file mode 100644 index 0000000000000..77ea762070bc8 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedArray.ts @@ -0,0 +1 @@ +var x = `abc${ [1,2,3] }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedArrayES6.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedArrayES6.ts new file mode 100644 index 0000000000000..2be90b5abfa77 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedArrayES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = `abc${ [1,2,3] }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedArrowFunction.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedArrowFunction.ts new file mode 100644 index 0000000000000..8d879732c7918 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedArrowFunction.ts @@ -0,0 +1 @@ +var x = `abc${ x => x }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedArrowFunctionES6.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedArrowFunctionES6.ts new file mode 100644 index 0000000000000..946bd41470fb5 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedArrowFunctionES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = `abc${ x => x }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedComments.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedComments.ts new file mode 100644 index 0000000000000..2cb295bbfeb98 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedComments.ts @@ -0,0 +1,12 @@ +`head${ // single line comment +10 +} +middle${ +/* Multi- + * line + * comment + */ + 20 + // closing comment +} +tail`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedCommentsES6.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedCommentsES6.ts new file mode 100644 index 0000000000000..2cb295bbfeb98 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedCommentsES6.ts @@ -0,0 +1,12 @@ +`head${ // single line comment +10 +} +middle${ +/* Multi- + * line + * comment + */ + 20 + // closing comment +} +tail`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedConditional.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedConditional.ts new file mode 100644 index 0000000000000..6c70bbc9b0469 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedConditional.ts @@ -0,0 +1 @@ +var x = `abc${ true ? false : " " }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedConditionalES6.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedConditionalES6.ts new file mode 100644 index 0000000000000..b1366210a2843 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedConditionalES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = `abc${ true ? false : " " }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedDivision.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedDivision.ts new file mode 100644 index 0000000000000..82ea537dc131d --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedDivision.ts @@ -0,0 +1 @@ +var x = `abc${ 1 / 1 }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedDivisionES6.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedDivisionES6.ts new file mode 100644 index 0000000000000..04f3740e3ae21 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedDivisionES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = `abc${ 1 / 1 }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedFunctionExpression.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedFunctionExpression.ts new file mode 100644 index 0000000000000..05c69d962e5be --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedFunctionExpression.ts @@ -0,0 +1 @@ +var x = `abc${ function y() { return y; } }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedFunctionExpressionES6.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedFunctionExpressionES6.ts new file mode 100644 index 0000000000000..3aab00817ee1e --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedFunctionExpressionES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = `abc${ function y() { return y; } }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedInOperator.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedInOperator.ts new file mode 100644 index 0000000000000..0e823e0ee1185 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedInOperator.ts @@ -0,0 +1 @@ +var x = `abc${ "hi" in { hi: 10, hello: 20} }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedInOperatorES6.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedInOperatorES6.ts new file mode 100644 index 0000000000000..c678d54246785 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedInOperatorES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = `abc${ "hi" in { hi: 10, hello: 20} }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedInstanceOf.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedInstanceOf.ts new file mode 100644 index 0000000000000..b8cd9ba5740a9 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedInstanceOf.ts @@ -0,0 +1 @@ +var x = `abc${ "hello" instanceof String }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedInstanceOfES6.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedInstanceOfES6.ts new file mode 100644 index 0000000000000..a6598788b9242 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedInstanceOfES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = `abc${ "hello" instanceof String }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedModulo.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedModulo.ts new file mode 100644 index 0000000000000..675627cb25d1c --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedModulo.ts @@ -0,0 +1 @@ +var x = `abc${ 1 % 1 }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedModuloES6.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedModuloES6.ts new file mode 100644 index 0000000000000..8b6d3ed7ef26b --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedModuloES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = `abc${ 1 % 1 }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedMultiplication.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedMultiplication.ts new file mode 100644 index 0000000000000..09a99646fc829 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedMultiplication.ts @@ -0,0 +1 @@ +var x = `abc${ 7 * 6 }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedMultiplicationES6.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedMultiplicationES6.ts new file mode 100644 index 0000000000000..1378909e1c62e --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedMultiplicationES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = `abc${ 7 * 6 }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedNewOperator.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedNewOperator.ts new file mode 100644 index 0000000000000..0f2652f892b1e --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedNewOperator.ts @@ -0,0 +1 @@ +var x = `abc${ new String("Hi") }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedNewOperatorES6.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedNewOperatorES6.ts new file mode 100644 index 0000000000000..4313531575a95 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedNewOperatorES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = `abc${ new String("Hi") }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedObjectLiteral.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedObjectLiteral.ts new file mode 100644 index 0000000000000..bfdbb3d6a3481 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedObjectLiteral.ts @@ -0,0 +1 @@ +var x = `abc${ { x: 10, y: 20 } }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedObjectLiteralES6.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedObjectLiteralES6.ts new file mode 100644 index 0000000000000..9927f5fe95e26 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedObjectLiteralES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = `abc${ { x: 10, y: 20 } }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedTemplateString.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedTemplateString.ts new file mode 100644 index 0000000000000..4fc2778aa4f5d --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedTemplateString.ts @@ -0,0 +1 @@ +var x = `123${ `456 ${ " | " } 654` }321 123${ `456 ${ " | " } 654` }321`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedTemplateStringES6.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedTemplateStringES6.ts new file mode 100644 index 0000000000000..4f8063ab03b2e --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedTemplateStringES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = `123${ `456 ${ " | " } 654` }321 123${ `456 ${ " | " } 654` }321`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedTypeAssertionOnAddition.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedTypeAssertionOnAddition.ts new file mode 100644 index 0000000000000..90a0e3561a394 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedTypeAssertionOnAddition.ts @@ -0,0 +1 @@ +var x = `abc${ (10 + 10) }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedTypeAssertionOnAdditionES6.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedTypeAssertionOnAdditionES6.ts new file mode 100644 index 0000000000000..9c0537b6489da --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedTypeAssertionOnAdditionES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = `abc${ (10 + 10) }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedTypeOfOperator.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedTypeOfOperator.ts new file mode 100644 index 0000000000000..1a93e586bdaf5 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedTypeOfOperator.ts @@ -0,0 +1 @@ +var x = `abc${ typeof "hi" }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedTypeOfOperatorES6.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedTypeOfOperatorES6.ts new file mode 100644 index 0000000000000..534cd667f43c9 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedTypeOfOperatorES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = `abc${ typeof "hi" }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedUnaryPlus.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedUnaryPlus.ts new file mode 100644 index 0000000000000..f97583812e47b --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedUnaryPlus.ts @@ -0,0 +1 @@ +var x = `abc${ +Infinity }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedUnaryPlusES6.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedUnaryPlusES6.ts new file mode 100644 index 0000000000000..7b724dba57926 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedUnaryPlusES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +var x = `abc${ +Infinity }def`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts new file mode 100644 index 0000000000000..cbf7f27258127 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts @@ -0,0 +1,4 @@ +function* gen { + // Once this is supported, yield *must* be parenthesized. + var x = `abc${ yield 10 }def`; +} diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts new file mode 100644 index 0000000000000..5a7409aef79c8 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts @@ -0,0 +1,5 @@ +// @target: ES6 +function* gen() { + // Once this is supported, yield *must* be parenthesized. + var x = `abc${ yield 10 }def`; +} diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmptyLiteralPortions.ts b/tests/cases/conformance/es6/templates/templateStringWithEmptyLiteralPortions.ts new file mode 100644 index 0000000000000..11dca4caf7739 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmptyLiteralPortions.ts @@ -0,0 +1,23 @@ +var a = ``; + +var b = `${ 0 }`; + +var c = `1${ 0 }`; + +var d = `${ 0 }2`; + +var e = `1${ 0 }2`; + +var f = `${ 0 }${ 0 }`; + +var g = `1${ 0 }${ 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`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithEmptyLiteralPortionsES6.ts b/tests/cases/conformance/es6/templates/templateStringWithEmptyLiteralPortionsES6.ts new file mode 100644 index 0000000000000..183da57dd4588 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithEmptyLiteralPortionsES6.ts @@ -0,0 +1,24 @@ +// @target: ES6 +var a = ``; + +var b = `${ 0 }`; + +var c = `1${ 0 }`; + +var d = `${ 0 }2`; + +var e = `1${ 0 }2`; + +var f = `${ 0 }${ 0 }`; + +var g = `1${ 0 }${ 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`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithOpenCommentInStringPortion.ts b/tests/cases/conformance/es6/templates/templateStringWithOpenCommentInStringPortion.ts new file mode 100644 index 0000000000000..9101c8e3e6b94 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithOpenCommentInStringPortion.ts @@ -0,0 +1 @@ +` /**head ${ 10 } // still middle ${ 20 } /* still tail ` \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithOpenCommentInStringPortionES6.ts b/tests/cases/conformance/es6/templates/templateStringWithOpenCommentInStringPortionES6.ts new file mode 100644 index 0000000000000..cb7f76540ccc5 --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithOpenCommentInStringPortionES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +` /**head ${ 10 } // still middle ${ 20 } /* still tail ` \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithPropertyAccess.ts b/tests/cases/conformance/es6/templates/templateStringWithPropertyAccess.ts new file mode 100644 index 0000000000000..87682fff572fa --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithPropertyAccess.ts @@ -0,0 +1 @@ +`abc${0}abc`.indexOf(`abc`); \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/templateStringWithPropertyAccessES6.ts b/tests/cases/conformance/es6/templates/templateStringWithPropertyAccessES6.ts new file mode 100644 index 0000000000000..261ea75bde65c --- /dev/null +++ b/tests/cases/conformance/es6/templates/templateStringWithPropertyAccessES6.ts @@ -0,0 +1,2 @@ +// @target: ES6 +`abc${0}abc`.indexOf(`abc`); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInTemplateLiteralParts1.ts b/tests/cases/fourslash/completionListInTemplateLiteralParts1.ts new file mode 100644 index 0000000000000..a71584bdbdd2f --- /dev/null +++ b/tests/cases/fourslash/completionListInTemplateLiteralParts1.ts @@ -0,0 +1,11 @@ +/// + +/////*0*/` $ { ${/*1*/ 10/*2*/ + 1.1/*3*/ /*4*/} 12312`/*5*/ +//// +/////*6*/`asdasd${/*7*/ 2 + 1.1 /*8*/} 12312 { + +test.markers().forEach(marker => { + goTo.position(marker.position); + + verify.completionListItemsCountIsGreaterThan(0) +}} \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInTemplateLiteralPartsNegatives1.ts b/tests/cases/fourslash/completionListInTemplateLiteralPartsNegatives1.ts new file mode 100644 index 0000000000000..1624192057b3f --- /dev/null +++ b/tests/cases/fourslash/completionListInTemplateLiteralPartsNegatives1.ts @@ -0,0 +1,11 @@ +/// + +////`/*0*/ /*1*/$ /*2*/{ /*3*/$/*4*/{ 10 + 1.1 }/*5*/ 12312/*6*/` +//// +////`asdasd$/*7*/{ 2 + 1.1 }/*8*/ 12312 /*9*/{/*10*/ + +test.markers().forEach(marker => { + goTo.position(marker.position); + + verify.completionListIsEmpty() +} \ No newline at end of file diff --git a/tests/cases/fourslash/semanticClassificationInTemplateExpressions.ts b/tests/cases/fourslash/semanticClassificationInTemplateExpressions.ts new file mode 100644 index 0000000000000..19f6d1062cb66 --- /dev/null +++ b/tests/cases/fourslash/semanticClassificationInTemplateExpressions.ts @@ -0,0 +1,21 @@ +/// + +////module /*0*/M { +//// export class /*1*/C { +//// static x; +//// } +//// export enum /*2*/E { +//// E1 = 0 +//// } +////} +////`abcd${ /*3*/M./*4*/C.x + /*5*/M./*6*/E.E1}efg` + +var c = classification; +verify.semanticClassificationsAre( + c.moduleName("M", test.marker("0").position), + c.className("C", test.marker("1").position), + c.enumName("E", test.marker("2").position), + c.moduleName("M", test.marker("3").position), + c.className("C", test.marker("4").position), + c.moduleName("M", test.marker("5").position), + c.enumName("E", test.marker("6").position)); diff --git a/tests/cases/fourslash/syntacticClassificationsTemplates1.ts b/tests/cases/fourslash/syntacticClassificationsTemplates1.ts new file mode 100644 index 0000000000000..4c79c047c81ac --- /dev/null +++ b/tests/cases/fourslash/syntacticClassificationsTemplates1.ts @@ -0,0 +1,15 @@ +/// + +////var v = 10e0; +////var x = { +//// p1: `hello world`, +//// p2: `goodbye ${0} cruel ${0} world`, +////}; + +var c = classification; +verify.syntacticClassificationsAre( + c.keyword("var"), c.text("v"), c.operator("="), c.numericLiteral("10e0"), c.punctuation(";"), + c.keyword("var"), c.text("x"), c.operator("="), c.punctuation("{"), + c.text("p1"), c.punctuation(":"), c.stringLiteral("`hello world`"), c.punctuation(","), + c.text("p2"), c.punctuation(":"), c.stringLiteral("`goodbye ${"), c.numericLiteral("0"), c.stringLiteral("} cruel ${"), c.numericLiteral("0"), c.stringLiteral("} world`"), c.punctuation(","), + c.punctuation("}"), c.punctuation(";")); \ No newline at end of file diff --git a/tests/cases/fourslash/syntacticClassificationsTemplates2.ts b/tests/cases/fourslash/syntacticClassificationsTemplates2.ts new file mode 100644 index 0000000000000..19bad4b54a825 --- /dev/null +++ b/tests/cases/fourslash/syntacticClassificationsTemplates2.ts @@ -0,0 +1,11 @@ +/// + +////var tiredOfCanonicalExamples = +////`goodbye "${ `hello world` }" +////and ${ `good${ " " }riddance` }`; + +var c = classification; +verify.syntacticClassificationsAre( + c.keyword("var"), c.text("tiredOfCanonicalExamples"), c.operator("="), + c.stringLiteral("`goodbye \"${"), c.stringLiteral("`hello world`"), + c.stringLiteral("}\" \nand ${"), c.stringLiteral("`good${"), c.stringLiteral("\" \""), c.stringLiteral("}riddance`"), c.stringLiteral("}`"), c.punctuation(";")); \ No newline at end of file