To make a JS package consumable by a reasonably strict TS project, someone has to basically rewrite the package. It's less effort than writing one from scratch, but it's not free.
I’m not sure what you mean by “strict” here... Certainly one can use JavaScript from TypeScript, and even provide type information for the JS with declaration files. [1] Does a “strict” project require something beyond this?
[1] “Declaration Files”, TypeScript Handbook https://www.typescriptlang.org/docs/handbook/declaration-fil...
Adding the actually correct and reliable types is the hard part. (But easier than writing the code in the first place.)
Still, this is unforgivable in my book:
[] + {} == "[object Object]"
{} + [] == 0 Array.prototype.toString = function () {
return '[' + this.join(', ') + ']';
};
It would be convenient if Object.prototype.toString by default threw an exception, since the default breaks the embedding rule I described.The second example is misleading, and it has nothing to do with the rules for addition: the {} at the beginning of the expression is parsed as a code block, played off the rules for what the value of a Javascript statement is. More realistically, we have
({}) + [] == "[object Object]"
but the original is, effectively, {
}
console.log(+[]); * safe/unsafe
* strong/weak
* static/dynamic
Note that while safe/unsafe is basically all-or-nothing, strong/weak and static/dynamic are more of a spectrum, so JavaScript would be safe, weaker, and more dynamic than other languages. Typescript makes JS stronger when authoring code.'1'+1=2 prevents a lot of errors. The languages tries to help you along compared to an harsh error. Maybe you want a harsh error.. halting everything until you declare a new variable with the same type and have to go through a manual conversion. For me let the language handle that. If you are tdding anything unexpected will be caught anyhow if you are worried how things convert.
It's like rust in terms of memory management vs c. It handles it for you..