mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Instantiation expressions (#47607)
* Permit type arguments in references to generic functions * Accept new baselines * Delete pointless fourslash test * Fix lint issue * Finalize implementation * Add tests * Accept new baselines * Properly handle instantiation of instantiation expression types * Accept new API baselines * Fix lint error * Add more tests * Properly handle unions/intersections of generic types * Add more tests * More permissive parsing of type arguments in member expressions * Update tests * Accept new baselines
This commit is contained in:
+148
-71
@@ -4592,7 +4592,7 @@ namespace ts {
|
||||
// get symbol of the first identifier of the entityName
|
||||
let meaning: SymbolFlags;
|
||||
if (entityName.parent.kind === SyntaxKind.TypeQuery ||
|
||||
isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) ||
|
||||
entityName.parent.kind === SyntaxKind.ExpressionWithTypeArguments && !isPartOfTypeNode(entityName.parent) ||
|
||||
entityName.parent.kind === SyntaxKind.ComputedPropertyName) {
|
||||
// Typeof value
|
||||
meaning = SymbolFlags.Value | SymbolFlags.ExportValue;
|
||||
@@ -11320,7 +11320,6 @@ namespace ts {
|
||||
* Converts an AnonymousType to a ResolvedType.
|
||||
*/
|
||||
function resolveAnonymousTypeMembers(type: AnonymousType) {
|
||||
const symbol = getMergedSymbol(type.symbol);
|
||||
if (type.target) {
|
||||
setStructuredTypeMembers(type, emptySymbols, emptyArray, emptyArray, emptyArray);
|
||||
const members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper!, /*mappingThisOnly*/ false);
|
||||
@@ -11328,82 +11327,83 @@ namespace ts {
|
||||
const constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, SignatureKind.Construct), type.mapper!);
|
||||
const indexInfos = instantiateIndexInfos(getIndexInfosOfType(type.target), type.mapper!);
|
||||
setStructuredTypeMembers(type, members, callSignatures, constructSignatures, indexInfos);
|
||||
return;
|
||||
}
|
||||
else if (symbol.flags & SymbolFlags.TypeLiteral) {
|
||||
const symbol = getMergedSymbol(type.symbol);
|
||||
if (symbol.flags & SymbolFlags.TypeLiteral) {
|
||||
setStructuredTypeMembers(type, emptySymbols, emptyArray, emptyArray, emptyArray);
|
||||
const members = getMembersOfSymbol(symbol);
|
||||
const callSignatures = getSignaturesOfSymbol(members.get(InternalSymbolName.Call));
|
||||
const constructSignatures = getSignaturesOfSymbol(members.get(InternalSymbolName.New));
|
||||
const indexInfos = getIndexInfosOfSymbol(symbol);
|
||||
setStructuredTypeMembers(type, members, callSignatures, constructSignatures, indexInfos);
|
||||
return;
|
||||
}
|
||||
// Combinations of function, class, enum and module
|
||||
let members = emptySymbols;
|
||||
let indexInfos: IndexInfo[] | undefined;
|
||||
if (symbol.exports) {
|
||||
members = getExportsOfSymbol(symbol);
|
||||
if (symbol === globalThisSymbol) {
|
||||
const varsOnly = new Map<string, Symbol>() as SymbolTable;
|
||||
members.forEach(p => {
|
||||
if (!(p.flags & SymbolFlags.BlockScoped)) {
|
||||
varsOnly.set(p.escapedName, p);
|
||||
}
|
||||
});
|
||||
members = varsOnly;
|
||||
}
|
||||
}
|
||||
let baseConstructorIndexInfo: IndexInfo | undefined;
|
||||
setStructuredTypeMembers(type, members, emptyArray, emptyArray, emptyArray);
|
||||
if (symbol.flags & SymbolFlags.Class) {
|
||||
const classType = getDeclaredTypeOfClassOrInterface(symbol);
|
||||
const baseConstructorType = getBaseConstructorTypeOfClass(classType);
|
||||
if (baseConstructorType.flags & (TypeFlags.Object | TypeFlags.Intersection | TypeFlags.TypeVariable)) {
|
||||
members = createSymbolTable(getNamedOrIndexSignatureMembers(members));
|
||||
addInheritedMembers(members, getPropertiesOfType(baseConstructorType));
|
||||
}
|
||||
else if (baseConstructorType === anyType) {
|
||||
baseConstructorIndexInfo = createIndexInfo(stringType, anyType, /*isReadonly*/ false);
|
||||
}
|
||||
}
|
||||
|
||||
const indexSymbol = getIndexSymbolFromSymbolTable(members);
|
||||
if (indexSymbol) {
|
||||
indexInfos = getIndexInfosOfIndexSymbol(indexSymbol);
|
||||
}
|
||||
else {
|
||||
// Combinations of function, class, enum and module
|
||||
let members = emptySymbols;
|
||||
let indexInfos: IndexInfo[] | undefined;
|
||||
if (symbol.exports) {
|
||||
members = getExportsOfSymbol(symbol);
|
||||
if (symbol === globalThisSymbol) {
|
||||
const varsOnly = new Map<string, Symbol>() as SymbolTable;
|
||||
members.forEach(p => {
|
||||
if (!(p.flags & SymbolFlags.BlockScoped)) {
|
||||
varsOnly.set(p.escapedName, p);
|
||||
}
|
||||
});
|
||||
members = varsOnly;
|
||||
}
|
||||
if (baseConstructorIndexInfo) {
|
||||
indexInfos = append(indexInfos, baseConstructorIndexInfo);
|
||||
}
|
||||
let baseConstructorIndexInfo: IndexInfo | undefined;
|
||||
setStructuredTypeMembers(type, members, emptyArray, emptyArray, emptyArray);
|
||||
if (symbol.flags & SymbolFlags.Class) {
|
||||
const classType = getDeclaredTypeOfClassOrInterface(symbol);
|
||||
const baseConstructorType = getBaseConstructorTypeOfClass(classType);
|
||||
if (baseConstructorType.flags & (TypeFlags.Object | TypeFlags.Intersection | TypeFlags.TypeVariable)) {
|
||||
members = createSymbolTable(getNamedOrIndexSignatureMembers(members));
|
||||
addInheritedMembers(members, getPropertiesOfType(baseConstructorType));
|
||||
}
|
||||
else if (baseConstructorType === anyType) {
|
||||
baseConstructorIndexInfo = createIndexInfo(stringType, anyType, /*isReadonly*/ false);
|
||||
}
|
||||
if (symbol.flags & SymbolFlags.Enum && (getDeclaredTypeOfSymbol(symbol).flags & TypeFlags.Enum ||
|
||||
some(type.properties, prop => !!(getTypeOfSymbol(prop).flags & TypeFlags.NumberLike)))) {
|
||||
indexInfos = append(indexInfos, enumNumberIndexInfo);
|
||||
}
|
||||
|
||||
const indexSymbol = getIndexSymbolFromSymbolTable(members);
|
||||
if (indexSymbol) {
|
||||
indexInfos = getIndexInfosOfIndexSymbol(indexSymbol);
|
||||
}
|
||||
setStructuredTypeMembers(type, members, emptyArray, emptyArray, indexInfos || emptyArray);
|
||||
// We resolve the members before computing the signatures because a signature may use
|
||||
// typeof with a qualified name expression that circularly references the type we are
|
||||
// in the process of resolving (see issue #6072). The temporarily empty signature list
|
||||
// will never be observed because a qualified name can't reference signatures.
|
||||
if (symbol.flags & (SymbolFlags.Function | SymbolFlags.Method)) {
|
||||
type.callSignatures = getSignaturesOfSymbol(symbol);
|
||||
}
|
||||
// And likewise for construct signatures for classes
|
||||
if (symbol.flags & SymbolFlags.Class) {
|
||||
const classType = getDeclaredTypeOfClassOrInterface(symbol);
|
||||
let constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get(InternalSymbolName.Constructor)) : emptyArray;
|
||||
if (symbol.flags & SymbolFlags.Function) {
|
||||
constructSignatures = addRange(constructSignatures.slice(), mapDefined(
|
||||
type.callSignatures,
|
||||
sig => isJSConstructor(sig.declaration) ?
|
||||
createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & SignatureFlags.PropagatingFlags) :
|
||||
undefined));
|
||||
}
|
||||
else {
|
||||
if (baseConstructorIndexInfo) {
|
||||
indexInfos = append(indexInfos, baseConstructorIndexInfo);
|
||||
}
|
||||
if (symbol.flags & SymbolFlags.Enum && (getDeclaredTypeOfSymbol(symbol).flags & TypeFlags.Enum ||
|
||||
some(type.properties, prop => !!(getTypeOfSymbol(prop).flags & TypeFlags.NumberLike)))) {
|
||||
indexInfos = append(indexInfos, enumNumberIndexInfo);
|
||||
}
|
||||
}
|
||||
setStructuredTypeMembers(type, members, emptyArray, emptyArray, indexInfos || emptyArray);
|
||||
// We resolve the members before computing the signatures because a signature may use
|
||||
// typeof with a qualified name expression that circularly references the type we are
|
||||
// in the process of resolving (see issue #6072). The temporarily empty signature list
|
||||
// will never be observed because a qualified name can't reference signatures.
|
||||
if (symbol.flags & (SymbolFlags.Function | SymbolFlags.Method)) {
|
||||
type.callSignatures = getSignaturesOfSymbol(symbol);
|
||||
}
|
||||
// And likewise for construct signatures for classes
|
||||
if (symbol.flags & SymbolFlags.Class) {
|
||||
const classType = getDeclaredTypeOfClassOrInterface(symbol);
|
||||
let constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get(InternalSymbolName.Constructor)) : emptyArray;
|
||||
if (symbol.flags & SymbolFlags.Function) {
|
||||
constructSignatures = addRange(constructSignatures.slice(), mapDefined(
|
||||
type.callSignatures,
|
||||
sig => isJSConstructor(sig.declaration) ?
|
||||
createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & SignatureFlags.PropagatingFlags) :
|
||||
undefined));
|
||||
}
|
||||
if (!constructSignatures.length) {
|
||||
constructSignatures = getDefaultConstructSignatures(classType);
|
||||
}
|
||||
type.constructSignatures = constructSignatures;
|
||||
if (!constructSignatures.length) {
|
||||
constructSignatures = getDefaultConstructSignatures(classType);
|
||||
}
|
||||
type.constructSignatures = constructSignatures;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13719,7 +13719,7 @@ namespace ts {
|
||||
// The expression is processed as an identifier expression (section 4.3)
|
||||
// or property access expression(section 4.10),
|
||||
// the widened type(section 3.9) of which becomes the result.
|
||||
const type = isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName);
|
||||
const type = checkExpressionWithTypeArguments(node);
|
||||
links.resolvedType = getRegularTypeOfLiteralType(getWidenedType(type));
|
||||
}
|
||||
return links.resolvedType;
|
||||
@@ -16627,7 +16627,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getObjectTypeInstantiation(type: AnonymousType | DeferredTypeReference, mapper: TypeMapper, aliasSymbol?: Symbol, aliasTypeArguments?: readonly Type[]) {
|
||||
const declaration = type.objectFlags & ObjectFlags.Reference ? (type as TypeReference).node! : type.symbol.declarations![0];
|
||||
const declaration = type.objectFlags & ObjectFlags.Reference ? (type as TypeReference).node! :
|
||||
type.objectFlags & ObjectFlags.InstantiationExpressionType ? (type as InstantiationExpressionType).node :
|
||||
type.symbol.declarations![0];
|
||||
const links = getNodeLinks(declaration);
|
||||
const target = type.objectFlags & ObjectFlags.Reference ? links.resolvedType! as DeferredTypeReference :
|
||||
type.objectFlags & ObjectFlags.Instantiated ? type.target! : type;
|
||||
@@ -16643,8 +16645,8 @@ namespace ts {
|
||||
outerTypeParameters = addRange(outerTypeParameters, templateTagParameters);
|
||||
}
|
||||
typeParameters = outerTypeParameters || emptyArray;
|
||||
const allDeclarations = type.objectFlags & ObjectFlags.Reference ? [declaration] : type.symbol.declarations!;
|
||||
typeParameters = (target.objectFlags & ObjectFlags.Reference || target.symbol.flags & SymbolFlags.Method || target.symbol.flags & SymbolFlags.TypeLiteral) && !target.aliasTypeArguments ?
|
||||
const allDeclarations = type.objectFlags & (ObjectFlags.Reference | ObjectFlags.InstantiationExpressionType) ? [declaration] : type.symbol.declarations!;
|
||||
typeParameters = (target.objectFlags & (ObjectFlags.Reference | ObjectFlags.InstantiationExpressionType) || target.symbol.flags & SymbolFlags.Method || target.symbol.flags & SymbolFlags.TypeLiteral) && !target.aliasTypeArguments ?
|
||||
filter(typeParameters, tp => some(allDeclarations, d => isTypeParameterPossiblyReferenced(tp, d))) :
|
||||
typeParameters;
|
||||
links.outerTypeParameters = typeParameters;
|
||||
@@ -16825,6 +16827,9 @@ namespace ts {
|
||||
mapper = combineTypeMappers(makeUnaryTypeMapper(origTypeParameter, freshTypeParameter), mapper);
|
||||
freshTypeParameter.mapper = mapper;
|
||||
}
|
||||
if (type.objectFlags & ObjectFlags.InstantiationExpressionType) {
|
||||
(result as InstantiationExpressionType).node = (type as InstantiationExpressionType).node;
|
||||
}
|
||||
result.target = type;
|
||||
result.mapper = mapper;
|
||||
result.aliasSymbol = aliasSymbol || type.aliasSymbol;
|
||||
@@ -21575,7 +21580,7 @@ namespace ts {
|
||||
type.flags & TypeFlags.Object && !isNonGenericTopLevelType(type) && (
|
||||
objectFlags & ObjectFlags.Reference && ((type as TypeReference).node || forEach(getTypeArguments(type as TypeReference), couldContainTypeVariables)) ||
|
||||
objectFlags & ObjectFlags.Anonymous && type.symbol && type.symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral) && type.symbol.declarations ||
|
||||
objectFlags & (ObjectFlags.Mapped | ObjectFlags.ReverseMapped | ObjectFlags.ObjectRestType)) ||
|
||||
objectFlags & (ObjectFlags.Mapped | ObjectFlags.ReverseMapped | ObjectFlags.ObjectRestType | ObjectFlags.InstantiationExpressionType)) ||
|
||||
type.flags & TypeFlags.UnionOrIntersection && !(type.flags & TypeFlags.EnumLiteral) && !isNonGenericTopLevelType(type) && some((type as UnionOrIntersectionType).types, couldContainTypeVariables));
|
||||
if (type.flags & TypeFlags.ObjectFlagsType) {
|
||||
(type as ObjectFlagsType).objectFlags |= ObjectFlags.CouldContainTypeVariablesComputed | (result ? ObjectFlags.CouldContainTypeVariables : 0);
|
||||
@@ -31501,6 +31506,76 @@ namespace ts {
|
||||
getNonNullableType(checkExpression(node.expression));
|
||||
}
|
||||
|
||||
function checkExpressionWithTypeArguments(node: ExpressionWithTypeArguments | TypeQueryNode) {
|
||||
checkGrammarExpressionWithTypeArguments(node);
|
||||
const exprType = node.kind === SyntaxKind.ExpressionWithTypeArguments ? checkExpression(node.expression) :
|
||||
isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) :
|
||||
checkExpression(node.exprName);
|
||||
const typeArguments = node.typeArguments;
|
||||
if (exprType === silentNeverType || isErrorType(exprType) || !some(typeArguments)) {
|
||||
return exprType;
|
||||
}
|
||||
let hasSomeApplicableSignature = false;
|
||||
let nonApplicableType: Type | undefined;
|
||||
const result = getInstantiatedType(exprType);
|
||||
const errorType = hasSomeApplicableSignature ? nonApplicableType : exprType;
|
||||
if (errorType) {
|
||||
diagnostics.add(createDiagnosticForNodeArray(getSourceFileOfNode(node), typeArguments, Diagnostics.Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable, typeToString(errorType)));
|
||||
}
|
||||
return result;
|
||||
|
||||
function getInstantiatedType(type: Type): Type {
|
||||
let hasSignatures = false;
|
||||
let hasApplicableSignature = false;
|
||||
const result = getInstantiatedTypePart(type);
|
||||
hasSomeApplicableSignature ||= hasApplicableSignature;
|
||||
if (hasSignatures && !hasApplicableSignature) {
|
||||
nonApplicableType ??= type;
|
||||
}
|
||||
return result;
|
||||
|
||||
function getInstantiatedTypePart(type: Type): Type {
|
||||
if (type.flags & TypeFlags.Object) {
|
||||
const resolved = resolveStructuredTypeMembers(type as ObjectType);
|
||||
const callSignatures = getInstantiatedSignatures(resolved.callSignatures);
|
||||
const constructSignatures = getInstantiatedSignatures(resolved.constructSignatures);
|
||||
hasSignatures ||= resolved.callSignatures.length !== 0 || resolved.constructSignatures.length !== 0;
|
||||
hasApplicableSignature ||= callSignatures.length !== 0 || constructSignatures.length !== 0;
|
||||
if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) {
|
||||
const result = createAnonymousType(undefined, resolved.members, callSignatures, constructSignatures, resolved.indexInfos) as ResolvedType & InstantiationExpressionType;
|
||||
result.objectFlags |= ObjectFlags.InstantiationExpressionType;
|
||||
result.node = node;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else if (type.flags & TypeFlags.InstantiableNonPrimitive) {
|
||||
const constraint = getBaseConstraintOfType(type);
|
||||
if (constraint) {
|
||||
const instantiated = getInstantiatedTypePart(constraint);
|
||||
if (instantiated !== constraint) {
|
||||
return instantiated;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (type.flags & TypeFlags.Union) {
|
||||
return mapType(type, getInstantiatedType);
|
||||
}
|
||||
else if (type.flags & TypeFlags.Intersection) {
|
||||
return getIntersectionType(sameMap((type as IntersectionType).types, getInstantiatedTypePart));
|
||||
}
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
function getInstantiatedSignatures(signatures: readonly Signature[]) {
|
||||
const applicableSignatures = filter(signatures, sig => !!sig.typeParameters && hasCorrectTypeArgumentArity(sig, typeArguments));
|
||||
return sameMap(applicableSignatures, sig => {
|
||||
const typeArgumentTypes = checkTypeArguments(sig, typeArguments!, /*reportErrors*/ true);
|
||||
return typeArgumentTypes ? getSignatureInstantiation(sig, typeArgumentTypes, isInJSFile(sig.declaration)) : sig;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function checkMetaProperty(node: MetaProperty): Type {
|
||||
checkGrammarMetaProperty(node);
|
||||
|
||||
@@ -34263,6 +34338,8 @@ namespace ts {
|
||||
return checkAssertion(node as AssertionExpression);
|
||||
case SyntaxKind.NonNullExpression:
|
||||
return checkNonNullAssertion(node as NonNullExpression);
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return checkExpressionWithTypeArguments(node as ExpressionWithTypeArguments);
|
||||
case SyntaxKind.MetaProperty:
|
||||
return checkMetaProperty(node as MetaProperty);
|
||||
case SyntaxKind.DeleteExpression:
|
||||
@@ -43182,7 +43259,7 @@ namespace ts {
|
||||
return some(types, checkGrammarExpressionWithTypeArguments);
|
||||
}
|
||||
|
||||
function checkGrammarExpressionWithTypeArguments(node: ExpressionWithTypeArguments) {
|
||||
function checkGrammarExpressionWithTypeArguments(node: ExpressionWithTypeArguments | TypeQueryNode) {
|
||||
return checkGrammarTypeArguments(node, node.typeArguments);
|
||||
}
|
||||
|
||||
|
||||
@@ -1152,10 +1152,6 @@
|
||||
"category": "Error",
|
||||
"code": 1383
|
||||
},
|
||||
"A 'new' expression with type arguments must always be followed by a parenthesized argument list.": {
|
||||
"category": "Error",
|
||||
"code": 1384
|
||||
},
|
||||
"Function type notation must be parenthesized when used in a union type.": {
|
||||
"category": "Error",
|
||||
"code": 1385
|
||||
@@ -2703,6 +2699,10 @@
|
||||
"category": "Error",
|
||||
"code": 2634
|
||||
},
|
||||
"Type '{0}' has no signatures for which the type argument list is applicable.": {
|
||||
"category": "Error",
|
||||
"code": 2635
|
||||
},
|
||||
|
||||
"Cannot augment module '{0}' with value exports because it resolves to a non-module entity.": {
|
||||
"category": "Error",
|
||||
|
||||
@@ -1727,6 +1727,8 @@ namespace ts {
|
||||
return emitAsExpression(node as AsExpression);
|
||||
case SyntaxKind.NonNullExpression:
|
||||
return emitNonNullExpression(node as NonNullExpression);
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return emitExpressionWithTypeArguments(node as ExpressionWithTypeArguments);
|
||||
case SyntaxKind.MetaProperty:
|
||||
return emitMetaProperty(node as MetaProperty);
|
||||
case SyntaxKind.SyntheticExpression:
|
||||
@@ -2227,6 +2229,7 @@ namespace ts {
|
||||
writeKeyword("typeof");
|
||||
writeSpace();
|
||||
emit(node.exprName);
|
||||
emitTypeArguments(node, node.typeArguments);
|
||||
}
|
||||
|
||||
function emitTypeLiteral(node: TypeLiteralNode) {
|
||||
|
||||
@@ -1839,17 +1839,19 @@ namespace ts {
|
||||
}
|
||||
|
||||
// @api
|
||||
function createTypeQueryNode(exprName: EntityName) {
|
||||
function createTypeQueryNode(exprName: EntityName, typeArguments?: readonly TypeNode[]) {
|
||||
const node = createBaseNode<TypeQueryNode>(SyntaxKind.TypeQuery);
|
||||
node.exprName = exprName;
|
||||
node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
|
||||
node.transformFlags = TransformFlags.ContainsTypeScript;
|
||||
return node;
|
||||
}
|
||||
|
||||
// @api
|
||||
function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName) {
|
||||
function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName, typeArguments?: readonly TypeNode[]) {
|
||||
return node.exprName !== exprName
|
||||
? update(createTypeQueryNode(exprName), node)
|
||||
|| node.typeArguments !== typeArguments
|
||||
? update(createTypeQueryNode(exprName, typeArguments), node)
|
||||
: node;
|
||||
}
|
||||
|
||||
|
||||
+60
-74
@@ -180,7 +180,8 @@ namespace ts {
|
||||
visitNode(cbNode, (node as TypePredicateNode).parameterName) ||
|
||||
visitNode(cbNode, (node as TypePredicateNode).type);
|
||||
case SyntaxKind.TypeQuery:
|
||||
return visitNode(cbNode, (node as TypeQueryNode).exprName);
|
||||
return visitNode(cbNode, (node as TypeQueryNode).exprName) ||
|
||||
visitNodes(cbNode, cbNodes, (node as TypeQueryNode).typeArguments);
|
||||
case SyntaxKind.TypeLiteral:
|
||||
return visitNodes(cbNode, cbNodes, (node as TypeLiteralNode).members);
|
||||
case SyntaxKind.ArrayType:
|
||||
@@ -3078,7 +3079,9 @@ namespace ts {
|
||||
function parseTypeQuery(): TypeQueryNode {
|
||||
const pos = getNodePos();
|
||||
parseExpected(SyntaxKind.TypeOfKeyword);
|
||||
return finishNode(factory.createTypeQueryNode(parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ true)), pos);
|
||||
const entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ true);
|
||||
const typeArguments = tryParseTypeArguments();
|
||||
return finishNode(factory.createTypeQueryNode(entityName, typeArguments), pos);
|
||||
}
|
||||
|
||||
function parseTypeParameter(): TypeParameterDeclaration {
|
||||
@@ -5428,12 +5431,6 @@ namespace ts {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!questionDotToken && token() === SyntaxKind.ExclamationToken && !scanner.hasPrecedingLineBreak()) {
|
||||
nextToken();
|
||||
expression = finishNode(factory.createNonNullExpression(expression), pos);
|
||||
continue;
|
||||
}
|
||||
|
||||
// when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName
|
||||
if ((questionDotToken || !inDecoratorContext()) && parseOptional(SyntaxKind.OpenBracketToken)) {
|
||||
expression = parseElementAccessExpressionRest(pos, expression, questionDotToken);
|
||||
@@ -5441,10 +5438,26 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (isTemplateStartOfTaggedTemplate()) {
|
||||
expression = parseTaggedTemplateRest(pos, expression, questionDotToken, /*typeArguments*/ undefined);
|
||||
// Absorb type arguments into TemplateExpression when preceding expression is ExpressionWithTypeArguments
|
||||
expression = !questionDotToken && expression.kind === SyntaxKind.ExpressionWithTypeArguments ?
|
||||
parseTaggedTemplateRest(pos, (expression as ExpressionWithTypeArguments).expression, questionDotToken, (expression as ExpressionWithTypeArguments).typeArguments) :
|
||||
parseTaggedTemplateRest(pos, expression, questionDotToken, /*typeArguments*/ undefined);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!questionDotToken) {
|
||||
if (token() === SyntaxKind.ExclamationToken && !scanner.hasPrecedingLineBreak()) {
|
||||
nextToken();
|
||||
expression = finishNode(factory.createNonNullExpression(expression), pos);
|
||||
continue;
|
||||
}
|
||||
const typeArguments = tryParse(parseTypeArgumentsInExpression);
|
||||
if (typeArguments) {
|
||||
expression = finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return expression as MemberExpression;
|
||||
}
|
||||
}
|
||||
@@ -5471,39 +5484,30 @@ namespace ts {
|
||||
function parseCallExpressionRest(pos: number, expression: LeftHandSideExpression): LeftHandSideExpression {
|
||||
while (true) {
|
||||
expression = parseMemberExpressionRest(pos, expression, /*allowOptionalChain*/ true);
|
||||
let typeArguments: NodeArray<TypeNode> | undefined;
|
||||
const questionDotToken = parseOptionalToken(SyntaxKind.QuestionDotToken);
|
||||
// handle 'foo<<T>()'
|
||||
// parse template arguments only in TypeScript files (not in JavaScript files).
|
||||
if ((contextFlags & NodeFlags.JavaScriptFile) === 0 && (token() === SyntaxKind.LessThanToken || token() === SyntaxKind.LessThanLessThanToken)) {
|
||||
// See if this is the start of a generic invocation. If so, consume it and
|
||||
// keep checking for postfix expressions. Otherwise, it's just a '<' that's
|
||||
// part of an arithmetic expression. Break out so we consume it higher in the
|
||||
// stack.
|
||||
const typeArguments = tryParse(parseTypeArgumentsInExpression);
|
||||
if (typeArguments) {
|
||||
if (isTemplateStartOfTaggedTemplate()) {
|
||||
expression = parseTaggedTemplateRest(pos, expression, questionDotToken, typeArguments);
|
||||
continue;
|
||||
}
|
||||
|
||||
const argumentList = parseArgumentList();
|
||||
const callExpr = questionDotToken || tryReparseOptionalChain(expression) ?
|
||||
factory.createCallChain(expression, questionDotToken, typeArguments, argumentList) :
|
||||
factory.createCallExpression(expression, typeArguments, argumentList);
|
||||
expression = finishNode(callExpr, pos);
|
||||
if (questionDotToken) {
|
||||
typeArguments = tryParse(parseTypeArgumentsInExpression);
|
||||
if (isTemplateStartOfTaggedTemplate()) {
|
||||
expression = parseTaggedTemplateRest(pos, expression, questionDotToken, typeArguments);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (token() === SyntaxKind.OpenParenToken) {
|
||||
if (typeArguments || token() === SyntaxKind.OpenParenToken) {
|
||||
// Absorb type arguments into CallExpression when preceding expression is ExpressionWithTypeArguments
|
||||
if (!questionDotToken && expression.kind === SyntaxKind.ExpressionWithTypeArguments) {
|
||||
typeArguments = (expression as ExpressionWithTypeArguments).typeArguments;
|
||||
expression = (expression as ExpressionWithTypeArguments).expression;
|
||||
}
|
||||
const argumentList = parseArgumentList();
|
||||
const callExpr = questionDotToken || tryReparseOptionalChain(expression) ?
|
||||
factory.createCallChain(expression, questionDotToken, /*typeArguments*/ undefined, argumentList) :
|
||||
factory.createCallExpression(expression, /*typeArguments*/ undefined, argumentList);
|
||||
factory.createCallChain(expression, questionDotToken, typeArguments, argumentList) :
|
||||
factory.createCallExpression(expression, typeArguments, argumentList);
|
||||
expression = finishNode(callExpr, pos);
|
||||
continue;
|
||||
}
|
||||
if (questionDotToken) {
|
||||
// We failed to parse anything, so report a missing identifier here.
|
||||
// We parsed `?.` but then failed to parse anything, so report a missing identifier here.
|
||||
const name = createMissingNode<Identifier>(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ false, Diagnostics.Identifier_expected);
|
||||
expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos);
|
||||
}
|
||||
@@ -5536,22 +5540,26 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// If we have a '<', then only parse this as a argument list if the type arguments
|
||||
// are complete and we have an open paren. if we don't, rewind and return nothing.
|
||||
return typeArguments && canFollowTypeArgumentsInExpression()
|
||||
? typeArguments
|
||||
: undefined;
|
||||
// We successfully parsed a type argument list. The next token determines whether we want to
|
||||
// treat it as such. If the type argument list is followed by `(` or a template literal, as in
|
||||
// `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
|
||||
// it as a relational expression.
|
||||
return typeArguments && canFollowTypeArgumentsInExpression() ? typeArguments : undefined;
|
||||
}
|
||||
|
||||
function canFollowTypeArgumentsInExpression(): boolean {
|
||||
switch (token()) {
|
||||
// These tokens can follow a type argument list in a call expression.
|
||||
case SyntaxKind.OpenParenToken: // foo<x>(
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral: // foo<T> `...`
|
||||
case SyntaxKind.TemplateHead: // foo<T> `...${100}...`
|
||||
// these are the only tokens can legally follow a type argument
|
||||
// list. So we definitely want to treat them as type arg lists.
|
||||
// These tokens can't follow in a call expression, nor can they start an
|
||||
// expression. So, consider the type argument list part of an instantiation
|
||||
// expression.
|
||||
// falls through
|
||||
case SyntaxKind.CommaToken: // foo<x>,
|
||||
case SyntaxKind.DotToken: // foo<x>.
|
||||
case SyntaxKind.QuestionDotToken: // foo<x>?.
|
||||
case SyntaxKind.CloseParenToken: // foo<x>)
|
||||
case SyntaxKind.CloseBracketToken: // foo<x>]
|
||||
case SyntaxKind.ColonToken: // foo<x>:
|
||||
@@ -5569,21 +5577,10 @@ namespace ts {
|
||||
case SyntaxKind.BarToken: // foo<x> |
|
||||
case SyntaxKind.CloseBraceToken: // foo<x> }
|
||||
case SyntaxKind.EndOfFileToken: // foo<x>
|
||||
// these cases can't legally follow a type arg list. However, they're not legal
|
||||
// expressions either. The user is probably in the middle of a generic type. So
|
||||
// treat it as such.
|
||||
return true;
|
||||
|
||||
case SyntaxKind.CommaToken: // foo<x>,
|
||||
case SyntaxKind.OpenBraceToken: // foo<x> {
|
||||
// We don't want to treat these as type arguments. Otherwise we'll parse this
|
||||
// as an invocation expression. Instead, we want to parse out the expression
|
||||
// in isolation from the type arguments.
|
||||
// falls through
|
||||
default:
|
||||
// Anything else treat as an expression.
|
||||
return false;
|
||||
}
|
||||
// Treat anything else as an expression.
|
||||
return false;
|
||||
}
|
||||
|
||||
function parsePrimaryExpression(): PrimaryExpression {
|
||||
@@ -5790,30 +5787,16 @@ namespace ts {
|
||||
const name = parseIdentifierName();
|
||||
return finishNode(factory.createMetaProperty(SyntaxKind.NewKeyword, name), pos);
|
||||
}
|
||||
|
||||
const expressionPos = getNodePos();
|
||||
let expression: MemberExpression = parsePrimaryExpression();
|
||||
let typeArguments;
|
||||
while (true) {
|
||||
expression = parseMemberExpressionRest(expressionPos, expression, /*allowOptionalChain*/ false);
|
||||
typeArguments = tryParse(parseTypeArgumentsInExpression);
|
||||
if (isTemplateStartOfTaggedTemplate()) {
|
||||
Debug.assert(!!typeArguments,
|
||||
"Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'");
|
||||
expression = parseTaggedTemplateRest(expressionPos, expression, /*optionalChain*/ undefined, typeArguments);
|
||||
typeArguments = undefined;
|
||||
}
|
||||
break;
|
||||
let expression: LeftHandSideExpression = parseMemberExpressionRest(expressionPos, parsePrimaryExpression(), /*allowOptionalChain*/ false);
|
||||
let typeArguments: NodeArray<TypeNode> | undefined;
|
||||
// Absorb type arguments into NewExpression when preceding expression is ExpressionWithTypeArguments
|
||||
if (expression.kind === SyntaxKind.ExpressionWithTypeArguments) {
|
||||
typeArguments = (expression as ExpressionWithTypeArguments).typeArguments;
|
||||
expression = (expression as ExpressionWithTypeArguments).expression;
|
||||
}
|
||||
|
||||
let argumentsArray: NodeArray<Expression> | undefined;
|
||||
if (token() === SyntaxKind.OpenParenToken) {
|
||||
argumentsArray = parseArgumentList();
|
||||
}
|
||||
else if (typeArguments) {
|
||||
parseErrorAt(pos, scanner.getStartPos(), Diagnostics.A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list);
|
||||
}
|
||||
return finishNode(factory.createNewExpression(expression, typeArguments, argumentsArray), pos);
|
||||
const argumentList = token() === SyntaxKind.OpenParenToken ? parseArgumentList() : undefined;
|
||||
return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos);
|
||||
}
|
||||
|
||||
// STATEMENTS
|
||||
@@ -7071,6 +7054,9 @@ namespace ts {
|
||||
function parseExpressionWithTypeArguments(): ExpressionWithTypeArguments {
|
||||
const pos = getNodePos();
|
||||
const expression = parseLeftHandSideExpressionOrHigher();
|
||||
if (expression.kind === SyntaxKind.ExpressionWithTypeArguments) {
|
||||
return expression as ExpressionWithTypeArguments;
|
||||
}
|
||||
const typeArguments = tryParseTypeArguments();
|
||||
return finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos);
|
||||
}
|
||||
|
||||
+13
-8
@@ -1616,7 +1616,7 @@ namespace ts {
|
||||
readonly type?: TypeNode;
|
||||
}
|
||||
|
||||
export interface TypeQueryNode extends TypeNode {
|
||||
export interface TypeQueryNode extends NodeWithTypeArguments {
|
||||
readonly kind: SyntaxKind.TypeQuery;
|
||||
readonly exprName: EntityName;
|
||||
}
|
||||
@@ -2446,9 +2446,8 @@ namespace ts {
|
||||
readonly expression: ImportExpression;
|
||||
}
|
||||
|
||||
export interface ExpressionWithTypeArguments extends NodeWithTypeArguments {
|
||||
export interface ExpressionWithTypeArguments extends MemberExpression, NodeWithTypeArguments {
|
||||
readonly kind: SyntaxKind.ExpressionWithTypeArguments;
|
||||
readonly parent: HeritageClause | JSDocAugmentsTag | JSDocImplementsTag;
|
||||
readonly expression: LeftHandSideExpression;
|
||||
}
|
||||
|
||||
@@ -5336,13 +5335,14 @@ namespace ts {
|
||||
// Flags that require TypeFlags.Object
|
||||
ContainsSpread = 1 << 22, // Object literal contains spread operation
|
||||
ObjectRestType = 1 << 23, // Originates in object rest declaration
|
||||
InstantiationExpressionType = 1 << 24, // Originates in instantiation expression
|
||||
/* @internal */
|
||||
IsClassInstanceClone = 1 << 24, // Type is a clone of a class instance type
|
||||
IsClassInstanceClone = 1 << 25, // Type is a clone of a class instance type
|
||||
// Flags that require TypeFlags.Object and ObjectFlags.Reference
|
||||
/* @internal */
|
||||
IdenticalBaseTypeCalculated = 1 << 25, // has had `getSingleBaseForNonAugmentingSubtype` invoked on it already
|
||||
IdenticalBaseTypeCalculated = 1 << 26, // has had `getSingleBaseForNonAugmentingSubtype` invoked on it already
|
||||
/* @internal */
|
||||
IdenticalBaseTypeExists = 1 << 26, // has a defined cachedEquivalentBaseType member
|
||||
IdenticalBaseTypeExists = 1 << 27, // has a defined cachedEquivalentBaseType member
|
||||
|
||||
// Flags that require TypeFlags.UnionOrIntersection or TypeFlags.Substitution
|
||||
/* @internal */
|
||||
@@ -5527,6 +5527,11 @@ namespace ts {
|
||||
instantiations?: ESMap<string, Type>; // Instantiations of generic type alias (undefined if non-generic)
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export interface InstantiationExpressionType extends AnonymousType {
|
||||
node: ExpressionWithTypeArguments | TypeQueryNode;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export interface MappedType extends AnonymousType {
|
||||
declaration: MappedTypeNode;
|
||||
@@ -7245,8 +7250,8 @@ namespace ts {
|
||||
updateConstructorTypeNode(node: ConstructorTypeNode, modifiers: readonly Modifier[] | undefined, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode): ConstructorTypeNode;
|
||||
/** @deprecated */
|
||||
updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode): ConstructorTypeNode;
|
||||
createTypeQueryNode(exprName: EntityName): TypeQueryNode;
|
||||
updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode;
|
||||
createTypeQueryNode(exprName: EntityName, typeArguments?: readonly TypeNode[]): TypeQueryNode;
|
||||
updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName, typeArguments?: readonly TypeNode[]): TypeQueryNode;
|
||||
createTypeLiteralNode(members: readonly TypeElement[] | undefined): TypeLiteralNode;
|
||||
updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray<TypeElement>): TypeLiteralNode;
|
||||
createArrayTypeNode(elementType: TypeNode): ArrayTypeNode;
|
||||
|
||||
@@ -1304,7 +1304,7 @@ namespace ts {
|
||||
case SyntaxKind.VoidKeyword:
|
||||
return node.parent.kind !== SyntaxKind.VoidExpression;
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return !isExpressionWithTypeArgumentsInClassExtendsClause(node);
|
||||
return isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node);
|
||||
case SyntaxKind.TypeParameter:
|
||||
return node.parent.kind === SyntaxKind.MappedType || node.parent.kind === SyntaxKind.InferType;
|
||||
|
||||
@@ -1344,7 +1344,7 @@ namespace ts {
|
||||
}
|
||||
switch (parent.kind) {
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return !isExpressionWithTypeArgumentsInClassExtendsClause(parent);
|
||||
return isHeritageClause(parent.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(parent);
|
||||
case SyntaxKind.TypeParameter:
|
||||
return node === (parent as TypeParameterDeclaration).constraint;
|
||||
case SyntaxKind.JSDocTemplateTag:
|
||||
@@ -2070,7 +2070,7 @@ namespace ts {
|
||||
case SyntaxKind.SpreadAssignment:
|
||||
return true;
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return (parent as ExpressionWithTypeArguments).expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent);
|
||||
return (parent as ExpressionWithTypeArguments).expression === node && !isPartOfTypeNode(parent);
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
return (parent as ShorthandPropertyAssignment).objectAssignmentInitializer === node;
|
||||
default:
|
||||
|
||||
@@ -1538,6 +1538,7 @@ namespace ts {
|
||||
case SyntaxKind.TrueKeyword:
|
||||
case SyntaxKind.SuperKeyword:
|
||||
case SyntaxKind.NonNullExpression:
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
case SyntaxKind.MetaProperty:
|
||||
case SyntaxKind.ImportKeyword: // technically this is only an Expression if it's in a CallExpression
|
||||
return true;
|
||||
|
||||
@@ -538,7 +538,8 @@ namespace ts {
|
||||
case SyntaxKind.TypeQuery:
|
||||
Debug.type<TypeQueryNode>(node);
|
||||
return factory.updateTypeQueryNode(node,
|
||||
nodeVisitor(node.exprName, visitor, isEntityName));
|
||||
nodeVisitor(node.exprName, visitor, isEntityName),
|
||||
nodesVisitor(node.typeArguments, visitor, isTypeNode));
|
||||
|
||||
case SyntaxKind.TypeLiteral:
|
||||
Debug.type<TypeLiteralNode>(node);
|
||||
|
||||
@@ -200,7 +200,7 @@ namespace ts {
|
||||
case SyntaxKind.ImportType:
|
||||
return !(node.parent as ImportTypeNode).isTypeOf;
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return !isExpressionWithTypeArgumentsInClassExtendsClause(node.parent as ExpressionWithTypeArguments);
|
||||
return isPartOfTypeNode(node.parent);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
+7
-7
@@ -901,7 +901,7 @@ declare namespace ts {
|
||||
readonly parameterName: Identifier | ThisTypeNode;
|
||||
readonly type?: TypeNode;
|
||||
}
|
||||
export interface TypeQueryNode extends TypeNode {
|
||||
export interface TypeQueryNode extends NodeWithTypeArguments {
|
||||
readonly kind: SyntaxKind.TypeQuery;
|
||||
readonly exprName: EntityName;
|
||||
}
|
||||
@@ -1285,9 +1285,8 @@ declare namespace ts {
|
||||
export interface ImportCall extends CallExpression {
|
||||
readonly expression: ImportExpression;
|
||||
}
|
||||
export interface ExpressionWithTypeArguments extends NodeWithTypeArguments {
|
||||
export interface ExpressionWithTypeArguments extends MemberExpression, NodeWithTypeArguments {
|
||||
readonly kind: SyntaxKind.ExpressionWithTypeArguments;
|
||||
readonly parent: HeritageClause | JSDocAugmentsTag | JSDocImplementsTag;
|
||||
readonly expression: LeftHandSideExpression;
|
||||
}
|
||||
export interface NewExpression extends PrimaryExpression, Declaration {
|
||||
@@ -2662,6 +2661,7 @@ declare namespace ts {
|
||||
ClassOrInterface = 3,
|
||||
ContainsSpread = 4194304,
|
||||
ObjectRestType = 8388608,
|
||||
InstantiationExpressionType = 16777216,
|
||||
}
|
||||
export interface ObjectType extends Type {
|
||||
objectFlags: ObjectFlags;
|
||||
@@ -3397,8 +3397,8 @@ declare namespace ts {
|
||||
updateConstructorTypeNode(node: ConstructorTypeNode, modifiers: readonly Modifier[] | undefined, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode): ConstructorTypeNode;
|
||||
/** @deprecated */
|
||||
updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode): ConstructorTypeNode;
|
||||
createTypeQueryNode(exprName: EntityName): TypeQueryNode;
|
||||
updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode;
|
||||
createTypeQueryNode(exprName: EntityName, typeArguments?: readonly TypeNode[]): TypeQueryNode;
|
||||
updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName, typeArguments?: readonly TypeNode[]): TypeQueryNode;
|
||||
createTypeLiteralNode(members: readonly TypeElement[] | undefined): TypeLiteralNode;
|
||||
updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray<TypeElement>): TypeLiteralNode;
|
||||
createArrayTypeNode(elementType: TypeNode): ArrayTypeNode;
|
||||
@@ -10755,9 +10755,9 @@ declare namespace ts {
|
||||
/** @deprecated Use `factory.updateConstructorTypeNode` or the factory supplied by your transformation context instead. */
|
||||
const updateConstructorTypeNode: (node: ConstructorTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode) => ConstructorTypeNode;
|
||||
/** @deprecated Use `factory.createTypeQueryNode` or the factory supplied by your transformation context instead. */
|
||||
const createTypeQueryNode: (exprName: EntityName) => TypeQueryNode;
|
||||
const createTypeQueryNode: (exprName: EntityName, typeArguments?: readonly TypeNode[] | undefined) => TypeQueryNode;
|
||||
/** @deprecated Use `factory.updateTypeQueryNode` or the factory supplied by your transformation context instead. */
|
||||
const updateTypeQueryNode: (node: TypeQueryNode, exprName: EntityName) => TypeQueryNode;
|
||||
const updateTypeQueryNode: (node: TypeQueryNode, exprName: EntityName, typeArguments?: readonly TypeNode[] | undefined) => TypeQueryNode;
|
||||
/** @deprecated Use `factory.createTypeLiteralNode` or the factory supplied by your transformation context instead. */
|
||||
const createTypeLiteralNode: (members: readonly TypeElement[] | undefined) => TypeLiteralNode;
|
||||
/** @deprecated Use `factory.updateTypeLiteralNode` or the factory supplied by your transformation context instead. */
|
||||
|
||||
+7
-7
@@ -901,7 +901,7 @@ declare namespace ts {
|
||||
readonly parameterName: Identifier | ThisTypeNode;
|
||||
readonly type?: TypeNode;
|
||||
}
|
||||
export interface TypeQueryNode extends TypeNode {
|
||||
export interface TypeQueryNode extends NodeWithTypeArguments {
|
||||
readonly kind: SyntaxKind.TypeQuery;
|
||||
readonly exprName: EntityName;
|
||||
}
|
||||
@@ -1285,9 +1285,8 @@ declare namespace ts {
|
||||
export interface ImportCall extends CallExpression {
|
||||
readonly expression: ImportExpression;
|
||||
}
|
||||
export interface ExpressionWithTypeArguments extends NodeWithTypeArguments {
|
||||
export interface ExpressionWithTypeArguments extends MemberExpression, NodeWithTypeArguments {
|
||||
readonly kind: SyntaxKind.ExpressionWithTypeArguments;
|
||||
readonly parent: HeritageClause | JSDocAugmentsTag | JSDocImplementsTag;
|
||||
readonly expression: LeftHandSideExpression;
|
||||
}
|
||||
export interface NewExpression extends PrimaryExpression, Declaration {
|
||||
@@ -2662,6 +2661,7 @@ declare namespace ts {
|
||||
ClassOrInterface = 3,
|
||||
ContainsSpread = 4194304,
|
||||
ObjectRestType = 8388608,
|
||||
InstantiationExpressionType = 16777216,
|
||||
}
|
||||
export interface ObjectType extends Type {
|
||||
objectFlags: ObjectFlags;
|
||||
@@ -3397,8 +3397,8 @@ declare namespace ts {
|
||||
updateConstructorTypeNode(node: ConstructorTypeNode, modifiers: readonly Modifier[] | undefined, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode): ConstructorTypeNode;
|
||||
/** @deprecated */
|
||||
updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode): ConstructorTypeNode;
|
||||
createTypeQueryNode(exprName: EntityName): TypeQueryNode;
|
||||
updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode;
|
||||
createTypeQueryNode(exprName: EntityName, typeArguments?: readonly TypeNode[]): TypeQueryNode;
|
||||
updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName, typeArguments?: readonly TypeNode[]): TypeQueryNode;
|
||||
createTypeLiteralNode(members: readonly TypeElement[] | undefined): TypeLiteralNode;
|
||||
updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray<TypeElement>): TypeLiteralNode;
|
||||
createArrayTypeNode(elementType: TypeNode): ArrayTypeNode;
|
||||
@@ -6937,9 +6937,9 @@ declare namespace ts {
|
||||
/** @deprecated Use `factory.updateConstructorTypeNode` or the factory supplied by your transformation context instead. */
|
||||
const updateConstructorTypeNode: (node: ConstructorTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode) => ConstructorTypeNode;
|
||||
/** @deprecated Use `factory.createTypeQueryNode` or the factory supplied by your transformation context instead. */
|
||||
const createTypeQueryNode: (exprName: EntityName) => TypeQueryNode;
|
||||
const createTypeQueryNode: (exprName: EntityName, typeArguments?: readonly TypeNode[] | undefined) => TypeQueryNode;
|
||||
/** @deprecated Use `factory.updateTypeQueryNode` or the factory supplied by your transformation context instead. */
|
||||
const updateTypeQueryNode: (node: TypeQueryNode, exprName: EntityName) => TypeQueryNode;
|
||||
const updateTypeQueryNode: (node: TypeQueryNode, exprName: EntityName, typeArguments?: readonly TypeNode[] | undefined) => TypeQueryNode;
|
||||
/** @deprecated Use `factory.createTypeLiteralNode` or the factory supplied by your transformation context instead. */
|
||||
const createTypeLiteralNode: (members: readonly TypeElement[] | undefined) => TypeLiteralNode;
|
||||
/** @deprecated Use `factory.updateTypeLiteralNode` or the factory supplied by your transformation context instead. */
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(6,22): error TS1005: ',' expected.
|
||||
tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(6,30): error TS1109: Expression expected.
|
||||
tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(7,22): error TS1005: ',' expected.
|
||||
tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(7,32): error TS1109: Expression expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts (4 errors) ====
|
||||
// array type cannot use typeof.
|
||||
|
||||
var x = 1;
|
||||
var xs: typeof x[]; // Not an error. This is equivalent to Array<typeof x>
|
||||
var xs2: typeof Array;
|
||||
var xs3: typeof Array<number>;
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
var xs4: typeof Array<typeof x>;
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
@@ -13,6 +13,4 @@ var x = 1;
|
||||
var xs; // Not an error. This is equivalent to Array<typeof x>
|
||||
var xs2;
|
||||
var xs3;
|
||||
;
|
||||
var xs4;
|
||||
;
|
||||
|
||||
@@ -14,15 +14,11 @@ var xs2: typeof Array;
|
||||
>Array : ArrayConstructor
|
||||
|
||||
var xs3: typeof Array<number>;
|
||||
>xs3 : ArrayConstructor
|
||||
>xs3 : { (arrayLength: number): number[]; (...items: number[]): number[]; new (arrayLength: number): number[]; new (...items: number[]): number[]; isArray(arg: any): arg is any[]; readonly prototype: any[]; }
|
||||
>Array : ArrayConstructor
|
||||
><number> : number
|
||||
> : any
|
||||
|
||||
var xs4: typeof Array<typeof x>;
|
||||
>xs4 : ArrayConstructor
|
||||
>xs4 : { (arrayLength: number): number[]; (...items: number[]): number[]; new (arrayLength: number): number[]; new (...items: number[]): number[]; isArray(arg: any): arg is any[]; readonly prototype: any[]; }
|
||||
>Array : ArrayConstructor
|
||||
><typeof x> : number
|
||||
>x : number
|
||||
> : any
|
||||
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
tests/cases/compiler/genericCallWithoutArgs.ts(4,17): error TS1005: '(' expected.
|
||||
tests/cases/compiler/genericCallWithoutArgs.ts(4,18): error TS1005: ')' expected.
|
||||
tests/cases/compiler/genericCallWithoutArgs.ts(4,18): error TS1003: Identifier expected.
|
||||
|
||||
|
||||
==== tests/cases/compiler/genericCallWithoutArgs.ts (2 errors) ====
|
||||
==== tests/cases/compiler/genericCallWithoutArgs.ts (1 errors) ====
|
||||
function f<X, Y>(x: X, y: Y) {
|
||||
}
|
||||
|
||||
f<number,string>.
|
||||
~
|
||||
!!! error TS1005: '(' expected.
|
||||
|
||||
!!! error TS1005: ')' expected.
|
||||
!!! error TS1003: Identifier expected.
|
||||
@@ -7,4 +7,4 @@ f<number,string>.
|
||||
//// [genericCallWithoutArgs.js]
|
||||
function f(x, y) {
|
||||
}
|
||||
f();
|
||||
f.;
|
||||
|
||||
@@ -6,6 +6,7 @@ function f<X, Y>(x: X, y: Y) {
|
||||
}
|
||||
|
||||
f<number,string>.
|
||||
>f<number,string>. : void
|
||||
>f<number,string>. : any
|
||||
>f : <X, Y>(x: X, y: Y) => void
|
||||
> : any
|
||||
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
tests/cases/compiler/genericCallsWithoutParens.ts(2,18): error TS1005: '(' expected.
|
||||
tests/cases/compiler/genericCallsWithoutParens.ts(7,8): error TS1384: A 'new' expression with type arguments must always be followed by a parenthesized argument list.
|
||||
|
||||
|
||||
==== tests/cases/compiler/genericCallsWithoutParens.ts (2 errors) ====
|
||||
==== tests/cases/compiler/genericCallsWithoutParens.ts (1 errors) ====
|
||||
function f<T>() { }
|
||||
var r = f<number>; // parse error
|
||||
~
|
||||
!!! error TS1005: '(' expected.
|
||||
|
||||
class C<T> {
|
||||
foo: T;
|
||||
|
||||
@@ -11,7 +11,7 @@ var c = new C<number>; // parse error
|
||||
|
||||
//// [genericCallsWithoutParens.js]
|
||||
function f() { }
|
||||
var r = f(); // parse error
|
||||
var r = (f); // parse error
|
||||
var C = /** @class */ (function () {
|
||||
function C() {
|
||||
}
|
||||
|
||||
@@ -3,8 +3,7 @@ function f<T>() { }
|
||||
>f : <T>() => void
|
||||
|
||||
var r = f<number>; // parse error
|
||||
>r : void
|
||||
>f<number> : void
|
||||
>r : () => void
|
||||
>f : <T>() => void
|
||||
|
||||
class C<T> {
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
tests/cases/compiler/genericObjectCreationWithoutTypeArgs.ts(6,9): error TS1384: A 'new' expression with type arguments must always be followed by a parenthesized argument list.
|
||||
|
||||
|
||||
==== tests/cases/compiler/genericObjectCreationWithoutTypeArgs.ts (1 errors) ====
|
||||
class SS<T>{
|
||||
|
||||
}
|
||||
|
||||
var x1 = new SS<number>(); // OK
|
||||
var x2 = new SS < number>; // Correctly give error
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1384: A 'new' expression with type arguments must always be followed by a parenthesized argument list.
|
||||
var x3 = new SS(); // OK
|
||||
var x4 = new SS; // Should be allowed, but currently give error ('supplied parameters do not match any signature of the call target')
|
||||
|
||||
@@ -4,9 +4,9 @@ class SS<T>{
|
||||
}
|
||||
|
||||
var x1 = new SS<number>(); // OK
|
||||
var x2 = new SS < number>; // Correctly give error
|
||||
var x2 = new SS<number>; // OK
|
||||
var x3 = new SS(); // OK
|
||||
var x4 = new SS; // Should be allowed, but currently give error ('supplied parameters do not match any signature of the call target')
|
||||
var x4 = new SS; // OK
|
||||
|
||||
|
||||
//// [genericObjectCreationWithoutTypeArgs.js]
|
||||
@@ -16,6 +16,6 @@ var SS = /** @class */ (function () {
|
||||
return SS;
|
||||
}());
|
||||
var x1 = new SS(); // OK
|
||||
var x2 = new SS; // Correctly give error
|
||||
var x2 = new SS; // OK
|
||||
var x3 = new SS(); // OK
|
||||
var x4 = new SS; // Should be allowed, but currently give error ('supplied parameters do not match any signature of the call target')
|
||||
var x4 = new SS; // OK
|
||||
|
||||
@@ -9,7 +9,7 @@ var x1 = new SS<number>(); // OK
|
||||
>x1 : Symbol(x1, Decl(genericObjectCreationWithoutTypeArgs.ts, 4, 3))
|
||||
>SS : Symbol(SS, Decl(genericObjectCreationWithoutTypeArgs.ts, 0, 0))
|
||||
|
||||
var x2 = new SS < number>; // Correctly give error
|
||||
var x2 = new SS<number>; // OK
|
||||
>x2 : Symbol(x2, Decl(genericObjectCreationWithoutTypeArgs.ts, 5, 3))
|
||||
>SS : Symbol(SS, Decl(genericObjectCreationWithoutTypeArgs.ts, 0, 0))
|
||||
|
||||
@@ -17,7 +17,7 @@ var x3 = new SS(); // OK
|
||||
>x3 : Symbol(x3, Decl(genericObjectCreationWithoutTypeArgs.ts, 6, 3))
|
||||
>SS : Symbol(SS, Decl(genericObjectCreationWithoutTypeArgs.ts, 0, 0))
|
||||
|
||||
var x4 = new SS; // Should be allowed, but currently give error ('supplied parameters do not match any signature of the call target')
|
||||
var x4 = new SS; // OK
|
||||
>x4 : Symbol(x4, Decl(genericObjectCreationWithoutTypeArgs.ts, 7, 3))
|
||||
>SS : Symbol(SS, Decl(genericObjectCreationWithoutTypeArgs.ts, 0, 0))
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ var x1 = new SS<number>(); // OK
|
||||
>new SS<number>() : SS<number>
|
||||
>SS : typeof SS
|
||||
|
||||
var x2 = new SS < number>; // Correctly give error
|
||||
var x2 = new SS<number>; // OK
|
||||
>x2 : SS<number>
|
||||
>new SS < number> : SS<number>
|
||||
>new SS<number> : SS<number>
|
||||
>SS : typeof SS
|
||||
|
||||
var x3 = new SS(); // OK
|
||||
@@ -19,7 +19,7 @@ var x3 = new SS(); // OK
|
||||
>new SS() : SS<unknown>
|
||||
>SS : typeof SS
|
||||
|
||||
var x4 = new SS; // Should be allowed, but currently give error ('supplied parameters do not match any signature of the call target')
|
||||
var x4 = new SS; // OK
|
||||
>x4 : SS<unknown>
|
||||
>new SS : SS<unknown>
|
||||
>SS : typeof SS
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(13,12): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'string[]'.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(13,14): error TS2693: 'number' only refers to a type, but is being used as a value here.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(18,12): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(18,14): error TS2693: 'number' only refers to a type, but is being used as a value here.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(18,29): error TS1109: Expression expected.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(19,24): error TS2635: Type '{ (): number; g<U>(): U; }' has no signatures for which the type argument list is applicable.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(23,23): error TS1005: '(' expected.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(26,24): error TS2558: Expected 0 type arguments, but got 1.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(31,2): error TS2554: Expected 0 arguments, but got 1.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts(35,12): error TS2365: Operator '<' cannot be applied to types '{ <T>(): T; g<U>(): U; }' and 'boolean'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts (10 errors) ====
|
||||
declare let f: { <T>(): T, g<U>(): U };
|
||||
|
||||
// Type arguments in member expressions
|
||||
|
||||
const a1 = f<number>; // { (): number; g<U>(): U; }
|
||||
const a2 = f.g<number>; // () => number
|
||||
const a3 = f<number>.g; // <U>() => U
|
||||
const a4 = f<number>.g<number>; // () => number
|
||||
const a5 = f['g']<number>; // () => number
|
||||
|
||||
// `[` is an expression starter and cannot immediately follow a type argument list
|
||||
|
||||
const a6 = f<number>['g']; // Error
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and 'string[]'.
|
||||
~~~~~~
|
||||
!!! error TS2693: 'number' only refers to a type, but is being used as a value here.
|
||||
const a7 = (f<number>)['g'];
|
||||
|
||||
// An `<` cannot immediately follow a type argument list
|
||||
|
||||
const a8 = f<number><number>; // Relational operator error
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'.
|
||||
~~~~~~
|
||||
!!! error TS2693: 'number' only refers to a type, but is being used as a value here.
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
const a9 = (f<number>)<number>; // Error, no applicable signatures
|
||||
~~~~~~
|
||||
!!! error TS2635: Type '{ (): number; g<U>(): U; }' has no signatures for which the type argument list is applicable.
|
||||
|
||||
// Type arguments with `?.` token
|
||||
|
||||
const b1 = f?.<number>; // Error, `(` expected
|
||||
~
|
||||
!!! error TS1005: '(' expected.
|
||||
const b2 = f?.<number>();
|
||||
const b3 = f<number>?.();
|
||||
const b4 = f<number>?.<number>(); // Error, expected no type arguments
|
||||
~~~~~~
|
||||
!!! error TS2558: Expected 0 type arguments, but got 1.
|
||||
|
||||
// Parsed as function call, even though this differs from JavaScript
|
||||
|
||||
const x1 = f<true>
|
||||
(true);
|
||||
~~~~
|
||||
!!! error TS2554: Expected 0 arguments, but got 1.
|
||||
|
||||
// Parsed as relational expression
|
||||
|
||||
const x2 = f<true>
|
||||
~~~~~~
|
||||
!!! error TS2365: Operator '<' cannot be applied to types '{ <T>(): T; g<U>(): U; }' and 'boolean'.
|
||||
true;
|
||||
|
||||
// Parsed as instantiation expression
|
||||
|
||||
const x3 = f<true>;
|
||||
true;
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
//// [instantiationExpressionErrors.ts]
|
||||
declare let f: { <T>(): T, g<U>(): U };
|
||||
|
||||
// Type arguments in member expressions
|
||||
|
||||
const a1 = f<number>; // { (): number; g<U>(): U; }
|
||||
const a2 = f.g<number>; // () => number
|
||||
const a3 = f<number>.g; // <U>() => U
|
||||
const a4 = f<number>.g<number>; // () => number
|
||||
const a5 = f['g']<number>; // () => number
|
||||
|
||||
// `[` is an expression starter and cannot immediately follow a type argument list
|
||||
|
||||
const a6 = f<number>['g']; // Error
|
||||
const a7 = (f<number>)['g'];
|
||||
|
||||
// An `<` cannot immediately follow a type argument list
|
||||
|
||||
const a8 = f<number><number>; // Relational operator error
|
||||
const a9 = (f<number>)<number>; // Error, no applicable signatures
|
||||
|
||||
// Type arguments with `?.` token
|
||||
|
||||
const b1 = f?.<number>; // Error, `(` expected
|
||||
const b2 = f?.<number>();
|
||||
const b3 = f<number>?.();
|
||||
const b4 = f<number>?.<number>(); // Error, expected no type arguments
|
||||
|
||||
// Parsed as function call, even though this differs from JavaScript
|
||||
|
||||
const x1 = f<true>
|
||||
(true);
|
||||
|
||||
// Parsed as relational expression
|
||||
|
||||
const x2 = f<true>
|
||||
true;
|
||||
|
||||
// Parsed as instantiation expression
|
||||
|
||||
const x3 = f<true>;
|
||||
true;
|
||||
|
||||
|
||||
//// [instantiationExpressionErrors.js]
|
||||
"use strict";
|
||||
var _a, _b;
|
||||
// Type arguments in member expressions
|
||||
var a1 = (f); // { (): number; g<U>(): U; }
|
||||
var a2 = (f.g); // () => number
|
||||
var a3 = f.g; // <U>() => U
|
||||
var a4 = (f.g); // () => number
|
||||
var a5 = (f['g']); // () => number
|
||||
// `[` is an expression starter and cannot immediately follow a type argument list
|
||||
var a6 = f < number > ['g']; // Error
|
||||
var a7 = (f)['g'];
|
||||
// An `<` cannot immediately follow a type argument list
|
||||
var a8 = f < number > ; // Relational operator error
|
||||
var a9 = ((f)); // Error, no applicable signatures
|
||||
// Type arguments with `?.` token
|
||||
var b1 = f === null || f === void 0 ? void 0 : f(); // Error, `(` expected
|
||||
var b2 = f === null || f === void 0 ? void 0 : f();
|
||||
var b3 = (_a = (f)) === null || _a === void 0 ? void 0 : _a();
|
||||
var b4 = (_b = (f)) === null || _b === void 0 ? void 0 : _b(); // Error, expected no type arguments
|
||||
// Parsed as function call, even though this differs from JavaScript
|
||||
var x1 = f(true);
|
||||
// Parsed as relational expression
|
||||
var x2 = f < true >
|
||||
true;
|
||||
// Parsed as instantiation expression
|
||||
var x3 = (f);
|
||||
true;
|
||||
|
||||
|
||||
//// [instantiationExpressionErrors.d.ts]
|
||||
declare let f: {
|
||||
<T>(): T;
|
||||
g<U>(): U;
|
||||
};
|
||||
declare const a1: {
|
||||
(): number;
|
||||
g<U>(): U;
|
||||
};
|
||||
declare const a2: () => number;
|
||||
declare const a3: <U>() => U;
|
||||
declare const a4: () => number;
|
||||
declare const a5: () => number;
|
||||
declare const a6: boolean;
|
||||
declare const a7: <U>() => U;
|
||||
declare const a8: boolean;
|
||||
declare const a9: {
|
||||
g<U>(): U;
|
||||
};
|
||||
declare const b1: number;
|
||||
declare const b2: number;
|
||||
declare const b3: number;
|
||||
declare const b4: number;
|
||||
declare const x1: true;
|
||||
declare const x2: boolean;
|
||||
declare const x3: {
|
||||
(): true;
|
||||
g<U>(): U;
|
||||
};
|
||||
@@ -0,0 +1,101 @@
|
||||
=== tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts ===
|
||||
declare let f: { <T>(): T, g<U>(): U };
|
||||
>f : Symbol(f, Decl(instantiationExpressionErrors.ts, 0, 11))
|
||||
>T : Symbol(T, Decl(instantiationExpressionErrors.ts, 0, 18))
|
||||
>T : Symbol(T, Decl(instantiationExpressionErrors.ts, 0, 18))
|
||||
>g : Symbol(g, Decl(instantiationExpressionErrors.ts, 0, 26))
|
||||
>U : Symbol(U, Decl(instantiationExpressionErrors.ts, 0, 29))
|
||||
>U : Symbol(U, Decl(instantiationExpressionErrors.ts, 0, 29))
|
||||
|
||||
// Type arguments in member expressions
|
||||
|
||||
const a1 = f<number>; // { (): number; g<U>(): U; }
|
||||
>a1 : Symbol(a1, Decl(instantiationExpressionErrors.ts, 4, 5))
|
||||
>f : Symbol(f, Decl(instantiationExpressionErrors.ts, 0, 11))
|
||||
|
||||
const a2 = f.g<number>; // () => number
|
||||
>a2 : Symbol(a2, Decl(instantiationExpressionErrors.ts, 5, 5))
|
||||
>f.g : Symbol(g, Decl(instantiationExpressionErrors.ts, 0, 26))
|
||||
>f : Symbol(f, Decl(instantiationExpressionErrors.ts, 0, 11))
|
||||
>g : Symbol(g, Decl(instantiationExpressionErrors.ts, 0, 26))
|
||||
|
||||
const a3 = f<number>.g; // <U>() => U
|
||||
>a3 : Symbol(a3, Decl(instantiationExpressionErrors.ts, 6, 5))
|
||||
>f<number>.g : Symbol(g, Decl(instantiationExpressionErrors.ts, 0, 26))
|
||||
>f : Symbol(f, Decl(instantiationExpressionErrors.ts, 0, 11))
|
||||
>g : Symbol(g, Decl(instantiationExpressionErrors.ts, 0, 26))
|
||||
|
||||
const a4 = f<number>.g<number>; // () => number
|
||||
>a4 : Symbol(a4, Decl(instantiationExpressionErrors.ts, 7, 5))
|
||||
>f<number>.g : Symbol(g, Decl(instantiationExpressionErrors.ts, 0, 26))
|
||||
>f : Symbol(f, Decl(instantiationExpressionErrors.ts, 0, 11))
|
||||
>g : Symbol(g, Decl(instantiationExpressionErrors.ts, 0, 26))
|
||||
|
||||
const a5 = f['g']<number>; // () => number
|
||||
>a5 : Symbol(a5, Decl(instantiationExpressionErrors.ts, 8, 5))
|
||||
>f : Symbol(f, Decl(instantiationExpressionErrors.ts, 0, 11))
|
||||
>'g' : Symbol(g, Decl(instantiationExpressionErrors.ts, 0, 26))
|
||||
|
||||
// `[` is an expression starter and cannot immediately follow a type argument list
|
||||
|
||||
const a6 = f<number>['g']; // Error
|
||||
>a6 : Symbol(a6, Decl(instantiationExpressionErrors.ts, 12, 5))
|
||||
>f : Symbol(f, Decl(instantiationExpressionErrors.ts, 0, 11))
|
||||
|
||||
const a7 = (f<number>)['g'];
|
||||
>a7 : Symbol(a7, Decl(instantiationExpressionErrors.ts, 13, 5))
|
||||
>f : Symbol(f, Decl(instantiationExpressionErrors.ts, 0, 11))
|
||||
>'g' : Symbol(g, Decl(instantiationExpressionErrors.ts, 0, 26))
|
||||
|
||||
// An `<` cannot immediately follow a type argument list
|
||||
|
||||
const a8 = f<number><number>; // Relational operator error
|
||||
>a8 : Symbol(a8, Decl(instantiationExpressionErrors.ts, 17, 5))
|
||||
>f : Symbol(f, Decl(instantiationExpressionErrors.ts, 0, 11))
|
||||
|
||||
const a9 = (f<number>)<number>; // Error, no applicable signatures
|
||||
>a9 : Symbol(a9, Decl(instantiationExpressionErrors.ts, 18, 5))
|
||||
>f : Symbol(f, Decl(instantiationExpressionErrors.ts, 0, 11))
|
||||
|
||||
// Type arguments with `?.` token
|
||||
|
||||
const b1 = f?.<number>; // Error, `(` expected
|
||||
>b1 : Symbol(b1, Decl(instantiationExpressionErrors.ts, 22, 5))
|
||||
>f : Symbol(f, Decl(instantiationExpressionErrors.ts, 0, 11))
|
||||
|
||||
const b2 = f?.<number>();
|
||||
>b2 : Symbol(b2, Decl(instantiationExpressionErrors.ts, 23, 5))
|
||||
>f : Symbol(f, Decl(instantiationExpressionErrors.ts, 0, 11))
|
||||
|
||||
const b3 = f<number>?.();
|
||||
>b3 : Symbol(b3, Decl(instantiationExpressionErrors.ts, 24, 5))
|
||||
>f : Symbol(f, Decl(instantiationExpressionErrors.ts, 0, 11))
|
||||
|
||||
const b4 = f<number>?.<number>(); // Error, expected no type arguments
|
||||
>b4 : Symbol(b4, Decl(instantiationExpressionErrors.ts, 25, 5))
|
||||
>f : Symbol(f, Decl(instantiationExpressionErrors.ts, 0, 11))
|
||||
|
||||
// Parsed as function call, even though this differs from JavaScript
|
||||
|
||||
const x1 = f<true>
|
||||
>x1 : Symbol(x1, Decl(instantiationExpressionErrors.ts, 29, 5))
|
||||
>f : Symbol(f, Decl(instantiationExpressionErrors.ts, 0, 11))
|
||||
|
||||
(true);
|
||||
|
||||
// Parsed as relational expression
|
||||
|
||||
const x2 = f<true>
|
||||
>x2 : Symbol(x2, Decl(instantiationExpressionErrors.ts, 34, 5))
|
||||
>f : Symbol(f, Decl(instantiationExpressionErrors.ts, 0, 11))
|
||||
|
||||
true;
|
||||
|
||||
// Parsed as instantiation expression
|
||||
|
||||
const x3 = f<true>;
|
||||
>x3 : Symbol(x3, Decl(instantiationExpressionErrors.ts, 39, 5))
|
||||
>f : Symbol(f, Decl(instantiationExpressionErrors.ts, 0, 11))
|
||||
|
||||
true;
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
=== tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressionErrors.ts ===
|
||||
declare let f: { <T>(): T, g<U>(): U };
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
>g : <U>() => U
|
||||
|
||||
// Type arguments in member expressions
|
||||
|
||||
const a1 = f<number>; // { (): number; g<U>(): U; }
|
||||
>a1 : { (): number; g<U>(): U; }
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
|
||||
const a2 = f.g<number>; // () => number
|
||||
>a2 : () => number
|
||||
>f.g : <U>() => U
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
>g : <U>() => U
|
||||
|
||||
const a3 = f<number>.g; // <U>() => U
|
||||
>a3 : <U>() => U
|
||||
>f<number>.g : <U>() => U
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
>g : <U>() => U
|
||||
|
||||
const a4 = f<number>.g<number>; // () => number
|
||||
>a4 : () => number
|
||||
>f<number>.g : <U>() => U
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
>g : <U>() => U
|
||||
|
||||
const a5 = f['g']<number>; // () => number
|
||||
>a5 : () => number
|
||||
>f['g'] : <U>() => U
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
>'g' : "g"
|
||||
|
||||
// `[` is an expression starter and cannot immediately follow a type argument list
|
||||
|
||||
const a6 = f<number>['g']; // Error
|
||||
>a6 : boolean
|
||||
>f<number>['g'] : boolean
|
||||
>f<number : boolean
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
>number : any
|
||||
>['g'] : string[]
|
||||
>'g' : "g"
|
||||
|
||||
const a7 = (f<number>)['g'];
|
||||
>a7 : <U>() => U
|
||||
>(f<number>)['g'] : <U>() => U
|
||||
>(f<number>) : { (): number; g<U>(): U; }
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
>'g' : "g"
|
||||
|
||||
// An `<` cannot immediately follow a type argument list
|
||||
|
||||
const a8 = f<number><number>; // Relational operator error
|
||||
>a8 : boolean
|
||||
>f<number><number> : boolean
|
||||
>f<number : boolean
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
>number : any
|
||||
><number> : number
|
||||
> : any
|
||||
|
||||
const a9 = (f<number>)<number>; // Error, no applicable signatures
|
||||
>a9 : { g<U>(): U; }
|
||||
>(f<number>) : { (): number; g<U>(): U; }
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
|
||||
// Type arguments with `?.` token
|
||||
|
||||
const b1 = f?.<number>; // Error, `(` expected
|
||||
>b1 : number
|
||||
>f?.<number> : number
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
|
||||
const b2 = f?.<number>();
|
||||
>b2 : number
|
||||
>f?.<number>() : number
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
|
||||
const b3 = f<number>?.();
|
||||
>b3 : number
|
||||
>f<number>?.() : number
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
|
||||
const b4 = f<number>?.<number>(); // Error, expected no type arguments
|
||||
>b4 : number
|
||||
>f<number>?.<number>() : number
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
|
||||
// Parsed as function call, even though this differs from JavaScript
|
||||
|
||||
const x1 = f<true>
|
||||
>x1 : true
|
||||
>f<true>(true) : true
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
>true : true
|
||||
|
||||
(true);
|
||||
>true : true
|
||||
|
||||
// Parsed as relational expression
|
||||
|
||||
const x2 = f<true>
|
||||
>x2 : boolean
|
||||
>f<true>true : boolean
|
||||
>f<true : boolean
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
>true : true
|
||||
|
||||
true;
|
||||
>true : true
|
||||
|
||||
// Parsed as instantiation expression
|
||||
|
||||
const x3 = f<true>;
|
||||
>x3 : { (): true; g<U>(): U; }
|
||||
>f : { <T>(): T; g<U>(): U; }
|
||||
>true : true
|
||||
|
||||
true;
|
||||
>true : true
|
||||
|
||||
@@ -0,0 +1,228 @@
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressions.ts(6,16): error TS1099: Type argument list cannot be empty.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressions.ts(9,17): error TS2635: Type '{ <T>(x: T): T; <T>(x: T, n: number): T; <T, U>(t: [T, U]): [T, U]; }' has no signatures for which the type argument list is applicable.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressions.ts(12,21): error TS1099: Type argument list cannot be empty.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressions.ts(15,22): error TS2635: Type '{ <T>(x: T): T; <T>(x: T, n: number): T; <T, U>(t: [T, U]): [T, U]; }' has no signatures for which the type argument list is applicable.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressions.ts(18,21): error TS1099: Type argument list cannot be empty.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressions.ts(20,22): error TS2635: Type 'ArrayConstructor' has no signatures for which the type argument list is applicable.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressions.ts(23,24): error TS1099: Type argument list cannot be empty.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressions.ts(25,25): error TS2635: Type 'ArrayConstructor' has no signatures for which the type argument list is applicable.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressions.ts(50,16): error TS2635: Type '{ x: string; y: string; }' has no signatures for which the type argument list is applicable.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressions.ts(82,16): error TS2635: Type '{ x: string; } & { y: string; }' has no signatures for which the type argument list is applicable.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressions.ts(106,16): error TS2635: Type '(a: string, b: number) => string[]' has no signatures for which the type argument list is applicable.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressions.ts(114,16): error TS2635: Type '{ x: string; } | { y: string; }' has no signatures for which the type argument list is applicable.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressions.ts(126,16): error TS2635: Type '(a: string, b: number) => string[]' has no signatures for which the type argument list is applicable.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressions.ts(130,16): error TS2635: Type 'new (a: string, b: number) => string[]' has no signatures for which the type argument list is applicable.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressions.ts(163,40): error TS2344: Type 'U' does not satisfy the constraint 'number'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressions.ts(164,40): error TS2344: Type 'U' does not satisfy the constraint 'string'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressions.ts (16 errors) ====
|
||||
declare function fx<T>(x: T): T;
|
||||
declare function fx<T>(x: T, n: number): T;
|
||||
declare function fx<T, U>(t: [T, U]): [T, U];
|
||||
|
||||
function f1() {
|
||||
let f0 = fx<>; // Error
|
||||
~~
|
||||
!!! error TS1099: Type argument list cannot be empty.
|
||||
let f1 = fx<string>; // { (x: string): string; (x: string, n: number): string; }
|
||||
let f2 = fx<string, number>; // (t: [string, number]) => [string, number]
|
||||
let f3 = fx<string, number, boolean>; // Error
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2635: Type '{ <T>(x: T): T; <T>(x: T, n: number): T; <T, U>(t: [T, U]): [T, U]; }' has no signatures for which the type argument list is applicable.
|
||||
}
|
||||
|
||||
type T10 = typeof fx<>; // Error
|
||||
~~
|
||||
!!! error TS1099: Type argument list cannot be empty.
|
||||
type T11 = typeof fx<string>; // { (x: string): string; (x: string, n: number): string; }
|
||||
type T12 = typeof fx<string, number>; // (t: [string, number]) => [string, number]
|
||||
type T13 = typeof fx<string, number, boolean>; // Error
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2635: Type '{ <T>(x: T): T; <T>(x: T, n: number): T; <T, U>(t: [T, U]): [T, U]; }' has no signatures for which the type argument list is applicable.
|
||||
|
||||
function f2() {
|
||||
const A0 = Array<>; // Error
|
||||
~~
|
||||
!!! error TS1099: Type argument list cannot be empty.
|
||||
const A1 = Array<string>; // new (...) => string[]
|
||||
const A2 = Array<string, number>; // Error
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2635: Type 'ArrayConstructor' has no signatures for which the type argument list is applicable.
|
||||
}
|
||||
|
||||
type T20 = typeof Array<>; // Error
|
||||
~~
|
||||
!!! error TS1099: Type argument list cannot be empty.
|
||||
type T21 = typeof Array<string>; // new (...) => string[]
|
||||
type T22 = typeof Array<string, number>; // Error
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2635: Type 'ArrayConstructor' has no signatures for which the type argument list is applicable.
|
||||
|
||||
declare class C<T> {
|
||||
constructor(x: T);
|
||||
static f<U>(x: U): U[];
|
||||
}
|
||||
|
||||
function f3() {
|
||||
let c1 = C<string>; // { new (x: string): C<string>; f<U>(x: U): T[]; prototype: C<any>; }
|
||||
let f1 = C.f<string>; // (x: string) => string[]
|
||||
}
|
||||
|
||||
function f10(f: { <T>(a: T): T, <U>(a: U, b: number): U[] }) {
|
||||
let fs = f<string>; // { (a: string): string; (a: string, b: number): string[]; }
|
||||
}
|
||||
|
||||
function f11(f: { <T>(a: T): T, (a: string, b: number): string[] }) {
|
||||
let fs = f<string>; // (a: string) => string
|
||||
}
|
||||
|
||||
function f12(f: { <T>(a: T): T, x: string }) {
|
||||
let fs = f<string>; // { (a: string): string; x: string; }
|
||||
}
|
||||
|
||||
function f13(f: { x: string, y: string }) {
|
||||
let fs = f<string>; // Error, no applicable signatures
|
||||
~~~~~~
|
||||
!!! error TS2635: Type '{ x: string; y: string; }' has no signatures for which the type argument list is applicable.
|
||||
}
|
||||
|
||||
function f14(f: { new <T>(a: T): T, new <U>(a: U, b: number): U[] }) {
|
||||
let fs = f<string>; // { new (a: string): string; new (a: string, b: number): string[]; }
|
||||
}
|
||||
|
||||
function f15(f: { new <T>(a: T): T, <U>(a: U, b: number): U[] }) {
|
||||
let fs = f<string>; // { new (a: string): string; (a: string, b: number): string[]; }
|
||||
}
|
||||
|
||||
function f16(f: { new <T>(a: T): T, (a: string, b: number): string[] }) {
|
||||
let fs = f<string>; // new (a: string) => string
|
||||
}
|
||||
|
||||
function f17(f: { <T>(a: T): T, new (a: string, b: number): string[] }) {
|
||||
let fs = f<string>; // (a: string) => string
|
||||
}
|
||||
|
||||
function f20(f: (<T>(a: T) => T) & (<U>(a: U, b: number) => U[])) {
|
||||
let fs = f<string>; // ((a: string) => string) & ((a: string, b: number) => string[]])
|
||||
}
|
||||
|
||||
function f21(f: (<T>(a: T) => T) & ((a: string, b: number) => string[])) {
|
||||
let fs = f<string>; // (a: string) => string
|
||||
}
|
||||
|
||||
function f22(f: (<T>(a: T) => T) & { x: string }) {
|
||||
let fs = f<string>; // ((a: string) => string) & { x: string }
|
||||
}
|
||||
|
||||
function f23(f: { x: string } & { y: string }) {
|
||||
let fs = f<string>; // Error, no applicable signatures
|
||||
~~~~~~
|
||||
!!! error TS2635: Type '{ x: string; } & { y: string; }' has no signatures for which the type argument list is applicable.
|
||||
}
|
||||
|
||||
function f24(f: (new <T>(a: T) => T) & (new <U>(a: U, b: number) => U[])) {
|
||||
let fs = f<string>; // (new (a: string) => string) & ((a: string, b: number) => string[]])
|
||||
}
|
||||
|
||||
function f25(f: (new <T>(a: T) => T) & (<U>(a: U, b: number) => U[])) {
|
||||
let fs = f<string>; // (new (a: string) => string) & ((a: string, b: number) => string[]])
|
||||
}
|
||||
|
||||
function f26(f: (new <T>(a: T) => T) & ((a: string, b: number) => string[])) {
|
||||
let fs = f<string>; // new (a: string) => string
|
||||
}
|
||||
|
||||
function f27(f: (<T>(a: T) => T) & (new (a: string, b: number) => string[])) {
|
||||
let fs = f<string>; // (a: string) => string
|
||||
}
|
||||
|
||||
function f30(f: (<T>(a: T) => T) | (<U>(a: U, b: number) => U[])) {
|
||||
let fs = f<string>; // ((a: string) => string) | ((a: string, b: number) => string[]])
|
||||
}
|
||||
|
||||
function f31(f: (<T>(a: T) => T) | ((a: string, b: number) => string[])) {
|
||||
let fs = f<string>; // Error, '(a: string, b: number) => string[]' has no applicable signatures
|
||||
~~~~~~
|
||||
!!! error TS2635: Type '(a: string, b: number) => string[]' has no signatures for which the type argument list is applicable.
|
||||
}
|
||||
|
||||
function f32(f: (<T>(a: T) => T) | { x: string }) {
|
||||
let fs = f<string>; // ((a: string) => string) | { x: string }
|
||||
}
|
||||
|
||||
function f33(f: { x: string } | { y: string }) {
|
||||
let fs = f<string>; // Error, no applicable signatures
|
||||
~~~~~~
|
||||
!!! error TS2635: Type '{ x: string; } | { y: string; }' has no signatures for which the type argument list is applicable.
|
||||
}
|
||||
|
||||
function f34(f: (new <T>(a: T) => T) | (new <U>(a: U, b: number) => U[])) {
|
||||
let fs = f<string>; // (new (a: string) => string) | ((a: string, b: number) => string[]])
|
||||
}
|
||||
|
||||
function f35(f: (new <T>(a: T) => T) | (<U>(a: U, b: number) => U[])) {
|
||||
let fs = f<string>; // (new (a: string) => string) | ((a: string, b: number) => string[]])
|
||||
}
|
||||
|
||||
function f36(f: (new <T>(a: T) => T) | ((a: string, b: number) => string[])) {
|
||||
let fs = f<string>; // Error, '(a: string, b: number) => string[]' has no applicable signatures
|
||||
~~~~~~
|
||||
!!! error TS2635: Type '(a: string, b: number) => string[]' has no signatures for which the type argument list is applicable.
|
||||
}
|
||||
|
||||
function f37(f: (<T>(a: T) => T) | (new (a: string, b: number) => string[])) {
|
||||
let fs = f<string>; // Error, 'new (a: string, b: number) => string[]' has no applicable signatures
|
||||
~~~~~~
|
||||
!!! error TS2635: Type 'new (a: string, b: number) => string[]' has no signatures for which the type argument list is applicable.
|
||||
}
|
||||
|
||||
function f38<T extends (<A>(x: A) => A) | (<B>(x: B) => B[]), U>(f: T | U | (<C>(x: C) => C[][])) {
|
||||
let fs = f<string>; // U | ((x: string) => string) | ((x: string) => string[]) | ((x: string) => string[][])
|
||||
}
|
||||
|
||||
function makeBox<T>(value: T) {
|
||||
return { value };
|
||||
}
|
||||
|
||||
type BoxFunc<T> = typeof makeBox<T>; // (value: T) => { value: T }
|
||||
type StringBoxFunc = BoxFunc<string>; // (value: string) => { value: string }
|
||||
|
||||
type Box<T> = ReturnType<typeof makeBox<T>>; // { value: T }
|
||||
type StringBox = Box<string>; // { value: string }
|
||||
|
||||
type A<U> = InstanceType<typeof Array<U>>; // U[]
|
||||
|
||||
declare const g1: {
|
||||
<T>(a: T): { a: T };
|
||||
new <U>(b: U): { b: U };
|
||||
}
|
||||
|
||||
type T30<V> = typeof g1<V>; // { (a: V) => { a: V }; new (b: V) => { b: V }; }
|
||||
type T31<A> = ReturnType<T30<A>>; // { a: A }
|
||||
type T32<B> = InstanceType<T30<B>>; // { b: B }
|
||||
|
||||
declare const g2: {
|
||||
<T extends string>(a: T): T;
|
||||
new <T extends number>(b: T): T;
|
||||
}
|
||||
|
||||
type T40<U extends string> = typeof g2<U>; // Error
|
||||
~
|
||||
!!! error TS2344: Type 'U' does not satisfy the constraint 'number'.
|
||||
!!! error TS2344: Type 'string' is not assignable to type 'number'.
|
||||
type T41<U extends number> = typeof g2<U>; // Error
|
||||
~
|
||||
!!! error TS2344: Type 'U' does not satisfy the constraint 'string'.
|
||||
!!! error TS2344: Type 'number' is not assignable to type 'string'.
|
||||
|
||||
declare const g3: {
|
||||
<T extends string>(a: T): T;
|
||||
new <T extends number, Q>(b: T): T;
|
||||
}
|
||||
|
||||
type T50<U extends string> = typeof g3<U>; // (a: U) => U
|
||||
type T51<U extends number> = typeof g3<U, any>; // (b: U) => U
|
||||
|
||||
@@ -0,0 +1,382 @@
|
||||
//// [instantiationExpressions.ts]
|
||||
declare function fx<T>(x: T): T;
|
||||
declare function fx<T>(x: T, n: number): T;
|
||||
declare function fx<T, U>(t: [T, U]): [T, U];
|
||||
|
||||
function f1() {
|
||||
let f0 = fx<>; // Error
|
||||
let f1 = fx<string>; // { (x: string): string; (x: string, n: number): string; }
|
||||
let f2 = fx<string, number>; // (t: [string, number]) => [string, number]
|
||||
let f3 = fx<string, number, boolean>; // Error
|
||||
}
|
||||
|
||||
type T10 = typeof fx<>; // Error
|
||||
type T11 = typeof fx<string>; // { (x: string): string; (x: string, n: number): string; }
|
||||
type T12 = typeof fx<string, number>; // (t: [string, number]) => [string, number]
|
||||
type T13 = typeof fx<string, number, boolean>; // Error
|
||||
|
||||
function f2() {
|
||||
const A0 = Array<>; // Error
|
||||
const A1 = Array<string>; // new (...) => string[]
|
||||
const A2 = Array<string, number>; // Error
|
||||
}
|
||||
|
||||
type T20 = typeof Array<>; // Error
|
||||
type T21 = typeof Array<string>; // new (...) => string[]
|
||||
type T22 = typeof Array<string, number>; // Error
|
||||
|
||||
declare class C<T> {
|
||||
constructor(x: T);
|
||||
static f<U>(x: U): U[];
|
||||
}
|
||||
|
||||
function f3() {
|
||||
let c1 = C<string>; // { new (x: string): C<string>; f<U>(x: U): T[]; prototype: C<any>; }
|
||||
let f1 = C.f<string>; // (x: string) => string[]
|
||||
}
|
||||
|
||||
function f10(f: { <T>(a: T): T, <U>(a: U, b: number): U[] }) {
|
||||
let fs = f<string>; // { (a: string): string; (a: string, b: number): string[]; }
|
||||
}
|
||||
|
||||
function f11(f: { <T>(a: T): T, (a: string, b: number): string[] }) {
|
||||
let fs = f<string>; // (a: string) => string
|
||||
}
|
||||
|
||||
function f12(f: { <T>(a: T): T, x: string }) {
|
||||
let fs = f<string>; // { (a: string): string; x: string; }
|
||||
}
|
||||
|
||||
function f13(f: { x: string, y: string }) {
|
||||
let fs = f<string>; // Error, no applicable signatures
|
||||
}
|
||||
|
||||
function f14(f: { new <T>(a: T): T, new <U>(a: U, b: number): U[] }) {
|
||||
let fs = f<string>; // { new (a: string): string; new (a: string, b: number): string[]; }
|
||||
}
|
||||
|
||||
function f15(f: { new <T>(a: T): T, <U>(a: U, b: number): U[] }) {
|
||||
let fs = f<string>; // { new (a: string): string; (a: string, b: number): string[]; }
|
||||
}
|
||||
|
||||
function f16(f: { new <T>(a: T): T, (a: string, b: number): string[] }) {
|
||||
let fs = f<string>; // new (a: string) => string
|
||||
}
|
||||
|
||||
function f17(f: { <T>(a: T): T, new (a: string, b: number): string[] }) {
|
||||
let fs = f<string>; // (a: string) => string
|
||||
}
|
||||
|
||||
function f20(f: (<T>(a: T) => T) & (<U>(a: U, b: number) => U[])) {
|
||||
let fs = f<string>; // ((a: string) => string) & ((a: string, b: number) => string[]])
|
||||
}
|
||||
|
||||
function f21(f: (<T>(a: T) => T) & ((a: string, b: number) => string[])) {
|
||||
let fs = f<string>; // (a: string) => string
|
||||
}
|
||||
|
||||
function f22(f: (<T>(a: T) => T) & { x: string }) {
|
||||
let fs = f<string>; // ((a: string) => string) & { x: string }
|
||||
}
|
||||
|
||||
function f23(f: { x: string } & { y: string }) {
|
||||
let fs = f<string>; // Error, no applicable signatures
|
||||
}
|
||||
|
||||
function f24(f: (new <T>(a: T) => T) & (new <U>(a: U, b: number) => U[])) {
|
||||
let fs = f<string>; // (new (a: string) => string) & ((a: string, b: number) => string[]])
|
||||
}
|
||||
|
||||
function f25(f: (new <T>(a: T) => T) & (<U>(a: U, b: number) => U[])) {
|
||||
let fs = f<string>; // (new (a: string) => string) & ((a: string, b: number) => string[]])
|
||||
}
|
||||
|
||||
function f26(f: (new <T>(a: T) => T) & ((a: string, b: number) => string[])) {
|
||||
let fs = f<string>; // new (a: string) => string
|
||||
}
|
||||
|
||||
function f27(f: (<T>(a: T) => T) & (new (a: string, b: number) => string[])) {
|
||||
let fs = f<string>; // (a: string) => string
|
||||
}
|
||||
|
||||
function f30(f: (<T>(a: T) => T) | (<U>(a: U, b: number) => U[])) {
|
||||
let fs = f<string>; // ((a: string) => string) | ((a: string, b: number) => string[]])
|
||||
}
|
||||
|
||||
function f31(f: (<T>(a: T) => T) | ((a: string, b: number) => string[])) {
|
||||
let fs = f<string>; // Error, '(a: string, b: number) => string[]' has no applicable signatures
|
||||
}
|
||||
|
||||
function f32(f: (<T>(a: T) => T) | { x: string }) {
|
||||
let fs = f<string>; // ((a: string) => string) | { x: string }
|
||||
}
|
||||
|
||||
function f33(f: { x: string } | { y: string }) {
|
||||
let fs = f<string>; // Error, no applicable signatures
|
||||
}
|
||||
|
||||
function f34(f: (new <T>(a: T) => T) | (new <U>(a: U, b: number) => U[])) {
|
||||
let fs = f<string>; // (new (a: string) => string) | ((a: string, b: number) => string[]])
|
||||
}
|
||||
|
||||
function f35(f: (new <T>(a: T) => T) | (<U>(a: U, b: number) => U[])) {
|
||||
let fs = f<string>; // (new (a: string) => string) | ((a: string, b: number) => string[]])
|
||||
}
|
||||
|
||||
function f36(f: (new <T>(a: T) => T) | ((a: string, b: number) => string[])) {
|
||||
let fs = f<string>; // Error, '(a: string, b: number) => string[]' has no applicable signatures
|
||||
}
|
||||
|
||||
function f37(f: (<T>(a: T) => T) | (new (a: string, b: number) => string[])) {
|
||||
let fs = f<string>; // Error, 'new (a: string, b: number) => string[]' has no applicable signatures
|
||||
}
|
||||
|
||||
function f38<T extends (<A>(x: A) => A) | (<B>(x: B) => B[]), U>(f: T | U | (<C>(x: C) => C[][])) {
|
||||
let fs = f<string>; // U | ((x: string) => string) | ((x: string) => string[]) | ((x: string) => string[][])
|
||||
}
|
||||
|
||||
function makeBox<T>(value: T) {
|
||||
return { value };
|
||||
}
|
||||
|
||||
type BoxFunc<T> = typeof makeBox<T>; // (value: T) => { value: T }
|
||||
type StringBoxFunc = BoxFunc<string>; // (value: string) => { value: string }
|
||||
|
||||
type Box<T> = ReturnType<typeof makeBox<T>>; // { value: T }
|
||||
type StringBox = Box<string>; // { value: string }
|
||||
|
||||
type A<U> = InstanceType<typeof Array<U>>; // U[]
|
||||
|
||||
declare const g1: {
|
||||
<T>(a: T): { a: T };
|
||||
new <U>(b: U): { b: U };
|
||||
}
|
||||
|
||||
type T30<V> = typeof g1<V>; // { (a: V) => { a: V }; new (b: V) => { b: V }; }
|
||||
type T31<A> = ReturnType<T30<A>>; // { a: A }
|
||||
type T32<B> = InstanceType<T30<B>>; // { b: B }
|
||||
|
||||
declare const g2: {
|
||||
<T extends string>(a: T): T;
|
||||
new <T extends number>(b: T): T;
|
||||
}
|
||||
|
||||
type T40<U extends string> = typeof g2<U>; // Error
|
||||
type T41<U extends number> = typeof g2<U>; // Error
|
||||
|
||||
declare const g3: {
|
||||
<T extends string>(a: T): T;
|
||||
new <T extends number, Q>(b: T): T;
|
||||
}
|
||||
|
||||
type T50<U extends string> = typeof g3<U>; // (a: U) => U
|
||||
type T51<U extends number> = typeof g3<U, any>; // (b: U) => U
|
||||
|
||||
|
||||
//// [instantiationExpressions.js]
|
||||
"use strict";
|
||||
function f1() {
|
||||
var f0 = fx; // Error
|
||||
var f1 = (fx); // { (x: string): string; (x: string, n: number): string; }
|
||||
var f2 = (fx); // (t: [string, number]) => [string, number]
|
||||
var f3 = (fx); // Error
|
||||
}
|
||||
function f2() {
|
||||
var A0 = Array; // Error
|
||||
var A1 = (Array); // new (...) => string[]
|
||||
var A2 = (Array); // Error
|
||||
}
|
||||
function f3() {
|
||||
var c1 = (C); // { new (x: string): C<string>; f<U>(x: U): T[]; prototype: C<any>; }
|
||||
var f1 = (C.f); // (x: string) => string[]
|
||||
}
|
||||
function f10(f) {
|
||||
var fs = (f); // { (a: string): string; (a: string, b: number): string[]; }
|
||||
}
|
||||
function f11(f) {
|
||||
var fs = (f); // (a: string) => string
|
||||
}
|
||||
function f12(f) {
|
||||
var fs = (f); // { (a: string): string; x: string; }
|
||||
}
|
||||
function f13(f) {
|
||||
var fs = (f); // Error, no applicable signatures
|
||||
}
|
||||
function f14(f) {
|
||||
var fs = (f); // { new (a: string): string; new (a: string, b: number): string[]; }
|
||||
}
|
||||
function f15(f) {
|
||||
var fs = (f); // { new (a: string): string; (a: string, b: number): string[]; }
|
||||
}
|
||||
function f16(f) {
|
||||
var fs = (f); // new (a: string) => string
|
||||
}
|
||||
function f17(f) {
|
||||
var fs = (f); // (a: string) => string
|
||||
}
|
||||
function f20(f) {
|
||||
var fs = (f); // ((a: string) => string) & ((a: string, b: number) => string[]])
|
||||
}
|
||||
function f21(f) {
|
||||
var fs = (f); // (a: string) => string
|
||||
}
|
||||
function f22(f) {
|
||||
var fs = (f); // ((a: string) => string) & { x: string }
|
||||
}
|
||||
function f23(f) {
|
||||
var fs = (f); // Error, no applicable signatures
|
||||
}
|
||||
function f24(f) {
|
||||
var fs = (f); // (new (a: string) => string) & ((a: string, b: number) => string[]])
|
||||
}
|
||||
function f25(f) {
|
||||
var fs = (f); // (new (a: string) => string) & ((a: string, b: number) => string[]])
|
||||
}
|
||||
function f26(f) {
|
||||
var fs = (f); // new (a: string) => string
|
||||
}
|
||||
function f27(f) {
|
||||
var fs = (f); // (a: string) => string
|
||||
}
|
||||
function f30(f) {
|
||||
var fs = (f); // ((a: string) => string) | ((a: string, b: number) => string[]])
|
||||
}
|
||||
function f31(f) {
|
||||
var fs = (f); // Error, '(a: string, b: number) => string[]' has no applicable signatures
|
||||
}
|
||||
function f32(f) {
|
||||
var fs = (f); // ((a: string) => string) | { x: string }
|
||||
}
|
||||
function f33(f) {
|
||||
var fs = (f); // Error, no applicable signatures
|
||||
}
|
||||
function f34(f) {
|
||||
var fs = (f); // (new (a: string) => string) | ((a: string, b: number) => string[]])
|
||||
}
|
||||
function f35(f) {
|
||||
var fs = (f); // (new (a: string) => string) | ((a: string, b: number) => string[]])
|
||||
}
|
||||
function f36(f) {
|
||||
var fs = (f); // Error, '(a: string, b: number) => string[]' has no applicable signatures
|
||||
}
|
||||
function f37(f) {
|
||||
var fs = (f); // Error, 'new (a: string, b: number) => string[]' has no applicable signatures
|
||||
}
|
||||
function f38(f) {
|
||||
var fs = (f); // U | ((x: string) => string) | ((x: string) => string[]) | ((x: string) => string[][])
|
||||
}
|
||||
function makeBox(value) {
|
||||
return { value: value };
|
||||
}
|
||||
|
||||
|
||||
//// [instantiationExpressions.d.ts]
|
||||
declare function fx<T>(x: T): T;
|
||||
declare function fx<T>(x: T, n: number): T;
|
||||
declare function fx<T, U>(t: [T, U]): [T, U];
|
||||
declare function f1(): void;
|
||||
declare type T10 = typeof fx;
|
||||
declare type T11 = typeof fx<string>;
|
||||
declare type T12 = typeof fx<string, number>;
|
||||
declare type T13 = typeof fx<string, number, boolean>;
|
||||
declare function f2(): void;
|
||||
declare type T20 = typeof Array;
|
||||
declare type T21 = typeof Array<string>;
|
||||
declare type T22 = typeof Array<string, number>;
|
||||
declare class C<T> {
|
||||
constructor(x: T);
|
||||
static f<U>(x: U): U[];
|
||||
}
|
||||
declare function f3(): void;
|
||||
declare function f10(f: {
|
||||
<T>(a: T): T;
|
||||
<U>(a: U, b: number): U[];
|
||||
}): void;
|
||||
declare function f11(f: {
|
||||
<T>(a: T): T;
|
||||
(a: string, b: number): string[];
|
||||
}): void;
|
||||
declare function f12(f: {
|
||||
<T>(a: T): T;
|
||||
x: string;
|
||||
}): void;
|
||||
declare function f13(f: {
|
||||
x: string;
|
||||
y: string;
|
||||
}): void;
|
||||
declare function f14(f: {
|
||||
new <T>(a: T): T;
|
||||
new <U>(a: U, b: number): U[];
|
||||
}): void;
|
||||
declare function f15(f: {
|
||||
new <T>(a: T): T;
|
||||
<U>(a: U, b: number): U[];
|
||||
}): void;
|
||||
declare function f16(f: {
|
||||
new <T>(a: T): T;
|
||||
(a: string, b: number): string[];
|
||||
}): void;
|
||||
declare function f17(f: {
|
||||
<T>(a: T): T;
|
||||
new (a: string, b: number): string[];
|
||||
}): void;
|
||||
declare function f20(f: (<T>(a: T) => T) & (<U>(a: U, b: number) => U[])): void;
|
||||
declare function f21(f: (<T>(a: T) => T) & ((a: string, b: number) => string[])): void;
|
||||
declare function f22(f: (<T>(a: T) => T) & {
|
||||
x: string;
|
||||
}): void;
|
||||
declare function f23(f: {
|
||||
x: string;
|
||||
} & {
|
||||
y: string;
|
||||
}): void;
|
||||
declare function f24(f: (new <T>(a: T) => T) & (new <U>(a: U, b: number) => U[])): void;
|
||||
declare function f25(f: (new <T>(a: T) => T) & (<U>(a: U, b: number) => U[])): void;
|
||||
declare function f26(f: (new <T>(a: T) => T) & ((a: string, b: number) => string[])): void;
|
||||
declare function f27(f: (<T>(a: T) => T) & (new (a: string, b: number) => string[])): void;
|
||||
declare function f30(f: (<T>(a: T) => T) | (<U>(a: U, b: number) => U[])): void;
|
||||
declare function f31(f: (<T>(a: T) => T) | ((a: string, b: number) => string[])): void;
|
||||
declare function f32(f: (<T>(a: T) => T) | {
|
||||
x: string;
|
||||
}): void;
|
||||
declare function f33(f: {
|
||||
x: string;
|
||||
} | {
|
||||
y: string;
|
||||
}): void;
|
||||
declare function f34(f: (new <T>(a: T) => T) | (new <U>(a: U, b: number) => U[])): void;
|
||||
declare function f35(f: (new <T>(a: T) => T) | (<U>(a: U, b: number) => U[])): void;
|
||||
declare function f36(f: (new <T>(a: T) => T) | ((a: string, b: number) => string[])): void;
|
||||
declare function f37(f: (<T>(a: T) => T) | (new (a: string, b: number) => string[])): void;
|
||||
declare function f38<T extends (<A>(x: A) => A) | (<B>(x: B) => B[]), U>(f: T | U | (<C>(x: C) => C[][])): void;
|
||||
declare function makeBox<T>(value: T): {
|
||||
value: T;
|
||||
};
|
||||
declare type BoxFunc<T> = typeof makeBox<T>;
|
||||
declare type StringBoxFunc = BoxFunc<string>;
|
||||
declare type Box<T> = ReturnType<typeof makeBox<T>>;
|
||||
declare type StringBox = Box<string>;
|
||||
declare type A<U> = InstanceType<typeof Array<U>>;
|
||||
declare const g1: {
|
||||
<T>(a: T): {
|
||||
a: T;
|
||||
};
|
||||
new <U>(b: U): {
|
||||
b: U;
|
||||
};
|
||||
};
|
||||
declare type T30<V> = typeof g1<V>;
|
||||
declare type T31<A> = ReturnType<T30<A>>;
|
||||
declare type T32<B> = InstanceType<T30<B>>;
|
||||
declare const g2: {
|
||||
<T extends string>(a: T): T;
|
||||
new <T extends number>(b: T): T;
|
||||
};
|
||||
declare type T40<U extends string> = typeof g2<U>;
|
||||
declare type T41<U extends number> = typeof g2<U>;
|
||||
declare const g3: {
|
||||
<T extends string>(a: T): T;
|
||||
new <T extends number, Q>(b: T): T;
|
||||
};
|
||||
declare type T50<U extends string> = typeof g3<U>;
|
||||
declare type T51<U extends number> = typeof g3<U, any>;
|
||||
@@ -0,0 +1,650 @@
|
||||
=== tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressions.ts ===
|
||||
declare function fx<T>(x: T): T;
|
||||
>fx : Symbol(fx, Decl(instantiationExpressions.ts, 0, 0), Decl(instantiationExpressions.ts, 0, 32), Decl(instantiationExpressions.ts, 1, 43))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 0, 20))
|
||||
>x : Symbol(x, Decl(instantiationExpressions.ts, 0, 23))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 0, 20))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 0, 20))
|
||||
|
||||
declare function fx<T>(x: T, n: number): T;
|
||||
>fx : Symbol(fx, Decl(instantiationExpressions.ts, 0, 0), Decl(instantiationExpressions.ts, 0, 32), Decl(instantiationExpressions.ts, 1, 43))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 1, 20))
|
||||
>x : Symbol(x, Decl(instantiationExpressions.ts, 1, 23))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 1, 20))
|
||||
>n : Symbol(n, Decl(instantiationExpressions.ts, 1, 28))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 1, 20))
|
||||
|
||||
declare function fx<T, U>(t: [T, U]): [T, U];
|
||||
>fx : Symbol(fx, Decl(instantiationExpressions.ts, 0, 0), Decl(instantiationExpressions.ts, 0, 32), Decl(instantiationExpressions.ts, 1, 43))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 2, 20))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 2, 22))
|
||||
>t : Symbol(t, Decl(instantiationExpressions.ts, 2, 26))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 2, 20))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 2, 22))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 2, 20))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 2, 22))
|
||||
|
||||
function f1() {
|
||||
>f1 : Symbol(f1, Decl(instantiationExpressions.ts, 2, 45))
|
||||
|
||||
let f0 = fx<>; // Error
|
||||
>f0 : Symbol(f0, Decl(instantiationExpressions.ts, 5, 7))
|
||||
>fx : Symbol(fx, Decl(instantiationExpressions.ts, 0, 0), Decl(instantiationExpressions.ts, 0, 32), Decl(instantiationExpressions.ts, 1, 43))
|
||||
|
||||
let f1 = fx<string>; // { (x: string): string; (x: string, n: number): string; }
|
||||
>f1 : Symbol(f1, Decl(instantiationExpressions.ts, 6, 7))
|
||||
>fx : Symbol(fx, Decl(instantiationExpressions.ts, 0, 0), Decl(instantiationExpressions.ts, 0, 32), Decl(instantiationExpressions.ts, 1, 43))
|
||||
|
||||
let f2 = fx<string, number>; // (t: [string, number]) => [string, number]
|
||||
>f2 : Symbol(f2, Decl(instantiationExpressions.ts, 7, 7))
|
||||
>fx : Symbol(fx, Decl(instantiationExpressions.ts, 0, 0), Decl(instantiationExpressions.ts, 0, 32), Decl(instantiationExpressions.ts, 1, 43))
|
||||
|
||||
let f3 = fx<string, number, boolean>; // Error
|
||||
>f3 : Symbol(f3, Decl(instantiationExpressions.ts, 8, 7))
|
||||
>fx : Symbol(fx, Decl(instantiationExpressions.ts, 0, 0), Decl(instantiationExpressions.ts, 0, 32), Decl(instantiationExpressions.ts, 1, 43))
|
||||
}
|
||||
|
||||
type T10 = typeof fx<>; // Error
|
||||
>T10 : Symbol(T10, Decl(instantiationExpressions.ts, 9, 1))
|
||||
>fx : Symbol(fx, Decl(instantiationExpressions.ts, 0, 0), Decl(instantiationExpressions.ts, 0, 32), Decl(instantiationExpressions.ts, 1, 43))
|
||||
|
||||
type T11 = typeof fx<string>; // { (x: string): string; (x: string, n: number): string; }
|
||||
>T11 : Symbol(T11, Decl(instantiationExpressions.ts, 11, 23))
|
||||
>fx : Symbol(fx, Decl(instantiationExpressions.ts, 0, 0), Decl(instantiationExpressions.ts, 0, 32), Decl(instantiationExpressions.ts, 1, 43))
|
||||
|
||||
type T12 = typeof fx<string, number>; // (t: [string, number]) => [string, number]
|
||||
>T12 : Symbol(T12, Decl(instantiationExpressions.ts, 12, 29))
|
||||
>fx : Symbol(fx, Decl(instantiationExpressions.ts, 0, 0), Decl(instantiationExpressions.ts, 0, 32), Decl(instantiationExpressions.ts, 1, 43))
|
||||
|
||||
type T13 = typeof fx<string, number, boolean>; // Error
|
||||
>T13 : Symbol(T13, Decl(instantiationExpressions.ts, 13, 37))
|
||||
>fx : Symbol(fx, Decl(instantiationExpressions.ts, 0, 0), Decl(instantiationExpressions.ts, 0, 32), Decl(instantiationExpressions.ts, 1, 43))
|
||||
|
||||
function f2() {
|
||||
>f2 : Symbol(f2, Decl(instantiationExpressions.ts, 14, 46))
|
||||
|
||||
const A0 = Array<>; // Error
|
||||
>A0 : Symbol(A0, Decl(instantiationExpressions.ts, 17, 9))
|
||||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
const A1 = Array<string>; // new (...) => string[]
|
||||
>A1 : Symbol(A1, Decl(instantiationExpressions.ts, 18, 9))
|
||||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
const A2 = Array<string, number>; // Error
|
||||
>A2 : Symbol(A2, Decl(instantiationExpressions.ts, 19, 9))
|
||||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
}
|
||||
|
||||
type T20 = typeof Array<>; // Error
|
||||
>T20 : Symbol(T20, Decl(instantiationExpressions.ts, 20, 1))
|
||||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
type T21 = typeof Array<string>; // new (...) => string[]
|
||||
>T21 : Symbol(T21, Decl(instantiationExpressions.ts, 22, 26))
|
||||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
type T22 = typeof Array<string, number>; // Error
|
||||
>T22 : Symbol(T22, Decl(instantiationExpressions.ts, 23, 32))
|
||||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
declare class C<T> {
|
||||
>C : Symbol(C, Decl(instantiationExpressions.ts, 24, 40))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 26, 16))
|
||||
|
||||
constructor(x: T);
|
||||
>x : Symbol(x, Decl(instantiationExpressions.ts, 27, 16))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 26, 16))
|
||||
|
||||
static f<U>(x: U): U[];
|
||||
>f : Symbol(C.f, Decl(instantiationExpressions.ts, 27, 22))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 28, 13))
|
||||
>x : Symbol(x, Decl(instantiationExpressions.ts, 28, 16))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 28, 13))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 28, 13))
|
||||
}
|
||||
|
||||
function f3() {
|
||||
>f3 : Symbol(f3, Decl(instantiationExpressions.ts, 29, 1))
|
||||
|
||||
let c1 = C<string>; // { new (x: string): C<string>; f<U>(x: U): T[]; prototype: C<any>; }
|
||||
>c1 : Symbol(c1, Decl(instantiationExpressions.ts, 32, 7))
|
||||
>C : Symbol(C, Decl(instantiationExpressions.ts, 24, 40))
|
||||
|
||||
let f1 = C.f<string>; // (x: string) => string[]
|
||||
>f1 : Symbol(f1, Decl(instantiationExpressions.ts, 33, 7))
|
||||
>C.f : Symbol(C.f, Decl(instantiationExpressions.ts, 27, 22))
|
||||
>C : Symbol(C, Decl(instantiationExpressions.ts, 24, 40))
|
||||
>f : Symbol(C.f, Decl(instantiationExpressions.ts, 27, 22))
|
||||
}
|
||||
|
||||
function f10(f: { <T>(a: T): T, <U>(a: U, b: number): U[] }) {
|
||||
>f10 : Symbol(f10, Decl(instantiationExpressions.ts, 34, 1))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 36, 13))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 36, 19))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 36, 22))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 36, 19))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 36, 19))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 36, 33))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 36, 36))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 36, 33))
|
||||
>b : Symbol(b, Decl(instantiationExpressions.ts, 36, 41))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 36, 33))
|
||||
|
||||
let fs = f<string>; // { (a: string): string; (a: string, b: number): string[]; }
|
||||
>fs : Symbol(fs, Decl(instantiationExpressions.ts, 37, 7))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 36, 13))
|
||||
}
|
||||
|
||||
function f11(f: { <T>(a: T): T, (a: string, b: number): string[] }) {
|
||||
>f11 : Symbol(f11, Decl(instantiationExpressions.ts, 38, 1))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 40, 13))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 40, 19))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 40, 22))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 40, 19))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 40, 19))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 40, 33))
|
||||
>b : Symbol(b, Decl(instantiationExpressions.ts, 40, 43))
|
||||
|
||||
let fs = f<string>; // (a: string) => string
|
||||
>fs : Symbol(fs, Decl(instantiationExpressions.ts, 41, 7))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 40, 13))
|
||||
}
|
||||
|
||||
function f12(f: { <T>(a: T): T, x: string }) {
|
||||
>f12 : Symbol(f12, Decl(instantiationExpressions.ts, 42, 1))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 44, 13))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 44, 19))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 44, 22))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 44, 19))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 44, 19))
|
||||
>x : Symbol(x, Decl(instantiationExpressions.ts, 44, 31))
|
||||
|
||||
let fs = f<string>; // { (a: string): string; x: string; }
|
||||
>fs : Symbol(fs, Decl(instantiationExpressions.ts, 45, 7))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 44, 13))
|
||||
}
|
||||
|
||||
function f13(f: { x: string, y: string }) {
|
||||
>f13 : Symbol(f13, Decl(instantiationExpressions.ts, 46, 1))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 48, 13))
|
||||
>x : Symbol(x, Decl(instantiationExpressions.ts, 48, 17))
|
||||
>y : Symbol(y, Decl(instantiationExpressions.ts, 48, 28))
|
||||
|
||||
let fs = f<string>; // Error, no applicable signatures
|
||||
>fs : Symbol(fs, Decl(instantiationExpressions.ts, 49, 7))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 48, 13))
|
||||
}
|
||||
|
||||
function f14(f: { new <T>(a: T): T, new <U>(a: U, b: number): U[] }) {
|
||||
>f14 : Symbol(f14, Decl(instantiationExpressions.ts, 50, 1))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 52, 13))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 52, 23))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 52, 26))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 52, 23))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 52, 23))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 52, 41))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 52, 44))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 52, 41))
|
||||
>b : Symbol(b, Decl(instantiationExpressions.ts, 52, 49))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 52, 41))
|
||||
|
||||
let fs = f<string>; // { new (a: string): string; new (a: string, b: number): string[]; }
|
||||
>fs : Symbol(fs, Decl(instantiationExpressions.ts, 53, 7))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 52, 13))
|
||||
}
|
||||
|
||||
function f15(f: { new <T>(a: T): T, <U>(a: U, b: number): U[] }) {
|
||||
>f15 : Symbol(f15, Decl(instantiationExpressions.ts, 54, 1))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 56, 13))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 56, 23))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 56, 26))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 56, 23))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 56, 23))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 56, 37))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 56, 40))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 56, 37))
|
||||
>b : Symbol(b, Decl(instantiationExpressions.ts, 56, 45))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 56, 37))
|
||||
|
||||
let fs = f<string>; // { new (a: string): string; (a: string, b: number): string[]; }
|
||||
>fs : Symbol(fs, Decl(instantiationExpressions.ts, 57, 7))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 56, 13))
|
||||
}
|
||||
|
||||
function f16(f: { new <T>(a: T): T, (a: string, b: number): string[] }) {
|
||||
>f16 : Symbol(f16, Decl(instantiationExpressions.ts, 58, 1))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 60, 13))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 60, 23))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 60, 26))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 60, 23))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 60, 23))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 60, 37))
|
||||
>b : Symbol(b, Decl(instantiationExpressions.ts, 60, 47))
|
||||
|
||||
let fs = f<string>; // new (a: string) => string
|
||||
>fs : Symbol(fs, Decl(instantiationExpressions.ts, 61, 7))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 60, 13))
|
||||
}
|
||||
|
||||
function f17(f: { <T>(a: T): T, new (a: string, b: number): string[] }) {
|
||||
>f17 : Symbol(f17, Decl(instantiationExpressions.ts, 62, 1))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 64, 13))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 64, 19))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 64, 22))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 64, 19))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 64, 19))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 64, 37))
|
||||
>b : Symbol(b, Decl(instantiationExpressions.ts, 64, 47))
|
||||
|
||||
let fs = f<string>; // (a: string) => string
|
||||
>fs : Symbol(fs, Decl(instantiationExpressions.ts, 65, 7))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 64, 13))
|
||||
}
|
||||
|
||||
function f20(f: (<T>(a: T) => T) & (<U>(a: U, b: number) => U[])) {
|
||||
>f20 : Symbol(f20, Decl(instantiationExpressions.ts, 66, 1))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 68, 13))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 68, 18))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 68, 21))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 68, 18))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 68, 18))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 68, 37))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 68, 40))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 68, 37))
|
||||
>b : Symbol(b, Decl(instantiationExpressions.ts, 68, 45))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 68, 37))
|
||||
|
||||
let fs = f<string>; // ((a: string) => string) & ((a: string, b: number) => string[]])
|
||||
>fs : Symbol(fs, Decl(instantiationExpressions.ts, 69, 7))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 68, 13))
|
||||
}
|
||||
|
||||
function f21(f: (<T>(a: T) => T) & ((a: string, b: number) => string[])) {
|
||||
>f21 : Symbol(f21, Decl(instantiationExpressions.ts, 70, 1))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 72, 13))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 72, 18))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 72, 21))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 72, 18))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 72, 18))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 72, 37))
|
||||
>b : Symbol(b, Decl(instantiationExpressions.ts, 72, 47))
|
||||
|
||||
let fs = f<string>; // (a: string) => string
|
||||
>fs : Symbol(fs, Decl(instantiationExpressions.ts, 73, 7))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 72, 13))
|
||||
}
|
||||
|
||||
function f22(f: (<T>(a: T) => T) & { x: string }) {
|
||||
>f22 : Symbol(f22, Decl(instantiationExpressions.ts, 74, 1))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 76, 13))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 76, 18))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 76, 21))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 76, 18))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 76, 18))
|
||||
>x : Symbol(x, Decl(instantiationExpressions.ts, 76, 36))
|
||||
|
||||
let fs = f<string>; // ((a: string) => string) & { x: string }
|
||||
>fs : Symbol(fs, Decl(instantiationExpressions.ts, 77, 7))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 76, 13))
|
||||
}
|
||||
|
||||
function f23(f: { x: string } & { y: string }) {
|
||||
>f23 : Symbol(f23, Decl(instantiationExpressions.ts, 78, 1))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 80, 13))
|
||||
>x : Symbol(x, Decl(instantiationExpressions.ts, 80, 17))
|
||||
>y : Symbol(y, Decl(instantiationExpressions.ts, 80, 33))
|
||||
|
||||
let fs = f<string>; // Error, no applicable signatures
|
||||
>fs : Symbol(fs, Decl(instantiationExpressions.ts, 81, 7))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 80, 13))
|
||||
}
|
||||
|
||||
function f24(f: (new <T>(a: T) => T) & (new <U>(a: U, b: number) => U[])) {
|
||||
>f24 : Symbol(f24, Decl(instantiationExpressions.ts, 82, 1))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 84, 13))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 84, 22))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 84, 25))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 84, 22))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 84, 22))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 84, 45))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 84, 48))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 84, 45))
|
||||
>b : Symbol(b, Decl(instantiationExpressions.ts, 84, 53))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 84, 45))
|
||||
|
||||
let fs = f<string>; // (new (a: string) => string) & ((a: string, b: number) => string[]])
|
||||
>fs : Symbol(fs, Decl(instantiationExpressions.ts, 85, 7))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 84, 13))
|
||||
}
|
||||
|
||||
function f25(f: (new <T>(a: T) => T) & (<U>(a: U, b: number) => U[])) {
|
||||
>f25 : Symbol(f25, Decl(instantiationExpressions.ts, 86, 1))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 88, 13))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 88, 22))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 88, 25))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 88, 22))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 88, 22))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 88, 41))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 88, 44))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 88, 41))
|
||||
>b : Symbol(b, Decl(instantiationExpressions.ts, 88, 49))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 88, 41))
|
||||
|
||||
let fs = f<string>; // (new (a: string) => string) & ((a: string, b: number) => string[]])
|
||||
>fs : Symbol(fs, Decl(instantiationExpressions.ts, 89, 7))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 88, 13))
|
||||
}
|
||||
|
||||
function f26(f: (new <T>(a: T) => T) & ((a: string, b: number) => string[])) {
|
||||
>f26 : Symbol(f26, Decl(instantiationExpressions.ts, 90, 1))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 92, 13))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 92, 22))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 92, 25))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 92, 22))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 92, 22))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 92, 41))
|
||||
>b : Symbol(b, Decl(instantiationExpressions.ts, 92, 51))
|
||||
|
||||
let fs = f<string>; // new (a: string) => string
|
||||
>fs : Symbol(fs, Decl(instantiationExpressions.ts, 93, 7))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 92, 13))
|
||||
}
|
||||
|
||||
function f27(f: (<T>(a: T) => T) & (new (a: string, b: number) => string[])) {
|
||||
>f27 : Symbol(f27, Decl(instantiationExpressions.ts, 94, 1))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 96, 13))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 96, 18))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 96, 21))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 96, 18))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 96, 18))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 96, 41))
|
||||
>b : Symbol(b, Decl(instantiationExpressions.ts, 96, 51))
|
||||
|
||||
let fs = f<string>; // (a: string) => string
|
||||
>fs : Symbol(fs, Decl(instantiationExpressions.ts, 97, 7))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 96, 13))
|
||||
}
|
||||
|
||||
function f30(f: (<T>(a: T) => T) | (<U>(a: U, b: number) => U[])) {
|
||||
>f30 : Symbol(f30, Decl(instantiationExpressions.ts, 98, 1))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 100, 13))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 100, 18))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 100, 21))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 100, 18))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 100, 18))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 100, 37))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 100, 40))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 100, 37))
|
||||
>b : Symbol(b, Decl(instantiationExpressions.ts, 100, 45))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 100, 37))
|
||||
|
||||
let fs = f<string>; // ((a: string) => string) | ((a: string, b: number) => string[]])
|
||||
>fs : Symbol(fs, Decl(instantiationExpressions.ts, 101, 7))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 100, 13))
|
||||
}
|
||||
|
||||
function f31(f: (<T>(a: T) => T) | ((a: string, b: number) => string[])) {
|
||||
>f31 : Symbol(f31, Decl(instantiationExpressions.ts, 102, 1))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 104, 13))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 104, 18))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 104, 21))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 104, 18))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 104, 18))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 104, 37))
|
||||
>b : Symbol(b, Decl(instantiationExpressions.ts, 104, 47))
|
||||
|
||||
let fs = f<string>; // Error, '(a: string, b: number) => string[]' has no applicable signatures
|
||||
>fs : Symbol(fs, Decl(instantiationExpressions.ts, 105, 7))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 104, 13))
|
||||
}
|
||||
|
||||
function f32(f: (<T>(a: T) => T) | { x: string }) {
|
||||
>f32 : Symbol(f32, Decl(instantiationExpressions.ts, 106, 1))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 108, 13))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 108, 18))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 108, 21))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 108, 18))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 108, 18))
|
||||
>x : Symbol(x, Decl(instantiationExpressions.ts, 108, 36))
|
||||
|
||||
let fs = f<string>; // ((a: string) => string) | { x: string }
|
||||
>fs : Symbol(fs, Decl(instantiationExpressions.ts, 109, 7))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 108, 13))
|
||||
}
|
||||
|
||||
function f33(f: { x: string } | { y: string }) {
|
||||
>f33 : Symbol(f33, Decl(instantiationExpressions.ts, 110, 1))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 112, 13))
|
||||
>x : Symbol(x, Decl(instantiationExpressions.ts, 112, 17))
|
||||
>y : Symbol(y, Decl(instantiationExpressions.ts, 112, 33))
|
||||
|
||||
let fs = f<string>; // Error, no applicable signatures
|
||||
>fs : Symbol(fs, Decl(instantiationExpressions.ts, 113, 7))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 112, 13))
|
||||
}
|
||||
|
||||
function f34(f: (new <T>(a: T) => T) | (new <U>(a: U, b: number) => U[])) {
|
||||
>f34 : Symbol(f34, Decl(instantiationExpressions.ts, 114, 1))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 116, 13))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 116, 22))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 116, 25))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 116, 22))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 116, 22))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 116, 45))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 116, 48))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 116, 45))
|
||||
>b : Symbol(b, Decl(instantiationExpressions.ts, 116, 53))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 116, 45))
|
||||
|
||||
let fs = f<string>; // (new (a: string) => string) | ((a: string, b: number) => string[]])
|
||||
>fs : Symbol(fs, Decl(instantiationExpressions.ts, 117, 7))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 116, 13))
|
||||
}
|
||||
|
||||
function f35(f: (new <T>(a: T) => T) | (<U>(a: U, b: number) => U[])) {
|
||||
>f35 : Symbol(f35, Decl(instantiationExpressions.ts, 118, 1))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 120, 13))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 120, 22))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 120, 25))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 120, 22))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 120, 22))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 120, 41))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 120, 44))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 120, 41))
|
||||
>b : Symbol(b, Decl(instantiationExpressions.ts, 120, 49))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 120, 41))
|
||||
|
||||
let fs = f<string>; // (new (a: string) => string) | ((a: string, b: number) => string[]])
|
||||
>fs : Symbol(fs, Decl(instantiationExpressions.ts, 121, 7))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 120, 13))
|
||||
}
|
||||
|
||||
function f36(f: (new <T>(a: T) => T) | ((a: string, b: number) => string[])) {
|
||||
>f36 : Symbol(f36, Decl(instantiationExpressions.ts, 122, 1))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 124, 13))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 124, 22))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 124, 25))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 124, 22))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 124, 22))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 124, 41))
|
||||
>b : Symbol(b, Decl(instantiationExpressions.ts, 124, 51))
|
||||
|
||||
let fs = f<string>; // Error, '(a: string, b: number) => string[]' has no applicable signatures
|
||||
>fs : Symbol(fs, Decl(instantiationExpressions.ts, 125, 7))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 124, 13))
|
||||
}
|
||||
|
||||
function f37(f: (<T>(a: T) => T) | (new (a: string, b: number) => string[])) {
|
||||
>f37 : Symbol(f37, Decl(instantiationExpressions.ts, 126, 1))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 128, 13))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 128, 18))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 128, 21))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 128, 18))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 128, 18))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 128, 41))
|
||||
>b : Symbol(b, Decl(instantiationExpressions.ts, 128, 51))
|
||||
|
||||
let fs = f<string>; // Error, 'new (a: string, b: number) => string[]' has no applicable signatures
|
||||
>fs : Symbol(fs, Decl(instantiationExpressions.ts, 129, 7))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 128, 13))
|
||||
}
|
||||
|
||||
function f38<T extends (<A>(x: A) => A) | (<B>(x: B) => B[]), U>(f: T | U | (<C>(x: C) => C[][])) {
|
||||
>f38 : Symbol(f38, Decl(instantiationExpressions.ts, 130, 1))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 132, 13))
|
||||
>A : Symbol(A, Decl(instantiationExpressions.ts, 132, 25))
|
||||
>x : Symbol(x, Decl(instantiationExpressions.ts, 132, 28))
|
||||
>A : Symbol(A, Decl(instantiationExpressions.ts, 132, 25))
|
||||
>A : Symbol(A, Decl(instantiationExpressions.ts, 132, 25))
|
||||
>B : Symbol(B, Decl(instantiationExpressions.ts, 132, 44))
|
||||
>x : Symbol(x, Decl(instantiationExpressions.ts, 132, 47))
|
||||
>B : Symbol(B, Decl(instantiationExpressions.ts, 132, 44))
|
||||
>B : Symbol(B, Decl(instantiationExpressions.ts, 132, 44))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 132, 61))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 132, 65))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 132, 13))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 132, 61))
|
||||
>C : Symbol(C, Decl(instantiationExpressions.ts, 132, 78))
|
||||
>x : Symbol(x, Decl(instantiationExpressions.ts, 132, 81))
|
||||
>C : Symbol(C, Decl(instantiationExpressions.ts, 132, 78))
|
||||
>C : Symbol(C, Decl(instantiationExpressions.ts, 132, 78))
|
||||
|
||||
let fs = f<string>; // U | ((x: string) => string) | ((x: string) => string[]) | ((x: string) => string[][])
|
||||
>fs : Symbol(fs, Decl(instantiationExpressions.ts, 133, 7))
|
||||
>f : Symbol(f, Decl(instantiationExpressions.ts, 132, 65))
|
||||
}
|
||||
|
||||
function makeBox<T>(value: T) {
|
||||
>makeBox : Symbol(makeBox, Decl(instantiationExpressions.ts, 134, 1))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 136, 17))
|
||||
>value : Symbol(value, Decl(instantiationExpressions.ts, 136, 20))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 136, 17))
|
||||
|
||||
return { value };
|
||||
>value : Symbol(value, Decl(instantiationExpressions.ts, 137, 12))
|
||||
}
|
||||
|
||||
type BoxFunc<T> = typeof makeBox<T>; // (value: T) => { value: T }
|
||||
>BoxFunc : Symbol(BoxFunc, Decl(instantiationExpressions.ts, 138, 1))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 140, 13))
|
||||
>makeBox : Symbol(makeBox, Decl(instantiationExpressions.ts, 134, 1))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 140, 13))
|
||||
|
||||
type StringBoxFunc = BoxFunc<string>; // (value: string) => { value: string }
|
||||
>StringBoxFunc : Symbol(StringBoxFunc, Decl(instantiationExpressions.ts, 140, 36))
|
||||
>BoxFunc : Symbol(BoxFunc, Decl(instantiationExpressions.ts, 138, 1))
|
||||
|
||||
type Box<T> = ReturnType<typeof makeBox<T>>; // { value: T }
|
||||
>Box : Symbol(Box, Decl(instantiationExpressions.ts, 141, 37))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 143, 9))
|
||||
>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --))
|
||||
>makeBox : Symbol(makeBox, Decl(instantiationExpressions.ts, 134, 1))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 143, 9))
|
||||
|
||||
type StringBox = Box<string>; // { value: string }
|
||||
>StringBox : Symbol(StringBox, Decl(instantiationExpressions.ts, 143, 44))
|
||||
>Box : Symbol(Box, Decl(instantiationExpressions.ts, 141, 37))
|
||||
|
||||
type A<U> = InstanceType<typeof Array<U>>; // U[]
|
||||
>A : Symbol(A, Decl(instantiationExpressions.ts, 144, 29))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 146, 7))
|
||||
>InstanceType : Symbol(InstanceType, Decl(lib.es5.d.ts, --, --))
|
||||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 146, 7))
|
||||
|
||||
declare const g1: {
|
||||
>g1 : Symbol(g1, Decl(instantiationExpressions.ts, 148, 13))
|
||||
|
||||
<T>(a: T): { a: T };
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 149, 5))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 149, 8))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 149, 5))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 149, 16))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 149, 5))
|
||||
|
||||
new <U>(b: U): { b: U };
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 150, 9))
|
||||
>b : Symbol(b, Decl(instantiationExpressions.ts, 150, 12))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 150, 9))
|
||||
>b : Symbol(b, Decl(instantiationExpressions.ts, 150, 20))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 150, 9))
|
||||
}
|
||||
|
||||
type T30<V> = typeof g1<V>; // { (a: V) => { a: V }; new (b: V) => { b: V }; }
|
||||
>T30 : Symbol(T30, Decl(instantiationExpressions.ts, 151, 1))
|
||||
>V : Symbol(V, Decl(instantiationExpressions.ts, 153, 9))
|
||||
>g1 : Symbol(g1, Decl(instantiationExpressions.ts, 148, 13))
|
||||
>V : Symbol(V, Decl(instantiationExpressions.ts, 153, 9))
|
||||
|
||||
type T31<A> = ReturnType<T30<A>>; // { a: A }
|
||||
>T31 : Symbol(T31, Decl(instantiationExpressions.ts, 153, 27))
|
||||
>A : Symbol(A, Decl(instantiationExpressions.ts, 154, 9))
|
||||
>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --))
|
||||
>T30 : Symbol(T30, Decl(instantiationExpressions.ts, 151, 1))
|
||||
>A : Symbol(A, Decl(instantiationExpressions.ts, 154, 9))
|
||||
|
||||
type T32<B> = InstanceType<T30<B>>; // { b: B }
|
||||
>T32 : Symbol(T32, Decl(instantiationExpressions.ts, 154, 33))
|
||||
>B : Symbol(B, Decl(instantiationExpressions.ts, 155, 9))
|
||||
>InstanceType : Symbol(InstanceType, Decl(lib.es5.d.ts, --, --))
|
||||
>T30 : Symbol(T30, Decl(instantiationExpressions.ts, 151, 1))
|
||||
>B : Symbol(B, Decl(instantiationExpressions.ts, 155, 9))
|
||||
|
||||
declare const g2: {
|
||||
>g2 : Symbol(g2, Decl(instantiationExpressions.ts, 157, 13))
|
||||
|
||||
<T extends string>(a: T): T;
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 158, 5))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 158, 23))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 158, 5))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 158, 5))
|
||||
|
||||
new <T extends number>(b: T): T;
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 159, 9))
|
||||
>b : Symbol(b, Decl(instantiationExpressions.ts, 159, 27))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 159, 9))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 159, 9))
|
||||
}
|
||||
|
||||
type T40<U extends string> = typeof g2<U>; // Error
|
||||
>T40 : Symbol(T40, Decl(instantiationExpressions.ts, 160, 1))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 162, 9))
|
||||
>g2 : Symbol(g2, Decl(instantiationExpressions.ts, 157, 13))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 162, 9))
|
||||
|
||||
type T41<U extends number> = typeof g2<U>; // Error
|
||||
>T41 : Symbol(T41, Decl(instantiationExpressions.ts, 162, 42))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 163, 9))
|
||||
>g2 : Symbol(g2, Decl(instantiationExpressions.ts, 157, 13))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 163, 9))
|
||||
|
||||
declare const g3: {
|
||||
>g3 : Symbol(g3, Decl(instantiationExpressions.ts, 165, 13))
|
||||
|
||||
<T extends string>(a: T): T;
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 166, 5))
|
||||
>a : Symbol(a, Decl(instantiationExpressions.ts, 166, 23))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 166, 5))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 166, 5))
|
||||
|
||||
new <T extends number, Q>(b: T): T;
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 167, 9))
|
||||
>Q : Symbol(Q, Decl(instantiationExpressions.ts, 167, 26))
|
||||
>b : Symbol(b, Decl(instantiationExpressions.ts, 167, 30))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 167, 9))
|
||||
>T : Symbol(T, Decl(instantiationExpressions.ts, 167, 9))
|
||||
}
|
||||
|
||||
type T50<U extends string> = typeof g3<U>; // (a: U) => U
|
||||
>T50 : Symbol(T50, Decl(instantiationExpressions.ts, 168, 1))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 170, 9))
|
||||
>g3 : Symbol(g3, Decl(instantiationExpressions.ts, 165, 13))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 170, 9))
|
||||
|
||||
type T51<U extends number> = typeof g3<U, any>; // (b: U) => U
|
||||
>T51 : Symbol(T51, Decl(instantiationExpressions.ts, 170, 42))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 171, 9))
|
||||
>g3 : Symbol(g3, Decl(instantiationExpressions.ts, 165, 13))
|
||||
>U : Symbol(U, Decl(instantiationExpressions.ts, 171, 9))
|
||||
|
||||
@@ -0,0 +1,482 @@
|
||||
=== tests/cases/conformance/types/typeParameters/typeArgumentLists/instantiationExpressions.ts ===
|
||||
declare function fx<T>(x: T): T;
|
||||
>fx : { <T>(x: T): T; <T>(x: T, n: number): T; <T, U>(t: [T, U]): [T, U]; }
|
||||
>x : T
|
||||
|
||||
declare function fx<T>(x: T, n: number): T;
|
||||
>fx : { <T>(x: T): T; <T>(x: T, n: number): T; <T, U>(t: [T, U]): [T, U]; }
|
||||
>x : T
|
||||
>n : number
|
||||
|
||||
declare function fx<T, U>(t: [T, U]): [T, U];
|
||||
>fx : { <T>(x: T): T; <T>(x: T, n: number): T; <T, U>(t: [T, U]): [T, U]; }
|
||||
>t : [T, U]
|
||||
|
||||
function f1() {
|
||||
>f1 : () => void
|
||||
|
||||
let f0 = fx<>; // Error
|
||||
>f0 : { <T>(x: T): T; <T>(x: T, n: number): T; <T, U>(t: [T, U]): [T, U]; }
|
||||
>fx : { <T>(x: T): T; <T>(x: T, n: number): T; <T, U>(t: [T, U]): [T, U]; }
|
||||
|
||||
let f1 = fx<string>; // { (x: string): string; (x: string, n: number): string; }
|
||||
>f1 : { (x: string): string; (x: string, n: number): string; }
|
||||
>fx : { <T>(x: T): T; <T>(x: T, n: number): T; <T, U>(t: [T, U]): [T, U]; }
|
||||
|
||||
let f2 = fx<string, number>; // (t: [string, number]) => [string, number]
|
||||
>f2 : (t: [string, number]) => [string, number]
|
||||
>fx : { <T>(x: T): T; <T>(x: T, n: number): T; <T, U>(t: [T, U]): [T, U]; }
|
||||
|
||||
let f3 = fx<string, number, boolean>; // Error
|
||||
>f3 : {}
|
||||
>fx : { <T>(x: T): T; <T>(x: T, n: number): T; <T, U>(t: [T, U]): [T, U]; }
|
||||
}
|
||||
|
||||
type T10 = typeof fx<>; // Error
|
||||
>T10 : { <T>(x: T): T; <T>(x: T, n: number): T; <T, U>(t: [T, U]): [T, U]; }
|
||||
>fx : { <T>(x: T): T; <T>(x: T, n: number): T; <T, U>(t: [T, U]): [T, U]; }
|
||||
|
||||
type T11 = typeof fx<string>; // { (x: string): string; (x: string, n: number): string; }
|
||||
>T11 : { (x: string): string; (x: string, n: number): string; }
|
||||
>fx : { <T>(x: T): T; <T>(x: T, n: number): T; <T, U>(t: [T, U]): [T, U]; }
|
||||
|
||||
type T12 = typeof fx<string, number>; // (t: [string, number]) => [string, number]
|
||||
>T12 : (t: [string, number]) => [string, number]
|
||||
>fx : { <T>(x: T): T; <T>(x: T, n: number): T; <T, U>(t: [T, U]): [T, U]; }
|
||||
|
||||
type T13 = typeof fx<string, number, boolean>; // Error
|
||||
>T13 : {}
|
||||
>fx : { <T>(x: T): T; <T>(x: T, n: number): T; <T, U>(t: [T, U]): [T, U]; }
|
||||
|
||||
function f2() {
|
||||
>f2 : () => void
|
||||
|
||||
const A0 = Array<>; // Error
|
||||
>A0 : ArrayConstructor
|
||||
>Array : ArrayConstructor
|
||||
|
||||
const A1 = Array<string>; // new (...) => string[]
|
||||
>A1 : { (arrayLength: number): string[]; (...items: string[]): string[]; new (arrayLength: number): string[]; new (...items: string[]): string[]; isArray(arg: any): arg is any[]; readonly prototype: any[]; }
|
||||
>Array : ArrayConstructor
|
||||
|
||||
const A2 = Array<string, number>; // Error
|
||||
>A2 : { isArray(arg: any): arg is any[]; readonly prototype: any[]; }
|
||||
>Array : ArrayConstructor
|
||||
}
|
||||
|
||||
type T20 = typeof Array<>; // Error
|
||||
>T20 : ArrayConstructor
|
||||
>Array : ArrayConstructor
|
||||
|
||||
type T21 = typeof Array<string>; // new (...) => string[]
|
||||
>T21 : { (arrayLength: number): string[]; (...items: string[]): string[]; new (arrayLength: number): string[]; new (...items: string[]): string[]; isArray(arg: any): arg is any[]; readonly prototype: any[]; }
|
||||
>Array : ArrayConstructor
|
||||
|
||||
type T22 = typeof Array<string, number>; // Error
|
||||
>T22 : { isArray(arg: any): arg is any[]; readonly prototype: any[]; }
|
||||
>Array : ArrayConstructor
|
||||
|
||||
declare class C<T> {
|
||||
>C : C<T>
|
||||
|
||||
constructor(x: T);
|
||||
>x : T
|
||||
|
||||
static f<U>(x: U): U[];
|
||||
>f : <U>(x: U) => U[]
|
||||
>x : U
|
||||
}
|
||||
|
||||
function f3() {
|
||||
>f3 : () => void
|
||||
|
||||
let c1 = C<string>; // { new (x: string): C<string>; f<U>(x: U): T[]; prototype: C<any>; }
|
||||
>c1 : { new (x: string): C<string>; prototype: C<any>; f<U>(x: U): U[]; }
|
||||
>C : typeof C
|
||||
|
||||
let f1 = C.f<string>; // (x: string) => string[]
|
||||
>f1 : (x: string) => string[]
|
||||
>C.f : <U>(x: U) => U[]
|
||||
>C : typeof C
|
||||
>f : <U>(x: U) => U[]
|
||||
}
|
||||
|
||||
function f10(f: { <T>(a: T): T, <U>(a: U, b: number): U[] }) {
|
||||
>f10 : (f: { <T>(a: T): T; <U>(a: U, b: number): U[]; }) => void
|
||||
>f : { <T>(a: T): T; <U>(a: U, b: number): U[]; }
|
||||
>a : T
|
||||
>a : U
|
||||
>b : number
|
||||
|
||||
let fs = f<string>; // { (a: string): string; (a: string, b: number): string[]; }
|
||||
>fs : { (a: string): string; (a: string, b: number): string[]; }
|
||||
>f : { <T>(a: T): T; <U>(a: U, b: number): U[]; }
|
||||
}
|
||||
|
||||
function f11(f: { <T>(a: T): T, (a: string, b: number): string[] }) {
|
||||
>f11 : (f: { <T>(a: T): T; (a: string, b: number): string[]; }) => void
|
||||
>f : { <T>(a: T): T; (a: string, b: number): string[]; }
|
||||
>a : T
|
||||
>a : string
|
||||
>b : number
|
||||
|
||||
let fs = f<string>; // (a: string) => string
|
||||
>fs : (a: string) => string
|
||||
>f : { <T>(a: T): T; (a: string, b: number): string[]; }
|
||||
}
|
||||
|
||||
function f12(f: { <T>(a: T): T, x: string }) {
|
||||
>f12 : (f: { <T>(a: T): T; x: string; }) => void
|
||||
>f : { <T>(a: T): T; x: string; }
|
||||
>a : T
|
||||
>x : string
|
||||
|
||||
let fs = f<string>; // { (a: string): string; x: string; }
|
||||
>fs : { (a: string): string; x: string; }
|
||||
>f : { <T>(a: T): T; x: string; }
|
||||
}
|
||||
|
||||
function f13(f: { x: string, y: string }) {
|
||||
>f13 : (f: { x: string; y: string;}) => void
|
||||
>f : { x: string; y: string; }
|
||||
>x : string
|
||||
>y : string
|
||||
|
||||
let fs = f<string>; // Error, no applicable signatures
|
||||
>fs : { x: string; y: string; }
|
||||
>f : { x: string; y: string; }
|
||||
}
|
||||
|
||||
function f14(f: { new <T>(a: T): T, new <U>(a: U, b: number): U[] }) {
|
||||
>f14 : (f: { new <T>(a: T): T; new <U>(a: U, b: number): U[]; }) => void
|
||||
>f : { new <T>(a: T): T; new <U>(a: U, b: number): U[]; }
|
||||
>a : T
|
||||
>a : U
|
||||
>b : number
|
||||
|
||||
let fs = f<string>; // { new (a: string): string; new (a: string, b: number): string[]; }
|
||||
>fs : { new (a: string): string; new (a: string, b: number): string[]; }
|
||||
>f : { new <T>(a: T): T; new <U>(a: U, b: number): U[]; }
|
||||
}
|
||||
|
||||
function f15(f: { new <T>(a: T): T, <U>(a: U, b: number): U[] }) {
|
||||
>f15 : (f: { <U>(a: U, b: number): U[]; new <T>(a: T): T; }) => void
|
||||
>f : { <U>(a: U, b: number): U[]; new <T>(a: T): T; }
|
||||
>a : T
|
||||
>a : U
|
||||
>b : number
|
||||
|
||||
let fs = f<string>; // { new (a: string): string; (a: string, b: number): string[]; }
|
||||
>fs : { (a: string, b: number): string[]; new (a: string): string; }
|
||||
>f : { <U>(a: U, b: number): U[]; new <T>(a: T): T; }
|
||||
}
|
||||
|
||||
function f16(f: { new <T>(a: T): T, (a: string, b: number): string[] }) {
|
||||
>f16 : (f: { (a: string, b: number): string[]; new <T>(a: T): T; }) => void
|
||||
>f : { (a: string, b: number): string[]; new <T>(a: T): T; }
|
||||
>a : T
|
||||
>a : string
|
||||
>b : number
|
||||
|
||||
let fs = f<string>; // new (a: string) => string
|
||||
>fs : new (a: string) => string
|
||||
>f : { (a: string, b: number): string[]; new <T>(a: T): T; }
|
||||
}
|
||||
|
||||
function f17(f: { <T>(a: T): T, new (a: string, b: number): string[] }) {
|
||||
>f17 : (f: { <T>(a: T): T; new (a: string, b: number): string[]; }) => void
|
||||
>f : { <T>(a: T): T; new (a: string, b: number): string[]; }
|
||||
>a : T
|
||||
>a : string
|
||||
>b : number
|
||||
|
||||
let fs = f<string>; // (a: string) => string
|
||||
>fs : (a: string) => string
|
||||
>f : { <T>(a: T): T; new (a: string, b: number): string[]; }
|
||||
}
|
||||
|
||||
function f20(f: (<T>(a: T) => T) & (<U>(a: U, b: number) => U[])) {
|
||||
>f20 : (f: (<T>(a: T) => T) & (<U>(a: U, b: number) => U[])) => void
|
||||
>f : (<T>(a: T) => T) & (<U>(a: U, b: number) => U[])
|
||||
>a : T
|
||||
>a : U
|
||||
>b : number
|
||||
|
||||
let fs = f<string>; // ((a: string) => string) & ((a: string, b: number) => string[]])
|
||||
>fs : ((a: string) => string) & ((a: string, b: number) => string[])
|
||||
>f : (<T>(a: T) => T) & (<U>(a: U, b: number) => U[])
|
||||
}
|
||||
|
||||
function f21(f: (<T>(a: T) => T) & ((a: string, b: number) => string[])) {
|
||||
>f21 : (f: (<T>(a: T) => T) & ((a: string, b: number) => string[])) => void
|
||||
>f : (<T>(a: T) => T) & ((a: string, b: number) => string[])
|
||||
>a : T
|
||||
>a : string
|
||||
>b : number
|
||||
|
||||
let fs = f<string>; // (a: string) => string
|
||||
>fs : (a: string) => string
|
||||
>f : (<T>(a: T) => T) & ((a: string, b: number) => string[])
|
||||
}
|
||||
|
||||
function f22(f: (<T>(a: T) => T) & { x: string }) {
|
||||
>f22 : (f: (<T>(a: T) => T) & { x: string; }) => void
|
||||
>f : (<T>(a: T) => T) & { x: string; }
|
||||
>a : T
|
||||
>x : string
|
||||
|
||||
let fs = f<string>; // ((a: string) => string) & { x: string }
|
||||
>fs : ((a: string) => string) & { x: string; }
|
||||
>f : (<T>(a: T) => T) & { x: string; }
|
||||
}
|
||||
|
||||
function f23(f: { x: string } & { y: string }) {
|
||||
>f23 : (f: { x: string;} & { y: string;}) => void
|
||||
>f : { x: string; } & { y: string; }
|
||||
>x : string
|
||||
>y : string
|
||||
|
||||
let fs = f<string>; // Error, no applicable signatures
|
||||
>fs : { x: string; } & { y: string; }
|
||||
>f : { x: string; } & { y: string; }
|
||||
}
|
||||
|
||||
function f24(f: (new <T>(a: T) => T) & (new <U>(a: U, b: number) => U[])) {
|
||||
>f24 : (f: (new <T>(a: T) => T) & (new <U>(a: U, b: number) => U[])) => void
|
||||
>f : (new <T>(a: T) => T) & (new <U>(a: U, b: number) => U[])
|
||||
>a : T
|
||||
>a : U
|
||||
>b : number
|
||||
|
||||
let fs = f<string>; // (new (a: string) => string) & ((a: string, b: number) => string[]])
|
||||
>fs : (new (a: string) => string) & (new (a: string, b: number) => string[])
|
||||
>f : (new <T>(a: T) => T) & (new <U>(a: U, b: number) => U[])
|
||||
}
|
||||
|
||||
function f25(f: (new <T>(a: T) => T) & (<U>(a: U, b: number) => U[])) {
|
||||
>f25 : (f: (new <T>(a: T) => T) & (<U>(a: U, b: number) => U[])) => void
|
||||
>f : (new <T>(a: T) => T) & (<U>(a: U, b: number) => U[])
|
||||
>a : T
|
||||
>a : U
|
||||
>b : number
|
||||
|
||||
let fs = f<string>; // (new (a: string) => string) & ((a: string, b: number) => string[]])
|
||||
>fs : (new (a: string) => string) & ((a: string, b: number) => string[])
|
||||
>f : (new <T>(a: T) => T) & (<U>(a: U, b: number) => U[])
|
||||
}
|
||||
|
||||
function f26(f: (new <T>(a: T) => T) & ((a: string, b: number) => string[])) {
|
||||
>f26 : (f: (new <T>(a: T) => T) & ((a: string, b: number) => string[])) => void
|
||||
>f : (new <T>(a: T) => T) & ((a: string, b: number) => string[])
|
||||
>a : T
|
||||
>a : string
|
||||
>b : number
|
||||
|
||||
let fs = f<string>; // new (a: string) => string
|
||||
>fs : new (a: string) => string
|
||||
>f : (new <T>(a: T) => T) & ((a: string, b: number) => string[])
|
||||
}
|
||||
|
||||
function f27(f: (<T>(a: T) => T) & (new (a: string, b: number) => string[])) {
|
||||
>f27 : (f: (<T>(a: T) => T) & (new (a: string, b: number) => string[])) => void
|
||||
>f : (<T>(a: T) => T) & (new (a: string, b: number) => string[])
|
||||
>a : T
|
||||
>a : string
|
||||
>b : number
|
||||
|
||||
let fs = f<string>; // (a: string) => string
|
||||
>fs : (a: string) => string
|
||||
>f : (<T>(a: T) => T) & (new (a: string, b: number) => string[])
|
||||
}
|
||||
|
||||
function f30(f: (<T>(a: T) => T) | (<U>(a: U, b: number) => U[])) {
|
||||
>f30 : (f: (<T>(a: T) => T) | (<U>(a: U, b: number) => U[])) => void
|
||||
>f : (<T>(a: T) => T) | (<U>(a: U, b: number) => U[])
|
||||
>a : T
|
||||
>a : U
|
||||
>b : number
|
||||
|
||||
let fs = f<string>; // ((a: string) => string) | ((a: string, b: number) => string[]])
|
||||
>fs : ((a: string) => string) | ((a: string, b: number) => string[])
|
||||
>f : (<T>(a: T) => T) | (<U>(a: U, b: number) => U[])
|
||||
}
|
||||
|
||||
function f31(f: (<T>(a: T) => T) | ((a: string, b: number) => string[])) {
|
||||
>f31 : (f: (<T>(a: T) => T) | ((a: string, b: number) => string[])) => void
|
||||
>f : (<T>(a: T) => T) | ((a: string, b: number) => string[])
|
||||
>a : T
|
||||
>a : string
|
||||
>b : number
|
||||
|
||||
let fs = f<string>; // Error, '(a: string, b: number) => string[]' has no applicable signatures
|
||||
>fs : ((a: string) => string) | {}
|
||||
>f : (<T>(a: T) => T) | ((a: string, b: number) => string[])
|
||||
}
|
||||
|
||||
function f32(f: (<T>(a: T) => T) | { x: string }) {
|
||||
>f32 : (f: { x: string; } | (<T>(a: T) => T)) => void
|
||||
>f : { x: string; } | (<T>(a: T) => T)
|
||||
>a : T
|
||||
>x : string
|
||||
|
||||
let fs = f<string>; // ((a: string) => string) | { x: string }
|
||||
>fs : { x: string; } | ((a: string) => string)
|
||||
>f : { x: string; } | (<T>(a: T) => T)
|
||||
}
|
||||
|
||||
function f33(f: { x: string } | { y: string }) {
|
||||
>f33 : (f: { x: string;} | { y: string;}) => void
|
||||
>f : { x: string; } | { y: string; }
|
||||
>x : string
|
||||
>y : string
|
||||
|
||||
let fs = f<string>; // Error, no applicable signatures
|
||||
>fs : { x: string; } | { y: string; }
|
||||
>f : { x: string; } | { y: string; }
|
||||
}
|
||||
|
||||
function f34(f: (new <T>(a: T) => T) | (new <U>(a: U, b: number) => U[])) {
|
||||
>f34 : (f: (new <T>(a: T) => T) | (new <U>(a: U, b: number) => U[])) => void
|
||||
>f : (new <T>(a: T) => T) | (new <U>(a: U, b: number) => U[])
|
||||
>a : T
|
||||
>a : U
|
||||
>b : number
|
||||
|
||||
let fs = f<string>; // (new (a: string) => string) | ((a: string, b: number) => string[]])
|
||||
>fs : (new (a: string) => string) | (new (a: string, b: number) => string[])
|
||||
>f : (new <T>(a: T) => T) | (new <U>(a: U, b: number) => U[])
|
||||
}
|
||||
|
||||
function f35(f: (new <T>(a: T) => T) | (<U>(a: U, b: number) => U[])) {
|
||||
>f35 : (f: (new <T>(a: T) => T) | (<U>(a: U, b: number) => U[])) => void
|
||||
>f : (new <T>(a: T) => T) | (<U>(a: U, b: number) => U[])
|
||||
>a : T
|
||||
>a : U
|
||||
>b : number
|
||||
|
||||
let fs = f<string>; // (new (a: string) => string) | ((a: string, b: number) => string[]])
|
||||
>fs : (new (a: string) => string) | ((a: string, b: number) => string[])
|
||||
>f : (new <T>(a: T) => T) | (<U>(a: U, b: number) => U[])
|
||||
}
|
||||
|
||||
function f36(f: (new <T>(a: T) => T) | ((a: string, b: number) => string[])) {
|
||||
>f36 : (f: (new <T>(a: T) => T) | ((a: string, b: number) => string[])) => void
|
||||
>f : (new <T>(a: T) => T) | ((a: string, b: number) => string[])
|
||||
>a : T
|
||||
>a : string
|
||||
>b : number
|
||||
|
||||
let fs = f<string>; // Error, '(a: string, b: number) => string[]' has no applicable signatures
|
||||
>fs : (new (a: string) => string) | {}
|
||||
>f : (new <T>(a: T) => T) | ((a: string, b: number) => string[])
|
||||
}
|
||||
|
||||
function f37(f: (<T>(a: T) => T) | (new (a: string, b: number) => string[])) {
|
||||
>f37 : (f: (<T>(a: T) => T) | (new (a: string, b: number) => string[])) => void
|
||||
>f : (<T>(a: T) => T) | (new (a: string, b: number) => string[])
|
||||
>a : T
|
||||
>a : string
|
||||
>b : number
|
||||
|
||||
let fs = f<string>; // Error, 'new (a: string, b: number) => string[]' has no applicable signatures
|
||||
>fs : ((a: string) => string) | {}
|
||||
>f : (<T>(a: T) => T) | (new (a: string, b: number) => string[])
|
||||
}
|
||||
|
||||
function f38<T extends (<A>(x: A) => A) | (<B>(x: B) => B[]), U>(f: T | U | (<C>(x: C) => C[][])) {
|
||||
>f38 : <T extends (<A>(x: A) => A) | (<B>(x: B) => B[]), U>(f: T | U | (<C>(x: C) => C[][])) => void
|
||||
>x : A
|
||||
>x : B
|
||||
>f : T | U | (<C>(x: C) => C[][])
|
||||
>x : C
|
||||
|
||||
let fs = f<string>; // U | ((x: string) => string) | ((x: string) => string[]) | ((x: string) => string[][])
|
||||
>fs : U | ((x: string) => string) | ((x: string) => string[]) | ((x: string) => string[][])
|
||||
>f : T | U | (<C>(x: C) => C[][])
|
||||
}
|
||||
|
||||
function makeBox<T>(value: T) {
|
||||
>makeBox : <T>(value: T) => { value: T; }
|
||||
>value : T
|
||||
|
||||
return { value };
|
||||
>{ value } : { value: T; }
|
||||
>value : T
|
||||
}
|
||||
|
||||
type BoxFunc<T> = typeof makeBox<T>; // (value: T) => { value: T }
|
||||
>BoxFunc : (value: T) => { value: T; }
|
||||
>makeBox : <T>(value: T) => { value: T; }
|
||||
|
||||
type StringBoxFunc = BoxFunc<string>; // (value: string) => { value: string }
|
||||
>StringBoxFunc : StringBoxFunc
|
||||
|
||||
type Box<T> = ReturnType<typeof makeBox<T>>; // { value: T }
|
||||
>Box : { value: T; }
|
||||
>makeBox : <T>(value: T) => { value: T; }
|
||||
|
||||
type StringBox = Box<string>; // { value: string }
|
||||
>StringBox : StringBox
|
||||
|
||||
type A<U> = InstanceType<typeof Array<U>>; // U[]
|
||||
>A : U[]
|
||||
>Array : ArrayConstructor
|
||||
|
||||
declare const g1: {
|
||||
>g1 : { <T>(a: T): { a: T; }; new <U>(b: U): { b: U; }; }
|
||||
|
||||
<T>(a: T): { a: T };
|
||||
>a : T
|
||||
>a : T
|
||||
|
||||
new <U>(b: U): { b: U };
|
||||
>b : U
|
||||
>b : U
|
||||
}
|
||||
|
||||
type T30<V> = typeof g1<V>; // { (a: V) => { a: V }; new (b: V) => { b: V }; }
|
||||
>T30 : { (a: V): { a: V; }; new (b: V): { b: V; }; }
|
||||
>g1 : { <T>(a: T): { a: T; }; new <U>(b: U): { b: U; }; }
|
||||
|
||||
type T31<A> = ReturnType<T30<A>>; // { a: A }
|
||||
>T31 : { a: A; }
|
||||
|
||||
type T32<B> = InstanceType<T30<B>>; // { b: B }
|
||||
>T32 : { b: B; }
|
||||
|
||||
declare const g2: {
|
||||
>g2 : { <T extends string>(a: T): T; new <T extends number>(b: T): T; }
|
||||
|
||||
<T extends string>(a: T): T;
|
||||
>a : T
|
||||
|
||||
new <T extends number>(b: T): T;
|
||||
>b : T
|
||||
}
|
||||
|
||||
type T40<U extends string> = typeof g2<U>; // Error
|
||||
>T40 : { (a: U): U; new <T extends number>(b: T): T; }
|
||||
>g2 : { <T extends string>(a: T): T; new <T extends number>(b: T): T; }
|
||||
|
||||
type T41<U extends number> = typeof g2<U>; // Error
|
||||
>T41 : { <T extends string>(a: T): T; new (b: U): U; }
|
||||
>g2 : { <T extends string>(a: T): T; new <T extends number>(b: T): T; }
|
||||
|
||||
declare const g3: {
|
||||
>g3 : { <T extends string>(a: T): T; new <T extends number, Q>(b: T): T; }
|
||||
|
||||
<T extends string>(a: T): T;
|
||||
>a : T
|
||||
|
||||
new <T extends number, Q>(b: T): T;
|
||||
>b : T
|
||||
}
|
||||
|
||||
type T50<U extends string> = typeof g3<U>; // (a: U) => U
|
||||
>T50 : (a: U) => U
|
||||
>g3 : { <T extends string>(a: T): T; new <T extends number, Q>(b: T): T; }
|
||||
|
||||
type T51<U extends number> = typeof g3<U, any>; // (b: U) => U
|
||||
>T51 : new (b: U) => U
|
||||
>g3 : { <T extends string>(a: T): T; new <T extends number, Q>(b: T): T; }
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts(26,16): error TS1005: ',' expected.
|
||||
tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts(26,16): error TS2695: Left side of comma operator is unused and has no side effects.
|
||||
tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts(31,9): error TS1384: A 'new' expression with type arguments must always be followed by a parenthesized argument list.
|
||||
tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts(36,9): error TS2350: Only a void function can be called with the 'new' keyword.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts (4 errors) ====
|
||||
==== tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts (3 errors) ====
|
||||
class C0 {
|
||||
|
||||
}
|
||||
@@ -39,9 +38,7 @@ tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts(36,9):
|
||||
// Generic construct expression with no parentheses
|
||||
var c1 = new T;
|
||||
var c1: T<{}>;
|
||||
var c2 = new T<string>; // Parse error
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS1384: A 'new' expression with type arguments must always be followed by a parenthesized argument list.
|
||||
var c2 = new T<string>; // Ok
|
||||
|
||||
|
||||
// Construct expression of non-void returning function
|
||||
|
||||
@@ -29,7 +29,7 @@ var b = new C0 32, ''; // Parse error
|
||||
// Generic construct expression with no parentheses
|
||||
var c1 = new T;
|
||||
var c1: T<{}>;
|
||||
var c2 = new T<string>; // Parse error
|
||||
var c2 = new T<string>; // Ok
|
||||
|
||||
|
||||
// Construct expression of non-void returning function
|
||||
@@ -62,7 +62,7 @@ var b = new C0;
|
||||
// Generic construct expression with no parentheses
|
||||
var c1 = new T;
|
||||
var c1;
|
||||
var c2 = new T; // Parse error
|
||||
var c2 = new T; // Ok
|
||||
// Construct expression of non-void returning function
|
||||
function fnNumber() { return 32; }
|
||||
var s = new fnNumber(); // Error
|
||||
|
||||
@@ -58,7 +58,7 @@ var c1: T<{}>;
|
||||
>c1 : Symbol(c1, Decl(newOperatorErrorCases.ts, 28, 3), Decl(newOperatorErrorCases.ts, 29, 3))
|
||||
>T : Symbol(T, Decl(newOperatorErrorCases.ts, 5, 1))
|
||||
|
||||
var c2 = new T<string>; // Parse error
|
||||
var c2 = new T<string>; // Ok
|
||||
>c2 : Symbol(c2, Decl(newOperatorErrorCases.ts, 30, 3))
|
||||
>T : Symbol(T, Decl(newOperatorErrorCases.ts, 5, 1))
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ var c1 = new T;
|
||||
var c1: T<{}>;
|
||||
>c1 : T<unknown>
|
||||
|
||||
var c2 = new T<string>; // Parse error
|
||||
var c2 = new T<string>; // Ok
|
||||
>c2 : T<string>
|
||||
>new T<string> : T<string>
|
||||
>T : typeof T
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserConstructorAmbiguity3.ts(1,1): error TS1384: A 'new' expression with type arguments must always be followed by a parenthesized argument list.
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserConstructorAmbiguity3.ts(1,10): error TS2304: Cannot find name 'A'.
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserConstructorAmbiguity3.ts(1,10): error TS2558: Expected 0 type arguments, but got 1.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/Generics/parserConstructorAmbiguity3.ts (3 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/Generics/parserConstructorAmbiguity3.ts (2 errors) ====
|
||||
new Date<A>
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1384: A 'new' expression with type arguments must always be followed by a parenthesized argument list.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'A'.
|
||||
~
|
||||
|
||||
@@ -3,19 +3,11 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(2,1): error TS2304: Cannot find name 'Foo'.
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(2,9): error TS2304: Cannot find name 'T'.
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(3,1): error TS2304: Cannot find name 'Foo'.
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(3,5): error TS2304: Cannot find name 'T'.
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(3,7): error TS1005: '(' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(3,8): error TS2304: Cannot find name 'Bar'.
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(3,13): error TS1005: ')' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,1): error TS2304: Cannot find name 'Foo'.
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,5): error TS2304: Cannot find name 'T'.
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,7): error TS1005: '(' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,8): error TS2304: Cannot find name 'Bar'.
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,12): error TS2304: Cannot find name 'T'.
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts(4,16): error TS1005: ')' expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts (15 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression1.ts (7 errors) ====
|
||||
Foo<T>();
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'Foo'.
|
||||
@@ -29,25 +21,9 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessExpression
|
||||
Foo<T>.Bar();
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'Foo'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'T'.
|
||||
~
|
||||
!!! error TS1005: '(' expected.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'Bar'.
|
||||
~
|
||||
!!! error TS1005: ')' expected.
|
||||
Foo<T>.Bar<T>();
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'Foo'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'T'.
|
||||
~
|
||||
!!! error TS1005: '(' expected.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'Bar'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'T'.
|
||||
~
|
||||
!!! error TS1005: ')' expected.
|
||||
|
||||
@@ -8,5 +8,5 @@ Foo<T>.Bar<T>();
|
||||
//// [parserMemberAccessExpression1.js]
|
||||
Foo();
|
||||
Foo.Bar();
|
||||
Foo(Bar());
|
||||
Foo(Bar());
|
||||
Foo.Bar();
|
||||
Foo.Bar();
|
||||
|
||||
@@ -11,13 +11,13 @@ Foo.Bar<T>();
|
||||
|
||||
Foo<T>.Bar();
|
||||
>Foo<T>.Bar() : any
|
||||
>Foo<T>.Bar : any
|
||||
>Foo : any
|
||||
>Bar() : any
|
||||
>Bar : any
|
||||
|
||||
Foo<T>.Bar<T>();
|
||||
>Foo<T>.Bar<T>() : any
|
||||
>Foo<T>.Bar : any
|
||||
>Foo : any
|
||||
>Bar<T>() : any
|
||||
>Bar : any
|
||||
|
||||
|
||||
@@ -1,16 +1,7 @@
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts(1,9): error TS2304: Cannot find name 'List'.
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts(1,21): error TS1005: '(' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts(1,22): error TS2304: Cannot find name 'makeChild'.
|
||||
tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts(1,33): error TS1005: ')' expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts (4 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/Generics/parserMemberAccessOffOfGenericType1.ts (1 errors) ====
|
||||
var v = List<number>.makeChild();
|
||||
~~~~
|
||||
!!! error TS2304: Cannot find name 'List'.
|
||||
~
|
||||
!!! error TS1005: '(' expected.
|
||||
~~~~~~~~~
|
||||
!!! error TS2304: Cannot find name 'makeChild'.
|
||||
~
|
||||
!!! error TS1005: ')' expected.
|
||||
!!! error TS2304: Cannot find name 'List'.
|
||||
@@ -2,4 +2,4 @@
|
||||
var v = List<number>.makeChild();
|
||||
|
||||
//// [parserMemberAccessOffOfGenericType1.js]
|
||||
var v = List(makeChild());
|
||||
var v = List.makeChild();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
var v = List<number>.makeChild();
|
||||
>v : any
|
||||
>List<number>.makeChild() : any
|
||||
>List<number>.makeChild : any
|
||||
>List : any
|
||||
>makeChild() : any
|
||||
>makeChild : any
|
||||
|
||||
|
||||
@@ -1,16 +1,7 @@
|
||||
tests/cases/conformance/parser/ecmascript5/Types/parserTypeQuery8.ts(1,15): error TS2304: Cannot find name 'A'.
|
||||
tests/cases/conformance/parser/ecmascript5/Types/parserTypeQuery8.ts(1,16): error TS1005: ',' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/Types/parserTypeQuery8.ts(1,17): error TS2304: Cannot find name 'B'.
|
||||
tests/cases/conformance/parser/ecmascript5/Types/parserTypeQuery8.ts(1,19): error TS1109: Expression expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/Types/parserTypeQuery8.ts (4 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/Types/parserTypeQuery8.ts (1 errors) ====
|
||||
var v: typeof A<B>
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'A'.
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'B'.
|
||||
|
||||
!!! error TS1109: Expression expected.
|
||||
!!! error TS2304: Cannot find name 'A'.
|
||||
@@ -3,4 +3,3 @@ var v: typeof A<B>
|
||||
|
||||
//// [parserTypeQuery8.js]
|
||||
var v;
|
||||
;
|
||||
|
||||
@@ -2,6 +2,4 @@
|
||||
var v: typeof A<B>
|
||||
>v : any
|
||||
>A : any
|
||||
><B> : B
|
||||
> : any
|
||||
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
tests/cases/conformance/es6/templates/taggedTemplatesWithTypeArguments2.ts(13,30): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplatesWithTypeArguments2.ts(15,11): error TS2347: Untyped function calls may not accept type arguments.
|
||||
tests/cases/conformance/es6/templates/taggedTemplatesWithTypeArguments2.ts(17,11): error TS2347: Untyped function calls may not accept type arguments.
|
||||
tests/cases/conformance/es6/templates/taggedTemplatesWithTypeArguments2.ts(17,30): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplatesWithTypeArguments2.ts(17,59): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplatesWithTypeArguments2.ts(35,5): error TS2377: Constructors for derived classes must contain a 'super' call.
|
||||
tests/cases/conformance/es6/templates/taggedTemplatesWithTypeArguments2.ts(36,9): error TS17011: 'super' must be called before accessing a property of 'super' in the constructor of a derived class.
|
||||
tests/cases/conformance/es6/templates/taggedTemplatesWithTypeArguments2.ts(36,14): error TS2754: 'super' may not use type arguments.
|
||||
tests/cases/conformance/es6/templates/taggedTemplatesWithTypeArguments2.ts(36,34): error TS1034: 'super' must be followed by an argument list or member access.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/taggedTemplatesWithTypeArguments2.ts (8 errors) ====
|
||||
==== tests/cases/conformance/es6/templates/taggedTemplatesWithTypeArguments2.ts (7 errors) ====
|
||||
export interface SomethingTaggable {
|
||||
<T>(t: TemplateStringsArray, ...args: T[]): SomethingNewable;
|
||||
}
|
||||
@@ -26,14 +25,12 @@ tests/cases/conformance/es6/templates/taggedTemplatesWithTypeArguments2.ts(36,34
|
||||
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.
|
||||
|
||||
const c = new tag<number> `${100} ${200}`<string>("hello", "world");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2347: Untyped function calls may not accept type arguments.
|
||||
|
||||
const d = new tag<number> `${"hello"} ${"world"}`<string>(100, 200);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2347: Untyped function calls may not accept type arguments.
|
||||
~~~~~~~
|
||||
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.
|
||||
~~~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
|
||||
|
||||
/**
|
||||
* Testing ASI. This should never parse as
|
||||
|
||||
@@ -41,8 +41,8 @@ class SomeDerived<T> extends SomeBase<number, string, T> {
|
||||
//// [taggedTemplatesWithTypeArguments2.js]
|
||||
const a = new tag `${100} ${200}`("hello", "world");
|
||||
const b = new tag `${"hello"} ${"world"}`(100, 200);
|
||||
const c = (new tag `${100} ${200}`)("hello", "world");
|
||||
const d = (new tag `${"hello"} ${"world"}`)(100, 200);
|
||||
const c = new tag `${100} ${200}`("hello", "world");
|
||||
const d = new tag `${"hello"} ${"world"}`(100, 200);
|
||||
/**
|
||||
* Testing ASI. This should never parse as
|
||||
*
|
||||
|
||||
@@ -38,7 +38,6 @@ const b = new tag<number> `${"hello"} ${"world"}`(100, 200);
|
||||
const c = new tag<number> `${100} ${200}`<string>("hello", "world");
|
||||
>c : any
|
||||
>new tag<number> `${100} ${200}`<string>("hello", "world") : any
|
||||
>new tag<number> `${100} ${200}` : any
|
||||
>tag<number> `${100} ${200}` : SomethingNewable
|
||||
>tag : SomethingTaggable
|
||||
>`${100} ${200}` : string
|
||||
@@ -50,7 +49,6 @@ const c = new tag<number> `${100} ${200}`<string>("hello", "world");
|
||||
const d = new tag<number> `${"hello"} ${"world"}`<string>(100, 200);
|
||||
>d : any
|
||||
>new tag<number> `${"hello"} ${"world"}`<string>(100, 200) : any
|
||||
>new tag<number> `${"hello"} ${"world"}` : any
|
||||
>tag<number> `${"hello"} ${"world"}` : SomethingNewable
|
||||
>tag : SomethingTaggable
|
||||
>`${"hello"} ${"world"}` : string
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
function f<T>() { }
|
||||
var r = f<number>; // parse error
|
||||
|
||||
class C<T> {
|
||||
foo: T;
|
||||
}
|
||||
var c = new C<number>; // parse error
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
class B { }
|
||||
var b = new B; // no error
|
||||
|
||||
class C<T> {
|
||||
x: T;
|
||||
}
|
||||
|
||||
var c = new C // C<any>
|
||||
var c2 = new C<number> // error, type params are actually part of the arg list so you need both
|
||||
@@ -3,6 +3,6 @@ class SS<T>{
|
||||
}
|
||||
|
||||
var x1 = new SS<number>(); // OK
|
||||
var x2 = new SS < number>; // Correctly give error
|
||||
var x2 = new SS<number>; // OK
|
||||
var x3 = new SS(); // OK
|
||||
var x4 = new SS; // Should be allowed, but currently give error ('supplied parameters do not match any signature of the call target')
|
||||
var x4 = new SS; // OK
|
||||
|
||||
@@ -29,7 +29,7 @@ var b = new C0 32, ''; // Parse error
|
||||
// Generic construct expression with no parentheses
|
||||
var c1 = new T;
|
||||
var c1: T<{}>;
|
||||
var c2 = new T<string>; // Parse error
|
||||
var c2 = new T<string>; // Ok
|
||||
|
||||
|
||||
// Construct expression of non-void returning function
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
// @strict: true
|
||||
// @declaration: true
|
||||
|
||||
declare let f: { <T>(): T, g<U>(): U };
|
||||
|
||||
// Type arguments in member expressions
|
||||
|
||||
const a1 = f<number>; // { (): number; g<U>(): U; }
|
||||
const a2 = f.g<number>; // () => number
|
||||
const a3 = f<number>.g; // <U>() => U
|
||||
const a4 = f<number>.g<number>; // () => number
|
||||
const a5 = f['g']<number>; // () => number
|
||||
|
||||
// `[` is an expression starter and cannot immediately follow a type argument list
|
||||
|
||||
const a6 = f<number>['g']; // Error
|
||||
const a7 = (f<number>)['g'];
|
||||
|
||||
// An `<` cannot immediately follow a type argument list
|
||||
|
||||
const a8 = f<number><number>; // Relational operator error
|
||||
const a9 = (f<number>)<number>; // Error, no applicable signatures
|
||||
|
||||
// Type arguments with `?.` token
|
||||
|
||||
const b1 = f?.<number>; // Error, `(` expected
|
||||
const b2 = f?.<number>();
|
||||
const b3 = f<number>?.();
|
||||
const b4 = f<number>?.<number>(); // Error, expected no type arguments
|
||||
|
||||
// Parsed as function call, even though this differs from JavaScript
|
||||
|
||||
const x1 = f<true>
|
||||
(true);
|
||||
|
||||
// Parsed as relational expression
|
||||
|
||||
const x2 = f<true>
|
||||
true;
|
||||
|
||||
// Parsed as instantiation expression
|
||||
|
||||
const x3 = f<true>;
|
||||
true;
|
||||
+175
@@ -0,0 +1,175 @@
|
||||
// @strict: true
|
||||
// @declaration: true
|
||||
|
||||
declare function fx<T>(x: T): T;
|
||||
declare function fx<T>(x: T, n: number): T;
|
||||
declare function fx<T, U>(t: [T, U]): [T, U];
|
||||
|
||||
function f1() {
|
||||
let f0 = fx<>; // Error
|
||||
let f1 = fx<string>; // { (x: string): string; (x: string, n: number): string; }
|
||||
let f2 = fx<string, number>; // (t: [string, number]) => [string, number]
|
||||
let f3 = fx<string, number, boolean>; // Error
|
||||
}
|
||||
|
||||
type T10 = typeof fx<>; // Error
|
||||
type T11 = typeof fx<string>; // { (x: string): string; (x: string, n: number): string; }
|
||||
type T12 = typeof fx<string, number>; // (t: [string, number]) => [string, number]
|
||||
type T13 = typeof fx<string, number, boolean>; // Error
|
||||
|
||||
function f2() {
|
||||
const A0 = Array<>; // Error
|
||||
const A1 = Array<string>; // new (...) => string[]
|
||||
const A2 = Array<string, number>; // Error
|
||||
}
|
||||
|
||||
type T20 = typeof Array<>; // Error
|
||||
type T21 = typeof Array<string>; // new (...) => string[]
|
||||
type T22 = typeof Array<string, number>; // Error
|
||||
|
||||
declare class C<T> {
|
||||
constructor(x: T);
|
||||
static f<U>(x: U): U[];
|
||||
}
|
||||
|
||||
function f3() {
|
||||
let c1 = C<string>; // { new (x: string): C<string>; f<U>(x: U): T[]; prototype: C<any>; }
|
||||
let f1 = C.f<string>; // (x: string) => string[]
|
||||
}
|
||||
|
||||
function f10(f: { <T>(a: T): T, <U>(a: U, b: number): U[] }) {
|
||||
let fs = f<string>; // { (a: string): string; (a: string, b: number): string[]; }
|
||||
}
|
||||
|
||||
function f11(f: { <T>(a: T): T, (a: string, b: number): string[] }) {
|
||||
let fs = f<string>; // (a: string) => string
|
||||
}
|
||||
|
||||
function f12(f: { <T>(a: T): T, x: string }) {
|
||||
let fs = f<string>; // { (a: string): string; x: string; }
|
||||
}
|
||||
|
||||
function f13(f: { x: string, y: string }) {
|
||||
let fs = f<string>; // Error, no applicable signatures
|
||||
}
|
||||
|
||||
function f14(f: { new <T>(a: T): T, new <U>(a: U, b: number): U[] }) {
|
||||
let fs = f<string>; // { new (a: string): string; new (a: string, b: number): string[]; }
|
||||
}
|
||||
|
||||
function f15(f: { new <T>(a: T): T, <U>(a: U, b: number): U[] }) {
|
||||
let fs = f<string>; // { new (a: string): string; (a: string, b: number): string[]; }
|
||||
}
|
||||
|
||||
function f16(f: { new <T>(a: T): T, (a: string, b: number): string[] }) {
|
||||
let fs = f<string>; // new (a: string) => string
|
||||
}
|
||||
|
||||
function f17(f: { <T>(a: T): T, new (a: string, b: number): string[] }) {
|
||||
let fs = f<string>; // (a: string) => string
|
||||
}
|
||||
|
||||
function f20(f: (<T>(a: T) => T) & (<U>(a: U, b: number) => U[])) {
|
||||
let fs = f<string>; // ((a: string) => string) & ((a: string, b: number) => string[]])
|
||||
}
|
||||
|
||||
function f21(f: (<T>(a: T) => T) & ((a: string, b: number) => string[])) {
|
||||
let fs = f<string>; // (a: string) => string
|
||||
}
|
||||
|
||||
function f22(f: (<T>(a: T) => T) & { x: string }) {
|
||||
let fs = f<string>; // ((a: string) => string) & { x: string }
|
||||
}
|
||||
|
||||
function f23(f: { x: string } & { y: string }) {
|
||||
let fs = f<string>; // Error, no applicable signatures
|
||||
}
|
||||
|
||||
function f24(f: (new <T>(a: T) => T) & (new <U>(a: U, b: number) => U[])) {
|
||||
let fs = f<string>; // (new (a: string) => string) & ((a: string, b: number) => string[]])
|
||||
}
|
||||
|
||||
function f25(f: (new <T>(a: T) => T) & (<U>(a: U, b: number) => U[])) {
|
||||
let fs = f<string>; // (new (a: string) => string) & ((a: string, b: number) => string[]])
|
||||
}
|
||||
|
||||
function f26(f: (new <T>(a: T) => T) & ((a: string, b: number) => string[])) {
|
||||
let fs = f<string>; // new (a: string) => string
|
||||
}
|
||||
|
||||
function f27(f: (<T>(a: T) => T) & (new (a: string, b: number) => string[])) {
|
||||
let fs = f<string>; // (a: string) => string
|
||||
}
|
||||
|
||||
function f30(f: (<T>(a: T) => T) | (<U>(a: U, b: number) => U[])) {
|
||||
let fs = f<string>; // ((a: string) => string) | ((a: string, b: number) => string[]])
|
||||
}
|
||||
|
||||
function f31(f: (<T>(a: T) => T) | ((a: string, b: number) => string[])) {
|
||||
let fs = f<string>; // Error, '(a: string, b: number) => string[]' has no applicable signatures
|
||||
}
|
||||
|
||||
function f32(f: (<T>(a: T) => T) | { x: string }) {
|
||||
let fs = f<string>; // ((a: string) => string) | { x: string }
|
||||
}
|
||||
|
||||
function f33(f: { x: string } | { y: string }) {
|
||||
let fs = f<string>; // Error, no applicable signatures
|
||||
}
|
||||
|
||||
function f34(f: (new <T>(a: T) => T) | (new <U>(a: U, b: number) => U[])) {
|
||||
let fs = f<string>; // (new (a: string) => string) | ((a: string, b: number) => string[]])
|
||||
}
|
||||
|
||||
function f35(f: (new <T>(a: T) => T) | (<U>(a: U, b: number) => U[])) {
|
||||
let fs = f<string>; // (new (a: string) => string) | ((a: string, b: number) => string[]])
|
||||
}
|
||||
|
||||
function f36(f: (new <T>(a: T) => T) | ((a: string, b: number) => string[])) {
|
||||
let fs = f<string>; // Error, '(a: string, b: number) => string[]' has no applicable signatures
|
||||
}
|
||||
|
||||
function f37(f: (<T>(a: T) => T) | (new (a: string, b: number) => string[])) {
|
||||
let fs = f<string>; // Error, 'new (a: string, b: number) => string[]' has no applicable signatures
|
||||
}
|
||||
|
||||
function f38<T extends (<A>(x: A) => A) | (<B>(x: B) => B[]), U>(f: T | U | (<C>(x: C) => C[][])) {
|
||||
let fs = f<string>; // U | ((x: string) => string) | ((x: string) => string[]) | ((x: string) => string[][])
|
||||
}
|
||||
|
||||
function makeBox<T>(value: T) {
|
||||
return { value };
|
||||
}
|
||||
|
||||
type BoxFunc<T> = typeof makeBox<T>; // (value: T) => { value: T }
|
||||
type StringBoxFunc = BoxFunc<string>; // (value: string) => { value: string }
|
||||
|
||||
type Box<T> = ReturnType<typeof makeBox<T>>; // { value: T }
|
||||
type StringBox = Box<string>; // { value: string }
|
||||
|
||||
type A<U> = InstanceType<typeof Array<U>>; // U[]
|
||||
|
||||
declare const g1: {
|
||||
<T>(a: T): { a: T };
|
||||
new <U>(b: U): { b: U };
|
||||
}
|
||||
|
||||
type T30<V> = typeof g1<V>; // { (a: V) => { a: V }; new (b: V) => { b: V }; }
|
||||
type T31<A> = ReturnType<T30<A>>; // { a: A }
|
||||
type T32<B> = InstanceType<T30<B>>; // { b: B }
|
||||
|
||||
declare const g2: {
|
||||
<T extends string>(a: T): T;
|
||||
new <T extends number>(b: T): T;
|
||||
}
|
||||
|
||||
type T40<U extends string> = typeof g2<U>; // Error
|
||||
type T41<U extends number> = typeof g2<U>; // Error
|
||||
|
||||
declare const g3: {
|
||||
<T extends string>(a: T): T;
|
||||
new <T extends number, Q>(b: T): T;
|
||||
}
|
||||
|
||||
type T50<U extends string> = typeof g3<U>; // (a: U) => U
|
||||
type T51<U extends number> = typeof g3<U, any>; // (b: U) => U
|
||||
@@ -1,8 +0,0 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface T1 extends T<number,
|
||||
//// string
|
||||
//// /**/>
|
||||
|
||||
goTo.marker();
|
||||
verify.indentationIs(32);
|
||||
Reference in New Issue
Block a user