Skip to content

Commit adf6692

Browse files
committed
Add a note about interfaces in typescript section
1 parent af39ace commit adf6692

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

versioned_docs/version-6.x/typescript.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ And then we can use it:
5252

5353
This will provide type checking and intelliSense for props of the `Navigator` and `Screen` components.
5454

55+
> Note: The type containing the mappings must be a type alias (e.g. `type RootStackParamList = { ... }`). It cannot be an interface (e.g. `interface RootStackParamList { ... }`). It also shouldn't extend `ParamListBase` (e.g. `interface RootStackParamList extends ParamListBase { ... }`). Doing so will result in incorrect type checking where it allows you to pass incorrect route names.
56+
5557
### Type checking screens
5658

5759
To type check our screens, we need to annotate the `navigation` prop and the `route` prop received by a screen. The navigator packages in React Navigation export a generic types to define types for both the `navigation` and `route` props from the corresponding navigator.

0 commit comments

Comments
 (0)