Gr3q / types-cjs

Typescript declarations for CJS - Cinnamon JavaScript
MIT License
5 stars 2 forks source link

[Question] How does this work? #20

Open danimesq opened 1 year ago

danimesq commented 1 year ago

Does this enables spices to be written in TypeScript while being read by CJS as normal Javascript?

danimesq commented 1 year ago

Are this a framework for developing spices or an extension for Cinnamon itself?

Gr3q commented 1 year ago

For the first question, yes if you transpile to JS.

For the second question, this just enables development of spices using Typescript. More specifically it provides typescript declarations for libraries that are provided out of the box for spices in CJS under imports.*.

danimesq commented 1 year ago

So, spices' devs could write the "frontend" in vanilla CJS while imports.*'ing most of the code (the "backend" - quotes with an extra grain of salt pls) in TS + types-cjs declarations?

Gr3q commented 1 year ago

You don't need this library for vanilla (C)JS. You can also write an applet/extension in TS without it with a dummy declaration like this:

declare global {
    const imports: any;
}

but obviously it has some drawbacks.

So this library is only for providing declarations for that namespace for correct type-checking for Typescript.