rudderlabs / rudder-sdk-react-native

Repository for RudderStack's React Native SDK - to track your event data via RudderStack.
https://www.rudderstack.com
Other
17 stars 18 forks source link

Typescript support: allow for building with strictNullChecks #8

Closed twom closed 4 years ago

twom commented 4 years ago

The React Native module gives Typescript errors when attempting to use strictNullChecks (which is part of the strict profile). By default typescript projects are initialized with stritNullChecks: true. It would be great if this module would be buildable with strict mode.

These are the errors

Maybe: using Object | null = null ?

node_modules/@rudderstack/rudder-sdk-react-native/src/RudderClient.ts:82:3 - error TS2322: Type 'null' is not assignable to type 'Object'.

82   properties: Object = null,
     ~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@rudderstack/rudder-sdk-react-native/src/RudderClient.ts:83:3 - error TS2322: Type 'null' is not assignable to type 'Object'.

83   options: Object = null
     ~~~~~~~~~~~~~~~~~~~~~~

node_modules/@rudderstack/rudder-sdk-react-native/src/RudderClient.ts:99:3 - error TS2322: Type 'null' is not assignable to type 'Object'.

99   properties: Object = null,
     ~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@rudderstack/rudder-sdk-react-native/src/RudderClient.ts:100:3 - error TS2322: Type 'null' is not assignable to type 'Object'.

100   options: Object = null
      ~~~~~~~~~~~~~~~~~~~~~~

node_modules/@rudderstack/rudder-sdk-react-native/src/RudderClient.ts:118:3 - error TS2322: Type 'null' is not assignable to type 'Object'.

118   traitsOrOptions: Object = null,
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@rudderstack/rudder-sdk-react-native/src/RudderClient.ts:119:3 - error TS2322: Type 'null' is not assignable to type 'Object'.

119   options: Object = null
      ~~~~~~~~~~~~~~~~~~~~~~

node_modules/@rudderstack/rudder-sdk-react-native/src/RudderClient.ts:147:39 - error TS2322: Type 'null' is not assignable to type 'Object'.

147 async function group(groupId: string, traits: Object = null) {
                                          ~~~~~~~~~~~~~~~~~~~~~
dhawal1248 commented 4 years ago

Hey @twom , we have enabled building in TS strict mode. Feel free to check #9