Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix "property destructuring pattern expected" error? [duplicate]

I'm getting this error:

vscode screenshot

Same error when I try to compile:

c:\...\tsx-test>ntsc app/main.tsx
app/components/Note.tsx(13,31): error TS1180: Property destructuring pattern expected.

But I don't know what it's expecting. What's the property syntax?

I'm pretty sure this works as-is in ES6. Is the syntax different in TypeScript?

Note that I'm using TypeScript 1.5.3.

like image 353
mpen Avatar asked Feb 10 '23 14:02

mpen


1 Answers

I'm pretty sure this works as-is in ES6.

the {a, b, ...rest} = props pattern is supported by TypeScript now. Just update to the latest compiler and it will work without error.

More

Some docs on the TypeScript destructuring:

http://basarat.gitbook.io/typescript/content/docs/destructuring.html

like image 172
basarat Avatar answered Feb 12 '23 11:02

basarat