From 1b27b5839624ebf9fef65cea28a17281f3b79a74 Mon Sep 17 00:00:00 2001 From: Leo Kettmeir Date: Thu, 2 May 2024 11:13:51 -0700 Subject: fix(test): proper type checking for files with doc tests (#23654) Closes https://github.com/denoland/deno/issues/23430 --------- Co-authored-by: Yoshiya Hinosawa --- tests/specs/test/type_check_with_doc/__test__.jsonc | 5 +++++ tests/specs/test/type_check_with_doc/main.out | 13 +++++++++++++ tests/specs/test/type_check_with_doc/main.ts | 8 ++++++++ 3 files changed, 26 insertions(+) create mode 100644 tests/specs/test/type_check_with_doc/__test__.jsonc create mode 100644 tests/specs/test/type_check_with_doc/main.out create mode 100644 tests/specs/test/type_check_with_doc/main.ts (limited to 'tests') diff --git a/tests/specs/test/type_check_with_doc/__test__.jsonc b/tests/specs/test/type_check_with_doc/__test__.jsonc new file mode 100644 index 000000000..c4a26529a --- /dev/null +++ b/tests/specs/test/type_check_with_doc/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "test --doc main.ts", + "output": "main.out", + "exitCode": 1 +} diff --git a/tests/specs/test/type_check_with_doc/main.out b/tests/specs/test/type_check_with_doc/main.out new file mode 100644 index 000000000..931a6a5f3 --- /dev/null +++ b/tests/specs/test/type_check_with_doc/main.out @@ -0,0 +1,13 @@ +Check [WILDCARD]/main.ts +Check [WILDCARD]/main.ts$2-5.ts +error: TS2322 [ERROR]: Type 'number' is not assignable to type 'string'. +const a: string = 1; + ^ + at file://[WILDCARD]/main.ts:8:7 + +TS2322 [ERROR]: Type 'string' is not assignable to type 'number'. +const b: number = "1"; + ^ + at file://[WILDCARD]/main.ts$2-5.ts:1:7 + +Found 2 errors. diff --git a/tests/specs/test/type_check_with_doc/main.ts b/tests/specs/test/type_check_with_doc/main.ts new file mode 100644 index 000000000..04ccd00bf --- /dev/null +++ b/tests/specs/test/type_check_with_doc/main.ts @@ -0,0 +1,8 @@ +/** + * ```ts + * const b: number = "1"; + * ``` + */ +function foo() {} + +const a: string = 1; -- cgit v1.2.3