Skip to content
New issue

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

Activity log function return value type mismatch #9204

Open
bwmirek opened this issue Sep 19, 2024 · 1 comment
Open

Activity log function return value type mismatch #9204

bwmirek opened this issue Sep 19, 2024 · 1 comment

Comments

@bwmirek
Copy link

bwmirek commented Sep 19, 2024

Describe the bug

The activity method in the Logger interface is expected to return void based on the provided TypeScript signature, but in the actual implementation, it returns an id. This mismatch causes a TypeScript error when attempting to use the return value of the activity method, despite following the documentation.

Example code:

const activity = logger.activity("Preparing data for JSON output...") // Warning: Void function return value is used

Expected behavior

The activity method should return an id based on the implementation. The TypeScript signature should be updated to reflect this.

Code snippets
The current Logger type signature:

export type Logger = {
    panic: (data: any) => void;
    shouldLog: (level: string) => void;
    setLogLevel: (level: string) => void;
    unsetLogLevel: () => void;
    activity: (message: string, config?: any) => void; // This should be updated to return an id
    progress: (activityId: any, message: any) => void;
    error: (messageOrError: any, error?: any) => void;
    failure: (activityId: any, message: any) => void;
    success: (activityId: any, message: any) => void;
    debug: (message: any) => void;
    info: (message: any) => void;
    warn: (message: any) => void;
    log: (...args: any[]) => void;
};

Additional context

The activity method is clearly returning an id, but the TypeScript signature in the Logger type indicates it returns void. This mismatch causes a TypeScript warning when using the return value of the activity method, despite it following the documented behavior. The expected fix would be to update the Logger type to reflect that activity returns a string (or any other appropriate type).

@olivermrbl
Copy link
Contributor

Nice catch, would you be up for sending a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants