summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2024-01-25 15:39:21 +0100
committerGitHub <noreply@github.com>2024-01-25 14:39:21 +0000
commit2fd26de396b88c029f1e3a02179efaf4b2de9396 (patch)
tree76f2323f51720220325bd9067879a74c5c3cea03
parent414320d46b702003ded11fcf66607dd4dd2cbe5a (diff)
fix(lsp): disable experimentalDecorators by default (#22101)
Follow up to https://github.com/denoland/deno/pull/22040. By mistake I forgot to disable "experimental decorators" in the LSP.
-rw-r--r--cli/lsp/language_server.rs2
-rw-r--r--cli/tests/integration/lsp_tests.rs103
2 files changed, 104 insertions, 1 deletions
diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs
index 87b33b5cb..f55610b1c 100644
--- a/cli/lsp/language_server.rs
+++ b/cli/lsp/language_server.rs
@@ -1128,7 +1128,7 @@ impl Inner {
let mut tsconfig = TsConfig::new(json!({
"allowJs": true,
"esModuleInterop": true,
- "experimentalDecorators": true,
+ "experimentalDecorators": false,
"isolatedModules": true,
"jsx": "react",
"lib": ["deno.ns", "deno.window", "deno.unstable"],
diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs
index 3ea6d2ab5..79ca35fc7 100644
--- a/cli/tests/integration/lsp_tests.rs
+++ b/cli/tests/integration/lsp_tests.rs
@@ -11045,3 +11045,106 @@ fn sloppy_imports_not_enabled() {
);
client.shutdown();
}
+
+#[test]
+fn decorators_tc39() {
+ let context = TestContextBuilder::new().use_temp_cwd().build();
+ let temp_dir = context.temp_dir();
+ temp_dir.write("deno.json", r#"{}"#);
+
+ let mut client = context.new_lsp_command().build();
+ client.initialize_default();
+
+ let uri = Url::from_file_path(temp_dir.path().join("main.ts")).unwrap();
+
+ let diagnostics = client
+ .did_open(json!({
+ "textDocument": {
+ "uri": uri,
+ "languageId": "typescript",
+ "version": 1,
+ "text": r#"// deno-lint-ignore no-explicit-any
+function logged(value: any, { kind, name }: { kind: string; name: string }) {
+ if (kind === "method") {
+ return function (...args: unknown[]) {
+ console.log(`starting ${name} with arguments ${args.join(", ")}`);
+ // @ts-ignore this has implicit any type
+ const ret = value.call(this, ...args);
+ console.log(`ending ${name}`);
+ return ret;
+ };
+ }
+}
+
+class C {
+ @logged
+ m(arg: number) {
+ console.log("C.m", arg);
+ }
+}
+
+new C().m(1);
+"#
+ }
+ }))
+ .all();
+
+ assert_eq!(diagnostics.len(), 0);
+
+ client.shutdown();
+}
+
+#[test]
+fn decorators_ts() {
+ let context = TestContextBuilder::new().use_temp_cwd().build();
+ let temp_dir = context.temp_dir();
+ temp_dir.write(
+ "deno.json",
+ r#"{ "compilerOptions": { "experimentalDecorators": true } }"#,
+ );
+
+ let mut client = context.new_lsp_command().build();
+ client.initialize_default();
+
+ let uri = Url::from_file_path(temp_dir.path().join("main.ts")).unwrap();
+
+ let diagnostics = client
+ .did_open(json!({
+ "textDocument": {
+ "uri": uri,
+ "languageId": "typescript",
+ "version": 1,
+ "text": r#"// deno-lint-ignore-file
+function a() {
+ console.log("@A evaluated");
+ return function (
+ _target: any,
+ _propertyKey: string,
+ descriptor: PropertyDescriptor,
+ ) {
+ console.log("@A called");
+ const fn = descriptor.value;
+ descriptor.value = function () {
+ console.log("fn() called from @A");
+ fn();
+ };
+ };
+}
+
+class C {
+ @a()
+ static test() {
+ console.log("C.test() called");
+ }
+}
+
+C.test();
+"#
+ }
+ }))
+ .all();
+
+ assert_eq!(diagnostics.len(), 0);
+
+ client.shutdown();
+}