diff options
| author | David Sherret <dsherret@users.noreply.github.com> | 2024-08-21 13:12:56 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-21 17:12:56 +0000 |
| commit | 1d4169204cdc870a084a3371500d7b3ab8546bc2 (patch) | |
| tree | e70a6a99ab7d937dd789f58af5d656b0555f8507 /tests/specs | |
| parent | e2c50f7e8ada214f3a44a49da2faa0716d24970e (diff) | |
fix: warn about import assertions when using typescript (#25135)
1. On emit, checks for the prescence of import assertions.
1. Warns and doesn't store the parsed source in the emit cache in this
case.
Diffstat (limited to 'tests/specs')
| -rw-r--r-- | tests/specs/run/ts_import_assertions/__test__.jsonc | 18 | ||||
| -rw-r--r-- | tests/specs/run/ts_import_assertions/assertion.out | 14 | ||||
| -rw-r--r-- | tests/specs/run/ts_import_assertions/assertion.ts | 5 | ||||
| -rw-r--r-- | tests/specs/run/ts_import_assertions/data.json | 3 | ||||
| -rw-r--r-- | tests/specs/run/ts_import_assertions/with.out | 2 | ||||
| -rw-r--r-- | tests/specs/run/ts_import_assertions/with.ts | 3 |
6 files changed, 45 insertions, 0 deletions
diff --git a/tests/specs/run/ts_import_assertions/__test__.jsonc b/tests/specs/run/ts_import_assertions/__test__.jsonc new file mode 100644 index 000000000..dc5576bd1 --- /dev/null +++ b/tests/specs/run/ts_import_assertions/__test__.jsonc @@ -0,0 +1,18 @@ +{ + "tests": { + "assertion": { + "steps": [{ + "args": "run assertion.ts", + "output": "assertion.out" + }, { + // should output the same because the emit won't be cached + "args": "run assertion.ts", + "output": "assertion.out" + }] + }, + "with": { + "args": "run with.ts", + "output": "with.out" + } + } +} diff --git a/tests/specs/run/ts_import_assertions/assertion.out b/tests/specs/run/ts_import_assertions/assertion.out new file mode 100644 index 000000000..3cc900d64 --- /dev/null +++ b/tests/specs/run/ts_import_assertions/assertion.out @@ -0,0 +1,14 @@ +⚠️ Import assertions are deprecated. Use `with` keyword, instead of 'assert' keyword. + +import test from "./data.json" assert { type: "json" }; + + at file:///[WILDLINE]/assertion.ts:1:1 + +{ prop: "data" } +⚠️ Import assertions are deprecated. Use `with` keyword, instead of 'assert' keyword. + +console.log((await import("./data.json", { + + at file:///[WILDLINE]/assertion.ts:5:13 + +{ prop: "data" } diff --git a/tests/specs/run/ts_import_assertions/assertion.ts b/tests/specs/run/ts_import_assertions/assertion.ts new file mode 100644 index 000000000..cb653ffc7 --- /dev/null +++ b/tests/specs/run/ts_import_assertions/assertion.ts @@ -0,0 +1,5 @@ +import test from "./data.json" assert { type: "json" }; +console.log(test); +console.log( + (await import("./data.json", { assert: { type: "json" } })).default, +); diff --git a/tests/specs/run/ts_import_assertions/data.json b/tests/specs/run/ts_import_assertions/data.json new file mode 100644 index 000000000..e5b07266c --- /dev/null +++ b/tests/specs/run/ts_import_assertions/data.json @@ -0,0 +1,3 @@ +{ + "prop": "data" +} diff --git a/tests/specs/run/ts_import_assertions/with.out b/tests/specs/run/ts_import_assertions/with.out new file mode 100644 index 000000000..6141f8c07 --- /dev/null +++ b/tests/specs/run/ts_import_assertions/with.out @@ -0,0 +1,2 @@ +{ prop: "data" } +{ prop: "data" } diff --git a/tests/specs/run/ts_import_assertions/with.ts b/tests/specs/run/ts_import_assertions/with.ts new file mode 100644 index 000000000..58b7fb03d --- /dev/null +++ b/tests/specs/run/ts_import_assertions/with.ts @@ -0,0 +1,3 @@ +import test from "./data.json" with { type: "json" }; +console.log(test); +console.log((await import("./data.json", { with: { type: "json" } })).default); |
