Everyone loves types, Everyone loves autocompletion, Everyone loves getting warnings before they arise.
But nobody likes wasting time compiling stuff. Hopefully this will help convince you or your company that you don't actually need the TypeScript flavor syntax. So i have embedded the same editor used in VS-code to show you that you can have type safety with vanilla JavaScript and have the best of both worlds and play around with it.
There are some hidden features available built right into VScode that not everyone knows about. They are so great that they are disabled by default as it almost seems like Microsoft wants you to use typescript instead and doesn't want you to use ESM or vanilla javascript.
Here are some features that should be enabled by default:
You could also add a jsconfig.json to your project. jsconfig.json is a jsconfig.json is a descendant of tsconfig.json, which is a configuration file for TypeScript. jsconfig.json is tsconfig.json with "allowJs" attribute set to true basically.
Having it can help you generate d.ts files
'#name'
is of type=string or that it's private with jsdoc, VS code can figure out by the constructors argument that name was of type string (judging by the default argument value)import()
when compiling to commonjsCommonJS do support dynamic import()
from commonjs since v12.17, TypeScript don't see it that way.`
TypeScript replace `import` with `require` and breaks esm-only imports
Even doe you can transpile to es modules 1:1 with some target configuration, TypeScript is pretty bad at handling extensions and have totally ignored the problem ever since 2017 up until today and said: "We don't want to touch it, or automatically fix the extension problem, we rely on `require()` to do the job of resolving index and extension-less stuff" to summarize it shortly and marked it as "work as intended"
So developers did just simply add `.js` as recommended by the by some guides like the Pure ESM package.
For Deno users this is also a big problem. They don't treat remote http import any differently than browser and requires explicit path to the other file and wants you to write `'./ModalBackground.ts'` and `../index.ts` - never `../` or `../index.js` when you only got a `index.ts` file
So, the best thing to do is to not to publish Noncompiled TypeScript packages. TypeScript adds compile time overhead so it will take longer time to load