Skip to content

Discuss: Replace implicit return type with explicit and void return? #38

@tlancina

Description

@tlancina

Right now many of the wrapper functions return something along the lines of:

    // This Promise is replaced by one from the @Cordova decorator that wraps
    // the plugin's callbacks. We provide a dummy one here so TypeScript
    // knows that the correct return type is Promise, because there's no way
    // for it to know the return type from a decorator.
    // See https://github.com/Microsoft/TypeScript/issues/4881
    return new Promise<any>((res, rej) => {});

With the intention to reduce confusion about the decorator magic that is happening to change the return type. But I'm wondering if we just add the return type and a void return, so each wrapper looks more like an interface:

  @Cordova()
  static show(options?: {
    buttonLabels: string[],
    title?: string,
    androidTheme?: number,
    androidEnableCancelButton?: boolean,
    winphoneEnableCancelButton?: boolean,
    addCancelButtonWithLabel?: string,
    addDestructiveButtonWithLabel?: string,
    position?: number[]
  }) : Promise<any> { return }


  /**
   * Hide the ActionSheet.
   */
  @Cordova()
  static hide() : Promise<any> { return }

Seems a bit cleaner, @ihadeed thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions