diff options
author | Yusuke Tanaka <yusuktan@maguro.dev> | 2024-11-14 14:04:32 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-13 21:04:32 -0800 |
commit | 15fae197482a9ac84e0227200ef8f4d0d4e4bd33 (patch) | |
tree | be0cce33690ed742d950091bdb46c22ce04b0a1f /tests/specs/test/doc_ts_expect_error/mod.ts | |
parent | 6b5cb41545086a7a550c698620f5b7bb19b5524f (diff) |
fix(cli): preserve comments in doc tests (#26828)
This commit makes comments in code snippets in JSDoc or markdown
preserved when they are executed as tests. In particular, this is needed
to get TypeScript special comments such as `@ts-ignore` or
`@ts-expect-error` to work correctly.
Fixes #26728
Diffstat (limited to 'tests/specs/test/doc_ts_expect_error/mod.ts')
-rw-r--r-- | tests/specs/test/doc_ts_expect_error/mod.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/specs/test/doc_ts_expect_error/mod.ts b/tests/specs/test/doc_ts_expect_error/mod.ts new file mode 100644 index 000000000..eeace602a --- /dev/null +++ b/tests/specs/test/doc_ts_expect_error/mod.ts @@ -0,0 +1,13 @@ +/** + * ```ts + * import { add } from "./mod.ts"; + * + * add(1, 2); + * + * // @ts-expect-error: can only add numbers + * add('1', '2'); + * ``` + */ +export function add(first: number, second: number) { + return first + second; +} |