【发布时间】:2022-12-14 10:42:33
【问题描述】:
我有以下代码:
console.log(fs.readdirSync(__dirname));
其中打印出以下内容:
[ 'index.js', 'objective.js', 'quest.js', 'user_objective.js' ]
但是,我的文件目录设置如下:
为什么它会认为 .ts 扩展名是 .js?
tsconfig.json文件
{
"compilerOptions": {
"target": "es6",
"module": "commonjs" /* Specify what module code is generated. */,
"rootDir": "./src" /* Specify the root folder within your source files. */,
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
/* Type Checking */
"strict": true /* Enable all strict type-checking options. */,
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"exclude": ["node_modules"]
}
【问题讨论】:
标签: typescript node.js-fs