Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions code.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,35 @@ class HelloWorld {
```
````

### Twoslash

In JavaScript and TypeScript code blocks, use `twoslash` to enable interactive type information. Users can hover over variables, functions, and parameters to see types and errors like in an IDE.


```ts title="Twoslash Example" twoslash
type Pet = "cat" | "dog" | "hamster";

function adoptPet(name: string, type: Pet) {
return `${name} the ${type} is now adopted!`;
}

// Hover to see the inferred types
const message = adoptPet("Mintie", "cat");
```

````mdx
```ts title="Twoslash Example" twoslash
type Pet = "cat" | "dog" | "hamster";

function adoptPet(name: string, type: Pet) {
return `${name} the ${type} is now adopted! 🎉`;
}

// Hover to see the inferred types
const message = adoptPet("Mintie", "cat");
```
````

### Title

Add a title to label your code example. Use `title="Your title"` or a string on a single line.
Expand Down
Loading