Object destructing strips default values on typescript, errors on flow
See original GitHub issueSorry for bad title, but here is something I noticed after moving some variables into an object (hence why the first bit is wrong)
const test = {
foo = {
bar: 'baz'
},
foo = [
'bar', 'baz'
]
}
This object isn’t correct (foo =
instead of foo:
), but instead of giving an error when formatting it turns into
const test = {
foo,
foo,
};
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
jest doesn't understand flow types and object destructuring?
It seems that there are issues with the method signature using destructuring and flow types at the same time ( BuilderOptionsType object):
Read more >Flow – JavaScript Type Checker | Object Computing, Inc.
Flow is a static type checker, designed to find type errors in JavaScript ... By default, the values null and undefined are not...
Read more >Understanding TypeScript Configuration Options
TypeScript searches for the file with .ts , .tsx and .d.ts by default and, if allowJs is set to true, .js and .jsx...
Read more >Overzealous Destructuring | Aleksandr Hovhannisyan
The first problem with destructuring is that it strips object properties of their namespace, making it harder to tell, at a glance, ...
Read more >babel/plugin-transform-flow-strip-types
It will also throw errors for any Flow annotations found in files without the directive. allowDeclareFields. boolean , defaults to false. Added in:...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Raised this issue here: https://github.com/eslint/typescript-eslint-parser/issues/332
Seems this might be the right issue to track for flow: https://github.com/facebook/flow/issues/183 (Though it has been open since Dec 10, 2014)
Actually TypeScript still uses
ObjectLiteralExpression
instead ofObjectBindingPattern
in the following case:Prettier currently prints this as
Babylon is the only one that is correct.