1

也许这是一个tsconfig问题,但我不知道什么是正确的。我使用模板app-template-react-typescript,我发现当我使用src/page它时它可以工作。

这是我的 tsconfig

{
  "include": ["src", "types"],
  "exclude": ["node_modules"],
  "extends": "@snowpack/app-scripts-react/tsconfig.base.json",
  "compilerOptions": {
    // You can't currently define paths in your 'extends' config,
    // so we have to set 'baseUrl' & 'paths' here.
    // Don't change these unless you know what you're doing.
    // See: https://github.com/microsoft/TypeScript/issues/25430
    "experimentalDecorators": true,
    "baseUrl": "./",
    "paths": {
      "stylesheet/*": ["src/asset/stylesheet/*"],
      "image/*": ["src/asset/image/*"],
      "shared/*": ["src/shared/*"],
      "layout/*": ["src/layout/*"],
      "component/*": ["src/component/*"],
      "page/*": ["src/page/*"],
      "utils/*": ["src/utils/*"],
      "constant/*": ["src/constant/*"],
      "store/*": ["src/store/*"],
      "src/*":["src/*"]
    }
    // Feel free to add/edit new config options below:
    // ...
  }
}
4

1 回答 1

2

已经得到 snowpack 团队的回答,他们说:我们目前不支持 TSConfig 路径,但我们有一个 PR 要添加:pikapkg/snowpack#432 在那之前,您需要通过“src/page/Account”导入让 Snowpack 正确识别它

所以我会关闭这个问题并暂时使用'src/page/Account'来解决我的问题

于 2020-06-19T03:39:01.827 回答