Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The return type for createCable is unresolved/any instead of Cable #39

Closed
kcrwfrd opened this issue Apr 25, 2024 · 2 comments
Closed

The return type for createCable is unresolved/any instead of Cable #39

kcrwfrd opened this issue Apr 25, 2024 · 2 comments

Comments

@kcrwfrd
Copy link

kcrwfrd commented Apr 25, 2024

Screenshot 2024-04-25 at 2 26 57 PM

This is causing type errors in our project when trying to use anycable.

I think you need to import all of the imports from @anycable/core, not export them.

import {
  CreateOptions,
  Cable,
  ActionCableConsumer,
  TokenRefresher
} from '@anycable/core'

// is this necessary?
export { CreateOptions, Cable, ActionCableConsumer, TokenRefresher }
@palkan
Copy link
Member

palkan commented Apr 26, 2024

Thanks for the report!

It looks like it's gonna be fixed by #38.

I think you need to import all of the imports from @anycable/core, not export them.

We re-export types for usability (so, you can import all you need from the @anycable/web package without event knowing that @anycable/core exists and think about what to import from where).

palkan pushed a commit that referenced this issue May 21, 2024
It looks like in tsconfig.json, the `skipLibCheck` flag was added
so that check-dts could ignore these external errors:

```
✖ node_modules/@types/node/globals.d.ts:67:13: Type error TS2502
  'AbortController' is referenced directly or indirectly in its own type annotation.

✖ node_modules/@types/node/globals.d.ts:74:13: Type error TS2502
  'AbortSignal' is referenced directly or indirectly in its own type annotation.
```

See the check-dts FAQ for their guidance:
https://github.com/ai/check-dts/blob/7020f61159798fbe19d2a1e38aadd75ab0c7ccc5/README.md#i-am-getting-an-error-from-node-types-how-do-i-skip-node_modules

But adding that flag meant the type declaration files (*.d.ts) in
this anycable-client repo were skipped, so any errors were
overlooked. This has downstream effects for any consumers of the
anycable-core or anycable-web packages. If any declaration files
had type errors (as they did), and the consumers did not set
`skipLibCheck` in their tsconfig, then they'd experience
a failure in their repo as evidenced in issue #39.

So it's prudent for us to _not_ skip checking the type declarations.

`tsc` and `check-dts` both read from tsconfig.json, but we can point
`tsc` to a different configuration file that omits `skipLibCheck`
and ensures this repo's declaration files are checked.

Added the tsc type check at the front because it's the quickest test,
so tests will fail early and fast if there's an error.
@palkan
Copy link
Member

palkan commented May 21, 2024

Should be fixed in v0.9.0. Please, let me no if the problem still there, and we'll reopen it.

@palkan palkan closed this as completed May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants