Where Do External Types Come From?
Orta Therox, a former member of the core TypeScript team, discusses how types that you don't define can make their way into your application code.
0:00 I spoke to [indecipherable] , who used to be a member of the TypeScript team, and he mentioned there are four different spaces where types that you don't define come into your application code.
0:11 I'd say there are roughly four spaces where types can come into your projects. The types that get shipped with TypeScript, we would refer to as lib.d.ts. There's the DOM types, which dom.d.ts. There's definitely typed, and then there's included inside your either codebase or your Node Package Manager.
0:46 What you're saying is, let's say, const Whatever = Map. Going from this, how would I say, "OK, I want to see where this d.ts file is coming from?"
0:56 Are you on a Mac? You could command and click on that. It should, actually show you.
1:50 The next space where types come into your project is in the DOM typings.
2:11 It was a very reasonable idea and it still probably is to include dom.d.ts as the default. Lib.dom.d.ts is pretty complicated project that outputs a single DOM file and that small iteration file that you saw next to it.
2:26 This one is a separate repo from the TypeScript repo. It is maintained by an outside collaborator who works at Mozilla and is constantly up-to-date with spec changes in web browsers.
2:42 The problem with this one is realistically, you don't want a version your web browsers in the way that you might for your language. Our rules for this are if a feature is in the Web platform in general and you can see it in at least two browsers, that's Firefox, Safari, or Chrome EUMS. It has to be in two of those to be allowed in.
3:26 That is constantly updated. We get notifications about new updates all the time and this always represents the latest version of the DOM.
3:35 The third space is...
4:10 There are a set of absolute heroes that try to map this very complicated system of React into a runtime that can exist inside the type system.
4:23 The fourth space where types can come into your project.
5:11 Here you go. The four different spaces where types can come into your app, lib.d.ts, the DOM typings, definitely typed, and types that ship with libraries that have been built with TypeScript.