Skip to content

Commit

Permalink
Update missed baseline
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbranch committed Dec 19, 2024
1 parent 2fb1117 commit 590892b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) ====
Expand Down Expand Up @@ -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
~~~~~~~~~~~~~~~
Expand All @@ -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'.
Expand Down
14 changes: 10 additions & 4 deletions tests/baselines/reference/nodeModulesJson(module=node20).symbols
Original file line number Diff line number Diff line change
Expand Up @@ -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 ===
Expand Down
10 changes: 10 additions & 0 deletions tests/baselines/reference/nodeModulesJson(module=node20).types
Original file line number Diff line number Diff line change
Expand Up @@ -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
> : ^^^^^^
Expand Down

0 comments on commit 590892b

Please sign in to comment.