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 6: Use Your Editor to Interrogate and Explore the Type System
Things to Remember
Take advantage of the TypeScript language services by using an editor that supports them.
Use your editor to build an intuition for how the type system works and how TypeScript infers types.
Familiarize yourself with TypeScript's refactoring tools, e.g., renaming symbols and files.
Know how to jump into type declaration files to see how they model behavior.
Code Samples
functiongetElement(elOrId: string|HTMLElement|null): HTMLElement{if(typeofelOrId==='object'){returnelOrId;// ~~~ Type 'HTMLElement | null' is not assignable to type 'HTMLElement'}elseif(elOrId===null){returndocument.body;}elOrId// ^? (parameter) elOrId: stringreturndocument.getElementById(elOrId);// ~~~ Type 'HTMLElement | null' is not assignable to type 'HTMLElement'}