You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Item 76: Create an Accurate Model of Your Environment
Things to Remember
Your code runs in a particular environment. TypeScript will do a better job of checking your code if you create an accurate static model of that environment.
Model global variables and libraries that are loaded onto a web page along with your code.
Match versions between type declarations and the libraries and runtime environment that you use.
Use multiple tsconfig.json files and project references to model distinct environments within a single project (for example client and server).
Code Samples
// user-info-global.d.tsinterfaceUserInfo{name: string;accountId: string;}declare global {interfaceWindow{userInfo: UserInfo;}}
importsunrisePathfrom'./images/beautiful-sunrise.jpg';// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// Cannot find module './images/beautiful-sunrise.jpg' or its type declarations.