Skip to Content
🎉 Nextra 4.0 已发布。dimaMachina 正在 寻找新工作或咨询机会 
文档高级Twoslash 支持

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'
Cannot assign to 'title' because it is a read-only property.
.p
  • parseFloat
  • parseInt
  • prototype
('123', 10)

自定义日志消息

您可以通过添加以下内容来为代码添加日志消息:

  • @log: <message> 自定义日志消息
  • @error: <message> 自定义错误消息
  • @warn: <message> 自定义警告消息
  • @annotate: <message> 自定义注解消息
const = 1
Custom log message
const = 1
Custom error message
const = 1
Custom warning message
Custom annotation message
Last updated on