DefinitelyTyped/types/react-filepond/react-filepond-tests.tsx
Zach Posten 42117f4180 Create react-filepond typescript definition test
It currently reports the error:

    ERROR: 22:1  strict-export-declare-modifiers  'declare' keyword is redundant here. See: https://github.com/Microsoft/dtslint/blob/master/docs/strict-export-declare-modifiers.md

        at C:\dev\DefinitelyTyped\node_modules\dtslint\bin\index.js:158:19
        at Generator.next (<anonymous>)
        at fulfilled (C:\dev\DefinitelyTyped\node_modules\dtslint\bin\index.js:5:58)
        at <anonymous>

But if I remove the 'declare' keyword on line 22, I get the error

    A 'declare' modifier is required for a top level declaration in a .d.ts file.

I want to use a class under one name in this file and another name
externally, what do I do here?
2018-12-21 08:47:20 -06:00

52 lines
1.5 KiB
TypeScript

import * as React from 'react';
import * as filepond from 'react-filepond';
interface AppState {
filenames: string[];
}
// Example mostly taken from:
// https://github.com/pqina/react-filepond
class App extends React.Component<{}, AppState> {
private pond: filepond.FilePond | null;
constructor(props: {}) {
super(props);
this.state = {
// Set initial files
filenames: ['index.html']
};
}
private handleInit() {
console.log('FilePond instance has initialized', this.pond);
}
render() {
return (
<div className='App'>
{/* Pass FilePond properties as attributes */}
<filepond.FilePond
ref={ref => this.pond = ref}
allowMultiple={true}
maxFiles={3}
server='/api'
oninit={() => this.handleInit() }
onupdatefiles={(fileItems) => {
// Set current file objects to this.state
this.setState({
filenames: fileItems.map(fileItem => fileItem.file.name)
});
}}
>
{/* Update current files */}
{this.state.filenames.map(file => (
<filepond.File key={file} src={file} origin='local' />
))}
</filepond.FilePond>
</div>
);
}
}