尝试从 TS 迁移 JS 时没有创建文件

No Files Created When Trying To Migrate JS from TS

我在 Typescript 中有一个 Next.js 项目。我需要把它恢复到 Javascript。我需要删除所有 Typescript 标记或将其编译为 ES2018 JS。

我尝试使用此配置在项目根目录下 运行 tsc 命令:

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": ".",
    "paths": { "*": ["types/*"] },
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "jsx": "preserve",
    "lib": ["dom", "es2018"],
    "module": "esnext",
    "moduleResolution": "node",
    "noEmit": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "preserveConstEnums": true,
    "removeComments": false,
    "skipLibCheck": true,
    "sourceMap": true,
    "strict": false,
    "target": "esnext",
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "strictPropertyInitialization": false
  },
  "include": [
    "app/**/*"
  ],
  "exclude": [".next", "server/**/*.*"]
}

什么都没发生。

我希望将 .ts 文件替换为 .js 文件。如果不可能,我需要 .ts 文件旁边的 .js 文件。我可以手动删除.ts文件。

您的配置中有 "noEmit": true,这导致编译器不发出任何 .js 文件。至于删除 .ts 文件,您需要手动执行。