Comments (7)
Hi! Thank you for the thoughtful reply. I apologize for the confusion—when I said "general community preference" I meant the overall TypeScript user community. I have been part of a few TS adoptions in open source projects and have seen how this usually unfolds, and that was my attempt to offer an summary of what TS users generally request in this situation. I can see how that was not ideal framing and I've updated the request to make that clearer.
TypeScript is really great imho, so being TS compatible is also "really great" 🙂. TypeScript users would get 1) auto complete on StimulusReflex code and 2) wouldn't have to mess around with compiler flags or module declaration monkey patches to be able to use the library in their TypeScript code and 3) automatically know when refactors are required with the third party library because of API changes in the types.
Given that the surface area of the end-user API seems to be quite small, and the team's perfectly reasonable lack of interest in rewriting the library in TypeScript, 2 or 3 seems "really great" to me!
If we move forward with StimulusReflex at our company, I'll be glad to help with this effort. Otherwise, some other TS user has the information they need now to get it going and send a PR. Thank you for taking time to engage and for this great looking library!
from stimulus_reflex.
Hi Brian!
TypeScript is not currently a high priority for the team working on StimulusReflex, and option 1 is not likely on any current timeline. Option 2 or 3 - I don't know much about the TS ecosystem, so these options are equally reasonable sounding - are distinctly possible if someone who is involved in our community took ownership of implementing these measures and they didn't require substantial changes to the existing codebase. I think that we can all agree that there's a happy compromise between adopting a tech and wasting energy to block it.
That brings me to your use of the interesting term "general community preference"... right now, nobody who is currently participating in the SR community - loosely defined as folks we know from hanging out on Discord - seems to be in love with TS. That's a nuanced statement, because some of us think that the type hype is a bit overblown while others thing it's fine and maybe use it, but aren't feeling as though the lack of TS support is impacting their ability to use the library. So consider this a friendly invitation to come and change our minds. 😀
With all of that said, and having admitted that I'm not a TS expert, it's not at all clear to me how the StimulusReflex client being TS-compatible would actually be "really great". Everything happens in Stimulus controllers, and it's likely that many devs use SR without writing any JavaScript since the declarative format is quite popular. What would meaningfully change for folks calling this.stimulate()
in their controllers if it was TS-compatible?
from stimulus_reflex.
Right on.
Well, like you said: the good news is that the public API surface area is literally one method, maybe this will be the easiest TS shim-job in history:
this.stimulate('WiggleReflex#method', optional_splat)
Everything after the first string is zero to many optional parameters, each of any standard type eg. number, string, boolean, array, object.
from stimulus_reflex.
Moving forward, what's the best way for me to help with this issue? Is there a timeline for a conversation within your company?
If you decide not to pursue adding TS support at this time, let's close the issue. We can always reopen it later if priorities change.
from stimulus_reflex.
I think it's reasonable to close this to get it off your queue. If I or someone else comes along then it can be addressed then. Thank you for the conversation!
from stimulus_reflex.
Does anyone have a TypeScript snippet for how to declare stimulate
on the Controller classes? Seems like you can't "reopen" classes in TS, but is there some other way folk have gotten around this?
from stimulus_reflex.
Following up on my prev question: @ParamagicDev helped me out on Slack with this codepen: https://codesandbox.io/s/runtime-currying-bwl792?file=/src/index.ts:135-284
import StimulusReflex from "stimulus_reflex";
import { Controller } from "stimulus";
class ApplicationController extends Controller {
stimulate!: (
str: string,
element: null | undefined | Element,
options?: Record<string, any>,
...args: any[]
) => Promise<void>;
connect() {
StimulusReflex.register(this);
}
}
export default class extends ApplicationController {
async submit(e: Event) {
e.preventDefault();
await this.stimulate("PlatformAdmin::CheckoutBeacons#add", this.element);
}
}
from stimulus_reflex.
Related Issues (20)
- Controller over reflex attribute is ignore and reflex is always called with default StimulusReflexController HOT 7
- Broken Next Page Link on Welcome Page of Docs HOT 2
- HEAD and most of the latest releases are broken, references an undefined exception
- StimulusReflex is not compatible with the standalone ActionCable server HOT 9
- Wrong dataset getting from Docs example HOT 2
- NameError: undefined local variable or method `package_json' HOT 3
- Reflex not triggered when a Stimulus controller is also attached to a field HOT 4
- Form parse errors are not captured and reported back to front-end
- Drop Rails 5 and 6.0 support
- `solid_cache` seems to work as well as Rails cache store HOT 1
- Add full-stack tests
- Stimulus_reflex and esbuild error HOT 1
- OpenStruct no longer supported by json HOT 1
- Refactor away instances of OpenStruct
- NameError: uninitialized constant StimulusReflex::Installer::Thor when running rake tasks HOT 1
- Support `relative_url_root`
- Could not find generator 'stimulus_reflex:initializer'
- Unrecognized command "esbuild" (Rails::Command::UnrecognizedCommandError)
- Installer should work in CI (noninteractive) environment
- docs recommend hiredis gem along with incompatible redis version
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 stimulus_reflex.