We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Below is the .d.ts types that I use. I'm a newbie with TS, so, maybe is a better way to write it.
.d.ts
declare module "vue-api-query" { import { AxiosInstance, AxiosRequestConfig, AxiosPromise } from "axios"; type ThisClass<InstanceType extends Model> = { new (...args: any[]): InstanceType; }; type Constructor<T> = new (...args: any[]) => T; interface Class<T> { super(...args: any[]): T; } export class Model { constructor(...args: any[]); super: Constructor<this>; static $http: AxiosInstance; $http: AxiosInstance; mutations?: object; /** * Settings */ endpoint(): string; resource(): string; primaryKey(): string; getPrimaryKey(): string; baseURL(): string; request(config: AxiosRequestConfig): AxiosPromise<any>; _from(url: string): void; /** * Query */ append<T extends Model>(this: ThisClass<T>, ...args: any[]): T; custom<T extends Model>(this: ThisClass<T>, ...args: any[]): T; include<T extends Model>(this: ThisClass<T>, ...args: any[]): T; select<T extends Model>(this: ThisClass<T>, ...args: any[]): T; orderBy<T extends Model>(this: ThisClass<T>, ...args: any[]): T; where<T extends Model>(this: ThisClass<T>, field: string, value: any): T; whereIn<T extends Model>( this: ThisClass<T>, field: string, array: any[] ): T; limit<T extends Model>(this: ThisClass<T>, value: number): T; page<T extends Model>(this: ThisClass<T>, value: number): T; params<T extends Model>(this: ThisClass<T>, payload: object): T; for<T extends Model>(this: ThisClass<T>, ...args: any[]): T; hasMany<T>(model: T): T; /** * Results */ $find(identifier: number | string): any; $first(): any; $get(): any; find<T extends Model>( this: ThisClass<T>, identifier: number | string ): Promise<T>; first<T extends Model>(this: ThisClass<T>): Promise<T>; get<T extends Model>(this: ThisClass<T>): Promise<T[]>; delete(): Promise<any>; save<T extends Model>(this: ThisClass<T>): Promise<T>; attach(params: object): Promise<any>; sync(params: object): Promise<any>; /** * Helpers */ hasId(): boolean; isValidId(id: any): boolean; parameterNames(): any; static $find(id: number | string): any; static $first(): any; static $get(): any; static append<T extends Model>(this: ThisClass<T>, ...args: any[]): T; static custom<T extends Model>(this: ThisClass<T>, ...args: any[]): T; static find(id: number | string): Model; static first<T extends Model>(this: ThisClass<T>): T; static get(): any; static include(...args: any[]): Model; static instance<T extends Model>(this: ThisClass<T>): T; static limit(value: any): Model; static orderBy(...args: any[]): Model; static page(value: any): Model; static params<T extends Model>(this: ThisClass<T>, payload: object): T; static select<T extends Model>(this: ThisClass<T>, ...args: any[]): T; static where<T extends Model>( this: ThisClass<T>, field: string, value: any ): T; static whereIn<T extends Model>( this: ThisClass<T>, field: string, array: any[] ): T; } }
The text was updated successfully, but these errors were encountered:
Thanks again @alvaro-canepa !
For now, i am not intend to provide official typescript support. I am closing it for now, but will keep it for future reference.
Sorry, something went wrong.
feat: add typescript support (#168)
1d8122f
Based on #104 by @alvaro-canepa
No branches or pull requests
Below is the
.d.ts
types that I use.I'm a newbie with TS, so, maybe is a better way to write it.
The text was updated successfully, but these errors were encountered: