[{"data":1,"prerenderedAt":356},["ShallowReactive",2],{"navigation_docs":3,"-introduction-built-on-typescript-go":132,"-introduction-built-on-typescript-go-surround":351},[4,27,69,91,127],{"title":5,"icon":6,"redirect":7,"path":8,"stem":9,"children":10,"page":26},"Introduction","i-lucide-rocket","\u002Fintroduction\u002Fabout-ts-runtypes","\u002Fintroduction","1.introduction",[11,14,18,22],{"title":12,"path":7,"stem":13},"About RunTypes","1.introduction\u002F1.about-ts-runtypes",{"title":15,"path":16,"stem":17},"Built on typescript-go","\u002Fintroduction\u002Fbuilt-on-typescript-go","1.introduction\u002F2.built-on-typescript-go",{"title":19,"path":20,"stem":21},"Quick Start","\u002Fintroduction\u002Fquick-start","1.introduction\u002F3.quick-start",{"title":23,"path":24,"stem":25},"Configuration","\u002Fintroduction\u002Fconfiguration","1.introduction\u002F4.configuration",false,{"title":28,"icon":29,"redirect":30,"path":31,"stem":32,"children":33,"page":26},"Guide","i-lucide-book-open","\u002Fguide\u002Ftypes-vs-schemas","\u002Fguide","2.guide",[34,37,41,45,49,53,57,61,65],{"title":35,"path":30,"stem":36},"Types vs Schemas","2.guide\u002F1.types-vs-schemas",{"title":38,"path":39,"stem":40},"Type Formats","\u002Fguide\u002Ftype-formats","2.guide\u002F2.type-formats",{"title":42,"path":43,"stem":44},"Reflection","\u002Fguide\u002Freflection","2.guide\u002F3.reflection",{"title":46,"path":47,"stem":48},"Serialization","\u002Fguide\u002Fserialization","2.guide\u002F4.serialization",{"title":50,"path":51,"stem":52},"Validation","\u002Fguide\u002Fvalidation","2.guide\u002F5.validation",{"title":54,"path":55,"stem":56},"Data Mocking","\u002Fguide\u002Fmocking","2.guide\u002F6.mocking",{"title":58,"path":59,"stem":60},"Compiler Markers","\u002Fguide\u002Fcompiler-markers","2.guide\u002F7.compiler-markers",{"title":62,"path":63,"stem":64},"Pure Functions","\u002Fguide\u002Fpure-functions","2.guide\u002F8.pure-functions",{"title":66,"path":67,"stem":68},"Linting","\u002Fguide\u002Flinting","2.guide\u002F9.linting",{"title":70,"icon":71,"redirect":72,"path":73,"stem":74,"children":75,"page":26},"AI Integration","i-lucide-sparkles","\u002Fai-integration\u002Fworkflow-and-commands","\u002Fai-integration","3.ai-integration",[76,79,83,87],{"title":77,"path":72,"stem":78},"AI Workflow","3.ai-integration\u002F1.workflow-and-commands",{"title":80,"path":81,"stem":82},"FriendlyText","\u002Fai-integration\u002Ffriendly-type","3.ai-integration\u002F2.friendly-type",{"title":84,"path":85,"stem":86},"MockData","\u002Fai-integration\u002Fmock-data","3.ai-integration\u002F3.mock-data",{"title":88,"path":89,"stem":90},"Translations (i18n)","\u002Fai-integration\u002Fi18n","3.ai-integration\u002F4.i18n",{"title":92,"icon":93,"redirect":94,"path":95,"stem":96,"children":97,"page":26},"Benchmarks","i-lucide-gauge","\u002Fbenchmarks\u002Fvalidation","\u002Fbenchmarks","7.benchmarks",[98,100,104,108,112,115,119,123],{"title":50,"path":94,"stem":99},"7.benchmarks\u002F1.validation",{"title":101,"path":102,"stem":103},"Validation Formats","\u002Fbenchmarks\u002Fvalidation-formats","7.benchmarks\u002F2.validation-formats",{"title":105,"path":106,"stem":107},"Validation Errors","\u002Fbenchmarks\u002Fgetvalidationerrors","7.benchmarks\u002F3.getvalidationerrors",{"title":109,"path":110,"stem":111},"Validation Error Formats","\u002Fbenchmarks\u002Fgetvalidationerrors-formats","7.benchmarks\u002F4.getvalidationerrors-formats",{"title":46,"path":113,"stem":114},"\u002Fbenchmarks\u002Fserialization","7.benchmarks\u002F5.serialization",{"title":116,"path":117,"stem":118},"Serialization Formats","\u002Fbenchmarks\u002Fserialization-formats","7.benchmarks\u002F6.serialization-formats",{"title":120,"path":121,"stem":122},"Compile Time","\u002Fbenchmarks\u002Fcompiletime","7.benchmarks\u002F7.compiletime",{"title":124,"path":125,"stem":126},"Correctness","\u002Fbenchmarks\u002Fcorrectness","7.benchmarks\u002F8.correctness",{"title":128,"path":129,"stem":130,"icon":131},"Diagnostics","\u002Fdiagnostics","8.diagnostics","i-lucide-triangle-alert",{"id":133,"title":15,"body":134,"description":344,"extension":345,"links":346,"meta":347,"navigation":348,"path":16,"seo":349,"stem":17,"__hash__":350},"docs\u002F1.introduction\u002F2.built-on-typescript-go.md",{"type":135,"value":136},"minimark",[137,151,156,159,191,195,204,207,255,258,262,268,274,292,296,299,305,328,331,340],[138,139,140,141,145,146,150],"p",{},"RunTypes does not reimplement TypeScript. It is built directly on top of ",[142,143,144],"strong",{},"typescript-go",", the native Go rewrite of the TypeScript compiler (the same one shipping as TypeScript 7, run from your terminal as ",[147,148,149],"code",{},"tsgo","). When RunTypes reads your types, it asks that compiler, so the answer is exactly the answer TypeScript would give.",[152,153,155],"h2",{"id":154},"a-superset-not-a-dialect","A superset, not a dialect",[138,157,158],{},"RunTypes adds a layer on top of TypeScript. It never changes the language underneath.",[160,161,162,175,185],"ul",{},[163,164,165,168,169,171,172,174],"li",{},[142,166,167],{},"Anything that works on typescript-go works with RunTypes."," Your types are resolved by the same checker ",[147,170,149],{}," uses, so whatever ",[147,173,149],{}," understands, RunTypes understands in exactly the same way.",[163,176,177,180,181,184],{},[142,178,179],{},"100% compatible."," There is no special compiler flag to switch on and no schema dialect to learn. Point the plugin at your existing ",[147,182,183],{},"tsconfig.json"," and your types are the schema.",[163,186,187,190],{},[142,188,189],{},"A strict superset."," You keep everything TypeScript already gives you, and on top of it you get runtime functions generated from those same types: validators, JSON and binary serializers, mock data and reflection.",[152,192,194],{"id":193},"the-whole-compiler-is-in-the-box","The whole compiler is in the box",[138,196,197,198,200,201,203],{},"The RunTypes binary loads your ",[147,199,183],{},", builds the same program ",[147,202,149],{}," would build, and runs the same type checker. The complete compiler lives inside it.",[138,205,206],{},"You can see the exact compiler revision it carries:",[208,209,214],"pre",{"className":210,"code":211,"language":212,"meta":213,"style":213},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","$ npx ts-runtypes-bin --version\nts-runtypes 0.1.0 (tsgo v0.21.1)\n","bash","",[147,215,216,235],{"__ignoreMap":213},[217,218,221,225,229,232],"span",{"class":219,"line":220},"line",1,[217,222,224],{"class":223},"sBMFI","$",[217,226,228],{"class":227},"sfazB"," npx",[217,230,231],{"class":227}," ts-runtypes-bin",[217,233,234],{"class":227}," --version\n",[217,236,238,241,245,249,252],{"class":219,"line":237},2,[217,239,240],{"class":223},"ts-runtypes",[217,242,244],{"class":243},"sbssI"," 0.1.0",[217,246,248],{"class":247},"sTEyZ"," (tsgo ",[217,250,251],{"class":227},"v0.21.1",[217,253,254],{"class":247},")\n",[138,256,257],{},"The value in parentheses is the pinned typescript-go revision the binary was built against (your exact numbers will differ per release). Your types are read by a real, known version of the TypeScript compiler, never an approximation of it.",[152,259,261],{"id":260},"you-could-compile-with-it-but-that-is-not-the-point","You could compile with it, but that is not the point",[138,263,264,265,267],{},"Because the full compiler is embedded, the binary could in principle type check or even emit JavaScript for your whole project, the same way ",[147,266,149],{}," does. We deliberately do not do that.",[138,269,270,271,273],{},"Compiling and type checking TypeScript is ",[147,272,149],{},"'s job, and it already does it well. RunTypes has a single job: take the compiler's understanding of your types and turn it into runtime code. We borrow the type system, we do not try to take over your build.",[275,276,277,278,281,282,285,286,288,289,291],"note",{},"RunTypes ships no ",[147,279,280],{},"build"," or ",[147,283,284],{},"tsc"," style command. It reads your types and emits runtime functions. Keep running ",[147,287,149],{}," (or ",[147,290,284],{},") for your build exactly as you do today.",[152,293,295],{"id":294},"current-status-a-preview-compiler-two-passes","Current status: a preview compiler, two passes",[138,297,298],{},"Two honest caveats, both rooted in where the Go compiler is today.",[138,300,301,304],{},[142,302,303],{},"typescript-go is still a preview."," TypeScript 7, the native compiler, is under active development and is not yet the stable default. RunTypes tracks it as it matures, so the occasional rough edge comes from the foundation still being in preview.",[138,306,307,310,311,318,319,321,322,324,325,327],{},[142,308,309],{},"For now, RunTypes runs as a second pass."," The hook that once let runtime libraries plug into the compiler was never ported to the Go compiler (",[312,313,317],"a",{"href":314,"rel":315},"https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002Ftypescript-go\u002Fissues\u002F516",[316],"nofollow","microsoft\u002Ftypescript-go#516","), and there is no supported way to run inside it yet. So today ",[147,320,149],{}," and the RunTypes binary are two separate processes: your normal build runs ",[147,323,149],{},", and the plugin runs our binary alongside it. Each one builds its own view of the project, which means your files are read twice, once by ",[147,326,149],{}," for your build and once by RunTypes for the generated code.",[138,329,330],{},"That second pass is a real cost, and it is a current limitation rather than the destination. If the compiler ever exposes a supported extension point, RunTypes would fold into a single pass. Until then the extra read stays where it belongs, at build time, and nothing about it reaches your runtime bundle.",[138,332,333,334,336,337,339],{},"See ",[312,335,12],{"href":7}," for the design decisions behind all of this, or jump to the ",[312,338,19],{"href":20}," to wire it up.",[341,342,343],"style",{},"html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}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 .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}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);}","RunTypes is built on the real typescript-go compiler and stays a 100% compatible superset.","md",null,{"toc":26},true,{"title":15,"description":344},"soJ1x0fSzs6l6BengglZwA8iE9_P_6-GiSceaFQR-HI",[352,354],{"title":12,"path":7,"stem":13,"description":353,"children":-1},"The design decisions behind RunTypes and why everything happens at build time.",{"title":19,"path":20,"stem":21,"description":355,"children":-1},"Install the package + Vite plugin and generate your first validator from a TypeScript type.",1785369663347]