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

add filterProperty to getTypeDocumentation #21

Merged
merged 1 commit into from
Jun 12, 2024
Merged

Conversation

souporserious
Copy link
Owner

This adds the ability to filter specific properties in getTypeDocumentation by passing a custom filter. Take the following source file:

import * as React from 'react';

type ButtonVariant = 'primary' | 'secondary' | 'danger';

type ButtonProps = {
  variant?: ButtonVariant;
} & React.ButtonHTMLAttributes<HTMLButtonElement>

export const Button = (props: ButtonProps) => {
  return <button {...props} />
};

When processing documentation from this source file, a filter can now be provided to allow specific properties from node_modules to be processed for documentation:

const types = getTypeDocumentation(
  sourceFile.getVariableDeclarationOrThrow('Button'),
  (property) => {
    if (property.getName() === 'onClick') {
      return true
    }
    return !property.getSourceFile().isInNodeModules()
  }
)

Copy link

vercel bot commented Jun 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
tsxmod ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 12, 2024 4:39pm

Copy link

changeset-bot bot commented Jun 12, 2024

🦋 Changeset detected

Latest commit: 5f988c6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@tsxmod/utils Minor
tsxmod Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@souporserious souporserious merged commit 9675822 into main Jun 12, 2024
3 checks passed
@souporserious souporserious deleted the filter-property branch June 12, 2024 16:42
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

Successfully merging this pull request may close these issues.

1 participant