这个要怎么在TypeScript里用
Closed this issue · 3 comments
VALLIS-NERIA commented
Steps to reproduce the behavior:
import * as React from "react";
import ImgsViewer from "react-images-viewer";
export interface IImageViewProps {
imgs: string[];
}
export class ImageView extends React.Component<IImageViewProps, {}> {
render() {
const imgs = this.props.imgs.map((s) => ({ src: s }));
return <ImgsViewer
imgs={imgs}
currImg={ImgsViewer.state.currImg}
isOpen={this.state.viewerIsOpen}
onClickPrev={this.gotoPrevious}
onClickNext={this.gotoNext}
onClose={this.closeViewer} />;
}
}
Expected behavior:
Actual behavior:
ERROR in D:\*******\ImageView.tsx
./*******/ImageView.tsx
[tsl] ERROR in D:\*******\ImageView.tsx(14,39)
TS2339: Property 'viewerIsOpen' does not exist on type 'Readonly<{}>'.
ERROR in D:\*******\ImageView.tsx
./*******/ImageView.tsx
[tsl] ERROR in D:\*******\ImageView.tsx(14,57)
TS2304: Cannot find name 'a'.
ERROR in D:\*******\ImageView.tsx
./*******/ImageView.tsx
[tsl] ERROR in D:\*******\ImageView.tsx(15,38)
TS2339: Property 'gotoPrevious' does not exist on type 'ImageView'.
ERROR in D:\*******\ImageView.tsx
./*******/ImageView.tsx
[tsl] ERROR in D:\*******\ImageView.tsx(16,38)
TS2339: Property 'gotoNext' does not exist on type 'ImageView'.
ERROR in D:\*******\ImageView.tsx
./*******/ImageView.tsx
[tsl] ERROR in D:\*******\ImageView.tsx(17,34)
TS2339: Property 'closeViewer' does not exist on type 'ImageView'.
guonanci commented
I will quickly support TypeScript, thanks for your suggestion.
personaljs commented
Hello) Looking forward to.
guonanci commented
Try add declare module 'react-images-viewer'
in src/typings.d.ts ?