BREAKING CHANGE:Object Rests Drop Unspreadable Members from Generic Objects
TL;DR
分割代入&スプレッド構文を使った推論が修正された。
Previous
class Thing {
prop = 42;
method() {}
}
function foo(thing: Thing) {
let { prop, ...rest } = thing;
rest.someMethod();
}
foo(new Thing());
トランスパイル後のJSでエラーになる。
class Thing {
prop = 42;
method() {}
}
function foo(thing) {
let { prop, ...rest } = thing;
rest.someMethod(); // ❌ ERROR! rest === {}
}
foo(new Thing());
Current
TSでエラーが表示されるようになった。
class Thing {
prop = 42;
method() {}
}
function foo(thing: Thing) {
let { prop, ...rest } = thing; // ❌ ERROR!
rest.someMethod();
}
foo(new Thing());
PreviousTypeScript Trace AnalyzerNextBREAKING CHANGE:JavaScript Files Always Receive Grammar and Binding Errors
Last updated