@@ -728,7 +728,7 @@ test('when navigating from a route with no params and no search to the current r
728
728
} )
729
729
730
730
test ( 'when navigating from a route with no params and no search to the parent route' , ( ) => {
731
- expectTypeOf ( Link < DefaultRouter , '/posts' , '../ ' > )
731
+ expectTypeOf ( Link < DefaultRouter , '/posts' , '..' > )
732
732
. parameter ( 0 )
733
733
. toHaveProperty ( 'to' )
734
734
. toEqualTypeOf <
@@ -740,11 +740,11 @@ test('when navigating from a route with no params and no search to the parent ro
740
740
| '../invoices/$invoiceId/details/$detailId'
741
741
| '../invoices/$invoiceId/details/$detailId/lines'
742
742
| '../invoices'
743
- | '../ '
743
+ | '..'
744
744
| undefined
745
745
> ( )
746
746
747
- expectTypeOf ( Link < DefaultRouterObjects , '/posts' , '../ ' > )
747
+ expectTypeOf ( Link < DefaultRouterObjects , '/posts' , '..' > )
748
748
. parameter ( 0 )
749
749
. toHaveProperty ( 'to' )
750
750
. toEqualTypeOf <
@@ -756,7 +756,7 @@ test('when navigating from a route with no params and no search to the parent ro
756
756
| '../invoices/$invoiceId/details/$detailId'
757
757
| '../invoices/$invoiceId/details/$detailId/lines'
758
758
| '../invoices'
759
- | '../ '
759
+ | '..'
760
760
| undefined
761
761
> ( )
762
762
@@ -776,7 +776,7 @@ test('when navigating from a route with no params and no search to the parent ro
776
776
| undefined
777
777
> ( )
778
778
779
- expectTypeOf ( Link < RouterNeverTrailingSlashes , '/posts' , '../ ' > )
779
+ expectTypeOf ( Link < RouterNeverTrailingSlashes , '/posts' , '..' > )
780
780
. parameter ( 0 )
781
781
. toHaveProperty ( 'to' )
782
782
. toEqualTypeOf <
@@ -788,11 +788,11 @@ test('when navigating from a route with no params and no search to the parent ro
788
788
| '../invoices/$invoiceId/details/$detailId'
789
789
| '../invoices/$invoiceId/details/$detailId/lines'
790
790
| '../invoices'
791
- | '../ '
791
+ | '..'
792
792
| undefined
793
793
> ( )
794
794
795
- expectTypeOf ( Link < RouterPreserveTrailingSlashes , '/posts' , '../ ' > )
795
+ expectTypeOf ( Link < RouterPreserveTrailingSlashes , '/posts' , '..' > )
796
796
. parameter ( 0 )
797
797
. toHaveProperty ( 'to' )
798
798
. toEqualTypeOf <
@@ -813,6 +813,7 @@ test('when navigating from a route with no params and no search to the parent ro
813
813
| '../invoices'
814
814
| '../invoices/'
815
815
| '../'
816
+ | '..'
816
817
| undefined
817
818
> ( )
818
819
} )
@@ -3855,10 +3856,18 @@ test('ResolveRelativePath', () => {
3855
3856
ResolveRelativePath < '/posts/1/comments' , '..' >
3856
3857
> ( ) . toEqualTypeOf < '/posts/1' > ( )
3857
3858
3859
+ expectTypeOf <
3860
+ ResolveRelativePath < '/posts/1/comments/' , '..' >
3861
+ > ( ) . toEqualTypeOf < '/posts/1/' > ( )
3862
+
3858
3863
expectTypeOf <
3859
3864
ResolveRelativePath < '/posts/1/comments' , '../..' >
3860
3865
> ( ) . toEqualTypeOf < '/posts' > ( )
3861
3866
3867
+ expectTypeOf <
3868
+ ResolveRelativePath < '/posts/1/comments/' , '../..' >
3869
+ > ( ) . toEqualTypeOf < '/posts/' > ( )
3870
+
3862
3871
expectTypeOf <
3863
3872
ResolveRelativePath < '/posts/1/comments' , '../../..' >
3864
3873
> ( ) . toEqualTypeOf < '/' > ( )
@@ -3875,6 +3884,10 @@ test('ResolveRelativePath', () => {
3875
3884
ResolveRelativePath < '/posts/1/comments' , '../edit' >
3876
3885
> ( ) . toEqualTypeOf < '/posts/1/edit' > ( )
3877
3886
3887
+ expectTypeOf <
3888
+ ResolveRelativePath < '/posts/1/comments/' , '../edit' >
3889
+ > ( ) . toEqualTypeOf < '/posts/1/edit' > ( )
3890
+
3878
3891
expectTypeOf <
3879
3892
ResolveRelativePath < '/posts/1/comments' , '1' >
3880
3893
> ( ) . toEqualTypeOf < '/posts/1/comments/1' > ( )
@@ -3888,6 +3901,169 @@ test('ResolveRelativePath', () => {
3888
3901
> ( ) . toEqualTypeOf < '/posts/1/comments/1/2' > ( )
3889
3902
} )
3890
3903
3904
+ test ( 'navigation edge cases' , ( ) => {
3905
+ expectTypeOf ( Link < DefaultRouter , '/' , '..' > )
3906
+ . parameter ( 0 )
3907
+ . toHaveProperty ( 'to' )
3908
+ . toEqualTypeOf < undefined > ( )
3909
+
3910
+ expectTypeOf ( Link < RouterAlwaysTrailingSlashes , '/' , '../' > )
3911
+ . parameter ( 0 )
3912
+ . toHaveProperty ( 'to' )
3913
+ . toEqualTypeOf < undefined > ( )
3914
+
3915
+ expectTypeOf ( Link < RouterNeverTrailingSlashes , '/' , '..' > )
3916
+ . parameter ( 0 )
3917
+ . toHaveProperty ( 'to' )
3918
+ . toEqualTypeOf < undefined > ( )
3919
+
3920
+ expectTypeOf ( Link < RouterPreserveTrailingSlashes , '/' , '..' | '../' > )
3921
+ . parameter ( 0 )
3922
+ . toHaveProperty ( 'to' )
3923
+ . toEqualTypeOf < undefined > ( )
3924
+
3925
+ expectTypeOf ( Link < DefaultRouter , '' , '..' > )
3926
+ . parameter ( 0 )
3927
+ . toHaveProperty ( 'to' )
3928
+ . toEqualTypeOf < undefined > ( )
3929
+
3930
+ expectTypeOf ( Link < RouterAlwaysTrailingSlashes , '' , '../' > )
3931
+ . parameter ( 0 )
3932
+ . toHaveProperty ( 'to' )
3933
+ . toEqualTypeOf < undefined > ( )
3934
+
3935
+ expectTypeOf ( Link < RouterNeverTrailingSlashes , '' , '..' > )
3936
+ . parameter ( 0 )
3937
+ . toHaveProperty ( 'to' )
3938
+ . toEqualTypeOf < undefined > ( )
3939
+
3940
+ expectTypeOf ( Link < RouterPreserveTrailingSlashes , '' , '..' | '../' > )
3941
+ . parameter ( 0 )
3942
+ . toHaveProperty ( 'to' )
3943
+ . toEqualTypeOf < undefined > ( )
3944
+
3945
+ expectTypeOf ( Link < DefaultRouter , '/posts' , '...' > )
3946
+ . parameter ( 0 )
3947
+ . toHaveProperty ( 'to' )
3948
+ . toEqualTypeOf < undefined > ( )
3949
+
3950
+ expectTypeOf ( Link < RouterAlwaysTrailingSlashes , '/posts' , '.../' > )
3951
+ . parameter ( 0 )
3952
+ . toHaveProperty ( 'to' )
3953
+ . toEqualTypeOf < undefined > ( )
3954
+
3955
+ expectTypeOf ( Link < RouterNeverTrailingSlashes , '/posts' , '...' > )
3956
+ . parameter ( 0 )
3957
+ . toHaveProperty ( 'to' )
3958
+ . toEqualTypeOf < undefined > ( )
3959
+
3960
+ expectTypeOf ( Link < RouterPreserveTrailingSlashes , '/posts' , '...' | '.../' > )
3961
+ . parameter ( 0 )
3962
+ . toHaveProperty ( 'to' )
3963
+ . toEqualTypeOf < undefined > ( )
3964
+
3965
+ expectTypeOf ( Link < DefaultRouter , '/posts/$postId' , '../../..' > )
3966
+ . parameter ( 0 )
3967
+ . toHaveProperty ( 'to' )
3968
+ . toEqualTypeOf < undefined > ( )
3969
+
3970
+ expectTypeOf ( Link < RouterAlwaysTrailingSlashes , '/posts/$postId' , '../../../' > )
3971
+ . parameter ( 0 )
3972
+ . toHaveProperty ( 'to' )
3973
+ . toEqualTypeOf < undefined > ( )
3974
+
3975
+ expectTypeOf ( Link < RouterNeverTrailingSlashes , '/posts/$postId' , '../../..' > )
3976
+ . parameter ( 0 )
3977
+ . toHaveProperty ( 'to' )
3978
+ . toEqualTypeOf < undefined > ( )
3979
+
3980
+ expectTypeOf (
3981
+ Link <
3982
+ RouterPreserveTrailingSlashes ,
3983
+ '/posts/$postId' ,
3984
+ '../../..' | '../../../'
3985
+ > ,
3986
+ )
3987
+ . parameter ( 0 )
3988
+ . toHaveProperty ( 'to' )
3989
+ . toEqualTypeOf < undefined > ( )
3990
+
3991
+ expectTypeOf ( Link < DefaultRouter , '/posts/$postId' , '../..' > )
3992
+ . parameter ( 0 )
3993
+ . toHaveProperty ( 'to' )
3994
+ . toEqualTypeOf <
3995
+ | '../..'
3996
+ | '../../posts'
3997
+ | '../../posts/$postId'
3998
+ | '../../invoices'
3999
+ | '../../invoices/$invoiceId'
4000
+ | '../../invoices/$invoiceId/edit'
4001
+ | '../../invoices/$invoiceId/details'
4002
+ | '../../invoices/$invoiceId/details/$detailId'
4003
+ | '../../invoices/$invoiceId/details/$detailId/lines'
4004
+ | undefined
4005
+ > ( )
4006
+
4007
+ expectTypeOf ( Link < RouterAlwaysTrailingSlashes , '/posts/$postId' , '../../' > )
4008
+ . parameter ( 0 )
4009
+ . toHaveProperty ( 'to' )
4010
+ . toEqualTypeOf <
4011
+ | '../../'
4012
+ | '../../posts/'
4013
+ | '../../posts/$postId/'
4014
+ | '../../invoices/'
4015
+ | '../../invoices/$invoiceId/'
4016
+ | '../../invoices/$invoiceId/edit/'
4017
+ | '../../invoices/$invoiceId/details/'
4018
+ | '../../invoices/$invoiceId/details/$detailId/'
4019
+ | '../../invoices/$invoiceId/details/$detailId/lines/'
4020
+ | undefined
4021
+ > ( )
4022
+
4023
+ expectTypeOf ( Link < RouterNeverTrailingSlashes , '/posts/$postId' , '../../' > )
4024
+ . parameter ( 0 )
4025
+ . toHaveProperty ( 'to' )
4026
+ . toEqualTypeOf <
4027
+ | '../..'
4028
+ | '../../posts'
4029
+ | '../../posts/$postId'
4030
+ | '../../invoices'
4031
+ | '../../invoices/$invoiceId'
4032
+ | '../../invoices/$invoiceId/edit'
4033
+ | '../../invoices/$invoiceId/details'
4034
+ | '../../invoices/$invoiceId/details/$detailId'
4035
+ | '../../invoices/$invoiceId/details/$detailId/lines'
4036
+ | undefined
4037
+ > ( )
4038
+
4039
+ expectTypeOf (
4040
+ Link < RouterPreserveTrailingSlashes , '/posts/$postId' , '../../' | '../..' > ,
4041
+ )
4042
+ . parameter ( 0 )
4043
+ . toHaveProperty ( 'to' )
4044
+ . toEqualTypeOf <
4045
+ | '../..'
4046
+ | '../../'
4047
+ | '../../posts'
4048
+ | '../../posts/$postId'
4049
+ | '../../invoices'
4050
+ | '../../invoices/$invoiceId'
4051
+ | '../../invoices/$invoiceId/edit'
4052
+ | '../../invoices/$invoiceId/details'
4053
+ | '../../invoices/$invoiceId/details/$detailId'
4054
+ | '../../invoices/$invoiceId/details/$detailId/lines'
4055
+ | '../../posts/'
4056
+ | '../../posts/$postId/'
4057
+ | '../../invoices/'
4058
+ | '../../invoices/$invoiceId/'
4059
+ | '../../invoices/$invoiceId/edit/'
4060
+ | '../../invoices/$invoiceId/details/'
4061
+ | '../../invoices/$invoiceId/details/$detailId/'
4062
+ | '../../invoices/$invoiceId/details/$detailId/lines/'
4063
+ | undefined
4064
+ > ( )
4065
+ } )
4066
+
3891
4067
test ( 'linkOptions' , ( ) => {
3892
4068
const defaultRouterLinkOptions = linkOptions <
3893
4069
{ label : string } ,
0 commit comments