import{_ as n}from"./chunks/PageInfo.vue_vue_type_script_setup_true_lang.250b3e56.js";import{_ as l,o,c as e,H as p,k as s,a as t,Q as c}from"./chunks/framework.b7580407.js";import"./chunks/commonjsHelpers.725317a4.js";const C=JSON.parse('{"title":"Emit","description":"You can replace the contents of your code examples with the results of running TypeScript over the project.","frontmatter":{"description":"You can replace the contents of your code examples with the results of running TypeScript over the project.","title":"Emit"},"headers":[],"relativePath":"application/vitepress-plugin-shiki-twoslash/api/emit.md","filePath":"application/vitepress-plugin-shiki-twoslash/api/emit.md","lastUpdated":1710267506000}'),r={name:"application/vitepress-plugin-shiki-twoslash/api/emit.md"},i=s("h1",{id:"emit",tabindex:"-1"},[t("Emit "),s("a",{class:"header-anchor",href:"#emit","aria-label":'Permalink to "Emit"'},"​")],-1),d=c('

Running a Twoslash code example is a full TypeScript compiler run that will create files inside the virtual file system. You can replace the contents of your code examples with the results of running TypeScript over the project.

@showEmit

// @showEmit is the main command to tell Shiki Twoslash that you want to replace the output of your code example with the equivalent .js file.

ts
ts
"use strict";
const level = 'Danger';
 
ts
"use strict";
const level = 'Danger';
 
md
```ts twoslash\n// @showEmit\nconst level: string = 'Danger'\n```
```ts twoslash\n// @showEmit\nconst level: string = 'Danger'\n```

@showEmittedFile: [file]

While the .js file is probably the most useful file out of the box, TypeScript does emit other files if you have the right flags enabled (.d.ts and .map) but also when you have a multi-file code sample — you might need to tell Twoslash which file to show. For all these cases you can also add @showEmittedFile: [file] to tell Twoslash which file you want to show.

Shows emitted .d.ts for a TypeScript code example:

md
```ts twoslash\n// @declaration\n// @showEmit\n// @showEmittedFile: index.d.ts\nexport const hello = 'world'\n```
```ts twoslash\n// @declaration\n// @showEmit\n// @showEmittedFile: index.d.ts\nexport const hello = 'world'\n```
ts
ts
export declare const hello = "world";
 
ts
export declare const hello = "world";
 

Shows emitted .map files:

md
```ts twoslash\n// @sourceMap\n// @showEmit\n// @showEmittedFile: index.js.map\nexport const hello = 'world'\n```
```ts twoslash\n// @sourceMap\n// @showEmit\n// @showEmittedFile: index.js.map\nexport const hello = 'world'\n```
ts
ts
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAA"}
ts
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAA"}
md
```ts twoslash\n// @declaration\n// @declarationMap\n// @showEmit\n// @showEmittedFile: index.d.ts.map\nexport const hello = 'world'\n```
```ts twoslash\n// @declaration\n// @declarationMap\n// @showEmit\n// @showEmittedFile: index.d.ts.map\nexport const hello = 'world'\n```
ts
ts
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,UAAU,CAAA"}
ts
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,UAAU,CAAA"}
',11);function y(u,A,h,m,v,b){const a=n;return o(),e("div",null,[i,p(a,{readTime:"1",words:"264"}),d])}const q=l(r,[["render",y]]);export{C as __pageData,q as default};