From df1f71b455ccaa67be6d57536bb891e22503d8c1 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Tue, 2 Nov 2021 20:03:03 +0000 Subject: [PATCH 1/2] Cherry-pick PR #46630 into release-4.5 Component commits: 8ba5d7c4f3 Allow import assertions on esm imports under module: nodenext 2c5b9a93bc Changes to copy b48868dd78 Merge branch 'main' into import-assertions-module-nodenext --- src/compiler/checker.ts | 12 +++-- src/compiler/diagnosticMessages.json | 8 +++- ...portAssertion1(module=commonjs).errors.txt | 48 +++++++++---------- ...importAssertion1(module=es2015).errors.txt | 20 ++++---- ...portAssertion2(module=commonjs).errors.txt | 24 +++++----- ...importAssertion2(module=es2015).errors.txt | 24 +++++----- ...importAssertion3(module=es2015).errors.txt | 16 +++---- ...mportCallExpressionGrammarError.errors.txt | 4 +- ...ImportAssertions(module=node12).errors.txt | 28 +++++++++++ ...eModulesImportAssertions(module=node12).js | 20 ++++++++ ...lesImportAssertions(module=node12).symbols | 25 ++++++++++ ...dulesImportAssertions(module=node12).types | 36 ++++++++++++++ ...portAssertions(module=nodenext).errors.txt | 22 +++++++++ ...odulesImportAssertions(module=nodenext).js | 20 ++++++++ ...sImportAssertions(module=nodenext).symbols | 25 ++++++++++ ...lesImportAssertions(module=nodenext).types | 36 ++++++++++++++ .../node/nodeModulesImportAssertions.ts | 13 +++++ 17 files changed, 307 insertions(+), 74 deletions(-) create mode 100644 tests/baselines/reference/nodeModulesImportAssertions(module=node12).errors.txt create mode 100644 tests/baselines/reference/nodeModulesImportAssertions(module=node12).js create mode 100644 tests/baselines/reference/nodeModulesImportAssertions(module=node12).symbols create mode 100644 tests/baselines/reference/nodeModulesImportAssertions(module=node12).types create mode 100644 tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).errors.txt create mode 100644 tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).symbols create mode 100644 tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).types create mode 100644 tests/cases/conformance/node/nodeModulesImportAssertions.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9d1bf23546c56..cea18ee57a5eb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -39680,8 +39680,12 @@ namespace ts { function checkAssertClause(declaration: ImportDeclaration | ExportDeclaration) { if (declaration.assertClause) { - if (moduleKind !== ModuleKind.ESNext) { - return grammarErrorOnNode(declaration.assertClause, Diagnostics.Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext); + const mode = (moduleKind === ModuleKind.NodeNext) && declaration.moduleSpecifier && getUsageModeForExpression(declaration.moduleSpecifier); + if (mode !== ModuleKind.ESNext && moduleKind !== ModuleKind.ESNext) { + return grammarErrorOnNode(declaration.assertClause, + moduleKind === ModuleKind.NodeNext + ? Diagnostics.Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls + : Diagnostics.Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext); } if (isImportDeclaration(declaration) ? declaration.importClause?.isTypeOnly : declaration.isTypeOnly) { @@ -43891,13 +43895,13 @@ namespace ts { } const nodeArguments = node.arguments; - if (moduleKind !== ModuleKind.ESNext) { + if (moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.NodeNext) { // We are allowed trailing comma after proposal-import-assertions. checkGrammarForDisallowedTrailingComma(nodeArguments); if (nodeArguments.length > 1) { const assertionArgument = nodeArguments[1]; - return grammarErrorOnNode(assertionArgument, Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext); + return grammarErrorOnNode(assertionArgument, Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_or_nodenext); } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 26d8e39f07084..606dc1a2acb49 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -924,7 +924,7 @@ "category": "Error", "code": 1323 }, - "Dynamic imports only support a second argument when the '--module' option is set to 'esnext'.": { + "Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'.": { "category": "Error", "code": 1324 }, @@ -3333,7 +3333,7 @@ "category": "Error", "code": 2820 }, - "Import assertions are only supported when the '--module' option is set to 'esnext'.": { + "Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.": { "category": "Error", "code": 2821 }, @@ -3353,6 +3353,10 @@ "category": "Error", "code": 2835 }, + "Import assertions are not allowed on statements that transpile to commonjs 'require' calls.": { + "category": "Error", + "code": 2836 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/tests/baselines/reference/importAssertion1(module=commonjs).errors.txt b/tests/baselines/reference/importAssertion1(module=commonjs).errors.txt index 11bbc5c2504f2..fa365df88cdf2 100644 --- a/tests/baselines/reference/importAssertion1(module=commonjs).errors.txt +++ b/tests/baselines/reference/importAssertion1(module=commonjs).errors.txt @@ -1,16 +1,16 @@ -tests/cases/conformance/importAssertion/1.ts(1,14): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/1.ts(2,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/1.ts(3,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/3.ts(2,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/3.ts(3,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/3.ts(4,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/3.ts(5,26): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/3.ts(7,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext'. +tests/cases/conformance/importAssertion/1.ts(1,14): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/1.ts(2,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/1.ts(3,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(2,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(3,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(4,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(5,26): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(7,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. tests/cases/conformance/importAssertion/3.ts(8,11): message TS1450: Dynamic imports can only accept a module specifier and an optional assertion as arguments -tests/cases/conformance/importAssertion/3.ts(9,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/3.ts(10,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext'. +tests/cases/conformance/importAssertion/3.ts(9,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(10,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. tests/cases/conformance/importAssertion/3.ts(10,52): error TS1009: Trailing comma not allowed. @@ -21,13 +21,13 @@ tests/cases/conformance/importAssertion/3.ts(10,52): error TS1009: Trailing comm ==== tests/cases/conformance/importAssertion/1.ts (3 errors) ==== import './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. import { a, b } from './0' assert { "type": "json" } ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. import * as foo from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. a; b; foo.a; @@ -36,10 +36,10 @@ tests/cases/conformance/importAssertion/3.ts(10,52): error TS1009: Trailing comm ==== tests/cases/conformance/importAssertion/2.ts (2 errors) ==== import { a, b } from './0' assert {} ~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. import { a as c, b as d } from './0' assert { a: "a", b: "b", c: "c" } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. a; b; c; @@ -49,29 +49,29 @@ tests/cases/conformance/importAssertion/3.ts(10,52): error TS1009: Trailing comm const a = import('./0') const b = import('./0', { assert: { type: "json" } }) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext'. +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. const c = import('./0', { assert: { type: "json", ttype: "typo" } }) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext'. +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. const d = import('./0', { assert: {} }) ~~~~~~~~~~~~~~ -!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext'. +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. const dd = import('./0', {}) ~~ -!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext'. +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. declare function foo(): any; const e = import('./0', foo()) ~~~~~ -!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext'. +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. const f = import() ~~~~~~~~ !!! message TS1450: Dynamic imports can only accept a module specifier and an optional assertion as arguments const g = import('./0', {}, {}) ~~ -!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext'. +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. const h = import('./0', { assert: { type: "json" }},) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext'. +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. ~ !!! error TS1009: Trailing comma not allowed. diff --git a/tests/baselines/reference/importAssertion1(module=es2015).errors.txt b/tests/baselines/reference/importAssertion1(module=es2015).errors.txt index 28290d8f67290..fb959409350b0 100644 --- a/tests/baselines/reference/importAssertion1(module=es2015).errors.txt +++ b/tests/baselines/reference/importAssertion1(module=es2015).errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/importAssertion/1.ts(1,14): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/1.ts(2,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/1.ts(3,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +tests/cases/conformance/importAssertion/1.ts(1,14): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/1.ts(2,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/1.ts(3,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. tests/cases/conformance/importAssertion/3.ts(1,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. tests/cases/conformance/importAssertion/3.ts(2,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. tests/cases/conformance/importAssertion/3.ts(3,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. @@ -21,13 +21,13 @@ tests/cases/conformance/importAssertion/3.ts(10,11): error TS1323: Dynamic impor ==== tests/cases/conformance/importAssertion/1.ts (3 errors) ==== import './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. import { a, b } from './0' assert { "type": "json" } ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. import * as foo from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. a; b; foo.a; @@ -36,10 +36,10 @@ tests/cases/conformance/importAssertion/3.ts(10,11): error TS1323: Dynamic impor ==== tests/cases/conformance/importAssertion/2.ts (2 errors) ==== import { a, b } from './0' assert {} ~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. import { a as c, b as d } from './0' assert { a: "a", b: "b", c: "c" } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. a; b; c; diff --git a/tests/baselines/reference/importAssertion2(module=commonjs).errors.txt b/tests/baselines/reference/importAssertion2(module=commonjs).errors.txt index d3617f72bb06d..8cd296422e7e2 100644 --- a/tests/baselines/reference/importAssertion2(module=commonjs).errors.txt +++ b/tests/baselines/reference/importAssertion2(module=commonjs).errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/importAssertion/1.ts(1,22): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/1.ts(2,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/1.ts(3,21): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/1.ts(4,27): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +tests/cases/conformance/importAssertion/1.ts(1,22): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/1.ts(2,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/1.ts(3,21): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/1.ts(4,27): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. ==== tests/cases/conformance/importAssertion/0.ts (0 errors) ==== @@ -13,22 +13,22 @@ tests/cases/conformance/importAssertion/2.ts(2,38): error TS2821: Import asserti ==== tests/cases/conformance/importAssertion/1.ts (4 errors) ==== export {} from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. export { a, b } from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. export * from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. export * as ns from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. ==== tests/cases/conformance/importAssertion/2.ts (2 errors) ==== export { a, b } from './0' assert {} ~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. export { a as c, b as d } from './0' assert { a: "a", b: "b", c: "c" } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. \ No newline at end of file diff --git a/tests/baselines/reference/importAssertion2(module=es2015).errors.txt b/tests/baselines/reference/importAssertion2(module=es2015).errors.txt index d3617f72bb06d..8cd296422e7e2 100644 --- a/tests/baselines/reference/importAssertion2(module=es2015).errors.txt +++ b/tests/baselines/reference/importAssertion2(module=es2015).errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/importAssertion/1.ts(1,22): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/1.ts(2,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/1.ts(3,21): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/1.ts(4,27): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +tests/cases/conformance/importAssertion/1.ts(1,22): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/1.ts(2,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/1.ts(3,21): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/1.ts(4,27): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. ==== tests/cases/conformance/importAssertion/0.ts (0 errors) ==== @@ -13,22 +13,22 @@ tests/cases/conformance/importAssertion/2.ts(2,38): error TS2821: Import asserti ==== tests/cases/conformance/importAssertion/1.ts (4 errors) ==== export {} from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. export { a, b } from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. export * from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. export * as ns from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. ==== tests/cases/conformance/importAssertion/2.ts (2 errors) ==== export { a, b } from './0' assert {} ~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. export { a as c, b as d } from './0' assert { a: "a", b: "b", c: "c" } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. \ No newline at end of file diff --git a/tests/baselines/reference/importAssertion3(module=es2015).errors.txt b/tests/baselines/reference/importAssertion3(module=es2015).errors.txt index fade981ac769f..fdfac065b05f6 100644 --- a/tests/baselines/reference/importAssertion3(module=es2015).errors.txt +++ b/tests/baselines/reference/importAssertion3(module=es2015).errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/importAssertion/1.ts(1,27): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/1.ts(2,30): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/2.ts(1,31): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/2.ts(2,33): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +tests/cases/conformance/importAssertion/1.ts(1,27): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/1.ts(2,30): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/2.ts(1,31): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/importAssertion/2.ts(2,33): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. ==== tests/cases/conformance/importAssertion/0.ts (0 errors) ==== @@ -10,17 +10,17 @@ tests/cases/conformance/importAssertion/2.ts(2,33): error TS2821: Import asserti ==== tests/cases/conformance/importAssertion/1.ts (2 errors) ==== export type {} from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. export type { I } from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. ==== tests/cases/conformance/importAssertion/2.ts (2 errors) ==== import type { I } from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. import type * as foo from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionGrammarError.errors.txt b/tests/baselines/reference/importCallExpressionGrammarError.errors.txt index 57e3866b8f149..063b200b6729a 100644 --- a/tests/baselines/reference/importCallExpressionGrammarError.errors.txt +++ b/tests/baselines/reference/importCallExpressionGrammarError.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(5,8): tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(7,17): error TS1325: Argument of dynamic import cannot be spread element. tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(8,12): message TS1450: Dynamic imports can only accept a module specifier and an optional assertion as arguments tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(9,19): error TS2307: Cannot find module 'pathToModule' or its corresponding type declarations. -tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(9,35): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext'. +tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(9,35): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(9,35): error TS2559: Type '"secondModule"' has no properties in common with type 'ImportCallOptions'. @@ -25,6 +25,6 @@ tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(9,35): ~~~~~~~~~~~~~~ !!! error TS2307: Cannot find module 'pathToModule' or its corresponding type declarations. ~~~~~~~~~~~~~~ -!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext'. +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. ~~~~~~~~~~~~~~ !!! error TS2559: Type '"secondModule"' has no properties in common with type 'ImportCallOptions'. \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportAssertions(module=node12).errors.txt b/tests/baselines/reference/nodeModulesImportAssertions(module=node12).errors.txt new file mode 100644 index 0000000000000..e1c723d1dec84 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportAssertions(module=node12).errors.txt @@ -0,0 +1,28 @@ +tests/cases/conformance/node/index.ts(1,18): error TS7062: JSON imports are experimental in ES module mode imports. +tests/cases/conformance/node/index.ts(1,35): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/node/otherc.cts(1,35): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +tests/cases/conformance/node/otherc.cts(2,22): error TS7062: JSON imports are experimental in ES module mode imports. +tests/cases/conformance/node/otherc.cts(2,40): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. + + +==== tests/cases/conformance/node/index.ts (2 errors) ==== + import json from "./package.json" assert { type: "json" }; + ~~~~~~~~~~~~~~~~ +!!! error TS7062: JSON imports are experimental in ES module mode imports. + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +==== tests/cases/conformance/node/otherc.cts (3 errors) ==== + import json from "./package.json" assert { type: "json" }; // should error, cjs mode imports don't support assertions + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. + const json2 = import("./package.json", { assert: { type: "json" } }); // should be fine + ~~~~~~~~~~~~~~~~ +!!! error TS7062: JSON imports are experimental in ES module mode imports. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "pkg", + "private": true, + "type": "module" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportAssertions(module=node12).js b/tests/baselines/reference/nodeModulesImportAssertions(module=node12).js new file mode 100644 index 0000000000000..091166d523cd1 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportAssertions(module=node12).js @@ -0,0 +1,20 @@ +//// [tests/cases/conformance/node/nodeModulesImportAssertions.ts] //// + +//// [index.ts] +import json from "./package.json" assert { type: "json" }; +//// [otherc.cts] +import json from "./package.json" assert { type: "json" }; // should error, cjs mode imports don't support assertions +const json2 = import("./package.json", { assert: { type: "json" } }); // should be fine +//// [package.json] +{ + "name": "pkg", + "private": true, + "type": "module" +} + +//// [index.js] +export {}; +//// [otherc.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const json2 = import("./package.json", { assert: { type: "json" } }); // should be fine diff --git a/tests/baselines/reference/nodeModulesImportAssertions(module=node12).symbols b/tests/baselines/reference/nodeModulesImportAssertions(module=node12).symbols new file mode 100644 index 0000000000000..3bacb3cfabe76 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportAssertions(module=node12).symbols @@ -0,0 +1,25 @@ +=== tests/cases/conformance/node/index.ts === +import json from "./package.json" assert { type: "json" }; +>json : Symbol(json, Decl(index.ts, 0, 6)) + +=== tests/cases/conformance/node/otherc.cts === +import json from "./package.json" assert { type: "json" }; // should error, cjs mode imports don't support assertions +>json : Symbol(json, Decl(otherc.cts, 0, 6)) + +const json2 = import("./package.json", { assert: { type: "json" } }); // should be fine +>json2 : Symbol(json2, Decl(otherc.cts, 1, 5)) +>"./package.json" : Symbol("tests/cases/conformance/node/package", Decl(package.json, 0, 0)) +>assert : Symbol(assert, Decl(otherc.cts, 1, 40)) +>type : Symbol(type, Decl(otherc.cts, 1, 50)) + +=== tests/cases/conformance/node/package.json === +{ + "name": "pkg", +>"name" : Symbol("name", Decl(package.json, 0, 1)) + + "private": true, +>"private" : Symbol("private", Decl(package.json, 1, 18)) + + "type": "module" +>"type" : Symbol("type", Decl(package.json, 2, 20)) +} diff --git a/tests/baselines/reference/nodeModulesImportAssertions(module=node12).types b/tests/baselines/reference/nodeModulesImportAssertions(module=node12).types new file mode 100644 index 0000000000000..36c03c4d92697 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportAssertions(module=node12).types @@ -0,0 +1,36 @@ +=== tests/cases/conformance/node/index.ts === +import json from "./package.json" assert { type: "json" }; +>json : { name: string; private: boolean; type: string; } +>type : any + +=== tests/cases/conformance/node/otherc.cts === +import json from "./package.json" assert { type: "json" }; // should error, cjs mode imports don't support assertions +>json : { name: string; private: boolean; type: string; } +>type : any + +const json2 = import("./package.json", { assert: { type: "json" } }); // should be fine +>json2 : Promise<{ default: { name: string; private: boolean; type: string; }; }> +>import("./package.json", { assert: { type: "json" } }) : Promise<{ default: { name: string; private: boolean; type: string; }; }> +>"./package.json" : "./package.json" +>{ assert: { type: "json" } } : { assert: { type: string; }; } +>assert : { type: string; } +>{ type: "json" } : { type: string; } +>type : string +>"json" : "json" + +=== tests/cases/conformance/node/package.json === +{ +>{ "name": "pkg", "private": true, "type": "module"} : { name: string; private: boolean; type: string; } + + "name": "pkg", +>"name" : string +>"pkg" : "pkg" + + "private": true, +>"private" : boolean +>true : true + + "type": "module" +>"type" : string +>"module" : "module" +} diff --git a/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).errors.txt new file mode 100644 index 0000000000000..29dbcb839f52b --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).errors.txt @@ -0,0 +1,22 @@ +tests/cases/conformance/node/index.ts(1,18): error TS7062: JSON imports are experimental in ES module mode imports. +tests/cases/conformance/node/otherc.cts(1,35): error TS2836: Import assertions are not allowed on statements that transpile to commonjs 'require' calls. +tests/cases/conformance/node/otherc.cts(2,22): error TS7062: JSON imports are experimental in ES module mode imports. + + +==== tests/cases/conformance/node/index.ts (1 errors) ==== + import json from "./package.json" assert { type: "json" }; + ~~~~~~~~~~~~~~~~ +!!! error TS7062: JSON imports are experimental in ES module mode imports. +==== tests/cases/conformance/node/otherc.cts (2 errors) ==== + import json from "./package.json" assert { type: "json" }; // should error, cjs mode imports don't support assertions + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2836: Import assertions are not allowed on statements that transpile to commonjs 'require' calls. + const json2 = import("./package.json", { assert: { type: "json" } }); // should be fine + ~~~~~~~~~~~~~~~~ +!!! error TS7062: JSON imports are experimental in ES module mode imports. +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "pkg", + "private": true, + "type": "module" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).js b/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).js new file mode 100644 index 0000000000000..091166d523cd1 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).js @@ -0,0 +1,20 @@ +//// [tests/cases/conformance/node/nodeModulesImportAssertions.ts] //// + +//// [index.ts] +import json from "./package.json" assert { type: "json" }; +//// [otherc.cts] +import json from "./package.json" assert { type: "json" }; // should error, cjs mode imports don't support assertions +const json2 = import("./package.json", { assert: { type: "json" } }); // should be fine +//// [package.json] +{ + "name": "pkg", + "private": true, + "type": "module" +} + +//// [index.js] +export {}; +//// [otherc.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const json2 = import("./package.json", { assert: { type: "json" } }); // should be fine diff --git a/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).symbols b/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).symbols new file mode 100644 index 0000000000000..3bacb3cfabe76 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).symbols @@ -0,0 +1,25 @@ +=== tests/cases/conformance/node/index.ts === +import json from "./package.json" assert { type: "json" }; +>json : Symbol(json, Decl(index.ts, 0, 6)) + +=== tests/cases/conformance/node/otherc.cts === +import json from "./package.json" assert { type: "json" }; // should error, cjs mode imports don't support assertions +>json : Symbol(json, Decl(otherc.cts, 0, 6)) + +const json2 = import("./package.json", { assert: { type: "json" } }); // should be fine +>json2 : Symbol(json2, Decl(otherc.cts, 1, 5)) +>"./package.json" : Symbol("tests/cases/conformance/node/package", Decl(package.json, 0, 0)) +>assert : Symbol(assert, Decl(otherc.cts, 1, 40)) +>type : Symbol(type, Decl(otherc.cts, 1, 50)) + +=== tests/cases/conformance/node/package.json === +{ + "name": "pkg", +>"name" : Symbol("name", Decl(package.json, 0, 1)) + + "private": true, +>"private" : Symbol("private", Decl(package.json, 1, 18)) + + "type": "module" +>"type" : Symbol("type", Decl(package.json, 2, 20)) +} diff --git a/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).types b/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).types new file mode 100644 index 0000000000000..36c03c4d92697 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).types @@ -0,0 +1,36 @@ +=== tests/cases/conformance/node/index.ts === +import json from "./package.json" assert { type: "json" }; +>json : { name: string; private: boolean; type: string; } +>type : any + +=== tests/cases/conformance/node/otherc.cts === +import json from "./package.json" assert { type: "json" }; // should error, cjs mode imports don't support assertions +>json : { name: string; private: boolean; type: string; } +>type : any + +const json2 = import("./package.json", { assert: { type: "json" } }); // should be fine +>json2 : Promise<{ default: { name: string; private: boolean; type: string; }; }> +>import("./package.json", { assert: { type: "json" } }) : Promise<{ default: { name: string; private: boolean; type: string; }; }> +>"./package.json" : "./package.json" +>{ assert: { type: "json" } } : { assert: { type: string; }; } +>assert : { type: string; } +>{ type: "json" } : { type: string; } +>type : string +>"json" : "json" + +=== tests/cases/conformance/node/package.json === +{ +>{ "name": "pkg", "private": true, "type": "module"} : { name: string; private: boolean; type: string; } + + "name": "pkg", +>"name" : string +>"pkg" : "pkg" + + "private": true, +>"private" : boolean +>true : true + + "type": "module" +>"type" : string +>"module" : "module" +} diff --git a/tests/cases/conformance/node/nodeModulesImportAssertions.ts b/tests/cases/conformance/node/nodeModulesImportAssertions.ts new file mode 100644 index 0000000000000..0fe1ccdf820b6 --- /dev/null +++ b/tests/cases/conformance/node/nodeModulesImportAssertions.ts @@ -0,0 +1,13 @@ +// @module: node12,nodenext +// @resolveJsonModule: true +// @filename: index.ts +import json from "./package.json" assert { type: "json" }; +// @filename: otherc.cts +import json from "./package.json" assert { type: "json" }; // should error, cjs mode imports don't support assertions +const json2 = import("./package.json", { assert: { type: "json" } }); // should be fine +// @filename: package.json +{ + "name": "pkg", + "private": true, + "type": "module" +} \ No newline at end of file From 035ac355047a7409feaa0428ed18d3134445d362 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Wed, 3 Nov 2021 10:02:40 -0700 Subject: [PATCH 2/2] Update baselines --- .../nodeModulesImportAssertions(module=node12).errors.txt | 2 ++ .../nodeModulesImportAssertions(module=nodenext).errors.txt | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/baselines/reference/nodeModulesImportAssertions(module=node12).errors.txt b/tests/baselines/reference/nodeModulesImportAssertions(module=node12).errors.txt index e1c723d1dec84..0f457c7a4cab8 100644 --- a/tests/baselines/reference/nodeModulesImportAssertions(module=node12).errors.txt +++ b/tests/baselines/reference/nodeModulesImportAssertions(module=node12).errors.txt @@ -1,3 +1,4 @@ +error TS4124: Compiler option 'module' of value 'node12' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'. tests/cases/conformance/node/index.ts(1,18): error TS7062: JSON imports are experimental in ES module mode imports. tests/cases/conformance/node/index.ts(1,35): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. tests/cases/conformance/node/otherc.cts(1,35): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. @@ -5,6 +6,7 @@ tests/cases/conformance/node/otherc.cts(2,22): error TS7062: JSON imports are ex tests/cases/conformance/node/otherc.cts(2,40): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS4124: Compiler option 'module' of value 'node12' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'. ==== tests/cases/conformance/node/index.ts (2 errors) ==== import json from "./package.json" assert { type: "json" }; ~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).errors.txt index 29dbcb839f52b..33d4f5c935f19 100644 --- a/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesImportAssertions(module=nodenext).errors.txt @@ -1,8 +1,10 @@ +error TS4124: Compiler option 'module' of value 'nodenext' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'. tests/cases/conformance/node/index.ts(1,18): error TS7062: JSON imports are experimental in ES module mode imports. tests/cases/conformance/node/otherc.cts(1,35): error TS2836: Import assertions are not allowed on statements that transpile to commonjs 'require' calls. tests/cases/conformance/node/otherc.cts(2,22): error TS7062: JSON imports are experimental in ES module mode imports. +!!! error TS4124: Compiler option 'module' of value 'nodenext' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'. ==== tests/cases/conformance/node/index.ts (1 errors) ==== import json from "./package.json" assert { type: "json" }; ~~~~~~~~~~~~~~~~