Skip to content

where first type declaration is messing the completion of field param when other params are filled #101

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

Closed
ftzi opened this issue Nov 10, 2021 · 2 comments

Comments

@ftzi
Copy link

ftzi commented Nov 10, 2021

Images to better explain:

When writing first param. Working as intended:

image

When filling first param when others are already filled. Intellisense not working, may enter invalid fields without TS error.

image

I have found out that if I remove the first where type declaration in the .d.ts of this lib, it gets fixed.

image

The problematic where that causes it and that I removed to fix it, as shows the previous image

image

@ftzi
Copy link
Author

ftzi commented Nov 10, 2021

The problematic type is the DocId, that is declared just as declare class DocId {}, and that {} is probably being interpreted as any non-nullish value, as it says when we type A = {}:

Don't use `{}` as a type. `{}` actually means "any non-nullish value".
- If you want a type meaning "any object", you probably want `Record<string, unknown>` instead.
- If you want a type meaning "any value", you probably want `unknown` instead.
- If you want a type meaning "empty object", you probably want `Record<string, never>` instead.

Proof of that is that I can just write any type of value in the first param when the other params are filled, except null.

image

image

I am using the alpha version of the lib.

I have no idea on how to fix this, as I never saw that DocId type before.

@kossnocorp
Copy link
Owner

Fixed with v10

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