You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Indicate typescript support in process.features #54294
Command line applications that want to load typescript configuration files should be able to detect whether the current node process is able to import typescript files to avoid an error during async import.
What is the feature you are proposing to solve the problem?
Add boolean value process.features.typescript to indicate whether --experimental-strip-types is enabled.
What alternatives have you considered?
It's possible to check for the presence of --experimental-strip-types in either process.execArgv or process.env.NODE_OPTIONS, but doing so is quite cumbersome.
As for my use case of loading a config file, I think I don't strictly need this given that Promise.any can solve this pretty nicely as one could just ignore the import error like this:
Activity
anonrig commentedon Aug 10, 2024
You can check it by accessing and checking process.argv - https://nodejs.org/docs/latest/api/process.html#processargv
silverwind commentedon Aug 11, 2024
Node-specifc options are not present in
argv, only onexecArgv. Also, those do not work whenNODE_OPTIONSis in use:Writing such a check currently would be clumsy and break if the experimental prefix is removed or the option is enabled by default:
silverwind commentedon Aug 11, 2024
As for my use case of loading a config file, I think I don't strictly need this given that
Promise.anycan solve this pretty nicely as one could just ignore the import error like this:anonrig commentedon Aug 11, 2024
I think this can still be easily supported on userland with a single line:
silverwind commentedon Aug 12, 2024
This works now, but it's bound to break once the
experimentalprefix is removed or when the setting is made the default.