Skip to content

simple support to the Partial<T> annotation#35960

Closed
cipolleschi wants to merge 1 commit into
facebook:mainfrom
cipolleschi:export-D42640880
Closed

simple support to the Partial<T> annotation#35960
cipolleschi wants to merge 1 commit into
facebook:mainfrom
cipolleschi:export-D42640880

Conversation

@cipolleschi
Copy link
Copy Markdown
Contributor

Summary:
This feature allows using $Partial<Obj> in flow and Partial<Obj> in TypeScript based on the spec mentioned here: https://flow.org/en/docs/types/utilities/#toc-partial.

We currently only allow passing an Obj to Partial so

export type SomeObj = {
  a: string,
  b?: boolean,
};

export type PartialSomeObj = Partial<SomeObj>;

should work.
and also-

export type PartialSomeObj = Partial<{
  a: string,
  b?: boolean,
}>;

But not

export type PartialSomeObj = Partial<Partial<{
  a: string,
  b?: boolean,
}>>;

This can be improved in the future by a recursive unwrapping of the value inside the Partial annotation.

Changelog:
[General] [Added] - Allow the use of "Partial" in Turbo Module specs.

Reviewed By: christophpurrer, cipolleschi

Differential Revision: D42640880

Summary:
This feature allows using `$Partial<Obj>` in flow and `Partial<Obj>` in TypeScript based on the spec mentioned here: https://flow.org/en/docs/types/utilities/#toc-partial.

We currently only allow passing an Obj to Partial so
```
export type SomeObj = {
  a: string,
  b?: boolean,
};

export type PartialSomeObj = Partial<SomeObj>;
```
should work.
and also-
```
export type PartialSomeObj = Partial<{
  a: string,
  b?: boolean,
}>;
```
But not
```
export type PartialSomeObj = Partial<Partial<{
  a: string,
  b?: boolean,
}>>;
```
This can be improved in the future by a recursive unwrapping of the value inside the `Partial` annotation.

Changelog:
[General] [Added] -  Allow the use of "Partial<T>" in Turbo Module specs.

Reviewed By: christophpurrer, cipolleschi

Differential Revision: D42640880

fbshipit-source-id: 380cecceeef501c6021e61152efb238b98138e7e
@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels Jan 25, 2023
@react-native-bot react-native-bot added the Type: Enhancement A new feature or enhancement of an existing feature. label Jan 25, 2023
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D42640880

@analysis-bot
Copy link
Copy Markdown

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,462,911 +0
android hermes armeabi-v7a 7,783,489 +0
android hermes x86 8,936,172 +0
android hermes x86_64 8,794,233 +0
android jsc arm64-v8a 9,648,873 +0
android jsc armeabi-v7a 8,383,370 +0
android jsc x86 9,711,124 +0
android jsc x86_64 10,188,137 +0

Base commit: 2bfb53c
Branch: main

vzaidman added a commit to vzaidman/react-native that referenced this pull request Jan 25, 2023
Summary:
Pull Request resolved: facebook#35961

Pull Request resolved: facebook#35960

This fixes facebook#35864

This feature allows using `$Partial<Obj>` in flow and `Partial<Obj>` in TypeScript based on the spec mentioned here: https://flow.org/en/docs/types/utilities/#toc-partial.

We currently only allow passing an Obj to Partial so
```
export type SomeObj = {
  a: string,
  b?: boolean,
};

export type PartialSomeObj = Partial<SomeObj>;
```
should work.
and also-
```
export type PartialSomeObj = Partial<{
  a: string,
  b?: boolean,
}>;
```
But not
```
export type PartialSomeObj = Partial<Partial<{
  a: string,
  b?: boolean,
}>>;
```
This can be improved in the future by a recursive unwrapping of the value inside the `Partial` annotation.

Changelog:
[General] [Added] -  Allow the use of "Partial<T>" in Turbo Module specs.

Reviewed By: christophpurrer, cipolleschi

Differential Revision: D42640880

fbshipit-source-id: eba1ef64dd3a0c95d267a04f9e56cb8641ccbbf2
vzaidman added a commit to vzaidman/react-native that referenced this pull request Jan 26, 2023
Summary:
Pull Request resolved: facebook#35961

Pull Request resolved: facebook#35960

This fixes facebook#35864

This feature allows using `$Partial<Obj>` in flow and `Partial<Obj>` in TypeScript based on the spec mentioned here: https://flow.org/en/docs/types/utilities/#toc-partial.

We currently only allow passing an Obj to Partial so
```
export type SomeObj = {
  a: string,
  b?: boolean,
};

export type PartialSomeObj = Partial<SomeObj>;
```
should work.
and also-
```
export type PartialSomeObj = Partial<{
  a: string,
  b?: boolean,
}>;
```
But not
```
export type PartialSomeObj = Partial<Partial<{
  a: string,
  b?: boolean,
}>>;
```
This can be improved in the future by a recursive unwrapping of the value inside the `Partial` annotation.

Changelog:
[General] [Added] -  Allow the use of "Partial<T>" in Turbo Module specs.

Reviewed By: christophpurrer, cipolleschi

Differential Revision: D42640880

fbshipit-source-id: e0b863c6863c312cc7b77438b326bfa5ed845d33
facebook-github-bot pushed a commit that referenced this pull request Jan 26, 2023
Summary:
Pull Request resolved: #35961

Pull Request resolved: #35960

This fixes #35864

This feature allows using `$Partial<Obj>` in flow and `Partial<Obj>` in TypeScript based on the spec mentioned here: https://flow.org/en/docs/types/utilities/#toc-partial.

We currently only allow passing an Obj to Partial so
```
export type SomeObj = {
  a: string,
  b?: boolean,
};

export type PartialSomeObj = Partial<SomeObj>;
```
should work.
and also-
```
export type PartialSomeObj = Partial<{
  a: string,
  b?: boolean,
}>;
```
But not
```
export type PartialSomeObj = Partial<Partial<{
  a: string,
  b?: boolean,
}>>;
```
This can be improved in the future by a recursive unwrapping of the value inside the `Partial` annotation.

Changelog:
[General] [Added] -  Allow the use of "Partial<T>" in Turbo Module specs.

Reviewed By: christophpurrer, cipolleschi

Differential Revision: D42640880

fbshipit-source-id: 03a3fccc38ccfc7a5440fe11893beb68e77753f3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported p: Facebook Partner: Facebook Partner Type: Enhancement A new feature or enhancement of an existing feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants