expo: Stack breaks typescript in v2

Minimal reproducible example

https://github.com/lhguerra/expo-router-stack-typescript-bug

Which package manager are you using? (Yarn is recommended)

npm

If the issue is web-related, please select the bundler (web.bundler in the app.json)

metro

Summary

When adding Stack component to the _layout, it breaks the type check with a bunch of errors in expo-router lib.

Just download the repository above, install the dependencies and run npm run lint:ts

Environment

expo-env-info 1.0.5 environment info: System: OS: Linux 5.15 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish) Shell: 5.8.1 - /usr/bin/zsh Binaries: Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node npm: 9.5.1 - ~/.nvm/versions/node/v18.16.0/bin/npm npmPackages: expo: ^49.0.3 => 49.0.13 react: 18.2.0 => 18.2.0 react-dom: 18.2.0 => 18.2.0 react-native: 0.72.3 => 0.72.3 react-native-web: ~0.19.6 => 0.19.9 npmGlobalPackages: eas-cli: 5.0.2 expo-cli: 6.3.10 Expo Workflow: managed

About this issue

  • Original URL
  • State: closed
  • Created 8 months ago
  • Reactions: 2
  • Comments: 15 (10 by maintainers)

Most upvoted comments

All right, I fixed the errors by changing my import from

import {Stack} from "expo-router/stack";

to

import {Stack} from "expo-router";

I believe I was importing a ts file and it was causing the problems.

This comment helped me: https://github.com/microsoft/TypeScript/issues/40426#issuecomment-1774231789