From 15fae197482a9ac84e0227200ef8f4d0d4e4bd33 Mon Sep 17 00:00:00 2001 From: Yusuke Tanaka Date: Thu, 14 Nov 2024 14:04:32 +0900 Subject: 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 --- tests/specs/test/doc_ts_expect_error/mod.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tests/specs/test/doc_ts_expect_error/mod.ts (limited to 'tests/specs/test/doc_ts_expect_error/mod.ts') 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; +} -- cgit v1.2.3