-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a56797
commit a697946
Showing
4 changed files
with
49 additions
and
62 deletions.
There are no files selected for viewing
26 changes: 12 additions & 14 deletions
26
tests/baselines/reference/better_subType_assignable_to_superType_error_messsage.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
better_subType_assignable_to_superType_error_messsage.ts(13,3): error TS2322: Type 'SuperType' is not assignable to type 'SubType2'. | ||
better_subType_assignable_to_superType_error_messsage.ts(2,3): error TS2552: Cannot find name 'subtype'. Did you mean 'subType2'? | ||
better_subType_assignable_to_superType_error_messsage.ts(5,3): error TS2322: Type 'SuperType' is not assignable to type 'SubType2'. | ||
'SubType2' is constrained to be a subtype of 'SuperType'. | ||
|
||
|
||
==== better_subType_assignable_to_superType_error_messsage.ts (1 errors) ==== | ||
==== better_subType_assignable_to_superType_error_messsage.ts (2 errors) ==== | ||
function parameterExtendsOtherParameter<SuperType, SubType extends SuperType, SubType2 extends SubType>(superType: SuperType, subType2: SubType2) { | ||
// TS 3.3: Type 'SuperType' is not assignable to type 'SubType'. | ||
// | ||
// TS 3.5: Type 'SuperType' is not assignable to type 'SubType'. | ||
// 'SuperType' is assignable to the constraint of type 'SubType', but 'SubType' could be instantiated with a different subtype of constraint '{}'. | ||
// | ||
// TS 3.9: Type 'SuperType' is not assignable to type 'SubType'. | ||
// 'SubType' could be instantiated with an arbitrary type which could be unrelated to 'SuperType'. | ||
// | ||
// TS 4.8: Type 'SuperType' is not assignable to type 'SubType'. | ||
// 'SubType' could be instantiated with an arbitrary type which could be unrelated to 'SuperType'. | ||
// input.tsx(1, 41): This type parameter might need an `extends V` constraint. | ||
subType2 = superType; | ||
subtype = superType;//error | ||
~~~~~~~ | ||
!!! error TS2552: Cannot find name 'subtype'. Did you mean 'subType2'? | ||
!!! related TS2728 better_subType_assignable_to_superType_error_messsage.ts:1:127: 'subType2' is declared here. | ||
|
||
//ensures that supertypes are not assignable to 'grandchild' subtypes | ||
subType2 = superType;//error | ||
~~~~~~~~ | ||
!!! error TS2322: Type 'SuperType' is not assignable to type 'SubType2'. | ||
!!! error TS2322: 'SubType2' is constrained to be a subtype of 'SuperType'. | ||
!!! related TS2208 better_subType_assignable_to_superType_error_messsage.ts:1:41: This type parameter might need an `extends SubType2` constraint. | ||
|
||
superType = subType2;//ok | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters