expo-router 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-router",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "main": "src/index.tsx",
5
5
  "types": "src/index.tsx",
6
6
  "files": [
@@ -62,6 +62,7 @@
62
62
  },
63
63
  "devDependencies": {
64
64
  "@react-navigation/drawer": "^6.6.2",
65
+ "@types/url-parse": "^1.4.8",
65
66
  "expo-splash-screen": "~0.18.1",
66
67
  "expo-status-bar": "~1.4.4",
67
68
  "react-native-gesture-handler": "~2.9.0",
@@ -71,7 +72,7 @@
71
72
  },
72
73
  "dependencies": {
73
74
  "@bacons/react-views": "^1.1.3",
74
- "@expo/metro-runtime": "1.0.0",
75
+ "@expo/metro-runtime": "1.0.1",
75
76
  "@radix-ui/react-slot": "^1.0.0",
76
77
  "@react-navigation/bottom-tabs": "~6.5.7",
77
78
  "@react-navigation/native": "~6.1.6",
@@ -156,7 +156,7 @@ export function getNormalizedStatePath({
156
156
  prev[key] = decodeURIComponent(value as string);
157
157
  }
158
158
  return prev;
159
- }, {}),
159
+ }, {} as SearchParams),
160
160
  };
161
161
  }
162
162
 
@@ -515,7 +515,7 @@ function getParamsWithConventionsCollapsed({
515
515
  routeName: string;
516
516
  params: object;
517
517
  }): Record<string, string> {
518
- const processedParams = { ...params };
518
+ const processedParams: Record<string, string> = { ...params };
519
519
 
520
520
  // Remove the params present in the pattern since we'll only use the rest for query string
521
521
 
@@ -472,6 +472,7 @@ const createNormalizedConfigs = (
472
472
 
473
473
  parentScreens.push(screen);
474
474
 
475
+ // @ts-expect-error
475
476
  const config = routeConfig[screen];
476
477
 
477
478
  if (typeof config === "string") {
@@ -1,3 +1,4 @@
1
+ // @ts-expect-error
1
2
  import useLinking from "@react-navigation/native/lib/module/useLinking";
2
3
 
3
4
  export default useLinking as typeof import("./useLinking.native").default;
package/src/link/path.ts CHANGED
@@ -21,7 +21,7 @@
21
21
 
22
22
  // https://github.com/browserify/path-browserify/blob/master/index.js
23
23
 
24
- function assertPath(path) {
24
+ function assertPath(path: string) {
25
25
  if (typeof path !== "string") {
26
26
  throw new TypeError(
27
27
  "Path must be a string. Received " + JSON.stringify(path)
@@ -30,7 +30,7 @@ function assertPath(path) {
30
30
  }
31
31
 
32
32
  // Resolves . and .. elements in a path with directory names
33
- function normalizeStringPosix(path, allowAboveRoot) {
33
+ function normalizeStringPosix(path: string, allowAboveRoot?: boolean) {
34
34
  let res = "";
35
35
  let lastSegmentLength = 0;
36
36
  let lastSlash = -1;
@@ -98,7 +98,7 @@ function normalizeStringPosix(path, allowAboveRoot) {
98
98
  }
99
99
 
100
100
  // path.resolve([from ...], to)
101
- export function resolve(...segments) {
101
+ export function resolve(...segments: string[]) {
102
102
  let resolvedPath = "";
103
103
  let resolvedAbsolute = false;
104
104
 
@@ -36,7 +36,7 @@ export function isMovingToSiblingRoute(
36
36
  let currentRoot: InitialState | undefined = rootState;
37
37
 
38
38
  while (current?.routes?.[current?.routes?.length - 1].state != null) {
39
- const nextRoute = current?.routes?.[current?.routes?.length - 1];
39
+ const nextRoute: any = current?.routes?.[current?.routes?.length - 1];
40
40
 
41
41
  if (
42
42
  // Has more
@@ -74,9 +74,9 @@ export function getQualifiedStateForTopOfTargetState(
74
74
  let currentRoot: InitialState | undefined = rootState;
75
75
 
76
76
  while (current?.routes?.[current?.routes?.length - 1].state != null) {
77
- const nextRoute = current?.routes?.[current?.routes?.length - 1];
77
+ const nextRoute: any = current?.routes?.[current?.routes?.length - 1];
78
78
 
79
- const nextCurrentRoot = currentRoot?.routes?.find(
79
+ const nextCurrentRoot: InitialState | undefined = currentRoot?.routes?.find(
80
80
  (route) => route.name === nextRoute.name
81
81
  )?.state;
82
82
 
@@ -4,7 +4,7 @@ import { Platform, View } from "react-native";
4
4
  import registerRootComponent from "./fork/expo/registerRootComponent";
5
5
  import { SplashScreen } from "./views/Splash";
6
6
 
7
- function isBaseObject(obj) {
7
+ function isBaseObject(obj: any) {
8
8
  if (Object.prototype.toString.call(obj) !== "[object Object]") {
9
9
  return false;
10
10
  }
@@ -15,7 +15,7 @@ function isBaseObject(obj) {
15
15
  return proto === Object.prototype;
16
16
  }
17
17
 
18
- function isErrorShaped(error) {
18
+ function isErrorShaped(error: any): error is Error {
19
19
  return (
20
20
  error &&
21
21
  typeof error === "object" &&
@@ -28,7 +28,7 @@ function isErrorShaped(error) {
28
28
  * After we throw this error, any number of tools could handle it.
29
29
  * This check ensures the error is always in a reason state before surfacing it to the runtime.
30
30
  */
31
- function convertError(error) {
31
+ function convertError(error: any) {
32
32
  if (isErrorShaped(error)) {
33
33
  return error;
34
34
  }
@@ -8,6 +8,7 @@ import { ServerContainer, ServerContainerRef } from "@react-navigation/native";
8
8
  import App, { getManifest } from "expo-router/_root";
9
9
  import React from "react";
10
10
  import ReactDOMServer from "react-dom/server";
11
+ // @ts-expect-error
11
12
  import { AppRegistry } from "react-native-web";
12
13
 
13
14
  import Head from "../head/Head";
@@ -113,7 +114,7 @@ function StyleReset() {
113
114
  }
114
115
 
115
116
  // TODO(EvanBacon): Expose this to the developer
116
- export function Root({ children }) {
117
+ export function Root({ children }: { children: React.ReactNode }) {
117
118
  return (
118
119
  <html lang="en" style={{ height: "100%" }}>
119
120
  <head>
@@ -1,4 +1,5 @@
1
1
  // TODO: This is fragile and only works on web
2
+ // @ts-expect-error
2
3
  import ServerContext from "@react-navigation/native/lib/module/ServerContext";
3
4
  import React from "react";
4
5
 
@@ -165,7 +165,7 @@ export function createGetIdForRoute(
165
165
  if (!route.dynamic?.length) {
166
166
  return undefined;
167
167
  }
168
- return ({ params }) => {
168
+ return ({ params }: { params?: Record<string, any> }) => {
169
169
  const getPreferredId = (segment: DynamicConvention) => {
170
170
  // Params can be undefined when there are no params in the route.
171
171
  const preferredId = params?.[segment.name];
@@ -10,12 +10,14 @@ import { useContextKey } from "../Route";
10
10
  import { useFilterScreenChildren } from "../layouts/withLayoutContext";
11
11
  import { useSortedScreens } from "../useScreens";
12
12
 
13
+ type NavigatorTypes = ReturnType<typeof useNavigationBuilder>;
14
+
13
15
  // TODO: This might already exist upstream, maybe something like `useCurrentRender` ?
14
16
  export const NavigatorContext = React.createContext<{
15
17
  contextKey: string;
16
- state: any;
17
- navigation: any;
18
- descriptors: any;
18
+ state: NavigatorTypes["state"];
19
+ navigation: NavigatorTypes["navigation"];
20
+ descriptors: NavigatorTypes["descriptors"];
19
21
  router: RouterFactory<any, any, any>;
20
22
  } | null>(null);
21
23