[{"data":1,"prerenderedAt":257},["ShallowReactive",2],{"term-t\u002Ftype-safety":3,"related-t\u002Ftype-safety":239},{"id":4,"title":5,"acronym":6,"body":7,"category":220,"description":221,"difficulty":222,"extension":223,"letter":224,"meta":225,"navigation":130,"path":226,"related":227,"seo":233,"sitemap":234,"stem":237,"subcategory":6,"__hash__":238},"terms\u002Fterms\u002Ft\u002Ftype-safety.md","Type Safety",null,{"type":8,"value":9,"toc":214},"minimark",[10,15,19,23,26,30,203,207,210],[11,12,14],"h2",{"id":13},"eli5-the-vibe-check","ELI5 - The Vibe Check",[16,17,18],"p",{},"Type safety is your programming language refusing to let you accidentally add a number to a string and get a nonsense result back, or call a function with completely the wrong shape of data, without at least warning you first. A type-safe language catches an entire category of dumb mistakes before your code ever runs, instead of letting you discover them from a confused user's bug report.",[11,20,22],{"id":21},"real-talk","Real Talk",[16,24,25],{},"Type safety is the degree to which a programming language prevents type errors, meaning operations performed on values of an inappropriate or unexpected type, either at compile time (static type safety, as in TypeScript or Rust) or at runtime (dynamic type safety, as in Python raising a TypeError rather than silently corrupting data). A fully type-safe language guarantees that no operation is ever applied to data it wasn't designed to handle, catching a large class of bugs before they reach production.",[11,27,29],{"id":28},"show-me-the-code","Show Me The Code",[31,32,37],"pre",{"className":33,"code":34,"language":35,"meta":36,"style":36},"language-typescript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u002F\u002F unsafe: silently returns a nonsense string\nfunction add(a, b) { return a + b }\nadd(\"5\", 3) \u002F\u002F \"53\", not what you wanted\n\n\u002F\u002F type-safe: caught at compile time\nfunction add(a: number, b: number): number { return a + b }\nadd(\"5\", 3) \u002F\u002F Error: Argument of type 'string' is not assignable to type 'number'\n","typescript","",[38,39,40,49,96,125,132,138,181],"code",{"__ignoreMap":36},[41,42,45],"span",{"class":43,"line":44},"line",1,[41,46,48],{"class":47},"sHwdD","\u002F\u002F unsafe: silently returns a nonsense string\n",[41,50,52,56,60,64,68,71,74,77,80,84,88,91,93],{"class":43,"line":51},2,[41,53,55],{"class":54},"spNyl","function",[41,57,59],{"class":58},"s2Zo4"," add",[41,61,63],{"class":62},"sMK4o","(",[41,65,67],{"class":66},"sHdIc","a",[41,69,70],{"class":62},",",[41,72,73],{"class":66}," b",[41,75,76],{"class":62},")",[41,78,79],{"class":62}," {",[41,81,83],{"class":82},"s7zQu"," return",[41,85,87],{"class":86},"sTEyZ"," a",[41,89,90],{"class":62}," +",[41,92,73],{"class":86},[41,94,95],{"class":62}," }\n",[41,97,99,102,104,107,111,113,115,119,122],{"class":43,"line":98},3,[41,100,101],{"class":58},"add",[41,103,63],{"class":86},[41,105,106],{"class":62},"\"",[41,108,110],{"class":109},"sfazB","5",[41,112,106],{"class":62},[41,114,70],{"class":62},[41,116,118],{"class":117},"sbssI"," 3",[41,120,121],{"class":86},") ",[41,123,124],{"class":47},"\u002F\u002F \"53\", not what you wanted\n",[41,126,128],{"class":43,"line":127},4,[41,129,131],{"emptyLinePlaceholder":130},true,"\n",[41,133,135],{"class":43,"line":134},5,[41,136,137],{"class":47},"\u002F\u002F type-safe: caught at compile time\n",[41,139,141,143,145,147,149,152,156,158,160,162,164,167,169,171,173,175,177,179],{"class":43,"line":140},6,[41,142,55],{"class":54},[41,144,59],{"class":58},[41,146,63],{"class":62},[41,148,67],{"class":66},[41,150,151],{"class":62},":",[41,153,155],{"class":154},"sBMFI"," number",[41,157,70],{"class":62},[41,159,73],{"class":66},[41,161,151],{"class":62},[41,163,155],{"class":154},[41,165,166],{"class":62},"):",[41,168,155],{"class":154},[41,170,79],{"class":62},[41,172,83],{"class":82},[41,174,87],{"class":86},[41,176,90],{"class":62},[41,178,73],{"class":86},[41,180,95],{"class":62},[41,182,184,186,188,190,192,194,196,198,200],{"class":43,"line":183},7,[41,185,101],{"class":58},[41,187,63],{"class":86},[41,189,106],{"class":62},[41,191,110],{"class":109},[41,193,106],{"class":62},[41,195,70],{"class":62},[41,197,118],{"class":117},[41,199,121],{"class":86},[41,201,202],{"class":47},"\u002F\u002F Error: Argument of type 'string' is not assignable to type 'number'\n",[11,204,206],{"id":205},"when-youll-hear-this","When You'll Hear This",[16,208,209],{},"\"Switching to TypeScript gave us type safety we didn't know we were missing.\" \u002F \"That bug wouldn't have shipped if the API response had any type safety at all.\"",[211,212,213],"style",{},"html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":36,"searchDepth":51,"depth":51,"links":215},[216,217,218,219],{"id":13,"depth":51,"text":14},{"id":21,"depth":51,"text":22},{"id":28,"depth":51,"text":29},{"id":205,"depth":51,"text":206},"general","Type safety is your programming language refusing to let you accidentally add a number to a string and get a nonsense result back, or call a function with...","intermediate","md","t",{},"\u002Fterms\u002Ft\u002Ftype-safety",[228,229,230,231,232],"Static Typing","Dynamic Typing","TypeScript","Type Inference","Duck Typing",{"title":5,"description":221},{"changefreq":235,"priority":236},"weekly",0.7,"terms\u002Ft\u002Ftype-safety","VMyHZFh5_fS1zYn4nPjavzT6Om77hwC63vaKetq1IBA",[240,244,247,250,253],{"title":232,"path":241,"acronym":6,"category":220,"difficulty":242,"description":243},"\u002Fterms\u002Fd\u002Fduck-typing","beginner","Duck typing is the ultimate 'don't ask for a resume' approach. If it walks like a duck and quacks like a duck, it's a duck.",{"title":229,"path":245,"acronym":6,"category":220,"difficulty":222,"description":246},"\u002Fterms\u002Fd\u002Fdynamic-typing","Dynamic typing is like a box that can hold anything — toys, food, or a cat — and you don't have to label what goes in it ahead of time.",{"title":228,"path":248,"acronym":6,"category":220,"difficulty":222,"description":249},"\u002Fterms\u002Fs\u002Fstatic-typing","Static typing means you have to tell the computer what type each variable is when you write the code, and it checks everything is correct BEFORE running.",{"title":231,"path":251,"acronym":6,"category":220,"difficulty":222,"description":252},"\u002Fterms\u002Ft\u002Ftype-inference","Type inference is the compiler being smart enough to figure out what type something is without you having to spell it out.",{"title":230,"path":254,"acronym":6,"category":255,"difficulty":222,"description":256},"\u002Fterms\u002Ft\u002Ftypescript","frontend","TypeScript is JavaScript with a strict parent watching over it.",1792528133219]