diff options
Diffstat (limited to 'cli/tests')
24 files changed, 62 insertions, 47 deletions
diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs index c86d30456..2dea05015 100644 --- a/cli/tests/integration/lsp_tests.rs +++ b/cli/tests/integration/lsp_tests.rs @@ -760,7 +760,7 @@ fn lsp_deno_task() { } #[test] -fn lsp_import_assertions() { +fn lsp_import_attributes() { let context = TestContextBuilder::new().use_temp_cwd().build(); let mut client = context.new_lsp_command().build(); client.initialize(|builder| { @@ -806,9 +806,9 @@ fn lsp_import_assertions() { "end": { "line": 0, "character": 27 } }, "severity": 1, - "code": "no-assert-type", + "code": "no-attribute-type", "source": "deno", - "message": "The module is a JSON module and not being imported with an import assertion. Consider adding `assert { type: \"json\" }` to the import statement." + "message": "The module is a JSON module and not being imported with an import attribute. Consider adding `with { type: \"json\" }` to the import statement." } ]) ); @@ -831,9 +831,9 @@ fn lsp_import_assertions() { "end": { "line": 0, "character": 27 } }, "severity": 1, - "code": "no-assert-type", + "code": "no-attribute-type", "source": "deno", - "message": "The module is a JSON module and not being imported with an import assertion. Consider adding `assert { type: \"json\" }` to the import statement." + "message": "The module is a JSON module and not being imported with an import attribute. Consider adding `with { type: \"json\" }` to the import statement." }], "only": ["quickfix"] } @@ -843,7 +843,7 @@ fn lsp_import_assertions() { assert_eq!( res, json!([{ - "title": "Insert import assertion.", + "title": "Insert import attribute.", "kind": "quickfix", "diagnostics": [ { @@ -852,9 +852,9 @@ fn lsp_import_assertions() { "end": { "line": 0, "character": 27 } }, "severity": 1, - "code": "no-assert-type", + "code": "no-attribute-type", "source": "deno", - "message": "The module is a JSON module and not being imported with an import assertion. Consider adding `assert { type: \"json\" }` to the import statement." + "message": "The module is a JSON module and not being imported with an import attribute. Consider adding `with { type: \"json\" }` to the import statement." } ], "edit": { @@ -865,7 +865,7 @@ fn lsp_import_assertions() { "start": { "line": 0, "character": 27 }, "end": { "line": 0, "character": 27 } }, - "newText": " assert { type: \"json\" }" + "newText": " with { type: \"json\" }" } ] } diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs index e7ff19954..dd5b346ae 100644 --- a/cli/tests/integration/run_tests.rs +++ b/cli/tests/integration/run_tests.rs @@ -2066,14 +2066,14 @@ itest!(shebang_swc { }); itest!(shebang_with_json_imports_tsc { - args: "run --quiet import_assertions/json_with_shebang.ts", - output: "import_assertions/json_with_shebang.ts.out", + args: "run --quiet import_attributes/json_with_shebang.ts", + output: "import_attributes/json_with_shebang.ts.out", exit_code: 1, }); itest!(shebang_with_json_imports_swc { - args: "run --quiet --no-check import_assertions/json_with_shebang.ts", - output: "import_assertions/json_with_shebang.ts.out", + args: "run --quiet --no-check import_attributes/json_with_shebang.ts", + output: "import_attributes/json_with_shebang.ts.out", exit_code: 1, }); @@ -3050,36 +3050,36 @@ itest!(issue_13562 { output: "run/issue13562.ts.out", }); -itest!(import_assertions_static_import { - args: "run --allow-read import_assertions/static_import.ts", - output: "import_assertions/static_import.out", +itest!(import_attributes_static_import { + args: "run --allow-read import_attributes/static_import.ts", + output: "import_attributes/static_import.out", }); -itest!(import_assertions_static_export { - args: "run --allow-read import_assertions/static_export.ts", - output: "import_assertions/static_export.out", +itest!(import_attributes_static_export { + args: "run --allow-read import_attributes/static_export.ts", + output: "import_attributes/static_export.out", }); -itest!(import_assertions_static_error { - args: "run --allow-read import_assertions/static_error.ts", - output: "import_assertions/static_error.out", +itest!(import_attributes_static_error { + args: "run --allow-read import_attributes/static_error.ts", + output: "import_attributes/static_error.out", exit_code: 1, }); -itest!(import_assertions_dynamic_import { - args: "run --allow-read import_assertions/dynamic_import.ts", - output: "import_assertions/dynamic_import.out", +itest!(import_attributes_dynamic_import { + args: "run --allow-read --check import_attributes/dynamic_import.ts", + output: "import_attributes/dynamic_import.out", }); -itest!(import_assertions_dynamic_error { - args: "run --allow-read import_assertions/dynamic_error.ts", - output: "import_assertions/dynamic_error.out", +itest!(import_attributes_dynamic_error { + args: "run --allow-read import_attributes/dynamic_error.ts", + output: "import_attributes/dynamic_error.out", exit_code: 1, }); -itest!(import_assertions_type_check { - args: "run --allow-read --check import_assertions/type_check.ts", - output: "import_assertions/type_check.out", +itest!(import_attributes_type_check { + args: "run --allow-read --check import_attributes/type_check.ts", + output: "import_attributes/type_check.out", exit_code: 1, }); diff --git a/cli/tests/testdata/import_assertions/dynamic_import.ts b/cli/tests/testdata/import_assertions/dynamic_import.ts deleted file mode 100644 index d6983852c..000000000 --- a/cli/tests/testdata/import_assertions/dynamic_import.ts +++ /dev/null @@ -1,3 +0,0 @@ -const data = await import("./data.json", { assert: { type: "json" } }); - -console.log(data); diff --git a/cli/tests/testdata/import_assertions/static_import.ts b/cli/tests/testdata/import_assertions/static_import.ts deleted file mode 100644 index 180ab75f2..000000000 --- a/cli/tests/testdata/import_assertions/static_import.ts +++ /dev/null @@ -1,3 +0,0 @@ -import data from "./data.json" assert { type: "json" }; - -console.log(data); diff --git a/cli/tests/testdata/import_assertions/type_check.out b/cli/tests/testdata/import_assertions/type_check.out deleted file mode 100644 index 8e1387456..000000000 --- a/cli/tests/testdata/import_assertions/type_check.out +++ /dev/null @@ -1,5 +0,0 @@ -[WILDCARD] -error: TS2339 [ERROR]: Property 'foo' does not exist on type '{ a: string; c: { d: number; }; }'. -console.log(data.foo); - ~~~ - at [WILDCARD]type_check.ts:3:18 diff --git a/cli/tests/testdata/import_assertions/type_check.ts b/cli/tests/testdata/import_assertions/type_check.ts deleted file mode 100644 index 19adb3eae..000000000 --- a/cli/tests/testdata/import_assertions/type_check.ts +++ /dev/null @@ -1,3 +0,0 @@ -import data from "./data.json" assert { type: "json" }; - -console.log(data.foo); diff --git a/cli/tests/testdata/import_assertions/data.json b/cli/tests/testdata/import_attributes/data.json index 37b3ee1e0..37b3ee1e0 100644 --- a/cli/tests/testdata/import_assertions/data.json +++ b/cli/tests/testdata/import_attributes/data.json diff --git a/cli/tests/testdata/import_assertions/dynamic_error.out b/cli/tests/testdata/import_attributes/dynamic_error.out index 927eae0b8..927eae0b8 100644 --- a/cli/tests/testdata/import_assertions/dynamic_error.out +++ b/cli/tests/testdata/import_attributes/dynamic_error.out diff --git a/cli/tests/testdata/import_assertions/dynamic_error.ts b/cli/tests/testdata/import_attributes/dynamic_error.ts index 2d9c6757f..2d9c6757f 100644 --- a/cli/tests/testdata/import_assertions/dynamic_error.ts +++ b/cli/tests/testdata/import_attributes/dynamic_error.ts diff --git a/cli/tests/testdata/import_assertions/dynamic_import.out b/cli/tests/testdata/import_attributes/dynamic_import.out index 7a7b4c91f..01bc76c8a 100644 --- a/cli/tests/testdata/import_assertions/dynamic_import.out +++ b/cli/tests/testdata/import_attributes/dynamic_import.out @@ -1,2 +1,3 @@ [WILDCARD] [Module: null prototype] { default: { a: "b", c: { d: 10 } } } +[Module: null prototype] { default: { a: "b", c: { d: 10 } } } diff --git a/cli/tests/testdata/import_attributes/dynamic_import.ts b/cli/tests/testdata/import_attributes/dynamic_import.ts new file mode 100644 index 000000000..73f348697 --- /dev/null +++ b/cli/tests/testdata/import_attributes/dynamic_import.ts @@ -0,0 +1,5 @@ +const data1 = await import("./data.json", { with: { type: "json" } }); +const data2 = await import("./data.json", { assert: { type: "json" } }); + +console.log(data1); +console.log(data2); diff --git a/cli/tests/testdata/import_assertions/json_with_shebang.json b/cli/tests/testdata/import_attributes/json_with_shebang.json index b695e4457..b695e4457 100644 --- a/cli/tests/testdata/import_assertions/json_with_shebang.json +++ b/cli/tests/testdata/import_attributes/json_with_shebang.json diff --git a/cli/tests/testdata/import_assertions/json_with_shebang.ts b/cli/tests/testdata/import_attributes/json_with_shebang.ts index 523bf8772..523bf8772 100644 --- a/cli/tests/testdata/import_assertions/json_with_shebang.ts +++ b/cli/tests/testdata/import_attributes/json_with_shebang.ts diff --git a/cli/tests/testdata/import_assertions/json_with_shebang.ts.out b/cli/tests/testdata/import_attributes/json_with_shebang.ts.out index 23eb03720..23eb03720 100644 --- a/cli/tests/testdata/import_assertions/json_with_shebang.ts.out +++ b/cli/tests/testdata/import_attributes/json_with_shebang.ts.out diff --git a/cli/tests/testdata/import_assertions/static_error.out b/cli/tests/testdata/import_attributes/static_error.out index 4efdf8682..171ae0c1a 100644 --- a/cli/tests/testdata/import_assertions/static_error.out +++ b/cli/tests/testdata/import_attributes/static_error.out @@ -1,4 +1,4 @@ [WILDCARD] -error: Expected a JavaScript or TypeScript module, but identified a Json module. Consider importing Json modules with an import assertion with the type of "json". +error: Expected a JavaScript or TypeScript module, but identified a Json module. Consider importing Json modules with an import attribute with the type of "json". Specifier: [WILDCARD]/data.json at [WILDCARD]static_error.ts:1:18 diff --git a/cli/tests/testdata/import_assertions/static_error.ts b/cli/tests/testdata/import_attributes/static_error.ts index 0bc3a93f8..0bc3a93f8 100644 --- a/cli/tests/testdata/import_assertions/static_error.ts +++ b/cli/tests/testdata/import_attributes/static_error.ts diff --git a/cli/tests/testdata/import_assertions/static_export.out b/cli/tests/testdata/import_attributes/static_export.out index 42fbc066c..42fbc066c 100644 --- a/cli/tests/testdata/import_assertions/static_export.out +++ b/cli/tests/testdata/import_attributes/static_export.out diff --git a/cli/tests/testdata/import_assertions/static_export.ts b/cli/tests/testdata/import_attributes/static_export.ts index ac3ee694f..ac3ee694f 100644 --- a/cli/tests/testdata/import_assertions/static_export.ts +++ b/cli/tests/testdata/import_attributes/static_export.ts diff --git a/cli/tests/testdata/import_assertions/static_import.out b/cli/tests/testdata/import_attributes/static_import.out index 42fbc066c..b3b71cd8f 100644 --- a/cli/tests/testdata/import_assertions/static_import.out +++ b/cli/tests/testdata/import_attributes/static_import.out @@ -1,2 +1,3 @@ [WILDCARD] { a: "b", c: { d: 10 } } +{ a: "b", c: { d: 10 } } diff --git a/cli/tests/testdata/import_attributes/static_import.ts b/cli/tests/testdata/import_attributes/static_import.ts new file mode 100644 index 000000000..d46d93b4a --- /dev/null +++ b/cli/tests/testdata/import_attributes/static_import.ts @@ -0,0 +1,5 @@ +import data1 from "./data.json" with { type: "json" }; +import data2 from "./data.json" assert { type: "json" }; + +console.log(data1); +console.log(data2); diff --git a/cli/tests/testdata/import_assertions/static_reexport.ts b/cli/tests/testdata/import_attributes/static_reexport.ts index 81af428be..81af428be 100644 --- a/cli/tests/testdata/import_assertions/static_reexport.ts +++ b/cli/tests/testdata/import_attributes/static_reexport.ts diff --git a/cli/tests/testdata/import_attributes/type_check.out b/cli/tests/testdata/import_attributes/type_check.out new file mode 100644 index 000000000..5ecdec82d --- /dev/null +++ b/cli/tests/testdata/import_attributes/type_check.out @@ -0,0 +1,12 @@ +Check file:///[WILDCARD]/type_check.ts +error: TS2339 [ERROR]: Property 'foo' does not exist on type '{ a: string; c: { d: number; }; }'. +console.log(data1.foo); + ~~~ + at [WILDCARD]type_check.ts:4:19 + +TS2339 [ERROR]: Property 'foo' does not exist on type '{ a: string; c: { d: number; }; }'. +console.log(data2.foo); + ~~~ + at [WILDCARD]type_check.ts:5:19 + +Found 2 errors. diff --git a/cli/tests/testdata/import_attributes/type_check.ts b/cli/tests/testdata/import_attributes/type_check.ts new file mode 100644 index 000000000..ddf28e67a --- /dev/null +++ b/cli/tests/testdata/import_attributes/type_check.ts @@ -0,0 +1,5 @@ +import data1 from "./data.json" with { type: "json" }; +import data2 from "./data.json" assert { type: "json" }; + +console.log(data1.foo); +console.log(data2.foo); diff --git a/cli/tests/testdata/run/020_json_modules.ts.out b/cli/tests/testdata/run/020_json_modules.ts.out index da33c40bf..750363da2 100644 --- a/cli/tests/testdata/run/020_json_modules.ts.out +++ b/cli/tests/testdata/run/020_json_modules.ts.out @@ -1,4 +1,4 @@ [WILDCARD] -error: Expected a JavaScript or TypeScript module, but identified a Json module. Consider importing Json modules with an import assertion with the type of "json". +error: Expected a JavaScript or TypeScript module, but identified a Json module. Consider importing Json modules with an import attribute with the type of "json". Specifier: [WILDCARD]/subdir/config.json [WILDCARD]
\ No newline at end of file |