#Optional type parameters for interfaces?

1 messages · Page 1 of 1 (latest)

raw hinge
#

I am trying to create an interface in typescript that takes in parameters, but I want the parameters to be optional. Is this possible?

Example:

export interface MyInterface<T> {...}

let thing1: MyInterface = ...
let thing2: MyInterface<param> = ...

celest axle
#

assign a default type

raw hinge
#

so I tried export interface MyInterface<T extends MyInterface = void>

#

but I get error "Type 'void' does not satisfy the constraint 'MyInterface<void>"

wheat cape
#

or MyInterface

raw hinge