Reputation: 83848
Transpiling TKO / Knockout.js back to ES3 or ES5 for IE9 compatibility, tko.binding.if/src/ifNotWith.js an error is encountered here:
class ConditionalBindingHandler extends AsyncBindingHandler {
...
get shouldDisplayIf () { return !!unwrap(this.value) }
...
}
export class UnlessBindingHandler extends ConditionalBindingHandler {
get shouldDisplayIf () { return !super.shouldDisplayIf }
}
This errors after Typescript is run on it because Typescript changes the super.shouldDisplayIf
to super.prototype.shouldDisplayIf
, which changes the this
reference.
What it should do (for getting, but setting is similar) is something like this:
p = Object.getOwnPropertyDescriptor(super, 'shouldDisplayIf')
return 'get' in p ? p.get.call(this) || p.value
... but it's not. Is this a known issue with Typescript, or am I missing something?
The only related issue I could find was: https://github.com/Microsoft/TypeScript/issues/338
Upvotes: 1
Views: 124
Reputation: 83848
This appears to be a WONTFIX by Microsoft:
RyanCavanaugh commented on Nov 27, 2017
Long story short - after five years of not having this and people surviving despite it, it seems like ES6 adoption is catching up fast enough that the narrow window of people who target ES5 (rather than 3 for maximum compat or 6 for smallest emit delta) is closing to the point where we don't want to accept a big chunk of helper emit at this point. Open to data otherwise but it just doesn't seem common enough to warrant a big change in the emitter.
https://github.com/Microsoft/TypeScript/issues/338
Upvotes: 1