[{"data":1,"prerenderedAt":708,"buildId":709},["ShallowReactive",2],{"page:\u002Fextensions\u002Fkubb-labs\u002Fplugin-ts":3},{"id":4,"frontmatter":5,"title":6,"heading":6,"body":7,"path":707,"source":4},"extensions\u002Fkubb-labs\u002Fplugin-ts\u002Findex.md",{},"TypeScript",{"type":8,"value":9,"toc":698},"minimark",[10,14,22,27,127,157,161,164,168,332,355,359,378,691],[11,12,13],"p",{},"The TypeScript plugin generates a type for every schema in your OpenAPI spec, plus the request, response, and parameter types of each operation.",[11,15,16,17,21],{},"The other Kubb plugins import these types, and Kubb runs this plugin before them, whatever the order of ",[18,19,20],"code",{},"plugins",".",[23,24,26],"h2",{"id":25},"installation","Installation",[28,29,31,54,74,92,110],"code-group",{"sync":30},"install",[32,33,38],"pre",{"language":34,"filename":35,"code":36,"class":37},"shell","kubb","kubb add plugin-ts","highlights",[18,39,41],{"class":40},"language-shell",[42,43,46,50],"span",{"class":44,"style":45},"line","display: inline",[42,47,49],{"style":48},"color:#6f42c1;--hls-dark:#b392f0","kubb ",[42,51,53],{"style":52},"color:#24292e;--hls-dark:#e1e4e8","add plugin-ts",[32,55,58],{"language":34,"filename":56,"code":57,"class":37},"bun","bun add -d @kubb\u002Fplugin-ts",[18,59,60],{"class":40},[42,61,62,65,68,71],{"class":44,"style":45},[42,63,64],{"style":48},"bun ",[42,66,67],{"style":52},"add -d ",[42,69,70],{"style":52},"@",[42,72,73],{"style":52},"kubb\u002Fplugin-ts",[32,75,78],{"language":34,"filename":76,"code":77,"class":37},"pnpm","pnpm add -D @kubb\u002Fplugin-ts",[18,79,80],{"class":40},[42,81,82,85,88,90],{"class":44,"style":45},[42,83,84],{"style":48},"pnpm ",[42,86,87],{"style":52},"add -D ",[42,89,70],{"style":52},[42,91,73],{"style":52},[32,93,96],{"language":34,"filename":94,"code":95,"class":37},"npm","npm install --save-dev @kubb\u002Fplugin-ts",[18,97,98],{"class":40},[42,99,100,103,106,108],{"class":44,"style":45},[42,101,102],{"style":48},"npm ",[42,104,105],{"style":52},"install --save-dev ",[42,107,70],{"style":52},[42,109,73],{"style":52},[32,111,114],{"language":34,"filename":112,"code":113,"class":37},"yarn","yarn add -D @kubb\u002Fplugin-ts",[18,115,116],{"class":40},[42,117,118,121,123,125],{"class":44,"style":45},[42,119,120],{"style":48},"yarn ",[42,122,87],{"style":52},[42,124,70],{"style":52},[42,126,73],{"style":52},[11,128,129,132,133,138,139,142,143,146,147,149,150,156],{},[18,130,131],{},"kubb add"," installs the version the ",[134,135,137],"a",{"href":136},"\u002Fregistry","Kubb registry"," pins and adds ",[18,140,141],{},"pluginTs()"," to ",[18,144,145],{},"kubb.config.ts",". It needs a ",[18,148,145],{},", so run ",[134,151,153],{"href":152},"\u002Fdocs\u002F5.x\u002Freference\u002Fcommands\u002Finit",[18,154,155],{},"kubb init"," first in a new project.",[23,158,160],{"id":159},"setup","Setup",[11,162,163],{},"No other plugins or packages are needed.",[23,165,167],{"id":166},"options-worth-knowing","Options worth knowing",[169,170,171,187],"table",{},[172,173,174],"thead",{},[175,176,177,181,184],"tr",{},[178,179,180],"th",{},"Option",[178,182,183],{},"Default",[178,185,186],{},"What it does",[188,189,190,217,242,268,292,313],"tbody",{},[175,191,192,201,206],{},[193,194,195],"td",{},[134,196,198],{"href":197},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-ts\u002Foptions#enumtype",[18,199,200],{},"enum.type",[193,202,203],{},[18,204,205],{},"'asConst'",[193,207,208,209,212,213,216],{},"Writes enums as an ",[18,210,211],{},"as const"," object, an ",[18,214,215],{},"enum",", or a literal union.",[175,218,219,227,232],{},[193,220,221],{},[134,222,224],{"href":223},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-ts\u002Foptions#syntaxtype",[18,225,226],{},"syntaxType",[193,228,229],{},[18,230,231],{},"'type'",[193,233,234,235,238,239,21],{},"Writes object schemas as ",[18,236,237],{},"type"," or ",[18,240,241],{},"interface",[175,243,244,252,257],{},[193,245,246],{},[134,247,249],{"href":248},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-ts\u002Foptions#optionaltype",[18,250,251],{},"optionalType",[193,253,254],{},[18,255,256],{},"'questionToken'",[193,258,259,260,263,264,267],{},"Writes ",[18,261,262],{},"a?: T",", ",[18,265,266],{},"a: T | undefined",", or both.",[175,269,270,278,283],{},[193,271,272],{},[134,273,275],{"href":274},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-ts\u002Foptions#arraytype",[18,276,277],{},"arrayType",[193,279,280],{},[18,281,282],{},"'array'",[193,284,285,286,238,289,21],{},"Writes arrays as ",[18,287,288],{},"T[]",[18,290,291],{},"Array\u003CT>",[175,293,294,302,307],{},[193,295,296],{},[134,297,299],{"href":298},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-ts\u002Foptions#operations",[18,300,301],{},"operations",[193,303,304],{},[18,305,306],{},"'inline'",[193,308,309,312],{},[18,310,311],{},"'export'"," writes a types file per operation.",[175,314,315,323,326],{},[193,316,317],{},[134,318,320],{"href":319},"https:\u002F\u002Fkubb.dev\u002Fdocs\u002F5.x\u002Freference\u002Fplugin-options#group",[18,321,322],{},"group",[193,324,325],{},"None",[193,327,328,329,21],{},"Splits the output into folders by tag or path. Does not work with ",[18,330,331],{},"output.mode: 'file'",[333,334,336,337,340,341,344,345,351,352,21],"blockquote",{"as":335},"tip","The OpenAPI adapter types ",[18,338,339],{},"int64"," fields as ",[18,342,343],{},"bigint",", but JSON responses hold numbers. For most JSON APIs, set ",[134,346,348],{"href":347},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fadapter-oas\u002Foptions#integertype",[18,349,350],{},"integerType: 'number'"," on ",[18,353,354],{},"adapterOas",[23,356,358],{"id":357},"example","Example",[11,360,361,362,365,366,369,370,373,374,377],{},"This config writes the types to ",[18,363,364],{},"src\u002Fgen\u002Ftypes",". For a ",[18,367,368],{},"Pet"," schema with a ",[18,371,372],{},"status"," enum, the plugin writes ",[18,375,376],{},"Pet.ts",":",[28,379,380,508],{},[32,381,384],{"language":382,"filename":145,"code":383,"class":37},"typescript","import { defineConfig } from 'kubb\u002Fconfig'\nimport { pluginTs } from '@kubb\u002Fplugin-ts'\n\nexport default defineConfig({\n input: '.\u002FpetStore.yaml',\n output: { path: '.\u002Fsrc\u002Fgen' },\n plugins: [pluginTs()],\n})",[18,385,387,410,411,410,427,410,429,410,443,410,460,410,484,410,503],{"class":386},"language-typescript",[42,388,389,393,397,400,403,406],{"class":44,"style":45},[42,390,392],{"style":391},"color:#d73a49;--hls-dark:#f97583","import ",[42,394,396],{"style":395},"color:#005cc5;--hls-dark:#79b8ff","{ ",[42,398,399],{"style":52},"defineConfig ",[42,401,402],{"style":395},"} ",[42,404,405],{"style":391},"from ",[42,407,409],{"style":408},"color:#032f62;--hls-dark:#9ecbff","'kubb\u002Fconfig'","\n",[42,412,413,415,417,420,422,424],{"class":44,"style":45},[42,414,392],{"style":391},[42,416,396],{"style":395},[42,418,419],{"style":52},"pluginTs ",[42,421,402],{"style":395},[42,423,405],{"style":391},[42,425,426],{"style":408},"'@kubb\u002Fplugin-ts'",[42,428],{"class":44,"style":45},[42,430,431,434,437,440],{"class":44,"style":45},[42,432,433],{"style":391},"export ",[42,435,436],{"style":391},"default ",[42,438,439],{"style":48},"defineConfig",[42,441,442],{"style":395},"({",[42,444,445,448,451,454,457],{"class":44,"style":45},[42,446,447],{"style":395}," ",[42,449,450],{"style":395},"input",[42,452,453],{"style":391},": ",[42,455,456],{"style":408},"'.\u002FpetStore.yaml'",[42,458,459],{"style":391},",",[42,461,462,464,467,469,471,474,476,479,482],{"class":44,"style":45},[42,463,447],{"style":391},[42,465,466],{"style":395},"output",[42,468,453],{"style":391},[42,470,396],{"style":395},[42,472,473],{"style":395},"path",[42,475,453],{"style":391},[42,477,478],{"style":408},"'.\u002Fsrc\u002Fgen' ",[42,480,481],{"style":395},"}",[42,483,459],{"style":391},[42,485,486,488,490,492,495,498,501],{"class":44,"style":45},[42,487,447],{"style":391},[42,489,20],{"style":395},[42,491,453],{"style":391},[42,493,494],{"style":395},"[",[42,496,497],{"style":48},"pluginTs",[42,499,500],{"style":395},"()]",[42,502,459],{"style":391},[42,504,505],{"class":44,"style":45},[42,506,507],{"style":395},"})",[32,509,512],{"language":382,"filename":510,"code":511,"class":37},"src\u002Fgen\u002Ftypes\u002FPet.ts","\u002F\u002F excerpt, without JSDoc\nexport const petStatusEnum = {\n available: 'available',\n pending: 'pending',\n sold: 'sold',\n} as const\n\nexport type PetStatusEnumKey = (typeof petStatusEnum)[keyof typeof petStatusEnum]\n\nexport type Pet = {\n id?: bigint\n name: string\n photoUrls: string[]\n status?: PetStatusEnumKey\n}",[18,513,514,410,520,410,536,410,550,410,564,410,578,410,588,410,590,410,622,410,624,410,637,410,651,410,661,410,675,410,687],{"class":386},[42,515,516],{"class":44,"style":45},[42,517,519],{"style":518},"color:#6a737d;--hls-dark:#6a737d","\u002F\u002F excerpt, without JSDoc",[42,521,522,524,527,530,533],{"class":44,"style":45},[42,523,433],{"style":391},[42,525,526],{"style":391},"const ",[42,528,529],{"style":52},"petStatusEnum ",[42,531,532],{"style":391},"= ",[42,534,535],{"style":395},"{",[42,537,538,540,543,545,548],{"class":44,"style":45},[42,539,447],{"style":395},[42,541,542],{"style":395},"available",[42,544,453],{"style":391},[42,546,547],{"style":408},"'available'",[42,549,459],{"style":391},[42,551,552,554,557,559,562],{"class":44,"style":45},[42,553,447],{"style":391},[42,555,556],{"style":395},"pending",[42,558,453],{"style":391},[42,560,561],{"style":408},"'pending'",[42,563,459],{"style":391},[42,565,566,568,571,573,576],{"class":44,"style":45},[42,567,447],{"style":391},[42,569,570],{"style":395},"sold",[42,572,453],{"style":391},[42,574,575],{"style":408},"'sold'",[42,577,459],{"style":391},[42,579,580,582,585],{"class":44,"style":45},[42,581,402],{"style":395},[42,583,584],{"style":391},"as ",[42,586,587],{"style":391},"const",[42,589],{"class":44,"style":45},[42,591,592,594,597,600,602,605,608,611,614,617,619],{"class":44,"style":45},[42,593,433],{"style":391},[42,595,596],{"style":391},"type ",[42,598,599],{"style":48},"PetStatusEnumKey ",[42,601,532],{"style":391},[42,603,604],{"style":395},"(",[42,606,607],{"style":391},"typeof ",[42,609,610],{"style":52},"petStatusEnum",[42,612,613],{"style":395},")[",[42,615,616],{"style":391},"keyof typeof ",[42,618,610],{"style":52},[42,620,621],{"style":395},"]",[42,623],{"class":44,"style":45},[42,625,626,628,630,633,635],{"class":44,"style":45},[42,627,433],{"style":391},[42,629,596],{"style":391},[42,631,632],{"style":48},"Pet ",[42,634,532],{"style":391},[42,636,535],{"style":395},[42,638,639,641,644,647,649],{"class":44,"style":45},[42,640,447],{"style":395},[42,642,643],{"style":395},"id",[42,645,646],{"style":52},"?",[42,648,453],{"style":391},[42,650,343],{"style":52},[42,652,653,656,658],{"class":44,"style":45},[42,654,655],{"style":52}," name",[42,657,453],{"style":52},[42,659,660],{"style":48},"string",[42,662,663,665,668,670,672],{"class":44,"style":45},[42,664,447],{"style":48},[42,666,667],{"style":52},"photoUrls",[42,669,453],{"style":52},[42,671,660],{"style":48},[42,673,674],{"style":395},"[]",[42,676,677,679,681,684],{"class":44,"style":45},[42,678,447],{"style":395},[42,680,372],{"style":52},[42,682,683],{"style":52},"?: ",[42,685,686],{"style":48},"PetStatusEnumKey",[42,688,689],{"class":44,"style":45},[42,690,481],{"style":395},[11,692,693,694,21],{},"Next, ",[134,695,697],{"href":696},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-ts\u002Fguides\u002Fcustomization","customize the generated types",{"title":699,"searchDepth":700,"depth":700,"links":701},"",5,[702,704,705,706],{"id":25,"depth":703,"text":26},2,{"id":159,"depth":703,"text":160},{"id":166,"depth":703,"text":167},{"id":357,"depth":703,"text":358},"\u002Fextensions\u002Fkubb-labs\u002Fplugin-ts",1795727681964,"1b64b1eb-29b7-4f90-ad41-6f24721e1669"]