3 ms·
>> Try using object destructuring in a class constructor to create optional named parameters for a class. Works perfectly in Vanilla JS, but TS will throw a hi
by wffurr 4y ago
>> Try using object destructuring in a class constructor to create optional named parameters for a class. Works perfectly in Vanilla JS, but TS will throw a hissy-fit.
What?
You mean like this?
class Foo {
constructor({opt1, opt2, opt3}: {opt1: string, opt2?: number, opt3?: Object}) {
}
}
https://www.typescriptlang.org/play?#code/MYGwhgzhAEBiD29oG8BQ0PWPAdhALgE4Cuw+8hAFMvAA74CMANNHfgEwtsDMAvgFwo2DQQUIBLHAHMu9dgH5BOYgFsARgFNCs-N0XQA8moBWGsrwCUKVOky9UvIA https://www.typescriptlang.org/play?#code/MYGwhgzhAEBiD29oG8...