-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Clarification regarding distributing TS source code instead of JS #6036
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
Comments
Common practice or best practice. Most runtimes don't support TypeScript as a first class language, ergo, there is little choice. That doesn't make it best practice.
JavaScript +
Again, distributing as We have discussed the TypeScript version issue. In the end, supporting n versions of TypeScript in the same runtime compiler doesn't help anyone in the long term. It simply drags around old code. Almost all of the "breaking" TypeScript changes make code more sound, or catch errors that were previously uncaught. It is actually better for everyone if we break that code, with an escape hatch of Another way to "fix" code for distribution, would be to use |
I would argue it is best practice because there ARE folks that prefer to distribute shared code as raw TS. (usually seen in internal teams from my experience) It is not nearly as common but it does happen. The scenario I outlined above is the reason not to do it.
I am not sure that is true. but could be missing something. https://github.com/deebloo/ts-dist-options This may be a non issue with Deno but I wanted to be certain. This would largely only cause issues with folks who use custom "tsconfig.json" which at least at this point does not seem very common. One Deno version supporting one Typescript version also makes sense. Is it possible for a user to provide a different version or is it locked to the version that is installed with Deno? |
I am of the opinion that given TypeScript has both a history of breaking changes and 31 boolean configuration options for the compiler the only sensible approach is to publish and consume JavaScript (which is backwards compatible) and leave the TypeScript as a purely authortime concern (since it is anyhow). |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Uh oh!
There was an error while loading. Please reload this page.
If this isn't the best place to post this please let me know and I will close and will ask elsewhere.
In the current day typescript world it is best practice to distribute compiled javascript alongside .d.ts files. This means that the end user doesn't need to worry about compiling the source code.
I know that Deno supports .d.ts files but it doesn't seem to be the preferred method based on the documentation/examples and I also see that it is limited (which makes sense).
What I have seen so far is that each user is fundamentally responsible for compiling a module's typescript code. This means that the user environment (Deno version, TS version, TS conifg, Deno config) would need to be the same/compatible with the authors environment.
Case:
Module author distributes a module where they use a custom tsconfig with more lax compiler options. (ex: sets strictNullChecks to false)
Result:
An end user using the default strict compiler options would potentially NOT be able to compile and run the module.
The other place this shows up is modules depending on the --unstable flag.
I am concerned this issue will continue to come up as the ecosystem grows and especially as new Typescript versions are released. Is there guidance for how to avoid the issues above?
Thanks for the great work! I hope to be able to contribute more than long github issues in the future.
EDIT: here is an example repo that demonstrates the potential issue I am thinking about https://github.com/deebloo/ts-dist-options
The text was updated successfully, but these errors were encountered: