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

Webpack plugin causes Typescript build errors when React component annotation is enabled #515

Open
willgardner9 opened this issue Apr 3, 2024 · 1 comment
Assignees

Comments

@willgardner9
Copy link

Environment

Steps to Reproduce

I have created a minimal reproduction of the issue here.

To reproduce:

  1. Use a Typescript generic within your React project (e.g. line 11 of src/app.tsx of the minimal reproduction)
  2. Attempt to build your project using a webpack config that uses the Sentry webpack plugin with react component annotation enabled
  3. The build errors

The build succeeds if you either:

  • Do not have any Typescript generics in your source code (e.g. line 11 of src/app.tsx is commented out)
  • Have Typescript generics but don't have React component annotation enabled (e.g. line 25 of webpack.config.js is set to enabled: false)

Expected Result

Webpack build succeeds, with React component annotation enabled. This is observable through the data-sentry-component data attributes being present in the bundle.

Actual Result

The build fails, here is an example log (with some unnecessary logs removed/truncated) from the minimal reproduction:

npm run build

> [email protected] build
> webpack --output-path dist

assets by status 139 KiB [cached] 2 assets
modules by path ./node_modules/ 141 KiB
  modules by path ./node_modules/react-dom/ 130 KiB
    ./node_modules/react-dom/index.js 1.33 KiB [built] [code generated]
    ./node_modules/react-dom/cjs/react-dom.production.min.js 129 KiB [built] [code generated]
  modules by path ./node_modules/react/ 6.94 KiB
    ./node_modules/react/index.js 190 bytes [built] [code generated]
    ./node_modules/react/cjs/react.production.min.js 6.75 KiB [built] [code generated]
  modules by path ./node_modules/scheduler/ 4.33 KiB
    ./node_modules/scheduler/index.js 198 bytes [built] [code generated]
    ./node_modules/scheduler/cjs/scheduler.production.min.js 4.14 KiB [built] [code generated]
modules by path ./src/*.tsx 3.38 KiB
  ./src/index.tsx 371 bytes [built] [code generated]
  ./src/app.tsx 3.02 KiB [built] [code generated] [1 error]

ERROR in /[redacted]/sentry-webpack-react-component-annotation-minimal-repro/src/app.tsx
./src/app.tsx 35:18-50
[tsl] ERROR in /[redacted]/sentry-webpack-react-component-annotation-minimal-repro/src/app.tsx(35,19)
      TS2347: Untyped function calls may not accept type arguments.
ts-loader-default_e3b0c44298fc1c14
 @ ./src/index.tsx 3:34-50

webpack 5.91.0 compiled with 1 error in 3386 ms
@lforst
Copy link
Member

lforst commented Apr 3, 2024

@0Calories mind taking a look?

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

No branches or pull requests

3 participants