Skip to content

Commit

Permalink
Update globals.d.ts for File declaration in Typescript (#38165)
Browse files Browse the repository at this point in the history
Summary:
In Webstorm or VSCode when using Typescript the declaration of the class "File" is missing. So both IDEs show "File" as error. With this change it fixes the issue #38061 .

## Changelog:
[GENERAL] [FIXED] Fixed missing File declaration in Typescript global.d.ts
<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: #38165

Test Plan:
I ran
`yarn run test-typescript`
with no error

After that i initialized a new react-native project and installed the react-native library with my local changes of global.d.ts. Webstorm and VSCode now find the declaration of "File" and don't show "File" as error and suggest the right parameters.

Reviewed By: rshest

Differential Revision: D47209461

Pulled By: cortinico

fbshipit-source-id: 0884dfe786ea3a5070aa0a487a8e74463c8f1a0f
  • Loading branch information
trashcoder authored and facebook-github-bot committed Jul 4, 2023
1 parent f2d93a3 commit 9c0441b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/react-native/types/modules/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@ declare var Blob: {
new (blobParts?: Array<Blob | string>, options?: BlobOptions): Blob;
};

interface File extends Blob {
name: string;
lastModified: number;
}

declare var File: {
prototype: File;
new (
fileParts?: Array<Blob | string>,
name?: string,
options?: BlobOptions,
): File;
};

type FormDataValue =
| string
| {name?: string | undefined; type?: string | undefined; uri: string};
Expand Down

0 comments on commit 9c0441b

Please sign in to comment.