mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Optional variance annotations (#48240)
* Simplify getVariancesWorker and associated logic * Accept new API baselines * Add 'in' and 'out' modififers / add modifiers to type parameters * Check variance annotations * Update test runner * Accept new API baselines * Allow variance annotations only on certain type parameters * Add deprecated implementation of createTypeParameterDeclaration * Accept new API baselines * Report variance markers as 'sub-XXX' and 'super-XXX' * Add tests * Accept new baselines
This commit is contained in:
+112
-61
@@ -347,6 +347,7 @@ namespace ts {
|
||||
let instantiationDepth = 0;
|
||||
let inlineLevel = 0;
|
||||
let currentNode: Node | undefined;
|
||||
let varianceTypeParameter: TypeParameter | undefined;
|
||||
|
||||
const emptySymbols = createSymbolTable();
|
||||
const arrayVariances = [VarianceFlags.Covariant];
|
||||
@@ -761,6 +762,7 @@ namespace ts {
|
||||
const subtypeReductionCache = new Map<string, Type[]>();
|
||||
const evolvingArrayTypes: EvolvingArrayType[] = [];
|
||||
const undefinedProperties: SymbolTable = new Map();
|
||||
const markerTypes = new Set<number>();
|
||||
|
||||
const unknownSymbol = createSymbol(SymbolFlags.Property, "unknown" as __String);
|
||||
const resolvingSymbol = createSymbol(0, InternalSymbolName.Resolving);
|
||||
@@ -4985,9 +4987,12 @@ namespace ts {
|
||||
return factory.createTypeReferenceNode(factory.createIdentifier(idText(name)), /*typeArguments*/ undefined);
|
||||
}
|
||||
// Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter.
|
||||
return type.symbol
|
||||
? symbolToTypeNode(type.symbol, context, SymbolFlags.Type)
|
||||
: factory.createTypeReferenceNode(factory.createIdentifier("?"), /*typeArguments*/ undefined);
|
||||
if (type.symbol) {
|
||||
return symbolToTypeNode(type.symbol, context, SymbolFlags.Type);
|
||||
}
|
||||
const name = (type === markerSuperType || type === markerSubType) && varianceTypeParameter && varianceTypeParameter.symbol ?
|
||||
(type === markerSubType ? "sub-" : "super-") + symbolName(varianceTypeParameter.symbol) : "?";
|
||||
return factory.createTypeReferenceNode(factory.createIdentifier(name), /*typeArguments*/ undefined);
|
||||
}
|
||||
if (type.flags & TypeFlags.Union && (type as UnionType).origin) {
|
||||
type = (type as UnionType).origin!;
|
||||
@@ -5107,7 +5112,7 @@ namespace ts {
|
||||
// type stays homomorphic
|
||||
return factory.createConditionalTypeNode(
|
||||
typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context),
|
||||
factory.createInferTypeNode(factory.createTypeParameterDeclaration(factory.cloneNode(newTypeVariable!.typeName) as Identifier)),
|
||||
factory.createInferTypeNode(factory.createTypeParameterDeclaration(/*modifiers*/ undefined, factory.cloneNode(newTypeVariable!.typeName) as Identifier)),
|
||||
result,
|
||||
factory.createKeywordTypeNode(SyntaxKind.NeverKeyword)
|
||||
);
|
||||
@@ -5795,11 +5800,12 @@ namespace ts {
|
||||
function typeParameterToDeclarationWithConstraint(type: TypeParameter, context: NodeBuilderContext, constraintNode: TypeNode | undefined): TypeParameterDeclaration {
|
||||
const savedContextFlags = context.flags;
|
||||
context.flags &= ~NodeBuilderFlags.WriteTypeParametersInQualifiedName; // Avoids potential infinite loop when building for a claimspace with a generic
|
||||
const modifiers = factory.createModifiersFromModifierFlags(getVarianceModifiers(type));
|
||||
const name = typeParameterToName(type, context);
|
||||
const defaultParameter = getDefaultFromTypeParameter(type);
|
||||
const defaultParameterNode = defaultParameter && typeToTypeNodeHelper(defaultParameter, context);
|
||||
context.flags = savedContextFlags;
|
||||
return factory.createTypeParameterDeclaration(name, constraintNode, defaultParameterNode);
|
||||
return factory.createTypeParameterDeclaration(modifiers, name, constraintNode, defaultParameterNode);
|
||||
}
|
||||
|
||||
function typeParameterToDeclaration(type: TypeParameter, context: NodeBuilderContext, constraint = getConstraintOfTypeParameter(type)): TypeParameterDeclaration {
|
||||
@@ -18404,7 +18410,7 @@ namespace ts {
|
||||
generalizedSourceType = getTypeNameForErrorDisplay(generalizedSource);
|
||||
}
|
||||
|
||||
if (target.flags & TypeFlags.TypeParameter) {
|
||||
if (target.flags & TypeFlags.TypeParameter && target !== markerSuperType && target !== markerSubType) {
|
||||
const constraint = getBaseConstraintOfType(target);
|
||||
let needsOriginalSource;
|
||||
if (constraint && (isTypeAssignableTo(generalizedSource, constraint) || (needsOriginalSource = isTypeAssignableTo(source, constraint)))) {
|
||||
@@ -19227,9 +19233,8 @@ namespace ts {
|
||||
// We limit alias variance probing to only object and conditional types since their alias behavior
|
||||
// is more predictable than other, interned types, which may or may not have an alias depending on
|
||||
// the order in which things were checked.
|
||||
if (sourceFlags & (TypeFlags.Object | TypeFlags.Conditional) && source.aliasSymbol &&
|
||||
source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol &&
|
||||
!(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) {
|
||||
if (sourceFlags & (TypeFlags.Object | TypeFlags.Conditional) && source.aliasSymbol && source.aliasTypeArguments &&
|
||||
source.aliasSymbol === target.aliasSymbol && !(isMarkerType(source) || isMarkerType(target))) {
|
||||
const variances = getAliasVariances(source.aliasSymbol);
|
||||
if (variances === emptyArray) {
|
||||
return Ternary.Unknown;
|
||||
@@ -19608,7 +19613,7 @@ namespace ts {
|
||||
return Ternary.False;
|
||||
}
|
||||
if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (source as TypeReference).target === (target as TypeReference).target &&
|
||||
!isTupleType(source) && !(getObjectFlags(source) & ObjectFlags.MarkerType || getObjectFlags(target) & ObjectFlags.MarkerType)) {
|
||||
!isTupleType(source) && !(isMarkerType(source) || isMarkerType(target))) {
|
||||
// When strictNullChecks is disabled, the element type of the empty array literal is undefinedWideningType,
|
||||
// and an empty array literal wouldn't be assignable to a `never[]` without this check.
|
||||
if (isEmptyArrayLiteralType(source)) {
|
||||
@@ -20559,21 +20564,15 @@ namespace ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return a type reference where the source type parameter is replaced with the target marker
|
||||
// type, and flag the result as a marker type reference.
|
||||
function getMarkerTypeReference(type: GenericType, source: TypeParameter, target: Type) {
|
||||
const result = createTypeReference(type, map(type.typeParameters, t => t === source ? target : t));
|
||||
result.objectFlags |= ObjectFlags.MarkerType;
|
||||
return result;
|
||||
function getVariances(type: GenericType): VarianceFlags[] {
|
||||
// Arrays and tuples are known to be covariant, no need to spend time computing this.
|
||||
return type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & ObjectFlags.Tuple ?
|
||||
arrayVariances :
|
||||
getVariancesWorker(type.symbol, type.typeParameters);
|
||||
}
|
||||
|
||||
function getAliasVariances(symbol: Symbol) {
|
||||
const links = getSymbolLinks(symbol);
|
||||
return getVariancesWorker(links.typeParameters, links, (_links, param, marker) => {
|
||||
const type = getTypeAliasInstantiation(symbol, instantiateTypes(links.typeParameters!, makeUnaryTypeMapper(param, marker)));
|
||||
type.aliasTypeArgumentsContainsMarker = true;
|
||||
return type;
|
||||
});
|
||||
return getVariancesWorker(symbol, getSymbolLinks(symbol).typeParameters);
|
||||
}
|
||||
|
||||
// Return an array containing the variance of each type parameter. The variance is effectively
|
||||
@@ -20581,55 +20580,71 @@ namespace ts {
|
||||
// generic type are structurally compared. We infer the variance information by comparing
|
||||
// instantiations of the generic type for type arguments with known relations. The function
|
||||
// returns the emptyArray singleton when invoked recursively for the given generic type.
|
||||
function getVariancesWorker<TCache extends { variances?: VarianceFlags[] }>(typeParameters: readonly TypeParameter[] = emptyArray, cache: TCache, createMarkerType: (input: TCache, param: TypeParameter, marker: Type) => Type): VarianceFlags[] {
|
||||
let variances = cache.variances;
|
||||
if (!variances) {
|
||||
tracing?.push(tracing.Phase.CheckTypes, "getVariancesWorker", { arity: typeParameters.length, id: (cache as any).id ?? (cache as any).declaredType?.id ?? -1 });
|
||||
// The emptyArray singleton is used to signal a recursive invocation.
|
||||
cache.variances = emptyArray;
|
||||
variances = [];
|
||||
function getVariancesWorker(symbol: Symbol, typeParameters: readonly TypeParameter[] = emptyArray): VarianceFlags[] {
|
||||
const links = getSymbolLinks(symbol);
|
||||
if (!links.variances) {
|
||||
tracing?.push(tracing.Phase.CheckTypes, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
|
||||
links.variances = emptyArray;
|
||||
const variances = [];
|
||||
for (const tp of typeParameters) {
|
||||
let unmeasurable = false;
|
||||
let unreliable = false;
|
||||
const oldHandler = outofbandVarianceMarkerHandler;
|
||||
outofbandVarianceMarkerHandler = (onlyUnreliable) => onlyUnreliable ? unreliable = true : unmeasurable = true;
|
||||
// We first compare instantiations where the type parameter is replaced with
|
||||
// marker types that have a known subtype relationship. From this we can infer
|
||||
// invariance, covariance, contravariance or bivariance.
|
||||
const typeWithSuper = createMarkerType(cache, tp, markerSuperType);
|
||||
const typeWithSub = createMarkerType(cache, tp, markerSubType);
|
||||
let variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? VarianceFlags.Covariant : 0) |
|
||||
(isTypeAssignableTo(typeWithSuper, typeWithSub) ? VarianceFlags.Contravariant : 0);
|
||||
// If the instantiations appear to be related bivariantly it may be because the
|
||||
// type parameter is independent (i.e. it isn't witnessed anywhere in the generic
|
||||
// type). To determine this we compare instantiations where the type parameter is
|
||||
// replaced with marker types that are known to be unrelated.
|
||||
if (variance === VarianceFlags.Bivariant && isTypeAssignableTo(createMarkerType(cache, tp, markerOtherType), typeWithSuper)) {
|
||||
variance = VarianceFlags.Independent;
|
||||
}
|
||||
outofbandVarianceMarkerHandler = oldHandler;
|
||||
if (unmeasurable || unreliable) {
|
||||
if (unmeasurable) {
|
||||
variance |= VarianceFlags.Unmeasurable;
|
||||
const modifiers = getVarianceModifiers(tp);
|
||||
let variance = modifiers & ModifierFlags.Out ?
|
||||
modifiers & ModifierFlags.In ? VarianceFlags.Invariant : VarianceFlags.Covariant :
|
||||
modifiers & ModifierFlags.In ? VarianceFlags.Contravariant : undefined;
|
||||
if (variance === undefined) {
|
||||
let unmeasurable = false;
|
||||
let unreliable = false;
|
||||
const oldHandler = outofbandVarianceMarkerHandler;
|
||||
outofbandVarianceMarkerHandler = (onlyUnreliable) => onlyUnreliable ? unreliable = true : unmeasurable = true;
|
||||
// We first compare instantiations where the type parameter is replaced with
|
||||
// marker types that have a known subtype relationship. From this we can infer
|
||||
// invariance, covariance, contravariance or bivariance.
|
||||
const typeWithSuper = createMarkerType(symbol, tp, markerSuperType);
|
||||
const typeWithSub = createMarkerType(symbol, tp, markerSubType);
|
||||
variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? VarianceFlags.Covariant : 0) |
|
||||
(isTypeAssignableTo(typeWithSuper, typeWithSub) ? VarianceFlags.Contravariant : 0);
|
||||
// If the instantiations appear to be related bivariantly it may be because the
|
||||
// type parameter is independent (i.e. it isn't witnessed anywhere in the generic
|
||||
// type). To determine this we compare instantiations where the type parameter is
|
||||
// replaced with marker types that are known to be unrelated.
|
||||
if (variance === VarianceFlags.Bivariant && isTypeAssignableTo(createMarkerType(symbol, tp, markerOtherType), typeWithSuper)) {
|
||||
variance = VarianceFlags.Independent;
|
||||
}
|
||||
if (unreliable) {
|
||||
variance |= VarianceFlags.Unreliable;
|
||||
outofbandVarianceMarkerHandler = oldHandler;
|
||||
if (unmeasurable || unreliable) {
|
||||
if (unmeasurable) {
|
||||
variance |= VarianceFlags.Unmeasurable;
|
||||
}
|
||||
if (unreliable) {
|
||||
variance |= VarianceFlags.Unreliable;
|
||||
}
|
||||
}
|
||||
}
|
||||
variances.push(variance);
|
||||
}
|
||||
cache.variances = variances;
|
||||
links.variances = variances;
|
||||
tracing?.pop();
|
||||
}
|
||||
return variances;
|
||||
return links.variances;
|
||||
}
|
||||
|
||||
function getVariances(type: GenericType): VarianceFlags[] {
|
||||
// Arrays and tuples are known to be covariant, no need to spend time computing this.
|
||||
if (type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & ObjectFlags.Tuple) {
|
||||
return arrayVariances;
|
||||
}
|
||||
return getVariancesWorker(type.typeParameters, type, getMarkerTypeReference);
|
||||
function createMarkerType(symbol: Symbol, source: TypeParameter, target: Type) {
|
||||
const mapper = makeUnaryTypeMapper(source, target);
|
||||
const type = getDeclaredTypeOfSymbol(symbol);
|
||||
const result = symbol.flags & SymbolFlags.TypeAlias ?
|
||||
getTypeAliasInstantiation(symbol, instantiateTypes(getSymbolLinks(symbol).typeParameters!, mapper)) :
|
||||
createTypeReference(type as GenericType, instantiateTypes((type as GenericType).typeParameters, mapper));
|
||||
markerTypes.add(getTypeId(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
function isMarkerType(type: Type) {
|
||||
return markerTypes.has(getTypeId(type));
|
||||
}
|
||||
|
||||
function getVarianceModifiers(tp: TypeParameter): ModifierFlags {
|
||||
return (some(tp.symbol?.declarations, d => hasSyntacticModifier(d, ModifierFlags.In)) ? ModifierFlags.In : 0) |
|
||||
(some(tp.symbol?.declarations, d => hasSyntacticModifier(d, ModifierFlags.Out)) ? ModifierFlags.Out: 0);
|
||||
}
|
||||
|
||||
// Return true if the given type reference has a 'void' type argument for a covariant type parameter.
|
||||
@@ -34670,6 +34685,7 @@ namespace ts {
|
||||
|
||||
function checkTypeParameter(node: TypeParameterDeclaration) {
|
||||
// Grammar Checking
|
||||
checkGrammarModifiers(node);
|
||||
if (node.expression) {
|
||||
grammarErrorOnFirstToken(node.expression, Diagnostics.Type_expected);
|
||||
}
|
||||
@@ -34687,6 +34703,18 @@ namespace ts {
|
||||
if (constraintType && defaultType) {
|
||||
checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
|
||||
}
|
||||
if (node.parent.kind === SyntaxKind.InterfaceDeclaration || node.parent.kind === SyntaxKind.ClassDeclaration || node.parent.kind === SyntaxKind.TypeAliasDeclaration) {
|
||||
const modifiers = getVarianceModifiers(typeParameter);
|
||||
if (modifiers === ModifierFlags.In || modifiers === ModifierFlags.Out) {
|
||||
const symbol = getSymbolOfNode(node.parent);
|
||||
const source = createMarkerType(symbol, typeParameter, modifiers === ModifierFlags.Out ? markerSubType : markerSuperType);
|
||||
const target = createMarkerType(symbol, typeParameter, modifiers === ModifierFlags.Out ? markerSuperType : markerSubType);
|
||||
const saveVarianceTypeParameter = typeParameter;
|
||||
varianceTypeParameter = typeParameter;
|
||||
checkTypeAssignableTo(source, target, node, Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation);
|
||||
varianceTypeParameter = saveVarianceTypeParameter;
|
||||
}
|
||||
}
|
||||
if (produceDiagnostics) {
|
||||
checkTypeNameIsReserved(node.name, Diagnostics.Type_parameter_name_cannot_be_0);
|
||||
}
|
||||
@@ -43098,6 +43126,11 @@ namespace ts {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_an_index_signature, tokenToString(modifier.kind));
|
||||
}
|
||||
}
|
||||
if (modifier.kind !== SyntaxKind.InKeyword && modifier.kind !== SyntaxKind.OutKeyword) {
|
||||
if (node.kind === SyntaxKind.TypeParameter) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_type_parameter, tokenToString(modifier.kind));
|
||||
}
|
||||
}
|
||||
switch (modifier.kind) {
|
||||
case SyntaxKind.ConstKeyword:
|
||||
if (node.kind !== SyntaxKind.EnumDeclaration) {
|
||||
@@ -43305,6 +43338,23 @@ namespace ts {
|
||||
flags |= ModifierFlags.Async;
|
||||
lastAsync = modifier;
|
||||
break;
|
||||
|
||||
case SyntaxKind.InKeyword:
|
||||
case SyntaxKind.OutKeyword:
|
||||
const inOutFlag = modifier.kind === SyntaxKind.InKeyword ? ModifierFlags.In : ModifierFlags.Out;
|
||||
const inOutText = modifier.kind === SyntaxKind.InKeyword ? "in" : "out";
|
||||
if (node.kind !== SyntaxKind.TypeParameter || (node.parent.kind !== SyntaxKind.InterfaceDeclaration &&
|
||||
node.parent.kind !== SyntaxKind.ClassDeclaration && node.parent.kind !== SyntaxKind.TypeAliasDeclaration)) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText);
|
||||
}
|
||||
if (flags & inOutFlag) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, inOutText);
|
||||
}
|
||||
if (inOutFlag & ModifierFlags.In && flags & ModifierFlags.Out) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "in", "out");
|
||||
}
|
||||
flags |= inOutFlag;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43364,6 +43414,7 @@ namespace ts {
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.Parameter:
|
||||
case SyntaxKind.TypeParameter:
|
||||
return false;
|
||||
default:
|
||||
if (node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) {
|
||||
|
||||
@@ -883,6 +883,14 @@
|
||||
"category": "Error",
|
||||
"code": 1272
|
||||
},
|
||||
"'{0}' modifier cannot appear on a type parameter": {
|
||||
"category": "Error",
|
||||
"code": 1273
|
||||
},
|
||||
"'{0}' modifier can only appear on a type parameter of a class, interface or type alias": {
|
||||
"category": "Error",
|
||||
"code": 1274
|
||||
},
|
||||
|
||||
"'with' statements are not allowed in an async function block.": {
|
||||
"category": "Error",
|
||||
@@ -2727,6 +2735,10 @@
|
||||
"category": "Error",
|
||||
"code": 2635
|
||||
},
|
||||
"Type '{0}' is not assignable to type '{1}' as implied by variance annotation.": {
|
||||
"category": "Error",
|
||||
"code": 2636
|
||||
},
|
||||
|
||||
"Cannot augment module '{0}' with value exports because it resolves to a non-module entity.": {
|
||||
"category": "Error",
|
||||
|
||||
@@ -2009,6 +2009,7 @@ namespace ts {
|
||||
//
|
||||
|
||||
function emitTypeParameter(node: TypeParameterDeclaration) {
|
||||
emitModifiers(node, node.modifiers);
|
||||
emit(node.name);
|
||||
if (node.constraint) {
|
||||
writeSpace();
|
||||
|
||||
@@ -998,6 +998,8 @@ namespace ts {
|
||||
case SyntaxKind.BigIntKeyword:
|
||||
case SyntaxKind.NeverKeyword:
|
||||
case SyntaxKind.ObjectKeyword:
|
||||
case SyntaxKind.InKeyword:
|
||||
case SyntaxKind.OutKeyword:
|
||||
case SyntaxKind.OverrideKeyword:
|
||||
case SyntaxKind.StringKeyword:
|
||||
case SyntaxKind.BooleanKeyword:
|
||||
@@ -1077,6 +1079,8 @@ namespace ts {
|
||||
if (flags & ModifierFlags.Override) result.push(createModifier(SyntaxKind.OverrideKeyword));
|
||||
if (flags & ModifierFlags.Readonly) result.push(createModifier(SyntaxKind.ReadonlyKeyword));
|
||||
if (flags & ModifierFlags.Async) result.push(createModifier(SyntaxKind.AsyncKeyword));
|
||||
if (flags & ModifierFlags.In) result.push(createModifier(SyntaxKind.InKeyword));
|
||||
if (flags & ModifierFlags.Out) result.push(createModifier(SyntaxKind.OutKeyword));
|
||||
return result.length ? result : undefined;
|
||||
}
|
||||
|
||||
@@ -1126,11 +1130,27 @@ namespace ts {
|
||||
//
|
||||
|
||||
// @api
|
||||
function createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode) {
|
||||
function createTypeParameterDeclaration(modifiers: readonly Modifier[] | undefined, name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration;
|
||||
/** @deprecated */
|
||||
function createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration;
|
||||
function createTypeParameterDeclaration(modifiersOrName: readonly Modifier[] | string | Identifier | undefined , nameOrConstraint?: string | Identifier | TypeNode, constraintOrDefault?: TypeNode, defaultType?: TypeNode) {
|
||||
let name;
|
||||
let modifiers;
|
||||
let constraint;
|
||||
if (modifiersOrName === undefined || isArray(modifiersOrName)) {
|
||||
modifiers = modifiersOrName;
|
||||
name = nameOrConstraint as string | Identifier;
|
||||
constraint = constraintOrDefault;
|
||||
}
|
||||
else {
|
||||
modifiers = undefined;
|
||||
name = modifiersOrName;
|
||||
constraint = nameOrConstraint as TypeNode | undefined;
|
||||
}
|
||||
const node = createBaseNamedDeclaration<TypeParameterDeclaration>(
|
||||
SyntaxKind.TypeParameter,
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
modifiers,
|
||||
name
|
||||
);
|
||||
node.constraint = constraint;
|
||||
@@ -1140,11 +1160,28 @@ namespace ts {
|
||||
}
|
||||
|
||||
// @api
|
||||
function updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined) {
|
||||
return node.name !== name
|
||||
function updateTypeParameterDeclaration(node: TypeParameterDeclaration, modifiers: readonly Modifier[] | undefined, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration;
|
||||
/** @deprecated */
|
||||
function updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration;
|
||||
function updateTypeParameterDeclaration(node: TypeParameterDeclaration, modifiersOrName: readonly Modifier[] | Identifier | undefined, nameOrConstraint: Identifier | TypeNode | undefined, constraintOrDefault: TypeNode | undefined, defaultType?: TypeNode | undefined) {
|
||||
let name;
|
||||
let modifiers;
|
||||
let constraint;
|
||||
if (modifiersOrName === undefined || isArray(modifiersOrName)) {
|
||||
modifiers = modifiersOrName;
|
||||
name = nameOrConstraint as Identifier;
|
||||
constraint = constraintOrDefault;
|
||||
}
|
||||
else {
|
||||
modifiers = undefined;
|
||||
name = modifiersOrName;
|
||||
constraint = nameOrConstraint as TypeNode | undefined;
|
||||
}
|
||||
return node.modifiers !== modifiers
|
||||
|| node.name !== name
|
||||
|| node.constraint !== constraint
|
||||
|| node.default !== defaultType
|
||||
? update(createTypeParameterDeclaration(name, constraint, defaultType), node)
|
||||
? update(createTypeParameterDeclaration(modifiers, name, constraint, defaultType), node)
|
||||
: node;
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,8 @@ namespace ts {
|
||||
return visitNode(cbNode, (node as QualifiedName).left) ||
|
||||
visitNode(cbNode, (node as QualifiedName).right);
|
||||
case SyntaxKind.TypeParameter:
|
||||
return visitNode(cbNode, (node as TypeParameterDeclaration).name) ||
|
||||
return visitNodes(cbNode, cbNodes, node.modifiers) ||
|
||||
visitNode(cbNode, (node as TypeParameterDeclaration).name) ||
|
||||
visitNode(cbNode, (node as TypeParameterDeclaration).constraint) ||
|
||||
visitNode(cbNode, (node as TypeParameterDeclaration).default) ||
|
||||
visitNode(cbNode, (node as TypeParameterDeclaration).expression);
|
||||
@@ -2176,7 +2177,7 @@ namespace ts {
|
||||
case ParsingContext.ArrayBindingElements:
|
||||
return token() === SyntaxKind.CommaToken || token() === SyntaxKind.DotDotDotToken || isBindingIdentifierOrPrivateIdentifierOrPattern();
|
||||
case ParsingContext.TypeParameters:
|
||||
return isIdentifier();
|
||||
return token() === SyntaxKind.InKeyword || isIdentifier();
|
||||
case ParsingContext.ArrayLiteralMembers:
|
||||
switch (token()) {
|
||||
case SyntaxKind.CommaToken:
|
||||
@@ -3176,6 +3177,7 @@ namespace ts {
|
||||
|
||||
function parseTypeParameter(): TypeParameterDeclaration {
|
||||
const pos = getNodePos();
|
||||
const modifiers = parseModifiers();
|
||||
const name = parseIdentifier();
|
||||
let constraint: TypeNode | undefined;
|
||||
let expression: Expression | undefined;
|
||||
@@ -3200,7 +3202,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
const defaultType = parseOptional(SyntaxKind.EqualsToken) ? parseType() : undefined;
|
||||
const node = factory.createTypeParameterDeclaration(name, constraint, defaultType);
|
||||
const node = factory.createTypeParameterDeclaration(modifiers, name, constraint, defaultType);
|
||||
node.expression = expression;
|
||||
return finishNode(node, pos);
|
||||
}
|
||||
@@ -3605,7 +3607,7 @@ namespace ts {
|
||||
const name = parseIdentifierName();
|
||||
parseExpected(SyntaxKind.InKeyword);
|
||||
const type = parseType();
|
||||
return finishNode(factory.createTypeParameterDeclaration(name, type, /*defaultType*/ undefined), pos);
|
||||
return finishNode(factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, type, /*defaultType*/ undefined), pos);
|
||||
}
|
||||
|
||||
function parseMappedType() {
|
||||
@@ -3961,6 +3963,7 @@ namespace ts {
|
||||
const pos = getNodePos();
|
||||
return finishNode(
|
||||
factory.createTypeParameterDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
parseIdentifier(),
|
||||
/*constraint*/ undefined,
|
||||
/*defaultType*/ undefined
|
||||
@@ -8656,7 +8659,7 @@ namespace ts {
|
||||
if (nodeIsMissing(name)) {
|
||||
return undefined;
|
||||
}
|
||||
return finishNode(factory.createTypeParameterDeclaration(name, /*constraint*/ undefined, defaultType), typeParameterPos);
|
||||
return finishNode(factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, /*constraint*/ undefined, defaultType), typeParameterPos);
|
||||
}
|
||||
|
||||
function parseTemplateTagTypeParameters() {
|
||||
|
||||
@@ -2414,6 +2414,8 @@ namespace ts {
|
||||
case SyntaxKind.DeclareKeyword:
|
||||
case SyntaxKind.AbstractKeyword:
|
||||
case SyntaxKind.OverrideKeyword:
|
||||
case SyntaxKind.InKeyword:
|
||||
case SyntaxKind.OutKeyword:
|
||||
diagnostics.push(createDiagnosticForNode(modifier, Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, tokenToString(modifier.kind)));
|
||||
break;
|
||||
|
||||
|
||||
@@ -131,6 +131,7 @@ namespace ts {
|
||||
protected: SyntaxKind.ProtectedKeyword,
|
||||
public: SyntaxKind.PublicKeyword,
|
||||
override: SyntaxKind.OverrideKeyword,
|
||||
out: SyntaxKind.OutKeyword,
|
||||
readonly: SyntaxKind.ReadonlyKeyword,
|
||||
require: SyntaxKind.RequireKeyword,
|
||||
global: SyntaxKind.GlobalKeyword,
|
||||
|
||||
@@ -1029,7 +1029,7 @@ namespace ts {
|
||||
}
|
||||
case SyntaxKind.TypeParameter: {
|
||||
if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) {
|
||||
return cleanup(factory.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined));
|
||||
return cleanup(factory.updateTypeParameterDeclaration(input, input.modifiers, input.name, /*constraint*/ undefined, /*defaultType*/ undefined));
|
||||
}
|
||||
return cleanup(visitEachChild(input, visitDeclarationSubtree, context));
|
||||
}
|
||||
|
||||
@@ -373,6 +373,8 @@ namespace ts {
|
||||
case SyntaxKind.ConstKeyword:
|
||||
case SyntaxKind.DeclareKeyword:
|
||||
case SyntaxKind.ReadonlyKeyword:
|
||||
case SyntaxKind.InKeyword:
|
||||
case SyntaxKind.OutKeyword:
|
||||
// TypeScript accessibility and readonly modifiers are elided
|
||||
// falls through
|
||||
case SyntaxKind.ArrayType:
|
||||
|
||||
+37
-25
@@ -176,6 +176,7 @@ namespace ts {
|
||||
ModuleKeyword,
|
||||
NamespaceKeyword,
|
||||
NeverKeyword,
|
||||
OutKeyword,
|
||||
ReadonlyKeyword,
|
||||
RequireKeyword,
|
||||
NumberKeyword,
|
||||
@@ -602,6 +603,7 @@ namespace ts {
|
||||
| SyntaxKind.ProtectedKeyword
|
||||
| SyntaxKind.PublicKeyword
|
||||
| SyntaxKind.ReadonlyKeyword
|
||||
| SyntaxKind.OutKeyword
|
||||
| SyntaxKind.OverrideKeyword
|
||||
| SyntaxKind.RequireKeyword
|
||||
| SyntaxKind.ReturnKeyword
|
||||
@@ -634,10 +636,12 @@ namespace ts {
|
||||
| SyntaxKind.DeclareKeyword
|
||||
| SyntaxKind.DefaultKeyword
|
||||
| SyntaxKind.ExportKeyword
|
||||
| SyntaxKind.InKeyword
|
||||
| SyntaxKind.PrivateKeyword
|
||||
| SyntaxKind.ProtectedKeyword
|
||||
| SyntaxKind.PublicKeyword
|
||||
| SyntaxKind.ReadonlyKeyword
|
||||
| SyntaxKind.OutKeyword
|
||||
| SyntaxKind.OverrideKeyword
|
||||
| SyntaxKind.StaticKeyword
|
||||
;
|
||||
@@ -817,6 +821,8 @@ namespace ts {
|
||||
|
||||
Deprecated = 1 << 13, // Deprecated tag.
|
||||
Override = 1 << 14, // Override method.
|
||||
In = 1 << 15, // Contravariance modifier
|
||||
Out = 1 << 16, // Covariance modifier
|
||||
HasComputedFlags = 1 << 29, // Modifier flags have been computed
|
||||
|
||||
AccessibilityModifier = Public | Private | Protected,
|
||||
@@ -824,9 +830,9 @@ namespace ts {
|
||||
ParameterPropertyModifier = AccessibilityModifier | Readonly | Override,
|
||||
NonPublicAccessibilityModifier = Private | Protected,
|
||||
|
||||
TypeScriptModifier = Ambient | Public | Private | Protected | Readonly | Abstract | Const | Override,
|
||||
TypeScriptModifier = Ambient | Public | Private | Protected | Readonly | Abstract | Const | Override | In | Out,
|
||||
ExportDefault = Export | Default,
|
||||
All = Export | Ambient | Public | Private | Protected | Static | Readonly | Abstract | Async | Default | Const | Deprecated | Override
|
||||
All = Export | Ambient | Public | Private | Protected | Static | Readonly | Abstract | Async | Default | Const | Deprecated | Override | In | Out
|
||||
}
|
||||
|
||||
export const enum JsxFlags {
|
||||
@@ -1066,10 +1072,12 @@ namespace ts {
|
||||
export type DeclareKeyword = ModifierToken<SyntaxKind.DeclareKeyword>;
|
||||
export type DefaultKeyword = ModifierToken<SyntaxKind.DefaultKeyword>;
|
||||
export type ExportKeyword = ModifierToken<SyntaxKind.ExportKeyword>;
|
||||
export type InKeyword = ModifierToken<SyntaxKind.InKeyword>;
|
||||
export type PrivateKeyword = ModifierToken<SyntaxKind.PrivateKeyword>;
|
||||
export type ProtectedKeyword = ModifierToken<SyntaxKind.ProtectedKeyword>;
|
||||
export type PublicKeyword = ModifierToken<SyntaxKind.PublicKeyword>;
|
||||
export type ReadonlyKeyword = ModifierToken<SyntaxKind.ReadonlyKeyword>;
|
||||
export type OutKeyword = ModifierToken<SyntaxKind.OutKeyword>;
|
||||
export type OverrideKeyword = ModifierToken<SyntaxKind.OverrideKeyword>;
|
||||
export type StaticKeyword = ModifierToken<SyntaxKind.StaticKeyword>;
|
||||
|
||||
@@ -1083,9 +1091,11 @@ namespace ts {
|
||||
| DeclareKeyword
|
||||
| DefaultKeyword
|
||||
| ExportKeyword
|
||||
| InKeyword
|
||||
| PrivateKeyword
|
||||
| ProtectedKeyword
|
||||
| PublicKeyword
|
||||
| OutKeyword
|
||||
| OverrideKeyword
|
||||
| ReadonlyKeyword
|
||||
| StaticKeyword
|
||||
@@ -5244,7 +5254,6 @@ namespace ts {
|
||||
pattern?: DestructuringPattern; // Destructuring pattern represented by type (if any)
|
||||
aliasSymbol?: Symbol; // Alias associated with type
|
||||
aliasTypeArguments?: readonly Type[]; // Alias type arguments (if any)
|
||||
/* @internal */ aliasTypeArgumentsContainsMarker?: boolean; // Alias type arguments (if any)
|
||||
/* @internal */
|
||||
permissiveInstantiation?: Type; // Instantiation with type parameters mapped to wildcard type
|
||||
/* @internal */
|
||||
@@ -5325,22 +5334,21 @@ namespace ts {
|
||||
ObjectLiteralPatternWithComputedProperties = 1 << 9, // Object literal pattern with computed properties
|
||||
ReverseMapped = 1 << 10, // Object contains a property from a reverse-mapped type
|
||||
JsxAttributes = 1 << 11, // Jsx attributes type
|
||||
MarkerType = 1 << 12, // Marker type used for variance probing
|
||||
JSLiteral = 1 << 13, // Object type declared in JS - disables errors on read/write of nonexisting members
|
||||
FreshLiteral = 1 << 14, // Fresh object literal
|
||||
ArrayLiteral = 1 << 15, // Originates in an array literal
|
||||
JSLiteral = 1 << 12, // Object type declared in JS - disables errors on read/write of nonexisting members
|
||||
FreshLiteral = 1 << 13, // Fresh object literal
|
||||
ArrayLiteral = 1 << 14, // Originates in an array literal
|
||||
/* @internal */
|
||||
PrimitiveUnion = 1 << 16, // Union of only primitive types
|
||||
PrimitiveUnion = 1 << 15, // Union of only primitive types
|
||||
/* @internal */
|
||||
ContainsWideningType = 1 << 17, // Type is or contains undefined or null widening type
|
||||
ContainsWideningType = 1 << 16, // Type is or contains undefined or null widening type
|
||||
/* @internal */
|
||||
ContainsObjectOrArrayLiteral = 1 << 18, // Type is or contains object literal type
|
||||
ContainsObjectOrArrayLiteral = 1 << 17, // Type is or contains object literal type
|
||||
/* @internal */
|
||||
NonInferrableType = 1 << 19, // Type is or contains anyFunctionType or silentNeverType
|
||||
NonInferrableType = 1 << 18, // Type is or contains anyFunctionType or silentNeverType
|
||||
/* @internal */
|
||||
CouldContainTypeVariablesComputed = 1 << 20, // CouldContainTypeVariables flag has been computed
|
||||
CouldContainTypeVariablesComputed = 1 << 19, // CouldContainTypeVariables flag has been computed
|
||||
/* @internal */
|
||||
CouldContainTypeVariables = 1 << 21, // Type could contain a type variable
|
||||
CouldContainTypeVariables = 1 << 20, // Type could contain a type variable
|
||||
|
||||
ClassOrInterface = Class | Interface,
|
||||
/* @internal */
|
||||
@@ -5352,36 +5360,36 @@ namespace ts {
|
||||
ObjectTypeKindMask = ClassOrInterface | Reference | Tuple | Anonymous | Mapped | ReverseMapped | EvolvingArray,
|
||||
|
||||
// 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
|
||||
ContainsSpread = 1 << 21, // Object literal contains spread operation
|
||||
ObjectRestType = 1 << 22, // Originates in object rest declaration
|
||||
InstantiationExpressionType = 1 << 23, // Originates in instantiation expression
|
||||
/* @internal */
|
||||
IsClassInstanceClone = 1 << 25, // Type is a clone of a class instance type
|
||||
IsClassInstanceClone = 1 << 24, // Type is a clone of a class instance type
|
||||
// Flags that require TypeFlags.Object and ObjectFlags.Reference
|
||||
/* @internal */
|
||||
IdenticalBaseTypeCalculated = 1 << 26, // has had `getSingleBaseForNonAugmentingSubtype` invoked on it already
|
||||
IdenticalBaseTypeCalculated = 1 << 25, // has had `getSingleBaseForNonAugmentingSubtype` invoked on it already
|
||||
/* @internal */
|
||||
IdenticalBaseTypeExists = 1 << 27, // has a defined cachedEquivalentBaseType member
|
||||
IdenticalBaseTypeExists = 1 << 26, // has a defined cachedEquivalentBaseType member
|
||||
|
||||
// Flags that require TypeFlags.UnionOrIntersection or TypeFlags.Substitution
|
||||
/* @internal */
|
||||
IsGenericTypeComputed = 1 << 22, // IsGenericObjectType flag has been computed
|
||||
IsGenericTypeComputed = 1 << 21, // IsGenericObjectType flag has been computed
|
||||
/* @internal */
|
||||
IsGenericObjectType = 1 << 23, // Union or intersection contains generic object type
|
||||
IsGenericObjectType = 1 << 22, // Union or intersection contains generic object type
|
||||
/* @internal */
|
||||
IsGenericIndexType = 1 << 24, // Union or intersection contains generic index type
|
||||
IsGenericIndexType = 1 << 23, // Union or intersection contains generic index type
|
||||
/* @internal */
|
||||
IsGenericType = IsGenericObjectType | IsGenericIndexType,
|
||||
|
||||
// Flags that require TypeFlags.Union
|
||||
/* @internal */
|
||||
ContainsIntersections = 1 << 25, // Union contains intersections
|
||||
ContainsIntersections = 1 << 24, // Union contains intersections
|
||||
|
||||
// Flags that require TypeFlags.Intersection
|
||||
/* @internal */
|
||||
IsNeverIntersectionComputed = 1 << 25, // IsNeverLike flag has been computed
|
||||
IsNeverIntersectionComputed = 1 << 24, // IsNeverLike flag has been computed
|
||||
/* @internal */
|
||||
IsNeverIntersection = 1 << 26, // Intersection reduces to never
|
||||
IsNeverIntersection = 1 << 25, // Intersection reduces to never
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -7240,7 +7248,11 @@ namespace ts {
|
||||
// Signature elements
|
||||
//
|
||||
|
||||
createTypeParameterDeclaration(modifiers: readonly Modifier[] | undefined, name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration;
|
||||
/** @deprecated */
|
||||
createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration;
|
||||
updateTypeParameterDeclaration(node: TypeParameterDeclaration, modifiers: readonly Modifier[] | undefined, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration;
|
||||
/** @deprecated */
|
||||
updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration;
|
||||
createParameterDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration;
|
||||
updateParameterDeclaration(node: ParameterDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration;
|
||||
|
||||
@@ -5003,6 +5003,8 @@ namespace ts {
|
||||
case SyntaxKind.AsyncKeyword: return ModifierFlags.Async;
|
||||
case SyntaxKind.ReadonlyKeyword: return ModifierFlags.Readonly;
|
||||
case SyntaxKind.OverrideKeyword: return ModifierFlags.Override;
|
||||
case SyntaxKind.InKeyword: return ModifierFlags.In;
|
||||
case SyntaxKind.OutKeyword: return ModifierFlags.Out;
|
||||
}
|
||||
return ModifierFlags.None;
|
||||
}
|
||||
|
||||
@@ -1187,11 +1187,13 @@ namespace ts {
|
||||
case SyntaxKind.DeclareKeyword:
|
||||
case SyntaxKind.DefaultKeyword:
|
||||
case SyntaxKind.ExportKeyword:
|
||||
case SyntaxKind.InKeyword:
|
||||
case SyntaxKind.PublicKeyword:
|
||||
case SyntaxKind.PrivateKeyword:
|
||||
case SyntaxKind.ProtectedKeyword:
|
||||
case SyntaxKind.ReadonlyKeyword:
|
||||
case SyntaxKind.StaticKeyword:
|
||||
case SyntaxKind.OutKeyword:
|
||||
case SyntaxKind.OverrideKeyword:
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -385,6 +385,7 @@ namespace ts {
|
||||
case SyntaxKind.TypeParameter:
|
||||
Debug.type<TypeParameterDeclaration>(node);
|
||||
return factory.updateTypeParameterDeclaration(node,
|
||||
nodesVisitor(node.modifiers, visitor, isModifier),
|
||||
nodeVisitor(node.name, visitor, isIdentifier),
|
||||
nodeVisitor(node.constraint, visitor, isTypeNode),
|
||||
nodeVisitor(node.default, visitor, isTypeNode));
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace ts.codefix {
|
||||
function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, { container, typeNode, constraint, name }: Info): void {
|
||||
changes.replaceNode(sourceFile, container, factory.createMappedTypeNode(
|
||||
/*readonlyToken*/ undefined,
|
||||
factory.createTypeParameterDeclaration(name, factory.createTypeReferenceNode(constraint)),
|
||||
factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, factory.createTypeReferenceNode(constraint)),
|
||||
/*nameType*/ undefined,
|
||||
/*questionToken*/ undefined,
|
||||
typeNode,
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace ts.codefix {
|
||||
const members = isInterfaceDeclaration(container) ? container.members : (container.type as TypeLiteralNode).members;
|
||||
const otherMembers = members.filter(member => !isIndexSignatureDeclaration(member));
|
||||
const parameter = first(indexSignature.parameters);
|
||||
const mappedTypeParameter = factory.createTypeParameterDeclaration(cast(parameter.name, isIdentifier), parameter.type);
|
||||
const mappedTypeParameter = factory.createTypeParameterDeclaration(/*modifiers*/ undefined, cast(parameter.name, isIdentifier), parameter.type);
|
||||
const mappedIntersectionType = factory.createMappedTypeNode(
|
||||
hasEffectiveReadonlyModifier(indexSignature) ? factory.createModifier(SyntaxKind.ReadonlyKeyword) : undefined,
|
||||
mappedTypeParameter,
|
||||
|
||||
@@ -222,6 +222,7 @@ namespace ts.codefix {
|
||||
}
|
||||
return factory.updateTypeParameterDeclaration(
|
||||
typeParameterDecl,
|
||||
typeParameterDecl.modifiers,
|
||||
typeParameterDecl.name,
|
||||
constraint,
|
||||
defaultType
|
||||
@@ -306,7 +307,7 @@ namespace ts.codefix {
|
||||
const typeParameters = isJs || typeArguments === undefined
|
||||
? undefined
|
||||
: map(typeArguments, (_, i) =>
|
||||
factory.createTypeParameterDeclaration(CharacterCodes.T + typeArguments.length - 1 <= CharacterCodes.Z ? String.fromCharCode(CharacterCodes.T + i) : `T${i}`));
|
||||
factory.createTypeParameterDeclaration(/*modifiers*/ undefined, CharacterCodes.T + typeArguments.length - 1 <= CharacterCodes.Z ? String.fromCharCode(CharacterCodes.T + i) : `T${i}`));
|
||||
const parameters = createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, isJs);
|
||||
const type = isJs || contextualType === undefined
|
||||
? undefined
|
||||
|
||||
@@ -203,7 +203,7 @@ namespace ts.refactor {
|
||||
/* decorators */ undefined,
|
||||
/* modifiers */ undefined,
|
||||
name,
|
||||
typeParameters.map(id => factory.updateTypeParameterDeclaration(id, id.name, id.constraint, /* defaultType */ undefined)),
|
||||
typeParameters.map(id => factory.updateTypeParameterDeclaration(id, id.modifiers, id.name, id.constraint, /* defaultType */ undefined)),
|
||||
selection
|
||||
);
|
||||
changes.insertNodeBefore(file, firstStatement, ignoreSourceNewlines(newTypeNode), /* blankLineBetween */ true);
|
||||
@@ -237,7 +237,7 @@ namespace ts.refactor {
|
||||
const templates: JSDocTemplateTag[] = [];
|
||||
forEach(typeParameters, typeParameter => {
|
||||
const constraint = getEffectiveConstraintOfTypeParameter(typeParameter);
|
||||
const parameter = factory.createTypeParameterDeclaration(typeParameter.name);
|
||||
const parameter = factory.createTypeParameterDeclaration(/*modifiers*/ undefined, typeParameter.name);
|
||||
const template = factory.createJSDocTemplateTag(
|
||||
factory.createIdentifier("template"),
|
||||
constraint && cast(constraint, isJSDocTypeExpression),
|
||||
|
||||
@@ -267,7 +267,7 @@ namespace ts {
|
||||
factory.createKeywordTypeNode(SyntaxKind.AnyKeyword)
|
||||
),
|
||||
factory.createFunctionTypeNode(
|
||||
[factory.createTypeParameterDeclaration("T")],
|
||||
[factory.createTypeParameterDeclaration(/*modifiers*/ undefined, "T")],
|
||||
[factory.createParameterDeclaration(
|
||||
/*decorators*/ undefined,
|
||||
/*modifiers*/ undefined,
|
||||
|
||||
+251
-237
@@ -249,218 +249,219 @@ declare namespace ts {
|
||||
ModuleKeyword = 141,
|
||||
NamespaceKeyword = 142,
|
||||
NeverKeyword = 143,
|
||||
ReadonlyKeyword = 144,
|
||||
RequireKeyword = 145,
|
||||
NumberKeyword = 146,
|
||||
ObjectKeyword = 147,
|
||||
SetKeyword = 148,
|
||||
StringKeyword = 149,
|
||||
SymbolKeyword = 150,
|
||||
TypeKeyword = 151,
|
||||
UndefinedKeyword = 152,
|
||||
UniqueKeyword = 153,
|
||||
UnknownKeyword = 154,
|
||||
FromKeyword = 155,
|
||||
GlobalKeyword = 156,
|
||||
BigIntKeyword = 157,
|
||||
OverrideKeyword = 158,
|
||||
OfKeyword = 159,
|
||||
QualifiedName = 160,
|
||||
ComputedPropertyName = 161,
|
||||
TypeParameter = 162,
|
||||
Parameter = 163,
|
||||
Decorator = 164,
|
||||
PropertySignature = 165,
|
||||
PropertyDeclaration = 166,
|
||||
MethodSignature = 167,
|
||||
MethodDeclaration = 168,
|
||||
ClassStaticBlockDeclaration = 169,
|
||||
Constructor = 170,
|
||||
GetAccessor = 171,
|
||||
SetAccessor = 172,
|
||||
CallSignature = 173,
|
||||
ConstructSignature = 174,
|
||||
IndexSignature = 175,
|
||||
TypePredicate = 176,
|
||||
TypeReference = 177,
|
||||
FunctionType = 178,
|
||||
ConstructorType = 179,
|
||||
TypeQuery = 180,
|
||||
TypeLiteral = 181,
|
||||
ArrayType = 182,
|
||||
TupleType = 183,
|
||||
OptionalType = 184,
|
||||
RestType = 185,
|
||||
UnionType = 186,
|
||||
IntersectionType = 187,
|
||||
ConditionalType = 188,
|
||||
InferType = 189,
|
||||
ParenthesizedType = 190,
|
||||
ThisType = 191,
|
||||
TypeOperator = 192,
|
||||
IndexedAccessType = 193,
|
||||
MappedType = 194,
|
||||
LiteralType = 195,
|
||||
NamedTupleMember = 196,
|
||||
TemplateLiteralType = 197,
|
||||
TemplateLiteralTypeSpan = 198,
|
||||
ImportType = 199,
|
||||
ObjectBindingPattern = 200,
|
||||
ArrayBindingPattern = 201,
|
||||
BindingElement = 202,
|
||||
ArrayLiteralExpression = 203,
|
||||
ObjectLiteralExpression = 204,
|
||||
PropertyAccessExpression = 205,
|
||||
ElementAccessExpression = 206,
|
||||
CallExpression = 207,
|
||||
NewExpression = 208,
|
||||
TaggedTemplateExpression = 209,
|
||||
TypeAssertionExpression = 210,
|
||||
ParenthesizedExpression = 211,
|
||||
FunctionExpression = 212,
|
||||
ArrowFunction = 213,
|
||||
DeleteExpression = 214,
|
||||
TypeOfExpression = 215,
|
||||
VoidExpression = 216,
|
||||
AwaitExpression = 217,
|
||||
PrefixUnaryExpression = 218,
|
||||
PostfixUnaryExpression = 219,
|
||||
BinaryExpression = 220,
|
||||
ConditionalExpression = 221,
|
||||
TemplateExpression = 222,
|
||||
YieldExpression = 223,
|
||||
SpreadElement = 224,
|
||||
ClassExpression = 225,
|
||||
OmittedExpression = 226,
|
||||
ExpressionWithTypeArguments = 227,
|
||||
AsExpression = 228,
|
||||
NonNullExpression = 229,
|
||||
MetaProperty = 230,
|
||||
SyntheticExpression = 231,
|
||||
TemplateSpan = 232,
|
||||
SemicolonClassElement = 233,
|
||||
Block = 234,
|
||||
EmptyStatement = 235,
|
||||
VariableStatement = 236,
|
||||
ExpressionStatement = 237,
|
||||
IfStatement = 238,
|
||||
DoStatement = 239,
|
||||
WhileStatement = 240,
|
||||
ForStatement = 241,
|
||||
ForInStatement = 242,
|
||||
ForOfStatement = 243,
|
||||
ContinueStatement = 244,
|
||||
BreakStatement = 245,
|
||||
ReturnStatement = 246,
|
||||
WithStatement = 247,
|
||||
SwitchStatement = 248,
|
||||
LabeledStatement = 249,
|
||||
ThrowStatement = 250,
|
||||
TryStatement = 251,
|
||||
DebuggerStatement = 252,
|
||||
VariableDeclaration = 253,
|
||||
VariableDeclarationList = 254,
|
||||
FunctionDeclaration = 255,
|
||||
ClassDeclaration = 256,
|
||||
InterfaceDeclaration = 257,
|
||||
TypeAliasDeclaration = 258,
|
||||
EnumDeclaration = 259,
|
||||
ModuleDeclaration = 260,
|
||||
ModuleBlock = 261,
|
||||
CaseBlock = 262,
|
||||
NamespaceExportDeclaration = 263,
|
||||
ImportEqualsDeclaration = 264,
|
||||
ImportDeclaration = 265,
|
||||
ImportClause = 266,
|
||||
NamespaceImport = 267,
|
||||
NamedImports = 268,
|
||||
ImportSpecifier = 269,
|
||||
ExportAssignment = 270,
|
||||
ExportDeclaration = 271,
|
||||
NamedExports = 272,
|
||||
NamespaceExport = 273,
|
||||
ExportSpecifier = 274,
|
||||
MissingDeclaration = 275,
|
||||
ExternalModuleReference = 276,
|
||||
JsxElement = 277,
|
||||
JsxSelfClosingElement = 278,
|
||||
JsxOpeningElement = 279,
|
||||
JsxClosingElement = 280,
|
||||
JsxFragment = 281,
|
||||
JsxOpeningFragment = 282,
|
||||
JsxClosingFragment = 283,
|
||||
JsxAttribute = 284,
|
||||
JsxAttributes = 285,
|
||||
JsxSpreadAttribute = 286,
|
||||
JsxExpression = 287,
|
||||
CaseClause = 288,
|
||||
DefaultClause = 289,
|
||||
HeritageClause = 290,
|
||||
CatchClause = 291,
|
||||
AssertClause = 292,
|
||||
AssertEntry = 293,
|
||||
ImportTypeAssertionContainer = 294,
|
||||
PropertyAssignment = 295,
|
||||
ShorthandPropertyAssignment = 296,
|
||||
SpreadAssignment = 297,
|
||||
EnumMember = 298,
|
||||
UnparsedPrologue = 299,
|
||||
UnparsedPrepend = 300,
|
||||
UnparsedText = 301,
|
||||
UnparsedInternalText = 302,
|
||||
UnparsedSyntheticReference = 303,
|
||||
SourceFile = 304,
|
||||
Bundle = 305,
|
||||
UnparsedSource = 306,
|
||||
InputFiles = 307,
|
||||
JSDocTypeExpression = 308,
|
||||
JSDocNameReference = 309,
|
||||
JSDocMemberName = 310,
|
||||
JSDocAllType = 311,
|
||||
JSDocUnknownType = 312,
|
||||
JSDocNullableType = 313,
|
||||
JSDocNonNullableType = 314,
|
||||
JSDocOptionalType = 315,
|
||||
JSDocFunctionType = 316,
|
||||
JSDocVariadicType = 317,
|
||||
JSDocNamepathType = 318,
|
||||
OutKeyword = 144,
|
||||
ReadonlyKeyword = 145,
|
||||
RequireKeyword = 146,
|
||||
NumberKeyword = 147,
|
||||
ObjectKeyword = 148,
|
||||
SetKeyword = 149,
|
||||
StringKeyword = 150,
|
||||
SymbolKeyword = 151,
|
||||
TypeKeyword = 152,
|
||||
UndefinedKeyword = 153,
|
||||
UniqueKeyword = 154,
|
||||
UnknownKeyword = 155,
|
||||
FromKeyword = 156,
|
||||
GlobalKeyword = 157,
|
||||
BigIntKeyword = 158,
|
||||
OverrideKeyword = 159,
|
||||
OfKeyword = 160,
|
||||
QualifiedName = 161,
|
||||
ComputedPropertyName = 162,
|
||||
TypeParameter = 163,
|
||||
Parameter = 164,
|
||||
Decorator = 165,
|
||||
PropertySignature = 166,
|
||||
PropertyDeclaration = 167,
|
||||
MethodSignature = 168,
|
||||
MethodDeclaration = 169,
|
||||
ClassStaticBlockDeclaration = 170,
|
||||
Constructor = 171,
|
||||
GetAccessor = 172,
|
||||
SetAccessor = 173,
|
||||
CallSignature = 174,
|
||||
ConstructSignature = 175,
|
||||
IndexSignature = 176,
|
||||
TypePredicate = 177,
|
||||
TypeReference = 178,
|
||||
FunctionType = 179,
|
||||
ConstructorType = 180,
|
||||
TypeQuery = 181,
|
||||
TypeLiteral = 182,
|
||||
ArrayType = 183,
|
||||
TupleType = 184,
|
||||
OptionalType = 185,
|
||||
RestType = 186,
|
||||
UnionType = 187,
|
||||
IntersectionType = 188,
|
||||
ConditionalType = 189,
|
||||
InferType = 190,
|
||||
ParenthesizedType = 191,
|
||||
ThisType = 192,
|
||||
TypeOperator = 193,
|
||||
IndexedAccessType = 194,
|
||||
MappedType = 195,
|
||||
LiteralType = 196,
|
||||
NamedTupleMember = 197,
|
||||
TemplateLiteralType = 198,
|
||||
TemplateLiteralTypeSpan = 199,
|
||||
ImportType = 200,
|
||||
ObjectBindingPattern = 201,
|
||||
ArrayBindingPattern = 202,
|
||||
BindingElement = 203,
|
||||
ArrayLiteralExpression = 204,
|
||||
ObjectLiteralExpression = 205,
|
||||
PropertyAccessExpression = 206,
|
||||
ElementAccessExpression = 207,
|
||||
CallExpression = 208,
|
||||
NewExpression = 209,
|
||||
TaggedTemplateExpression = 210,
|
||||
TypeAssertionExpression = 211,
|
||||
ParenthesizedExpression = 212,
|
||||
FunctionExpression = 213,
|
||||
ArrowFunction = 214,
|
||||
DeleteExpression = 215,
|
||||
TypeOfExpression = 216,
|
||||
VoidExpression = 217,
|
||||
AwaitExpression = 218,
|
||||
PrefixUnaryExpression = 219,
|
||||
PostfixUnaryExpression = 220,
|
||||
BinaryExpression = 221,
|
||||
ConditionalExpression = 222,
|
||||
TemplateExpression = 223,
|
||||
YieldExpression = 224,
|
||||
SpreadElement = 225,
|
||||
ClassExpression = 226,
|
||||
OmittedExpression = 227,
|
||||
ExpressionWithTypeArguments = 228,
|
||||
AsExpression = 229,
|
||||
NonNullExpression = 230,
|
||||
MetaProperty = 231,
|
||||
SyntheticExpression = 232,
|
||||
TemplateSpan = 233,
|
||||
SemicolonClassElement = 234,
|
||||
Block = 235,
|
||||
EmptyStatement = 236,
|
||||
VariableStatement = 237,
|
||||
ExpressionStatement = 238,
|
||||
IfStatement = 239,
|
||||
DoStatement = 240,
|
||||
WhileStatement = 241,
|
||||
ForStatement = 242,
|
||||
ForInStatement = 243,
|
||||
ForOfStatement = 244,
|
||||
ContinueStatement = 245,
|
||||
BreakStatement = 246,
|
||||
ReturnStatement = 247,
|
||||
WithStatement = 248,
|
||||
SwitchStatement = 249,
|
||||
LabeledStatement = 250,
|
||||
ThrowStatement = 251,
|
||||
TryStatement = 252,
|
||||
DebuggerStatement = 253,
|
||||
VariableDeclaration = 254,
|
||||
VariableDeclarationList = 255,
|
||||
FunctionDeclaration = 256,
|
||||
ClassDeclaration = 257,
|
||||
InterfaceDeclaration = 258,
|
||||
TypeAliasDeclaration = 259,
|
||||
EnumDeclaration = 260,
|
||||
ModuleDeclaration = 261,
|
||||
ModuleBlock = 262,
|
||||
CaseBlock = 263,
|
||||
NamespaceExportDeclaration = 264,
|
||||
ImportEqualsDeclaration = 265,
|
||||
ImportDeclaration = 266,
|
||||
ImportClause = 267,
|
||||
NamespaceImport = 268,
|
||||
NamedImports = 269,
|
||||
ImportSpecifier = 270,
|
||||
ExportAssignment = 271,
|
||||
ExportDeclaration = 272,
|
||||
NamedExports = 273,
|
||||
NamespaceExport = 274,
|
||||
ExportSpecifier = 275,
|
||||
MissingDeclaration = 276,
|
||||
ExternalModuleReference = 277,
|
||||
JsxElement = 278,
|
||||
JsxSelfClosingElement = 279,
|
||||
JsxOpeningElement = 280,
|
||||
JsxClosingElement = 281,
|
||||
JsxFragment = 282,
|
||||
JsxOpeningFragment = 283,
|
||||
JsxClosingFragment = 284,
|
||||
JsxAttribute = 285,
|
||||
JsxAttributes = 286,
|
||||
JsxSpreadAttribute = 287,
|
||||
JsxExpression = 288,
|
||||
CaseClause = 289,
|
||||
DefaultClause = 290,
|
||||
HeritageClause = 291,
|
||||
CatchClause = 292,
|
||||
AssertClause = 293,
|
||||
AssertEntry = 294,
|
||||
ImportTypeAssertionContainer = 295,
|
||||
PropertyAssignment = 296,
|
||||
ShorthandPropertyAssignment = 297,
|
||||
SpreadAssignment = 298,
|
||||
EnumMember = 299,
|
||||
UnparsedPrologue = 300,
|
||||
UnparsedPrepend = 301,
|
||||
UnparsedText = 302,
|
||||
UnparsedInternalText = 303,
|
||||
UnparsedSyntheticReference = 304,
|
||||
SourceFile = 305,
|
||||
Bundle = 306,
|
||||
UnparsedSource = 307,
|
||||
InputFiles = 308,
|
||||
JSDocTypeExpression = 309,
|
||||
JSDocNameReference = 310,
|
||||
JSDocMemberName = 311,
|
||||
JSDocAllType = 312,
|
||||
JSDocUnknownType = 313,
|
||||
JSDocNullableType = 314,
|
||||
JSDocNonNullableType = 315,
|
||||
JSDocOptionalType = 316,
|
||||
JSDocFunctionType = 317,
|
||||
JSDocVariadicType = 318,
|
||||
JSDocNamepathType = 319,
|
||||
/** @deprecated Use SyntaxKind.JSDoc */
|
||||
JSDocComment = 319,
|
||||
JSDocText = 320,
|
||||
JSDocTypeLiteral = 321,
|
||||
JSDocSignature = 322,
|
||||
JSDocLink = 323,
|
||||
JSDocLinkCode = 324,
|
||||
JSDocLinkPlain = 325,
|
||||
JSDocTag = 326,
|
||||
JSDocAugmentsTag = 327,
|
||||
JSDocImplementsTag = 328,
|
||||
JSDocAuthorTag = 329,
|
||||
JSDocDeprecatedTag = 330,
|
||||
JSDocClassTag = 331,
|
||||
JSDocPublicTag = 332,
|
||||
JSDocPrivateTag = 333,
|
||||
JSDocProtectedTag = 334,
|
||||
JSDocReadonlyTag = 335,
|
||||
JSDocOverrideTag = 336,
|
||||
JSDocCallbackTag = 337,
|
||||
JSDocEnumTag = 338,
|
||||
JSDocParameterTag = 339,
|
||||
JSDocReturnTag = 340,
|
||||
JSDocThisTag = 341,
|
||||
JSDocTypeTag = 342,
|
||||
JSDocTemplateTag = 343,
|
||||
JSDocTypedefTag = 344,
|
||||
JSDocSeeTag = 345,
|
||||
JSDocPropertyTag = 346,
|
||||
SyntaxList = 347,
|
||||
NotEmittedStatement = 348,
|
||||
PartiallyEmittedExpression = 349,
|
||||
CommaListExpression = 350,
|
||||
MergeDeclarationMarker = 351,
|
||||
EndOfDeclarationMarker = 352,
|
||||
SyntheticReferenceExpression = 353,
|
||||
Count = 354,
|
||||
JSDocComment = 320,
|
||||
JSDocText = 321,
|
||||
JSDocTypeLiteral = 322,
|
||||
JSDocSignature = 323,
|
||||
JSDocLink = 324,
|
||||
JSDocLinkCode = 325,
|
||||
JSDocLinkPlain = 326,
|
||||
JSDocTag = 327,
|
||||
JSDocAugmentsTag = 328,
|
||||
JSDocImplementsTag = 329,
|
||||
JSDocAuthorTag = 330,
|
||||
JSDocDeprecatedTag = 331,
|
||||
JSDocClassTag = 332,
|
||||
JSDocPublicTag = 333,
|
||||
JSDocPrivateTag = 334,
|
||||
JSDocProtectedTag = 335,
|
||||
JSDocReadonlyTag = 336,
|
||||
JSDocOverrideTag = 337,
|
||||
JSDocCallbackTag = 338,
|
||||
JSDocEnumTag = 339,
|
||||
JSDocParameterTag = 340,
|
||||
JSDocReturnTag = 341,
|
||||
JSDocThisTag = 342,
|
||||
JSDocTypeTag = 343,
|
||||
JSDocTemplateTag = 344,
|
||||
JSDocTypedefTag = 345,
|
||||
JSDocSeeTag = 346,
|
||||
JSDocPropertyTag = 347,
|
||||
SyntaxList = 348,
|
||||
NotEmittedStatement = 349,
|
||||
PartiallyEmittedExpression = 350,
|
||||
CommaListExpression = 351,
|
||||
MergeDeclarationMarker = 352,
|
||||
EndOfDeclarationMarker = 353,
|
||||
SyntheticReferenceExpression = 354,
|
||||
Count = 355,
|
||||
FirstAssignment = 63,
|
||||
LastAssignment = 78,
|
||||
FirstCompoundAssignment = 64,
|
||||
@@ -468,15 +469,15 @@ declare namespace ts {
|
||||
FirstReservedWord = 81,
|
||||
LastReservedWord = 116,
|
||||
FirstKeyword = 81,
|
||||
LastKeyword = 159,
|
||||
LastKeyword = 160,
|
||||
FirstFutureReservedWord = 117,
|
||||
LastFutureReservedWord = 125,
|
||||
FirstTypeNode = 176,
|
||||
LastTypeNode = 199,
|
||||
FirstTypeNode = 177,
|
||||
LastTypeNode = 200,
|
||||
FirstPunctuation = 18,
|
||||
LastPunctuation = 78,
|
||||
FirstToken = 0,
|
||||
LastToken = 159,
|
||||
LastToken = 160,
|
||||
FirstTriviaToken = 2,
|
||||
LastTriviaToken = 7,
|
||||
FirstLiteralToken = 8,
|
||||
@@ -485,21 +486,21 @@ declare namespace ts {
|
||||
LastTemplateToken = 17,
|
||||
FirstBinaryOperator = 29,
|
||||
LastBinaryOperator = 78,
|
||||
FirstStatement = 236,
|
||||
LastStatement = 252,
|
||||
FirstNode = 160,
|
||||
FirstJSDocNode = 308,
|
||||
LastJSDocNode = 346,
|
||||
FirstJSDocTagNode = 326,
|
||||
LastJSDocTagNode = 346,
|
||||
JSDoc = 319
|
||||
FirstStatement = 237,
|
||||
LastStatement = 253,
|
||||
FirstNode = 161,
|
||||
FirstJSDocNode = 309,
|
||||
LastJSDocNode = 347,
|
||||
FirstJSDocTagNode = 327,
|
||||
LastJSDocTagNode = 347,
|
||||
JSDoc = 320
|
||||
}
|
||||
export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia;
|
||||
export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral;
|
||||
export type PseudoLiteralSyntaxKind = SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail;
|
||||
export type PunctuationSyntaxKind = SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.QuestionDotToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.BacktickToken | SyntaxKind.HashToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken;
|
||||
export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AssertKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword;
|
||||
export type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.StaticKeyword;
|
||||
export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AssertKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword;
|
||||
export type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.InKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.StaticKeyword;
|
||||
export type KeywordTypeSyntaxKind = SyntaxKind.AnyKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VoidKeyword;
|
||||
export type TokenSyntaxKind = SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | TriviaSyntaxKind | LiteralSyntaxKind | PseudoLiteralSyntaxKind | PunctuationSyntaxKind | SyntaxKind.Identifier | KeywordSyntaxKind;
|
||||
export type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken;
|
||||
@@ -550,13 +551,15 @@ declare namespace ts {
|
||||
HasComputedJSDocModifiers = 4096,
|
||||
Deprecated = 8192,
|
||||
Override = 16384,
|
||||
In = 32768,
|
||||
Out = 65536,
|
||||
HasComputedFlags = 536870912,
|
||||
AccessibilityModifier = 28,
|
||||
ParameterPropertyModifier = 16476,
|
||||
NonPublicAccessibilityModifier = 24,
|
||||
TypeScriptModifier = 18654,
|
||||
TypeScriptModifier = 116958,
|
||||
ExportDefault = 513,
|
||||
All = 27647
|
||||
All = 125951
|
||||
}
|
||||
export enum JsxFlags {
|
||||
None = 0,
|
||||
@@ -617,15 +620,17 @@ declare namespace ts {
|
||||
export type DeclareKeyword = ModifierToken<SyntaxKind.DeclareKeyword>;
|
||||
export type DefaultKeyword = ModifierToken<SyntaxKind.DefaultKeyword>;
|
||||
export type ExportKeyword = ModifierToken<SyntaxKind.ExportKeyword>;
|
||||
export type InKeyword = ModifierToken<SyntaxKind.InKeyword>;
|
||||
export type PrivateKeyword = ModifierToken<SyntaxKind.PrivateKeyword>;
|
||||
export type ProtectedKeyword = ModifierToken<SyntaxKind.ProtectedKeyword>;
|
||||
export type PublicKeyword = ModifierToken<SyntaxKind.PublicKeyword>;
|
||||
export type ReadonlyKeyword = ModifierToken<SyntaxKind.ReadonlyKeyword>;
|
||||
export type OutKeyword = ModifierToken<SyntaxKind.OutKeyword>;
|
||||
export type OverrideKeyword = ModifierToken<SyntaxKind.OverrideKeyword>;
|
||||
export type StaticKeyword = ModifierToken<SyntaxKind.StaticKeyword>;
|
||||
/** @deprecated Use `ReadonlyKeyword` instead. */
|
||||
export type ReadonlyToken = ReadonlyKeyword;
|
||||
export type Modifier = AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword;
|
||||
export type Modifier = AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | InKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OutKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword;
|
||||
export type AccessibilityModifier = PublicKeyword | PrivateKeyword | ProtectedKeyword;
|
||||
export type ParameterPropertyModifier = AccessibilityModifier | ReadonlyKeyword;
|
||||
export type ClassMemberModifier = AccessibilityModifier | ReadonlyKeyword | StaticKeyword;
|
||||
@@ -2670,14 +2675,13 @@ declare namespace ts {
|
||||
ObjectLiteralPatternWithComputedProperties = 512,
|
||||
ReverseMapped = 1024,
|
||||
JsxAttributes = 2048,
|
||||
MarkerType = 4096,
|
||||
JSLiteral = 8192,
|
||||
FreshLiteral = 16384,
|
||||
ArrayLiteral = 32768,
|
||||
JSLiteral = 4096,
|
||||
FreshLiteral = 8192,
|
||||
ArrayLiteral = 16384,
|
||||
ClassOrInterface = 3,
|
||||
ContainsSpread = 4194304,
|
||||
ObjectRestType = 8388608,
|
||||
InstantiationExpressionType = 16777216,
|
||||
ContainsSpread = 2097152,
|
||||
ObjectRestType = 4194304,
|
||||
InstantiationExpressionType = 8388608,
|
||||
}
|
||||
export interface ObjectType extends Type {
|
||||
objectFlags: ObjectFlags;
|
||||
@@ -3392,7 +3396,11 @@ declare namespace ts {
|
||||
updateQualifiedName(node: QualifiedName, left: EntityName, right: Identifier): QualifiedName;
|
||||
createComputedPropertyName(expression: Expression): ComputedPropertyName;
|
||||
updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName;
|
||||
createTypeParameterDeclaration(modifiers: readonly Modifier[] | undefined, name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration;
|
||||
/** @deprecated */
|
||||
createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration;
|
||||
updateTypeParameterDeclaration(node: TypeParameterDeclaration, modifiers: readonly Modifier[] | undefined, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration;
|
||||
/** @deprecated */
|
||||
updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration;
|
||||
createParameterDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration;
|
||||
updateParameterDeclaration(node: ParameterDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration;
|
||||
@@ -10758,9 +10766,15 @@ declare namespace ts {
|
||||
/** @deprecated Use `factory.updateComputedPropertyName` or the factory supplied by your transformation context instead. */
|
||||
const updateComputedPropertyName: (node: ComputedPropertyName, expression: Expression) => ComputedPropertyName;
|
||||
/** @deprecated Use `factory.createTypeParameterDeclaration` or the factory supplied by your transformation context instead. */
|
||||
const createTypeParameterDeclaration: (name: string | Identifier, constraint?: TypeNode | undefined, defaultType?: TypeNode | undefined) => TypeParameterDeclaration;
|
||||
const createTypeParameterDeclaration: {
|
||||
(modifiers: readonly Modifier[] | undefined, name: string | Identifier, constraint?: TypeNode | undefined, defaultType?: TypeNode | undefined): TypeParameterDeclaration;
|
||||
(name: string | Identifier, constraint?: TypeNode | undefined, defaultType?: TypeNode | undefined): TypeParameterDeclaration;
|
||||
};
|
||||
/** @deprecated Use `factory.updateTypeParameterDeclaration` or the factory supplied by your transformation context instead. */
|
||||
const updateTypeParameterDeclaration: (node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined) => TypeParameterDeclaration;
|
||||
const updateTypeParameterDeclaration: {
|
||||
(node: TypeParameterDeclaration, modifiers: readonly Modifier[] | undefined, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration;
|
||||
(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration;
|
||||
};
|
||||
/** @deprecated Use `factory.createParameterDeclaration` or the factory supplied by your transformation context instead. */
|
||||
const createParameter: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken | undefined, type?: TypeNode | undefined, initializer?: Expression | undefined) => ParameterDeclaration;
|
||||
/** @deprecated Use `factory.updateParameterDeclaration` or the factory supplied by your transformation context instead. */
|
||||
|
||||
+251
-237
@@ -249,218 +249,219 @@ declare namespace ts {
|
||||
ModuleKeyword = 141,
|
||||
NamespaceKeyword = 142,
|
||||
NeverKeyword = 143,
|
||||
ReadonlyKeyword = 144,
|
||||
RequireKeyword = 145,
|
||||
NumberKeyword = 146,
|
||||
ObjectKeyword = 147,
|
||||
SetKeyword = 148,
|
||||
StringKeyword = 149,
|
||||
SymbolKeyword = 150,
|
||||
TypeKeyword = 151,
|
||||
UndefinedKeyword = 152,
|
||||
UniqueKeyword = 153,
|
||||
UnknownKeyword = 154,
|
||||
FromKeyword = 155,
|
||||
GlobalKeyword = 156,
|
||||
BigIntKeyword = 157,
|
||||
OverrideKeyword = 158,
|
||||
OfKeyword = 159,
|
||||
QualifiedName = 160,
|
||||
ComputedPropertyName = 161,
|
||||
TypeParameter = 162,
|
||||
Parameter = 163,
|
||||
Decorator = 164,
|
||||
PropertySignature = 165,
|
||||
PropertyDeclaration = 166,
|
||||
MethodSignature = 167,
|
||||
MethodDeclaration = 168,
|
||||
ClassStaticBlockDeclaration = 169,
|
||||
Constructor = 170,
|
||||
GetAccessor = 171,
|
||||
SetAccessor = 172,
|
||||
CallSignature = 173,
|
||||
ConstructSignature = 174,
|
||||
IndexSignature = 175,
|
||||
TypePredicate = 176,
|
||||
TypeReference = 177,
|
||||
FunctionType = 178,
|
||||
ConstructorType = 179,
|
||||
TypeQuery = 180,
|
||||
TypeLiteral = 181,
|
||||
ArrayType = 182,
|
||||
TupleType = 183,
|
||||
OptionalType = 184,
|
||||
RestType = 185,
|
||||
UnionType = 186,
|
||||
IntersectionType = 187,
|
||||
ConditionalType = 188,
|
||||
InferType = 189,
|
||||
ParenthesizedType = 190,
|
||||
ThisType = 191,
|
||||
TypeOperator = 192,
|
||||
IndexedAccessType = 193,
|
||||
MappedType = 194,
|
||||
LiteralType = 195,
|
||||
NamedTupleMember = 196,
|
||||
TemplateLiteralType = 197,
|
||||
TemplateLiteralTypeSpan = 198,
|
||||
ImportType = 199,
|
||||
ObjectBindingPattern = 200,
|
||||
ArrayBindingPattern = 201,
|
||||
BindingElement = 202,
|
||||
ArrayLiteralExpression = 203,
|
||||
ObjectLiteralExpression = 204,
|
||||
PropertyAccessExpression = 205,
|
||||
ElementAccessExpression = 206,
|
||||
CallExpression = 207,
|
||||
NewExpression = 208,
|
||||
TaggedTemplateExpression = 209,
|
||||
TypeAssertionExpression = 210,
|
||||
ParenthesizedExpression = 211,
|
||||
FunctionExpression = 212,
|
||||
ArrowFunction = 213,
|
||||
DeleteExpression = 214,
|
||||
TypeOfExpression = 215,
|
||||
VoidExpression = 216,
|
||||
AwaitExpression = 217,
|
||||
PrefixUnaryExpression = 218,
|
||||
PostfixUnaryExpression = 219,
|
||||
BinaryExpression = 220,
|
||||
ConditionalExpression = 221,
|
||||
TemplateExpression = 222,
|
||||
YieldExpression = 223,
|
||||
SpreadElement = 224,
|
||||
ClassExpression = 225,
|
||||
OmittedExpression = 226,
|
||||
ExpressionWithTypeArguments = 227,
|
||||
AsExpression = 228,
|
||||
NonNullExpression = 229,
|
||||
MetaProperty = 230,
|
||||
SyntheticExpression = 231,
|
||||
TemplateSpan = 232,
|
||||
SemicolonClassElement = 233,
|
||||
Block = 234,
|
||||
EmptyStatement = 235,
|
||||
VariableStatement = 236,
|
||||
ExpressionStatement = 237,
|
||||
IfStatement = 238,
|
||||
DoStatement = 239,
|
||||
WhileStatement = 240,
|
||||
ForStatement = 241,
|
||||
ForInStatement = 242,
|
||||
ForOfStatement = 243,
|
||||
ContinueStatement = 244,
|
||||
BreakStatement = 245,
|
||||
ReturnStatement = 246,
|
||||
WithStatement = 247,
|
||||
SwitchStatement = 248,
|
||||
LabeledStatement = 249,
|
||||
ThrowStatement = 250,
|
||||
TryStatement = 251,
|
||||
DebuggerStatement = 252,
|
||||
VariableDeclaration = 253,
|
||||
VariableDeclarationList = 254,
|
||||
FunctionDeclaration = 255,
|
||||
ClassDeclaration = 256,
|
||||
InterfaceDeclaration = 257,
|
||||
TypeAliasDeclaration = 258,
|
||||
EnumDeclaration = 259,
|
||||
ModuleDeclaration = 260,
|
||||
ModuleBlock = 261,
|
||||
CaseBlock = 262,
|
||||
NamespaceExportDeclaration = 263,
|
||||
ImportEqualsDeclaration = 264,
|
||||
ImportDeclaration = 265,
|
||||
ImportClause = 266,
|
||||
NamespaceImport = 267,
|
||||
NamedImports = 268,
|
||||
ImportSpecifier = 269,
|
||||
ExportAssignment = 270,
|
||||
ExportDeclaration = 271,
|
||||
NamedExports = 272,
|
||||
NamespaceExport = 273,
|
||||
ExportSpecifier = 274,
|
||||
MissingDeclaration = 275,
|
||||
ExternalModuleReference = 276,
|
||||
JsxElement = 277,
|
||||
JsxSelfClosingElement = 278,
|
||||
JsxOpeningElement = 279,
|
||||
JsxClosingElement = 280,
|
||||
JsxFragment = 281,
|
||||
JsxOpeningFragment = 282,
|
||||
JsxClosingFragment = 283,
|
||||
JsxAttribute = 284,
|
||||
JsxAttributes = 285,
|
||||
JsxSpreadAttribute = 286,
|
||||
JsxExpression = 287,
|
||||
CaseClause = 288,
|
||||
DefaultClause = 289,
|
||||
HeritageClause = 290,
|
||||
CatchClause = 291,
|
||||
AssertClause = 292,
|
||||
AssertEntry = 293,
|
||||
ImportTypeAssertionContainer = 294,
|
||||
PropertyAssignment = 295,
|
||||
ShorthandPropertyAssignment = 296,
|
||||
SpreadAssignment = 297,
|
||||
EnumMember = 298,
|
||||
UnparsedPrologue = 299,
|
||||
UnparsedPrepend = 300,
|
||||
UnparsedText = 301,
|
||||
UnparsedInternalText = 302,
|
||||
UnparsedSyntheticReference = 303,
|
||||
SourceFile = 304,
|
||||
Bundle = 305,
|
||||
UnparsedSource = 306,
|
||||
InputFiles = 307,
|
||||
JSDocTypeExpression = 308,
|
||||
JSDocNameReference = 309,
|
||||
JSDocMemberName = 310,
|
||||
JSDocAllType = 311,
|
||||
JSDocUnknownType = 312,
|
||||
JSDocNullableType = 313,
|
||||
JSDocNonNullableType = 314,
|
||||
JSDocOptionalType = 315,
|
||||
JSDocFunctionType = 316,
|
||||
JSDocVariadicType = 317,
|
||||
JSDocNamepathType = 318,
|
||||
OutKeyword = 144,
|
||||
ReadonlyKeyword = 145,
|
||||
RequireKeyword = 146,
|
||||
NumberKeyword = 147,
|
||||
ObjectKeyword = 148,
|
||||
SetKeyword = 149,
|
||||
StringKeyword = 150,
|
||||
SymbolKeyword = 151,
|
||||
TypeKeyword = 152,
|
||||
UndefinedKeyword = 153,
|
||||
UniqueKeyword = 154,
|
||||
UnknownKeyword = 155,
|
||||
FromKeyword = 156,
|
||||
GlobalKeyword = 157,
|
||||
BigIntKeyword = 158,
|
||||
OverrideKeyword = 159,
|
||||
OfKeyword = 160,
|
||||
QualifiedName = 161,
|
||||
ComputedPropertyName = 162,
|
||||
TypeParameter = 163,
|
||||
Parameter = 164,
|
||||
Decorator = 165,
|
||||
PropertySignature = 166,
|
||||
PropertyDeclaration = 167,
|
||||
MethodSignature = 168,
|
||||
MethodDeclaration = 169,
|
||||
ClassStaticBlockDeclaration = 170,
|
||||
Constructor = 171,
|
||||
GetAccessor = 172,
|
||||
SetAccessor = 173,
|
||||
CallSignature = 174,
|
||||
ConstructSignature = 175,
|
||||
IndexSignature = 176,
|
||||
TypePredicate = 177,
|
||||
TypeReference = 178,
|
||||
FunctionType = 179,
|
||||
ConstructorType = 180,
|
||||
TypeQuery = 181,
|
||||
TypeLiteral = 182,
|
||||
ArrayType = 183,
|
||||
TupleType = 184,
|
||||
OptionalType = 185,
|
||||
RestType = 186,
|
||||
UnionType = 187,
|
||||
IntersectionType = 188,
|
||||
ConditionalType = 189,
|
||||
InferType = 190,
|
||||
ParenthesizedType = 191,
|
||||
ThisType = 192,
|
||||
TypeOperator = 193,
|
||||
IndexedAccessType = 194,
|
||||
MappedType = 195,
|
||||
LiteralType = 196,
|
||||
NamedTupleMember = 197,
|
||||
TemplateLiteralType = 198,
|
||||
TemplateLiteralTypeSpan = 199,
|
||||
ImportType = 200,
|
||||
ObjectBindingPattern = 201,
|
||||
ArrayBindingPattern = 202,
|
||||
BindingElement = 203,
|
||||
ArrayLiteralExpression = 204,
|
||||
ObjectLiteralExpression = 205,
|
||||
PropertyAccessExpression = 206,
|
||||
ElementAccessExpression = 207,
|
||||
CallExpression = 208,
|
||||
NewExpression = 209,
|
||||
TaggedTemplateExpression = 210,
|
||||
TypeAssertionExpression = 211,
|
||||
ParenthesizedExpression = 212,
|
||||
FunctionExpression = 213,
|
||||
ArrowFunction = 214,
|
||||
DeleteExpression = 215,
|
||||
TypeOfExpression = 216,
|
||||
VoidExpression = 217,
|
||||
AwaitExpression = 218,
|
||||
PrefixUnaryExpression = 219,
|
||||
PostfixUnaryExpression = 220,
|
||||
BinaryExpression = 221,
|
||||
ConditionalExpression = 222,
|
||||
TemplateExpression = 223,
|
||||
YieldExpression = 224,
|
||||
SpreadElement = 225,
|
||||
ClassExpression = 226,
|
||||
OmittedExpression = 227,
|
||||
ExpressionWithTypeArguments = 228,
|
||||
AsExpression = 229,
|
||||
NonNullExpression = 230,
|
||||
MetaProperty = 231,
|
||||
SyntheticExpression = 232,
|
||||
TemplateSpan = 233,
|
||||
SemicolonClassElement = 234,
|
||||
Block = 235,
|
||||
EmptyStatement = 236,
|
||||
VariableStatement = 237,
|
||||
ExpressionStatement = 238,
|
||||
IfStatement = 239,
|
||||
DoStatement = 240,
|
||||
WhileStatement = 241,
|
||||
ForStatement = 242,
|
||||
ForInStatement = 243,
|
||||
ForOfStatement = 244,
|
||||
ContinueStatement = 245,
|
||||
BreakStatement = 246,
|
||||
ReturnStatement = 247,
|
||||
WithStatement = 248,
|
||||
SwitchStatement = 249,
|
||||
LabeledStatement = 250,
|
||||
ThrowStatement = 251,
|
||||
TryStatement = 252,
|
||||
DebuggerStatement = 253,
|
||||
VariableDeclaration = 254,
|
||||
VariableDeclarationList = 255,
|
||||
FunctionDeclaration = 256,
|
||||
ClassDeclaration = 257,
|
||||
InterfaceDeclaration = 258,
|
||||
TypeAliasDeclaration = 259,
|
||||
EnumDeclaration = 260,
|
||||
ModuleDeclaration = 261,
|
||||
ModuleBlock = 262,
|
||||
CaseBlock = 263,
|
||||
NamespaceExportDeclaration = 264,
|
||||
ImportEqualsDeclaration = 265,
|
||||
ImportDeclaration = 266,
|
||||
ImportClause = 267,
|
||||
NamespaceImport = 268,
|
||||
NamedImports = 269,
|
||||
ImportSpecifier = 270,
|
||||
ExportAssignment = 271,
|
||||
ExportDeclaration = 272,
|
||||
NamedExports = 273,
|
||||
NamespaceExport = 274,
|
||||
ExportSpecifier = 275,
|
||||
MissingDeclaration = 276,
|
||||
ExternalModuleReference = 277,
|
||||
JsxElement = 278,
|
||||
JsxSelfClosingElement = 279,
|
||||
JsxOpeningElement = 280,
|
||||
JsxClosingElement = 281,
|
||||
JsxFragment = 282,
|
||||
JsxOpeningFragment = 283,
|
||||
JsxClosingFragment = 284,
|
||||
JsxAttribute = 285,
|
||||
JsxAttributes = 286,
|
||||
JsxSpreadAttribute = 287,
|
||||
JsxExpression = 288,
|
||||
CaseClause = 289,
|
||||
DefaultClause = 290,
|
||||
HeritageClause = 291,
|
||||
CatchClause = 292,
|
||||
AssertClause = 293,
|
||||
AssertEntry = 294,
|
||||
ImportTypeAssertionContainer = 295,
|
||||
PropertyAssignment = 296,
|
||||
ShorthandPropertyAssignment = 297,
|
||||
SpreadAssignment = 298,
|
||||
EnumMember = 299,
|
||||
UnparsedPrologue = 300,
|
||||
UnparsedPrepend = 301,
|
||||
UnparsedText = 302,
|
||||
UnparsedInternalText = 303,
|
||||
UnparsedSyntheticReference = 304,
|
||||
SourceFile = 305,
|
||||
Bundle = 306,
|
||||
UnparsedSource = 307,
|
||||
InputFiles = 308,
|
||||
JSDocTypeExpression = 309,
|
||||
JSDocNameReference = 310,
|
||||
JSDocMemberName = 311,
|
||||
JSDocAllType = 312,
|
||||
JSDocUnknownType = 313,
|
||||
JSDocNullableType = 314,
|
||||
JSDocNonNullableType = 315,
|
||||
JSDocOptionalType = 316,
|
||||
JSDocFunctionType = 317,
|
||||
JSDocVariadicType = 318,
|
||||
JSDocNamepathType = 319,
|
||||
/** @deprecated Use SyntaxKind.JSDoc */
|
||||
JSDocComment = 319,
|
||||
JSDocText = 320,
|
||||
JSDocTypeLiteral = 321,
|
||||
JSDocSignature = 322,
|
||||
JSDocLink = 323,
|
||||
JSDocLinkCode = 324,
|
||||
JSDocLinkPlain = 325,
|
||||
JSDocTag = 326,
|
||||
JSDocAugmentsTag = 327,
|
||||
JSDocImplementsTag = 328,
|
||||
JSDocAuthorTag = 329,
|
||||
JSDocDeprecatedTag = 330,
|
||||
JSDocClassTag = 331,
|
||||
JSDocPublicTag = 332,
|
||||
JSDocPrivateTag = 333,
|
||||
JSDocProtectedTag = 334,
|
||||
JSDocReadonlyTag = 335,
|
||||
JSDocOverrideTag = 336,
|
||||
JSDocCallbackTag = 337,
|
||||
JSDocEnumTag = 338,
|
||||
JSDocParameterTag = 339,
|
||||
JSDocReturnTag = 340,
|
||||
JSDocThisTag = 341,
|
||||
JSDocTypeTag = 342,
|
||||
JSDocTemplateTag = 343,
|
||||
JSDocTypedefTag = 344,
|
||||
JSDocSeeTag = 345,
|
||||
JSDocPropertyTag = 346,
|
||||
SyntaxList = 347,
|
||||
NotEmittedStatement = 348,
|
||||
PartiallyEmittedExpression = 349,
|
||||
CommaListExpression = 350,
|
||||
MergeDeclarationMarker = 351,
|
||||
EndOfDeclarationMarker = 352,
|
||||
SyntheticReferenceExpression = 353,
|
||||
Count = 354,
|
||||
JSDocComment = 320,
|
||||
JSDocText = 321,
|
||||
JSDocTypeLiteral = 322,
|
||||
JSDocSignature = 323,
|
||||
JSDocLink = 324,
|
||||
JSDocLinkCode = 325,
|
||||
JSDocLinkPlain = 326,
|
||||
JSDocTag = 327,
|
||||
JSDocAugmentsTag = 328,
|
||||
JSDocImplementsTag = 329,
|
||||
JSDocAuthorTag = 330,
|
||||
JSDocDeprecatedTag = 331,
|
||||
JSDocClassTag = 332,
|
||||
JSDocPublicTag = 333,
|
||||
JSDocPrivateTag = 334,
|
||||
JSDocProtectedTag = 335,
|
||||
JSDocReadonlyTag = 336,
|
||||
JSDocOverrideTag = 337,
|
||||
JSDocCallbackTag = 338,
|
||||
JSDocEnumTag = 339,
|
||||
JSDocParameterTag = 340,
|
||||
JSDocReturnTag = 341,
|
||||
JSDocThisTag = 342,
|
||||
JSDocTypeTag = 343,
|
||||
JSDocTemplateTag = 344,
|
||||
JSDocTypedefTag = 345,
|
||||
JSDocSeeTag = 346,
|
||||
JSDocPropertyTag = 347,
|
||||
SyntaxList = 348,
|
||||
NotEmittedStatement = 349,
|
||||
PartiallyEmittedExpression = 350,
|
||||
CommaListExpression = 351,
|
||||
MergeDeclarationMarker = 352,
|
||||
EndOfDeclarationMarker = 353,
|
||||
SyntheticReferenceExpression = 354,
|
||||
Count = 355,
|
||||
FirstAssignment = 63,
|
||||
LastAssignment = 78,
|
||||
FirstCompoundAssignment = 64,
|
||||
@@ -468,15 +469,15 @@ declare namespace ts {
|
||||
FirstReservedWord = 81,
|
||||
LastReservedWord = 116,
|
||||
FirstKeyword = 81,
|
||||
LastKeyword = 159,
|
||||
LastKeyword = 160,
|
||||
FirstFutureReservedWord = 117,
|
||||
LastFutureReservedWord = 125,
|
||||
FirstTypeNode = 176,
|
||||
LastTypeNode = 199,
|
||||
FirstTypeNode = 177,
|
||||
LastTypeNode = 200,
|
||||
FirstPunctuation = 18,
|
||||
LastPunctuation = 78,
|
||||
FirstToken = 0,
|
||||
LastToken = 159,
|
||||
LastToken = 160,
|
||||
FirstTriviaToken = 2,
|
||||
LastTriviaToken = 7,
|
||||
FirstLiteralToken = 8,
|
||||
@@ -485,21 +486,21 @@ declare namespace ts {
|
||||
LastTemplateToken = 17,
|
||||
FirstBinaryOperator = 29,
|
||||
LastBinaryOperator = 78,
|
||||
FirstStatement = 236,
|
||||
LastStatement = 252,
|
||||
FirstNode = 160,
|
||||
FirstJSDocNode = 308,
|
||||
LastJSDocNode = 346,
|
||||
FirstJSDocTagNode = 326,
|
||||
LastJSDocTagNode = 346,
|
||||
JSDoc = 319
|
||||
FirstStatement = 237,
|
||||
LastStatement = 253,
|
||||
FirstNode = 161,
|
||||
FirstJSDocNode = 309,
|
||||
LastJSDocNode = 347,
|
||||
FirstJSDocTagNode = 327,
|
||||
LastJSDocTagNode = 347,
|
||||
JSDoc = 320
|
||||
}
|
||||
export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia;
|
||||
export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral;
|
||||
export type PseudoLiteralSyntaxKind = SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail;
|
||||
export type PunctuationSyntaxKind = SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.QuestionDotToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.BacktickToken | SyntaxKind.HashToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken;
|
||||
export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AssertKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword;
|
||||
export type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.StaticKeyword;
|
||||
export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AssertKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword;
|
||||
export type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.InKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.StaticKeyword;
|
||||
export type KeywordTypeSyntaxKind = SyntaxKind.AnyKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VoidKeyword;
|
||||
export type TokenSyntaxKind = SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | TriviaSyntaxKind | LiteralSyntaxKind | PseudoLiteralSyntaxKind | PunctuationSyntaxKind | SyntaxKind.Identifier | KeywordSyntaxKind;
|
||||
export type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken;
|
||||
@@ -550,13 +551,15 @@ declare namespace ts {
|
||||
HasComputedJSDocModifiers = 4096,
|
||||
Deprecated = 8192,
|
||||
Override = 16384,
|
||||
In = 32768,
|
||||
Out = 65536,
|
||||
HasComputedFlags = 536870912,
|
||||
AccessibilityModifier = 28,
|
||||
ParameterPropertyModifier = 16476,
|
||||
NonPublicAccessibilityModifier = 24,
|
||||
TypeScriptModifier = 18654,
|
||||
TypeScriptModifier = 116958,
|
||||
ExportDefault = 513,
|
||||
All = 27647
|
||||
All = 125951
|
||||
}
|
||||
export enum JsxFlags {
|
||||
None = 0,
|
||||
@@ -617,15 +620,17 @@ declare namespace ts {
|
||||
export type DeclareKeyword = ModifierToken<SyntaxKind.DeclareKeyword>;
|
||||
export type DefaultKeyword = ModifierToken<SyntaxKind.DefaultKeyword>;
|
||||
export type ExportKeyword = ModifierToken<SyntaxKind.ExportKeyword>;
|
||||
export type InKeyword = ModifierToken<SyntaxKind.InKeyword>;
|
||||
export type PrivateKeyword = ModifierToken<SyntaxKind.PrivateKeyword>;
|
||||
export type ProtectedKeyword = ModifierToken<SyntaxKind.ProtectedKeyword>;
|
||||
export type PublicKeyword = ModifierToken<SyntaxKind.PublicKeyword>;
|
||||
export type ReadonlyKeyword = ModifierToken<SyntaxKind.ReadonlyKeyword>;
|
||||
export type OutKeyword = ModifierToken<SyntaxKind.OutKeyword>;
|
||||
export type OverrideKeyword = ModifierToken<SyntaxKind.OverrideKeyword>;
|
||||
export type StaticKeyword = ModifierToken<SyntaxKind.StaticKeyword>;
|
||||
/** @deprecated Use `ReadonlyKeyword` instead. */
|
||||
export type ReadonlyToken = ReadonlyKeyword;
|
||||
export type Modifier = AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword;
|
||||
export type Modifier = AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | InKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OutKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword;
|
||||
export type AccessibilityModifier = PublicKeyword | PrivateKeyword | ProtectedKeyword;
|
||||
export type ParameterPropertyModifier = AccessibilityModifier | ReadonlyKeyword;
|
||||
export type ClassMemberModifier = AccessibilityModifier | ReadonlyKeyword | StaticKeyword;
|
||||
@@ -2670,14 +2675,13 @@ declare namespace ts {
|
||||
ObjectLiteralPatternWithComputedProperties = 512,
|
||||
ReverseMapped = 1024,
|
||||
JsxAttributes = 2048,
|
||||
MarkerType = 4096,
|
||||
JSLiteral = 8192,
|
||||
FreshLiteral = 16384,
|
||||
ArrayLiteral = 32768,
|
||||
JSLiteral = 4096,
|
||||
FreshLiteral = 8192,
|
||||
ArrayLiteral = 16384,
|
||||
ClassOrInterface = 3,
|
||||
ContainsSpread = 4194304,
|
||||
ObjectRestType = 8388608,
|
||||
InstantiationExpressionType = 16777216,
|
||||
ContainsSpread = 2097152,
|
||||
ObjectRestType = 4194304,
|
||||
InstantiationExpressionType = 8388608,
|
||||
}
|
||||
export interface ObjectType extends Type {
|
||||
objectFlags: ObjectFlags;
|
||||
@@ -3392,7 +3396,11 @@ declare namespace ts {
|
||||
updateQualifiedName(node: QualifiedName, left: EntityName, right: Identifier): QualifiedName;
|
||||
createComputedPropertyName(expression: Expression): ComputedPropertyName;
|
||||
updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName;
|
||||
createTypeParameterDeclaration(modifiers: readonly Modifier[] | undefined, name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration;
|
||||
/** @deprecated */
|
||||
createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration;
|
||||
updateTypeParameterDeclaration(node: TypeParameterDeclaration, modifiers: readonly Modifier[] | undefined, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration;
|
||||
/** @deprecated */
|
||||
updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration;
|
||||
createParameterDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration;
|
||||
updateParameterDeclaration(node: ParameterDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration;
|
||||
@@ -6940,9 +6948,15 @@ declare namespace ts {
|
||||
/** @deprecated Use `factory.updateComputedPropertyName` or the factory supplied by your transformation context instead. */
|
||||
const updateComputedPropertyName: (node: ComputedPropertyName, expression: Expression) => ComputedPropertyName;
|
||||
/** @deprecated Use `factory.createTypeParameterDeclaration` or the factory supplied by your transformation context instead. */
|
||||
const createTypeParameterDeclaration: (name: string | Identifier, constraint?: TypeNode | undefined, defaultType?: TypeNode | undefined) => TypeParameterDeclaration;
|
||||
const createTypeParameterDeclaration: {
|
||||
(modifiers: readonly Modifier[] | undefined, name: string | Identifier, constraint?: TypeNode | undefined, defaultType?: TypeNode | undefined): TypeParameterDeclaration;
|
||||
(name: string | Identifier, constraint?: TypeNode | undefined, defaultType?: TypeNode | undefined): TypeParameterDeclaration;
|
||||
};
|
||||
/** @deprecated Use `factory.updateTypeParameterDeclaration` or the factory supplied by your transformation context instead. */
|
||||
const updateTypeParameterDeclaration: (node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined) => TypeParameterDeclaration;
|
||||
const updateTypeParameterDeclaration: {
|
||||
(node: TypeParameterDeclaration, modifiers: readonly Modifier[] | undefined, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration;
|
||||
(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration;
|
||||
};
|
||||
/** @deprecated Use `factory.createParameterDeclaration` or the factory supplied by your transformation context instead. */
|
||||
const createParameter: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken | undefined, type?: TypeNode | undefined, initializer?: Expression | undefined) => ParameterDeclaration;
|
||||
/** @deprecated Use `factory.updateParameterDeclaration` or the factory supplied by your transformation context instead. */
|
||||
|
||||
@@ -0,0 +1,307 @@
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts(9,1): error TS2322: Type 'Covariant<unknown>' is not assignable to type 'Covariant<string>'.
|
||||
Type 'unknown' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts(18,1): error TS2322: Type 'Contravariant<string>' is not assignable to type 'Contravariant<unknown>'.
|
||||
Type 'unknown' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts(28,1): error TS2322: Type 'Invariant<string>' is not assignable to type 'Invariant<unknown>'.
|
||||
Types of property 'f' are incompatible.
|
||||
Type '(x: string) => string' is not assignable to type '(x: unknown) => unknown'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type 'unknown' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts(29,1): error TS2322: Type 'Invariant<unknown>' is not assignable to type 'Invariant<string>'.
|
||||
The types returned by 'f(...)' are incompatible between these types.
|
||||
Type 'unknown' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts(40,17): error TS2636: Type 'Covariant1<super-T>' is not assignable to type 'Covariant1<sub-T>' as implied by variance annotation.
|
||||
Types of property 'x' are incompatible.
|
||||
Type 'super-T' is not assignable to type 'sub-T'.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts(44,21): error TS2636: Type 'keyof sub-T' is not assignable to type 'keyof super-T' as implied by variance annotation.
|
||||
Type 'string | number | symbol' is not assignable to type 'keyof super-T'.
|
||||
Type 'string' is not assignable to type 'keyof super-T'.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts(46,21): error TS2636: Type 'Contravariant2<sub-T>' is not assignable to type 'Contravariant2<super-T>' as implied by variance annotation.
|
||||
Types of property 'f' are incompatible.
|
||||
Type '(x: sub-T) => void' is not assignable to type '(x: super-T) => void'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type 'super-T' is not assignable to type 'sub-T'.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts(50,17): error TS2636: Type 'Invariant1<super-T>' is not assignable to type 'Invariant1<sub-T>' as implied by variance annotation.
|
||||
The types returned by 'f(...)' are incompatible between these types.
|
||||
Type 'super-T' is not assignable to type 'sub-T'.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts(54,17): error TS2636: Type 'Invariant2<sub-T>' is not assignable to type 'Invariant2<super-T>' as implied by variance annotation.
|
||||
Types of property 'f' are incompatible.
|
||||
Type '(x: sub-T) => sub-T' is not assignable to type '(x: super-T) => super-T'.
|
||||
Types of parameters 'x' and 'x' are incompatible.
|
||||
Type 'super-T' is not assignable to type 'sub-T'.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts(60,11): error TS2636: Type 'Foo1<super-T>' is not assignable to type 'Foo1<sub-T>' as implied by variance annotation.
|
||||
Types of property 'x' are incompatible.
|
||||
Type 'super-T' is not assignable to type 'sub-T'.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts(71,11): error TS2636: Type 'Foo2<sub-T>' is not assignable to type 'Foo2<super-T>' as implied by variance annotation.
|
||||
Types of property 'f' are incompatible.
|
||||
Type 'FooFn2<sub-T>' is not assignable to type 'FooFn2<super-T>'.
|
||||
Type 'super-T' is not assignable to type 'sub-T'.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts(95,10): error TS1273: 'public' modifier cannot appear on a type parameter
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts(96,17): error TS1030: 'in' modifier already seen.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts(97,17): error TS1030: 'out' modifier already seen.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts(98,14): error TS1029: 'in' modifier must precede 'out' modifier.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts(100,21): error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts(101,21): error TS1274: 'out' modifier can only appear on a type parameter of a class, interface or type alias
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts(104,5): error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts(105,5): error TS1274: 'out' modifier can only appear on a type parameter of a class, interface or type alias
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts(116,1): error TS2322: Type 'Baz<string>' is not assignable to type 'Baz<unknown>'.
|
||||
Type 'unknown' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts(117,1): error TS2322: Type 'Baz<unknown>' is not assignable to type 'Baz<string>'.
|
||||
Type 'unknown' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts(136,7): error TS2322: Type 'Parent<unknown>' is not assignable to type 'Parent<string>'.
|
||||
Type 'unknown' is not assignable to type 'string'.
|
||||
tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts(160,68): error TS2345: Argument of type 'ActionObject<{ type: "PLAY"; value: number; }>' is not assignable to parameter of type 'ActionObject<{ type: "PLAY"; value: number; } | { type: "RESET"; }>'.
|
||||
Types of property 'exec' are incompatible.
|
||||
Type '(meta: StateNode<any, { type: "PLAY"; value: number; }>) => void' is not assignable to type '(meta: StateNode<any, { type: "PLAY"; value: number; } | { type: "RESET"; }>) => void'.
|
||||
Types of parameters 'meta' and 'meta' are incompatible.
|
||||
Type 'StateNode<any, { type: "PLAY"; value: number; } | { type: "RESET"; }>' is not assignable to type 'StateNode<any, { type: "PLAY"; value: number; }>'.
|
||||
Types of property '_storedEvent' are incompatible.
|
||||
Type '{ type: "PLAY"; value: number; } | { type: "RESET"; }' is not assignable to type '{ type: "PLAY"; value: number; }'.
|
||||
Type '{ type: "RESET"; }' is not assignable to type '{ type: "PLAY"; value: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts (23 errors) ====
|
||||
type Covariant<out T> = {
|
||||
x: T;
|
||||
}
|
||||
|
||||
declare let super_covariant: Covariant<unknown>;
|
||||
declare let sub_covariant: Covariant<string>;
|
||||
|
||||
super_covariant = sub_covariant;
|
||||
sub_covariant = super_covariant; // Error
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type 'Covariant<unknown>' is not assignable to type 'Covariant<string>'.
|
||||
!!! error TS2322: Type 'unknown' is not assignable to type 'string'.
|
||||
|
||||
type Contravariant<in T> = {
|
||||
f: (x: T) => void;
|
||||
}
|
||||
|
||||
declare let super_contravariant: Contravariant<unknown>;
|
||||
declare let sub_contravariant: Contravariant<string>;
|
||||
|
||||
super_contravariant = sub_contravariant; // Error
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type 'Contravariant<string>' is not assignable to type 'Contravariant<unknown>'.
|
||||
!!! error TS2322: Type 'unknown' is not assignable to type 'string'.
|
||||
sub_contravariant = super_contravariant;
|
||||
|
||||
type Invariant<in out T> = {
|
||||
f: (x: T) => T;
|
||||
}
|
||||
|
||||
declare let super_invariant: Invariant<unknown>;
|
||||
declare let sub_invariant: Invariant<string>;
|
||||
|
||||
super_invariant = sub_invariant; // Error
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type 'Invariant<string>' is not assignable to type 'Invariant<unknown>'.
|
||||
!!! error TS2322: Types of property 'f' are incompatible.
|
||||
!!! error TS2322: Type '(x: string) => string' is not assignable to type '(x: unknown) => unknown'.
|
||||
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
|
||||
!!! error TS2322: Type 'unknown' is not assignable to type 'string'.
|
||||
sub_invariant = super_invariant; // Error
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type 'Invariant<unknown>' is not assignable to type 'Invariant<string>'.
|
||||
!!! error TS2322: The types returned by 'f(...)' are incompatible between these types.
|
||||
!!! error TS2322: Type 'unknown' is not assignable to type 'string'.
|
||||
|
||||
// Variance of various type constructors
|
||||
|
||||
type T10<out T> = T;
|
||||
type T11<in T> = keyof T;
|
||||
type T12<out T, out K extends keyof T> = T[K];
|
||||
type T13<in out T> = T[keyof T];
|
||||
|
||||
// Variance annotation errors
|
||||
|
||||
type Covariant1<in T> = { // Error
|
||||
~~~~
|
||||
!!! error TS2636: Type 'Covariant1<super-T>' is not assignable to type 'Covariant1<sub-T>' as implied by variance annotation.
|
||||
!!! error TS2636: Types of property 'x' are incompatible.
|
||||
!!! error TS2636: Type 'super-T' is not assignable to type 'sub-T'.
|
||||
x: T;
|
||||
}
|
||||
|
||||
type Contravariant1<out T> = keyof T; // Error
|
||||
~~~~~
|
||||
!!! error TS2636: Type 'keyof sub-T' is not assignable to type 'keyof super-T' as implied by variance annotation.
|
||||
!!! error TS2636: Type 'string | number | symbol' is not assignable to type 'keyof super-T'.
|
||||
!!! error TS2636: Type 'string' is not assignable to type 'keyof super-T'.
|
||||
|
||||
type Contravariant2<out T> = { // Error
|
||||
~~~~~
|
||||
!!! error TS2636: Type 'Contravariant2<sub-T>' is not assignable to type 'Contravariant2<super-T>' as implied by variance annotation.
|
||||
!!! error TS2636: Types of property 'f' are incompatible.
|
||||
!!! error TS2636: Type '(x: sub-T) => void' is not assignable to type '(x: super-T) => void'.
|
||||
!!! error TS2636: Types of parameters 'x' and 'x' are incompatible.
|
||||
!!! error TS2636: Type 'super-T' is not assignable to type 'sub-T'.
|
||||
f: (x: T) => void;
|
||||
}
|
||||
|
||||
type Invariant1<in T> = { // Error
|
||||
~~~~
|
||||
!!! error TS2636: Type 'Invariant1<super-T>' is not assignable to type 'Invariant1<sub-T>' as implied by variance annotation.
|
||||
!!! error TS2636: The types returned by 'f(...)' are incompatible between these types.
|
||||
!!! error TS2636: Type 'super-T' is not assignable to type 'sub-T'.
|
||||
f: (x: T) => T;
|
||||
}
|
||||
|
||||
type Invariant2<out T> = { // Error
|
||||
~~~~~
|
||||
!!! error TS2636: Type 'Invariant2<sub-T>' is not assignable to type 'Invariant2<super-T>' as implied by variance annotation.
|
||||
!!! error TS2636: Types of property 'f' are incompatible.
|
||||
!!! error TS2636: Type '(x: sub-T) => sub-T' is not assignable to type '(x: super-T) => super-T'.
|
||||
!!! error TS2636: Types of parameters 'x' and 'x' are incompatible.
|
||||
!!! error TS2636: Type 'super-T' is not assignable to type 'sub-T'.
|
||||
f: (x: T) => T;
|
||||
}
|
||||
|
||||
// Variance in circular types
|
||||
|
||||
type Foo1<in T> = { // Error
|
||||
~~~~
|
||||
!!! error TS2636: Type 'Foo1<super-T>' is not assignable to type 'Foo1<sub-T>' as implied by variance annotation.
|
||||
!!! error TS2636: Types of property 'x' are incompatible.
|
||||
!!! error TS2636: Type 'super-T' is not assignable to type 'sub-T'.
|
||||
x: T;
|
||||
f: FooFn1<T>;
|
||||
}
|
||||
|
||||
type FooFn1<T> = (foo: Bar1<T[]>) => void;
|
||||
|
||||
type Bar1<T> = {
|
||||
value: Foo1<T[]>;
|
||||
}
|
||||
|
||||
type Foo2<out T> = { // Error
|
||||
~~~~~
|
||||
!!! error TS2636: Type 'Foo2<sub-T>' is not assignable to type 'Foo2<super-T>' as implied by variance annotation.
|
||||
!!! error TS2636: Types of property 'f' are incompatible.
|
||||
!!! error TS2636: Type 'FooFn2<sub-T>' is not assignable to type 'FooFn2<super-T>'.
|
||||
!!! error TS2636: Type 'super-T' is not assignable to type 'sub-T'.
|
||||
x: T;
|
||||
f: FooFn2<T>;
|
||||
}
|
||||
|
||||
type FooFn2<T> = (foo: Bar2<T[]>) => void;
|
||||
|
||||
type Bar2<T> = {
|
||||
value: Foo2<T[]>;
|
||||
}
|
||||
|
||||
type Foo3<in out T> = {
|
||||
x: T;
|
||||
f: FooFn3<T>;
|
||||
}
|
||||
|
||||
type FooFn3<T> = (foo: Bar3<T[]>) => void;
|
||||
|
||||
type Bar3<T> = {
|
||||
value: Foo3<T[]>;
|
||||
}
|
||||
|
||||
// Wrong modifier usage
|
||||
|
||||
type T20<public T> = T; // Error
|
||||
~~~~~~
|
||||
!!! error TS1273: 'public' modifier cannot appear on a type parameter
|
||||
type T21<in out in T> = T; // Error
|
||||
~~
|
||||
!!! error TS1030: 'in' modifier already seen.
|
||||
type T22<in out out T> = T; // Error
|
||||
~~~
|
||||
!!! error TS1030: 'out' modifier already seen.
|
||||
type T23<out in T> = T; // Error
|
||||
~~
|
||||
!!! error TS1029: 'in' modifier must precede 'out' modifier.
|
||||
|
||||
declare function f1<in T>(x: T): void; // Error
|
||||
~~
|
||||
!!! error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias
|
||||
declare function f2<out T>(): T; // Error
|
||||
~~~
|
||||
!!! error TS1274: 'out' modifier can only appear on a type parameter of a class, interface or type alias
|
||||
|
||||
class C {
|
||||
in a = 0; // Error
|
||||
~~
|
||||
!!! error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias
|
||||
out b = 0; // Error
|
||||
~~~
|
||||
!!! error TS1274: 'out' modifier can only appear on a type parameter of a class, interface or type alias
|
||||
}
|
||||
|
||||
// Interface merging
|
||||
|
||||
interface Baz<out T> {}
|
||||
interface Baz<in T> {}
|
||||
|
||||
declare let baz1: Baz<unknown>;
|
||||
declare let baz2: Baz<string>;
|
||||
|
||||
baz1 = baz2; // Error
|
||||
~~~~
|
||||
!!! error TS2322: Type 'Baz<string>' is not assignable to type 'Baz<unknown>'.
|
||||
!!! error TS2322: Type 'unknown' is not assignable to type 'string'.
|
||||
baz2 = baz1; // Error
|
||||
~~~~
|
||||
!!! error TS2322: Type 'Baz<unknown>' is not assignable to type 'Baz<string>'.
|
||||
!!! error TS2322: Type 'unknown' is not assignable to type 'string'.
|
||||
|
||||
// Repro from #44572
|
||||
|
||||
interface Parent<out A> {
|
||||
child: Child<A> | null;
|
||||
parent: Parent<A> | null;
|
||||
}
|
||||
|
||||
interface Child<A, B = unknown> extends Parent<A> {
|
||||
readonly a: A;
|
||||
readonly b: B;
|
||||
}
|
||||
|
||||
function fn<A>(inp: Child<A>) {
|
||||
const a: Child<unknown> = inp;
|
||||
}
|
||||
|
||||
const pu: Parent<unknown> = { child: { a: 0, b: 0, child: null, parent: null }, parent: null };
|
||||
const notString: Parent<string> = pu; // Error
|
||||
~~~~~~~~~
|
||||
!!! error TS2322: Type 'Parent<unknown>' is not assignable to type 'Parent<string>'.
|
||||
!!! error TS2322: Type 'unknown' is not assignable to type 'string'.
|
||||
|
||||
// Repro from comment in #44572
|
||||
|
||||
declare class StateNode<TContext, in out TEvent extends { type: string }> {
|
||||
_storedEvent: TEvent;
|
||||
_action: ActionObject<TEvent>;
|
||||
_state: StateNode<TContext, any>;
|
||||
}
|
||||
|
||||
interface ActionObject<TEvent extends { type: string }> {
|
||||
exec: (meta: StateNode<any, TEvent>) => void;
|
||||
}
|
||||
|
||||
declare function createMachine<TEvent extends { type: string }>(action: ActionObject<TEvent>): StateNode<any, any>;
|
||||
|
||||
declare function interpret<TContext>(machine: StateNode<TContext, any>): void;
|
||||
|
||||
const machine = createMachine({} as any);
|
||||
|
||||
interpret(machine);
|
||||
|
||||
declare const qq: ActionObject<{ type: "PLAY"; value: number }>;
|
||||
|
||||
createMachine<{ type: "PLAY"; value: number } | { type: "RESET" }>(qq); // Error
|
||||
~~
|
||||
!!! error TS2345: Argument of type 'ActionObject<{ type: "PLAY"; value: number; }>' is not assignable to parameter of type 'ActionObject<{ type: "PLAY"; value: number; } | { type: "RESET"; }>'.
|
||||
!!! error TS2345: Types of property 'exec' are incompatible.
|
||||
!!! error TS2345: Type '(meta: StateNode<any, { type: "PLAY"; value: number; }>) => void' is not assignable to type '(meta: StateNode<any, { type: "PLAY"; value: number; } | { type: "RESET"; }>) => void'.
|
||||
!!! error TS2345: Types of parameters 'meta' and 'meta' are incompatible.
|
||||
!!! error TS2345: Type 'StateNode<any, { type: "PLAY"; value: number; } | { type: "RESET"; }>' is not assignable to type 'StateNode<any, { type: "PLAY"; value: number; }>'.
|
||||
!!! error TS2345: Types of property '_storedEvent' are incompatible.
|
||||
!!! error TS2345: Type '{ type: "PLAY"; value: number; } | { type: "RESET"; }' is not assignable to type '{ type: "PLAY"; value: number; }'.
|
||||
!!! error TS2345: Type '{ type: "RESET"; }' is not assignable to type '{ type: "PLAY"; value: number; }'.
|
||||
|
||||
@@ -0,0 +1,295 @@
|
||||
//// [varianceAnnotations.ts]
|
||||
type Covariant<out T> = {
|
||||
x: T;
|
||||
}
|
||||
|
||||
declare let super_covariant: Covariant<unknown>;
|
||||
declare let sub_covariant: Covariant<string>;
|
||||
|
||||
super_covariant = sub_covariant;
|
||||
sub_covariant = super_covariant; // Error
|
||||
|
||||
type Contravariant<in T> = {
|
||||
f: (x: T) => void;
|
||||
}
|
||||
|
||||
declare let super_contravariant: Contravariant<unknown>;
|
||||
declare let sub_contravariant: Contravariant<string>;
|
||||
|
||||
super_contravariant = sub_contravariant; // Error
|
||||
sub_contravariant = super_contravariant;
|
||||
|
||||
type Invariant<in out T> = {
|
||||
f: (x: T) => T;
|
||||
}
|
||||
|
||||
declare let super_invariant: Invariant<unknown>;
|
||||
declare let sub_invariant: Invariant<string>;
|
||||
|
||||
super_invariant = sub_invariant; // Error
|
||||
sub_invariant = super_invariant; // Error
|
||||
|
||||
// Variance of various type constructors
|
||||
|
||||
type T10<out T> = T;
|
||||
type T11<in T> = keyof T;
|
||||
type T12<out T, out K extends keyof T> = T[K];
|
||||
type T13<in out T> = T[keyof T];
|
||||
|
||||
// Variance annotation errors
|
||||
|
||||
type Covariant1<in T> = { // Error
|
||||
x: T;
|
||||
}
|
||||
|
||||
type Contravariant1<out T> = keyof T; // Error
|
||||
|
||||
type Contravariant2<out T> = { // Error
|
||||
f: (x: T) => void;
|
||||
}
|
||||
|
||||
type Invariant1<in T> = { // Error
|
||||
f: (x: T) => T;
|
||||
}
|
||||
|
||||
type Invariant2<out T> = { // Error
|
||||
f: (x: T) => T;
|
||||
}
|
||||
|
||||
// Variance in circular types
|
||||
|
||||
type Foo1<in T> = { // Error
|
||||
x: T;
|
||||
f: FooFn1<T>;
|
||||
}
|
||||
|
||||
type FooFn1<T> = (foo: Bar1<T[]>) => void;
|
||||
|
||||
type Bar1<T> = {
|
||||
value: Foo1<T[]>;
|
||||
}
|
||||
|
||||
type Foo2<out T> = { // Error
|
||||
x: T;
|
||||
f: FooFn2<T>;
|
||||
}
|
||||
|
||||
type FooFn2<T> = (foo: Bar2<T[]>) => void;
|
||||
|
||||
type Bar2<T> = {
|
||||
value: Foo2<T[]>;
|
||||
}
|
||||
|
||||
type Foo3<in out T> = {
|
||||
x: T;
|
||||
f: FooFn3<T>;
|
||||
}
|
||||
|
||||
type FooFn3<T> = (foo: Bar3<T[]>) => void;
|
||||
|
||||
type Bar3<T> = {
|
||||
value: Foo3<T[]>;
|
||||
}
|
||||
|
||||
// Wrong modifier usage
|
||||
|
||||
type T20<public T> = T; // Error
|
||||
type T21<in out in T> = T; // Error
|
||||
type T22<in out out T> = T; // Error
|
||||
type T23<out in T> = T; // Error
|
||||
|
||||
declare function f1<in T>(x: T): void; // Error
|
||||
declare function f2<out T>(): T; // Error
|
||||
|
||||
class C {
|
||||
in a = 0; // Error
|
||||
out b = 0; // Error
|
||||
}
|
||||
|
||||
// Interface merging
|
||||
|
||||
interface Baz<out T> {}
|
||||
interface Baz<in T> {}
|
||||
|
||||
declare let baz1: Baz<unknown>;
|
||||
declare let baz2: Baz<string>;
|
||||
|
||||
baz1 = baz2; // Error
|
||||
baz2 = baz1; // Error
|
||||
|
||||
// Repro from #44572
|
||||
|
||||
interface Parent<out A> {
|
||||
child: Child<A> | null;
|
||||
parent: Parent<A> | null;
|
||||
}
|
||||
|
||||
interface Child<A, B = unknown> extends Parent<A> {
|
||||
readonly a: A;
|
||||
readonly b: B;
|
||||
}
|
||||
|
||||
function fn<A>(inp: Child<A>) {
|
||||
const a: Child<unknown> = inp;
|
||||
}
|
||||
|
||||
const pu: Parent<unknown> = { child: { a: 0, b: 0, child: null, parent: null }, parent: null };
|
||||
const notString: Parent<string> = pu; // Error
|
||||
|
||||
// Repro from comment in #44572
|
||||
|
||||
declare class StateNode<TContext, in out TEvent extends { type: string }> {
|
||||
_storedEvent: TEvent;
|
||||
_action: ActionObject<TEvent>;
|
||||
_state: StateNode<TContext, any>;
|
||||
}
|
||||
|
||||
interface ActionObject<TEvent extends { type: string }> {
|
||||
exec: (meta: StateNode<any, TEvent>) => void;
|
||||
}
|
||||
|
||||
declare function createMachine<TEvent extends { type: string }>(action: ActionObject<TEvent>): StateNode<any, any>;
|
||||
|
||||
declare function interpret<TContext>(machine: StateNode<TContext, any>): void;
|
||||
|
||||
const machine = createMachine({} as any);
|
||||
|
||||
interpret(machine);
|
||||
|
||||
declare const qq: ActionObject<{ type: "PLAY"; value: number }>;
|
||||
|
||||
createMachine<{ type: "PLAY"; value: number } | { type: "RESET" }>(qq); // Error
|
||||
|
||||
|
||||
//// [varianceAnnotations.js]
|
||||
"use strict";
|
||||
super_covariant = sub_covariant;
|
||||
sub_covariant = super_covariant; // Error
|
||||
super_contravariant = sub_contravariant; // Error
|
||||
sub_contravariant = super_contravariant;
|
||||
super_invariant = sub_invariant; // Error
|
||||
sub_invariant = super_invariant; // Error
|
||||
var C = /** @class */ (function () {
|
||||
function C() {
|
||||
this.a = 0; // Error
|
||||
this.b = 0; // Error
|
||||
}
|
||||
return C;
|
||||
}());
|
||||
baz1 = baz2; // Error
|
||||
baz2 = baz1; // Error
|
||||
function fn(inp) {
|
||||
var a = inp;
|
||||
}
|
||||
var pu = { child: { a: 0, b: 0, child: null, parent: null }, parent: null };
|
||||
var notString = pu; // Error
|
||||
var machine = createMachine({});
|
||||
interpret(machine);
|
||||
createMachine(qq); // Error
|
||||
|
||||
|
||||
//// [varianceAnnotations.d.ts]
|
||||
declare type Covariant<out T> = {
|
||||
x: T;
|
||||
};
|
||||
declare let super_covariant: Covariant<unknown>;
|
||||
declare let sub_covariant: Covariant<string>;
|
||||
declare type Contravariant<in T> = {
|
||||
f: (x: T) => void;
|
||||
};
|
||||
declare let super_contravariant: Contravariant<unknown>;
|
||||
declare let sub_contravariant: Contravariant<string>;
|
||||
declare type Invariant<in out T> = {
|
||||
f: (x: T) => T;
|
||||
};
|
||||
declare let super_invariant: Invariant<unknown>;
|
||||
declare let sub_invariant: Invariant<string>;
|
||||
declare type T10<out T> = T;
|
||||
declare type T11<in T> = keyof T;
|
||||
declare type T12<out T, out K extends keyof T> = T[K];
|
||||
declare type T13<in out T> = T[keyof T];
|
||||
declare type Covariant1<in T> = {
|
||||
x: T;
|
||||
};
|
||||
declare type Contravariant1<out T> = keyof T;
|
||||
declare type Contravariant2<out T> = {
|
||||
f: (x: T) => void;
|
||||
};
|
||||
declare type Invariant1<in T> = {
|
||||
f: (x: T) => T;
|
||||
};
|
||||
declare type Invariant2<out T> = {
|
||||
f: (x: T) => T;
|
||||
};
|
||||
declare type Foo1<in T> = {
|
||||
x: T;
|
||||
f: FooFn1<T>;
|
||||
};
|
||||
declare type FooFn1<T> = (foo: Bar1<T[]>) => void;
|
||||
declare type Bar1<T> = {
|
||||
value: Foo1<T[]>;
|
||||
};
|
||||
declare type Foo2<out T> = {
|
||||
x: T;
|
||||
f: FooFn2<T>;
|
||||
};
|
||||
declare type FooFn2<T> = (foo: Bar2<T[]>) => void;
|
||||
declare type Bar2<T> = {
|
||||
value: Foo2<T[]>;
|
||||
};
|
||||
declare type Foo3<in out T> = {
|
||||
x: T;
|
||||
f: FooFn3<T>;
|
||||
};
|
||||
declare type FooFn3<T> = (foo: Bar3<T[]>) => void;
|
||||
declare type Bar3<T> = {
|
||||
value: Foo3<T[]>;
|
||||
};
|
||||
declare type T20<public T> = T;
|
||||
declare type T21<in out in T> = T;
|
||||
declare type T22<in out out T> = T;
|
||||
declare type T23<out in T> = T;
|
||||
declare function f1<in T>(x: T): void;
|
||||
declare function f2<out T>(): T;
|
||||
declare class C {
|
||||
in a: number;
|
||||
out b: number;
|
||||
}
|
||||
interface Baz<out T> {
|
||||
}
|
||||
interface Baz<in T> {
|
||||
}
|
||||
declare let baz1: Baz<unknown>;
|
||||
declare let baz2: Baz<string>;
|
||||
interface Parent<out A> {
|
||||
child: Child<A> | null;
|
||||
parent: Parent<A> | null;
|
||||
}
|
||||
interface Child<A, B = unknown> extends Parent<A> {
|
||||
readonly a: A;
|
||||
readonly b: B;
|
||||
}
|
||||
declare function fn<A>(inp: Child<A>): void;
|
||||
declare const pu: Parent<unknown>;
|
||||
declare const notString: Parent<string>;
|
||||
declare class StateNode<TContext, in out TEvent extends {
|
||||
type: string;
|
||||
}> {
|
||||
_storedEvent: TEvent;
|
||||
_action: ActionObject<TEvent>;
|
||||
_state: StateNode<TContext, any>;
|
||||
}
|
||||
interface ActionObject<TEvent extends {
|
||||
type: string;
|
||||
}> {
|
||||
exec: (meta: StateNode<any, TEvent>) => void;
|
||||
}
|
||||
declare function createMachine<TEvent extends {
|
||||
type: string;
|
||||
}>(action: ActionObject<TEvent>): StateNode<any, any>;
|
||||
declare function interpret<TContext>(machine: StateNode<TContext, any>): void;
|
||||
declare const machine: StateNode<any, any>;
|
||||
declare const qq: ActionObject<{
|
||||
type: "PLAY";
|
||||
value: number;
|
||||
}>;
|
||||
@@ -0,0 +1,450 @@
|
||||
=== tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts ===
|
||||
type Covariant<out T> = {
|
||||
>Covariant : Symbol(Covariant, Decl(varianceAnnotations.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 0, 15))
|
||||
|
||||
x: T;
|
||||
>x : Symbol(x, Decl(varianceAnnotations.ts, 0, 25))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 0, 15))
|
||||
}
|
||||
|
||||
declare let super_covariant: Covariant<unknown>;
|
||||
>super_covariant : Symbol(super_covariant, Decl(varianceAnnotations.ts, 4, 11))
|
||||
>Covariant : Symbol(Covariant, Decl(varianceAnnotations.ts, 0, 0))
|
||||
|
||||
declare let sub_covariant: Covariant<string>;
|
||||
>sub_covariant : Symbol(sub_covariant, Decl(varianceAnnotations.ts, 5, 11))
|
||||
>Covariant : Symbol(Covariant, Decl(varianceAnnotations.ts, 0, 0))
|
||||
|
||||
super_covariant = sub_covariant;
|
||||
>super_covariant : Symbol(super_covariant, Decl(varianceAnnotations.ts, 4, 11))
|
||||
>sub_covariant : Symbol(sub_covariant, Decl(varianceAnnotations.ts, 5, 11))
|
||||
|
||||
sub_covariant = super_covariant; // Error
|
||||
>sub_covariant : Symbol(sub_covariant, Decl(varianceAnnotations.ts, 5, 11))
|
||||
>super_covariant : Symbol(super_covariant, Decl(varianceAnnotations.ts, 4, 11))
|
||||
|
||||
type Contravariant<in T> = {
|
||||
>Contravariant : Symbol(Contravariant, Decl(varianceAnnotations.ts, 8, 32))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 10, 19))
|
||||
|
||||
f: (x: T) => void;
|
||||
>f : Symbol(f, Decl(varianceAnnotations.ts, 10, 28))
|
||||
>x : Symbol(x, Decl(varianceAnnotations.ts, 11, 8))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 10, 19))
|
||||
}
|
||||
|
||||
declare let super_contravariant: Contravariant<unknown>;
|
||||
>super_contravariant : Symbol(super_contravariant, Decl(varianceAnnotations.ts, 14, 11))
|
||||
>Contravariant : Symbol(Contravariant, Decl(varianceAnnotations.ts, 8, 32))
|
||||
|
||||
declare let sub_contravariant: Contravariant<string>;
|
||||
>sub_contravariant : Symbol(sub_contravariant, Decl(varianceAnnotations.ts, 15, 11))
|
||||
>Contravariant : Symbol(Contravariant, Decl(varianceAnnotations.ts, 8, 32))
|
||||
|
||||
super_contravariant = sub_contravariant; // Error
|
||||
>super_contravariant : Symbol(super_contravariant, Decl(varianceAnnotations.ts, 14, 11))
|
||||
>sub_contravariant : Symbol(sub_contravariant, Decl(varianceAnnotations.ts, 15, 11))
|
||||
|
||||
sub_contravariant = super_contravariant;
|
||||
>sub_contravariant : Symbol(sub_contravariant, Decl(varianceAnnotations.ts, 15, 11))
|
||||
>super_contravariant : Symbol(super_contravariant, Decl(varianceAnnotations.ts, 14, 11))
|
||||
|
||||
type Invariant<in out T> = {
|
||||
>Invariant : Symbol(Invariant, Decl(varianceAnnotations.ts, 18, 40))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 20, 15))
|
||||
|
||||
f: (x: T) => T;
|
||||
>f : Symbol(f, Decl(varianceAnnotations.ts, 20, 28))
|
||||
>x : Symbol(x, Decl(varianceAnnotations.ts, 21, 8))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 20, 15))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 20, 15))
|
||||
}
|
||||
|
||||
declare let super_invariant: Invariant<unknown>;
|
||||
>super_invariant : Symbol(super_invariant, Decl(varianceAnnotations.ts, 24, 11))
|
||||
>Invariant : Symbol(Invariant, Decl(varianceAnnotations.ts, 18, 40))
|
||||
|
||||
declare let sub_invariant: Invariant<string>;
|
||||
>sub_invariant : Symbol(sub_invariant, Decl(varianceAnnotations.ts, 25, 11))
|
||||
>Invariant : Symbol(Invariant, Decl(varianceAnnotations.ts, 18, 40))
|
||||
|
||||
super_invariant = sub_invariant; // Error
|
||||
>super_invariant : Symbol(super_invariant, Decl(varianceAnnotations.ts, 24, 11))
|
||||
>sub_invariant : Symbol(sub_invariant, Decl(varianceAnnotations.ts, 25, 11))
|
||||
|
||||
sub_invariant = super_invariant; // Error
|
||||
>sub_invariant : Symbol(sub_invariant, Decl(varianceAnnotations.ts, 25, 11))
|
||||
>super_invariant : Symbol(super_invariant, Decl(varianceAnnotations.ts, 24, 11))
|
||||
|
||||
// Variance of various type constructors
|
||||
|
||||
type T10<out T> = T;
|
||||
>T10 : Symbol(T10, Decl(varianceAnnotations.ts, 28, 32))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 32, 9))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 32, 9))
|
||||
|
||||
type T11<in T> = keyof T;
|
||||
>T11 : Symbol(T11, Decl(varianceAnnotations.ts, 32, 20))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 33, 9))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 33, 9))
|
||||
|
||||
type T12<out T, out K extends keyof T> = T[K];
|
||||
>T12 : Symbol(T12, Decl(varianceAnnotations.ts, 33, 25))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 34, 9))
|
||||
>K : Symbol(K, Decl(varianceAnnotations.ts, 34, 15))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 34, 9))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 34, 9))
|
||||
>K : Symbol(K, Decl(varianceAnnotations.ts, 34, 15))
|
||||
|
||||
type T13<in out T> = T[keyof T];
|
||||
>T13 : Symbol(T13, Decl(varianceAnnotations.ts, 34, 46))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 35, 9))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 35, 9))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 35, 9))
|
||||
|
||||
// Variance annotation errors
|
||||
|
||||
type Covariant1<in T> = { // Error
|
||||
>Covariant1 : Symbol(Covariant1, Decl(varianceAnnotations.ts, 35, 32))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 39, 16))
|
||||
|
||||
x: T;
|
||||
>x : Symbol(x, Decl(varianceAnnotations.ts, 39, 25))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 39, 16))
|
||||
}
|
||||
|
||||
type Contravariant1<out T> = keyof T; // Error
|
||||
>Contravariant1 : Symbol(Contravariant1, Decl(varianceAnnotations.ts, 41, 1))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 43, 20))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 43, 20))
|
||||
|
||||
type Contravariant2<out T> = { // Error
|
||||
>Contravariant2 : Symbol(Contravariant2, Decl(varianceAnnotations.ts, 43, 37))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 45, 20))
|
||||
|
||||
f: (x: T) => void;
|
||||
>f : Symbol(f, Decl(varianceAnnotations.ts, 45, 30))
|
||||
>x : Symbol(x, Decl(varianceAnnotations.ts, 46, 8))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 45, 20))
|
||||
}
|
||||
|
||||
type Invariant1<in T> = { // Error
|
||||
>Invariant1 : Symbol(Invariant1, Decl(varianceAnnotations.ts, 47, 1))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 49, 16))
|
||||
|
||||
f: (x: T) => T;
|
||||
>f : Symbol(f, Decl(varianceAnnotations.ts, 49, 25))
|
||||
>x : Symbol(x, Decl(varianceAnnotations.ts, 50, 8))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 49, 16))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 49, 16))
|
||||
}
|
||||
|
||||
type Invariant2<out T> = { // Error
|
||||
>Invariant2 : Symbol(Invariant2, Decl(varianceAnnotations.ts, 51, 1))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 53, 16))
|
||||
|
||||
f: (x: T) => T;
|
||||
>f : Symbol(f, Decl(varianceAnnotations.ts, 53, 26))
|
||||
>x : Symbol(x, Decl(varianceAnnotations.ts, 54, 8))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 53, 16))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 53, 16))
|
||||
}
|
||||
|
||||
// Variance in circular types
|
||||
|
||||
type Foo1<in T> = { // Error
|
||||
>Foo1 : Symbol(Foo1, Decl(varianceAnnotations.ts, 55, 1))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 59, 10))
|
||||
|
||||
x: T;
|
||||
>x : Symbol(x, Decl(varianceAnnotations.ts, 59, 19))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 59, 10))
|
||||
|
||||
f: FooFn1<T>;
|
||||
>f : Symbol(f, Decl(varianceAnnotations.ts, 60, 9))
|
||||
>FooFn1 : Symbol(FooFn1, Decl(varianceAnnotations.ts, 62, 1))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 59, 10))
|
||||
}
|
||||
|
||||
type FooFn1<T> = (foo: Bar1<T[]>) => void;
|
||||
>FooFn1 : Symbol(FooFn1, Decl(varianceAnnotations.ts, 62, 1))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 64, 12))
|
||||
>foo : Symbol(foo, Decl(varianceAnnotations.ts, 64, 18))
|
||||
>Bar1 : Symbol(Bar1, Decl(varianceAnnotations.ts, 64, 42))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 64, 12))
|
||||
|
||||
type Bar1<T> = {
|
||||
>Bar1 : Symbol(Bar1, Decl(varianceAnnotations.ts, 64, 42))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 66, 10))
|
||||
|
||||
value: Foo1<T[]>;
|
||||
>value : Symbol(value, Decl(varianceAnnotations.ts, 66, 16))
|
||||
>Foo1 : Symbol(Foo1, Decl(varianceAnnotations.ts, 55, 1))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 66, 10))
|
||||
}
|
||||
|
||||
type Foo2<out T> = { // Error
|
||||
>Foo2 : Symbol(Foo2, Decl(varianceAnnotations.ts, 68, 1))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 70, 10))
|
||||
|
||||
x: T;
|
||||
>x : Symbol(x, Decl(varianceAnnotations.ts, 70, 20))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 70, 10))
|
||||
|
||||
f: FooFn2<T>;
|
||||
>f : Symbol(f, Decl(varianceAnnotations.ts, 71, 9))
|
||||
>FooFn2 : Symbol(FooFn2, Decl(varianceAnnotations.ts, 73, 1))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 70, 10))
|
||||
}
|
||||
|
||||
type FooFn2<T> = (foo: Bar2<T[]>) => void;
|
||||
>FooFn2 : Symbol(FooFn2, Decl(varianceAnnotations.ts, 73, 1))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 75, 12))
|
||||
>foo : Symbol(foo, Decl(varianceAnnotations.ts, 75, 18))
|
||||
>Bar2 : Symbol(Bar2, Decl(varianceAnnotations.ts, 75, 42))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 75, 12))
|
||||
|
||||
type Bar2<T> = {
|
||||
>Bar2 : Symbol(Bar2, Decl(varianceAnnotations.ts, 75, 42))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 77, 10))
|
||||
|
||||
value: Foo2<T[]>;
|
||||
>value : Symbol(value, Decl(varianceAnnotations.ts, 77, 16))
|
||||
>Foo2 : Symbol(Foo2, Decl(varianceAnnotations.ts, 68, 1))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 77, 10))
|
||||
}
|
||||
|
||||
type Foo3<in out T> = {
|
||||
>Foo3 : Symbol(Foo3, Decl(varianceAnnotations.ts, 79, 1))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 81, 10))
|
||||
|
||||
x: T;
|
||||
>x : Symbol(x, Decl(varianceAnnotations.ts, 81, 23))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 81, 10))
|
||||
|
||||
f: FooFn3<T>;
|
||||
>f : Symbol(f, Decl(varianceAnnotations.ts, 82, 9))
|
||||
>FooFn3 : Symbol(FooFn3, Decl(varianceAnnotations.ts, 84, 1))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 81, 10))
|
||||
}
|
||||
|
||||
type FooFn3<T> = (foo: Bar3<T[]>) => void;
|
||||
>FooFn3 : Symbol(FooFn3, Decl(varianceAnnotations.ts, 84, 1))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 86, 12))
|
||||
>foo : Symbol(foo, Decl(varianceAnnotations.ts, 86, 18))
|
||||
>Bar3 : Symbol(Bar3, Decl(varianceAnnotations.ts, 86, 42))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 86, 12))
|
||||
|
||||
type Bar3<T> = {
|
||||
>Bar3 : Symbol(Bar3, Decl(varianceAnnotations.ts, 86, 42))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 88, 10))
|
||||
|
||||
value: Foo3<T[]>;
|
||||
>value : Symbol(value, Decl(varianceAnnotations.ts, 88, 16))
|
||||
>Foo3 : Symbol(Foo3, Decl(varianceAnnotations.ts, 79, 1))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 88, 10))
|
||||
}
|
||||
|
||||
// Wrong modifier usage
|
||||
|
||||
type T20<public T> = T; // Error
|
||||
>T20 : Symbol(T20, Decl(varianceAnnotations.ts, 90, 1))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 94, 9))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 94, 9))
|
||||
|
||||
type T21<in out in T> = T; // Error
|
||||
>T21 : Symbol(T21, Decl(varianceAnnotations.ts, 94, 23))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 95, 9))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 95, 9))
|
||||
|
||||
type T22<in out out T> = T; // Error
|
||||
>T22 : Symbol(T22, Decl(varianceAnnotations.ts, 95, 26))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 96, 9))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 96, 9))
|
||||
|
||||
type T23<out in T> = T; // Error
|
||||
>T23 : Symbol(T23, Decl(varianceAnnotations.ts, 96, 27))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 97, 9))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 97, 9))
|
||||
|
||||
declare function f1<in T>(x: T): void; // Error
|
||||
>f1 : Symbol(f1, Decl(varianceAnnotations.ts, 97, 23))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 99, 20))
|
||||
>x : Symbol(x, Decl(varianceAnnotations.ts, 99, 26))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 99, 20))
|
||||
|
||||
declare function f2<out T>(): T; // Error
|
||||
>f2 : Symbol(f2, Decl(varianceAnnotations.ts, 99, 38))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 100, 20))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 100, 20))
|
||||
|
||||
class C {
|
||||
>C : Symbol(C, Decl(varianceAnnotations.ts, 100, 32))
|
||||
|
||||
in a = 0; // Error
|
||||
>a : Symbol(C.a, Decl(varianceAnnotations.ts, 102, 9))
|
||||
|
||||
out b = 0; // Error
|
||||
>b : Symbol(C.b, Decl(varianceAnnotations.ts, 103, 13))
|
||||
}
|
||||
|
||||
// Interface merging
|
||||
|
||||
interface Baz<out T> {}
|
||||
>Baz : Symbol(Baz, Decl(varianceAnnotations.ts, 105, 1), Decl(varianceAnnotations.ts, 109, 23))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 109, 14), Decl(varianceAnnotations.ts, 110, 14))
|
||||
|
||||
interface Baz<in T> {}
|
||||
>Baz : Symbol(Baz, Decl(varianceAnnotations.ts, 105, 1), Decl(varianceAnnotations.ts, 109, 23))
|
||||
>T : Symbol(T, Decl(varianceAnnotations.ts, 109, 14), Decl(varianceAnnotations.ts, 110, 14))
|
||||
|
||||
declare let baz1: Baz<unknown>;
|
||||
>baz1 : Symbol(baz1, Decl(varianceAnnotations.ts, 112, 11))
|
||||
>Baz : Symbol(Baz, Decl(varianceAnnotations.ts, 105, 1), Decl(varianceAnnotations.ts, 109, 23))
|
||||
|
||||
declare let baz2: Baz<string>;
|
||||
>baz2 : Symbol(baz2, Decl(varianceAnnotations.ts, 113, 11))
|
||||
>Baz : Symbol(Baz, Decl(varianceAnnotations.ts, 105, 1), Decl(varianceAnnotations.ts, 109, 23))
|
||||
|
||||
baz1 = baz2; // Error
|
||||
>baz1 : Symbol(baz1, Decl(varianceAnnotations.ts, 112, 11))
|
||||
>baz2 : Symbol(baz2, Decl(varianceAnnotations.ts, 113, 11))
|
||||
|
||||
baz2 = baz1; // Error
|
||||
>baz2 : Symbol(baz2, Decl(varianceAnnotations.ts, 113, 11))
|
||||
>baz1 : Symbol(baz1, Decl(varianceAnnotations.ts, 112, 11))
|
||||
|
||||
// Repro from #44572
|
||||
|
||||
interface Parent<out A> {
|
||||
>Parent : Symbol(Parent, Decl(varianceAnnotations.ts, 116, 12))
|
||||
>A : Symbol(A, Decl(varianceAnnotations.ts, 120, 17))
|
||||
|
||||
child: Child<A> | null;
|
||||
>child : Symbol(Parent.child, Decl(varianceAnnotations.ts, 120, 25))
|
||||
>Child : Symbol(Child, Decl(varianceAnnotations.ts, 123, 1))
|
||||
>A : Symbol(A, Decl(varianceAnnotations.ts, 120, 17))
|
||||
|
||||
parent: Parent<A> | null;
|
||||
>parent : Symbol(Parent.parent, Decl(varianceAnnotations.ts, 121, 27))
|
||||
>Parent : Symbol(Parent, Decl(varianceAnnotations.ts, 116, 12))
|
||||
>A : Symbol(A, Decl(varianceAnnotations.ts, 120, 17))
|
||||
}
|
||||
|
||||
interface Child<A, B = unknown> extends Parent<A> {
|
||||
>Child : Symbol(Child, Decl(varianceAnnotations.ts, 123, 1))
|
||||
>A : Symbol(A, Decl(varianceAnnotations.ts, 125, 16))
|
||||
>B : Symbol(B, Decl(varianceAnnotations.ts, 125, 18))
|
||||
>Parent : Symbol(Parent, Decl(varianceAnnotations.ts, 116, 12))
|
||||
>A : Symbol(A, Decl(varianceAnnotations.ts, 125, 16))
|
||||
|
||||
readonly a: A;
|
||||
>a : Symbol(Child.a, Decl(varianceAnnotations.ts, 125, 51))
|
||||
>A : Symbol(A, Decl(varianceAnnotations.ts, 125, 16))
|
||||
|
||||
readonly b: B;
|
||||
>b : Symbol(Child.b, Decl(varianceAnnotations.ts, 126, 18))
|
||||
>B : Symbol(B, Decl(varianceAnnotations.ts, 125, 18))
|
||||
}
|
||||
|
||||
function fn<A>(inp: Child<A>) {
|
||||
>fn : Symbol(fn, Decl(varianceAnnotations.ts, 128, 1))
|
||||
>A : Symbol(A, Decl(varianceAnnotations.ts, 130, 12))
|
||||
>inp : Symbol(inp, Decl(varianceAnnotations.ts, 130, 15))
|
||||
>Child : Symbol(Child, Decl(varianceAnnotations.ts, 123, 1))
|
||||
>A : Symbol(A, Decl(varianceAnnotations.ts, 130, 12))
|
||||
|
||||
const a: Child<unknown> = inp;
|
||||
>a : Symbol(a, Decl(varianceAnnotations.ts, 131, 9))
|
||||
>Child : Symbol(Child, Decl(varianceAnnotations.ts, 123, 1))
|
||||
>inp : Symbol(inp, Decl(varianceAnnotations.ts, 130, 15))
|
||||
}
|
||||
|
||||
const pu: Parent<unknown> = { child: { a: 0, b: 0, child: null, parent: null }, parent: null };
|
||||
>pu : Symbol(pu, Decl(varianceAnnotations.ts, 134, 5))
|
||||
>Parent : Symbol(Parent, Decl(varianceAnnotations.ts, 116, 12))
|
||||
>child : Symbol(child, Decl(varianceAnnotations.ts, 134, 29))
|
||||
>a : Symbol(a, Decl(varianceAnnotations.ts, 134, 38))
|
||||
>b : Symbol(b, Decl(varianceAnnotations.ts, 134, 44))
|
||||
>child : Symbol(child, Decl(varianceAnnotations.ts, 134, 50))
|
||||
>parent : Symbol(parent, Decl(varianceAnnotations.ts, 134, 63))
|
||||
>parent : Symbol(parent, Decl(varianceAnnotations.ts, 134, 79))
|
||||
|
||||
const notString: Parent<string> = pu; // Error
|
||||
>notString : Symbol(notString, Decl(varianceAnnotations.ts, 135, 5))
|
||||
>Parent : Symbol(Parent, Decl(varianceAnnotations.ts, 116, 12))
|
||||
>pu : Symbol(pu, Decl(varianceAnnotations.ts, 134, 5))
|
||||
|
||||
// Repro from comment in #44572
|
||||
|
||||
declare class StateNode<TContext, in out TEvent extends { type: string }> {
|
||||
>StateNode : Symbol(StateNode, Decl(varianceAnnotations.ts, 135, 37))
|
||||
>TContext : Symbol(TContext, Decl(varianceAnnotations.ts, 139, 24))
|
||||
>TEvent : Symbol(TEvent, Decl(varianceAnnotations.ts, 139, 33))
|
||||
>type : Symbol(type, Decl(varianceAnnotations.ts, 139, 57))
|
||||
|
||||
_storedEvent: TEvent;
|
||||
>_storedEvent : Symbol(StateNode._storedEvent, Decl(varianceAnnotations.ts, 139, 75))
|
||||
>TEvent : Symbol(TEvent, Decl(varianceAnnotations.ts, 139, 33))
|
||||
|
||||
_action: ActionObject<TEvent>;
|
||||
>_action : Symbol(StateNode._action, Decl(varianceAnnotations.ts, 140, 25))
|
||||
>ActionObject : Symbol(ActionObject, Decl(varianceAnnotations.ts, 143, 1))
|
||||
>TEvent : Symbol(TEvent, Decl(varianceAnnotations.ts, 139, 33))
|
||||
|
||||
_state: StateNode<TContext, any>;
|
||||
>_state : Symbol(StateNode._state, Decl(varianceAnnotations.ts, 141, 34))
|
||||
>StateNode : Symbol(StateNode, Decl(varianceAnnotations.ts, 135, 37))
|
||||
>TContext : Symbol(TContext, Decl(varianceAnnotations.ts, 139, 24))
|
||||
}
|
||||
|
||||
interface ActionObject<TEvent extends { type: string }> {
|
||||
>ActionObject : Symbol(ActionObject, Decl(varianceAnnotations.ts, 143, 1))
|
||||
>TEvent : Symbol(TEvent, Decl(varianceAnnotations.ts, 145, 23))
|
||||
>type : Symbol(type, Decl(varianceAnnotations.ts, 145, 39))
|
||||
|
||||
exec: (meta: StateNode<any, TEvent>) => void;
|
||||
>exec : Symbol(ActionObject.exec, Decl(varianceAnnotations.ts, 145, 57))
|
||||
>meta : Symbol(meta, Decl(varianceAnnotations.ts, 146, 11))
|
||||
>StateNode : Symbol(StateNode, Decl(varianceAnnotations.ts, 135, 37))
|
||||
>TEvent : Symbol(TEvent, Decl(varianceAnnotations.ts, 145, 23))
|
||||
}
|
||||
|
||||
declare function createMachine<TEvent extends { type: string }>(action: ActionObject<TEvent>): StateNode<any, any>;
|
||||
>createMachine : Symbol(createMachine, Decl(varianceAnnotations.ts, 147, 1))
|
||||
>TEvent : Symbol(TEvent, Decl(varianceAnnotations.ts, 149, 31))
|
||||
>type : Symbol(type, Decl(varianceAnnotations.ts, 149, 47))
|
||||
>action : Symbol(action, Decl(varianceAnnotations.ts, 149, 64))
|
||||
>ActionObject : Symbol(ActionObject, Decl(varianceAnnotations.ts, 143, 1))
|
||||
>TEvent : Symbol(TEvent, Decl(varianceAnnotations.ts, 149, 31))
|
||||
>StateNode : Symbol(StateNode, Decl(varianceAnnotations.ts, 135, 37))
|
||||
|
||||
declare function interpret<TContext>(machine: StateNode<TContext, any>): void;
|
||||
>interpret : Symbol(interpret, Decl(varianceAnnotations.ts, 149, 115))
|
||||
>TContext : Symbol(TContext, Decl(varianceAnnotations.ts, 151, 27))
|
||||
>machine : Symbol(machine, Decl(varianceAnnotations.ts, 151, 37))
|
||||
>StateNode : Symbol(StateNode, Decl(varianceAnnotations.ts, 135, 37))
|
||||
>TContext : Symbol(TContext, Decl(varianceAnnotations.ts, 151, 27))
|
||||
|
||||
const machine = createMachine({} as any);
|
||||
>machine : Symbol(machine, Decl(varianceAnnotations.ts, 153, 5))
|
||||
>createMachine : Symbol(createMachine, Decl(varianceAnnotations.ts, 147, 1))
|
||||
|
||||
interpret(machine);
|
||||
>interpret : Symbol(interpret, Decl(varianceAnnotations.ts, 149, 115))
|
||||
>machine : Symbol(machine, Decl(varianceAnnotations.ts, 153, 5))
|
||||
|
||||
declare const qq: ActionObject<{ type: "PLAY"; value: number }>;
|
||||
>qq : Symbol(qq, Decl(varianceAnnotations.ts, 157, 13))
|
||||
>ActionObject : Symbol(ActionObject, Decl(varianceAnnotations.ts, 143, 1))
|
||||
>type : Symbol(type, Decl(varianceAnnotations.ts, 157, 32))
|
||||
>value : Symbol(value, Decl(varianceAnnotations.ts, 157, 46))
|
||||
|
||||
createMachine<{ type: "PLAY"; value: number } | { type: "RESET" }>(qq); // Error
|
||||
>createMachine : Symbol(createMachine, Decl(varianceAnnotations.ts, 147, 1))
|
||||
>type : Symbol(type, Decl(varianceAnnotations.ts, 159, 15))
|
||||
>value : Symbol(value, Decl(varianceAnnotations.ts, 159, 29))
|
||||
>type : Symbol(type, Decl(varianceAnnotations.ts, 159, 49))
|
||||
>qq : Symbol(qq, Decl(varianceAnnotations.ts, 157, 13))
|
||||
|
||||
@@ -0,0 +1,348 @@
|
||||
=== tests/cases/conformance/types/typeParameters/typeParameterLists/varianceAnnotations.ts ===
|
||||
type Covariant<out T> = {
|
||||
>Covariant : Covariant<T>
|
||||
|
||||
x: T;
|
||||
>x : T
|
||||
}
|
||||
|
||||
declare let super_covariant: Covariant<unknown>;
|
||||
>super_covariant : Covariant<unknown>
|
||||
|
||||
declare let sub_covariant: Covariant<string>;
|
||||
>sub_covariant : Covariant<string>
|
||||
|
||||
super_covariant = sub_covariant;
|
||||
>super_covariant = sub_covariant : Covariant<string>
|
||||
>super_covariant : Covariant<unknown>
|
||||
>sub_covariant : Covariant<string>
|
||||
|
||||
sub_covariant = super_covariant; // Error
|
||||
>sub_covariant = super_covariant : Covariant<unknown>
|
||||
>sub_covariant : Covariant<string>
|
||||
>super_covariant : Covariant<unknown>
|
||||
|
||||
type Contravariant<in T> = {
|
||||
>Contravariant : Contravariant<T>
|
||||
|
||||
f: (x: T) => void;
|
||||
>f : (x: T) => void
|
||||
>x : T
|
||||
}
|
||||
|
||||
declare let super_contravariant: Contravariant<unknown>;
|
||||
>super_contravariant : Contravariant<unknown>
|
||||
|
||||
declare let sub_contravariant: Contravariant<string>;
|
||||
>sub_contravariant : Contravariant<string>
|
||||
|
||||
super_contravariant = sub_contravariant; // Error
|
||||
>super_contravariant = sub_contravariant : Contravariant<string>
|
||||
>super_contravariant : Contravariant<unknown>
|
||||
>sub_contravariant : Contravariant<string>
|
||||
|
||||
sub_contravariant = super_contravariant;
|
||||
>sub_contravariant = super_contravariant : Contravariant<unknown>
|
||||
>sub_contravariant : Contravariant<string>
|
||||
>super_contravariant : Contravariant<unknown>
|
||||
|
||||
type Invariant<in out T> = {
|
||||
>Invariant : Invariant<T>
|
||||
|
||||
f: (x: T) => T;
|
||||
>f : (x: T) => T
|
||||
>x : T
|
||||
}
|
||||
|
||||
declare let super_invariant: Invariant<unknown>;
|
||||
>super_invariant : Invariant<unknown>
|
||||
|
||||
declare let sub_invariant: Invariant<string>;
|
||||
>sub_invariant : Invariant<string>
|
||||
|
||||
super_invariant = sub_invariant; // Error
|
||||
>super_invariant = sub_invariant : Invariant<string>
|
||||
>super_invariant : Invariant<unknown>
|
||||
>sub_invariant : Invariant<string>
|
||||
|
||||
sub_invariant = super_invariant; // Error
|
||||
>sub_invariant = super_invariant : Invariant<unknown>
|
||||
>sub_invariant : Invariant<string>
|
||||
>super_invariant : Invariant<unknown>
|
||||
|
||||
// Variance of various type constructors
|
||||
|
||||
type T10<out T> = T;
|
||||
>T10 : T
|
||||
|
||||
type T11<in T> = keyof T;
|
||||
>T11 : keyof T
|
||||
|
||||
type T12<out T, out K extends keyof T> = T[K];
|
||||
>T12 : T12<T, K>
|
||||
|
||||
type T13<in out T> = T[keyof T];
|
||||
>T13 : T13<T>
|
||||
|
||||
// Variance annotation errors
|
||||
|
||||
type Covariant1<in T> = { // Error
|
||||
>Covariant1 : Covariant1<T>
|
||||
|
||||
x: T;
|
||||
>x : T
|
||||
}
|
||||
|
||||
type Contravariant1<out T> = keyof T; // Error
|
||||
>Contravariant1 : keyof T
|
||||
|
||||
type Contravariant2<out T> = { // Error
|
||||
>Contravariant2 : Contravariant2<T>
|
||||
|
||||
f: (x: T) => void;
|
||||
>f : (x: T) => void
|
||||
>x : T
|
||||
}
|
||||
|
||||
type Invariant1<in T> = { // Error
|
||||
>Invariant1 : Invariant1<T>
|
||||
|
||||
f: (x: T) => T;
|
||||
>f : (x: T) => T
|
||||
>x : T
|
||||
}
|
||||
|
||||
type Invariant2<out T> = { // Error
|
||||
>Invariant2 : Invariant2<T>
|
||||
|
||||
f: (x: T) => T;
|
||||
>f : (x: T) => T
|
||||
>x : T
|
||||
}
|
||||
|
||||
// Variance in circular types
|
||||
|
||||
type Foo1<in T> = { // Error
|
||||
>Foo1 : Foo1<T>
|
||||
|
||||
x: T;
|
||||
>x : T
|
||||
|
||||
f: FooFn1<T>;
|
||||
>f : FooFn1<T>
|
||||
}
|
||||
|
||||
type FooFn1<T> = (foo: Bar1<T[]>) => void;
|
||||
>FooFn1 : FooFn1<T>
|
||||
>foo : Bar1<T[]>
|
||||
|
||||
type Bar1<T> = {
|
||||
>Bar1 : Bar1<T>
|
||||
|
||||
value: Foo1<T[]>;
|
||||
>value : Foo1<T[]>
|
||||
}
|
||||
|
||||
type Foo2<out T> = { // Error
|
||||
>Foo2 : Foo2<T>
|
||||
|
||||
x: T;
|
||||
>x : T
|
||||
|
||||
f: FooFn2<T>;
|
||||
>f : FooFn2<T>
|
||||
}
|
||||
|
||||
type FooFn2<T> = (foo: Bar2<T[]>) => void;
|
||||
>FooFn2 : FooFn2<T>
|
||||
>foo : Bar2<T[]>
|
||||
|
||||
type Bar2<T> = {
|
||||
>Bar2 : Bar2<T>
|
||||
|
||||
value: Foo2<T[]>;
|
||||
>value : Foo2<T[]>
|
||||
}
|
||||
|
||||
type Foo3<in out T> = {
|
||||
>Foo3 : Foo3<T>
|
||||
|
||||
x: T;
|
||||
>x : T
|
||||
|
||||
f: FooFn3<T>;
|
||||
>f : FooFn3<T>
|
||||
}
|
||||
|
||||
type FooFn3<T> = (foo: Bar3<T[]>) => void;
|
||||
>FooFn3 : FooFn3<T>
|
||||
>foo : Bar3<T[]>
|
||||
|
||||
type Bar3<T> = {
|
||||
>Bar3 : Bar3<T>
|
||||
|
||||
value: Foo3<T[]>;
|
||||
>value : Foo3<T[]>
|
||||
}
|
||||
|
||||
// Wrong modifier usage
|
||||
|
||||
type T20<public T> = T; // Error
|
||||
>T20 : T
|
||||
|
||||
type T21<in out in T> = T; // Error
|
||||
>T21 : T
|
||||
|
||||
type T22<in out out T> = T; // Error
|
||||
>T22 : T
|
||||
|
||||
type T23<out in T> = T; // Error
|
||||
>T23 : T
|
||||
|
||||
declare function f1<in T>(x: T): void; // Error
|
||||
>f1 : <in T>(x: T) => void
|
||||
>x : T
|
||||
|
||||
declare function f2<out T>(): T; // Error
|
||||
>f2 : <out T>() => T
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
in a = 0; // Error
|
||||
>a : number
|
||||
>0 : 0
|
||||
|
||||
out b = 0; // Error
|
||||
>b : number
|
||||
>0 : 0
|
||||
}
|
||||
|
||||
// Interface merging
|
||||
|
||||
interface Baz<out T> {}
|
||||
interface Baz<in T> {}
|
||||
|
||||
declare let baz1: Baz<unknown>;
|
||||
>baz1 : Baz<unknown>
|
||||
|
||||
declare let baz2: Baz<string>;
|
||||
>baz2 : Baz<string>
|
||||
|
||||
baz1 = baz2; // Error
|
||||
>baz1 = baz2 : Baz<string>
|
||||
>baz1 : Baz<unknown>
|
||||
>baz2 : Baz<string>
|
||||
|
||||
baz2 = baz1; // Error
|
||||
>baz2 = baz1 : Baz<unknown>
|
||||
>baz2 : Baz<string>
|
||||
>baz1 : Baz<unknown>
|
||||
|
||||
// Repro from #44572
|
||||
|
||||
interface Parent<out A> {
|
||||
child: Child<A> | null;
|
||||
>child : Child<A, unknown> | null
|
||||
>null : null
|
||||
|
||||
parent: Parent<A> | null;
|
||||
>parent : Parent<A> | null
|
||||
>null : null
|
||||
}
|
||||
|
||||
interface Child<A, B = unknown> extends Parent<A> {
|
||||
readonly a: A;
|
||||
>a : A
|
||||
|
||||
readonly b: B;
|
||||
>b : B
|
||||
}
|
||||
|
||||
function fn<A>(inp: Child<A>) {
|
||||
>fn : <A>(inp: Child<A>) => void
|
||||
>inp : Child<A, unknown>
|
||||
|
||||
const a: Child<unknown> = inp;
|
||||
>a : Child<unknown, unknown>
|
||||
>inp : Child<A, unknown>
|
||||
}
|
||||
|
||||
const pu: Parent<unknown> = { child: { a: 0, b: 0, child: null, parent: null }, parent: null };
|
||||
>pu : Parent<unknown>
|
||||
>{ child: { a: 0, b: 0, child: null, parent: null }, parent: null } : { child: { a: number; b: number; child: null; parent: null; }; parent: null; }
|
||||
>child : { a: number; b: number; child: null; parent: null; }
|
||||
>{ a: 0, b: 0, child: null, parent: null } : { a: number; b: number; child: null; parent: null; }
|
||||
>a : number
|
||||
>0 : 0
|
||||
>b : number
|
||||
>0 : 0
|
||||
>child : null
|
||||
>null : null
|
||||
>parent : null
|
||||
>null : null
|
||||
>parent : null
|
||||
>null : null
|
||||
|
||||
const notString: Parent<string> = pu; // Error
|
||||
>notString : Parent<string>
|
||||
>pu : Parent<unknown>
|
||||
|
||||
// Repro from comment in #44572
|
||||
|
||||
declare class StateNode<TContext, in out TEvent extends { type: string }> {
|
||||
>StateNode : StateNode<TContext, TEvent>
|
||||
>type : string
|
||||
|
||||
_storedEvent: TEvent;
|
||||
>_storedEvent : TEvent
|
||||
|
||||
_action: ActionObject<TEvent>;
|
||||
>_action : ActionObject<TEvent>
|
||||
|
||||
_state: StateNode<TContext, any>;
|
||||
>_state : StateNode<TContext, any>
|
||||
}
|
||||
|
||||
interface ActionObject<TEvent extends { type: string }> {
|
||||
>type : string
|
||||
|
||||
exec: (meta: StateNode<any, TEvent>) => void;
|
||||
>exec : (meta: StateNode<any, TEvent>) => void
|
||||
>meta : StateNode<any, TEvent>
|
||||
}
|
||||
|
||||
declare function createMachine<TEvent extends { type: string }>(action: ActionObject<TEvent>): StateNode<any, any>;
|
||||
>createMachine : <TEvent extends { type: string; }>(action: ActionObject<TEvent>) => StateNode<any, any>
|
||||
>type : string
|
||||
>action : ActionObject<TEvent>
|
||||
|
||||
declare function interpret<TContext>(machine: StateNode<TContext, any>): void;
|
||||
>interpret : <TContext>(machine: StateNode<TContext, any>) => void
|
||||
>machine : StateNode<TContext, any>
|
||||
|
||||
const machine = createMachine({} as any);
|
||||
>machine : StateNode<any, any>
|
||||
>createMachine({} as any) : StateNode<any, any>
|
||||
>createMachine : <TEvent extends { type: string; }>(action: ActionObject<TEvent>) => StateNode<any, any>
|
||||
>{} as any : any
|
||||
>{} : {}
|
||||
|
||||
interpret(machine);
|
||||
>interpret(machine) : void
|
||||
>interpret : <TContext>(machine: StateNode<TContext, any>) => void
|
||||
>machine : StateNode<any, any>
|
||||
|
||||
declare const qq: ActionObject<{ type: "PLAY"; value: number }>;
|
||||
>qq : ActionObject<{ type: "PLAY"; value: number; }>
|
||||
>type : "PLAY"
|
||||
>value : number
|
||||
|
||||
createMachine<{ type: "PLAY"; value: number } | { type: "RESET" }>(qq); // Error
|
||||
>createMachine<{ type: "PLAY"; value: number } | { type: "RESET" }>(qq) : StateNode<any, any>
|
||||
>createMachine : <TEvent extends { type: string; }>(action: ActionObject<TEvent>) => StateNode<any, any>
|
||||
>type : "PLAY"
|
||||
>value : number
|
||||
>type : "RESET"
|
||||
>qq : ActionObject<{ type: "PLAY"; value: number; }>
|
||||
|
||||
+163
@@ -0,0 +1,163 @@
|
||||
// @strict: true
|
||||
// @declaration: true
|
||||
|
||||
type Covariant<out T> = {
|
||||
x: T;
|
||||
}
|
||||
|
||||
declare let super_covariant: Covariant<unknown>;
|
||||
declare let sub_covariant: Covariant<string>;
|
||||
|
||||
super_covariant = sub_covariant;
|
||||
sub_covariant = super_covariant; // Error
|
||||
|
||||
type Contravariant<in T> = {
|
||||
f: (x: T) => void;
|
||||
}
|
||||
|
||||
declare let super_contravariant: Contravariant<unknown>;
|
||||
declare let sub_contravariant: Contravariant<string>;
|
||||
|
||||
super_contravariant = sub_contravariant; // Error
|
||||
sub_contravariant = super_contravariant;
|
||||
|
||||
type Invariant<in out T> = {
|
||||
f: (x: T) => T;
|
||||
}
|
||||
|
||||
declare let super_invariant: Invariant<unknown>;
|
||||
declare let sub_invariant: Invariant<string>;
|
||||
|
||||
super_invariant = sub_invariant; // Error
|
||||
sub_invariant = super_invariant; // Error
|
||||
|
||||
// Variance of various type constructors
|
||||
|
||||
type T10<out T> = T;
|
||||
type T11<in T> = keyof T;
|
||||
type T12<out T, out K extends keyof T> = T[K];
|
||||
type T13<in out T> = T[keyof T];
|
||||
|
||||
// Variance annotation errors
|
||||
|
||||
type Covariant1<in T> = { // Error
|
||||
x: T;
|
||||
}
|
||||
|
||||
type Contravariant1<out T> = keyof T; // Error
|
||||
|
||||
type Contravariant2<out T> = { // Error
|
||||
f: (x: T) => void;
|
||||
}
|
||||
|
||||
type Invariant1<in T> = { // Error
|
||||
f: (x: T) => T;
|
||||
}
|
||||
|
||||
type Invariant2<out T> = { // Error
|
||||
f: (x: T) => T;
|
||||
}
|
||||
|
||||
// Variance in circular types
|
||||
|
||||
type Foo1<in T> = { // Error
|
||||
x: T;
|
||||
f: FooFn1<T>;
|
||||
}
|
||||
|
||||
type FooFn1<T> = (foo: Bar1<T[]>) => void;
|
||||
|
||||
type Bar1<T> = {
|
||||
value: Foo1<T[]>;
|
||||
}
|
||||
|
||||
type Foo2<out T> = { // Error
|
||||
x: T;
|
||||
f: FooFn2<T>;
|
||||
}
|
||||
|
||||
type FooFn2<T> = (foo: Bar2<T[]>) => void;
|
||||
|
||||
type Bar2<T> = {
|
||||
value: Foo2<T[]>;
|
||||
}
|
||||
|
||||
type Foo3<in out T> = {
|
||||
x: T;
|
||||
f: FooFn3<T>;
|
||||
}
|
||||
|
||||
type FooFn3<T> = (foo: Bar3<T[]>) => void;
|
||||
|
||||
type Bar3<T> = {
|
||||
value: Foo3<T[]>;
|
||||
}
|
||||
|
||||
// Wrong modifier usage
|
||||
|
||||
type T20<public T> = T; // Error
|
||||
type T21<in out in T> = T; // Error
|
||||
type T22<in out out T> = T; // Error
|
||||
type T23<out in T> = T; // Error
|
||||
|
||||
declare function f1<in T>(x: T): void; // Error
|
||||
declare function f2<out T>(): T; // Error
|
||||
|
||||
class C {
|
||||
in a = 0; // Error
|
||||
out b = 0; // Error
|
||||
}
|
||||
|
||||
// Interface merging
|
||||
|
||||
interface Baz<out T> {}
|
||||
interface Baz<in T> {}
|
||||
|
||||
declare let baz1: Baz<unknown>;
|
||||
declare let baz2: Baz<string>;
|
||||
|
||||
baz1 = baz2; // Error
|
||||
baz2 = baz1; // Error
|
||||
|
||||
// Repro from #44572
|
||||
|
||||
interface Parent<out A> {
|
||||
child: Child<A> | null;
|
||||
parent: Parent<A> | null;
|
||||
}
|
||||
|
||||
interface Child<A, B = unknown> extends Parent<A> {
|
||||
readonly a: A;
|
||||
readonly b: B;
|
||||
}
|
||||
|
||||
function fn<A>(inp: Child<A>) {
|
||||
const a: Child<unknown> = inp;
|
||||
}
|
||||
|
||||
const pu: Parent<unknown> = { child: { a: 0, b: 0, child: null, parent: null }, parent: null };
|
||||
const notString: Parent<string> = pu; // Error
|
||||
|
||||
// Repro from comment in #44572
|
||||
|
||||
declare class StateNode<TContext, in out TEvent extends { type: string }> {
|
||||
_storedEvent: TEvent;
|
||||
_action: ActionObject<TEvent>;
|
||||
_state: StateNode<TContext, any>;
|
||||
}
|
||||
|
||||
interface ActionObject<TEvent extends { type: string }> {
|
||||
exec: (meta: StateNode<any, TEvent>) => void;
|
||||
}
|
||||
|
||||
declare function createMachine<TEvent extends { type: string }>(action: ActionObject<TEvent>): StateNode<any, any>;
|
||||
|
||||
declare function interpret<TContext>(machine: StateNode<TContext, any>): void;
|
||||
|
||||
const machine = createMachine({} as any);
|
||||
|
||||
interpret(machine);
|
||||
|
||||
declare const qq: ActionObject<{ type: "PLAY"; value: number }>;
|
||||
|
||||
createMachine<{ type: "PLAY"; value: number } | { type: "RESET" }>(qq); // Error
|
||||
Reference in New Issue
Block a user