![Lautsprecheranlage 📢](https://abs.twimg.com/emoji/v2/72x72/1f4e2.png)
"10 Insights from Adopting TypeScript at Scale"
https://www.techatbloomberg.com/blog/10-insights-adopting-typescript-at-scale/
This is the first time we've really talked about our TypeScript infrastructure, despite it being used by over 300 internal projects. So there is a lot to unpack ![Verpacktes Geschenk 🎁](https://abs.twimg.com/emoji/v2/72x72/1f381.png)
Here's the OMGTLDR...
![Verpacktes Geschenk 🎁](https://abs.twimg.com/emoji/v2/72x72/1f381.png)
Here's the OMGTLDR...
![Elektrische Glühbirne 💡](https://abs.twimg.com/emoji/v2/72x72/1f4a1.png)
It's easy to take a JS purist approach & use TypeScript solely for erasable types. Use `target:ESNext` & avoid the TS features that affect the emitted JS runtime code.
This separation of concerns is no accident!
![Elektrische Glühbirne 💡](https://abs.twimg.com/emoji/v2/72x72/1f4a1.png)
TypeScript keeps getting better. There's strong incentives to use new versions. Keeping TypeScript up-to-date across your packages ensures declaration file compatibility & allows early impact assessment of nightly/Beta/RC releases.
![Elektrische Glühbirne 💡](https://abs.twimg.com/emoji/v2/72x72/1f4a1.png)
If you maintain a set of packages, it's best to avoid divergence in the TypeScript configurations as much as possible. In some cases mismatched settings can lead to inter-project type conflicts. https://twitter.com/matteocollina/status/1305900193582403585
![Elektrische Glühbirne 💡](https://abs.twimg.com/emoji/v2/72x72/1f4a1.png)
Using tsconfig "paths" to define where your dependencies live can have surprising results in the generated declaration files.
Declaring Ambient Modules instead of "paths" side-steps this issue.
https://www.typescriptlang.org/docs/handbook/modules.html#ambient-modules
![Elektrische Glühbirne 💡](https://abs.twimg.com/emoji/v2/72x72/1f4a1.png)
If any of your types use pinned "dependencies" in package.json, you may end up with multiple different versions of the types for a given package. This can result in staleness and nominality issues.
![Elektrische Glühbirne 💡](https://abs.twimg.com/emoji/v2/72x72/1f4a1.png)
Global types are bad for the same reasons that global variables are bad. Avoid global types where possible.
Prefer modular types that must be imported explicitly.
![Elektrische Glühbirne 💡](https://abs.twimg.com/emoji/v2/72x72/1f4a1.png)
A *.d.ts file operates in one of 3 different ways, based on its content. You can classify a given declaration file as either:
1
![Amerika auf dem Globus 🌎](https://abs.twimg.com/emoji/v2/72x72/1f30e.png)
2
![Paket 📦](https://abs.twimg.com/emoji/v2/72x72/1f4e6.png)
3
![Halloweenkürbis 🎃](https://abs.twimg.com/emoji/v2/72x72/1f383.png)
![Elektrische Glühbirne 💡](https://abs.twimg.com/emoji/v2/72x72/1f4a1.png)
Node packages can declare multiple entrypoints, e.g. "lodash/pick", "lodash/get"
TypeScript's declaration emit does not respect this, so generated declarations can contain injected imports to private files deep in other packages.
![Elektrische Glühbirne 💡](https://abs.twimg.com/emoji/v2/72x72/1f4a1.png)
Declaration files generated by TypeScript can contain lots of duplicated types. This is because types are sometimes inlined, rather than being referenced by name from their original location. https://twitter.com/robpalmer2/status/1319188885197422594
![Elektrische Glühbirne 💡](https://abs.twimg.com/emoji/v2/72x72/1f4a1.png)
Declaration files emitted by TypeScript often contain types & imports that are not relevant to users of your package.
Dead Type Elimination (Tree-Shaking!) can drastically reduce the volume of types you ship
![Feuer 🔥](https://abs.twimg.com/emoji/v2/72x72/1f525.png)
Thanks to the TypeScript team for building such a great technology. Especially to @sheetalkamat @atcb @sanders_n @orta @SeaRyanC @drosenwasser who all helped us out at some point along the way
![Thumbs up 👍](https://abs.twimg.com/emoji/v2/72x72/1f44d.png)
And thanks to the @TechAtBloomberg folk who built our JS/TS infrastructure @hughcrail @TChetwin @lilitdarbinyan @r_ricard @mkubilayk & @maxheiber
![Partyknaller 🎉](https://abs.twimg.com/emoji/v2/72x72/1f389.png)