diff --git a/cli/lsp/analysis.rs b/cli/lsp/analysis.rs index 853708221f..c128372dcd 100644 --- a/cli/lsp/analysis.rs +++ b/cli/lsp/analysis.rs @@ -1387,7 +1387,7 @@ impl CodeActionCollection { character: import_start.column_index as u32, }; let new_text = format!( - "{}// @deno-types=\"{}\"\n", + "{}// @ts-types=\"{}\"\n", if position.character == 0 { "" } else { "\n" }, &types_specifier_text ); @@ -1400,7 +1400,7 @@ impl CodeActionCollection { }; Some(lsp::CodeAction { title: format!( - "Add @deno-types directive for \"{}\"", + "Add @ts-types directive for \"{}\"", &types_specifier_text ), kind: Some(lsp::CodeActionKind::QUICKFIX), diff --git a/cli/lsp/diagnostics.rs b/cli/lsp/diagnostics.rs index ac4d8c01e4..01fc3bf69e 100644 --- a/cli/lsp/diagnostics.rs +++ b/cli/lsp/diagnostics.rs @@ -1355,7 +1355,7 @@ fn diagnose_resolution( } // don't bother warning about sloppy import redirects from .js to .d.ts // because explaining how to fix this via a diagnostic involves using - // @deno-types and that's a bit complicated to explain + // @ts-types and that's a bit complicated to explain let is_sloppy_import_dts_redirect = doc_specifier.scheme() == "file" && doc.media_type().is_declaration() && !MediaType::from_specifier(specifier).is_declaration(); @@ -1523,7 +1523,7 @@ fn diagnose_dependency( .iter() .map(|i| documents::to_lsp_range(&i.specifier_range)) .collect(); - // TODO(nayeemrmn): This is a crude way of detecting `@deno-types` which has + // TODO(nayeemrmn): This is a crude way of detecting `@ts-types` which has // a different specifier and therefore needs a separate call to // `diagnose_resolution()`. It would be much cleaner if that were modelled as // a separate dependency: https://github.com/denoland/deno_graph/issues/247. @@ -1540,7 +1540,7 @@ fn diagnose_dependency( snapshot, dependency_key, if dependency.maybe_code.is_none() - // If not @deno-types, diagnose the types if the code errored because + // If not @ts-types, diagnose the types if the code errored because // it's likely resolving into the node_modules folder, which might be // erroring correctly due to resolution only being for bundlers. Let this // fail at runtime if necessary, but don't bother erroring in the editor @@ -1951,7 +1951,7 @@ let c: number = "a"; &[( "a.ts", r#" - // @deno-types="bad.d.ts" + // @ts-types="bad.d.ts" import "bad.js"; import "bad.js"; "#, @@ -2005,11 +2005,11 @@ let c: number = "a"; "range": { "start": { "line": 1, - "character": 23 + "character": 21 }, "end": { "line": 1, - "character": 33 + "character": 31 } }, "severity": 1, diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index d3d821ebb3..931e008a72 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -3419,7 +3419,7 @@ fn parse_code_actions( &specifier_rewrite.new_deno_types_specifier { text_edit.new_text = format!( - "// @deno-types=\"{}\"\n{}", + "// @ts-types=\"{}\"\n{}", deno_types_specifier, &text_edit.new_text ); } @@ -3594,10 +3594,8 @@ impl CompletionEntryDetails { if let Some(deno_types_specifier) = &specifier_rewrite.new_deno_types_specifier { - *new_text = format!( - "// @deno-types=\"{}\"\n{}", - deno_types_specifier, new_text - ); + *new_text = + format!("// @ts-types=\"{}\"\n{}", deno_types_specifier, new_text); } } } diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs index decc635ffa..6142c55888 100644 --- a/tests/integration/lsp_tests.rs +++ b/tests/integration/lsp_tests.rs @@ -2701,7 +2701,7 @@ fn lsp_hover_dependency() { "uri": "file:///a/file.ts", "languageId": "typescript", "version": 1, - "text": "import * as a from \"http://127.0.0.1:4545/xTypeScriptTypes.js\";\n// @deno-types=\"http://127.0.0.1:4545/type_definitions/foo.d.ts\"\nimport * as b from \"http://127.0.0.1:4545/type_definitions/foo.js\";\nimport * as c from \"http://127.0.0.1:4545/subdir/type_reference.js\";\nimport * as d from \"http://127.0.0.1:4545/subdir/mod1.ts\";\nimport * as e from \"data:application/typescript;base64,ZXhwb3J0IGNvbnN0IGEgPSAiYSI7CgpleHBvcnQgZW51bSBBIHsKICBBLAogIEIsCiAgQywKfQo=\";\nimport * as f from \"./file_01.ts\";\nimport * as g from \"http://localhost:4545/x/a/mod.ts\";\nimport * as h from \"./mod🦕.ts\";\n\nconsole.log(a, b, c, d, e, f, g, h);\n" + "text": "import * as a from \"http://127.0.0.1:4545/xTypeScriptTypes.js\";\n// @ts-types=\"http://127.0.0.1:4545/type_definitions/foo.d.ts\"\nimport * as b from \"http://127.0.0.1:4545/type_definitions/foo.js\";\nimport * as c from \"http://127.0.0.1:4545/subdir/type_reference.js\";\nimport * as d from \"http://127.0.0.1:4545/subdir/mod1.ts\";\nimport * as e from \"data:application/typescript;base64,ZXhwb3J0IGNvbnN0IGEgPSAiYSI7CgpleHBvcnQgZW51bSBBIHsKICBBLAogIEIsCiAgQywKfQo=\";\nimport * as f from \"./file_01.ts\";\nimport * as g from \"http://localhost:4545/x/a/mod.ts\";\nimport * as h from \"./mod🦕.ts\";\n\nconsole.log(a, b, c, d, e, f, g, h);\n" } }), ); @@ -6269,7 +6269,7 @@ fn lsp_code_actions_deno_types_for_npm() { res, json!([ { - "title": "Add @deno-types directive for \"@types/react\"", + "title": "Add @ts-types directive for \"@types/react\"", "kind": "quickfix", "edit": { "changes": { @@ -6279,7 +6279,7 @@ fn lsp_code_actions_deno_types_for_npm() { "start": { "line": 0, "character": 0 }, "end": { "line": 0, "character": 0 }, }, - "newText": "// @deno-types=\"@types/react\"\n", + "newText": "// @ts-types=\"@types/react\"\n", }, ], }, @@ -6322,7 +6322,7 @@ fn lsp_code_actions_deno_types_for_npm() { res, json!([ { - "title": "Add @deno-types directive for \"npm:@types/react@^18.3.10\"", + "title": "Add @ts-types directive for \"npm:@types/react@^18.3.10\"", "kind": "quickfix", "edit": { "changes": { @@ -6332,7 +6332,7 @@ fn lsp_code_actions_deno_types_for_npm() { "start": { "line": 0, "character": 0 }, "end": { "line": 0, "character": 0 }, }, - "newText": "// @deno-types=\"npm:@types/react@^18.3.10\"\n", + "newText": "// @ts-types=\"npm:@types/react@^18.3.10\"\n", }, ], }, @@ -8310,7 +8310,7 @@ fn lsp_npm_auto_import_with_deno_types() { temp_dir.write( "other.ts", r#" - // @deno-types="@types/lz-string" + // @ts-types="@types/lz-string" import "lz-string"; "#, ); @@ -8358,7 +8358,7 @@ fn lsp_npm_auto_import_with_deno_types() { "start": { "line": 0, "character": 0 }, "end": { "line": 0, "character": 0 }, }, - "newText": "// @deno-types=\"@types/lz-string\"\nimport { compressToBase64 } from \"lz-string\";\n", + "newText": "// @ts-types=\"@types/lz-string\"\nimport { compressToBase64 } from \"lz-string\";\n", }, ], }), @@ -8391,7 +8391,7 @@ fn lsp_npm_auto_import_with_deno_types() { "start": { "line": 0, "character": 0 }, "end": { "line": 0, "character": 0 }, }, - "newText": "// @deno-types=\"@types/react\"\nimport { createRef } from \"react\";\n", + "newText": "// @ts-types=\"@types/react\"\nimport { createRef } from \"react\";\n", }, ], }), @@ -10226,7 +10226,7 @@ fn lsp_cache_location() { "uri": "file:///a/file.ts", "languageId": "typescript", "version": 1, - "text": "import * as a from \"http://127.0.0.1:4545/xTypeScriptTypes.js\";\n// @deno-types=\"http://127.0.0.1:4545/type_definitions/foo.d.ts\"\nimport * as b from \"http://127.0.0.1:4545/type_definitions/foo.js\";\nimport * as c from \"http://127.0.0.1:4545/subdir/type_reference.js\";\nimport * as d from \"http://127.0.0.1:4545/subdir/mod1.ts\";\nimport * as e from \"data:application/typescript;base64,ZXhwb3J0IGNvbnN0IGEgPSAiYSI7CgpleHBvcnQgZW51bSBBIHsKICBBLAogIEIsCiAgQywKfQo=\";\nimport * as f from \"./file_01.ts\";\nimport * as g from \"http://localhost:4545/x/a/mod.ts\";\n\nconsole.log(a, b, c, d, e, f, g);\n" + "text": "import * as a from \"http://127.0.0.1:4545/xTypeScriptTypes.js\";\n// @ts-types=\"http://127.0.0.1:4545/type_definitions/foo.d.ts\"\nimport * as b from \"http://127.0.0.1:4545/type_definitions/foo.js\";\nimport * as c from \"http://127.0.0.1:4545/subdir/type_reference.js\";\nimport * as d from \"http://127.0.0.1:4545/subdir/mod1.ts\";\nimport * as e from \"data:application/typescript;base64,ZXhwb3J0IGNvbnN0IGEgPSAiYSI7CgpleHBvcnQgZW51bSBBIHsKICBBLAogIEIsCiAgQywKfQo=\";\nimport * as f from \"./file_01.ts\";\nimport * as g from \"http://localhost:4545/x/a/mod.ts\";\n\nconsole.log(a, b, c, d, e, f, g);\n" } })); assert_eq!(diagnostics.all().len(), 6); @@ -10319,7 +10319,7 @@ fn lsp_tls_cert() { "uri": "file:///a/file.ts", "languageId": "typescript", "version": 1, - "text": "import * as a from \"https://localhost:5545/xTypeScriptTypes.js\";\n// @deno-types=\"https://localhost:5545/type_definitions/foo.d.ts\"\nimport * as b from \"https://localhost:5545/type_definitions/foo.js\";\nimport * as c from \"https://localhost:5545/subdir/type_reference.js\";\nimport * as d from \"https://localhost:5545/subdir/mod1.ts\";\nimport * as e from \"data:application/typescript;base64,ZXhwb3J0IGNvbnN0IGEgPSAiYSI7CgpleHBvcnQgZW51bSBBIHsKICBBLAogIEIsCiAgQywKfQo=\";\nimport * as f from \"./file_01.ts\";\nimport * as g from \"http://localhost:4545/x/a/mod.ts\";\n\nconsole.log(a, b, c, d, e, f, g);\n" + "text": "import * as a from \"https://localhost:5545/xTypeScriptTypes.js\";\n// @ts-types=\"https://localhost:5545/type_definitions/foo.d.ts\"\nimport * as b from \"https://localhost:5545/type_definitions/foo.js\";\nimport * as c from \"https://localhost:5545/subdir/type_reference.js\";\nimport * as d from \"https://localhost:5545/subdir/mod1.ts\";\nimport * as e from \"data:application/typescript;base64,ZXhwb3J0IGNvbnN0IGEgPSAiYSI7CgpleHBvcnQgZW51bSBBIHsKICBBLAogIEIsCiAgQywKfQo=\";\nimport * as f from \"./file_01.ts\";\nimport * as g from \"http://localhost:4545/x/a/mod.ts\";\n\nconsole.log(a, b, c, d, e, f, g);\n" } })); let diagnostics = diagnostics.all(); @@ -10784,7 +10784,7 @@ fn lsp_diagnostics_deno_types() { "uri": "file:///a/file.ts", "languageId": "typescript", "version": 1, - "text": "/// \n/// \n///