mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Initial work on overload resolution with tagged templates.
Currently type argument inference breaks hard when the first parameter of a tag has a generic type.
This commit is contained in:
+153
-53
@@ -147,6 +147,7 @@ module ts {
|
||||
var globalNumberType: ObjectType;
|
||||
var globalBooleanType: ObjectType;
|
||||
var globalRegExpType: ObjectType;
|
||||
var globalTemplateStringsArrayType: ObjectType;
|
||||
|
||||
var tupleTypes: Map<TupleType> = {};
|
||||
var unionTypes: Map<UnionType> = {};
|
||||
@@ -5155,23 +5156,31 @@ module ts {
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
function resolveUntypedCall(node: CallExpression): Signature {
|
||||
forEach(node.arguments, argument => {
|
||||
checkExpression(argument);
|
||||
});
|
||||
function resolveUntypedCall(node: CallExpression | TaggedTemplateExpression): Signature {
|
||||
if (node.kind === SyntaxKind.TaggedTemplateExpression) {
|
||||
checkExpression((<TaggedTemplateExpression>node).template);
|
||||
}
|
||||
else {
|
||||
forEach((<CallExpression>node).arguments, argument => {
|
||||
checkExpression(argument);
|
||||
});
|
||||
}
|
||||
return anySignature;
|
||||
}
|
||||
|
||||
function resolveErrorCall(node: CallExpression): Signature {
|
||||
function resolveErrorCall(node: CallExpression | TaggedTemplateExpression): Signature {
|
||||
resolveUntypedCall(node);
|
||||
return unknownSignature;
|
||||
}
|
||||
|
||||
function signatureHasCorrectArity(node: CallExpression, signature: Signature): boolean {
|
||||
if (!node.arguments) {
|
||||
function signatureHasCorrectArity(node: CallExpression | TaggedTemplateExpression, args: Expression[], signature: Signature): boolean {
|
||||
var isTaggedTemplate = node.kind === SyntaxKind.TaggedTemplateExpression;
|
||||
|
||||
if (!isTaggedTemplate && !(<CallExpression>node).arguments) {
|
||||
// This only happens when we have something of the form:
|
||||
// new C
|
||||
//
|
||||
Debug.assert(node.kind === SyntaxKind.NewExpression);
|
||||
return signature.minArgumentCount === 0;
|
||||
}
|
||||
|
||||
@@ -5179,11 +5188,12 @@ module ts {
|
||||
// to arity checking.
|
||||
// 1. A trailing comma is tantamount to adding another argument
|
||||
// 2. If the call is incomplete (no closing paren) allow fewer arguments than expected
|
||||
var args = node.arguments;
|
||||
var numberOfArgs = args.hasTrailingComma ? args.length + 1 : args.length;
|
||||
var numberOfArgs = !isTaggedTemplate && (<CallExpression>node).arguments.hasTrailingComma
|
||||
? args.length + 1
|
||||
: args.length;
|
||||
var hasTooManyArguments = !signature.hasRestParameter && numberOfArgs > signature.parameters.length;
|
||||
var hasRightNumberOfTypeArguments = !node.typeArguments ||
|
||||
(signature.typeParameters && node.typeArguments.length === signature.typeParameters.length);
|
||||
var hasRightNumberOfTypeArguments = !(<CallExpression>node).typeArguments ||
|
||||
(signature.typeParameters && (<CallExpression>node).typeArguments.length === signature.typeParameters.length);
|
||||
|
||||
if (hasTooManyArguments || !hasRightNumberOfTypeArguments) {
|
||||
return false;
|
||||
@@ -5191,7 +5201,17 @@ module ts {
|
||||
|
||||
// If we are missing the close paren, the call is incomplete, and we should skip
|
||||
// the lower bound check.
|
||||
var callIsIncomplete = args.end === node.end;
|
||||
var callIsIncomplete = false;
|
||||
if (isTaggedTemplate) {
|
||||
var template = (<TaggedTemplateExpression>node).template;
|
||||
if (template.kind === SyntaxKind.TemplateExpression) {
|
||||
var lastSpan = lastOrUndefined((<TemplateExpression>template).templateSpans)
|
||||
callIsIncomplete = lastSpan === undefined || lastSpan.literal.kind !== SyntaxKind.TemplateTail;
|
||||
}
|
||||
}
|
||||
else {
|
||||
callIsIncomplete = (<CallExpression>node).arguments.end === node.end;
|
||||
}
|
||||
var hasEnoughArguments = numberOfArgs >= signature.minArgumentCount;
|
||||
return callIsIncomplete || hasEnoughArguments;
|
||||
}
|
||||
@@ -5224,6 +5244,7 @@ module ts {
|
||||
var mapper = createInferenceMapper(context);
|
||||
// First infer from arguments that are not context sensitive
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
// TODO (drosen): This breaks hard when inferring on a tagged template.
|
||||
if (args[i].kind === SyntaxKind.OmittedExpression) {
|
||||
continue;
|
||||
}
|
||||
@@ -5277,31 +5298,69 @@ module ts {
|
||||
return typeArgumentsAreAssignable;
|
||||
}
|
||||
|
||||
function checkApplicableSignature(node: CallExpression, signature: Signature, relation: Map<Ternary>, excludeArgument: boolean[], reportErrors: boolean) {
|
||||
if (node.arguments) {
|
||||
for (var i = 0; i < node.arguments.length; i++) {
|
||||
var arg = node.arguments[i];
|
||||
if (arg.kind === SyntaxKind.OmittedExpression) {
|
||||
continue;
|
||||
}
|
||||
var paramType = getTypeAtPosition(signature, i);
|
||||
function checkApplicableSignature(node: CallExpression | TaggedTemplateExpression, callArguments: Node[], signature: Signature, relation: Map<Ternary>, excludeArgument: boolean[], reportErrors: boolean) {
|
||||
for (var i = 0; i < callArguments.length; i++) {
|
||||
var arg = callArguments[i];
|
||||
var argType: Type;
|
||||
|
||||
if (arg && arg.kind === SyntaxKind.OmittedExpression) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var paramType = getTypeAtPosition(signature, i);
|
||||
|
||||
if (i === 0 && node.kind === SyntaxKind.TaggedTemplateExpression) {
|
||||
arg = (<TaggedTemplateExpression>node).template; // just to report an error on the template
|
||||
argType = globalTemplateStringsArrayType;
|
||||
}
|
||||
else {
|
||||
// String literals get string literal types unless we're reporting errors
|
||||
var argType = arg.kind === SyntaxKind.StringLiteral && !reportErrors ?
|
||||
getStringLiteralType(<LiteralExpression>arg) :
|
||||
checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined);
|
||||
// Use argument expression as error location when reporting errors
|
||||
var isValidArgument = checkTypeRelatedTo(argType, paramType, relation, reportErrors ? arg : undefined,
|
||||
Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1);
|
||||
if (!isValidArgument) {
|
||||
return false;
|
||||
}
|
||||
argType = arg.kind === SyntaxKind.StringLiteral && !reportErrors
|
||||
? getStringLiteralType(<LiteralExpression>arg)
|
||||
: checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined);
|
||||
}
|
||||
|
||||
// Use argument expression as error location when reporting errors
|
||||
var isValidArgument = checkTypeRelatedTo(argType, paramType, relation, reportErrors ? arg : undefined,
|
||||
Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1);
|
||||
if (!isValidArgument) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function resolveCall(node: CallExpression, signatures: Signature[], candidatesOutArray: Signature[]): Signature {
|
||||
forEach(node.typeArguments, checkSourceElement);
|
||||
/**
|
||||
* Returns the effective arguments for an expression that works like a function invokation.
|
||||
*
|
||||
* If 'node' is a CallExpression or a NewExpression, then its argument list is returned.
|
||||
* If 'node' is a TaggedTemplateExpression, a new argument list is constructed from the substitution
|
||||
* expressions, where the first element of the argument list is 'undefined' to represent the "cooked" strings array.
|
||||
*/
|
||||
function getEffectiveCallArguments(node: CallExpression | TaggedTemplateExpression): Expression[] {
|
||||
var args: Expression[];
|
||||
if (node.kind === SyntaxKind.TaggedTemplateExpression) {
|
||||
var template = (<TaggedTemplateExpression>node).template;
|
||||
// REVIEW: Should this be undefined or template?
|
||||
// I currently use 'undefined' mostly to catch places we are not accounting for.
|
||||
args = [undefined];
|
||||
|
||||
if (template.kind === SyntaxKind.TemplateExpression) {
|
||||
args.push.apply(args, map((<TemplateExpression>template).templateSpans, span => span.expression));
|
||||
}
|
||||
}
|
||||
else {
|
||||
args = (<CallExpression>node).arguments || emptyArray;
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
function resolveCall(node: CallExpression | TaggedTemplateExpression, signatures: Signature[], candidatesOutArray: Signature[]): Signature {
|
||||
var typeArguments = (<CallExpression>node).typeArguments;
|
||||
forEach(typeArguments, checkSourceElement);
|
||||
|
||||
var candidates = candidatesOutArray || [];
|
||||
// collectCandidates fills up the candidates array directly
|
||||
collectCandidates();
|
||||
@@ -5309,11 +5368,22 @@ module ts {
|
||||
error(node, Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target);
|
||||
return resolveErrorCall(node);
|
||||
}
|
||||
var args = node.arguments || emptyArray;
|
||||
|
||||
var args = getEffectiveCallArguments(node);
|
||||
var isTaggedTemplate = node.kind === SyntaxKind.TaggedTemplateExpression;
|
||||
|
||||
// The following applies to any value of 'excludeArgument[i]':
|
||||
// - true: the argument at 'i' is susceptible to a one-time permanent contextual typing.
|
||||
// - undefined: the argument at 'i' is *not* susceptible to permanent contextual typing.
|
||||
// - false: the argument at 'i' *was* and *has been* permanently contextually typed.
|
||||
//
|
||||
// If the expression is a tagged template, then the first argument is implicitly the "cooked" strings array.
|
||||
var excludeArgument: boolean[];
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) {
|
||||
if (isContextSensitiveExpression(args[i])) {
|
||||
if (!excludeArgument) excludeArgument = new Array(args.length);
|
||||
if (!excludeArgument) {
|
||||
excludeArgument = new Array(args.length);
|
||||
}
|
||||
excludeArgument[i] = true;
|
||||
}
|
||||
}
|
||||
@@ -5378,11 +5448,11 @@ module ts {
|
||||
// in arguments too early. If possible, we'd like to only type them once we know the correct
|
||||
// overload. However, this matters for the case where the call is correct. When the call is
|
||||
// an error, we don't need to exclude any arguments, although it would cause no harm to do so.
|
||||
checkApplicableSignature(node, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true);
|
||||
checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true);
|
||||
}
|
||||
else if (candidateForTypeArgumentError) {
|
||||
if (node.typeArguments) {
|
||||
checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], /*reportErrors*/ true)
|
||||
if ((<CallExpression>node).typeArguments) {
|
||||
checkTypeArguments(candidateForTypeArgumentError, (<CallExpression>node).typeArguments, [], /*reportErrors*/ true)
|
||||
}
|
||||
else {
|
||||
Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0);
|
||||
@@ -5393,7 +5463,7 @@ module ts {
|
||||
Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly,
|
||||
typeToString(failedTypeParameter));
|
||||
|
||||
reportNoCommonSupertypeError(inferenceCandidates, node.func, diagnosticChainHead);
|
||||
reportNoCommonSupertypeError(inferenceCandidates, (<CallExpression>node).func || (<TaggedTemplateExpression>node).tag, diagnosticChainHead);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -5407,7 +5477,7 @@ module ts {
|
||||
// f({ |
|
||||
if (!fullTypeCheck) {
|
||||
for (var i = 0, n = candidates.length; i < n; i++) {
|
||||
if (signatureHasCorrectArity(node, candidates[i])) {
|
||||
if (signatureHasCorrectArity(node, args, candidates[i])) {
|
||||
return candidates[i];
|
||||
}
|
||||
}
|
||||
@@ -5417,7 +5487,7 @@ module ts {
|
||||
|
||||
function chooseOverload(candidates: Signature[], relation: Map<Ternary>, excludeArgument: boolean[]) {
|
||||
for (var i = 0; i < candidates.length; i++) {
|
||||
if (!signatureHasCorrectArity(node, candidates[i])) {
|
||||
if (!signatureHasCorrectArity(node, args, candidates[i])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -5429,9 +5499,9 @@ module ts {
|
||||
if (candidate.typeParameters) {
|
||||
var typeArgumentTypes: Type[];
|
||||
var typeArgumentsAreValid: boolean;
|
||||
if (node.typeArguments) {
|
||||
if ((<CallExpression>node).typeArguments) {
|
||||
typeArgumentTypes = new Array<Type>(candidate.typeParameters.length);
|
||||
typeArgumentsAreValid = checkTypeArguments(candidate, node.typeArguments, typeArgumentTypes, /*reportErrors*/ false)
|
||||
typeArgumentsAreValid = checkTypeArguments(candidate, (<CallExpression>node).typeArguments, typeArgumentTypes, /*reportErrors*/ false)
|
||||
}
|
||||
else {
|
||||
inferenceResult = inferTypeArguments(candidate, args, excludeArgument);
|
||||
@@ -5443,7 +5513,7 @@ module ts {
|
||||
}
|
||||
candidate = getSignatureInstantiation(candidate, typeArgumentTypes);
|
||||
}
|
||||
if (!checkApplicableSignature(node, candidate, relation, excludeArgument, /*reportErrors*/ false)) {
|
||||
if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, /*reportErrors*/ false)) {
|
||||
break;
|
||||
}
|
||||
var index = excludeArgument ? indexOf(excludeArgument, true) : -1;
|
||||
@@ -5465,7 +5535,7 @@ module ts {
|
||||
}
|
||||
else {
|
||||
candidateForTypeArgumentError = originalCandidate;
|
||||
if (!node.typeArguments) {
|
||||
if (!(<CallExpression>node).typeArguments) {
|
||||
resultOfFailedInference = inferenceResult;
|
||||
}
|
||||
}
|
||||
@@ -5576,7 +5646,6 @@ module ts {
|
||||
|
||||
function resolveNewExpression(node: NewExpression, candidatesOutArray: Signature[]): Signature {
|
||||
var expressionType = checkExpression(node.func);
|
||||
|
||||
// TS 1.0 spec: 4.11
|
||||
// If ConstructExpr is of type Any, Args can be any argument
|
||||
// list and the result of the operation is of type Any.
|
||||
@@ -5624,9 +5693,32 @@ module ts {
|
||||
return resolveErrorCall(node);
|
||||
}
|
||||
|
||||
function resolveTaggedTemplateExpression(node: TaggedTemplateExpression, candidatesOutArray: Signature[]): Signature {
|
||||
var tagType = checkExpression(node.tag);
|
||||
var apparentType = getApparentType(tagType);
|
||||
|
||||
if (apparentType === unknownType) {
|
||||
// Another error has already been reported
|
||||
return resolveErrorCall(node);
|
||||
}
|
||||
|
||||
var callSignatures = getSignaturesOfType(apparentType, SignatureKind.Call);
|
||||
|
||||
if (tagType === anyType || (!callSignatures.length && !(tagType.flags & TypeFlags.Union) && isTypeAssignableTo(tagType, globalFunctionType))) {
|
||||
return resolveUntypedCall(node);
|
||||
}
|
||||
|
||||
if (!callSignatures.length) {
|
||||
error(node, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature);
|
||||
return resolveErrorCall(node);
|
||||
}
|
||||
|
||||
return resolveCall(node, callSignatures, candidatesOutArray);
|
||||
}
|
||||
|
||||
// candidatesOutArray is passed by signature help in the language service, and collectCandidates
|
||||
// must fill it up with the appropriate candidate signatures
|
||||
function getResolvedSignature(node: CallExpression, candidatesOutArray?: Signature[]): Signature {
|
||||
function getResolvedSignature(node: CallExpression | TaggedTemplateExpression, candidatesOutArray?: Signature[]): Signature {
|
||||
var links = getNodeLinks(node);
|
||||
// If getResolvedSignature has already been called, we will have cached the resolvedSignature.
|
||||
// However, it is possible that either candidatesOutArray was not passed in the first time,
|
||||
@@ -5634,9 +5726,19 @@ module ts {
|
||||
// to correctly fill the candidatesOutArray.
|
||||
if (!links.resolvedSignature || candidatesOutArray) {
|
||||
links.resolvedSignature = anySignature;
|
||||
links.resolvedSignature = node.kind === SyntaxKind.CallExpression
|
||||
? resolveCallExpression(node, candidatesOutArray)
|
||||
: resolveNewExpression(node, candidatesOutArray);
|
||||
|
||||
if (node.kind === SyntaxKind.CallExpression) {
|
||||
links.resolvedSignature = resolveCallExpression(<CallExpression>node, candidatesOutArray);
|
||||
}
|
||||
else if (node.kind === SyntaxKind.NewExpression) {
|
||||
links.resolvedSignature = resolveNewExpression(<NewExpression>node, candidatesOutArray);
|
||||
}
|
||||
else if (node.kind === SyntaxKind.TaggedTemplateExpression) {
|
||||
links.resolvedSignature = resolveTaggedTemplateExpression(<TaggedTemplateExpression>node, candidatesOutArray);
|
||||
}
|
||||
else {
|
||||
Debug.fail("Branch in 'getResolvedSignature' should be unreachable.");
|
||||
}
|
||||
}
|
||||
return links.resolvedSignature;
|
||||
}
|
||||
@@ -5660,10 +5762,7 @@ module ts {
|
||||
}
|
||||
|
||||
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;
|
||||
return getReturnTypeOfSignature(getResolvedSignature(node));
|
||||
}
|
||||
|
||||
function checkTypeAssertion(node: TypeAssertion): Type {
|
||||
@@ -8752,6 +8851,7 @@ module ts {
|
||||
globalNumberType = getGlobalType("Number");
|
||||
globalBooleanType = getGlobalType("Boolean");
|
||||
globalRegExpType = getGlobalType("RegExp");
|
||||
globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray");
|
||||
}
|
||||
|
||||
initializeTypeChecker();
|
||||
|
||||
@@ -122,6 +122,17 @@ module ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last element of an array if non-empty, undefined otherwise.
|
||||
*/
|
||||
export function lastOrUndefined<T>(array: T[]): T {
|
||||
if (array.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return array[array.length - 1];
|
||||
}
|
||||
|
||||
export function binarySearch(array: number[], value: number): number {
|
||||
var low = 0;
|
||||
var high = array.length - 1;
|
||||
|
||||
Vendored
+4
@@ -484,6 +484,10 @@ declare var Number: {
|
||||
POSITIVE_INFINITY: number;
|
||||
}
|
||||
|
||||
interface TemplateStringsArray extends Array<string> {
|
||||
raw: string[];
|
||||
}
|
||||
|
||||
interface Math {
|
||||
/** The mathematical constant e. This is Euler's number, the base of natural logarithms. */
|
||||
E: number;
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
error TS2318: Cannot find global type 'Boolean'.
|
||||
error TS2318: Cannot find global type 'IArguments'.
|
||||
error TS2318: Cannot find global type 'TemplateStringsArray'.
|
||||
tests/cases/compiler/noDefaultLib.ts(4,11): error TS2317: Global type 'Array' must have 1 type parameter(s).
|
||||
|
||||
|
||||
!!! error TS2318: Cannot find global type 'Boolean'.
|
||||
!!! error TS2318: Cannot find global type 'IArguments'.
|
||||
!!! error TS2318: Cannot find global type 'TemplateStringsArray'.
|
||||
==== tests/cases/compiler/noDefaultLib.ts (1 errors) ====
|
||||
/// <reference no-default-lib="true"/>
|
||||
var x;
|
||||
|
||||
@@ -6,6 +6,7 @@ error TS2318: Cannot find global type 'Number'.
|
||||
error TS2318: Cannot find global type 'Object'.
|
||||
error TS2318: Cannot find global type 'RegExp'.
|
||||
error TS2318: Cannot find global type 'String'.
|
||||
error TS2318: Cannot find global type 'TemplateStringsArray'.
|
||||
|
||||
|
||||
!!! error TS2318: Cannot find global type 'Array'.
|
||||
@@ -16,6 +17,7 @@ error TS2318: Cannot find global type 'String'.
|
||||
!!! error TS2318: Cannot find global type 'Object'.
|
||||
!!! error TS2318: Cannot find global type 'RegExp'.
|
||||
!!! error TS2318: Cannot find global type 'String'.
|
||||
!!! error TS2318: Cannot find global type 'TemplateStringsArray'.
|
||||
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509698.ts (0 errors) ====
|
||||
/// <style requireSemi="on" />
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
@@ -6,6 +6,7 @@ error TS2318: Cannot find global type 'Number'.
|
||||
error TS2318: Cannot find global type 'Object'.
|
||||
error TS2318: Cannot find global type 'RegExp'.
|
||||
error TS2318: Cannot find global type 'String'.
|
||||
error TS2318: Cannot find global type 'TemplateStringsArray'.
|
||||
test.ts(3,8): error TS2304: Cannot find name 'Array'.
|
||||
|
||||
|
||||
@@ -17,6 +18,7 @@ test.ts(3,8): error TS2304: Cannot find name 'Array'.
|
||||
!!! error TS2318: Cannot find global type 'Object'.
|
||||
!!! error TS2318: Cannot find global type 'RegExp'.
|
||||
!!! error TS2318: Cannot find global type 'String'.
|
||||
!!! error TS2318: Cannot find global type 'TemplateStringsArray'.
|
||||
==== test.ts (1 errors) ====
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ error TS2318: Cannot find global type 'Number'.
|
||||
error TS2318: Cannot find global type 'Object'.
|
||||
error TS2318: Cannot find global type 'RegExp'.
|
||||
error TS2318: Cannot find global type 'String'.
|
||||
error TS2318: Cannot find global type 'TemplateStringsArray'.
|
||||
test.ts(3,8): error TS2304: Cannot find name 'Array'.
|
||||
|
||||
|
||||
@@ -17,6 +18,7 @@ test.ts(3,8): error TS2304: Cannot find name 'Array'.
|
||||
!!! error TS2318: Cannot find global type 'Object'.
|
||||
!!! error TS2318: Cannot find global type 'RegExp'.
|
||||
!!! error TS2318: Cannot find global type 'String'.
|
||||
!!! error TS2318: Cannot find global type 'TemplateStringsArray'.
|
||||
==== test.ts (1 errors) ====
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
+27
-1
@@ -8,9 +8,17 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTyped
|
||||
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(28,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(14,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(18,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(22,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,25): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,57): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts (10 errors) ====
|
||||
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts (18 errors) ====
|
||||
interface I {
|
||||
(stringParts: string[], ...rest: boolean[]): I;
|
||||
g: I;
|
||||
@@ -29,6 +37,8 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTyped
|
||||
f `abc${1}def${2}ghi`;
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f `abc`.member
|
||||
~~~~~~~
|
||||
@@ -37,6 +47,8 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTyped
|
||||
f `abc${1}def${2}ghi`.member;
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f `abc`["member"];
|
||||
~~~~~~~
|
||||
@@ -45,18 +57,32 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTyped
|
||||
f `abc${1}def${2}ghi`["member"];
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
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.
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
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.
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f `abc${ true }def${ true }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.
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f.thisIsNotATag(`abc`);
|
||||
|
||||
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(14,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(18,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(22,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(24,25): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(26,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(28,57): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts (6 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`
|
||||
|
||||
f `abc${1}def${2}ghi`;
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f `abc`.member
|
||||
|
||||
f `abc${1}def${2}ghi`.member;
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f `abc`["member"];
|
||||
|
||||
f `abc${1}def${2}ghi`["member"];
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f `abc`[0].member `abc${1}def${2}ghi`;
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`;
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f `abc${ true }def${ true }ghi`["member"].member `abc${ 1 }def${ 2 }ghi`;
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f.thisIsNotATag(`abc`);
|
||||
|
||||
f.thisIsNotATag(`abc${1}def${2}ghi`);
|
||||
@@ -26,10 +26,11 @@ f `abc`[0].member `abc${1}def${2}ghi`;
|
||||
|
||||
f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`;
|
||||
|
||||
f `abc${ true }def${ true }ghi`["member"].member `abc${ 1 }def${ 2 }ghi`;
|
||||
|
||||
f.thisIsNotATag(`abc`);
|
||||
|
||||
f.thisIsNotATag(`abc${1}def${2}ghi`);
|
||||
|
||||
f.thisIsNotATag(`abc${1}def${2}ghi`);
|
||||
|
||||
//// [taggedTemplateStringsWithIncompatibleTypedTagsES6.js]
|
||||
var f;
|
||||
@@ -41,5 +42,6 @@ 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 `abc${true}def${true}ghi`["member"].member `abc${1}def${2}ghi`;
|
||||
f.thisIsNotATag(`abc`);
|
||||
f.thisIsNotATag(`abc${1}def${2}ghi`);
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
=== 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
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMember
|
||||
|
||||
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressions.ts (1 errors) ====
|
||||
interface I {
|
||||
(strs: string[], subs: number[]): I;
|
||||
(strs: string[], ...subs: number[]): I;
|
||||
member: {
|
||||
new (s: string): {
|
||||
new (n: number): {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
//// [taggedTemplateStringsWithManyCallAndMemberExpressionsES6.ts]
|
||||
interface I {
|
||||
(strs: string[], subs: number[]): I;
|
||||
(strs: string[], ...subs: number[]): I;
|
||||
member: {
|
||||
new (s: string): {
|
||||
new (n: number): {
|
||||
|
||||
+6
-6
@@ -2,7 +2,7 @@
|
||||
interface I {
|
||||
>I : I
|
||||
|
||||
(strs: string[], subs: number[]): I;
|
||||
(strs: string[], ...subs: number[]): I;
|
||||
>strs : string[]
|
||||
>subs : number[]
|
||||
>I : I
|
||||
@@ -28,11 +28,11 @@ var f: 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
|
||||
>new new new f `abc${ 0 }def`.member("hello")(42) : boolean
|
||||
>new new f `abc${ 0 }def`.member("hello")(42) : new () => boolean
|
||||
>new f `abc${ 0 }def`.member("hello") : new (n: number) => new () => boolean
|
||||
>f `abc${ 0 }def`.member : new (s: string) => new (n: number) => new () => boolean
|
||||
>f : I
|
||||
>member : any
|
||||
>member : new (s: string) => new (n: number) => new () => boolean
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(16,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(17,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(18,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(19,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(20,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(21,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(12,20): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(14,9): error TS2346: Supplied parameters do not match any signature of call target.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(19,20): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(21,9): error TS2346: Supplied parameters do not match any signature of call target.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts (10 errors) ====
|
||||
function foo(strs: string[]): number;
|
||||
function foo(strs: string[], x: number): string;
|
||||
function foo(strs: string[], x: number, y: number): boolean;
|
||||
function foo(strs: string[], x: number, y: string): {};
|
||||
function foo(...stuff: any[]): any {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var a = foo([]); // number
|
||||
var b = foo([], 1); // string
|
||||
var c = foo([], 1, 2); // boolean
|
||||
var d = foo([], 1, true); // boolean (with error)
|
||||
~~~~
|
||||
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
|
||||
var e = foo([], 1, "2"); // {}
|
||||
var f = foo([], 1, 2, 3); // any (with error)
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2346: Supplied parameters do not match any signature of call target.
|
||||
|
||||
var u = foo ``; // number
|
||||
~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
var v = foo `${1}`; // string
|
||||
~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
var w = foo `${1}${2}`; // boolean
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
var x = foo `${1}${true}`; // boolean (with error)
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~
|
||||
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
|
||||
var y = foo `${1}${"2"}`; // {}
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
var z = foo `${1}${2}${3}`; // any (with error)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2346: Supplied parameters do not match any signature of call target.
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts(12,20): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts(14,9): error TS2346: Supplied parameters do not match any signature of call target.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts(19,20): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts(21,9): error TS2346: Supplied parameters do not match any signature of call target.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts (4 errors) ====
|
||||
function foo(strs: string[]): number;
|
||||
function foo(strs: string[], x: number): string;
|
||||
function foo(strs: string[], x: number, y: number): boolean;
|
||||
function foo(strs: string[], x: number, y: string): {};
|
||||
function foo(...stuff: any[]): any {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var a = foo([]); // number
|
||||
var b = foo([], 1); // string
|
||||
var c = foo([], 1, 2); // boolean
|
||||
var d = foo([], 1, true); // boolean (with error)
|
||||
~~~~
|
||||
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
|
||||
var e = foo([], 1, "2"); // {}
|
||||
var f = foo([], 1, 2, 3); // any (with error)
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2346: Supplied parameters do not match any signature of call target.
|
||||
|
||||
var u = foo ``; // number
|
||||
var v = foo `${1}`; // string
|
||||
var w = foo `${1}${2}`; // boolean
|
||||
var x = foo `${1}${true}`; // boolean (with error)
|
||||
~~~~
|
||||
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
|
||||
var y = foo `${1}${"2"}`; // {}
|
||||
var z = foo `${1}${2}${3}`; // any (with error)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2346: Supplied parameters do not match any signature of call target.
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
//// [taggedTemplateStringsWithOverloadResolution1_ES6.ts]
|
||||
function foo(strs: string[]): number;
|
||||
function foo(strs: string[], x: number): string;
|
||||
function foo(strs: string[], x: number, y: number): boolean;
|
||||
function foo(strs: string[], x: number, y: string): {};
|
||||
function foo(...stuff: any[]): any {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var a = foo([]); // number
|
||||
var b = foo([], 1); // string
|
||||
var c = foo([], 1, 2); // boolean
|
||||
var d = foo([], 1, true); // boolean (with error)
|
||||
var e = foo([], 1, "2"); // {}
|
||||
var f = foo([], 1, 2, 3); // any (with error)
|
||||
|
||||
var u = foo ``; // number
|
||||
var v = foo `${1}`; // string
|
||||
var w = foo `${1}${2}`; // boolean
|
||||
var x = foo `${1}${true}`; // boolean (with error)
|
||||
var y = foo `${1}${"2"}`; // {}
|
||||
var z = foo `${1}${2}${3}`; // any (with error)
|
||||
|
||||
|
||||
//// [taggedTemplateStringsWithOverloadResolution1_ES6.js]
|
||||
function foo() {
|
||||
var stuff = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
stuff[_i - 0] = arguments[_i];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
var a = foo([]); // number
|
||||
var b = foo([], 1); // string
|
||||
var c = foo([], 1, 2); // boolean
|
||||
var d = foo([], 1, true); // boolean (with error)
|
||||
var e = foo([], 1, "2"); // {}
|
||||
var f = foo([], 1, 2, 3); // any (with error)
|
||||
var u = foo ``; // number
|
||||
var v = foo `${1}`; // string
|
||||
var w = foo `${1}${2}`; // boolean
|
||||
var x = foo `${1}${true}`; // boolean (with error)
|
||||
var y = foo `${1}${"2"}`; // {}
|
||||
var z = foo `${1}${2}${3}`; // any (with error)
|
||||
@@ -39,34 +39,34 @@ f `abc${1}def${2}ghi`;
|
||||
>f : I
|
||||
|
||||
f `abc`.member
|
||||
>f `abc`.member : any
|
||||
>f `abc`.member : I
|
||||
>f : I
|
||||
>member : any
|
||||
>member : I
|
||||
|
||||
f `abc${1}def${2}ghi`.member;
|
||||
>f `abc${1}def${2}ghi`.member : any
|
||||
>f `abc${1}def${2}ghi`.member : I
|
||||
>f : I
|
||||
>member : any
|
||||
>member : I
|
||||
|
||||
f `abc`["member"];
|
||||
>f `abc`["member"] : any
|
||||
>f `abc`["member"] : I
|
||||
>f : I
|
||||
|
||||
f `abc${1}def${2}ghi`["member"];
|
||||
>f `abc${1}def${2}ghi`["member"] : any
|
||||
>f `abc${1}def${2}ghi`["member"] : I
|
||||
>f : I
|
||||
|
||||
f `abc`[0].member `abc${1}def${2}ghi`;
|
||||
>f `abc`[0].member : any
|
||||
>f `abc`[0] : any
|
||||
>f `abc`[0].member : I
|
||||
>f `abc`[0] : I
|
||||
>f : I
|
||||
>member : any
|
||||
>member : I
|
||||
|
||||
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 `abc${1}def${2}ghi`["member"].member : I
|
||||
>f `abc${1}def${2}ghi`["member"] : I
|
||||
>f : I
|
||||
>member : any
|
||||
>member : I
|
||||
|
||||
f.thisIsNotATag(`abc`);
|
||||
>f.thisIsNotATag(`abc`) : void
|
||||
|
||||
@@ -3,12 +3,15 @@ tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts(3,5): err
|
||||
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(1,9): error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts (5 errors) ====
|
||||
==== tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts (6 errors) ====
|
||||
var x = {
|
||||
~
|
||||
~
|
||||
a: `abc${ 123 }def`,
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
`b`: 321
|
||||
~~~~~~~
|
||||
@@ -19,6 +22,8 @@ tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts(4,1): err
|
||||
!!! error TS1005: ',' expected.
|
||||
~~~
|
||||
!!! error TS1134: Variable declaration expected.
|
||||
~~~~~~~
|
||||
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
@@ -2,11 +2,14 @@ tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts(3,5):
|
||||
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(1,9): error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts (4 errors) ====
|
||||
==== tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts (5 errors) ====
|
||||
var x = {
|
||||
~
|
||||
a: `abc${ 123 }def`,
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
`b`: 321
|
||||
~~~
|
||||
!!! error TS1136: Property assignment expected.
|
||||
@@ -14,6 +17,8 @@ tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts(4,1):
|
||||
!!! error TS1005: ',' expected.
|
||||
~~~
|
||||
!!! error TS1134: Variable declaration expected.
|
||||
~~~~~~~
|
||||
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
@@ -3,11 +3,13 @@ tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts(2,5): err
|
||||
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(1,9): error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts (5 errors) ====
|
||||
==== tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts (6 errors) ====
|
||||
var x = {
|
||||
~
|
||||
~
|
||||
`a`: 321
|
||||
~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
@@ -17,6 +19,8 @@ tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts(3,1): err
|
||||
!!! error TS1005: ',' expected.
|
||||
~~~
|
||||
!!! error TS1134: Variable declaration expected.
|
||||
~~~~~~~
|
||||
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
@@ -3,11 +3,13 @@ tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts(2,5): err
|
||||
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(1,9): error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts (5 errors) ====
|
||||
==== tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts (6 errors) ====
|
||||
var x = {
|
||||
~
|
||||
~
|
||||
`abc${ 123 }def${ 456 }ghi`: 321
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
@@ -17,6 +19,8 @@ tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts(3,1): err
|
||||
!!! error TS1005: ',' expected.
|
||||
~~~
|
||||
!!! error TS1134: Variable declaration expected.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
@@ -2,10 +2,12 @@ tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts(2,5):
|
||||
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(1,9): error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts (4 errors) ====
|
||||
==== tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts (5 errors) ====
|
||||
var x = {
|
||||
~
|
||||
`a`: 321
|
||||
~~~
|
||||
!!! error TS1136: Property assignment expected.
|
||||
@@ -13,6 +15,8 @@ tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts(3,1):
|
||||
!!! error TS1005: ',' expected.
|
||||
~~~
|
||||
!!! error TS1134: Variable declaration expected.
|
||||
~~~~~~~
|
||||
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
@@ -2,10 +2,12 @@ tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts(2,5):
|
||||
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(1,9): error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts (4 errors) ====
|
||||
==== tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts (5 errors) ====
|
||||
var x = {
|
||||
~
|
||||
`abc${ 123 }def${ 456 }ghi`: 321
|
||||
~~~~~~
|
||||
!!! error TS1136: Property assignment expected.
|
||||
@@ -13,6 +15,8 @@ tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts(3,1):
|
||||
!!! error TS1005: ',' expected.
|
||||
~~~
|
||||
!!! error TS1134: Variable declaration expected.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
@@ -6,6 +6,7 @@ error TS2318: Cannot find global type 'Number'.
|
||||
error TS2318: Cannot find global type 'Object'.
|
||||
error TS2318: Cannot find global type 'RegExp'.
|
||||
error TS2318: Cannot find global type 'String'.
|
||||
error TS2318: Cannot find global type 'TemplateStringsArray'.
|
||||
tests/cases/compiler/typeCheckTypeArgument.ts(3,19): error TS2304: Cannot find name 'UNKNOWN'.
|
||||
tests/cases/compiler/typeCheckTypeArgument.ts(5,26): error TS2304: Cannot find name 'UNKNOWN'.
|
||||
tests/cases/compiler/typeCheckTypeArgument.ts(7,21): error TS2304: Cannot find name 'UNKNOWN'.
|
||||
@@ -22,6 +23,7 @@ tests/cases/compiler/typeCheckTypeArgument.ts(15,13): error TS2304: Cannot find
|
||||
!!! error TS2318: Cannot find global type 'Object'.
|
||||
!!! error TS2318: Cannot find global type 'RegExp'.
|
||||
!!! error TS2318: Cannot find global type 'String'.
|
||||
!!! error TS2318: Cannot find global type 'TemplateStringsArray'.
|
||||
==== tests/cases/compiler/typeCheckTypeArgument.ts (6 errors) ====
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
+2
@@ -25,6 +25,8 @@ f `abc`[0].member `abc${1}def${2}ghi`;
|
||||
|
||||
f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`;
|
||||
|
||||
f `abc${ true }def${ true }ghi`["member"].member `abc${ 1 }def${ 2 }ghi`;
|
||||
|
||||
f.thisIsNotATag(`abc`);
|
||||
|
||||
f.thisIsNotATag(`abc${1}def${2}ghi`);
|
||||
|
||||
+3
-1
@@ -26,6 +26,8 @@ f `abc`[0].member `abc${1}def${2}ghi`;
|
||||
|
||||
f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`;
|
||||
|
||||
f `abc${ true }def${ true }ghi`["member"].member `abc${ 1 }def${ 2 }ghi`;
|
||||
|
||||
f.thisIsNotATag(`abc`);
|
||||
|
||||
f.thisIsNotATag(`abc${1}def${2}ghi`);
|
||||
f.thisIsNotATag(`abc${1}def${2}ghi`);
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
interface I {
|
||||
(strs: string[], subs: number[]): I;
|
||||
(strs: string[], ...subs: number[]): I;
|
||||
member: {
|
||||
new (s: string): {
|
||||
new (n: number): {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// @target: ES6
|
||||
interface I {
|
||||
(strs: string[], subs: number[]): I;
|
||||
(strs: string[], ...subs: number[]): I;
|
||||
member: {
|
||||
new (s: string): {
|
||||
new (n: number): {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
function foo(strs: string[]): number;
|
||||
function foo(strs: string[], x: number): string;
|
||||
function foo(strs: string[], x: number, y: number): boolean;
|
||||
function foo(strs: string[], x: number, y: string): {};
|
||||
function foo(...stuff: any[]): any {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var a = foo([]); // number
|
||||
var b = foo([], 1); // string
|
||||
var c = foo([], 1, 2); // boolean
|
||||
var d = foo([], 1, true); // boolean (with error)
|
||||
var e = foo([], 1, "2"); // {}
|
||||
var f = foo([], 1, 2, 3); // any (with error)
|
||||
|
||||
var u = foo ``; // number
|
||||
var v = foo `${1}`; // string
|
||||
var w = foo `${1}${2}`; // boolean
|
||||
var x = foo `${1}${true}`; // boolean (with error)
|
||||
var y = foo `${1}${"2"}`; // {}
|
||||
var z = foo `${1}${2}${3}`; // any (with error)
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
//@target: es6
|
||||
function foo(strs: string[]): number;
|
||||
function foo(strs: string[], x: number): string;
|
||||
function foo(strs: string[], x: number, y: number): boolean;
|
||||
function foo(strs: string[], x: number, y: string): {};
|
||||
function foo(...stuff: any[]): any {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var a = foo([]); // number
|
||||
var b = foo([], 1); // string
|
||||
var c = foo([], 1, 2); // boolean
|
||||
var d = foo([], 1, true); // boolean (with error)
|
||||
var e = foo([], 1, "2"); // {}
|
||||
var f = foo([], 1, 2, 3); // any (with error)
|
||||
|
||||
var u = foo ``; // number
|
||||
var v = foo `${1}`; // string
|
||||
var w = foo `${1}${2}`; // boolean
|
||||
var x = foo `${1}${true}`; // boolean (with error)
|
||||
var y = foo `${1}${"2"}`; // {}
|
||||
var z = foo `${1}${2}${3}`; // any (with error)
|
||||
Reference in New Issue
Block a user