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

Error parsing the jsdoc type expression "{number| {function(row?:any,index?:number): number}}" #221

Open
dalelotts opened this issue May 18, 2017 · 7 comments

Comments

@dalelotts
Copy link

dalelotts commented May 18, 2017

I'm trying to document a property that returns a number or a function - this seems to work with pure jsdocs but not here

* @type {number|function(row?:any,index?:number): number}

The property is defined as follows.
@Input() rowHeight: (number | ((row?: any, index?: number) => number)) = 0;

If I removing the ?'s it works, but I believe they will no longer appear as optional parameters.

Any suggestions on how we can work around this?

@petebacondarwin
Copy link
Member

@dalelotts - can you give me a bit more information. Is it the @type tag that is not working? What is being output?

@petebacondarwin
Copy link
Member

The library we use to parse the types is https://github.com/hegemonic/catharsis
Perhaps this doesn't support this notation?

@dalelotts
Copy link
Author

dalelotts commented May 19, 2017

Call stack here:

Error: Error parsing the jsdoc type expression "{number|function(row?:any,index?:number): number}"
    at /Users/dale.lotts/dev/vdl-angular/node_modules/dgeni-packages/jsdoc/services/transforms/extract-type.js:56:15
    at /Users/dale.lotts/dev/vdl-angular/node_modules/dgeni-packages/jsdoc/processors/extract-tags.js:166:19
    at arrayEach (/Users/dale.lotts/dev/vdl-angular/node_modules/lodash/lodash.js:537:11)
    at Function.forEach (/Users/dale.lotts/dev/vdl-angular/node_modules/lodash/lodash.js:9359:14)
    at /Users/dale.lotts/dev/vdl-angular/node_modules/dgeni-packages/jsdoc/processors/extract-tags.js:165:11
    at Object.tagDef.getProperty (/Users/dale.lotts/dev/vdl-angular/node_modules/dgeni-packages/jsdoc/processors/extract-tags.js:54:17)
    at readTags (/Users/dale.lotts/dev/vdl-angular/node_modules/dgeni-packages/jsdoc/processors/extract-tags.js:138:22)
    at /Users/dale.lotts/dev/vdl-angular/node_modules/dgeni-packages/jsdoc/processors/extract-tags.js:86:11
    at arrayEach (/Users/dale.lotts/dev/vdl-angular/node_modules/lodash/lodash.js:537:11)
    at Function.forEach (/Users/dale.lotts/dev/vdl-angular/node_modules/lodash/lodash.js:9359:14)
    at tagExtractor (/Users/dale.lotts/dev/vdl-angular/node_modules/dgeni-packages/jsdoc/processors/extract-tags.js:65:9)

@petebacondarwin
Copy link
Member

OK, I'll take a look...

@petebacondarwin
Copy link
Member

Right! I can reproduce this in a unit test. It look like catharsis does not like this syntax...

@petebacondarwin
Copy link
Member

@dalelotts - it seems that you are using an invalid syntax. The correct syntax should not include the parameter names. For example the following test passes in dgeni-packages:

  it('should handle optional function params', function() {
    value = '{number|function(?any,?number): number} some description';
    value = transform(doc, tag, value);
    expect(tag.typeList).toEqual([ 'number', 'function(?any, ?number): number' ]);
  });

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

2 participants