Skip to content

TypeScript compiler crashes due to unrestricted "includes" #129

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

Closed
kraenhansen opened this issue May 15, 2025 · 2 comments · Fixed by #130
Closed

TypeScript compiler crashes due to unrestricted "includes" #129

kraenhansen opened this issue May 15, 2025 · 2 comments · Fixed by #130

Comments

@kraenhansen
Copy link
Contributor

Description

Because neither @react-native/typescript-config nor the template's tsconfig.json declare "include" nor "files" TypeScript traverse all files of the project and crash doing so.

Steps to reproduce

  1. Clone the reproducer git clone https://github.com/react-native-community/reproducer-react-native
  2. Change directory into the app cd reproducer-react-native/ReproducerApp
  3. Clone hermes into the directory to get some more files: git clone git@github.com:facebook/hermes.git
  4. Run the typescript compiler: npx tsc - see the long runtime and crash
  5. Patch tsconfig.json with a less permissive include array: "include": ["*.tsx", "src/"]
  6. Run the typescript compiler: npx tsc - see the pass

React Native Community Template Version

0.79.2

Affected Platforms

Build - MacOS

Output of npx @react-native-community/cli@latest info

info Fetching system and libraries information...
System:
  OS: macOS 15.5
  CPU: (14) arm64 Apple M3 Max
  Memory: 132.83 MB / 36.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.15.1
    path: ~/.local/state/fnm_multishells/60920_1747302364972/bin/node
  Yarn: Not Found
  npm:
    version: 10.9.2
    path: ~/.local/state/fnm_multishells/60920_1747302364972/bin/npm
  Watchman:
    version: 2025.04.14.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.4
      - iOS 17.4
      - macOS 14.4
      - tvOS 17.4
      - visionOS 1.1
      - watchOS 10.4
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.3 AI-243.24978.46.2431.13363775
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.15
    path: /usr/bin/javac
  Ruby:
    version: 3.4.3
    path: /opt/homebrew/opt/ruby/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 18.0.0
    wanted: 18.0.0
  react:
    installed: 19.0.0
    wanted: 19.0.0
  react-native:
    installed: 0.79.1
    wanted: 0.79.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

info React Native v0.79.2 is now available (your project is running on v0.79.1).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.79.2
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.79.1&to=0.79.2
info For more info, check out "https://reactnative.dev/docs/upgrading?os=macos".

Stacktrace or Logs

/Users/kraen.hansen/Repositories/reproducer-react-native/ReproducerApp/node_modules/typescript/lib/tsc.js:29324
  function parseMemberExpressionOrHigher() {
                                        ^

RangeError: Maximum call stack size exceeded
    at parseMemberExpressionOrHigher (/Users/kraen.hansen/Repositories/reproducer-react-native/ReproducerApp/node_modules/typescript/lib/tsc.js:29324:41)
    at parseLeftHandSideExpressionOrHigher (/Users/kraen.hansen/Repositories/reproducer-react-native/ReproducerApp/node_modules/typescript/lib/tsc.js:29320:82)
    at parseUpdateExpression (/Users/kraen.hansen/Repositories/reproducer-react-native/ReproducerApp/node_modules/typescript/lib/tsc.js:29295:24)
    at parseUnaryExpressionOrHigher (/Users/kraen.hansen/Repositories/reproducer-react-native/ReproducerApp/node_modules/typescript/lib/tsc.js:29215:32)
    at parseBinaryExpressionOrHigher (/Users/kraen.hansen/Repositories/reproducer-react-native/ReproducerApp/node_modules/typescript/lib/tsc.js:29137:25)
    at parseAssignmentExpressionOrHigher (/Users/kraen.hansen/Repositories/reproducer-react-native/ReproducerApp/node_modules/typescript/lib/tsc.js:28810:18)
    at parseExpression (/Users/kraen.hansen/Repositories/reproducer-react-native/ReproducerApp/node_modules/typescript/lib/tsc.js:28776:16)
    at doOutsideOfContext (/Users/kraen.hansen/Repositories/reproducer-react-native/ReproducerApp/node_modules/typescript/lib/tsc.js:26473:12)
    at allowInAnd (/Users/kraen.hansen/Repositories/reproducer-react-native/ReproducerApp/node_modules/typescript/lib/tsc.js:26494:12)
    at parseParenthesizedExpression (/Users/kraen.hansen/Repositories/reproducer-react-native/ReproducerApp/node_modules/typescript/lib/tsc.js:29885:24)

Reproducer

https://github.com/react-native-community/reproducer-react-native

Screenshots and Videos

No response

@cortinico
Copy link
Member

cc @huntie
Potentially related to #127

@huntie
Copy link
Collaborator

huntie commented May 15, 2025

Interesting!

  • @cortinico Likely unrelated to that change, purely a potential perf/memory issue.

Patch tsconfig.json with a less permissive include array: "include": ["*.tsx", "src/"]

  • I like this idea, will open a PR.

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

Successfully merging a pull request may close this issue.

3 participants