Comments (11)
Hi, wouldn't it be possible to just release the typings in the npm package?
This should fix this issue :)
from turbo-rails.
Has anyone solved this issue? I'm having the similar problem on rails 7.
from turbo-rails.
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]
from turbo-rails.
Thanks javan. If you add "strict": true
to tsconfig.json
then run tsc
it produces the error. It looks like webpacker transpiles the TypeScript to JS but doesn't run the type checker itself.
from turbo-rails.
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.
from turbo-rails.
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.
from turbo-rails.
We do have definitions for Turbo itself, which is written in TypeScript, and passes right through this package:
It would be pretty straightforward to re-export its types too along with a few manual definitions for: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!
from turbo-rails.
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;
}
from turbo-rails.
I have opened two pullreqs to resolve this issue:
- #392
- DefinitelyTyped/DefinitelyTyped#62834 (closed once)
In order to keep up with turbo updates, I thought it would be preferable to convert turbo-rails to TypeScript as well.
If it is too much to convert turbo-rails to TypeScript, I think it would be better to follow the TypeScript community's practice and publish the type information from DT.
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.
from turbo-rails.
+1 on this one..
from turbo-rails.
I've opened #392 about ten months ago. Please upvote 😄
from turbo-rails.
Related Issues (20)
- `refresh` action is missing from Turbo::Streams::TagBuilder HOT 5
- Turbo Frame Responses missing tracked elements HOT 6
- Usage of anchor HOT 5
- Websocket doesn't work on production
- rails tests fail after turbo-rails upgrade from 1.5.0 to 2.0.3 HOT 4
- Single quotes not properly handled in Turbo Streams broadcast
- Content duplication on using render in controllers HOT 1
- Chrome reloads assets in the Link preload header HOT 1
- Uglifier::Error during assets:precompile HOT 1
- Turbo not streaming changes properly / window.Turbo is undefined HOT 3
- InstaClick prefetch not working with fragment cache
- Prefetch causes turbo stream to render on hover instead of on click HOT 2
- Inverted parameters in stream responses HOT 2
- unexpected routes added as part of the turbo rails gem HOT 2
- When streaming from a worker, path helpers append a domain `https://example.com` HOT 5
- Turbo Documentation need a "Broadcast" chatper
- Refresh broadcasts generated without changes
- Incompatible with Solid_Queue HOT 1
- turbo_frame_request_id safe operator in not handled correctly HOT 2
- Shouldn't broadcast refresh if streamables == [nil] HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from turbo-rails.