Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Href<T> breaks type checking on CI #746

Open
robrechtme opened this issue Jul 7, 2023 · 9 comments
Open

Href<T> breaks type checking on CI #746

robrechtme opened this issue Jul 7, 2023 · 9 comments
Assignees

Comments

@robrechtme
Copy link

robrechtme commented Jul 7, 2023

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

yarn

Summary

馃憢 Not sure if this is a bug or a feature request...

We have a basic yarn tsc check runnning on CI for pull requests, which fails on TypeScript errors. If try to use the Href<T> type, the CI pipeline breaks, because these types are dynamically generated.
Is there a way to generate these dynamic types on CI?

Minimal reproducible example

Simple example:

interface Props {
  to: Href<string>; 
   // ^ error TS2305: Module '"expo-router"' has no exported member 'Href'.
  title: string;
}

export const ListItem = ({ to, title }: Props) => { ... };
@caioedut
Copy link

Same here :(

@jdziadek
Copy link

Same

@davecalnan
Copy link

I've used a workaround of running pnpm start and killing it after 10 seconds using timeout. Here's an example working for me on GitHub actions:

- name: 师 Generate mobile router types
  run: timeout 10 pnpm start
  working-directory: apps/mobile
  continue-on-error: true

This could be quite brittle but works for now. Replace pnpm start with yarn start or pnpm run start and change/remove working-directory as needed. continue-on-error: true is needed as timeout returns a non-zero exit code and fails the job otherwise. timeout is available on GitHub Linux runners, on macOS you can do brew install coreutils to get timeout.

@robertherber
Copy link

Also looking for a good solution for this.

My current workaround is to add .expo/types to git, modifying my .gitignore like this, feels like an okayish solution at this time:

.expo/*
!.expo/types/

@oikalyptus
Copy link

@robertherber 鈥檚 fix is a nice temporary solution.

@la55u
Copy link

la55u commented Oct 10, 2023

It seems there is now a command to generate the types on demand. From the docs here:

If you find yourself in a situation where you need to generate these types without initiating the development server, such as during type checking on a Continuous Integration (CI) server. To do this, run the command npx expo customize tsconfig.json on the CI.

Which would solve OP's issue (and mine) but the command doesn't seem to work for me at least. I'm getting the following error:

CommandError: Invalid files: tsconfig.json. Allowed: babel.config.js, webpack.config.js, metro.config.js, web/serve.json, web/index.html

What am I doing wrong?

Related issue: expo/expo#24818

@johnjensenish
Copy link

What am I doing wrong?

Related issue: expo/expo#24818

For folks following along, the related issue has now been fixed & now you can use npx expo customize tsconfig.json as of expo@49.0.16.

@the-simian
Copy link

@johnjensenish we can still repro this error in expo v50 even after running the npx expo customize tsconfig.json

  "expo": "~50.0.14",
  "expo-router": "3.4.8",
  "react-native": "0.73.6",   

@robertherber 's solution is still a viable workaround.

@daxaxelrod
Copy link

Getting this with expo router Href and Route types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests