[{"data":1,"prerenderedAt":421,"buildId":422},["ShallowReactive",2],{"page:\u002Fextensions\u002Fkubb-labs\u002Fplugin-ts\u002Fguides\u002Fmigrate-to-v6":3},{"id":4,"frontmatter":5,"title":6,"heading":6,"body":7,"path":420,"source":4},"extensions\u002Fkubb-labs\u002Fplugin-ts\u002Fguides\u002Fmigrate-to-v6.md",{},"Migrate to v6",{"type":8,"value":9,"toc":406},"minimark",[10,19,30,35,149,152,248,251,281,285,288],[11,12,13,14,18],"p",{},"Upgrade ",[15,16,17],"code",{},"@kubb\u002Fplugin-ts"," from v5 to v6, which writes each operation's types inline where clients, hooks, and mocks use them, instead of in a types file per operation.",[11,20,21,22,25,26,29],{},"Code that only calls the generated functions or hooks needs a regenerate. Code that imports an operation type, such as ",[15,23,24],{},"AddPetResponses"," or ",[15,27,28],{},"GetPetByIdStatus200",", needs the edit below.",[31,32,34],"h2",{"id":33},"upgrade-steps","Upgrade steps",[36,37,39,44,53,92,96,99,112,116,119,131,135],"steps",{"level":38},"3",[40,41,43],"h3",{"id":42},"upgrade-the-packages","Upgrade the packages",[11,45,13,46,49,50,52],{},[15,47,48],{},"kubb"," and ",[15,51,17],{}," together. v6 needs Kubb 5.27.1 or later:",[54,55,59],"pre",{"language":56,"code":57,"class":58},"bash","npm install --save-dev kubb@latest @kubb\u002Fplugin-ts@6","highlights",[15,60,62],{"class":61},"language-bash",[63,64,67,71,75,78,81,83,86,88],"span",{"class":65,"style":66},"line","display: inline",[63,68,70],{"style":69},"color:#6f42c1;--hls-dark:#b392f0","npm ",[63,72,74],{"style":73},"color:#24292e;--hls-dark:#e1e4e8","install --save-dev kubb",[63,76,77],{"style":73},"@",[63,79,80],{"style":73},"latest ",[63,82,77],{"style":73},[63,84,85],{"style":73},"kubb\u002Fplugin-ts",[63,87,77],{"style":73},[63,89,91],{"style":90},"color:#005cc5;--hls-dark:#79b8ff","6",[40,93,95],{"id":94},"regenerate","Regenerate",[11,97,98],{},"This removes the per-operation type files:",[54,100,102],{"language":56,"code":101,"class":58},"npx kubb generate",[15,103,104],{"class":61},[63,105,106,109],{"class":65,"style":66},[63,107,108],{"style":69},"npx ",[63,110,111],{"style":73},"kubb generate",[40,113,115],{"id":114},"run-the-type-checker","Run the type checker",[11,117,118],{},"An import of a removed operation type shows up as a compile error:",[54,120,122],{"language":56,"code":121,"class":58},"npx tsc --noEmit",[15,123,124],{"class":61},[63,125,126,128],{"class":65,"style":66},[63,127,108],{"style":69},[63,129,130],{"style":73},"tsc --noEmit",[40,132,134],{"id":133},"fix-each-error","Fix each error",[11,136,137,138,143,144,148],{},"Find its row in ",[139,140,142],"a",{"href":141},"#what-to-change","What to change",". Then check the ",[139,145,147],{"href":146},"#behavior-changes","behavior changes",", which compile without errors.",[31,150,142],{"id":151},"what-to-change",[153,154,155,168],"table",{},[156,157,158],"thead",{},[159,160,161,165],"tr",{},[162,163,164],"th",{},"You used",[162,166,167],{},"Now",[169,170,171,200,218,232],"tbody",{},[159,172,173,186],{},[174,175,176,177,180,181,183,184],"td",{},"An operation type, such as ",[15,178,179],{},"AddPetOptions",", ",[15,182,24],{},", or ",[15,185,28],{},[174,187,188,189,192,193,199],{},"Import the schema type, such as ",[15,190,191],{},"Pet",", or set ",[139,194,196],{"href":195},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-ts\u002Foptions#operations",[15,197,198],{},"operations: 'export'"," to keep the operation types.",[159,201,202,212],{},[174,203,204,205,208,209],{},"A responses type passed to ",[15,206,207],{},"isResponseError",", such as ",[15,210,211],{},"isResponseError\u003CGetPetByIdResponses>(error)",[174,213,214,215,217],{},"Set ",[15,216,198],{},". Inline mode has no named responses type.",[159,219,220,226],{},[174,221,222,223],{},"A per-operation file, such as ",[15,224,225],{},"types\u002Fpet\u002FAddPet.ts",[174,227,228,229,231],{},"Removed. Set ",[15,230,198],{}," to write it again.",[159,233,234,241],{},[174,235,236,237,240],{},"The ",[15,238,239],{},"examples"," option of a custom printer",[174,242,243,244,247],{},"Removed. A type no longer carries the ",[15,245,246],{},"@example"," of its whole schema.",[11,249,250],{},"To keep the v5 output, set the old default:",[54,252,256],{"language":253,"filename":254,"code":255,"class":58},"typescript","kubb.config.ts","pluginTs({ operations: 'export' })",[15,257,259],{"class":258},"language-typescript",[63,260,261,264,267,270,274,278],{"class":65,"style":66},[63,262,263],{"style":69},"pluginTs",[63,265,266],{"style":90},"({ ",[63,268,269],{"style":90},"operations",[63,271,273],{"style":272},"color:#d73a49;--hls-dark:#f97583",": ",[63,275,277],{"style":276},"color:#032f62;--hls-dark:#9ecbff","'export' ",[63,279,280],{"style":90},"})",[31,282,284],{"id":283},"behavior-changes","Behavior changes",[11,286,287],{},"These compile without errors:",[153,289,290,303],{},[156,291,292],{},[159,293,294,297,300],{},[162,295,296],{},"Area",[162,298,299],{},"v5",[162,301,302],{},"v6",[169,304,305,320,346,357,371,391],{},[159,306,307,310,313],{},[174,308,309],{},"Output",[174,311,312],{},"One types file per operation.",[174,314,315,316,319],{},"Only schema types. With a single output file, such as ",[15,317,318],{},"output: { path: 'types.ts' }",", operation types stay exported.",[159,321,322,325,328],{},[174,323,324],{},"Names",[174,326,327],{},"An inlined schema could share a name with a type the file already uses.",[174,329,330,331,334,335,183,338,341,342,345],{},"It gets an alias, such as ",[15,332,333],{},"Options2"," next to the client's ",[15,336,337],{},"Options",[15,339,340],{},"Response2"," next to the fetch ",[15,343,344],{},"Response",".",[159,347,348,351,354],{},[174,349,350],{},"Enums",[174,352,353],{},"An enum declared inside an operation got its own declaration.",[174,355,356],{},"It becomes a literal union in inline mode.",[159,358,359,362,365],{},[174,360,361],{},"Headers",[174,363,364],{},"Each status code repeated its response headers type.",[174,366,367,368,345],{},"A status code with the same headers as an earlier one aliases it: ",[15,369,370],{},"ListPetsStatus429Headers = ListPetsStatus200Headers",[159,372,373,376,385],{},[174,374,375],{},"Comments",[174,377,378,379,208,382,345],{},"Property comments ended with ",[15,380,381],{},"@type",[15,383,384],{},"@type integer | undefined",[174,386,387,388,390],{},"No ",[15,389,381],{}," tag.",[159,392,393,395,401],{},[174,394,375],{},[174,396,397,398,400],{},"A type carried the ",[15,399,246],{}," of its whole schema or response body.",[174,402,403,404,345],{},"Only properties carry ",[15,405,246],{},{"title":407,"searchDepth":408,"depth":408,"links":409},"",5,[410,418,419],{"id":33,"depth":411,"text":34,"children":412},2,[413,415,416,417],{"id":42,"depth":414,"text":43},3,{"id":94,"depth":414,"text":95},{"id":114,"depth":414,"text":115},{"id":133,"depth":414,"text":134},{"id":151,"depth":411,"text":142},{"id":283,"depth":411,"text":284},"\u002Fextensions\u002Fkubb-labs\u002Fplugin-ts\u002Fguides\u002Fmigrate-to-v6",1795727686681,"1b64b1eb-29b7-4f90-ad41-6f24721e1669"]