mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-11 17:41:26 -06:00
This commit is contained in:
parent
fe2cb8ebaa
commit
29d92edd1c
@ -41147,7 +41147,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
const modifiers = getTypeParameterModifiers(typeParameter) & (ModifierFlags.In | ModifierFlags.Out);
|
||||
if (modifiers) {
|
||||
const symbol = getSymbolOfDeclaration(node.parent);
|
||||
if (isTypeAliasDeclaration(node.parent) && !(getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (ObjectFlags.Reference | ObjectFlags.Anonymous | ObjectFlags.Mapped))) {
|
||||
if (isTypeAliasDeclaration(node.parent) && !(getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (ObjectFlags.Anonymous | ObjectFlags.Mapped))) {
|
||||
error(node, Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types);
|
||||
}
|
||||
else if (modifiers === ModifierFlags.In || modifiers === ModifierFlags.Out) {
|
||||
|
||||
@ -1,9 +1,23 @@
|
||||
varianceReferences.ts(3,32): error TS2637: Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.
|
||||
varianceReferences.ts(8,28): error TS2637: Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.
|
||||
varianceReferences.ts(14,32): error TS2637: Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.
|
||||
varianceReferences.ts(9,1): error TS2322: Type '1 | 2' is not assignable to type '1'.
|
||||
Type '2' is not assignable to type '1'.
|
||||
varianceReferences.ts(14,28): error TS2637: Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.
|
||||
varianceReferences.ts(19,1): error TS2322: Type '1 | 2' is not assignable to type '1'.
|
||||
Type '2' is not assignable to type '1'.
|
||||
varianceReferences.ts(26,32): error TS2637: Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.
|
||||
varianceReferences.ts(31,1): error TS2322: Type '1 | 2' is not assignable to type '1'.
|
||||
Type '2' is not assignable to type '1'.
|
||||
varianceReferences.ts(38,20): error TS2637: Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.
|
||||
varianceReferences.ts(43,1): error TS2322: Type 'VarianceShape<1 | 2>' is not assignable to type 'VarianceShape<1>'.
|
||||
Type '1 | 2' is not assignable to type '1'.
|
||||
Type '2' is not assignable to type '1'.
|
||||
varianceReferences.ts(53,24): error TS2637: Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.
|
||||
varianceReferences.ts(58,1): error TS2322: Type 'VarianceDeepShape<1 | 2>' is not assignable to type 'VarianceDeepShape<1>'.
|
||||
Type '1 | 2' is not assignable to type '1'.
|
||||
Type '2' is not assignable to type '1'.
|
||||
|
||||
|
||||
==== varianceReferences.ts (3 errors) ====
|
||||
==== varianceReferences.ts (10 errors) ====
|
||||
type NumericConstraint<Value extends number> = Value;
|
||||
|
||||
type VarianceConstrainedNumber<in out Value extends number> =
|
||||
@ -11,12 +25,30 @@ varianceReferences.ts(14,32): error TS2637: Variance annotations are only suppor
|
||||
!!! error TS2637: Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.
|
||||
NumericConstraint<Value>;
|
||||
|
||||
declare let vcn1: VarianceConstrainedNumber<1>;
|
||||
declare let vcn12: VarianceConstrainedNumber<1 | 2>;
|
||||
|
||||
vcn1 = vcn12;
|
||||
~~~~
|
||||
!!! error TS2322: Type '1 | 2' is not assignable to type '1'.
|
||||
!!! error TS2322: Type '2' is not assignable to type '1'.
|
||||
vcn12 = vcn1;
|
||||
|
||||
type Unconstrained<Value> = Value;
|
||||
|
||||
type VarianceUnconstrained<in out Value> = Unconstrained<Value>;
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2637: Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.
|
||||
|
||||
declare let vu1: VarianceUnconstrained<1>;
|
||||
declare let vu12: VarianceUnconstrained<1 | 2>;
|
||||
|
||||
vu1 = vu12;
|
||||
~~~
|
||||
!!! error TS2322: Type '1 | 2' is not assignable to type '1'.
|
||||
!!! error TS2322: Type '2' is not assignable to type '1'.
|
||||
vu12 = vu1;
|
||||
|
||||
type Level3of3Unconstrained<Value> = Value;
|
||||
type Level2of3Unconstrained<Value> = Level3of3Unconstrained<Value>;
|
||||
type Level1of3Unconstrained<Value> = Level2of3Unconstrained<Value>;
|
||||
@ -25,11 +57,32 @@ varianceReferences.ts(14,32): error TS2637: Variance annotations are only suppor
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2637: Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.
|
||||
|
||||
declare let vdu1: VarianceDeepUnconstrained<1>;
|
||||
declare let vdu12: VarianceDeepUnconstrained<1 | 2>;
|
||||
|
||||
vdu1 = vdu12;
|
||||
~~~~
|
||||
!!! error TS2322: Type '1 | 2' is not assignable to type '1'.
|
||||
!!! error TS2322: Type '2' is not assignable to type '1'.
|
||||
vdu12 = vdu1;
|
||||
|
||||
interface Shape<Value> {
|
||||
value: Value;
|
||||
}
|
||||
|
||||
type VarianceShape<in out Value> = Shape<Value>;
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2637: Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.
|
||||
|
||||
declare let vs1: VarianceShape<1>;
|
||||
declare let vs12: VarianceShape<1 | 2>;
|
||||
|
||||
vs1 = vs12;
|
||||
~~~
|
||||
!!! error TS2322: Type 'VarianceShape<1 | 2>' is not assignable to type 'VarianceShape<1>'.
|
||||
!!! error TS2322: Type '1 | 2' is not assignable to type '1'.
|
||||
!!! error TS2322: Type '2' is not assignable to type '1'.
|
||||
vs12 = vs1;
|
||||
|
||||
interface Level3of3Shape<Value> {
|
||||
value: Value;
|
||||
@ -39,4 +92,16 @@ varianceReferences.ts(14,32): error TS2637: Variance annotations are only suppor
|
||||
type Level1of3Shape<Value> = Level2of3Shape<Value>;
|
||||
|
||||
type VarianceDeepShape<in out Value> = Level1of3Shape<Value>;
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2637: Variance annotations are only supported in type aliases for object, function, constructor, and mapped types.
|
||||
|
||||
declare let vds1: VarianceDeepShape<1>;
|
||||
declare let vds12: VarianceDeepShape<1 | 2>;
|
||||
|
||||
vds1 = vds12;
|
||||
~~~~
|
||||
!!! error TS2322: Type 'VarianceDeepShape<1 | 2>' is not assignable to type 'VarianceDeepShape<1>'.
|
||||
!!! error TS2322: Type '1 | 2' is not assignable to type '1'.
|
||||
!!! error TS2322: Type '2' is not assignable to type '1'.
|
||||
vds12 = vds1;
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
//// [tests/cases/compiler/varianceReferences.ts] ////
|
||||
|
||||
//// [varianceReferences.ts]
|
||||
type NumericConstraint<Value extends number> = Value;
|
||||
|
||||
type VarianceConstrainedNumber<in out Value extends number> =
|
||||
NumericConstraint<Value>;
|
||||
|
||||
type Unconstrained<Value> = Value;
|
||||
|
||||
type VarianceUnconstrained<in out Value> = Unconstrained<Value>;
|
||||
|
||||
type Level3of3Unconstrained<Value> = Value;
|
||||
type Level2of3Unconstrained<Value> = Level3of3Unconstrained<Value>;
|
||||
type Level1of3Unconstrained<Value> = Level2of3Unconstrained<Value>;
|
||||
|
||||
type VarianceDeepUnconstrained<in out Value> = Level1of3Unconstrained<Value>;
|
||||
|
||||
interface Shape<Value> {
|
||||
value: Value;
|
||||
}
|
||||
|
||||
type VarianceShape<in out Value> = Shape<Value>;
|
||||
|
||||
interface Level3of3Shape<Value> {
|
||||
value: Value;
|
||||
}
|
||||
|
||||
type Level2of3Shape<Value> = Level3of3Shape<Value>;
|
||||
type Level1of3Shape<Value> = Level2of3Shape<Value>;
|
||||
|
||||
type VarianceDeepShape<in out Value> = Level1of3Shape<Value>;
|
||||
|
||||
|
||||
//// [varianceReferences.js]
|
||||
@ -14,79 +14,159 @@ type VarianceConstrainedNumber<in out Value extends number> =
|
||||
>NumericConstraint : Symbol(NumericConstraint, Decl(varianceReferences.ts, 0, 0))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 2, 31))
|
||||
|
||||
declare let vcn1: VarianceConstrainedNumber<1>;
|
||||
>vcn1 : Symbol(vcn1, Decl(varianceReferences.ts, 5, 11))
|
||||
>VarianceConstrainedNumber : Symbol(VarianceConstrainedNumber, Decl(varianceReferences.ts, 0, 53))
|
||||
|
||||
declare let vcn12: VarianceConstrainedNumber<1 | 2>;
|
||||
>vcn12 : Symbol(vcn12, Decl(varianceReferences.ts, 6, 11))
|
||||
>VarianceConstrainedNumber : Symbol(VarianceConstrainedNumber, Decl(varianceReferences.ts, 0, 53))
|
||||
|
||||
vcn1 = vcn12;
|
||||
>vcn1 : Symbol(vcn1, Decl(varianceReferences.ts, 5, 11))
|
||||
>vcn12 : Symbol(vcn12, Decl(varianceReferences.ts, 6, 11))
|
||||
|
||||
vcn12 = vcn1;
|
||||
>vcn12 : Symbol(vcn12, Decl(varianceReferences.ts, 6, 11))
|
||||
>vcn1 : Symbol(vcn1, Decl(varianceReferences.ts, 5, 11))
|
||||
|
||||
type Unconstrained<Value> = Value;
|
||||
>Unconstrained : Symbol(Unconstrained, Decl(varianceReferences.ts, 3, 27))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 5, 19))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 5, 19))
|
||||
>Unconstrained : Symbol(Unconstrained, Decl(varianceReferences.ts, 9, 13))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 11, 19))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 11, 19))
|
||||
|
||||
type VarianceUnconstrained<in out Value> = Unconstrained<Value>;
|
||||
>VarianceUnconstrained : Symbol(VarianceUnconstrained, Decl(varianceReferences.ts, 5, 34))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 7, 27))
|
||||
>Unconstrained : Symbol(Unconstrained, Decl(varianceReferences.ts, 3, 27))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 7, 27))
|
||||
>VarianceUnconstrained : Symbol(VarianceUnconstrained, Decl(varianceReferences.ts, 11, 34))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 13, 27))
|
||||
>Unconstrained : Symbol(Unconstrained, Decl(varianceReferences.ts, 9, 13))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 13, 27))
|
||||
|
||||
declare let vu1: VarianceUnconstrained<1>;
|
||||
>vu1 : Symbol(vu1, Decl(varianceReferences.ts, 15, 11))
|
||||
>VarianceUnconstrained : Symbol(VarianceUnconstrained, Decl(varianceReferences.ts, 11, 34))
|
||||
|
||||
declare let vu12: VarianceUnconstrained<1 | 2>;
|
||||
>vu12 : Symbol(vu12, Decl(varianceReferences.ts, 16, 11))
|
||||
>VarianceUnconstrained : Symbol(VarianceUnconstrained, Decl(varianceReferences.ts, 11, 34))
|
||||
|
||||
vu1 = vu12;
|
||||
>vu1 : Symbol(vu1, Decl(varianceReferences.ts, 15, 11))
|
||||
>vu12 : Symbol(vu12, Decl(varianceReferences.ts, 16, 11))
|
||||
|
||||
vu12 = vu1;
|
||||
>vu12 : Symbol(vu12, Decl(varianceReferences.ts, 16, 11))
|
||||
>vu1 : Symbol(vu1, Decl(varianceReferences.ts, 15, 11))
|
||||
|
||||
type Level3of3Unconstrained<Value> = Value;
|
||||
>Level3of3Unconstrained : Symbol(Level3of3Unconstrained, Decl(varianceReferences.ts, 7, 64))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 9, 28))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 9, 28))
|
||||
>Level3of3Unconstrained : Symbol(Level3of3Unconstrained, Decl(varianceReferences.ts, 19, 11))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 21, 28))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 21, 28))
|
||||
|
||||
type Level2of3Unconstrained<Value> = Level3of3Unconstrained<Value>;
|
||||
>Level2of3Unconstrained : Symbol(Level2of3Unconstrained, Decl(varianceReferences.ts, 9, 43))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 10, 28))
|
||||
>Level3of3Unconstrained : Symbol(Level3of3Unconstrained, Decl(varianceReferences.ts, 7, 64))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 10, 28))
|
||||
>Level2of3Unconstrained : Symbol(Level2of3Unconstrained, Decl(varianceReferences.ts, 21, 43))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 22, 28))
|
||||
>Level3of3Unconstrained : Symbol(Level3of3Unconstrained, Decl(varianceReferences.ts, 19, 11))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 22, 28))
|
||||
|
||||
type Level1of3Unconstrained<Value> = Level2of3Unconstrained<Value>;
|
||||
>Level1of3Unconstrained : Symbol(Level1of3Unconstrained, Decl(varianceReferences.ts, 10, 67))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 11, 28))
|
||||
>Level2of3Unconstrained : Symbol(Level2of3Unconstrained, Decl(varianceReferences.ts, 9, 43))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 11, 28))
|
||||
>Level1of3Unconstrained : Symbol(Level1of3Unconstrained, Decl(varianceReferences.ts, 22, 67))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 23, 28))
|
||||
>Level2of3Unconstrained : Symbol(Level2of3Unconstrained, Decl(varianceReferences.ts, 21, 43))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 23, 28))
|
||||
|
||||
type VarianceDeepUnconstrained<in out Value> = Level1of3Unconstrained<Value>;
|
||||
>VarianceDeepUnconstrained : Symbol(VarianceDeepUnconstrained, Decl(varianceReferences.ts, 11, 67))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 13, 31))
|
||||
>Level1of3Unconstrained : Symbol(Level1of3Unconstrained, Decl(varianceReferences.ts, 10, 67))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 13, 31))
|
||||
>VarianceDeepUnconstrained : Symbol(VarianceDeepUnconstrained, Decl(varianceReferences.ts, 23, 67))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 25, 31))
|
||||
>Level1of3Unconstrained : Symbol(Level1of3Unconstrained, Decl(varianceReferences.ts, 22, 67))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 25, 31))
|
||||
|
||||
declare let vdu1: VarianceDeepUnconstrained<1>;
|
||||
>vdu1 : Symbol(vdu1, Decl(varianceReferences.ts, 27, 11))
|
||||
>VarianceDeepUnconstrained : Symbol(VarianceDeepUnconstrained, Decl(varianceReferences.ts, 23, 67))
|
||||
|
||||
declare let vdu12: VarianceDeepUnconstrained<1 | 2>;
|
||||
>vdu12 : Symbol(vdu12, Decl(varianceReferences.ts, 28, 11))
|
||||
>VarianceDeepUnconstrained : Symbol(VarianceDeepUnconstrained, Decl(varianceReferences.ts, 23, 67))
|
||||
|
||||
vdu1 = vdu12;
|
||||
>vdu1 : Symbol(vdu1, Decl(varianceReferences.ts, 27, 11))
|
||||
>vdu12 : Symbol(vdu12, Decl(varianceReferences.ts, 28, 11))
|
||||
|
||||
vdu12 = vdu1;
|
||||
>vdu12 : Symbol(vdu12, Decl(varianceReferences.ts, 28, 11))
|
||||
>vdu1 : Symbol(vdu1, Decl(varianceReferences.ts, 27, 11))
|
||||
|
||||
interface Shape<Value> {
|
||||
>Shape : Symbol(Shape, Decl(varianceReferences.ts, 13, 77))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 15, 16))
|
||||
>Shape : Symbol(Shape, Decl(varianceReferences.ts, 31, 13))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 33, 16))
|
||||
|
||||
value: Value;
|
||||
>value : Symbol(Shape.value, Decl(varianceReferences.ts, 15, 24))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 15, 16))
|
||||
>value : Symbol(Shape.value, Decl(varianceReferences.ts, 33, 24))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 33, 16))
|
||||
}
|
||||
|
||||
type VarianceShape<in out Value> = Shape<Value>;
|
||||
>VarianceShape : Symbol(VarianceShape, Decl(varianceReferences.ts, 17, 1))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 19, 19))
|
||||
>Shape : Symbol(Shape, Decl(varianceReferences.ts, 13, 77))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 19, 19))
|
||||
>VarianceShape : Symbol(VarianceShape, Decl(varianceReferences.ts, 35, 1))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 37, 19))
|
||||
>Shape : Symbol(Shape, Decl(varianceReferences.ts, 31, 13))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 37, 19))
|
||||
|
||||
declare let vs1: VarianceShape<1>;
|
||||
>vs1 : Symbol(vs1, Decl(varianceReferences.ts, 39, 11))
|
||||
>VarianceShape : Symbol(VarianceShape, Decl(varianceReferences.ts, 35, 1))
|
||||
|
||||
declare let vs12: VarianceShape<1 | 2>;
|
||||
>vs12 : Symbol(vs12, Decl(varianceReferences.ts, 40, 11))
|
||||
>VarianceShape : Symbol(VarianceShape, Decl(varianceReferences.ts, 35, 1))
|
||||
|
||||
vs1 = vs12;
|
||||
>vs1 : Symbol(vs1, Decl(varianceReferences.ts, 39, 11))
|
||||
>vs12 : Symbol(vs12, Decl(varianceReferences.ts, 40, 11))
|
||||
|
||||
vs12 = vs1;
|
||||
>vs12 : Symbol(vs12, Decl(varianceReferences.ts, 40, 11))
|
||||
>vs1 : Symbol(vs1, Decl(varianceReferences.ts, 39, 11))
|
||||
|
||||
interface Level3of3Shape<Value> {
|
||||
>Level3of3Shape : Symbol(Level3of3Shape, Decl(varianceReferences.ts, 19, 48))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 21, 25))
|
||||
>Level3of3Shape : Symbol(Level3of3Shape, Decl(varianceReferences.ts, 43, 11))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 45, 25))
|
||||
|
||||
value: Value;
|
||||
>value : Symbol(Level3of3Shape.value, Decl(varianceReferences.ts, 21, 33))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 21, 25))
|
||||
>value : Symbol(Level3of3Shape.value, Decl(varianceReferences.ts, 45, 33))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 45, 25))
|
||||
}
|
||||
|
||||
type Level2of3Shape<Value> = Level3of3Shape<Value>;
|
||||
>Level2of3Shape : Symbol(Level2of3Shape, Decl(varianceReferences.ts, 23, 1))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 25, 20))
|
||||
>Level3of3Shape : Symbol(Level3of3Shape, Decl(varianceReferences.ts, 19, 48))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 25, 20))
|
||||
>Level2of3Shape : Symbol(Level2of3Shape, Decl(varianceReferences.ts, 47, 1))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 49, 20))
|
||||
>Level3of3Shape : Symbol(Level3of3Shape, Decl(varianceReferences.ts, 43, 11))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 49, 20))
|
||||
|
||||
type Level1of3Shape<Value> = Level2of3Shape<Value>;
|
||||
>Level1of3Shape : Symbol(Level1of3Shape, Decl(varianceReferences.ts, 25, 51))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 26, 20))
|
||||
>Level2of3Shape : Symbol(Level2of3Shape, Decl(varianceReferences.ts, 23, 1))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 26, 20))
|
||||
>Level1of3Shape : Symbol(Level1of3Shape, Decl(varianceReferences.ts, 49, 51))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 50, 20))
|
||||
>Level2of3Shape : Symbol(Level2of3Shape, Decl(varianceReferences.ts, 47, 1))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 50, 20))
|
||||
|
||||
type VarianceDeepShape<in out Value> = Level1of3Shape<Value>;
|
||||
>VarianceDeepShape : Symbol(VarianceDeepShape, Decl(varianceReferences.ts, 26, 51))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 28, 23))
|
||||
>Level1of3Shape : Symbol(Level1of3Shape, Decl(varianceReferences.ts, 25, 51))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 28, 23))
|
||||
>VarianceDeepShape : Symbol(VarianceDeepShape, Decl(varianceReferences.ts, 50, 51))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 52, 23))
|
||||
>Level1of3Shape : Symbol(Level1of3Shape, Decl(varianceReferences.ts, 49, 51))
|
||||
>Value : Symbol(Value, Decl(varianceReferences.ts, 52, 23))
|
||||
|
||||
declare let vds1: VarianceDeepShape<1>;
|
||||
>vds1 : Symbol(vds1, Decl(varianceReferences.ts, 54, 11))
|
||||
>VarianceDeepShape : Symbol(VarianceDeepShape, Decl(varianceReferences.ts, 50, 51))
|
||||
|
||||
declare let vds12: VarianceDeepShape<1 | 2>;
|
||||
>vds12 : Symbol(vds12, Decl(varianceReferences.ts, 55, 11))
|
||||
>VarianceDeepShape : Symbol(VarianceDeepShape, Decl(varianceReferences.ts, 50, 51))
|
||||
|
||||
vds1 = vds12;
|
||||
>vds1 : Symbol(vds1, Decl(varianceReferences.ts, 54, 11))
|
||||
>vds12 : Symbol(vds12, Decl(varianceReferences.ts, 55, 11))
|
||||
|
||||
vds12 = vds1;
|
||||
>vds12 : Symbol(vds12, Decl(varianceReferences.ts, 55, 11))
|
||||
>vds1 : Symbol(vds1, Decl(varianceReferences.ts, 54, 11))
|
||||
|
||||
|
||||
@ -11,6 +11,30 @@ type VarianceConstrainedNumber<in out Value extends number> =
|
||||
|
||||
NumericConstraint<Value>;
|
||||
|
||||
declare let vcn1: VarianceConstrainedNumber<1>;
|
||||
>vcn1 : 1
|
||||
> : ^
|
||||
|
||||
declare let vcn12: VarianceConstrainedNumber<1 | 2>;
|
||||
>vcn12 : 1 | 2
|
||||
> : ^^^^^
|
||||
|
||||
vcn1 = vcn12;
|
||||
>vcn1 = vcn12 : 1 | 2
|
||||
> : ^^^^^
|
||||
>vcn1 : 1
|
||||
> : ^
|
||||
>vcn12 : 1 | 2
|
||||
> : ^^^^^
|
||||
|
||||
vcn12 = vcn1;
|
||||
>vcn12 = vcn1 : 1
|
||||
> : ^
|
||||
>vcn12 : 1 | 2
|
||||
> : ^^^^^
|
||||
>vcn1 : 1
|
||||
> : ^
|
||||
|
||||
type Unconstrained<Value> = Value;
|
||||
>Unconstrained : Value
|
||||
> : ^^^^^
|
||||
@ -19,6 +43,30 @@ type VarianceUnconstrained<in out Value> = Unconstrained<Value>;
|
||||
>VarianceUnconstrained : Value
|
||||
> : ^^^^^
|
||||
|
||||
declare let vu1: VarianceUnconstrained<1>;
|
||||
>vu1 : 1
|
||||
> : ^
|
||||
|
||||
declare let vu12: VarianceUnconstrained<1 | 2>;
|
||||
>vu12 : 1 | 2
|
||||
> : ^^^^^
|
||||
|
||||
vu1 = vu12;
|
||||
>vu1 = vu12 : 1 | 2
|
||||
> : ^^^^^
|
||||
>vu1 : 1
|
||||
> : ^
|
||||
>vu12 : 1 | 2
|
||||
> : ^^^^^
|
||||
|
||||
vu12 = vu1;
|
||||
>vu12 = vu1 : 1
|
||||
> : ^
|
||||
>vu12 : 1 | 2
|
||||
> : ^^^^^
|
||||
>vu1 : 1
|
||||
> : ^
|
||||
|
||||
type Level3of3Unconstrained<Value> = Value;
|
||||
>Level3of3Unconstrained : Value
|
||||
> : ^^^^^
|
||||
@ -35,6 +83,30 @@ type VarianceDeepUnconstrained<in out Value> = Level1of3Unconstrained<Value>;
|
||||
>VarianceDeepUnconstrained : Value
|
||||
> : ^^^^^
|
||||
|
||||
declare let vdu1: VarianceDeepUnconstrained<1>;
|
||||
>vdu1 : 1
|
||||
> : ^
|
||||
|
||||
declare let vdu12: VarianceDeepUnconstrained<1 | 2>;
|
||||
>vdu12 : 1 | 2
|
||||
> : ^^^^^
|
||||
|
||||
vdu1 = vdu12;
|
||||
>vdu1 = vdu12 : 1 | 2
|
||||
> : ^^^^^
|
||||
>vdu1 : 1
|
||||
> : ^
|
||||
>vdu12 : 1 | 2
|
||||
> : ^^^^^
|
||||
|
||||
vdu12 = vdu1;
|
||||
>vdu12 = vdu1 : 1
|
||||
> : ^
|
||||
>vdu12 : 1 | 2
|
||||
> : ^^^^^
|
||||
>vdu1 : 1
|
||||
> : ^
|
||||
|
||||
interface Shape<Value> {
|
||||
value: Value;
|
||||
>value : Value
|
||||
@ -45,6 +117,30 @@ type VarianceShape<in out Value> = Shape<Value>;
|
||||
>VarianceShape : VarianceShape<Value>
|
||||
> : ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
declare let vs1: VarianceShape<1>;
|
||||
>vs1 : VarianceShape<1>
|
||||
> : ^^^^^^^^^^^^^^^^
|
||||
|
||||
declare let vs12: VarianceShape<1 | 2>;
|
||||
>vs12 : VarianceShape<1 | 2>
|
||||
> : ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
vs1 = vs12;
|
||||
>vs1 = vs12 : VarianceShape<1 | 2>
|
||||
> : ^^^^^^^^^^^^^^^^^^^^
|
||||
>vs1 : VarianceShape<1>
|
||||
> : ^^^^^^^^^^^^^^^^
|
||||
>vs12 : VarianceShape<1 | 2>
|
||||
> : ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
vs12 = vs1;
|
||||
>vs12 = vs1 : VarianceShape<1>
|
||||
> : ^^^^^^^^^^^^^^^^
|
||||
>vs12 : VarianceShape<1 | 2>
|
||||
> : ^^^^^^^^^^^^^^^^^^^^
|
||||
>vs1 : VarianceShape<1>
|
||||
> : ^^^^^^^^^^^^^^^^
|
||||
|
||||
interface Level3of3Shape<Value> {
|
||||
value: Value;
|
||||
>value : Value
|
||||
@ -63,3 +159,27 @@ type VarianceDeepShape<in out Value> = Level1of3Shape<Value>;
|
||||
>VarianceDeepShape : VarianceDeepShape<Value>
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
declare let vds1: VarianceDeepShape<1>;
|
||||
>vds1 : VarianceDeepShape<1>
|
||||
> : ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
declare let vds12: VarianceDeepShape<1 | 2>;
|
||||
>vds12 : VarianceDeepShape<1 | 2>
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
vds1 = vds12;
|
||||
>vds1 = vds12 : VarianceDeepShape<1 | 2>
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>vds1 : VarianceDeepShape<1>
|
||||
> : ^^^^^^^^^^^^^^^^^^^^
|
||||
>vds12 : VarianceDeepShape<1 | 2>
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
vds12 = vds1;
|
||||
>vds12 = vds1 : VarianceDeepShape<1>
|
||||
> : ^^^^^^^^^^^^^^^^^^^^
|
||||
>vds12 : VarianceDeepShape<1 | 2>
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>vds1 : VarianceDeepShape<1>
|
||||
> : ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
@ -1,24 +1,51 @@
|
||||
// @strict: true
|
||||
// @noEmit: true
|
||||
|
||||
type NumericConstraint<Value extends number> = Value;
|
||||
|
||||
type VarianceConstrainedNumber<in out Value extends number> =
|
||||
NumericConstraint<Value>;
|
||||
|
||||
declare let vcn1: VarianceConstrainedNumber<1>;
|
||||
declare let vcn12: VarianceConstrainedNumber<1 | 2>;
|
||||
|
||||
vcn1 = vcn12;
|
||||
vcn12 = vcn1;
|
||||
|
||||
type Unconstrained<Value> = Value;
|
||||
|
||||
type VarianceUnconstrained<in out Value> = Unconstrained<Value>;
|
||||
|
||||
declare let vu1: VarianceUnconstrained<1>;
|
||||
declare let vu12: VarianceUnconstrained<1 | 2>;
|
||||
|
||||
vu1 = vu12;
|
||||
vu12 = vu1;
|
||||
|
||||
type Level3of3Unconstrained<Value> = Value;
|
||||
type Level2of3Unconstrained<Value> = Level3of3Unconstrained<Value>;
|
||||
type Level1of3Unconstrained<Value> = Level2of3Unconstrained<Value>;
|
||||
|
||||
type VarianceDeepUnconstrained<in out Value> = Level1of3Unconstrained<Value>;
|
||||
|
||||
declare let vdu1: VarianceDeepUnconstrained<1>;
|
||||
declare let vdu12: VarianceDeepUnconstrained<1 | 2>;
|
||||
|
||||
vdu1 = vdu12;
|
||||
vdu12 = vdu1;
|
||||
|
||||
interface Shape<Value> {
|
||||
value: Value;
|
||||
}
|
||||
|
||||
type VarianceShape<in out Value> = Shape<Value>;
|
||||
|
||||
declare let vs1: VarianceShape<1>;
|
||||
declare let vs12: VarianceShape<1 | 2>;
|
||||
|
||||
vs1 = vs12;
|
||||
vs12 = vs1;
|
||||
|
||||
interface Level3of3Shape<Value> {
|
||||
value: Value;
|
||||
}
|
||||
@ -27,3 +54,9 @@ type Level2of3Shape<Value> = Level3of3Shape<Value>;
|
||||
type Level1of3Shape<Value> = Level2of3Shape<Value>;
|
||||
|
||||
type VarianceDeepShape<in out Value> = Level1of3Shape<Value>;
|
||||
|
||||
declare let vds1: VarianceDeepShape<1>;
|
||||
declare let vds12: VarianceDeepShape<1 | 2>;
|
||||
|
||||
vds1 = vds12;
|
||||
vds12 = vds1;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user