From 9636dcd8105efa5a582d431160ef58d6e7bcbfe3 Mon Sep 17 00:00:00 2001 From: Marcel Poisot <198049+mpoisot@users.noreply.github.com> Date: Mon, 19 Oct 2020 14:47:46 -0500 Subject: [PATCH] fix #76 : Types findable when used as npm lib --- package.json | 1 + src/index.d.ts | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 09af152..7d1718e 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "filestack-react", "version": "3.2.0", "main": "dist/filestack-react.js", + "types": "src/index.d.ts", "description": "React component wrapper for filestack-js", "scripts": { "test": "jest --no-cache --coverage", diff --git a/src/index.d.ts b/src/index.d.ts index d56b895..cd5754d 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -1,24 +1,28 @@ import React from 'react'; -import { PickerFileMetadata, ClientOptions } from 'filestack-js'; +import type { PickerFileMetadata, ClientOptions, PickerResponse } from 'filestack-js'; type FilestackAction = 'transform' | 'retrieve' | 'metadata' | 'storeUrl' | 'upload' | 'multiupload' | 'remove' | 'pick' | 'removeMetadata' | 'preview' | 'logout'; type ComponentDisplayModeType = 'button' | 'link' | 'immediate'; interface Props { - apikey: string; + apikey?: string; action?: FilestackAction; componentDisplayMode?: { type?: ComponentDisplayModeType; customText?: string; customClass?: string; }; - onSuccess?: (result: PickerFileMetadata[]) => void; + onSuccess?: (result: PickerResponse) => void; onError?: (error: PickerFileMetadata[]) => void; clientOptions?: ClientOptions; file?: File; source?: string; - customRender?: React.ComponentType; + customRender?: React.ComponentType<{ onPick: (arg: unknown) => void }>; + + // Maps to pickerOptions in filestack-js + // https://filestack.github.io/filestack-js/interfaces/pickeroptions.html + actionOptions?: Record; } declare class ReactFilestack extends React.Component {}