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
Context
In our project we have type tests using
dtslintand 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:
doSomethingConstructable(...)disappearsCode
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()anddoSomethingConstructable(...)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