problem description
our project, some people use TS, some people only use JS, so public modules are written in JS, we need to add TS type declaration file d.ts, but after the declaration I found that it did not take effect, do not know how to relate?
the environmental background of the problems and what methods you have tried
I have also tried to write a type declaration file for the third-party JS library in the project, which is valid, but it does not take effect when writing the JS library for myself. I wonder if it is because the former is global and the latter requires import relative path import?
related codes
write a type declaration to a public JS file of BasePage, which is a piece of code in the type declaration file:
declare class BasePage<P extends BasePageProps> extends IBUPage<P> {
navigation: object;
app: object;
pageKey: string;
pageConfig: object;
constructor(props: P, ext: object): void;
getPageId(): number;
_getRoute(targetPageName: string): businessPage[];
_isRouteExist(targetPageName: string): boolean;
_popToPage(targetPageName: string): void;
diyBackPage(targetPageName: string): void;
diyForwardPage(targetPageName: string, params: object, options: object): void;
backToDefaultPage(): void;
jumpToDiyIndex(): void;
}
this is the call:
import BasePage from "../../frame/BasePage"
export default class HotelList extends BasePage<IProps> {
constructor(props) {
super(props);
console.log(this.props.hotelList)
}
renderPageContent() {
return (
<ViewPort>
<View>
{
_.map([1, 2, 3], (item) => {
return <Text key={item}>hello, world</Text>
})
}
</View>
</ViewPort>
)
}
}
but the BasePage here still can"t find the type.
excuse me, is there anything particular about the location of d.ts files and basePage.js files? Or is there something wrong with my declare? Or do you need to configure it in tsconfig?