Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate TypeScript files instead of JS files? #238

Open
sbking opened this issue Oct 10, 2024 · 3 comments
Open

Generate TypeScript files instead of JS files? #238

sbking opened this issue Oct 10, 2024 · 3 comments

Comments

@sbking
Copy link

sbking commented Oct 10, 2024

I can not enable allowJs for my application because other build tooling (Remix + Vite) does not work well when allowJs is enabled. Is there any way to make Paraglide generate .ts files instead?

@samuelstroschein
Copy link
Member

We can likely offer an option emitWithTsExtension

Can you test if changing the file endings to .ts works seamlessly in your project? Due to the JSDoc annotations, I expect TypeScript to work out of the box. If that's the case, then we don't have to use the typescript compiler which we tried to avoid to keep the complexity low

@sbking
Copy link
Author

sbking commented Oct 15, 2024

Unfortunately no, looks like JSDoc type annotations are only supported in JS files.

That said, I think my actual problem was that I was missing Remix's unstable_optimizeDeps flag and I think allowJs is now working fine. I think I would still prefer an option to generate .ts files to align with the rest of my codebase, but for now it's less of an issue.

Copy link
Member

samuelstroschein commented Oct 15, 2024

Can confirm. TypeScript complains with "ts 80004: Please convert JSDoc to TypeScript types".

Ergh bummer. It seems like we need to run the typescript compiler with emitDeclarations only to parse the JSDoc and emit d.ts files https://www.typescriptlang.org/docs/handbook/declaration-files/dts-from-js.html.

Good news: We won't need an option because we can emit both .js and .d.ts files. JS projects shouldn't be affected.

  • Paraglide keeps being written in JSDoc

  • JS projects use JSDoc (.js files)

  • TS projects use declaration files (.d.ts)

@sbking are you open for a PR against the lix-integration branch that has paraglide js 2.0? Then we can include this in the paraglide js 2.0 release

EDIT: If parallel .js (jsdoc) and .d.ts files works, then we can also get rid of the entire allowJs step in the setup. That's great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants