举个例子:
import { RouterProps } from 'react-router'
上面的 react-router
实际指向了本地的 src/components/react-router
,并且在 src/components/react-router/index.tsx
文件有:
export interface RouterProps {
action?: Action
children?: React.ReactNode
location: Location
navigator: Navigator
static?: boolean
}
此时TS会找不到 react-router
模块,这我是能理解的,但有什么解决办法吗?
我通过tsconfig中配置paths参数也没用啊!
{
"baseUrl": ".",
"paths": {
"react-router": ["src/components/react-router"]
}
}
难道要手写一个声明文件,比如这样?
declare module 'react-router' {
export {...}
}