# Cutting | Toshiki's Note
Remove unnecessary code from your examples.
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

####

# Cutting ​

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

Every Twoslash code example needs to be a complete TypeScript program so it can compile. Quite often to make it compile, there is a bunch of code which isn't relevant to the user. This can be extracted out of the code examples via cut comments.

## `---cut---` ​

Cut works after TypeScript has generated the project and pulled out all the editor information (like identifiers, queries, highlights etc) and then amends all of their offsets and lines to re-fit the smaller output. What your user sees is everything below the `---cut---`.

outputmarkdown
ts

    tsconsole.log(level)

    tsconsole.log(level)

1
md

    ```ts twoslash
    const level: string = 'Danger'
    // ---cut---
    console.log(level)
    ```

    ```ts twoslash
    const level: string = 'Danger'
    // ---cut---
    console.log(level)
    ```

1
2
3
4
5

Cutting even works across multiple files. This is why `// @filename: [file]` is specifically the only Twoslash command which is not removed, because if it's not relevant it can be `---cut---` away.

outputmarkdown
ts

    tsimport { helloWorld } from './a'console.log(helloWorld)

    tsimport { helloWorld } from './a'console.log(helloWorld)

1
md

    ```ts twoslash
    // @filename: a.ts
    export const helloWorld: string = 'Hi'

    // @filename: b.ts
    // ---cut---
    import { helloWorld } from './a'
    console.log(helloWorld)
    ```

    ```ts twoslash
    // @filename: a.ts
    export const helloWorld: string = 'Hi'

    // @filename: b.ts
    // ---cut---
    import { helloWorld } from './a'
    console.log(helloWorld)
    ```

1
2
3
4
5
6
7
8
9

## `---cut-after---` ​

The sibling to `---cut---`, which trims anything after the sigil:

outputmarkdown
tsx

    tsx    <Container>        <ImportantComponent />    </Container>

    tsx    <Container>        <ImportantComponent />    </Container>

1
md

    ```tsx twoslash
    const Page = () => (
        // ---cut---
        <Container>
            <ImportantComponent />
        </Container>
        // ---cut-after---
    )
    ```

    ```tsx twoslash
    const Page = () => (
        // ---cut---
        <Container>
            <ImportantComponent />
        </Container>
        // ---cut-after---
    )
    ```

1
2
3
4
5
6
7
8
9