You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve the DX when writing RxJsonSchema files in TypeScript.
Info
Environment: NodeJS v12
Stack: Typescript
Code
Before:
exportdeclareclassRxJsonSchema{title?: string;description?: string;version: number;/** * TODO this looks like a typescript-bug * we have to allows all string because the 'object'-literal is not recognized * retry this in later typescript-versions */type: 'object'|string;properties: {[key: string]: RxJsonSchemaTopLevel};required?: string[];compoundIndexes?: string[]|string[][];keyCompression?: boolean;/** * if not set, rxdb will set 'false' as default */additionalProperties?: boolean;attachments?: {encrypted?: boolean};}
after:
exportdeclareclassRxJsonSchema<T>{title?: string;description?: string;version: number;/** * TODO this looks like a typescript-bug * we have to allows all string because the 'object'-literal is not recognized * retry this in later typescript-versions */type: 'object'|string;properties: {[keyinkeyofT]: RxJsonSchemaTopLevel};required?: [keyofT];compoundIndexes?: string[]|string[][];keyCompression?: boolean;/** * if not set, rxdb will set 'false' as default */additionalProperties?: boolean;attachments?: {encrypted?: boolean;};}
Hi @phil-lgr
I understand your usecase and I think this is a good proposal.
But I think it should be RxJsonSchema<T = any> so that it does not crash when T is not provided.
Can you create a PR for this?
Hint: There are some tests for the typings here which can be run via npm run test:typings
Case
Improvement to
class RxJsonSchema
Issue
Improve the DX when writing RxJsonSchema files in TypeScript.
Info
Code
Before:
after:
Usage example:
so you get type checking on the
properties
Any thoughts?
The text was updated successfully, but these errors were encountered: