Skip to content

Commit

Permalink
accepted baseline changes
Browse files Browse the repository at this point in the history
  • Loading branch information
RolandLocke committed Feb 17, 2025
1 parent 2a56797 commit a697946
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 62 deletions.
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
}

Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,19 @@

//// [better_subType_assignable_to_superType_error_messsage.ts]
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

//ensures that supertypes are not assignable to 'grandchild' subtypes
subType2 = superType;//error

superType = subType2;//ok
}


//// [better_subType_assignable_to_superType_error_messsage.js]
function parameterExtendsOtherParameter(superType, 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
//ensures that supertypes are not assignable to 'grandchild' subtypes
subType2 = superType; //error
superType = subType2; //ok
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,16 @@ function parameterExtendsOtherParameter<SuperType, SubType extends SuperType, Su
>subType2 : Symbol(subType2, Decl(better_subType_assignable_to_superType_error_messsage.ts, 0, 125))
>SubType2 : Symbol(SubType2, Decl(better_subType_assignable_to_superType_error_messsage.ts, 0, 77))

// 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
>superType : Symbol(superType, Decl(better_subType_assignable_to_superType_error_messsage.ts, 0, 104))

//ensures that supertypes are not assignable to 'grandchild' subtypes
subType2 = superType;//error
>subType2 : Symbol(subType2, Decl(better_subType_assignable_to_superType_error_messsage.ts, 0, 125))
>superType : Symbol(superType, Decl(better_subType_assignable_to_superType_error_messsage.ts, 0, 104))

superType = subType2;//ok
>superType : Symbol(superType, Decl(better_subType_assignable_to_superType_error_messsage.ts, 0, 104))
>subType2 : Symbol(subType2, Decl(better_subType_assignable_to_superType_error_messsage.ts, 0, 125))
}

Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,29 @@ function parameterExtendsOtherParameter<SuperType, SubType extends SuperType, Su
>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
>subtype = superType : SuperType
> : ^^^^^^^^^
>subtype : any
> : ^^^
>superType : SuperType
> : ^^^^^^^^^

//ensures that supertypes are not assignable to 'grandchild' subtypes
subType2 = superType;//error
>subType2 = superType : SuperType
> : ^^^^^^^^^
>subType2 : SubType2
> : ^^^^^^^^
>superType : SuperType
> : ^^^^^^^^^

superType = subType2;//ok
>superType = subType2 : SubType2
> : ^^^^^^^^
>superType : SuperType
> : ^^^^^^^^^
>subType2 : SubType2
> : ^^^^^^^^
}

0 comments on commit a697946

Please sign in to comment.