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

fromPartial method returns an error,'Argument type {} is not assignable to parameter type I' #838

Closed
zsp419 opened this issue May 24, 2023 · 7 comments
Labels

Comments

@zsp419
Copy link

zsp419 commented May 24, 2023

With the tool's automatically generated code, the fromPartial method returns an error, as shown below:
image
here is my protofile code:
image
please help me!

@stephenh
Copy link
Owner

Hi @zsp419 , that code has not caused issues in the past; out of curiosity, what version of TypeScript are you using? I'm wondering if it's a TS 5.x behavior.

@Truman55
Copy link

image

same problem. TS 5.0.4

@zsp419
Copy link
Author

zsp419 commented May 30, 2023

what ide do you use,I had problems with IntelliJ IDEA before, but vscode is fine

@stephenh
Copy link
Owner

stephenh commented Jun 4, 2023

Fwiw I've bumped ts-proto's integration tests to TypeScript 5.1 and am not getting any errors from the ?? {} lines. And I'm using Webstorm.

We have a useExactTypes=false flag that might avoid this error, but also would be great to find out what specifically is causing this. Like a tsconfig setting?

Granted we could always add a {} as any to get around it, but would be nice to know more about why this is not working.

@TennyZhuang
Copy link

TennyZhuang commented Jul 27, 2023

Same error on ts 5.1.6

My tsconfig is normal:

{
  "compilerOptions": {
    "target": "es6",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
  },
  "include": [
    "next-env.d.ts",
    "**/*.ts",
    "**/*.tsx"
  ],
  "exclude": [
    "node_modules"
  ]
}

stephenh added a commit that referenced this issue Jul 29, 2023
This should fix #838 which I believe only happens in complicated
schemas.
@stephenh
Copy link
Owner

I pushed a fix that adds an as any on that line. Fwiw my guess is that non-trivial protobuf schemas cause issues with our useExactTypes flag, so I recommend turning it off if you see these issues.

stephenh pushed a commit that referenced this issue Jul 29, 2023
## [1.156.2](v1.156.1...v1.156.2) (2023-07-29)

### Bug Fixes

* Add 'as any' in create ([#895](#895)) ([4214d5a](4214d5a)), closes [#838](#838)
@stephenh
Copy link
Owner

🎉 This issue has been resolved in version 1.156.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

4 participants