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

Can be generated from a difinition file? #814

Open
xiaosen7 opened this issue Jul 4, 2023 · 3 comments
Open

Can be generated from a difinition file? #814

xiaosen7 opened this issue Jul 4, 2023 · 3 comments

Comments

@xiaosen7
Copy link

xiaosen7 commented Jul 4, 2023

No description provided.

@xiaosen7 xiaosen7 changed the title Can be generated from a type declaration file Can be generated from a type declaration file? Jul 4, 2023
@danez
Copy link
Collaborator

danez commented Jul 4, 2023

Do you have an example?

@xiaosen7
Copy link
Author

xiaosen7 commented Jul 7, 2023

Do you have an example?

import { parse } from "react-docgen";

const code = `
import React from "react";
export interface Props {
  /** desc for prop1 */
  prop1: string;
}
export declare function FunctionDeclarationComponent(props: Props): JSX.Element;
`;

const documentation = parse(code, {
  babelOptions: {},
});

console.log(documentation);

I tried this, but got an error:

SyntaxError: unknown: Unexpected token, expected "{" (7:7)

  5 |   prop1: string;
  6 | }
> 7 | export declare function FunctionDeclarationComponent(props: Props): JSX.Element;
code: 'BABEL_PARSE_ERROR',
  reasonCode: 'UnexpectedToken',
  loc: Position { line: 7, column: 7, index: 103 },
  pos: [Getter/Setter]
}

@xiaosen7 xiaosen7 changed the title Can be generated from a type declaration file? Can be generated from a difinition file? Jul 7, 2023
@mryechkin
Copy link

Hi @xiaosen7 - did you ever end up finding a solution to this? I'm also getting the same error and trying to do the same.

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