Twoslash Support
Twoslash provides an inline type hove inside the code block.
Basic usage
You can enable twoslash to your code blocks by adding a twoslash
metadata:
Markdown
```ts twoslash
// @errors: 2540
interface Todo {
title: string
}
const todo: Readonly<Todo> = {
title: 'Delete inactive users'.toUpperCase()
// ^?
}
todo.title = 'Hello'
Number.parseInt('123', 10)
// ^|
```
Renders:
interface Todo {
Todo.title: string
title: string
}
const const todo: Readonly<Todo>
todo: type Readonly<T> = { readonly [P in keyof T]: T[P]; }
Make all properties in T readonlyReadonly<Todo> = {
title: string
title: 'Delete inactive users'.String.toUpperCase(): string
Converts all the alphabetic characters in a string to uppercase.toUpperCase()
}
const todo: Readonly<Todo>
todo.title = 'Hello'
var Number: NumberConstructor
An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers.Number.p- parseFloat
- parseInt
- prototype
NumberConstructor.parseInt(string: string, radix?: number): number
Converts A string to an integer.arseInt('123', 10)
Custom log message
You can add log message to your code by adding:
@log: <message>
Custom log message@error: <message>
Custom error message@warn: <message>
Custom warn message@annotate: <message>
Custom annotate message
const const a: 1
a = 1Custom log messageconst const b: 1
b = 1Custom error messageconst const c: 1
c = 1Custom warning message Custom annotation message
Last updated on