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

0.0.10 breaking code inspection in WebStorm #12

Open
gordongest opened this issue Oct 25, 2023 · 4 comments
Open

0.0.10 breaking code inspection in WebStorm #12

gordongest opened this issue Oct 25, 2023 · 4 comments

Comments

@gordongest
Copy link

Possibly related to the recent discovery re: returning a class instance with a proper reference to this, code inspection and completion in WebStorm is struggling to understand not only zod-class instances and methods, but also JS/TS code in general. Upon reverting to 0.0.9, the issue is resolved in multiple versions of WebStorm.

@sam-goodwin
Copy link
Owner

Thanks for reporting. Unfortunately I don't have WebStorm so can't test, but I would be surprised if it were truly localized to WebStorm.

Did you try VS Code?

It could be a regression in the published .d.ts files since I don't test those locally (when I really should).

@gordongest
Copy link
Author

The issue is present but slightly different in VS Code—rather than breaking overall code inspection, the interpreter throws errors re: the output of Foo.parse() not satisfying the type Foo because it is missing class methods e.g. getId(), getName(). Seems like you might be on to something.

@sam-goodwin
Copy link
Owner

I'm having a hard time reproducing this. It is working in both VS code and WebStorm for me.
image

@sam-goodwin
Copy link
Owner

I am getting this error when running tsc though - it is flagging an error in node_modules/zod-class which is really bad. This should be caught when publishing zod-class but it isn't. Very strange.

Interface 'ZodClass<Members, Instance, Shape>' incorrectly extends interface 'ZodType<Instance, ZodTypeDef, Instance>'.
  The types returned by 'safeParse(...)' are incompatible between these types.
    Type 'SafeParseReturnType<unknown, Instance>' is not assignable to type 'SafeParseReturnType<Instance, Instance>'.
      Type 'SafeParseError<unknown>' is not assignable to type 'SafeParseReturnType<Instance, Instance>'.
        Type 'SafeParseError<unknown>' is not assignable to type 'SafeParseError<Instance>'.
          The types returned by 'error.format()' are incompatible between these types.
            Type 'ZodFormattedError<unknown, string>' is not assignable to type 'ZodFormattedError<Instance, string>'.
              Type 'ZodFormattedError<unknown, string>' is not assignable to type 'recursiveZodFormattedError<NonNullable<Instance>>'.ts(2430)

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

No branches or pull requests

2 participants