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

@flow typeerror #3937

Open
stephen-dahl opened this issue Oct 11, 2024 · 4 comments
Open

@flow typeerror #3937

stephen-dahl opened this issue Oct 11, 2024 · 4 comments
Labels

Comments

@stephen-dahl
Copy link

Intended outcome:

use the @flow annotation

    @flow
    *fetch() {
      return true
    }

Actual outcome:

type error on @flow
image

How to reproduce the issue:

add the @flow decorator to a generator inside a class

https://codesandbox.io/p/sandbox/gifted-dawn-w2vdz9?workspaceId=6ecfa4fe-9261-4054-86f0-83188ee28c65

code sandbox does not show the error, not sure if they show ts errors. I see the error locally in vscode and webstorm.

Versions
"mobx": "^6.13.3",
"mobx-react-lite": "^4.0.7",
"typescript": "^5.6.3",

@mweststrate
Copy link
Member

You might need to specify the return type explicitly to Generator<boolean, boolean>. Without that I had the same error: 7f10f7a

@stephen-dahl
Copy link
Author

same error
before
image
after
image
image

@mweststrate
Copy link
Member

In the sandbox you linked it fixes the issue, so it probably relates to the further compilation configuration. Are you using legacy decorators for example? As work around it might be worth trying the old onProgress = flow((..) => { } syntax

@dmitriykozlov
Copy link

Have the same issue in my project
Screenshot 2024-10-28 at 13 53 56

tsconfig.json

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true
    "target": "es6",
    "lib": ["ESNext", "dom"],
    "moduleResolution": "Node",
    "esModuleInterop": true,
    "jsx": "react",
    "typeRoots": ["./typings"]
  },
}

babel

export default ({ env }) => {
  const isProduction = env('production')
  console.log('Babel isProduction=', isProduction)
  const plugins = [
    ['@babel/plugin-proposal-decorators', { version: '2023-11' }],
    [
      'babel-plugin-styled-components',
      {
        displayName: false,
        ssr: false,
        minify: isProduction,
        pure: isProduction,
      },
    ],
  ]
  if (!isProduction) {
    plugins.push(['react-refresh/babel'])
  }

  return {
    presets: [
      '@babel/preset-env',
      '@babel/preset-react',
      '@babel/preset-typescript',
    ],
    plugins,
    minified: true,
    sourceType: 'unambiguous',
  }
}
npm ls mobx mobx-react-lite typescript @babel/plugin-proposal-decorators 
[email protected] /Users/dima/WorkProjects/correqts-common
└─┬ @correqts-common/[email protected] -> ./chat
  ├── @babel/[email protected]
  ├─┬ @mobx-devtools/[email protected]
  │ └── [email protected] deduped
  ├─┬ @svgr/[email protected]
  │ └─┬ @svgr/[email protected]
  │   └─┬ [email protected]
  │     └── [email protected] deduped
  ├─┬ [email protected]
  │ └── [email protected] deduped
  ├── [email protected]
  └─┬ [email protected]
    └── [email protected]

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

No branches or pull requests

3 participants