Skip to content

Types become compatible after update to version 3.8.1-rc #37624

Description

Context

In our project we have type tests using dtslint and if we update the TS version some expected type errors disappear. I have extracted a minimal sample from our project (see code below).
The problem appears for all version after 3.8.1-rc including the latest builds.

Steps to reproduce:

  • Take the code snipped
  • Execute the snipped in the playground or locally
  • Depending on the TS version the error on doSomethingConstructable(...) disappears

Code

export class Field<EntityT> {
    constructor(readonly prop: Constructable<EntityT>) {
    }
}

export interface Constructable<EntityT,NotUsed={}> {
    someField: Field<EntityT>;
}

export class TestEntity1   {
    prop_1!: boolean;
    static someField: Field<TestEntity1> = new Field( TestEntity1)
}

export class TestEntity2  {
    prop_2!: boolean;
    static someField: Field<TestEntity2> = new Field( TestEntity2)
}

function doSomethingEntity<T>(...entity: T[]) { }
//Expected error (present for version 3.7.X and 3.8.X)
doSomethingEntity(TestEntity1,TestEntity2)

function doSomethingConstructable<T>(...entity: Constructable<T>[]) { }
//Expected error  (this one disappears if you update to version 3.8.1-rc)
doSomethingConstructable(TestEntity1,TestEntity2)

Thank you for support on this issue. Perhaps we are using something wrong. I realized, that the issue is somehow related to the default generic type. When I remove it, I get the same behavior for the 3.7.X and 3.8.X version. I think I can fix the problem by not using the default type and passing around the second paramter everywhere. But this would lead to a major code change in our project and it also worked in the version prior to 3.8.1-rc.

Expected behavior:
Type error for doSomethingEntity() and doSomethingConstructable(...) independent of the TS version.

Actual behavior:
When you use version 3.8.1-rc and above the error on doSomethingConstructable(...) disappears.

Playground Link: link

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Needs InvestigationThis issue needs a team member to investigate its status.RescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions