Consult `package.json` contents when creating `tsconfig.json` under `tsc --init` to determine better defaults
DetachHead opened this issue ยท 2 comments
DetachHead commented
Bug Report
๐ Search Terms
tsc init module commonjs
๐ Version & Regression Information
4.9.0-dev.20221017
โฏ Playground Link
n/a
๐ป Code
package.json
{
"name": "asdf",
"version": "1.0.0",
"description": "",
"author": "",
"license": "ISC",
"type": "module",
"devDependencies": {
"typescript": "^4.9.0-dev.20221017"
}
}๐ Actual behavior
> npx tsc --init
Created a new tsconfig.json with:
TS
target: es2016
module: commonjs
strict: true
esModuleInterop: true
skipLibCheck: true
forceConsistentCasingInFileNames: true
You can learn more at https://aka.ms/tsconfig
๐ Expected behavior
it should check the package.json to determine that module should be nodenext or something
DetachHead commented
moduleResolution should also default to nodenext or node16 when "type": "module" is in package.json.
also, maybe it would be better to not even include these options when running tsc --init and instead just infer the default values from package.json when they are not present in tsconfig.json