Skip to content

Commit 4b908d6

Browse files
Merge pull request #16 from BeeMyDesk/typescript-declaration
Add TypeScript declaration
2 parents b7d13ee + 32c5f48 commit 4b908d6

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

index.d.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
declare module 'react-cloudimage-responsive' {
2+
3+
type Params = string | Record<string, string>;
4+
5+
export interface CloudimageProviderConfig {
6+
token: string;
7+
baseURL?: string;
8+
doNotReplaceURL?: boolean;
9+
lazyLoading?: boolean;
10+
lazyLoadOffset?: number;
11+
params?: Params;
12+
placeholderBackground?: string;
13+
lowQualityPreview?: {
14+
minImgWidth: number;
15+
}
16+
presets?: Record<string, string>;
17+
limitFactor?: number;
18+
devicePixelRatioList?: number[];
19+
delay?: number;
20+
}
21+
22+
class CloudimageProvider extends React.Component<{ config: CloudimageProviderConfig }> { }
23+
24+
interface ImgProps {
25+
src: string;
26+
width?: string;
27+
height?: string;
28+
params?: Params;
29+
sizes?: Record<string, any>;
30+
ratio?: number;
31+
lazyLoading?: boolean;
32+
lazyLoadConfig?: Record<string, any>;
33+
}
34+
35+
class BackgroundImg extends React.Component<ImgProps & React.ComponentProps<'img'>> { }
36+
37+
export default class Img extends React.Component<ImgProps & React.ComponentProps<'img'>> { }
38+
39+
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"crop",
3232
"resize"
3333
],
34+
"types": "./index.d.ts",
3435
"scripts": {
3536
"start-demo": "webpack-dev-server --mode development --config webpack-demo.config.js",
3637
"dist": "rm -rf dist && babel src -d dist --copy-files",

0 commit comments

Comments
 (0)