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

The 'declare' modifier is only allowed when the 'allowDeclareFields' option of @babel/plugin-transform-typescript or @babel/preset-typescript is enabled #84

Open
ntucker opened this issue May 8, 2024 · 0 comments
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked bundler: webpack 📦 Issue is related to webpack bundler cat: typings 👮 Typescript types related issues needs: complete repro 🖥️ Issue need to have complete repro provided

Comments

@ntucker
Copy link

ntucker commented May 8, 2024

Environment

  • wyw-in-js version: 0.5.3
  • custom processor: -
  • Bundler (+ version): webpack 5.91.0
  • Node.js version: 20
  • OS: ubuntu linux

Description

ERROR in ./src/pages/IssueDetail/CreateComment.tsx
Module build failed (from ./node_modules/@wyw-in-js/webpack-loader/lib/index.js):
SyntaxError: /home/projects/aoniolzby.github/src/resources/Issue.tsx: The 'declare' modifier is only allowed when the 'allowDeclareFields' option of @babel/plugin-transform-typescript or @babel/preset-typescript is enabled.
  23 |   declare readonly draft?: boolean;
  24 |   get stateIcon() {
> 25 |     return stateToIcon[this.state];
     |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  26 |   }
  27 |   get owner() {
  28 |     const pieces = this.repositoryUrl.split('/');
    at File.buildCodeFrameError (file:///home/projects/aoniolzby.github/node_modules/@babel/core/lib/transformation/file/file.js:202:12)
    at NodePath.buildCodeFrameError (file:///home/projects/aoniolzby.github/node_modules/@babel/traverse/lib/path/index.js:98:21)
    at Object.field (file:///home/projects/aoniolzby.github/node_modules/@babel/plugin-transform-typescript/lib/index.js:73:22)
    at eval (file:///home/projects/aoniolzby.github/node_modules/@babel/plugin-transform-typescript/lib/index.js:360:33)
    at Array.forEach (<anonymous>)
    at PluginPass.Class (file:///home/projects/aoniolzby.github/node_modules/@babel/plugin-transform-typescript/lib/index.js:352:31)
    at newFn (file:///home/projects/aoniolzby.github/node_modules/@babel/traverse/lib/visitors.js:160:14)
    at NodePath._call (file:///home/projects/aoniolzby.github/node_modules/@babel/traverse/lib/path/context.js:46:20)
    at NodePath.call (file:///home/projects/aoniolzby.github/node_modules/@babel/traverse/lib/path/context.js:36:17)
    at NodePath.visit (file:///home/projects/aoniolzby.github/node_modules/@babel/traverse/lib/path/context.js:82:31)

This worked fine in previous versions. Only started happening over the latest update.

Reproducible Demo

Code: https://github.com/reactive/data-client/tree/master/examples/github-app
File that triggers: https://github.com/reactive/data-client/blob/master/examples/github-app/src/resources/Issue.tsx
Stackblitz location to see error : https://stackblitz.com/github/reactive/data-client/tree/master/examples/github-app?file=src%2Fresources%2FIssue.tsx
Webpack config wyw-in-js integration: https://github.com/ntucker/anansi/blob/60736b7b2b13fd3d30a24c8a7f4365d525c6157b/packages/webpack-config-anansi/src/base/index.js#L79
Related babel config integration: https://github.com/ntucker/anansi/blob/60736b7b2b13fd3d30a24c8a7f4365d525c6157b/packages/babel-preset-anansi/index.js#L27

@ntucker ntucker added bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized labels May 8, 2024
@github-actions github-actions bot added bundler: webpack 📦 Issue is related to webpack bundler cat: typings 👮 Typescript types related issues and removed needs: triage 🏷 Issue needs to be checked and prioritized labels May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked bundler: webpack 📦 Issue is related to webpack bundler cat: typings 👮 Typescript types related issues needs: complete repro 🖥️ Issue need to have complete repro provided
Projects
None yet
Development

No branches or pull requests

1 participant