mirror of
https://github.com/denoland/deno.git
synced 2024-12-18 13:22:55 -05:00
fix: replace the @deno-types with @ts-types (#27310)
This commit is contained in:
parent
c3af09821a
commit
59dd5d21d4
4 changed files with 24 additions and 26 deletions
|
@ -1387,7 +1387,7 @@ impl CodeActionCollection {
|
||||||
character: import_start.column_index as u32,
|
character: import_start.column_index as u32,
|
||||||
};
|
};
|
||||||
let new_text = format!(
|
let new_text = format!(
|
||||||
"{}// @deno-types=\"{}\"\n",
|
"{}// @ts-types=\"{}\"\n",
|
||||||
if position.character == 0 { "" } else { "\n" },
|
if position.character == 0 { "" } else { "\n" },
|
||||||
&types_specifier_text
|
&types_specifier_text
|
||||||
);
|
);
|
||||||
|
@ -1400,7 +1400,7 @@ impl CodeActionCollection {
|
||||||
};
|
};
|
||||||
Some(lsp::CodeAction {
|
Some(lsp::CodeAction {
|
||||||
title: format!(
|
title: format!(
|
||||||
"Add @deno-types directive for \"{}\"",
|
"Add @ts-types directive for \"{}\"",
|
||||||
&types_specifier_text
|
&types_specifier_text
|
||||||
),
|
),
|
||||||
kind: Some(lsp::CodeActionKind::QUICKFIX),
|
kind: Some(lsp::CodeActionKind::QUICKFIX),
|
||||||
|
|
|
@ -1355,7 +1355,7 @@ fn diagnose_resolution(
|
||||||
}
|
}
|
||||||
// don't bother warning about sloppy import redirects from .js to .d.ts
|
// don't bother warning about sloppy import redirects from .js to .d.ts
|
||||||
// because explaining how to fix this via a diagnostic involves using
|
// 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"
|
let is_sloppy_import_dts_redirect = doc_specifier.scheme() == "file"
|
||||||
&& doc.media_type().is_declaration()
|
&& doc.media_type().is_declaration()
|
||||||
&& !MediaType::from_specifier(specifier).is_declaration();
|
&& !MediaType::from_specifier(specifier).is_declaration();
|
||||||
|
@ -1523,7 +1523,7 @@ fn diagnose_dependency(
|
||||||
.iter()
|
.iter()
|
||||||
.map(|i| documents::to_lsp_range(&i.specifier_range))
|
.map(|i| documents::to_lsp_range(&i.specifier_range))
|
||||||
.collect();
|
.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
|
// a different specifier and therefore needs a separate call to
|
||||||
// `diagnose_resolution()`. It would be much cleaner if that were modelled as
|
// `diagnose_resolution()`. It would be much cleaner if that were modelled as
|
||||||
// a separate dependency: https://github.com/denoland/deno_graph/issues/247.
|
// a separate dependency: https://github.com/denoland/deno_graph/issues/247.
|
||||||
|
@ -1540,7 +1540,7 @@ fn diagnose_dependency(
|
||||||
snapshot,
|
snapshot,
|
||||||
dependency_key,
|
dependency_key,
|
||||||
if dependency.maybe_code.is_none()
|
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
|
// it's likely resolving into the node_modules folder, which might be
|
||||||
// erroring correctly due to resolution only being for bundlers. Let this
|
// erroring correctly due to resolution only being for bundlers. Let this
|
||||||
// fail at runtime if necessary, but don't bother erroring in the editor
|
// fail at runtime if necessary, but don't bother erroring in the editor
|
||||||
|
@ -1951,7 +1951,7 @@ let c: number = "a";
|
||||||
&[(
|
&[(
|
||||||
"a.ts",
|
"a.ts",
|
||||||
r#"
|
r#"
|
||||||
// @deno-types="bad.d.ts"
|
// @ts-types="bad.d.ts"
|
||||||
import "bad.js";
|
import "bad.js";
|
||||||
import "bad.js";
|
import "bad.js";
|
||||||
"#,
|
"#,
|
||||||
|
@ -2005,11 +2005,11 @@ let c: number = "a";
|
||||||
"range": {
|
"range": {
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 1,
|
||||||
"character": 23
|
"character": 21
|
||||||
},
|
},
|
||||||
"end": {
|
"end": {
|
||||||
"line": 1,
|
"line": 1,
|
||||||
"character": 33
|
"character": 31
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"severity": 1,
|
"severity": 1,
|
||||||
|
|
|
@ -3419,7 +3419,7 @@ fn parse_code_actions(
|
||||||
&specifier_rewrite.new_deno_types_specifier
|
&specifier_rewrite.new_deno_types_specifier
|
||||||
{
|
{
|
||||||
text_edit.new_text = format!(
|
text_edit.new_text = format!(
|
||||||
"// @deno-types=\"{}\"\n{}",
|
"// @ts-types=\"{}\"\n{}",
|
||||||
deno_types_specifier, &text_edit.new_text
|
deno_types_specifier, &text_edit.new_text
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -3594,10 +3594,8 @@ impl CompletionEntryDetails {
|
||||||
if let Some(deno_types_specifier) =
|
if let Some(deno_types_specifier) =
|
||||||
&specifier_rewrite.new_deno_types_specifier
|
&specifier_rewrite.new_deno_types_specifier
|
||||||
{
|
{
|
||||||
*new_text = format!(
|
*new_text =
|
||||||
"// @deno-types=\"{}\"\n{}",
|
format!("// @ts-types=\"{}\"\n{}", deno_types_specifier, new_text);
|
||||||
deno_types_specifier, new_text
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2701,7 +2701,7 @@ fn lsp_hover_dependency() {
|
||||||
"uri": "file:///a/file.ts",
|
"uri": "file:///a/file.ts",
|
||||||
"languageId": "typescript",
|
"languageId": "typescript",
|
||||||
"version": 1,
|
"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,
|
res,
|
||||||
json!([
|
json!([
|
||||||
{
|
{
|
||||||
"title": "Add @deno-types directive for \"@types/react\"",
|
"title": "Add @ts-types directive for \"@types/react\"",
|
||||||
"kind": "quickfix",
|
"kind": "quickfix",
|
||||||
"edit": {
|
"edit": {
|
||||||
"changes": {
|
"changes": {
|
||||||
|
@ -6279,7 +6279,7 @@ fn lsp_code_actions_deno_types_for_npm() {
|
||||||
"start": { "line": 0, "character": 0 },
|
"start": { "line": 0, "character": 0 },
|
||||||
"end": { "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,
|
res,
|
||||||
json!([
|
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",
|
"kind": "quickfix",
|
||||||
"edit": {
|
"edit": {
|
||||||
"changes": {
|
"changes": {
|
||||||
|
@ -6332,7 +6332,7 @@ fn lsp_code_actions_deno_types_for_npm() {
|
||||||
"start": { "line": 0, "character": 0 },
|
"start": { "line": 0, "character": 0 },
|
||||||
"end": { "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(
|
temp_dir.write(
|
||||||
"other.ts",
|
"other.ts",
|
||||||
r#"
|
r#"
|
||||||
// @deno-types="@types/lz-string"
|
// @ts-types="@types/lz-string"
|
||||||
import "lz-string";
|
import "lz-string";
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
|
@ -8358,7 +8358,7 @@ fn lsp_npm_auto_import_with_deno_types() {
|
||||||
"start": { "line": 0, "character": 0 },
|
"start": { "line": 0, "character": 0 },
|
||||||
"end": { "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 },
|
"start": { "line": 0, "character": 0 },
|
||||||
"end": { "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",
|
"uri": "file:///a/file.ts",
|
||||||
"languageId": "typescript",
|
"languageId": "typescript",
|
||||||
"version": 1,
|
"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);
|
assert_eq!(diagnostics.all().len(), 6);
|
||||||
|
@ -10319,7 +10319,7 @@ fn lsp_tls_cert() {
|
||||||
"uri": "file:///a/file.ts",
|
"uri": "file:///a/file.ts",
|
||||||
"languageId": "typescript",
|
"languageId": "typescript",
|
||||||
"version": 1,
|
"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();
|
let diagnostics = diagnostics.all();
|
||||||
|
@ -10784,7 +10784,7 @@ fn lsp_diagnostics_deno_types() {
|
||||||
"uri": "file:///a/file.ts",
|
"uri": "file:///a/file.ts",
|
||||||
"languageId": "typescript",
|
"languageId": "typescript",
|
||||||
"version": 1,
|
"version": 1,
|
||||||
"text": "/// <reference types=\"https://example.com/a/b.d.ts\" />\n/// <reference path=\"https://example.com/a/c.ts\"\n\n// @deno-types=https://example.com/a/d.d.ts\nimport * as d from \"https://example.com/a/d.js\";\n\n// @deno-types=\"https://example.com/a/e.d.ts\"\nimport * as e from \"https://example.com/a/e.js\";\n\nconsole.log(d, e);\n"
|
"text": "/// <reference types=\"https://example.com/a/b.d.ts\" />\n/// <reference path=\"https://example.com/a/c.ts\"\n\n// @ts-types=https://example.com/a/d.d.ts\nimport * as d from \"https://example.com/a/d.js\";\n\n// @ts-types=\"https://example.com/a/e.d.ts\"\nimport * as e from \"https://example.com/a/e.js\";\n\nconsole.log(d, e);\n"
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -10797,7 +10797,7 @@ fn lsp_diagnostics_deno_types() {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
assert_eq!(diagnostics.all().len(), 5);
|
assert_eq!(diagnostics.all().len(), 4);
|
||||||
client.shutdown();
|
client.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15782,7 +15782,7 @@ fn lsp_sloppy_imports() {
|
||||||
"import * as b from './b.js';\n",
|
"import * as b from './b.js';\n",
|
||||||
// this one's types resolve to a .d.ts file and we don't
|
// this one's types resolve to a .d.ts file and we don't
|
||||||
// bother warning about it because it's a bit complicated
|
// bother warning about it because it's a bit complicated
|
||||||
// to explain to use @deno-types in a diagnostic
|
// to explain to use @ts-types in a diagnostic
|
||||||
"import * as c from './c.js';\n",
|
"import * as c from './c.js';\n",
|
||||||
"console.log(a)\n",
|
"console.log(a)\n",
|
||||||
"console.log(b);\n",
|
"console.log(b);\n",
|
||||||
|
|
Loading…
Reference in a new issue