【问题标题】:No Files Created When Trying To Migrate JS from TS尝试从 TS 迁移 JS 时未创建文件
【发布时间】:2019-08-04 05:06:19
【问题描述】:

我在 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
  • 问题解决了。如果你用回答按钮回答问题,我会用绿色勾号标记。

标签: javascript typescript next.js


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2021-11-05
    • 1970-01-01
    • 2017-05-26
    • 2020-11-16
    • 1970-01-01
    • 2021-04-15
    • 2021-06-23
    • 1970-01-01
    • 2018-10-26
    相关资源
    最近更新 更多