Is there currently any converters online that could convert ts to js? I would like to use the components from here, but they're all written in ts and my rails app doesn't support it.
for example this file
import { Controller } from "@hotwired/stimulus"
import { useTransition } from 'stimulus-use/dist/use-transition'
export default class extends Controller {
menuTarget: HTMLElement
toggleTransition: (event?: Event) => void
leave: (event?: Event) => void
transitioned: false
static targets = ['menu']
connect (): void {
useTransition(this, {
element: this.menuTarget
})
}
toggle (): void {
this.toggleTransition()
}
hide (event: Event): void {
// @ts-ignore
if (!this.element.contains(event.target) && !this.menuTarget.classList.contains('hidden')) {
this.leave()
}
}
}
what kind of steps should I do in order to convert this to js? Bear in mind that I know nothing about typescript so I'm getting little confused here.
What I've currently done is the following
import { Controller } from "@hotwired/stimulus"
import { useTransition } from 'stimulus-use/dist/use-transition'
export default class extends Controller {
menuTarget: HTMLElement
toggleTransition: (event?: Event) => void
leave: (event?: Event) => void
transitioned: false
static targets = ['menu']
connect() {
useTransition(this, {
element: this.menuTarget
})
}
toggle() {
this.toggleTransition()
}
hide(event) {
// @ts-ignore
if (!this.element.contains(event.target) && !this.menuTarget.classList.contains('hidden')) {
this.leave()
}
}
}
but I don't quite know what to do with the hide function since it depends on the lines
menuTarget: HTMLElement
toggleTransition: (event?: Event) => void
leave: (event?: Event) => void
transitioned: false