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

[api-extractor] classify arrow functions as functions #1629

Open
1 of 2 tasks
postspectacular opened this issue Nov 17, 2019 · 8 comments
Open
1 of 2 tasks

[api-extractor] classify arrow functions as functions #1629

postspectacular opened this issue Nov 17, 2019 · 8 comments
Labels
effort: medium Needs a somewhat experienced developer enhancement The issue is asking for a new feature or design change help wanted If you're looking to contribute, this issue is a good place to start!

Comments

@postspectacular
Copy link

Is this a feature or a bug?

  • Feature
  • Bug

Please describe the actual behavior.

This is a feature request to classify exported arrow functions as functions rather than variables. Even though syntactically the latter is the case, semantically (for documentation & usage purposes) this doesn't make any sense - and worse - it invalidates any documentation effort in the docstrings related to parameter descriptions, return types etc.

The current behavior creates a situation where the doc toolchain implicitly discourages the use of public arrow functions. My entire mono-repo (100+ packages) is largely using arrow functions and as much as I like the API extractor approach, this current behavior is more or less a showstopper. I also can't imagine that this will bite a lot of other projects...

Related, I'd also like to propose that const symbols are not classified as "variable", but at least as "constant"...

If for whatever reason a reclassification of arrow functions as "function" is not possible, then please consider supporting a form of @kind tag to allow manual classification, e.g. @kind function, which then should override the inferred kind.

What is the expected behavior?

Public, exported arrow functions in the form below are extracted & classified as functions, with all that entails.

/**
 * Returns true if the first items of `buf` are the same items as in
 * `needle`.
 *
 * @remarks
 * This means `buf` should have at least the same length as `needle` for
 * this to be true.
 *
 * By default, uses {@link @thi.ng/equiv#equiv} for equality checking.
 *
 * {@link endsWith}
 *
 * @param buf - array to search
 * @param needle - search value
 * @param equiv - equality predicate
 */
export const startsWith = (
    buf: ArrayLike<any>,
    needle: ArrayLike<any>,
    equiv = _eq
) => {
    let i = buf.length;
    let j = needle.length;
    if (i < j) return false;
    while (-j >= 0 && equiv(buf[j], needle[j])) {}
    return j < 0;
};

If this is a bug, please provide the tool version, Node.js version, and OS.

  • Tool: api-extractor
  • Tool Version: 7.5.6
  • Node Version: 12.10.0
    • Is this a LTS version? no
    • Have you tested on a LTS version? no
  • OS: OSX 10.14
@octogonz
Copy link
Collaborator

This is a good proposal. @postspectacular are you able to help implement it?

@octogonz octogonz added the enhancement The issue is asking for a new feature or design change label Nov 17, 2019
@postspectacular
Copy link
Author

@octogonz thank you! i can't say yet if i can help w/ that - just haven't really looked through the source yet. will keep you posted!

@octogonz octogonz added effort: medium Needs a somewhat experienced developer help wanted If you're looking to contribute, this issue is a good place to start! labels Nov 18, 2019
@octogonz
Copy link
Collaborator

FYI there's some general instructions in the Contributing doc.

If you don't have time, let me know. I might be able to help, although I've been pretty busy with microsoft/tsdoc#196 this week since we're trying to roll out eslint-plugin-tsdoc in our repo.

@JamesBurnside
Copy link
Member

Would the best solution for this be to create a new @kind tag or identify and classify exported arrow functions as functions rather than variables?

I see value in a @kind tag as we have a series of React functional components and it would be nice to categorize them as such and separate from other exported functions.

@cary-hu
Copy link

cary-hu commented Nov 3, 2021

+1 for this issue

any update for arrow function parameter?

@EveChee
Copy link

EveChee commented Jul 20, 2022

Hi,where are we on this issue so far?

@octogonz
Copy link
Collaborator

We need a volunteer to implement it

@bartvandenende-wm
Copy link
Contributor

this should be resolved in @microsoft/api-extractor v7.40.0

@github-project-automation github-project-automation bot moved this to Needs triage in Bug Triage Feb 26, 2024
@iclanton iclanton moved this from Needs triage to AE/AD in Bug Triage Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort: medium Needs a somewhat experienced developer enhancement The issue is asking for a new feature or design change help wanted If you're looking to contribute, this issue is a good place to start!
Projects
Status: AE/AD
Development

No branches or pull requests

6 participants