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

JSDoc Parser breaks with a complex @pattern tag #18273

Open
egandro opened this issue Sep 6, 2017 · 6 comments · May be fixed by #59903
Open

JSDoc Parser breaks with a complex @pattern tag #18273

egandro opened this issue Sep 6, 2017 · 6 comments · May be fixed by #59903
Labels
Bug A bug in TypeScript Domain: JSDoc Relates to JSDoc parsing and type generation Help Wanted You can do this
Milestone

Comments

@egandro
Copy link

egandro commented Sep 6, 2017

TypeScript Version: 2.5.2

Code

  /**
   * @pattern ^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$
   */
  public emailPattern: string;

Expected behavior:
expected '^[a-zA-Z0-9_.+-]+' to equal '^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$'

Actual behavior:

This is parsed -^[a-zA-Z0-9_.+-]+
This is expected +^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$

Maybe I am doing something stupid or the parser is broken.

@sandersn sandersn changed the title JS Doc Parser is semibroken JSDoc Parser breaks with a complex @pattern tag Sep 6, 2017
@mhegazy mhegazy added Bug A bug in TypeScript Domain: JSDoc Relates to JSDoc parsing and type generation labels Sep 6, 2017
@mhegazy mhegazy added this to the TypeScript 2.6 milestone Sep 6, 2017
@gregjacobs
Copy link

I guess the parser should wait for a line break before interpreting another @ char as a new jsDoc tag?

@egandro
Copy link
Author

egandro commented Sep 19, 2017

If you guys fix this. You might try the even more complex patten from here:

http://emailregex.com/

/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/

@mhegazy mhegazy added the Help Wanted You can do this label Oct 10, 2017
@mhegazy mhegazy modified the milestones: TypeScript 2.7, Community Oct 10, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Oct 10, 2017

We should special case parsing of pattern tags to parse text till end of line instead of till next tag.

PRs welcomed

@sandersn
Copy link
Member

By the way, where is the @pattern tag is commonly used? I couldn't find anything on usejsdoc or the closure docs, and google failed me completely -- this issue is invariably in the top 10 hits.

@egandro
Copy link
Author

egandro commented Oct 10, 2017

Yes it is!

I use jsDoc tags for creating swagger files.

Swagger has "pattern" as validator.

If you want to validate an email adress - you have to use pattern and a "complex" pattern :)

@egandro
Copy link
Author

egandro commented Jun 2, 2018

ping?

@RyanCavanaugh RyanCavanaugh modified the milestones: Community, Backlog Mar 7, 2019
@Andarist Andarist linked a pull request Sep 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: JSDoc Relates to JSDoc parsing and type generation Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants