Unable to Parse Spread Operator

javascript
(Ravi Bhatia) #1
ERROR: Parse error at line 65 column 3:

61: import type {EntityDoc} from '@abc/xyz;
62: import type {Custody} from '../../pqr';
63: 
64: type PublicEndpointDoc = {|
65:   ...$Exact<EntityDoc>,
      ^
66:   endpoint_id: string,
67:   event_ids: Array<string>,
68:   url: string,
69:   member_id: string,
70:   network_name: string,
71: |};
72: 

Thank you.

(Fabrice Bellingard) #2

Nobody will help you if you just copy-paste some log. Please edit you post and give more context.

(Colin Brown) #3

I too have run across this. it can’t seem to parse the .JS file if a spread operator is used pre-transpiled (in our case with babel)

(Elena Vilchik) #4

Hi,
I suspect you are using Flow syntax. Indeed there are some cases we don’t parse it. But note that we plan in future to fully rely on babel parser for Flow (see https://github.com/SonarSource/SonarJS/issues/771). So I suggest you just ignore this parse error for now. Note that since SonarJS 5.0 even if you see this parsing error, part of the rules will be still executed based on babel parser.

regards,
Elena

(Ravi Bhatia) #5

Thank you Elena. You are correct, this is related to using Flow syntax.