Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create type definitions for react-filepond #31362

Merged
merged 2 commits into from
Dec 21, 2018

Conversation

0livare
Copy link
Contributor

@0livare 0livare commented Dec 13, 2018

Please fill in this template.

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Add or edit tests to reflect the change. (Run with npm test.)
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm run lint package-name (or tsc if no tslint.json is present).

Select one of these and delete the others:

If adding a new definition:

  • The package does not already provide its own types, or cannot have its .d.ts files generated via --declaration
  • If this is for an NPM package, match the name. If not, do not conflict with the name of an NPM package.
  • Create it with dts-gen --dt, not by basing it on an existing project.
    • ❓ I'm not sure what this means exactly
  • tslint.json should be present, and tsconfig.json should have noImplicitAny, noImplicitThis, strictNullChecks, and strictFunctionTypes set to true.

@0livare
Copy link
Contributor Author

0livare commented Dec 13, 2018

While running npm run lint react-filepond, I currently get an error that I'm hoping someone might be able to help with:

Error: C:/dev/DefinitelyTyped/types/react-filepond/index.d.ts:22:1
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 first glance it seems simple enough to remove the declare, however, if I remove it, I get a different error, A 'declare' modifier is required for a top level declaration in a .d.ts file. So I'm not sure how to handle this contradiction.

My goal is simply to avoid duplicating the File type within this module. Because File refers to the JS interface, but react-filepond also exports a type called File, I believe that I need to use it locally as one name, I've chosen FilePondFile, but export it as the name that matches that one that the package exports, File.

@typescript-bot typescript-bot added this to Needs Author Attention in Pull Request Status Board Dec 13, 2018
@typescript-bot typescript-bot added New Definition This PR creates a new definition package. The Travis CI build failed labels Dec 13, 2018
@typescript-bot
Copy link
Contributor

typescript-bot commented Dec 13, 2018

@zposten Thank you for submitting this PR!

Because this is a new definition, a DefinitelyTyped maintainer will be reviewing this PR in the next few days once the Travis CI build passes.

In the meantime, if the build fails or a merge conflict occurs, I'll let you know. Have a nice day!

@typescript-bot
Copy link
Contributor

typescript-bot commented Dec 13, 2018

@zposten The Travis CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

@typescript-bot
Copy link
Contributor

@zposten I haven't seen anything from you in a while and this PR currently has problems that prevent it from being merged. The PR will be closed tomorrow if there aren't new commits to fix the issues.

@0livare
Copy link
Contributor Author

0livare commented Dec 19, 2018

@typescript-bot Please don't close this PR. I'm looking for assistance to resolve the one error, as described above.

@0livare
Copy link
Contributor Author

0livare commented Dec 19, 2018

@sandersn Would you be able to help me with the seemingly lose-lose error described above?

@typescript-bot
Copy link
Contributor

typescript-bot commented Dec 19, 2018

@zposten The Travis CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

Zach Posten added 2 commits December 21, 2018 08:47
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?
@sandersn
Copy link
Contributor

@zposten I think tslint (or perhaps our custom rules in dtslint) was in a bad state for a day or so. I think that's why the error went away for the recent run of the build.

@sandersn sandersn merged commit b9f1962 into DefinitelyTyped:master Dec 21, 2018
@kurtgn
Copy link

kurtgn commented Mar 24, 2019

@zposten Hey Zach - I'm now trying to convert my Filepond components from JSX to TSX, and running into type errors. Specifically, my server parameter consists of callbacks which work with original React-Filepond but are not allowed by TS types. Example:

            <FilePond
                ref={(instance) => {this.fpInstance = instance}}
                server={{

                    /**
                     * When user hits revert - the parent component should receive its old URL
                     */
                    revert: (uniqueFileId: string, load: () => void) => {

                        this.props.updateUrl(this.state.oldImageUrl);
                        // Should call the load method when done, no parameters required
                        load();
                    },
                }}
            />

This fails because revert only accepts string | ServerUrl types. Would you mind adding callback types to the server parameters as well?

Thanks!

@0livare
Copy link
Contributor Author

0livare commented May 8, 2019

@kurtgn I see now why you didn't want to make this change yourself, it was kind of a 🐻 lol. But it should be done now, check out #35291!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Definition This PR creates a new definition package.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants