How to use the doctrine.parseType function in doctrine

To help you get started, we’ve selected a few doctrine examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jonschlinkert / parse-comments / test / parse.type.doctrine.js View on Github external
it('function type with name', () => {
      let type = doctrine.parseType('function(a)');
      assert.deepEqual(type, {
        type: 'FunctionType',
        params: [
          {
            type: 'NameExpression',
            name: 'a'
          }
        ],
        result: null
      });
    });
    it('function type with name and type', () => {
github jonschlinkert / parse-comments / test / parse.type.doctrine.js View on Github external
it('rest array type', () => {
      let type = doctrine.parseType('[string,...string]');
      assert.deepEqual(type, {
        elements: [
          {
            name: 'string',
            type: 'NameExpression'
          },
          {
            expression: {
              name: 'string',
              type: 'NameExpression'
            },
            type: 'RestType'
          }
        ],
        type: 'ArrayType'
      });
github jonschlinkert / parse-comments / test / parse.type.js View on Github external
it('should parse record types', () => {
      var fixture = '{ a: number, b: string }';
      assert.deepEqual(parse(fixture), doctrine.parseType(fixture));
      fixture = '{a: number, b: string}';
      assert.deepEqual(parse(fixture), doctrine.parseType(fixture));
      fixture = '{a: number, b: string, c}';
      assert.deepEqual(parse(fixture), doctrine.parseType(fixture));
      fixture = '{ a: number, b : string, c }';
      assert.deepEqual(parse(fixture), doctrine.parseType(fixture));
      fixture = '{ a : number, b : string, c }';
      assert.deepEqual(parse(fixture), doctrine.parseType(fixture));
    });
github jonschlinkert / parse-comments / test / parse.type.js View on Github external
it('should parse a type in parens', () => {
      assert.deepEqual(parse('(boolean)'), doctrine.parseType('(boolean)'));
      assert.deepEqual(parse('(Window)'), doctrine.parseType('(Window)'));
    });
github jonschlinkert / parse-comments / test / parse.type.doctrine.js View on Github external
it('boolean literal type', () => {
      let type = doctrine.parseType('true');
      assert.deepEqual(type, {
        type: 'BooleanLiteralType',
        value: true
      });
      type = doctrine.parseType('false');
      assert.deepEqual(type, {
        type: 'BooleanLiteralType',
        value: false
      });
    });
github jonschlinkert / parse-comments / test / parse.type.doctrine.js View on Github external
      assert.throws(() => doctrine.parseType('{0xd'), /unexpected token/);
      assert.throws(() => doctrine.parseType('{0x2_:'), /unexpected token/);
github jonschlinkert / parse-comments / test / parse.type.doctrine.js View on Github external
      assert.throws(() => doctrine.parseType('{0y'), /unexpected token/);
      assert.throws(() => doctrine.parseType('{0'), /unexpected token/);
github jonschlinkert / parse-comments / test / parse.type.doctrine.js View on Github external
      assert.throws(() => doctrine.parseType('{021:'), /unexpected token/);
      assert.throws(() => doctrine.parseType('{021_:'), /unexpected token/);
github jonschlinkert / parse-comments / test / parse.type.doctrine.js View on Github external
      assert.throws(() => doctrine.parseType('function(number=, string)'), /not reach to EOF/);
    });
github jscs-dev / jscs-jsdoc / lib / jsdoc-helpers.js View on Github external
function jsDocParseType (typeString) {
    var node;

    try {
        node = jsDocSimplifyNode(doctrineParser.parseType(typeString));
    } catch (e) {
        node = [];
        node.invalid = true;
    }

    return node;
}