-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: 2.2.0-dev.20161112
Code
// A *self-contained* demonstration of the problem follows...
export class ToggleTests {
state: any = {};
toggle1(key: string) {
console.log({ ...this.state, [key]: !this.state[key] });
}
toggle2(...keys: string[]) {
console.log({ ...this.state, [keys[0]]: !this.state[keys[0]] });
}
toggle3(...keys: string[]) {
console.log(keys.reduce((dict, key) => ({ ...dict, [key]: !this.state[key] }), {}));
}
toggle4(...keys: string[]) {
console.log(keys.reduce((dict, key) => {
dict[key] = !this.state[key];
return dict;
}, {}));
}
}
Expected behavior:
It should work (;
Actual behavior:
This code won't compile. If I delete/comment toggle2()
and toggle3()
methods it will compile and toggle1()
and toggle4()
methods work as expected.
Here's full error stack:
TypeError: Cannot read property 'kind' of undefined
at isNumericName (~\node_modules\typescript\lib\typescript.js:33945:24)
at getObjectLiteralIndexInfo (~\node_modules\typescript\lib\typescript.js:34000:48)
at createObjectLiteralType (~\node_modules\typescript\lib\typescript.js:34137:67)
at checkObjectLiteral (~\node_modules\typescript\lib\typescript.js:34128:52)
at checkExpressionWorker (~\node_modules\typescript\lib\typescript.js:37309:28)
at checkExpression (~\node_modules\typescript\lib\typescript.js:37268:42)
at checkExpressionWorker (~\node_modules\typescript\lib\typescript.js:37320:28)
at checkExpression (~\node_modules\typescript\lib\typescript.js:37268:42)
at checkExpressionCached (~\node_modules\typescript\lib\typescript.js:37184:38)
at getReturnTypeFromBody (~\node_modules\typescript\lib\typescript.js:36190:24)
at getReturnTypeOfSignature (~\node_modules\typescript\lib\typescript.js:28554:28)
at checkFunctionExpressionOrObjectLiteralMethodDeferred (~\node_modules\typescript\lib\typescript.js:36439:21)
at checkDeferredNodes (~\node_modules\typescript\lib\typescript.js:40914:25)
at checkSourceFileWorker (~\node_modules\typescript\lib\typescript.js:40948:17)
at checkSourceFile (~\node_modules\typescript\lib\typescript.js:40928:13)
at Object.forEach (~\node_modules\typescript\lib\typescript.js:1276:30)
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue