Twoslash 支援
Twoslash 提供程式碼區塊內的行內類型提示。
基本用法
您可以透過新增 twoslash
中繼資料來啟用程式碼區塊的 twoslash 功能
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)
// ^|
// Just comments, so Popup will be
// not behind the viewport of `<code>`
// element due his `position: absolute` style
//
```
渲染結果
interface Todo {
: string
}
const : <Todo> = {
title: string
title: 'Delete inactive users'.()
}
.title = 'Hello'
.p- parseFloat
- parseInt
- prototype
('123', 10)
自訂日誌訊息
您可以透過新增以下內容來自訂程式碼的日誌訊息:
@log: <訊息>
自訂日誌訊息@error: <訊息>
自訂錯誤訊息@warn: <訊息>
自訂警告訊息@annotate: <訊息>
自訂註釋訊息
const = 1Custom log messageconst = 1Custom error messageconst = 1Custom warning message Custom annotation message