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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[typescript] Create tsconfig.next.json #33721

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

marklawlor
Copy link
Contributor

@marklawlor marklawlor commented Dec 17, 2024

Why

React Contributors discord request

This the first step of many upgrade Expo's SDK to the latest TypeScript and align our tsconfig.json with the recommended settings.

  • Extended from @tsconfig/react-native
  • @tsconfig/react-native enables strict: true so the partial strict options were removed
  • Add noUnusedLocals
  • Remove inlineSource, I don't believe this is needed with the new debugger.
  • Remove types override. Where we using"jest-require"? Modules that do not run on device should override this setting
  • Remove lib override. Modules that do not run on device (or in multiple environments) should override this setting
  • Modules are compiled by default (build folder output). Modules will need to disable this if they do not perform a build step, or have alternative build tooling (cli).
  • While Metro is signalling that they would prefer that packages were not precompiled, the ecosystem is clearing moving towards things being precompiled. For example, react-native-builder-bob / react-native-reanimated / react-native-navigation all ship precompiled. https://bsky.app/profile/satya164.page/post/3ldf4egm2jk2q

All-in-all, when a module switches to this tsconfig we will need to

  • Check for module specific overrides
  • Fix the new strict mode errors
  • Commit or disable the build dir being

This tsconfig does not yet include the changes to module. I suspect the changes to strict are enough work for now. The react-native repro just switched to esnext this week.

@marklawlor marklawlor requested a review from byCedric December 17, 2024 21:29
Copy link
Contributor

Subscribed to pull request

File Patterns Mentions
packages/expo-module-scripts/** @ide

Generated by CodeMention

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Dec 17, 2024
@marklawlor marklawlor force-pushed the marklawlor/typescript/tsconfig.next.json branch from a71b824 to c6d3d79 Compare December 18, 2024 17:35
@expo-bot
Copy link
Collaborator

Hi there! 👋 I'm a bot whose goal is to ensure your contributions meet our guidelines.

I've found some issues in your pull request that should be addressed (click on them for more details) 👇

⚠️ Suggestion: Missing changelog entries


Your changes should be noted in the changelog, e.g.:
- Create tsconfig.next.json ([#33721](https://github.com/expo/expo/pull/33721) by [@marklawlor](https://github.com/marklawlor))
Read Updating Changelogs guide and consider adding an appropriate entry to the following changelogs:


Generated by ExpoBot 🤖 against c6d3d79

@@ -33,6 +33,7 @@
"@expo/npm-proofread": "^1.0.1",
"@testing-library/react-native": "^12.5.2",
"@tsconfig/node18": "^18.2.2",
"@tsconfig/react-native": "^3.0.5",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm, is it intended to use the community-based @tsconfig/react-native instead of the @react-native/typescript-config from the React Native monorepo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use the official one, this was a mistake

@reichhartd
Copy link
Contributor

While Metro is signalling that they would prefer that packages were not precompiled, the ecosystem is clearing moving towards things being precompiled. For example, react-native-builder-bob / react-native-reanimated / react-native-navigation all ship precompiled. https://bsky.app/profile/satya164.page/post/3ldf4egm2jk2q

What are the reasons that these libraries choose to ship their code precompiled, even though Metro prefers non-precompiled packages? In contrast, there is a trend in the Expo repository this year towards shipping TypeScript source files, as seen in the following pull requests: #33781, #30665, #29702, #29244.

@marklawlor
Copy link
Contributor Author

@reichhartd We should ship both src and build. While Metro prefers using src, other tools do not. Jest is a common example as it requires additional setup to work with React Native. We also see community members trying to use Expo packages with other bundlers such as Next.js

Metro supports conditional exports with a react-native condition, so we should be able to satisfy both use cases

 "exports": {
    "browser": "./dist/index.js",
    "react-native": "./src/index.js",
    "default": "./dist/index.js"
  }

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

Successfully merging this pull request may close these issues.

3 participants