From 48ea4e3c92b53936e89101a56a013300a47337d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 18 Sep 2024 14:49:30 +0100 Subject: [PATCH] feat(check): turn on noImplicitOverride (#25695) Closes https://github.com/denoland/deno/issues/11836 Ref https://github.com/denoland/deno/issues/25162 --- Cargo.lock | 4 ++-- cli/Cargo.toml | 2 +- cli/lsp/config.rs | 1 + cli/schemas/config-file.v1.json | 2 +- cli/tsc/99_main_compiler.js | 1 + tests/specs/check/no_implicit_override/__test__.jsonc | 5 +++++ tests/specs/check/no_implicit_override/main.out | 5 +++++ tests/specs/check/no_implicit_override/main.ts | 7 +++++++ tests/unit/url_search_params_test.ts | 4 ++-- 9 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 tests/specs/check/no_implicit_override/__test__.jsonc create mode 100644 tests/specs/check/no_implicit_override/main.out create mode 100644 tests/specs/check/no_implicit_override/main.ts diff --git a/Cargo.lock b/Cargo.lock index 9239facf64..48b174c0f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1375,9 +1375,9 @@ dependencies = [ [[package]] name = "deno_config" -version = "0.34.2" +version = "0.34.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "764368ba1424ea74f9a28d8e2e7633f57d008e73f76b12bc272f6d5903ca1e08" +checksum = "187d7dd888a49bfda396632371139e940c5cf47b15bfcaeeb2ba50f82f6940ec" dependencies = [ "anyhow", "deno_package_json", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 40e3844c20..057b601ff6 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -65,7 +65,7 @@ winres.workspace = true [dependencies] deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "proposal", "react", "sourcemap", "transforms", "typescript", "view", "visit"] } deno_cache_dir = { workspace = true } -deno_config = { version = "=0.34.2", features = ["workspace", "sync"] } +deno_config = { version = "=0.34.3", features = ["workspace", "sync"] } deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] } deno_doc = { version = "0.148.0", features = ["html", "syntect"] } deno_graph = { version = "=0.82.1" } diff --git a/cli/lsp/config.rs b/cli/lsp/config.rs index f69cae4359..94fdff1674 100644 --- a/cli/lsp/config.rs +++ b/cli/lsp/config.rs @@ -1129,6 +1129,7 @@ impl Default for LspTsConfig { "module": "esnext", "moduleDetection": "force", "noEmit": true, + "noImplicitOverride": true, "resolveJsonModule": true, "strict": true, "target": "esnext", diff --git a/cli/schemas/config-file.v1.json b/cli/schemas/config-file.v1.json index 8d0af55bfd..96b7c4bed3 100644 --- a/cli/schemas/config-file.v1.json +++ b/cli/schemas/config-file.v1.json @@ -127,7 +127,7 @@ "noImplicitOverride": { "description": "Ensure overriding members in derived classes are marked with an override modifier.", "type": "boolean", - "default": false, + "default": true, "markdownDescription": "Ensure overriding members in derived classes are marked with an override modifier.\n\nSee more: https://www.typescriptlang.org/tsconfig#noImplicitOverride" }, "noImplicitReturns": { diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js index c5769168fa..719f2b9824 100644 --- a/cli/tsc/99_main_compiler.js +++ b/cli/tsc/99_main_compiler.js @@ -1154,6 +1154,7 @@ delete Object.prototype.__proto__; "moduleResolution": "NodeNext", "moduleDetection": "force", "noEmit": true, + "noImplicitOverride": true, "resolveJsonModule": true, "strict": true, "target": "esnext", diff --git a/tests/specs/check/no_implicit_override/__test__.jsonc b/tests/specs/check/no_implicit_override/__test__.jsonc new file mode 100644 index 0000000000..a991c6eed4 --- /dev/null +++ b/tests/specs/check/no_implicit_override/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "check main.ts", + "output": "main.out", + "exitCode": 1 +} diff --git a/tests/specs/check/no_implicit_override/main.out b/tests/specs/check/no_implicit_override/main.out new file mode 100644 index 0000000000..6fd6573419 --- /dev/null +++ b/tests/specs/check/no_implicit_override/main.out @@ -0,0 +1,5 @@ +Check file:///[WILDCARD]/main.ts +error: TS4114 [ERROR]: This member must have an 'override' modifier because it overrides a member in the base class 'Greet'. + greet() {} + ~~~~~ + at file:///[WILDCARD]/no_implicit_override/main.ts:6:3 diff --git a/tests/specs/check/no_implicit_override/main.ts b/tests/specs/check/no_implicit_override/main.ts new file mode 100644 index 0000000000..b51dfb9d9e --- /dev/null +++ b/tests/specs/check/no_implicit_override/main.ts @@ -0,0 +1,7 @@ +class Greet { + greet() {} +} + +class Welcome extends Greet { + greet() {} +} diff --git a/tests/unit/url_search_params_test.ts b/tests/unit/url_search_params_test.ts index c547ef9385..d682c291a9 100644 --- a/tests/unit/url_search_params_test.ts +++ b/tests/unit/url_search_params_test.ts @@ -330,7 +330,7 @@ Deno.test( function urlSearchParamsOverridingAppendNotChangeConstructorAndSet() { let overriddenAppendCalled = 0; class CustomSearchParams extends URLSearchParams { - append(name: string, value: string) { + override append(name: string, value: string) { ++overriddenAppendCalled; super.append(name, value); } @@ -345,7 +345,7 @@ Deno.test( Deno.test(function urlSearchParamsOverridingEntriesNotChangeForEach() { class CustomSearchParams extends URLSearchParams { - *entries(): IterableIterator<[string, string]> { + override *entries(): IterableIterator<[string, string]> { yield* []; } }