From 590892b9f71936362251db92e51865aa28273dbb Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 19 Dec 2024 09:29:13 -0800 Subject: [PATCH] Update missed baseline --- .../nodeModulesJson(module=node20).errors.txt | 11 ++++++++--- .../nodeModulesJson(module=node20).symbols | 14 ++++++++++---- .../reference/nodeModulesJson(module=node20).types | 10 ++++++++++ 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/tests/baselines/reference/nodeModulesJson(module=node20).errors.txt b/tests/baselines/reference/nodeModulesJson(module=node20).errors.txt index 856b88b5b1b44..d828b1b8da6c8 100644 --- a/tests/baselines/reference/nodeModulesJson(module=node20).errors.txt +++ b/tests/baselines/reference/nodeModulesJson(module=node20).errors.txt @@ -3,8 +3,9 @@ /main.mts(2,22): error TS1543: Importing a JSON file into an ECMAScript module requires a 'type: "json"' import attribute when 'module' is set to 'Node20'. /main.mts(3,19): error TS1543: Importing a JSON file into an ECMAScript module requires a 'type: "json"' import attribute when 'module' is set to 'Node20'. /main.mts(7,21): error TS1543: Importing a JSON file into an ECMAScript module requires a 'type: "json"' import attribute when 'module' is set to 'Node20'. -/main.mts(8,10): error TS1544: Named imports from a JSON file into an ECMAScript module are not allowed when 'module' is set to 'Node20'. -/main.mts(10,9): error TS2339: Property 'version' does not exist on type '{ default: { version: number; }; }'. +/main.mts(9,47): error TS2857: Import attributes cannot be used with type-only imports or exports. +/main.mts(10,10): error TS1544: Named imports from a JSON file into an ECMAScript module are not allowed when 'module' is set to 'Node20'. +/main.mts(12,9): error TS2339: Property 'version' does not exist on type '{ default: { version: number; }; }'. ==== /node_modules/not.json/package.json (0 errors) ==== @@ -41,7 +42,7 @@ "version": 1 } -==== /main.mts (5 errors) ==== +==== /main.mts (6 errors) ==== import { oops } from "not.json"; // Ok import moreOops from "actually-json"; // Error in nodenext ~~~~~~~~~~~~~~~ @@ -55,6 +56,10 @@ import config2 from "./config.json"; // Error in nodenext, no attribute ~~~~~~~~~~~~~~~ !!! error TS1543: Importing a JSON file into an ECMAScript module requires a 'type: "json"' import attribute when 'module' is set to 'Node20'. + import type config2Type from "./config.json"; // Ok, type-only + import type config2Type2 from "./config.json" with { type: "json" }; // Error, import attributes not allowed on type-only imports + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2857: Import attributes cannot be used with type-only imports or exports. import { version } from "./config.json" with { type: "json" }; // Error, named import ~~~~~~~ !!! error TS1544: Named imports from a JSON file into an ECMAScript module are not allowed when 'module' is set to 'Node20'. diff --git a/tests/baselines/reference/nodeModulesJson(module=node20).symbols b/tests/baselines/reference/nodeModulesJson(module=node20).symbols index 42c68c640a2e7..52d983d5b9516 100644 --- a/tests/baselines/reference/nodeModulesJson(module=node20).symbols +++ b/tests/baselines/reference/nodeModulesJson(module=node20).symbols @@ -42,18 +42,24 @@ import { default as config1 } from "./config.json" with { type: "json" }; // Ok import config2 from "./config.json"; // Error in nodenext, no attribute >config2 : Symbol(config2, Decl(main.mts, 6, 6)) +import type config2Type from "./config.json"; // Ok, type-only +>config2Type : Symbol(config2Type, Decl(main.mts, 7, 6)) + +import type config2Type2 from "./config.json" with { type: "json" }; // Error, import attributes not allowed on type-only imports +>config2Type2 : Symbol(config2Type2, Decl(main.mts, 8, 6)) + import { version } from "./config.json" with { type: "json" }; // Error, named import ->version : Symbol(version, Decl(main.mts, 7, 8)) +>version : Symbol(version, Decl(main.mts, 9, 8)) import * as config3 from "./config.json" with { type: "json" }; ->config3 : Symbol(config3, Decl(main.mts, 8, 6)) +>config3 : Symbol(config3, Decl(main.mts, 10, 6)) config3.version; // Error ->config3 : Symbol(config3, Decl(main.mts, 8, 6)) +>config3 : Symbol(config3, Decl(main.mts, 10, 6)) config3.default; // Ok >config3.default : Symbol("/config") ->config3 : Symbol(config3, Decl(main.mts, 8, 6)) +>config3 : Symbol(config3, Decl(main.mts, 10, 6)) >default : Symbol("/config") === /loosey.cts === diff --git a/tests/baselines/reference/nodeModulesJson(module=node20).types b/tests/baselines/reference/nodeModulesJson(module=node20).types index 2c41926af320a..37ac9a196dd4e 100644 --- a/tests/baselines/reference/nodeModulesJson(module=node20).types +++ b/tests/baselines/reference/nodeModulesJson(module=node20).types @@ -64,6 +64,16 @@ import config2 from "./config.json"; // Error in nodenext, no attribute >config2 : { version: number; } > : ^^^^^^^^^^^^^^^^^^^^ +import type config2Type from "./config.json"; // Ok, type-only +>config2Type : any +> : ^^^ + +import type config2Type2 from "./config.json" with { type: "json" }; // Error, import attributes not allowed on type-only imports +>config2Type2 : any +> : ^^^ +>type : any +> : ^^^ + import { version } from "./config.json" with { type: "json" }; // Error, named import >version : number > : ^^^^^^