Allow trailing commas after non-rest elements in destructuring - #24672
Conversation
|
thanks Kevin Gibbons (@bakkot)! |
|
Will this be in 2.9.3 ? |
|
No. TS 3.0, should be out next week. |
|
This problem still exists in the 3.0.1 |
|
Jérôme Lipowicz (@jerome) The example from #24628 works for me with |
|
Andy (Andrewkraft) (@Andy-MS) in React component import React, { PureComponent } from 'react';
export interface ButtonProps {
size?: 'large' | 'normal' | 'small';
}
export default class Button extends PureComponent<ButtonProps, {}> {
render() {
const {
size,
children,
...others, // error line
} = this.props;
return <a {...others}>{children}</a>;
}
} |
|
Jerome (@JeromeLin), that's not syntactically valid JavaScript or (as of #22262) TypeScript. You can't have a trailing comma after a rest element ( TypeScript's behavior is correct; you should remove that comma. |
|
Kevin Gibbons (@bakkot) thanks. this problem has been solved. |
Fixes #24628.
cc Andy (Andrewkraft) (@Andy-MS) for the original change in #22262.