typescript - 带有 typescript 的 Yarn 工作区 SyntaxError : Unexpected token {

标签 typescript yarn-workspaces

我有带有 typescript 的应用程序,其结构如下:

/myapplication
  /packages
    /domain  <- @my-application/domain
    /graphql <- @my-application/graphql

@my-application/graphql 模块依赖于 @my-application/domain,当应用程序启动时,我收到此错误:

(node:42497) UnhandledPromiseRejectionWarning: /Users/pavel/Dev/catsapp/packages/domain/index.ts:1
(function (exports, require, module, __filename, __dirname) { import { CatCreateInput, Cat } from '@prisma/photon';
                                                                     ^

SyntaxError: Unexpected token {
    at new Script (vm.js:85:7)
    at createScript (vm.js:266:10)
    at Object.runInThisContext (vm.js:314:10)
    at Module._compile (internal/modules/cjs/loader.js:698:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:749:10)
    at Module.load (internal/modules/cjs/loader.js:630:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
    at Function.Module._load (internal/modules/cjs/loader.js:562:3)
    at Module.require (internal/modules/cjs/loader.js:667:17)
    at require (internal/modules/cjs/helpers.js:20:18)

我的tsconfig在@my-application/graphql中。 为什么 typescript 不转译 @my-application/domain 模块?

更新: 我在 Github 上添加了存储库示例

最佳答案

您需要将所有包包含到主 tsconfig.json 中:

"include": [
    "packages"
],

关于typescript - 带有 typescript 的 Yarn 工作区 SyntaxError : Unexpected token {,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59758809/

相关文章:

javascript - typescript 错误 : Type 'string' is not assignable to type for Typography

javascript - 类型 'number' 与类型 'FindOneOptions<Client>' 没有共同属性

Angular 5 import Google gapi witn @types/gapi.auth2 不工作

javascript - 如何防止对象/数组突变?

lerna - 如何在 monorepo 中仅打包 dist 文件夹

docker - 如何在我的 docker 构建中包含本地包依赖项?

yarnpkg - 为什么以及何时 yarn 决定不在工作区中提升包裹?

html - 添加 formControlName 会使默认值在我的 Angular 表单下拉列表中消失

node.js - Yarn workspaces——包别名

node.js - Yarn 2 工作区未安装依赖项