kossnocorp / typesaurus

🦕 Type-safe TypeScript-first ODM for Firestore
https://typesaurus.com
415 stars 36 forks source link

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

Closed SrBrahma closed 6 months ago

SrBrahma commented 3 years ago

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

SrBrahma commented 3 years ago

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 commented 6 months ago

Fixed with v10