-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object spread with rest arguments causes compile error #12200
Comments
Hm, I'm not able to repro this - what set of options are you using, and how are you compiling it? |
I'm using a
I'm getting the same error in this plunker if I uncomment |
I am not getting this either. c:\test\12200>ls
[.] [..] app.ts main.ts [node_modules] tsconfig.json
c:\test\12200>type tsconfig.json
{
"compilerOptions": {
"baseUrl": "./src",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"isolatedModules": true,
"lib": [ "dom", "es2015", "es2017" ],
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"target": "es5"
}
}
c:\test\12200>type main.ts
//main entry point
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {AppModule} from './app';
platformBrowserDynamic().bootstrapModule(AppModule)
c:\test\12200>type app.ts
//our root app component
import {Component, NgModule} from '@angular/core'
import {BrowserModule} from '@angular/platform-browser'
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;
}, {}));
}
}
@Component({
selector: 'my-app',
template: ``,
})
export class App {
constructor() {
const toggles = new ToggleTests();
toggles.toggle1('one', 'two');
toggles.toggle2('one', 'two');
toggles.toggle3('one', 'two');
toggles.toggle4('one', 'two');
}
}
@NgModule({
imports: [ BrowserModule ],
declarations: [ App ],
bootstrap: [ App ]
})
export class AppModule {}
c:\test\12200>tsc --v
Version 2.2.0-dev.20161113
c:\test\12200>tsc
app.ts(35,5): error TS2346: Supplied parameters do not match any signature of call target. |
It works for me too when I isolate it. Not sure what might be causing the error in my project...
|
In the error I got, second line:
points to this function in source code:
If I change this line to:
code compiles without errors and works in my app. Don't know how this works internally, or where is this in source code, but hopefully it will help (: |
We need to know why this is happening. why is the node undefined at runtime. if you can debug locally, when the exception happen try |
It seams |
@sandersn can you take a look. |
@sasxa found the source of the bug. |
Fix is up at #12248 |
Just to confirm it works in |
TypeScript Version: 2.2.0-dev.20161112
Code
Expected behavior:
It should work (;
Actual behavior:
This code won't compile. If I delete/comment
toggle2()
andtoggle3()
methods it will compile andtoggle1()
andtoggle4()
methods work as expected.Here's full error stack:
http://plnkr.co/edit/NIz1MhKpK28Afyf5fsbx?p=preview
The text was updated successfully, but these errors were encountered: