TypeScript Version: 2.9.1/3.0.0-dev.20180602
Search Terms:
Code
declare const anything: any[];
let a;
[
a,
] = anything;
let [
b,
] = anything;
Expected behavior:
no error
Actual behavior:
test.ts:6:4 - error TS1013: A rest parameter or binding pattern may not have a trailing comma.
6 a,
~
Per ECMAScript Spec, the trailing comma is allowed in a binding pattern without rest element.
Playground Link:
link
Related Issues:
(from prettier/prettier#4624)
PRs welcomed.
declare const anything: any[];
let a;
[
a
] = anything;
let [
b,
] = anything;
[23:31:52] Found 0 errors. Watching for file changes.
Correct me if i wrong
thanks @alexandrLamdan1995
@mhegazy I'm still seeing this on master:
$ cat in.ts
let a; [a,] = <any>[];
$ git rev-parse --short HEAD
7eaa78846e
$ gulp local
[...]
$ node built/local/tsc.js in.ts
in.ts:1:10 - error TS1013: A rest parameter or binding pattern may not have a trailing comma.
1 let a; [a,] = <any>[];
~
Looks like this was introduced in #22262. I'll submit a PR in a moment here.
Will anyone try to fix it? Windows update - crash + BSOD, skype update - crash, Typescript update - crash. Do you have testers for your own products? The worst QA in all over the world... And that is Microsoft.
It’ll be fixed by #24672 @BLRplex.
@j-f1 Hope it will not reopened again in few days. Thanks
Can this fix make it into into an earlier release, e.g., 2.9.2? We use Prettier and either we have to rip out all trailing commas or upset the TS compiler to update to 2.9.
As a workaround for anyone who stumbles into this issue, you can just append // prettier-ignore
to an offending line and Prettier will not add a trailing comma there to satisfy TS.
Most helpful comment
Can this fix make it into into an earlier release, e.g., 2.9.2? We use Prettier and either we have to rip out all trailing commas or upset the TS compiler to update to 2.9.