Reputation: 6901
I'm not sure why, but a setter I've written isn't being recognized when I call it.
Here's the error being thrown:
TypeError: Bridge.Config.middleware is not a function
Here's the typescript:
set middleware(val: any) { // should be function or function[]
this.props.exceptions.middleware = val;
}
get middleware() {
return this.props.exceptions.middleware;
}
Here's the generated JS:
Object.defineProperty(ConfigService.prototype, "middleware", {
get: function () {
return this.props.exceptions.middleware;
},
set: function (val) {
this.props.exceptions.middleware = val;
},
enumerable: true,
configurable: true
});
Testing:
// properly prints value
console.log(Bridge.Config.middleware);
// throws above-mentioned type error
Bridge.Config.middleware(fn);
How I'm Executing (compiling to es5):
tsc -w --module 'commonjs' --target 'es5'
Upvotes: 0
Views: 147
Reputation: 5519
You create a setter not a function.
Your code should be:
Bridge.Config.middleware = fn;
Upvotes: 2