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

allow decorator return function with different returnType #59008

Closed
6 tasks done
LongTengDao opened this issue Jun 25, 2024 · 2 comments
Closed
6 tasks done

allow decorator return function with different returnType #59008

LongTengDao opened this issue Jun 25, 2024 · 2 comments

Comments

@LongTengDao
Copy link
Contributor

πŸ” Search Terms

decorator

βœ… Viability Checklist

⭐ Suggestion

use decorator like higher-order function

πŸ“ƒ Motivating Example

function co<T> (method :() => Generator<void, T, void>, context :ClassMethodDecoratorContext) {
    return function () :T {
        const generator = method();
        let result;
        while ( !( result = generator.next() ).done ) ) {}
        return result.value;
    };
}

class X {
    @co
    * method () { return 1; }
}
function reiterable<T> (method :() => Generator<T, void, void>, context :ClassMethodDecoratorContext) {
    return function () :Iterable<T> {
        return { [Symbol.iterator]: method };
    };
}

class X {
    @reiterable
    * method () { yield 1; }
}

πŸ’» Use Cases

  1. What do you want to use this for?
  2. What shortcomings exist with current approaches?
  3. What workarounds are you using in the meantime?
@MartinJohns
Copy link
Contributor

You will have better success with your issue if you fill out the issue template.

@andrewbranch
Copy link
Member

To expedite the triage process, we need everyone to follow the issue template and instructions.

When you clicked "Create New Issue", the issue form was pre-populated with a template and some instructions. We need you to read those instructions completely, follow them, and then fill in all the fields in that template.

We are not able to assist with issues that don't follow the template instructions as they represent a significantly larger amount of work compared to issues which are correctly specified. Thank you for understanding.

@andrewbranch andrewbranch closed this as not planned Won't fix, can't repro, duplicate, stale Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants