Skip to content

Commit a697946

Browse files
committed
accepted baseline changes
1 parent 2a56797 commit a697946

4 files changed

Lines changed: 49 additions & 62 deletions
Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
better_subType_assignable_to_superType_error_messsage.ts(13,3): error TS2322: Type 'SuperType' is not assignable to type 'SubType2'.
1+
better_subType_assignable_to_superType_error_messsage.ts(2,3): error TS2552: Cannot find name 'subtype'. Did you mean 'subType2'?
2+
better_subType_assignable_to_superType_error_messsage.ts(5,3): error TS2322: Type 'SuperType' is not assignable to type 'SubType2'.
23
'SubType2' is constrained to be a subtype of 'SuperType'.
34

45

5-
==== better_subType_assignable_to_superType_error_messsage.ts (1 errors) ====
6+
==== better_subType_assignable_to_superType_error_messsage.ts (2 errors) ====
67
function parameterExtendsOtherParameter<SuperType, SubType extends SuperType, SubType2 extends SubType>(superType: SuperType, subType2: SubType2) {
7-
// TS 3.3: Type 'SuperType' is not assignable to type 'SubType'.
8-
//
9-
// TS 3.5: Type 'SuperType' is not assignable to type 'SubType'.
10-
// 'SuperType' is assignable to the constraint of type 'SubType', but 'SubType' could be instantiated with a different subtype of constraint '{}'.
11-
//
12-
// TS 3.9: Type 'SuperType' is not assignable to type 'SubType'.
13-
// 'SubType' could be instantiated with an arbitrary type which could be unrelated to 'SuperType'.
14-
//
15-
// TS 4.8: Type 'SuperType' is not assignable to type 'SubType'.
16-
// 'SubType' could be instantiated with an arbitrary type which could be unrelated to 'SuperType'.
17-
// input.tsx(1, 41): This type parameter might need an `extends V` constraint.
18-
subType2 = superType;
8+
subtype = superType;//error
9+
~~~~~~~
10+
!!! error TS2552: Cannot find name 'subtype'. Did you mean 'subType2'?
11+
!!! related TS2728 better_subType_assignable_to_superType_error_messsage.ts:1:127: 'subType2' is declared here.
12+
13+
//ensures that supertypes are not assignable to 'grandchild' subtypes
14+
subType2 = superType;//error
1915
~~~~~~~~
2016
!!! error TS2322: Type 'SuperType' is not assignable to type 'SubType2'.
2117
!!! error TS2322: 'SubType2' is constrained to be a subtype of 'SuperType'.
2218
!!! related TS2208 better_subType_assignable_to_superType_error_messsage.ts:1:41: This type parameter might need an `extends SubType2` constraint.
19+
20+
superType = subType2;//ok
2321
}
2422

tests/baselines/reference/better_subType_assignable_to_superType_error_messsage.js

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,19 @@
22

33
//// [better_subType_assignable_to_superType_error_messsage.ts]
44
function parameterExtendsOtherParameter<SuperType, SubType extends SuperType, SubType2 extends SubType>(superType: SuperType, subType2: SubType2) {
5-
// TS 3.3: Type 'SuperType' is not assignable to type 'SubType'.
6-
//
7-
// TS 3.5: Type 'SuperType' is not assignable to type 'SubType'.
8-
// 'SuperType' is assignable to the constraint of type 'SubType', but 'SubType' could be instantiated with a different subtype of constraint '{}'.
9-
//
10-
// TS 3.9: Type 'SuperType' is not assignable to type 'SubType'.
11-
// 'SubType' could be instantiated with an arbitrary type which could be unrelated to 'SuperType'.
12-
//
13-
// TS 4.8: Type 'SuperType' is not assignable to type 'SubType'.
14-
// 'SubType' could be instantiated with an arbitrary type which could be unrelated to 'SuperType'.
15-
// input.tsx(1, 41): This type parameter might need an `extends V` constraint.
16-
subType2 = superType;
5+
subtype = superType;//error
6+
7+
//ensures that supertypes are not assignable to 'grandchild' subtypes
8+
subType2 = superType;//error
9+
10+
superType = subType2;//ok
1711
}
1812

1913

2014
//// [better_subType_assignable_to_superType_error_messsage.js]
2115
function parameterExtendsOtherParameter(superType, subType2) {
22-
// TS 3.3: Type 'SuperType' is not assignable to type 'SubType'.
23-
//
24-
// TS 3.5: Type 'SuperType' is not assignable to type 'SubType'.
25-
// 'SuperType' is assignable to the constraint of type 'SubType', but 'SubType' could be instantiated with a different subtype of constraint '{}'.
26-
//
27-
// TS 3.9: Type 'SuperType' is not assignable to type 'SubType'.
28-
// 'SubType' could be instantiated with an arbitrary type which could be unrelated to 'SuperType'.
29-
//
30-
// TS 4.8: Type 'SuperType' is not assignable to type 'SubType'.
31-
// 'SubType' could be instantiated with an arbitrary type which could be unrelated to 'SuperType'.
32-
// input.tsx(1, 41): This type parameter might need an `extends V` constraint.
33-
subType2 = superType;
16+
subtype = superType; //error
17+
//ensures that supertypes are not assignable to 'grandchild' subtypes
18+
subType2 = superType; //error
19+
superType = subType2; //ok
3420
}

tests/baselines/reference/better_subType_assignable_to_superType_error_messsage.symbols

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,16 @@ function parameterExtendsOtherParameter<SuperType, SubType extends SuperType, Su
1313
>subType2 : Symbol(subType2, Decl(better_subType_assignable_to_superType_error_messsage.ts, 0, 125))
1414
>SubType2 : Symbol(SubType2, Decl(better_subType_assignable_to_superType_error_messsage.ts, 0, 77))
1515

16-
// TS 3.3: Type 'SuperType' is not assignable to type 'SubType'.
17-
//
18-
// TS 3.5: Type 'SuperType' is not assignable to type 'SubType'.
19-
// 'SuperType' is assignable to the constraint of type 'SubType', but 'SubType' could be instantiated with a different subtype of constraint '{}'.
20-
//
21-
// TS 3.9: Type 'SuperType' is not assignable to type 'SubType'.
22-
// 'SubType' could be instantiated with an arbitrary type which could be unrelated to 'SuperType'.
23-
//
24-
// TS 4.8: Type 'SuperType' is not assignable to type 'SubType'.
25-
// 'SubType' could be instantiated with an arbitrary type which could be unrelated to 'SuperType'.
26-
// input.tsx(1, 41): This type parameter might need an `extends V` constraint.
27-
subType2 = superType;
16+
subtype = superType;//error
17+
>superType : Symbol(superType, Decl(better_subType_assignable_to_superType_error_messsage.ts, 0, 104))
18+
19+
//ensures that supertypes are not assignable to 'grandchild' subtypes
20+
subType2 = superType;//error
2821
>subType2 : Symbol(subType2, Decl(better_subType_assignable_to_superType_error_messsage.ts, 0, 125))
2922
>superType : Symbol(superType, Decl(better_subType_assignable_to_superType_error_messsage.ts, 0, 104))
23+
24+
superType = subType2;//ok
25+
>superType : Symbol(superType, Decl(better_subType_assignable_to_superType_error_messsage.ts, 0, 104))
26+
>subType2 : Symbol(subType2, Decl(better_subType_assignable_to_superType_error_messsage.ts, 0, 125))
3027
}
3128

tests/baselines/reference/better_subType_assignable_to_superType_error_messsage.types

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,29 @@ function parameterExtendsOtherParameter<SuperType, SubType extends SuperType, Su
99
>subType2 : SubType2
1010
> : ^^^^^^^^
1111

12-
// TS 3.3: Type 'SuperType' is not assignable to type 'SubType'.
13-
//
14-
// TS 3.5: Type 'SuperType' is not assignable to type 'SubType'.
15-
// 'SuperType' is assignable to the constraint of type 'SubType', but 'SubType' could be instantiated with a different subtype of constraint '{}'.
16-
//
17-
// TS 3.9: Type 'SuperType' is not assignable to type 'SubType'.
18-
// 'SubType' could be instantiated with an arbitrary type which could be unrelated to 'SuperType'.
19-
//
20-
// TS 4.8: Type 'SuperType' is not assignable to type 'SubType'.
21-
// 'SubType' could be instantiated with an arbitrary type which could be unrelated to 'SuperType'.
22-
// input.tsx(1, 41): This type parameter might need an `extends V` constraint.
23-
subType2 = superType;
12+
subtype = superType;//error
13+
>subtype = superType : SuperType
14+
> : ^^^^^^^^^
15+
>subtype : any
16+
> : ^^^
17+
>superType : SuperType
18+
> : ^^^^^^^^^
19+
20+
//ensures that supertypes are not assignable to 'grandchild' subtypes
21+
subType2 = superType;//error
2422
>subType2 = superType : SuperType
2523
> : ^^^^^^^^^
2624
>subType2 : SubType2
2725
> : ^^^^^^^^
2826
>superType : SuperType
2927
> : ^^^^^^^^^
28+
29+
superType = subType2;//ok
30+
>superType = subType2 : SubType2
31+
> : ^^^^^^^^
32+
>superType : SuperType
33+
> : ^^^^^^^^^
34+
>subType2 : SubType2
35+
> : ^^^^^^^^
3036
}
3137

0 commit comments

Comments
 (0)