Skip to content

Wrong "func" type in "browser.scripting" API #46

@Juraj-Masiar

Description

@Juraj-Masiar

Hello,
First, thank you for new update!

I've checked it in all my projects and found only one issue:

declare namespace browser.scripting {
  func?: () => void | undefined;

The function type func?: () => void | undefined; should be probably func?: (...args: any) => any;.
The first issue is the arguments - the function will be called with arguments based on the "args" property in the interface ScriptInjection.
Second issue is the return type, function can return a value which is then used in the "InjectionResult" here:

    interface InjectionResult {
        /** The frame ID associated with the injection. */
        frameId: number;
        /** The result of the script execution. */
        result?: any;
        /**
         * The error property is set when the script execution failed. The value is typically an (Error) object with a message property, but could be any value (including primitives and undefined) if the script threw or rejected with such a value.
         */
        error?: any;
    }

In ideal world one would use generics instead of any, but I guess it's ok to keep it simple for now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions