I'm using typescript in react and following file is throwing a lot of errors, I'm not sure why (its working as js), but I suspect something here is to do with spread operators?
import React from 'react'
import { Subscribe } from 'unstated'
const getStoreAsProps = (storeArr) => {
const storeProps = {}
storeArr.map((value) => (storeProps[value.name] = value))
return storeProps
}
const withStore = (...args) => (Element) => () => (
<Subscribe to={[...args]}>{(...args) => <Element {...getStoreAsProps(args)} />}</Subscribe>
)
export default withStore
Errors thrown by tsc are
workspace/app/store/index.ts:11:14 - error TS1005: '>' expected.
11 {(...args) => } ~~
workspace/app/store/index.ts:11:16 - error TS1005: ')' expected.
11 {(...args) => } ~
workspace/app/store/index.ts:11:19 - error TS1109: Expression expected.
11 {(...args) => } ~~~
workspace/app/store/index.ts:11:26 - error TS1005: ',' expected.
11 {(...args) => } ~
workspace/app/store/index.ts:11:30 - error TS1136: Property assignment expected.
11 {(...args) => } ~
workspace/app/store/index.ts:11:40 - error TS1005: ';' expected.
11 {(...args) => } ~~
workspace/app/store/index.ts:11:52 - error TS1005: '>' expected.
11 {(...args) => } ~
workspace/app/store/index.ts:11:80 - error TS1109: Expression expected.
11 {(...args) => } ~
workspace/app/store/index.ts:11:81 - error TS1109: Expression expected.
11 {(...args) => } ~
workspace/app/store/index.ts:11:83 - error TS1110: Type expected.
11 {(...args) => } ~
workspace/app/store/index.ts:11:84 - error TS1161: Unterminated regular expression literal.
11 {(...args) => }
workspace/app/store/index.ts:12:1 - error TS1128: Declaration or statement expected.
12 ) ~
If it helps, syntax highlighting is breaking there as well

import * as React from "react";