From fc5182c4842dd8f54b4abe34cff00713d30a86d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 18 Sep 2024 00:05:41 +0200 Subject: [PATCH 1/5] feat(check): turn on noImplicitOverride --- Cargo.lock | 3 +-- Cargo.toml | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8b2d4fb80cd18c..3155985e2c3d35 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1376,8 +1376,7 @@ dependencies = [ [[package]] name = "deno_config" version = "0.34.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "764368ba1424ea74f9a28d8e2e7633f57d008e73f76b12bc272f6d5903ca1e08" +source = "git+https://github.com/denoland/deno_config?branch=feat_noImplicitOverride#af92a6fe4e1c80cef3d81b4a6d64e30ba7cd5cea" dependencies = [ "anyhow", "deno_package_json", diff --git a/Cargo.toml b/Cargo.toml index 2794d0a7851cc9..d0b15ccfe68907 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -396,3 +396,6 @@ opt-level = 3 opt-level = 3 [profile.release.package.zstd-sys] opt-level = 3 + +[patch.crates-io] +deno_config = { git = "https://github.com/denoland/deno_config", branch = "feat_noImplicitOverride" } From 8484492bd101d3e89ff96ba8176d94f10c0d1794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 18 Sep 2024 00:17:15 +0200 Subject: [PATCH 2/5] fix tests --- tests/unit/url_search_params_test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/url_search_params_test.ts b/tests/unit/url_search_params_test.ts index c547ef93859e6d..d682c291a9ddd8 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* []; } } From 1b31b6d404e9e99cd0884639d009416348ee0615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 18 Sep 2024 01:11:09 +0200 Subject: [PATCH 3/5] use version --- Cargo.lock | 5 +++-- Cargo.toml | 3 --- cli/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3155985e2c3d35..bb8634f5c9bd23 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1375,8 +1375,9 @@ dependencies = [ [[package]] name = "deno_config" -version = "0.34.2" -source = "git+https://github.com/denoland/deno_config?branch=feat_noImplicitOverride#af92a6fe4e1c80cef3d81b4a6d64e30ba7cd5cea" +version = "0.34.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "187d7dd888a49bfda396632371139e940c5cf47b15bfcaeeb2ba50f82f6940ec" dependencies = [ "anyhow", "deno_package_json", diff --git a/Cargo.toml b/Cargo.toml index d0b15ccfe68907..2794d0a7851cc9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -396,6 +396,3 @@ opt-level = 3 opt-level = 3 [profile.release.package.zstd-sys] opt-level = 3 - -[patch.crates-io] -deno_config = { git = "https://github.com/denoland/deno_config", branch = "feat_noImplicitOverride" } diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 7dcd6456d0d1c2..0851df87f56a18 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" } From cf7d0b931ee977cfbb50e284bb070e6ae430fb1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 18 Sep 2024 01:48:58 +0200 Subject: [PATCH 4/5] turn it in 99_main_compiler.js by default --- cli/schemas/config-file.v1.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/schemas/config-file.v1.json b/cli/schemas/config-file.v1.json index 8d0af55bfd24a8..96b7c4bed3cb25 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": { From a5f1d6f47977024f8acb48d9df350dc00798d6fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 18 Sep 2024 14:24:30 +0200 Subject: [PATCH 5/5] add a test, make it work in the lsp --- cli/lsp/config.rs | 1 + 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 +++++++ 5 files changed, 19 insertions(+) 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/cli/lsp/config.rs b/cli/lsp/config.rs index f69cae43596b8a..94fdff1674fac7 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/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js index c5769168fa75af..719f2b9824b052 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 00000000000000..a991c6eed4f620 --- /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 00000000000000..6fd65734197ebd --- /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 00000000000000..b51dfb9d9e70b5 --- /dev/null +++ b/tests/specs/check/no_implicit_override/main.ts @@ -0,0 +1,7 @@ +class Greet { + greet() {} +} + +class Welcome extends Greet { + greet() {} +}