Typescript generic type check not working as expected

前端 未结 3 1098
孤独总比滥情好
孤独总比滥情好 2021-01-21 13:48

I have made a simple test fixture:

export interface ITest1 {}
export interface ITest2 {}
export interface ITestGeneric {}

export function test() {
  le         


        
3条回答
  •  感动是毒
    2021-01-21 14:12

    I think since you don't restrict the

    ITestGeneric 
    

    it allows it. If you did

    ITestGeneric
    

    It would be more restrictive.

    TypeScript generics are not CSharp generics and are not 100% the same.

    your interface just says it has to be a ITestGeneric of anything.

提交回复
热议问题