finos / openfin-react-hooks

A collection of React Hooks built on top of the Openfin API - from Scott Logic
Apache License 2.0
48 stars 18 forks source link

Demo app typescript errors #47

Open nite opened 4 years ago

nite commented 4 years ago

Hi,

Spinning up your demo app, firstly I get this:

/src/App.tsx
TypeScript error in /Users/andyc/dev/openfin/openfin-react-hooks/demo/src/App.tsx(76,27):
Expected 2 type arguments, but got 1.  TS2558

    74 | };
    75 | 
  > 76 | export default withRouter<RouteComponentProps>(App);

fixed with: export default withRouter(App);

Now, I'm blocked by:

/src/pages/bounds/Bounds.tsx(44,11):
Type 'Bounds' is not an array type.  TS2461

    42 | 
    43 | const Bounds: React.FC = () => {
  > 44 |     const [bounds, setBounds] = useBounds();

any ideas?

typescript version:

yarn list typescript
yarn list v1.7.0
warning Filtering by arguments is deprecated. Please use the pattern option instead.
└─ typescript@3.4.5
oriondean commented 4 years ago

Hi, thanks for reporting this.

For the typing issue, did you happen to install the demo dependencies via npm not yarn? We've seen an issue where @types/react-router-dom v5.1.3 has been installed when the package-lock.json` stipulates that v.5.0.0 should be installed. If you install via yarn, that lockfile is ignored, we should probably tie that dependency down.

From the looks of the second typing issue, it seems like your TSC/IDE is still using the old useBound typings, does the index.d.ts file in the root of the repo directory show useBounds returning an array type on line 70?

nite commented 4 years ago

Sorry for delay on this - I've installed with npm now, however I'm getting this:

./src/pages/bounds/Bounds.tsx
Module not found: Can't resolve 'openfin-react-hooks' in '/home/andyc/work/bmll/tmp/openfin-react-hooks/demo/src/pages/bounds'

I've re-run npm i openfin-react-hooks -D for good measure.

Typing looks good on useBound now:

export const useBounds: (target?: _Window) => [
    Bounds | undefined,
    (newBounds: Bounds) => Promise<void>
];
nite commented 4 years ago

Switching back to node 12 (from 13) & got the app running. I've run it with npm start in 1 terminal & npm run launch in another. Now, if I click on anything, I get a white screen - cant load devtools, app just crashes. Nothing running on localhost:9090. Worth mentioning, I get this on npm run launch:

using config /Users/andyc/dev/openfin/openfin-react-hooks/demo/public/app.dev.json
Error: Failed to load url: https://app-directory.openfin.co/api/v1/apps/layouts, status code:404

I have a single openfin-react-hook running now in starter-typescript-react-sass, so hopefully I'm underway with kicking the tyres a bit more in the meantime.

oriondean commented 4 years ago

Not seen that layouts 404 issue before, might be something up with openfin, do you still see it?

With regards to the cannot resolve openfin-react-hooks, you may need to run a npm run compile in the root directory to do a first-time compile of the hooks before using them.

Lonli-Lokli commented 2 years ago

Node v14.18.2 npm 6.14.15

PS D:\github\openfin-react-hooks> npm run compile

> openfin-react-hooks@2.0.3 compile D:\github\openfin-react-hooks
> tsc

../node_modules/@types/prettier/index.d.ts:537:14 - error TS2456: Type alias 'Doc' circularly references itself.

537         type Doc = string | Doc[] | DocCommand;