patmood / pocketbase-typegen

Typescript generation for pocketbase records
https://www.npmjs.com/package/pocketbase-typegen
541 stars 20 forks source link

View Collections with ID field only returns never #97

Open Aragur opened 9 months ago

Aragur commented 9 months ago

Describe the bug My view collection has only an ID field, as this returns a public count of entries. This was generated by typegen:

export type MainDataCountResponse<Texpand = unknown> = Required<MainDataCountRecord> & BaseSystemFields<Texpand>;

Accessing the ID field doesn't work with following error:

[{
    "owner": "typescript",
    "code": "2339",
    "severity": 8,
    "message": "Property 'id' does not exist on type 'never'.",
    "source": "ts"
}]

Versions pocketbase-typegen version: 1.2.1 pocketbase version: 0.21.1

wojtekgalaj commented 8 months ago

I think in general the id field needs to be added to all the collection types.

patmood commented 8 months ago

@Aragur could you provide steps to reproduce this? Eg what is the query for your view collection? Could you also provide the generated type definition for MainDataCountRecord?

id is already part of BaseSystemFields so it should be part of all responses.