Giter Club home page Giter Club logo

Comments (7)

bbugh avatar bbugh commented on July 29, 2024 1

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.

leastbad avatar leastbad commented on July 29, 2024

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.

leastbad avatar leastbad commented on July 29, 2024

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.

leastbad avatar leastbad commented on July 29, 2024

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.

bbugh avatar bbugh commented on July 29, 2024

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.

machty avatar machty commented on July 29, 2024

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.

machty avatar machty commented on July 29, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.