【问题标题】:Typescript Compiler emit a single declaration file in s package of a Lerna monorepoTypescript 编译器在 Lerna monorepo 的 s 包中发出单个声明文件
【发布时间】:2022-06-26 02:11:09
【问题描述】:

项目结构:

    • 正面
    • 图书馆

库 tsconfig.json

{
  "include": [
    "**/*.js",
    "additional-types.d.ts"
  ],
  "exclude": [
    "**/*-test.js",
    "node_modules"
  ],
  "compilerOptions": {
    "moduleResolution": "node",
    "allowJs": true,
    "declaration": true,
    "emitDeclarationOnly": true,
    "skipLibCheck": true,
    "module": "AMD",
    "outFile": "global.d.ts",
  }
}

然后将生成的文件通过以下方式导入到前端包中:

/// <reference types="@Company/library/global" />

问题是声明路径不对:

declare module "libraries/utils/generateFrontPath/index" {
  // ...
}

代替:

declare module "@Company/library/libraries/utils/generateFrontPath" {
  // ...
}

软件包名称 (@Company/library) 丢失,并且末尾有一个不应出现的 /index

我该如何解决这个问题?

【问题讨论】:

    标签: typescript lerna


    【解决方案1】:

    将一个空的 typescript 文件添加到 typescript scripts 文件夹(您的 tsconfig 文件的位置)以满足 typescript 编译器的要求。

    这对我有用。我遇到了同样的问题。

    source

    问候。

    【讨论】:

      猜你喜欢
      • 2017-02-13
      • 1970-01-01
      • 1970-01-01
      • 2019-10-24
      • 2018-05-12
      • 1970-01-01
      • 1970-01-01
      • 2019-09-17
      • 2017-01-05
      相关资源
      最近更新 更多