From d2b8167133ffb052a5f893dd41d557fb34489d4c Mon Sep 17 00:00:00 2001 From: Felipe Castillo <1280530+fcastilloec@users.noreply.github.com> Date: Mon, 2 Mar 2020 09:31:42 -0800 Subject: [PATCH] [teslajs] fix wrong Vehicle interface (#42724) * [teslajs] fix wrong Vehicle interface * [teslajs] Fix async functions parameters --- types/teslajs/index.d.ts | 44 +++++++++++++++++----------------- types/teslajs/teslajs-tests.ts | 2 ++ 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/types/teslajs/index.d.ts b/types/teslajs/index.d.ts index c9e6e79290..43ee8748f2 100644 --- a/types/teslajs/index.d.ts +++ b/types/teslajs/index.d.ts @@ -4,9 +4,9 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export interface Vehicle { - response: object; id: string; vehicleID: number; + [key: string]: string | number | boolean | null; } export interface TokenResponse { response: object; @@ -67,7 +67,7 @@ export function logoutAsync(authToken: string): Promise; export function vehicle(options: optionsType, callback: nodeBack): Vehicle; export function vehicleAsync(options: optionsType): Promise; export function vehicles(options: optionsType, callback: nodeBack): void; -export function vehiclesAsync(options: optionsType): Promise; +export function vehiclesAsync(options: optionsType): Promise>; export function get_command(options: optionsType, command: string, callback: nodeBack): void; export function get_commandAsync(options: optionsType, command: string): Promise; export function post_command(options: optionsType, command: string, body: object, callback: nodeBack): void; @@ -107,7 +107,7 @@ export function scheduleSoftwareUpdateAsync(options: optionsType): Promise; export function navigationRequest(options: optionsType, subject: string, text: string, locale: string, callback: any): any; -export function navigationRequestAsync(options: optionsType): Promise; +export function navigationRequestAsync(options: optionsType, subject: string, text: string, locale: string): Promise; export function mediaTogglePlayback(options: optionsType, callback: any): any; export function mediaTogglePlaybackAsync(options: optionsType): Promise; export function mediaPlayNext(options: optionsType, callback: any): any; @@ -123,25 +123,25 @@ export function mediaVolumeUpAsync(options: optionsType): Promise; export function mediaVolumeDown(options: optionsType, callback: any): any; export function mediaVolumeDownAsync(options: optionsType): Promise; export function speedLimitActivate(options: optionsType, pin: number, callback: any): any; -export function speedLimitActivateAsync(options: optionsType): Promise; +export function speedLimitActivateAsync(options: optionsType, pin: number): Promise; export function speedLimitDeactivate(options: optionsType, pin: number, callback: any): any; -export function speedLimitDeactivateAsync(options: optionsType): Promise; +export function speedLimitDeactivateAsync(options: optionsType, pin: number): Promise; export function speedLimitClearPin(options: optionsType, pin: number, callback: any): any; -export function speedLimitClearPinAsync(options: optionsType): Promise; +export function speedLimitClearPinAsync(options: optionsType, pin: number): Promise; export function speedLimitSetLimit(options: optionsType, limit: number, callback: any): any; -export function speedLimitSetLimitAsync(options: optionsType): Promise; +export function speedLimitSetLimitAsync(options: optionsType, limit: number): Promise; export function setSentryMode(options: optionsType, onoff: boolean, callback: any): any; -export function setSentryModeAsync(options: optionsType): Promise; +export function setSentryModeAsync(options: optionsType, onoff: boolean): Promise; export function seatHeater(options: optionsType, heater: number, level: number, callback: any): any; -export function seatHeaterAsync(options: optionsType): Promise; +export function seatHeaterAsync(options: optionsType, heater: number, level: number): Promise; export function steeringHeater(options: optionsType, level: number, callback: any): any; -export function steeringHeaterAsync(options: optionsType): Promise; +export function steeringHeaterAsync(options: optionsType, level: number): Promise; export function maxDefrost(options: optionsType, onoff: boolean, callback: any): any; -export function maxDefrostAsync(options: optionsType): Promise; +export function maxDefrostAsync(options: optionsType, onoff: boolean): Promise; export function windowControl(options: optionsType, command: string, callback: any): any; -export function windowControlAsync(options: optionsType): Promise; +export function windowControlAsync(options: optionsType, command: string): Promise; export function setChargeLimit(options: optionsType, amt: any, callback: nodeBack): void; -export function setChargeLimitAsync(options: optionsType): Promise; +export function setChargeLimitAsync(options: optionsType, amt: any): Promise; export function chargeStandard(options: optionsType, callback: nodeBack): void; export function chargeStandardAsync(options: optionsType): Promise; export function chargeMaxRange(options: optionsType, callback: nodeBack): void; @@ -155,24 +155,24 @@ export function climateStartAsync(options: optionsType): Promise; export function climateStop(options: optionsType, callback: nodeBack): void; export function climateStopAsync(options: optionsType): Promise; export function sunRoofControl(options: optionsType, state: string, callback: nodeBack): void; -export function sunRoofControlAsync(options: optionsType): Promise; +export function sunRoofControlAsync(options: optionsType, state: string): Promise; export function sunRoofMove(options: optionsType, percent: any, callback: nodeBack): void; -export function sunRoofMoveAsync(options: optionsType): Promise; +export function sunRoofMoveAsync(options: optionsType, percent: any): Promise; export function setTemps(options: optionsType, driver: number, pass: number, callback: nodeBack): void; -export function setTempsAsync(options: optionsType): Promise; +export function setTempsAsync(options: optionsType, driver: number, pass: number): Promise; export function remoteStart(options: optionsType, password: string, callback: nodeBack): void; -export function remoteStartAsync(options: optionsType): Promise; +export function remoteStartAsync(options: optionsType, password: string): Promise; export function openTrunk(options: optionsType, which: string, callback: nodeBack): void; -export function openTrunkAsync(options: optionsType): Promise; +export function openTrunkAsync(options: optionsType, which: string): Promise; export function wakeUp(options: optionsType, callback: nodeBack): void; export function wakeUpAsync(options: optionsType): Promise; export function setValetMode(options: optionsType, onoff: boolean, pin: any, callback: nodeBack): void; -export function setValetModeAsync(options: optionsType): Promise; +export function setValetModeAsync(options: optionsType, onoff: boolean, pin: any): Promise; export function resetValetPin(options: optionsType, callback: nodeBack): void; export function resetValetPinAsync(options: optionsType): Promise; export function calendar(options: optionsType, entry: any, callback: nodeBack): void; -export function calendarAsync(options: optionsType): Promise; +export function calendarAsync(options: optionsType, entry: any): Promise; export function makeCalendarEntry(eventName: string, location: string, startTime: number, endTime: number, accountName: string, phoneName: string): object; -export function homelink(options: optionsType, lat: number, long: number, token: any, callback: nodeBack): void; -export function homelinkAsync(options: optionsType): Promise; +export function homelink(options: optionsType, lat: number, long: number, token: string, callback: nodeBack): void; +export function homelinkAsync(options: optionsType, lat: number, long: number, token: string): Promise; export function startStreaming(options: any, callback: nodeBack, onDataCb: nodeBack): any; diff --git a/types/teslajs/teslajs-tests.ts b/types/teslajs/teslajs-tests.ts index 0f79c2d910..8000cb18d0 100644 --- a/types/teslajs/teslajs-tests.ts +++ b/types/teslajs/teslajs-tests.ts @@ -6,8 +6,10 @@ async function main() { tjs.login('username', 'password', (err, result) => { const token = result.authToken; }); + const vehicle = await tjs.vehicleAsync(options); const vehicleData = await tjs.vehicleDataAsync(options); const chargeState = await tjs.chargeStateAsync(options); + await tjs.homelinkAsync(options, 36.98765432109876, -77.12345678901234, 'token'); } main();