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

support native Node.js Typescript type-stripping #441

Closed
mcollina opened this issue Jan 23, 2025 · 12 comments
Closed

support native Node.js Typescript type-stripping #441

mcollina opened this issue Jan 23, 2025 · 12 comments
Assignees
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@mcollina
Copy link
Member

Given that Node.js v23 has unflagged type stripping, I think we should support it out of the box

@mcollina mcollina added good first issue Good for newcomers help wanted Extra attention is needed labels Jan 23, 2025
@mcollina
Copy link
Member Author

cc @SamSalvatico @jean-michelet

@jean-michelet
Copy link
Contributor

We should wait for #440 to be merged.
Do you want to do it @SamSalvatico, or I take this one?

@SamSalvatico
Copy link
Contributor

I can take It @jean-michelet

@SamSalvatico
Copy link
Contributor

@jean-michelet I gave a look, but unfortunately I am not able to progress into this (missing knowledge on my side)

@jean-michelet
Copy link
Contributor

Have you had a look at runtime module?

I think we should detect the use here. But I haven't tested this new Node feature yet, I'll have a look.

@jean-michelet jean-michelet self-assigned this Jan 24, 2025
@SamSalvatico
Copy link
Contributor

runtime module

I gave a look to those links, but I cannot find a way in which the auto enable type stripping is checked, because it only looks for checkEnvVariable('FASTIFY_AUTOLOAD_TYPESCRIPT') or external tools, not node version

@jean-michelet
Copy link
Contributor

jean-michelet commented Jan 24, 2025

it only looks for checkEnvVariable('FASTIFY_AUTOLOAD_TYPESCRIPT') or external tools, not node version

You can have access Node version on process.

I think supportTypeScript should return true if node version >= 23.
Regarding testing, maybe we can create a script unit-typescript-native-type-strippping.js that exec ts test suite only if node version >= 23.

@jean-michelet
Copy link
Contributor

jean-michelet commented Jan 24, 2025

@mcollina
I started to work on this, I am positive I can push a PR soon, but this error will be unreachable from Node 23:
https://github.com/fastify/fastify-autoload/blob/master/lib/find-plugins.js#L148

So it does break the test that expect this error: https://github.com/fastify/fastify-autoload/tree/master/test/issues/369

For now, all I can think of is a wonky combination of a conditional test execution based on runtime Node version and ignoring coverage for L148.

@jean-michelet
Copy link
Contributor

Should we offer a way to enforce supportTypeScript = false? We can also try to check if the flag --no-experimental-strip-types is passed?

@mcollina
Copy link
Member Author

No, I don't think we should enforce it to false.

@mcollina
Copy link
Member Author

I would not try to check the cli option either.

@Fdawgs
Copy link
Member

Fdawgs commented Jan 31, 2025

Closed by #442

@Fdawgs Fdawgs closed this as completed Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants