Skip to content

Commit a268627

Browse files
committed
fix: make nested navigator params required
previously nested navigator params always included `| undefined`. this made it possible to cause a crash by allowing navigating to nested navigator without reequired params. this improves the types to make them required, and only make it optional if all nested params are optional. it's a bit stricter than runtime, as it can depend on initial route for a stack, but for now this is a safer option than making it always optional.
1 parent 44e76bb commit a268627

3 files changed

Lines changed: 229 additions & 87 deletions

File tree

example/__typechecks__/common.check.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,7 @@ useLinkProps<RootStackParamList>({ screen: 'Login' });
726726
Timeline
727727
</Button>;
728728

729+
// @ts-expect-error
729730
useLinkProps({ screen: 'StackBasic' });
730731
// @ts-expect-error
731732
useLinkProps({ screen: 'StackBasi' });
@@ -739,6 +740,7 @@ useLinkProps({
739740
params: { screen: 'Examples' },
740741
});
741742

743+
// @ts-expect-error
742744
<Link screen="StackBasic">StackBasic</Link>;
743745
// @ts-expect-error
744746
<Link screen="StackBasi">StackBasic</Link>;
@@ -750,6 +752,7 @@ useLinkProps({
750752
Home
751753
</Link>;
752754

755+
// @ts-expect-error
753756
<Button screen="StackBasic">StackBasic</Button>;
754757
// @ts-expect-error
755758
<Button screen="StackBasi">StackBasic</Button>;

0 commit comments

Comments
 (0)