enhance-dev / enhance-ssr

Server side render for custom elements.
143 stars 9 forks source link

TypeScript support #48

Closed erkannt closed 1 year ago

erkannt commented 1 year ago

Are there any plans for supporting TypeScript in this library?

tbeseda commented 1 year ago

Hi @erkannt What would that look like? It doesn't not support TypeScript (or any compiles-to-JS superset syntax). Do you mean types for the call signatures and the options?

erkannt commented 1 year ago

Yes, something that provides the types you mention to allow enhance to be used inside typescript projects easily. The cleanest would we a .d.ts file inside of this repo, but if that goes against the scope of this project I guess there is always the DefinitelyTyped escape hatch.

Motivation is to add progressively enhanced components to an existing web app written in TS that renders everything on the server side. enhance-ssr looks like a good fit for this that would let us keep components nicely encapsulated.

kristoferjoseph commented 1 year ago

As Typescript is not a web standard it does not make sense to use in a web standards focused project.

When types become a standard we will support them at that point in time.

Until then we will avoid all costly and time consuming refactors required to support an ever breaking type system that delivers no user facing benefits.

We respect your time too much to subject you to inevitable breaking changes.

https://enhance.dev/docs/learn/why-enhance

erkannt commented 1 year ago

Thanks for clarifying. That choice makes sense to me given your objectives.

kristoferjoseph commented 1 year ago

You can use Enhance SSR with your project. It exports a tagged template literal function that accepts an HTML string and returns a string of HTML.