尝试从 TS 迁移 JS 时未创建任何文件



我在 Typescript 中有一个 Next.js 项目。我需要把它放回Javascript。我需要删除所有打字稿标记或将其编译为 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文件,您需要手动执行此操作。

相关内容

最新更新