Under module: nodenext, which of these imports does TypeScript reject, and why write .js for a .ts file?
The project is compiled by tsc and run by Node.js. Its package.json has "type": "module", and its tsconfig sets module: "nodenext". Name every error TypeScript reports in src/main.ts.
{ "name": "shop-server", "type": "module" }
export function formatPrice(cents: number) {
return "$" + (cents / 100).toFixed(2);
}
export const currency = "USD";
import { formatPrice } from "./format";import { formatPrice as format } from "./format.js";import { formatPrice as price } from "./format.ts";import { currency } from "./config";import { currency as code } from "./config/index.js"; console.log(format(1999), code);Work it out first: the compiler shows every error and type.
The answer
Work out every error TypeScript reports and every type it shows, line by line. Then check.
Checking your sign-in…