LearningTypeScript / site

Companion website for the Learning TypeScript book.
https://learningtypescript.com
MIT License
48 stars 12 forks source link

Article: how to override third party types? #85

Open JoshuaKGoldberg opened 2 years ago

JoshuaKGoldberg commented 2 years ago

A question brought up on my Twitch stream today: overriding types of third party libraries if the types aren't made to be extended?

Example: some-library exports an interface MyData, and in your code you need to have an extra property myProperty added to all instances of MyData?

A more specific example: https://github.com/versatica/mediasoup/blob/41e2f52786a61942209512ca5ce20798baad8b96/node/lib/Worker.d.ts#L39

Thanks voltaryx on Twitch for bringing up! 🙌

JoshuaKGoldberg commented 2 years ago

See also: https://twitter.com/phunkren/status/1561794275855241216