React-native-paper: Ability to extend Theme TS type.

Created on 14 Apr 2020  路  4Comments  路  Source: callstack/react-native-paper

Describe the feature

useTheme hook should return the correct type that contains user-defined properties.

Motivation

The type returned by useTheme hook is not customizable in any way right now. It always returns a type containing only properties defined by the library. It would be handy if user-defined properties are also properly typed.

@satya164 Would you like to explain how this could be implemented? Or at least post some link where we could see how it is done in other libs?

Stale Typescript

Most helpful comment

@Trancever I think we can do following:

declare global {
  namespace ReactNativePaper {
    interface Theme {
      // Our theme properties here
    }
  }
}

Then users will be able to do the same to add any new properties.

All 4 comments

If it was an interface instead of Type we could use module augmentation to do so.

@Trancever I think we can do following:

declare global {
  namespace ReactNativePaper {
    interface Theme {
      // Our theme properties here
    }
  }
}

Then users will be able to do the same to add any new properties.

Hello 馃憢, this issue has been open for more than 2 months with no activity on it. If the issue is still present in the latest version, please leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution on workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix the issue.

This is fixed in 4.0.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

scottybo picture scottybo  路  3Comments

talaikis picture talaikis  路  3Comments

sm2017 picture sm2017  路  4Comments

yaronlevi picture yaronlevi  路  3Comments

zachariahtimothy picture zachariahtimothy  路  3Comments