# Emit | Toshiki's Note
You can replace the contents of your code examples with the results of running TypeScript over the project.
Author: Anda Toshiki
Keywords: Toshiki, Anda Toshiki, andatoshiki, GitHub, GitHub action, Vitepress, Vite, Notebook, Knowledge base, Programming, Programming Notes, Academic, Personal, Notebook, Productivity, Journal, Note-taking, Markdown, Notepad, Organization, Tutorial

Skip to content

####

# Emit ​

Author:Anda Toshiki
Updated:a minute ago
Words:264
Reading:1 min

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.

outputmarkdown
ts

    ts"use strict";const level = 'Danger';

    ts"use strict";const level = 'Danger';

1
md

    ```ts twoslash
    // @showEmit
    const level: string = 'Danger'
    ```

    ```ts twoslash
    // @showEmit
    const level: string = 'Danger'
    ```

1
2
3
4

## `@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:

markdownoutput
md

    ```ts twoslash
    // @declaration
    // @showEmit
    // @showEmittedFile: index.d.ts
    export const hello = 'world'
    ```

    ```ts twoslash
    // @declaration
    // @showEmit
    // @showEmittedFile: index.d.ts
    export const hello = 'world'
    ```

1
2
3
4
5
6
ts

    tsexport declare const hello = "world";

    tsexport declare const hello = "world";

1

Shows emitted `.map` files:

markdownoutput
md

    ```ts twoslash
    // @sourceMap
    // @showEmit
    // @showEmittedFile: index.js.map
    export const hello = 'world'
    ```

    ```ts twoslash
    // @sourceMap
    // @showEmit
    // @showEmittedFile: index.js.map
    export const hello = 'world'
    ```

1
2
3
4
5
6
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"}

1
markdownoutput
md

    ```ts twoslash
    // @declaration
    // @declarationMap
    // @showEmit
    // @showEmittedFile: index.d.ts.map
    export const hello = 'world'
    ```

    ```ts twoslash
    // @declaration
    // @declarationMap
    // @showEmit
    // @showEmittedFile: index.d.ts.map
    export const hello = 'world'
    ```

1
2
3
4
5
6
7
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"}

1