microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
101.21k stars 12.51k forks source link

tsc does not compiling 'with' statement ie ```import... from file.json with {type:'json'}``` #60499

Closed chidam02 closed 1 week ago

chidam02 commented 1 week ago

🔎 Search Terms

with assertion statement

🕗 Version & Regression Information

Typescript version : 4.7

💻 Code

import schedulePayloadSchema from "../validators/jobScheduleSchema.json" with { type: "json" };

🙁 Actual behavior

after compiling with tsc filename.ts

output:

import schedulePayloadSchema from "../validators/jobScheduleSchema.json";
with ({ type: "json" })
    ;

🙂 Expected behavior

expected:

import schedulePayloadSchema from "../validators/jobScheduleSchema.json" with { type: "json" } ;

Additional information about the issue

typescript compiler does not compiling import assertion statement written with 'with' statement but its working properly with 'assert' keyword which is deprecated in node latest version 22

MartinJohns commented 1 week ago

Typescript version : 4.7

This version is over two years old.

In the current version you will get the TS2823 error.

chidam02 commented 1 week ago
chidam02 commented 1 week ago

I installed typescript v 5.6.3 its working now.