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

refactor: use .ts sources and vitest #37

Merged
merged 1 commit into from
Nov 15, 2024
Merged

refactor: use .ts sources and vitest #37

merged 1 commit into from
Nov 15, 2024

Conversation

fvsch
Copy link
Owner

@fvsch fvsch commented Nov 15, 2024

I wrote this library using .js files and TypeScript types in JSDoc comments, to see how far I could go that way.

It works pretty well and lets you run code with Node directly, as well as using Node's built-in test runner.

There are a few downsides though:

  • Package size: this pattern ships types (in JSDoc comments) in the final package, even though those are not used at runtime.
  • DX: it's still more painful to write TS in JSDoc than in .ts files.
  • DX: Node's built-in test runner is okay, but a bit limited.

So now that I’ve shown myself that it’s doable and not too painful without a build step and transpilation shenanigans involved, as a matter of personal preference I’m switching to .ts sources and Vitest.

One small win: using Vitest unlocks running tests on Node 18, since we no longer depend on node:test's suite function (not available in Node 18).

@fvsch fvsch merged commit d3f25c0 into main Nov 15, 2024
3 checks passed
@fvsch fvsch deleted the fvsch/ts-sources branch November 15, 2024 11:06
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

Successfully merging this pull request may close these issues.

1 participant