Skip to content

Commit

Permalink
TypeScript tweaks and fixes
Browse files Browse the repository at this point in the history
- fix: React was used but not imported
- fix: S3Upload extends onFinishS3Put rather than onFinish
- tweak: Add typescript & types/react dev dependencies
- tweak: Explicitly set "types" in package.json
  • Loading branch information
dobesv committed Jan 30, 2020
1 parent ef4e823 commit b7bedf4
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 13 deletions.
31 changes: 28 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,41 @@ declare module 'react-s3-uploader' {
[key: string]: any;
}

class ReactS3Uploader extends React.Component<ReactS3UploaderProps, any> { }
class ReactS3Uploader extends Component<ReactS3UploaderProps, unknown> { }

export default ReactS3Uploader;
}

declare module 'react-s3-uploader/s3upload' {
import { ReactS3UploaderProps } from 'react-s3-uploader';
import { ReactS3UploaderProps, S3Response } from 'react-s3-uploader';

export interface S3UploadOptions extends Pick<
ReactS3UploaderProps,
| 'contentDisposition'
| 'getSignedUrl'
| 'onProgress'
| 'onError'
| 'onSignedUrl'
| 'preprocess'
| 's3path'
| 'server'
| 'signingUrl'
| 'signingUrlHeaders'
| 'signingUrlMethod'
| 'signingUrlQueryParams'
| 'signingUrlWithCredentials'
| 'uploadRequestHeaders'> {
fileElement?: HTMLInputElement | null;
files?: HTMLInputElement['files'] | null;
onFinishS3Put?: ReactS3UploaderProps['onFinish'];
successResponses?: number[];
scrubFilename?: (filename: string) => string;
}

class S3Upload {
constructor(options: ReactS3UploaderProps)
constructor(options: S3UploadOptions)
abortUpload(): void;
uploadToS3(file: File, signResult: S3Response): void;
}

export default S3Upload;
Expand Down
107 changes: 97 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"type": "git",
"url": "[email protected]:odysseyscience/react-s3-uploader.git"
},
"types": "index.d.ts",
"keywords": [
"react",
"upload",
Expand All @@ -24,10 +25,12 @@
},
"homepage": "https://github.com/odysseyscience/react-s3-uploader",
"dependencies": {
"@types/react": "*",
"aws-sdk": "2.x",
"create-react-class": "^15.5.2",
"object-assign": "^2.0.0",
"prop-types": "^15.5.8",
"typescript": "^3.7.5",
"uuid": "^3.1.0"
}
}

0 comments on commit b7bedf4

Please sign in to comment.