使用 typescript 3.0.1 项目引用时无法找到类型定义

Unable to find type definitions when using typescript 3.0.1 project refferences

我最初有以下项目结构 (monorepo)

_app/
_firebase/
_types/
tsconfig.json

这里,根级别的 tsconfig 用于 _app_firebase typescript 项目。 _types 是一个包含 models.tsstore.ts 等文件的文件夹...这些文件只是定义了不同的接口。

我之前可以在 _app_firebase 项目中使用这些接口,而无需导入/导出任何内容,没有任何问题。

我更改为使用 typescripts v3 项目引用,所以我的应用程序结构现在看起来像这样

_app/
  tsconfig.json
_firebase/
  tsconfig.json
_types/
tsconfig.json

根级别 tsconfig.json 具有以下内容

{
  "compilerOptions": {
    "composite": true
  },
  "references": [
    { 
      "path": "_app" 
    }
  ]
}

其他配置只有简单的选项,如 outDirtargetlib 等...

现在,如果我在 _app_firebase 中的任何位置使用 _types 文件夹中的接口,我会收到类似

的错误

[ts] Cannot find name 'IInventoryModel'.

有什么方法可以保留以前的功能,使我能够在没有显式导出/导入的情况下使用这些接口,同时仍然利用新项目引用功能?

编辑: 这里是 _app

的 tsconfig 示例
{
  "compilerOptions": {
    "target": "es2016",
    "module": "commonjs",
    "lib": ["es2016"],
    "jsx": "react",
    "outDir": "./dist",
    "strict": true,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
  }
}

编辑 _types 文件夹中的 2 接口是这样声明的,即 _types/models.ts

interface ICharacterModel { /* ... */ }

interface IInventoryModel { /* ... */ }

// etc...

首先,_types 需要自己的 tsconfig.json_app 需要引用它。然后,基于the documentation,看起来神奇的一步是在_types上设置一个outFile。以下配置对我有用:

// _app/tsconfig.json
{
  "compilerOptions": {
    "composite": true,
    "target": "es2016",
    "module": "commonjs",
    "lib": ["es2016"],
    "jsx": "react",
    "outDir": "./dist",
    "strict": true,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
  },
  "references": [
    {
      "path": "../_types"
    }
  ]
}

// _types/tsconfig.json
{
    "compilerOptions": {
        "composite": true,
        "outFile": "types.js"
    }
}