Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit c281a69f authored by Danny Lin's avatar Danny Lin
Browse files

Add return types from JSDoc

This fixes a warning in Visual Studio Code's TypeScript integration:
"JSDoc types may be moved to TypeScript types.  ts(80004)"
parent 4a8eec8d
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -279,7 +279,7 @@ export class FastbootDevice {
     * @returns {Promise<CommandResponse>} Object containing response text and data size, if any.
     * @throws {FastbootError}
     */
    private async readResponse() {
    private async readResponse(): Promise<CommandResponse> {
        let respData = {} as CommandResponse;
        let respStatus;

@@ -318,7 +318,7 @@ export class FastbootDevice {
     * @returns {Promise<CommandResponse>} Object containing response text and data size, if any.
     * @throws {FastbootError}
     */
    async runCommand(command: string) {
    async runCommand(command: string): Promise<CommandResponse> {
        // Command and response length is always 64 bytes regardless of protocol
        if (command.length > 64) {
            throw new RangeError();
@@ -340,7 +340,7 @@ export class FastbootDevice {
     * @returns {Promise<string>} Textual content of the variable.
     * @throws {FastbootError}
     */
    async getVariable(varName: string) {
    async getVariable(varName: string): Promise<string | null> {
        let resp;
        try {
            resp = (
@@ -372,7 +372,7 @@ export class FastbootDevice {
     * @returns {Promise<number>}
     * @throws {FastbootError}
     */
    private async getDownloadSize() {
    private async getDownloadSize(): Promise<number> {
        try {
            let resp = (
                await this.getVariable("max-download-size")
@@ -476,7 +476,7 @@ export class FastbootDevice {
     * @param {boolean} wait - Whether to wait for the device to reconnect.
     * @param {ReconnectCallback} onReconnect - Callback to request device reconnection, if wait is enabled.
     */
    async reboot(target = "", wait = false, onReconnect = () => {}) {
    async reboot(target: string = "", wait: boolean = false, onReconnect: ReconnectCallback = () => {}) {
        if (target.length > 0) {
            await this.runCommand(`reboot-${target}`);
        } else {
+2 −2
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ export interface SparseChunk {
 * @param {ArrayBuffer} buffer - Raw file header data.
 * @returns {SparseHeader} Object containing the header information.
 */
export function parseFileHeader(buffer: ArrayBuffer) {
export function parseFileHeader(buffer: ArrayBuffer): SparseHeader | null {
    let view = new DataView(buffer);

    let magic = view.getUint32(0, true);
@@ -171,7 +171,7 @@ function createImage(header: SparseHeader, chunks: Array<SparseChunk>) {
 * @param {ArrayBuffer} rawBuffer - Buffer containing the raw image data.
 * @returns {ArrayBuffer} Buffer containing the new sparse image.
 */
export function fromRaw(rawBuffer: ArrayBuffer) {
export function fromRaw(rawBuffer: ArrayBuffer): ArrayBuffer {
    let header = {
        blockSize: 4096,
        blocks: rawBuffer.byteLength / 4096,