如何正确覆盖打字稿定义

时间:2020-10-28 10:03:50

标签: node.js typescript react-native caching

我创建了一个定义文件以覆盖库中的一个,但是库中的一个似乎具有更高的优先级

.
├── android
├── app.json
├── babel.config.js
├── index.ts
├── ios
├── metro.config.js
├── node_modules
├── package.json
├── src
│   ├── customTypes
│   │   └── react-native-track-player
│   │   |    └── index.d.ts
├── __tests__
├── tsconfig.json
├── tsc.txt
├── yarn-error.log
└── yarn.lock

tsconfig:

{
  "compilerOptions": {
    "allowJs": false,
    "allowSyntheticDefaultImports": true,
    "experimentalDecorators": true,
    "jsx": "react-native",
    "module": "es2015",
    "moduleResolution": "node",
    "noImplicitAny": false,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noUnusedLocals": true,
    "sourceMap": true,
    "target": "esnext",
    "lib": ["esnext"],
    "skipLibCheck": true,
    "strict": true,
    "typeRoots": [
      "src/customTypings",
      "node_modules/@types"
    ]
  },
  "exclude": ["node_modules"],
  "include": [
    "index.ts"
  ]
}

使用traceResolution时,编译器从缓存中解析模块,这不利于调试:

======== Resolving module 'react-native-track-player' from '/projects/TwoUApp/src/player/ProgressBarMusic.tsx'. ========
Resolution for module 'react-native-track-player' was found in cache from location '/projects/TwoUApp/src/player'.
======== Module name 'react-native-track-player' was successfully resolved to '/projects/TwoUApp/node_modules/react-native-track-player/index.d.ts' with Package ID 'react-native-track-player/index.d.ts@1.2.3'. ========

如何覆盖类型定义文件或至少使缓存无效以进行调试?

感谢您的帮助。

0 个答案:

没有答案