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

Fix boolean type when converting to js #702

Merged
merged 1 commit into from
Nov 23, 2020
Merged

Conversation

xilin
Copy link
Contributor

@xilin xilin commented Nov 20, 2020

In iOS, @(YES) is converted as [NSNumber numberWithBool:], generating a __NSCFBoolean instance.
While @(1 == 1) is converted as [NSNumber numberWithInt:], generating a __NSCFNumber instance.
And RN converter treat this differently. The first one becomes bool value, and the second one becomes numberic value.

This PR makes sure the return value from native side will match type declaration in ts file lib/src/interfaces/NotificationPermissions.ts:

export interface NotificationPermissions {
  badge: boolean;
  alert: boolean;
  sound: boolean;
}

In iOS, `@(YES)` is converted as `[NSNumber numberWithBool:]`, generating a `__NSCFBoolean` instance.
While `@(1 == 1)` is converted as `[NSNumber numberWithInt:]`, generating a `__NSCFNumber` instance.
And RN converter treat this differently. The first one becomes bool value, and the second one becomes numberic value.
@xilin xilin requested a review from yogevbd as a code owner November 20, 2020 06:55
@xilin xilin changed the title fix boolean type when converting to js Fix boolean type when converting to js Nov 20, 2020
@yogevbd yogevbd merged commit 5e319ca into wix:master Nov 23, 2020
mburmistrov pushed a commit to mburmistrov/react-native-notifications that referenced this pull request Jan 10, 2021
In iOS, `@(YES)` is converted as `[NSNumber numberWithBool:]`, generating a `__NSCFBoolean` instance.
While `@(1 == 1)` is converted as `[NSNumber numberWithInt:]`, generating a `__NSCFNumber` instance.
And RN converter treat this differently. The first one becomes bool value, and the second one becomes numberic value.

This PR makes sure the return value from native side will match type declaration in ts file `lib/src/interfaces/NotificationPermissions.ts`:
```
export interface NotificationPermissions {
  badge: boolean;
  alert: boolean;
  sound: boolean;
}
```

Co-authored-by: Xi Lin <lxi@tesla.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants