TypeScript: extend Window object
19 September 2022 (Updated 19 September 2022)
Suppose you’re using a JavaScript library that adds a tidioChatApi
property to the Window
object. You can tell TypeScript about this global property by adding something like the following to a d.ts
file (e.g., types/window.d.ts
).
declare global {
interface Window {
tidioChatApi: { [key: string]: any } // or whatever type
}
}
export {}
Tagged:
TypeScript
Thanks for your comment 🙏. Once it's approved, it will appear here.
Leave a comment