-
Notifications
You must be signed in to change notification settings - Fork 325
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
TS7016: Could not find a declaration file for module '@hotwired/turbo-rails' #18
Comments
Can you share a sample app or your relevant TypeScript configuration? I can't reproduce in a stock setup on Rails 6.1: $ rails new wired && \
cd wired && \
bin/rails webpacker:install:typescript && \
yarn add @hotwired/turbo-rails && \
rm -rf app/javascript/packs/* && \
echo "import { Turbo, cable } from \"@hotwired/turbo-rails\"" > app/javascript/packs/application.ts && \
echo "console.log({ Turbo, cable })" >> app/javascript/packs/application.ts && \
bin/webpack
…
js/application-d58c957e0d7290104479.js.map 204 KiB application [emitted] [dev] application
manifest.json 364 bytes [emitted]
Entrypoint application = js/application-d58c957e0d7290104479.js js/application-d58c957e0d7290104479.js.map
[./app/javascript/packs/application.ts] 102 bytes {application} [built] |
Thanks javan. If you add |
I see. So this is more of a feature request to add TypeScript declarations than an issue since you'd encounter the same problem trying to use any library published without types. Noted! In the meantime, you may find some of these workarounds helpful. |
Well it used to work in Turbolinks 6 so this is new behavior after upgrading by following the install instructions in the readme but I see your point. Regardless of how you classify it I'm sure a lot of TypeScript users would appreciate type definitions on the interface to help migrate to the new version. Thanks again for looking into this. |
We do have definitions for Turbo itself, which is written in TypeScript, and passes right through this package:
turbo-rails/app/javascript/turbo/cable.js Lines 3 to 16 in 6df29f7
Happy to accept a PR if anyone feels like taking that on! |
Has anyone solved this issue? I'm having the similar problem on rails 7. |
Depending on how deeply you're using Turbo, you can define your own types for your specific use cases. In our case, for the moment, we only disabling Drive, so this worked for us: // app/javascript/@types/turbo.d.ts
declare module '@hotwired/turbo-rails' {
type TurboSession = {
drive: boolean;
}
type Turbo = {
session: TurboSession;
}
export const Turbo: Turbo;
} |
Hi, wouldn't it be possible to just release the typings in the npm package? |
I have opened two pullreqs to resolve this issue:
In order to keep up with turbo updates, I thought it would be preferable to convert turbo-rails to TypeScript as well. What do you think? If there is a lightweight way to re-export just the type information from turbo-rails without converting to TypeScript, that would be fine too. |
+1 on this one.. |
I've opened #392 about ten months ago. Please upvote 😄 |
Turbo left TypeScript. Closing this |
Ran into this error while upgrading a Rails 6 app that uses TypeScript and Turbolinks to the new Turbo. Any ideas? No results on DefinitelyTyped yet.
The text was updated successfully, but these errors were encountered: