Comparison of the type parsing results from [catharsis][], [doctrine][], and [parse-comments][].
(This document is generated by running $ node docs/comparisons
on the docs/comparisons.js file. Please update that file if you wish to add fixtures or another library to the comparisons.)
Fixture
('public'|'protected'|'private')
Result
// parse-comments
{ type: 'UnionType',
elements:
[ { type: 'StringLiteralType', value: 'public' },
{ type: 'StringLiteralType', value: 'protected' },
{ type: 'StringLiteralType', value: 'private' } ] }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'StringLiteralType', value: 'public' },
{ type: 'StringLiteralType', value: 'protected' },
{ type: 'StringLiteralType', value: 'private' } ] }
// catharsis
// N/A (throws parse error)
Fixture
{'ok':String}
Result
// parse-comments
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: 'ok',
value: { type: 'NameExpression', name: 'String' } } ] }
// doctrine
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: 'ok',
value: { type: 'NameExpression', name: 'String' } } ] }
// catharsis
// N/A (throws parse error)
Fixture
{0X2:String, 0:Number, 100e200, 10e-20:Number}
Result
// parse-comments
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: '2',
value: { type: 'NameExpression', name: 'String' } },
{ type: 'FieldType',
key: '0',
value: { type: 'NameExpression', name: 'Number' } },
{ type: 'FieldType', key: '1e+202', value: null },
{ type: 'FieldType',
key: '1e-19',
value: { type: 'NameExpression', name: 'Number' } } ] }
// doctrine
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: '2',
value: { type: 'NameExpression', name: 'String' } },
{ type: 'FieldType',
key: '0',
value: { type: 'NameExpression', name: 'Number' } },
{ type: 'FieldType', key: '1e+202', value: null },
{ type: 'FieldType',
key: '1e-19',
value: { type: 'NameExpression', name: 'Number' } } ] }
// catharsis
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: { type: 'NameExpression', name: '0X2:String' },
value: undefined },
{ type: 'FieldType',
key: { type: 'NameExpression', name: '0:Number' },
value: undefined },
{ type: 'FieldType',
key: { type: 'NameExpression', name: '100e200' },
value: undefined },
{ type: 'FieldType',
key: { type: 'NameExpression', name: '10e-20:Number' },
value: undefined } ] }
Fixture
!Object
Result
// parse-comments
{ type: 'NonNullableType',
expression: { type: 'NameExpression', name: 'Object' },
prefix: true }
// doctrine
{ type: 'NonNullableType',
expression: { type: 'NameExpression', name: 'Object' },
prefix: true }
// catharsis
{ type: 'NameExpression', name: 'Object', nullable: false }
Fixture
!string
Result
// parse-comments
{ type: 'NonNullableType',
expression: { type: 'NameExpression', name: 'string' },
prefix: true }
// doctrine
{ type: 'NonNullableType',
expression: { type: 'NameExpression', name: 'string' },
prefix: true }
// catharsis
{ type: 'NameExpression', name: 'string', nullable: false }
Fixture
"Hello, World"
Result
// parse-comments
{ type: 'StringLiteralType', value: 'Hello, World' }
// doctrine
{ type: 'StringLiteralType', value: 'Hello, World' }
// catharsis
// N/A (throws parse error)
Fixture
$
Result
// parse-comments
{ type: 'NameExpression', name: '$' }
// doctrine
{ type: 'NameExpression', name: '$' }
// catharsis
{ type: 'NameExpression', name: '$' }
Fixture
()
Result
// parse-comments
{ type: 'UnionType', elements: [] }
// doctrine
{ type: 'UnionType', elements: [] }
// catharsis
{ type: 'TypeUnion', elements: null }
Fixture
(Array|String)
Result
// parse-comments
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'Array' },
{ type: 'NameExpression', name: 'String' } ] }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'Array' },
{ type: 'NameExpression', name: 'String' } ] }
// catharsis
{ type: 'TypeUnion',
elements:
[ { type: 'NameExpression', name: 'Array' },
{ type: 'NameExpression', name: 'String' } ] }
Fixture
(boolean)
Result
// parse-comments
{ type: 'UnionType',
elements: [ { type: 'NameExpression', name: 'boolean' } ] }
// doctrine
{ type: 'UnionType',
elements: [ { type: 'NameExpression', name: 'boolean' } ] }
// catharsis
{ type: 'TypeUnion',
elements: [ { type: 'NameExpression', name: 'boolean' } ] }
Fixture
(boolean|"string")
Result
// parse-comments
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'boolean' },
{ type: 'StringLiteralType', value: 'string' } ] }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'boolean' },
{ type: 'StringLiteralType', value: 'string' } ] }
// catharsis
// N/A (throws parse error)
Fixture
(boolean|"string"|array)
Result
// parse-comments
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'boolean' },
{ type: 'StringLiteralType', value: 'string' },
{ type: 'NameExpression', name: 'array' } ] }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'boolean' },
{ type: 'StringLiteralType', value: 'string' },
{ type: 'NameExpression', name: 'array' } ] }
// catharsis
// N/A (throws parse error)
Fixture
(boolean|string)
Result
// parse-comments
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'boolean' },
{ type: 'NameExpression', name: 'string' } ] }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'boolean' },
{ type: 'NameExpression', name: 'string' } ] }
// catharsis
{ type: 'TypeUnion',
elements:
[ { type: 'NameExpression', name: 'boolean' },
{ type: 'NameExpression', name: 'string' } ] }
Fixture
(boolean|string|array)
Result
// parse-comments
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'boolean' },
{ type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'array' } ] }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'boolean' },
{ type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'array' } ] }
// catharsis
{ type: 'TypeUnion',
elements:
[ { type: 'NameExpression', name: 'boolean' },
{ type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'array' } ] }
Fixture
(number|boolean)
Result
// parse-comments
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'number' },
{ type: 'NameExpression', name: 'boolean' } ] }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'number' },
{ type: 'NameExpression', name: 'boolean' } ] }
// catharsis
{ type: 'TypeUnion',
elements:
[ { type: 'NameExpression', name: 'number' },
{ type: 'NameExpression', name: 'boolean' } ] }
Fixture
(number|string)
Result
// parse-comments
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'number' },
{ type: 'NameExpression', name: 'string' } ] }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'number' },
{ type: 'NameExpression', name: 'string' } ] }
// catharsis
{ type: 'TypeUnion',
elements:
[ { type: 'NameExpression', name: 'number' },
{ type: 'NameExpression', name: 'string' } ] }
Fixture
(string|number)
Result
// parse-comments
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'number' } ] }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'number' } ] }
// catharsis
{ type: 'TypeUnion',
elements:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'number' } ] }
Fixture
(Window)
Result
// parse-comments
{ type: 'UnionType',
elements: [ { type: 'NameExpression', name: 'Window' } ] }
// doctrine
{ type: 'UnionType',
elements: [ { type: 'NameExpression', name: 'Window' } ] }
// catharsis
{ type: 'TypeUnion',
elements: [ { type: 'NameExpression', name: 'Window' } ] }
Fixture
*
Result
// parse-comments
{ type: 'AllLiteral' }
// doctrine
{ type: 'AllLiteral' }
// catharsis
{ type: 'AllLiteral' }
Fixture
-142.42
Result
// parse-comments
{ type: 'NumericLiteralType', value: -142.42 }
// doctrine
{ type: 'NumericLiteralType', value: -142.42 }
// catharsis
// N/A (throws parse error)
Fixture
...(Array|String)
Result
// parse-comments
{ type: 'NameExpression', name: '...' }
// doctrine
// N/A (throws parse error)
// catharsis
{ type: 'TypeUnion',
elements:
[ { type: 'NameExpression', name: 'Array' },
{ type: 'NameExpression', name: 'String' } ],
repeatable: true }
Fixture
...number
Result
// parse-comments
{ type: 'RestType',
expression: { type: 'NameExpression', name: 'number' } }
// doctrine
// N/A (throws parse error)
// catharsis
{ type: 'NameExpression', name: 'number', repeatable: true }
Fixture
32
Result
// parse-comments
{ type: 'NumericLiteralType', value: 32 }
// doctrine
{ type: 'NumericLiteralType', value: 32 }
// catharsis
{ type: 'NameExpression', name: '32' }
Fixture
?
Result
// parse-comments
{ type: 'NullableLiteral' }
// doctrine
{ type: 'NullableLiteral' }
// catharsis
{ type: 'UnknownLiteral' }
Fixture
?number
Result
// parse-comments
{ type: 'NullableType',
expression: { type: 'NameExpression', name: 'number' },
prefix: true }
// doctrine
{ type: 'NullableType',
expression: { type: 'NameExpression', name: 'number' },
prefix: true }
// catharsis
{ type: 'NameExpression', name: 'number', nullable: true }
Fixture
?string
Result
// parse-comments
{ type: 'NullableType',
expression: { type: 'NameExpression', name: 'string' },
prefix: true }
// doctrine
{ type: 'NullableType',
expression: { type: 'NameExpression', name: 'string' },
prefix: true }
// catharsis
{ type: 'NameExpression', name: 'string', nullable: true }
Fixture
[*]
Result
// parse-comments
{ type: 'ArrayType', elements: [ { type: 'AllLiteral' } ] }
// doctrine
{ type: 'ArrayType', elements: [ { type: 'AllLiteral' } ] }
// catharsis
// N/A (throws parse error)
Fixture
[?]
Result
// parse-comments
{ type: 'ArrayType', elements: [ { type: 'NullableLiteral' } ] }
// doctrine
{ type: 'ArrayType', elements: [ { type: 'NullableLiteral' } ] }
// catharsis
// N/A (throws parse error)
Fixture
[?string,...string?]
Result
// parse-comments
{ type: 'ArrayType',
elements:
[ { type: 'NullableType',
expression: { type: 'NameExpression', name: 'string' },
prefix: true },
{ type: 'RestType',
expression:
{ type: 'NullableType',
expression: { type: 'NameExpression', name: 'string' },
prefix: false } } ] }
// doctrine
{ type: 'ArrayType',
elements:
[ { type: 'NullableType',
expression: { type: 'NameExpression', name: 'string' },
prefix: true },
{ type: 'RestType',
expression:
{ type: 'NullableType',
expression: { type: 'NameExpression', name: 'string' },
prefix: false } } ] }
// catharsis
// N/A (throws parse error)
Fixture
[?string,...string]
Result
// parse-comments
{ type: 'ArrayType',
elements:
[ { type: 'NullableType',
expression: { type: 'NameExpression', name: 'string' },
prefix: true },
{ type: 'RestType',
expression: { type: 'NameExpression', name: 'string' } } ] }
// doctrine
{ type: 'ArrayType',
elements:
[ { type: 'NullableType',
expression: { type: 'NameExpression', name: 'string' },
prefix: true },
{ type: 'RestType',
expression: { type: 'NameExpression', name: 'string' } } ] }
// catharsis
// N/A (throws parse error)
Fixture
[string, ...string]
Result
// parse-comments
{ type: 'ArrayType',
elements:
[ { type: 'NameExpression', name: 'string' },
{ type: 'RestType',
expression: { type: 'NameExpression', name: 'string' } } ] }
// doctrine
{ type: 'ArrayType',
elements:
[ { type: 'NameExpression', name: 'string' },
{ type: 'RestType',
expression: { type: 'NameExpression', name: 'string' } } ] }
// catharsis
// N/A (throws parse error)
Fixture
[string, ...string]
Result
// parse-comments
{ type: 'ArrayType',
elements:
[ { type: 'NameExpression', name: 'string' },
{ type: 'RestType',
expression: { type: 'NameExpression', name: 'string' } } ] }
// doctrine
{ type: 'ArrayType',
elements:
[ { type: 'NameExpression', name: 'string' },
{ type: 'RestType',
expression: { type: 'NameExpression', name: 'string' } } ] }
// catharsis
// N/A (throws parse error)
Fixture
[string, ...string]
Result
// parse-comments
{ type: 'ArrayType',
elements:
[ { type: 'NameExpression', name: 'string' },
{ type: 'RestType',
expression: { type: 'NameExpression', name: 'string' } } ] }
// doctrine
{ type: 'ArrayType',
elements:
[ { type: 'NameExpression', name: 'string' },
{ type: 'RestType',
expression: { type: 'NameExpression', name: 'string' } } ] }
// catharsis
// N/A (throws parse error)
Fixture
[string,...string?]
Result
// parse-comments
{ type: 'ArrayType',
elements:
[ { type: 'NameExpression', name: 'string' },
{ type: 'RestType',
expression:
{ type: 'NullableType',
expression: { type: 'NameExpression', name: 'string' },
prefix: false } } ] }
// doctrine
{ type: 'ArrayType',
elements:
[ { type: 'NameExpression', name: 'string' },
{ type: 'RestType',
expression:
{ type: 'NullableType',
expression: { type: 'NameExpression', name: 'string' },
prefix: false } } ] }
// catharsis
// N/A (throws parse error)
Fixture
[string,...string]
Result
// parse-comments
{ type: 'ArrayType',
elements:
[ { type: 'NameExpression', name: 'string' },
{ type: 'RestType',
expression: { type: 'NameExpression', name: 'string' } } ] }
// doctrine
{ type: 'ArrayType',
elements:
[ { type: 'NameExpression', name: 'string' },
{ type: 'RestType',
expression: { type: 'NameExpression', name: 'string' } } ] }
// catharsis
// N/A (throws parse error)
Fixture
[string,]
Result
// parse-comments
{ type: 'ArrayType',
elements: [ { type: 'NameExpression', name: 'string' } ] }
// doctrine
{ type: 'ArrayType',
elements: [ { type: 'NameExpression', name: 'string' } ] }
// catharsis
// N/A (throws parse error)
Fixture
[string]
Result
// parse-comments
{ type: 'ArrayType',
elements: [ { type: 'NameExpression', name: 'string' } ] }
// doctrine
{ type: 'ArrayType',
elements: [ { type: 'NameExpression', name: 'string' } ] }
// catharsis
// N/A (throws parse error)
Fixture
_
Result
// parse-comments
{ type: 'NameExpression', name: '_' }
// doctrine
{ type: 'NameExpression', name: '_' }
// catharsis
{ type: 'NameExpression', name: '_' }
Fixture
a.b.c
Result
// parse-comments
{ type: 'NameExpression', name: 'a.b.c' }
// doctrine
{ type: 'NameExpression', name: 'a.b.c' }
// catharsis
{ type: 'NameExpression', name: 'a.b.c' }
Fixture
all
Result
// parse-comments
{ type: 'NameExpression', name: 'all' }
// doctrine
{ type: 'NameExpression', name: 'all' }
// catharsis
{ type: 'NameExpression', name: 'all' }
Fixture
any
Result
// parse-comments
{ type: 'NameExpression', name: 'any' }
// doctrine
{ type: 'NameExpression', name: 'any' }
// catharsis
{ type: 'NameExpression', name: 'any' }
Fixture
Array.<String, Number>
Result
// parse-comments
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications:
[ { type: 'NameExpression', name: 'String' },
{ type: 'NameExpression', name: 'Number' } ] }
// doctrine
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications:
[ { type: 'NameExpression', name: 'String' },
{ type: 'NameExpression', name: 'Number' } ] }
// catharsis
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications:
[ { type: 'NameExpression', name: 'String' },
{ type: 'NameExpression', name: 'Number' } ] }
Fixture
Array.<string=>
Result
// parse-comments
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications:
[ { type: 'OptionalType',
expression: { type: 'NameExpression', name: 'string' } } ] }
// doctrine
// N/A (throws parse error)
// catharsis
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications:
[ { type: 'NameExpression', name: 'string', optional: true } ] }
Fixture
Array.<String>
Result
// parse-comments
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications: [ { type: 'NameExpression', name: 'String' } ] }
// doctrine
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications: [ { type: 'NameExpression', name: 'String' } ] }
// catharsis
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications: [ { type: 'NameExpression', name: 'String' } ] }
Fixture
Array<?>
Result
// parse-comments
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications: [ { type: 'NullableLiteral' } ] }
// doctrine
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications: [ { type: 'NullableLiteral' } ] }
// catharsis
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications: [ { type: 'UnknownLiteral' } ] }
Fixture
Array<Array<string>>
Result
// parse-comments
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications:
[ { type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications: [ { type: 'NameExpression', name: 'string' } ] } ] }
// doctrine
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications:
[ { type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications: [ { type: 'NameExpression', name: 'string' } ] } ] }
// catharsis
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications:
[ { type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications: [ { type: 'NameExpression', name: 'string' } ] } ] }
Fixture
Array<Function>
Result
// parse-comments
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications: [ { type: 'NameExpression', name: 'Function' } ] }
// doctrine
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications: [ { type: 'NameExpression', name: 'Function' } ] }
// catharsis
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications: [ null ] }
Fixture
Array<String>
Result
// parse-comments
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications: [ { type: 'NameExpression', name: 'String' } ] }
// doctrine
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications: [ { type: 'NameExpression', name: 'String' } ] }
// catharsis
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications: [ { type: 'NameExpression', name: 'String' } ] }
Fixture
Array|String
Result
// parse-comments
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'Array' },
{ type: 'NameExpression', name: 'String' } ] }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'Array' },
{ type: 'NameExpression', name: 'String' } ] }
// catharsis
{ type: 'TypeUnion',
elements:
[ { type: 'NameExpression', name: 'Array' },
{ type: 'NameExpression', name: 'String' } ] }
Fixture
boolean
Result
// parse-comments
{ type: 'NameExpression', name: 'boolean' }
// doctrine
{ type: 'NameExpression', name: 'boolean' }
// catharsis
{ type: 'NameExpression', name: 'boolean' }
Fixture
boolean|string
Result
// parse-comments
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'boolean' },
{ type: 'NameExpression', name: 'string' } ] }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'boolean' },
{ type: 'NameExpression', name: 'string' } ] }
// catharsis
{ type: 'TypeUnion',
elements:
[ { type: 'NameExpression', name: 'boolean' },
{ type: 'NameExpression', name: 'string' } ] }
Fixture
Cocoa.Cappuccino
Result
// parse-comments
{ type: 'NameExpression', name: 'Cocoa.Cappuccino' }
// doctrine
{ type: 'NameExpression', name: 'Cocoa.Cappuccino' }
// catharsis
{ type: 'NameExpression', name: 'Cocoa.Cappuccino' }
Fixture
constructor
Result
// parse-comments
{ type: 'NameExpression', name: 'constructor' }
// doctrine
{ type: 'NameExpression', name: 'constructor' }
// catharsis
{ type: 'NameExpression', name: 'constructor' }
Fixture
false
Result
// parse-comments
{ type: 'BooleanLiteralType', value: false }
// doctrine
{ type: 'BooleanLiteralType', value: false }
// catharsis
{ type: 'NameExpression', name: 'false', reservedWord: true }
Fixture
foo.bar
Result
// parse-comments
{ type: 'NameExpression', name: 'foo.bar' }
// doctrine
{ type: 'NameExpression', name: 'foo.bar' }
// catharsis
{ type: 'NameExpression', name: 'foo.bar' }
Fixture
Function
Result
// parse-comments
{ type: 'NameExpression', name: 'Function' }
// doctrine
{ type: 'NameExpression', name: 'Function' }
// catharsis
// N/A (throws parse error)
Fixture
function()
Result
// parse-comments
{ type: 'FunctionType', params: [], result: null }
// doctrine
{ type: 'FunctionType', params: [], result: null }
// catharsis
{ type: 'FunctionType', params: [] }
Fixture
function(): number
Result
// parse-comments
{ type: 'FunctionType',
params: [],
result: { type: 'NameExpression', name: 'number' } }
// doctrine
{ type: 'FunctionType',
params: [],
result: { type: 'NameExpression', name: 'number' } }
// catharsis
{ type: 'FunctionType',
params: [],
result: { type: 'NameExpression', name: 'number' } }
Fixture
function(...a)
Result
// parse-comments
{ type: 'FunctionType',
params:
[ { type: 'RestType',
expression: { type: 'NameExpression', name: 'a' } } ],
result: null }
// doctrine
{ type: 'FunctionType',
params:
[ { type: 'RestType',
expression: { type: 'NameExpression', name: 'a' } } ],
result: null }
// catharsis
{ type: 'FunctionType',
params: [ { type: 'NameExpression', name: 'a', repeatable: true } ] }
Fixture
function(...a:!b)
Result
// parse-comments
{ type: 'FunctionType',
params:
[ { type: 'RestType',
expression:
{ type: 'ParameterType',
name: 'a',
expression:
{ type: 'NonNullableType',
expression: { type: 'NameExpression', name: 'b' },
prefix: true } } } ],
result: null }
// doctrine
{ type: 'FunctionType',
params:
[ { type: 'RestType',
expression:
{ type: 'ParameterType',
name: 'a',
expression:
{ type: 'NonNullableType',
expression: { type: 'NameExpression', name: 'b' },
prefix: true } } } ],
result: null }
// catharsis
// N/A (throws parse error)
Fixture
function(...a:?b)
Result
// parse-comments
{ type: 'FunctionType',
params:
[ { type: 'RestType',
expression:
{ type: 'ParameterType',
name: 'a',
expression:
{ type: 'NullableType',
expression: { type: 'NameExpression', name: 'b' },
prefix: true } } } ],
result: null }
// doctrine
{ type: 'FunctionType',
params:
[ { type: 'RestType',
expression:
{ type: 'ParameterType',
name: 'a',
expression:
{ type: 'NullableType',
expression: { type: 'NameExpression', name: 'b' },
prefix: true } } } ],
result: null }
// catharsis
// N/A (throws parse error)
Fixture
function(...a:b)
Result
// parse-comments
{ type: 'FunctionType',
params:
[ { type: 'RestType',
expression:
{ type: 'ParameterType',
name: 'a',
expression: { type: 'NameExpression', name: 'b' } } } ],
result: null }
// doctrine
{ type: 'FunctionType',
params:
[ { type: 'RestType',
expression:
{ type: 'ParameterType',
name: 'a',
expression: { type: 'NameExpression', name: 'b' } } } ],
result: null }
// catharsis
{ type: 'FunctionType',
params:
[ { type: 'NameExpression', name: 'a:b', repeatable: true } ] }
Fixture
function(...a:b=)
Result
// parse-comments
{ type: 'FunctionType',
params:
[ { type: 'RestType',
expression:
{ type: 'OptionalType',
expression:
{ type: 'ParameterType',
name: 'a',
expression: { type: 'NameExpression', name: 'b' } } } } ],
result: null }
// doctrine
{ type: 'FunctionType',
params:
[ { type: 'RestType',
expression:
{ type: 'OptionalType',
expression:
{ type: 'ParameterType',
name: 'a',
expression: { type: 'NameExpression', name: 'b' } } } } ],
result: null }
// catharsis
{ type: 'FunctionType',
params:
[ { type: 'NameExpression',
name: 'a:b',
optional: true,
repeatable: true } ] }
Fixture
function(...a=)
Result
// parse-comments
{ type: 'FunctionType',
params:
[ { type: 'RestType',
expression:
{ type: 'OptionalType',
expression: { type: 'NameExpression', name: 'a' } } } ],
result: null }
// doctrine
{ type: 'FunctionType',
params:
[ { type: 'RestType',
expression:
{ type: 'OptionalType',
expression: { type: 'NameExpression', name: 'a' } } } ],
result: null }
// catharsis
{ type: 'FunctionType',
params:
[ { type: 'NameExpression',
name: 'a',
optional: true,
repeatable: true } ] }
Fixture
function(?, number)
Result
// parse-comments
{ type: 'FunctionType',
params:
[ { type: 'NullableLiteral' },
{ type: 'NameExpression', name: 'number' } ],
result: null }
// doctrine
{ type: 'FunctionType',
params:
[ { type: 'NullableLiteral' },
{ type: 'NameExpression', name: 'number' } ],
result: null }
// catharsis
{ type: 'FunctionType',
params:
[ { type: 'UnknownLiteral' },
{ type: 'NameExpression', name: 'number' } ] }
Fixture
function(?string=, number=)
Result
// parse-comments
{ type: 'FunctionType',
params:
[ { type: 'OptionalType',
expression:
{ type: 'NullableType',
expression: { type: 'NameExpression', name: 'string' },
prefix: true } },
{ type: 'OptionalType',
expression: { type: 'NameExpression', name: 'number' } } ],
result: null }
// doctrine
{ type: 'FunctionType',
params:
[ { type: 'OptionalType',
expression:
{ type: 'NullableType',
expression: { type: 'NameExpression', name: 'string' },
prefix: true } },
{ type: 'OptionalType',
expression: { type: 'NameExpression', name: 'number' } } ],
result: null }
// catharsis
{ type: 'FunctionType',
params:
[ { type: 'NameExpression',
name: 'string',
optional: true,
nullable: true },
{ type: 'NameExpression', name: 'number', optional: true } ] }
Fixture
function(a)
Result
// parse-comments
{ type: 'FunctionType',
params: [ { type: 'NameExpression', name: 'a' } ],
result: null }
// doctrine
{ type: 'FunctionType',
params: [ { type: 'NameExpression', name: 'a' } ],
result: null }
// catharsis
{ type: 'FunctionType',
params: [ { type: 'NameExpression', name: 'a' } ] }
Fixture
function(a:b)
Result
// parse-comments
{ type: 'FunctionType',
params:
[ { type: 'ParameterType',
name: 'a',
expression: { type: 'NameExpression', name: 'b' } } ],
result: null }
// doctrine
{ type: 'FunctionType',
params:
[ { type: 'ParameterType',
name: 'a',
expression: { type: 'NameExpression', name: 'b' } } ],
result: null }
// catharsis
{ type: 'FunctionType',
params: [ { type: 'NameExpression', name: 'a:b' } ] }
Fixture
function(a:b=)
Result
// parse-comments
{ type: 'FunctionType',
params:
[ { type: 'OptionalType',
expression:
{ type: 'ParameterType',
name: 'a',
expression: { type: 'NameExpression', name: 'b' } } } ],
result: null }
// doctrine
{ type: 'FunctionType',
params:
[ { type: 'OptionalType',
expression:
{ type: 'ParameterType',
name: 'a',
expression: { type: 'NameExpression', name: 'b' } } } ],
result: null }
// catharsis
{ type: 'FunctionType',
params: [ { type: 'NameExpression', name: 'a:b', optional: true } ] }
Fixture
function(a=)
Result
// parse-comments
{ type: 'FunctionType',
params:
[ { type: 'OptionalType',
expression: { type: 'NameExpression', name: 'a' } } ],
result: null }
// doctrine
{ type: 'FunctionType',
params:
[ { type: 'OptionalType',
expression: { type: 'NameExpression', name: 'a' } } ],
result: null }
// catharsis
{ type: 'FunctionType',
params: [ { type: 'NameExpression', name: 'a', optional: true } ] }
Fixture
function(new:goog.ui.Menu, string)
Result
// parse-comments
{ type: 'FunctionType',
params: [ { type: 'NameExpression', name: 'string' } ],
result: null,
this: { type: 'NameExpression', name: 'goog.ui.Menu' },
new: true }
// doctrine
{ type: 'FunctionType',
params: [ { type: 'NameExpression', name: 'string' } ],
result: null,
this: { type: 'NameExpression', name: 'goog.ui.Menu' },
new: true }
// catharsis
{ type: 'FunctionType',
params: [ { type: 'NameExpression', name: 'string' } ],
new: { type: 'NameExpression', name: 'goog.ui.Menu' } }
Fixture
function(number, ?)
Result
// parse-comments
{ type: 'FunctionType',
params:
[ { type: 'NameExpression', name: 'number' },
{ type: 'NullableLiteral' } ],
result: null }
// doctrine
{ type: 'FunctionType',
params:
[ { type: 'NameExpression', name: 'number' },
{ type: 'NullableLiteral' } ],
result: null }
// catharsis
{ type: 'FunctionType',
params:
[ { type: 'NameExpression', name: 'number' },
{ type: 'UnknownLiteral' } ] }
Fixture
function(number, number): number
Result
// parse-comments
{ type: 'FunctionType',
params:
[ { type: 'NameExpression', name: 'number' },
{ type: 'NameExpression', name: 'number' } ],
result: { type: 'NameExpression', name: 'number' } }
// doctrine
{ type: 'FunctionType',
params:
[ { type: 'NameExpression', name: 'number' },
{ type: 'NameExpression', name: 'number' } ],
result: { type: 'NameExpression', name: 'number' } }
// catharsis
{ type: 'FunctionType',
params:
[ { type: 'NameExpression', name: 'number' },
{ type: 'NameExpression', name: 'number' } ],
result: { type: 'NameExpression', name: 'number' } }
Fixture
function(string)
Result
// parse-comments
{ type: 'FunctionType',
params: [ { type: 'NameExpression', name: 'string' } ],
result: null }
// doctrine
{ type: 'FunctionType',
params: [ { type: 'NameExpression', name: 'string' } ],
result: null }
// catharsis
{ type: 'FunctionType',
params: [ { type: 'NameExpression', name: 'string' } ] }
Fixture
function(string, ...[number]): number
Result
// parse-comments
{ type: 'FunctionType',
params:
[ { type: 'NameExpression', name: 'string' },
{ type: 'RestType',
expression:
{ type: 'ArrayType',
elements: [ { type: 'NameExpression', name: 'number' } ] } } ],
result: { type: 'NameExpression', name: 'number' } }
// doctrine
{ type: 'FunctionType',
params:
[ { type: 'NameExpression', name: 'string' },
{ type: 'RestType',
expression:
{ type: 'ArrayType',
elements: [ { type: 'NameExpression', name: 'number' } ] } } ],
result: { type: 'NameExpression', name: 'number' } }
// catharsis
{ type: 'FunctionType',
params:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'number', repeatable: true } ],
result: { type: 'NameExpression', name: 'number' } }
Fixture
function(string, boolean)
Result
// parse-comments
{ type: 'FunctionType',
params:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'boolean' } ],
result: null }
// doctrine
{ type: 'FunctionType',
params:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'boolean' } ],
result: null }
// catharsis
{ type: 'FunctionType',
params:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'boolean' } ] }
Fixture
function(this:goog.ui.Menu, string)
Result
// parse-comments
{ type: 'FunctionType',
params: [ { type: 'NameExpression', name: 'string' } ],
result: null,
this: { type: 'NameExpression', name: 'goog.ui.Menu' } }
// doctrine
{ type: 'FunctionType',
params: [ { type: 'NameExpression', name: 'string' } ],
result: null,
this: { type: 'NameExpression', name: 'goog.ui.Menu' } }
// catharsis
{ type: 'FunctionType',
params: [ { type: 'NameExpression', name: 'string' } ],
this: { type: 'NameExpression', name: 'goog.ui.Menu' } }
Fixture
function(this:T,?,number)
Result
// parse-comments
{ type: 'FunctionType',
params:
[ { type: 'NullableLiteral' },
{ type: 'NameExpression', name: 'number' } ],
result: null,
this: { type: 'NameExpression', name: 'T' } }
// doctrine
{ type: 'FunctionType',
params:
[ { type: 'NullableLiteral' },
{ type: 'NameExpression', name: 'number' } ],
result: null,
this: { type: 'NameExpression', name: 'T' } }
// catharsis
{ type: 'FunctionType',
params:
[ { type: 'UnknownLiteral' },
{ type: 'NameExpression', name: 'number' } ],
this: { type: 'NameExpression', name: 'T' } }
Fixture
function(this:T,?,number):?
Result
// parse-comments
{ type: 'FunctionType',
params:
[ { type: 'NullableLiteral' },
{ type: 'NameExpression', name: 'number' } ],
result: { type: 'NullableLiteral' },
this: { type: 'NameExpression', name: 'T' } }
// doctrine
{ type: 'FunctionType',
params:
[ { type: 'NullableLiteral' },
{ type: 'NameExpression', name: 'number' } ],
result: { type: 'NullableLiteral' },
this: { type: 'NameExpression', name: 'T' } }
// catharsis
{ type: 'FunctionType',
params:
[ { type: 'UnknownLiteral' },
{ type: 'NameExpression', name: 'number' } ],
this: { type: 'NameExpression', name: 'T' },
result: { type: 'UnknownLiteral' } }
Fixture
goog.ui.Component?
Result
// parse-comments
{ type: 'NullableType',
expression: { type: 'NameExpression', name: 'goog.ui.Component' },
prefix: false }
// doctrine
{ type: 'NullableType',
expression: { type: 'NameExpression', name: 'goog.ui.Component' },
prefix: false }
// catharsis
{ type: 'NameExpression',
name: 'goog.ui.Component',
nullable: true }
Fixture
goog.ui.Menu
Result
// parse-comments
{ type: 'NameExpression', name: 'goog.ui.Menu' }
// doctrine
{ type: 'NameExpression', name: 'goog.ui.Menu' }
// catharsis
{ type: 'NameExpression', name: 'goog.ui.Menu' }
Fixture
interface
Result
// parse-comments
{ type: 'NameExpression', name: 'interface' }
// doctrine
{ type: 'NameExpression', name: 'interface' }
// catharsis
{ type: 'NameExpression', name: 'interface', reservedWord: true }
Fixture
number
Result
// parse-comments
{ type: 'NameExpression', name: 'number' }
// doctrine
{ type: 'NameExpression', name: 'number' }
// catharsis
{ type: 'NameExpression', name: 'number' }
Fixture
number|boolean
Result
// parse-comments
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'number' },
{ type: 'NameExpression', name: 'boolean' } ] }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'number' },
{ type: 'NameExpression', name: 'boolean' } ] }
// catharsis
{ type: 'TypeUnion',
elements:
[ { type: 'NameExpression', name: 'number' },
{ type: 'NameExpression', name: 'boolean' } ] }
Fixture
Object!
Result
// parse-comments
{ type: 'NonNullableType',
expression: { type: 'NameExpression', name: 'Object' },
prefix: false }
// doctrine
{ type: 'NonNullableType',
expression: { type: 'NameExpression', name: 'Object' },
prefix: false }
// catharsis
{ type: 'NameExpression', name: 'Object', nullable: false }
Fixture
Object.<string, number>
Result
// parse-comments
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Object' },
applications:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'number' } ] }
// doctrine
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Object' },
applications:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'number' } ] }
// catharsis
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Object' },
applications:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'number' } ] }
Fixture
Object<string, number>
Result
// parse-comments
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Object' },
applications:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'number' } ] }
// doctrine
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Object' },
applications:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'number' } ] }
// catharsis
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Object' },
applications:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'number' } ] }
Fixture
Object|undefined
Result
// parse-comments
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'Object' },
{ type: 'UndefinedLiteral' } ] }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'Object' },
{ type: 'UndefinedLiteral' } ] }
// catharsis
{ type: 'TypeUnion',
elements:
[ { type: 'NameExpression', name: 'Object' },
{ type: 'UndefinedLiteral' } ] }
Fixture
Object|null
Result
// parse-comments
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'Object' },
{ type: 'NullLiteral' } ] }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'Object' },
{ type: 'NullLiteral' } ] }
// catharsis
{ type: 'TypeUnion',
elements:
[ { type: 'NameExpression', name: 'Object' },
{ type: 'NullLiteral' } ] }
Fixture
Object|void
Result
// parse-comments
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'Object' },
{ type: 'NameExpression', name: 'void' } ] }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'Object' },
{ type: 'NameExpression', name: 'void' } ] }
// catharsis
{ type: 'TypeUnion',
elements:
[ { type: 'NameExpression', name: 'Object' },
{ type: 'NameExpression', name: 'void', reservedWord: true } ] }
Fixture
WeakMap|WeakSet
Result
// parse-comments
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'WeakMap' },
{ type: 'NameExpression', name: 'WeakSet' } ] }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'WeakMap' },
{ type: 'NameExpression', name: 'WeakSet' } ] }
// catharsis
{ type: 'TypeUnion',
elements:
[ { type: 'NameExpression', name: 'WeakMap' },
{ type: 'NameExpression', name: 'WeakSet' } ] }
Fixture
record
Result
// parse-comments
{ type: 'NameExpression', name: 'record' }
// doctrine
{ type: 'NameExpression', name: 'record' }
// catharsis
{ type: 'NameExpression', name: 'record' }
Fixture
string!
Result
// parse-comments
{ type: 'NonNullableType',
expression: { type: 'NameExpression', name: 'string' },
prefix: false }
// doctrine
{ type: 'NonNullableType',
expression: { type: 'NameExpression', name: 'string' },
prefix: false }
// catharsis
{ type: 'NameExpression', name: 'string', nullable: false }
Fixture
string?
Result
// parse-comments
{ type: 'NullableType',
expression: { type: 'NameExpression', name: 'string' },
prefix: false }
// doctrine
{ type: 'NullableType',
expression: { type: 'NameExpression', name: 'string' },
prefix: false }
// catharsis
{ type: 'NameExpression', name: 'string', nullable: true }
Fixture
String[]
Result
// parse-comments
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications: [ { type: 'NameExpression', name: 'String' } ] }
// doctrine
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications: [ { type: 'NameExpression', name: 'String' } ] }
// catharsis
// N/A (throws parse error)
Fixture
true
Result
// parse-comments
{ type: 'BooleanLiteralType', value: true }
// doctrine
{ type: 'BooleanLiteralType', value: true }
// catharsis
{ type: 'NameExpression', name: 'true', reservedWord: true }
Fixture
undefined
Result
// parse-comments
{ type: 'UndefinedLiteral' }
// doctrine
{ type: 'UndefinedLiteral' }
// catharsis
{ type: 'UndefinedLiteral' }
Fixture
null
Result
// parse-comments
{ type: 'NullLiteral' }
// doctrine
{ type: 'NullLiteral' }
// catharsis
{ type: 'NullLiteral' }
Fixture
unknown
Result
// parse-comments
{ type: 'NameExpression', name: 'unknown' }
// doctrine
{ type: 'NameExpression', name: 'unknown' }
// catharsis
{ type: 'NameExpression', name: 'unknown' }
Fixture
Window
Result
// parse-comments
{ type: 'NameExpression', name: 'Window' }
// doctrine
{ type: 'NameExpression', name: 'Window' }
// catharsis
{ type: 'NameExpression', name: 'Window' }
Fixture
{ok: true, data: string}
Result
// parse-comments
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: 'ok',
value: { type: 'BooleanLiteralType', value: true } },
{ type: 'FieldType',
key: 'data',
value: { type: 'NameExpression', name: 'string' } } ] }
// doctrine
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: 'ok',
value: { type: 'BooleanLiteralType', value: true } },
{ type: 'FieldType',
key: 'data',
value: { type: 'NameExpression', name: 'string' } } ] }
// catharsis
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: { type: 'NameExpression', name: 'ok' },
value: { type: 'NameExpression', name: 'true', reservedWord: true } },
{ type: 'FieldType',
key: { type: 'NameExpression', name: 'data' },
value: { type: 'NameExpression', name: 'string' } } ] }
Fixture
{ok: false, error: Error}
Result
// parse-comments
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: 'ok',
value: { type: 'BooleanLiteralType', value: false } },
{ type: 'FieldType',
key: 'error',
value: { type: 'NameExpression', name: 'Error' } } ] }
// doctrine
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: 'ok',
value: { type: 'BooleanLiteralType', value: false } },
{ type: 'FieldType',
key: 'error',
value: { type: 'NameExpression', name: 'Error' } } ] }
// catharsis
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: { type: 'NameExpression', name: 'ok' },
value:
{ type: 'NameExpression', name: 'false', reservedWord: true } },
{ type: 'FieldType',
key: { type: 'NameExpression', name: 'error' },
value: { type: 'NameExpression', name: 'Error' } } ] }
Fixture
({ok: true, data: string} | {ok: false, error: Error})
Result
// parse-comments
{ type: 'UnionType',
elements:
[ { type: 'RecordType',
fields:
[ { type: 'FieldType',
key: 'ok',
value: { type: 'BooleanLiteralType', value: true } },
{ type: 'FieldType',
key: 'data',
value: { type: 'NameExpression', name: 'string' } } ] },
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: 'ok',
value: { type: 'BooleanLiteralType', value: false } },
{ type: 'FieldType',
key: 'error',
value: { type: 'NameExpression', name: 'Error' } } ] } ] }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'RecordType',
fields:
[ { type: 'FieldType',
key: 'ok',
value: { type: 'BooleanLiteralType', value: true } },
{ type: 'FieldType',
key: 'data',
value: { type: 'NameExpression', name: 'string' } } ] },
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: 'ok',
value: { type: 'BooleanLiteralType', value: false } },
{ type: 'FieldType',
key: 'error',
value: { type: 'NameExpression', name: 'Error' } } ] } ] }
// catharsis
{ type: 'TypeUnion',
elements:
[ { type: 'RecordType',
fields:
[ { type: 'FieldType',
key: { type: 'NameExpression', name: 'ok' },
value: { type: 'NameExpression', name: 'true', reservedWord: true } },
{ type: 'FieldType',
key: { type: 'NameExpression', name: 'data' },
value: { type: 'NameExpression', name: 'string' } } ] },
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: { type: 'NameExpression', name: 'ok' },
value:
{ type: 'NameExpression', name: 'false', reservedWord: true } },
{ type: 'FieldType',
key: { type: 'NameExpression', name: 'error' },
value: { type: 'NameExpression', name: 'Error' } } ] } ] }
Fixture
{"\r\n\t\u2028\x20\u20\b\f\v\\r\n\\n\0\07\012\o":String}
Result
// parse-comments
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key:
'\\r\\n\\t\\u2028\\x20\\u20\\b\\f\\v\\\r\n\\\n\\0\\07\\012\\o',
value: { type: 'NameExpression', name: 'String' } } ] }
// doctrine
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: '\r\n\t
u20\b\f\u000b\u0000\u0007\no',
value: { type: 'NameExpression', name: 'String' } } ] }
// catharsis
// N/A (throws parse error)
Fixture
{,}
Result
// parse-comments
{ type: 'RecordType', fields: [] }
// doctrine
{ type: 'RecordType', fields: [] }
// catharsis
// N/A (throws parse error)
Fixture
{.2:String, 30:Number, 0x20:String}
Result
// parse-comments
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: '0.2',
value: { type: 'NameExpression', name: 'String' } },
{ type: 'FieldType',
key: '30',
value: { type: 'NameExpression', name: 'Number' } },
{ type: 'FieldType',
key: '32',
value: { type: 'NameExpression', name: 'String' } } ] }
// doctrine
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: '0.2',
value: { type: 'NameExpression', name: 'String' } },
{ type: 'FieldType',
key: '30',
value: { type: 'NameExpression', name: 'Number' } },
{ type: 'FieldType',
key: '32',
value: { type: 'NameExpression', name: 'String' } } ] }
// catharsis
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: { type: 'NameExpression', name: '.2:String' },
value: undefined },
{ type: 'FieldType',
key: { type: 'NameExpression', name: '30:Number' },
value: undefined },
{ type: 'FieldType',
key: { type: 'NameExpression', name: '0x20:String' },
value: undefined } ] }
Fixture
{0X2:String, 0:Number, 100e200:String, 10e-20:Number}
Result
// parse-comments
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: '2',
value: { type: 'NameExpression', name: 'String' } },
{ type: 'FieldType',
key: '0',
value: { type: 'NameExpression', name: 'Number' } },
{ type: 'FieldType',
key: '1e+202',
value: { type: 'NameExpression', name: 'String' } },
{ type: 'FieldType',
key: '1e-19',
value: { type: 'NameExpression', name: 'Number' } } ] }
// doctrine
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: '2',
value: { type: 'NameExpression', name: 'String' } },
{ type: 'FieldType',
key: '0',
value: { type: 'NameExpression', name: 'Number' } },
{ type: 'FieldType',
key: '1e+202',
value: { type: 'NameExpression', name: 'String' } },
{ type: 'FieldType',
key: '1e-19',
value: { type: 'NameExpression', name: 'Number' } } ] }
// catharsis
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: { type: 'NameExpression', name: '0X2:String' },
value: undefined },
{ type: 'FieldType',
key: { type: 'NameExpression', name: '0:Number' },
value: undefined },
{ type: 'FieldType',
key: { type: 'NameExpression', name: '100e200:String' },
value: undefined },
{ type: 'FieldType',
key: { type: 'NameExpression', name: '10e-20:Number' },
value: undefined } ] }
Fixture
{20:String}
Result
// parse-comments
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: '20',
value: { type: 'NameExpression', name: 'String' } } ] }
// doctrine
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: '20',
value: { type: 'NameExpression', name: 'String' } } ] }
// catharsis
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: { type: 'NameExpression', name: '20:String' },
value: undefined } ] }
Fixture
{myNum: number, myObject}
Result
// parse-comments
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: 'myNum',
value: { type: 'NameExpression', name: 'number' } },
{ type: 'FieldType', key: 'myObject', value: undefined } ] }
// doctrine
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: 'myNum',
value: { type: 'NameExpression', name: 'number' } },
{ type: 'FieldType', key: 'myObject', value: null } ] }
// catharsis
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: { type: 'NameExpression', name: 'myNum' },
value: { type: 'NameExpression', name: 'number' } },
{ type: 'FieldType',
key: { type: 'NameExpression', name: 'myObject' },
value: undefined } ] }
Fixture
{}
Result
// parse-comments
{ type: 'RecordType', fields: [] }
// doctrine
{ type: 'RecordType', fields: [] }
// catharsis
{ type: 'RecordType', fields: [] }
Fixture
!
Result
// parse-comments
{ type: 'NonNullableLiteral' }
// doctrine
// N/A (throws parse error)
// catharsis
// N/A (throws parse error)
Fixture
(function(...a): ?)|number
Result
// parse-comments
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'a' },
{ type: 'NullableLiteral' },
{ type: 'NameExpression', name: 'function' },
{ type: 'NameExpression', name: 'number' } ] }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'UnionType',
elements:
[ { type: 'FunctionType',
params:
[ { type: 'RestType',
expression: { type: 'NameExpression', name: 'a' } } ],
result: { type: 'NullableLiteral' } } ] },
{ type: 'NameExpression', name: 'number' } ] }
// catharsis
// N/A (throws parse error)
Fixture
...number
Result
// parse-comments
{ type: 'RestType',
expression: { type: 'NameExpression', name: 'number' } }
// doctrine
// N/A (throws parse error)
// catharsis
{ type: 'NameExpression', name: 'number', repeatable: true }
Fixture
=string
Result
// parse-comments
{ type: 'NameExpression', name: '=string' }
// doctrine
// N/A (throws parse error)
// catharsis
// N/A (throws parse error)
Fixture
Array.<(string|number), // ?Object=>|string|undefined
Result
// parse-comments
// N/A (throws parse error)
// doctrine
// N/A (throws parse error)
// catharsis
// N/A (throws parse error)
Fixture
Array.<string|number, // ?Object=>|string|undefined
Result
// parse-comments
// N/A (throws parse error)
// doctrine
// N/A (throws parse error)
// catharsis
// N/A (throws parse error)
Fixture
function(...a): (?|number)
Result
// parse-comments
{ type: 'FunctionType',
params:
[ { type: 'RestType',
expression: { type: 'NameExpression', name: 'a' } } ],
result:
{ type: 'TypeUnion',
elements:
[ { type: 'NullableLiteral' },
{ type: 'NameExpression', name: 'number' } ] } }
// doctrine
{ type: 'FunctionType',
params:
[ { type: 'RestType',
expression: { type: 'NameExpression', name: 'a' } } ],
result:
{ type: 'UnionType',
elements:
[ { type: 'NullableLiteral' },
{ type: 'NameExpression', name: 'number' } ] } }
// catharsis
{ type: 'FunctionType',
params: [ { type: 'NameExpression', name: 'a', repeatable: true } ],
result:
{ type: 'TypeUnion',
elements:
[ { type: 'UnknownLiteral' },
{ type: 'NameExpression', name: 'number' } ] } }
Fixture
function(...a): ?|number
Result
// parse-comments
{ type: 'FunctionType',
params:
[ { type: 'RestType',
expression: { type: 'NameExpression', name: 'a' } } ],
result:
{ type: 'TypeUnion',
elements:
[ { type: 'NullableLiteral' },
{ type: 'NameExpression', name: 'number' } ] } }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'FunctionType',
params:
[ { type: 'RestType',
expression: { type: 'NameExpression', name: 'a' } } ],
result: { type: 'NullableLiteral' } },
{ type: 'NameExpression', name: 'number' } ] }
// catharsis
{ type: 'FunctionType',
params: [ { type: 'NameExpression', name: 'a', repeatable: true } ],
result:
{ type: 'TypeUnion',
elements:
[ { type: 'UnknownLiteral' },
{ type: 'NameExpression', name: 'number' } ] } }
Fixture
number=
Result
// parse-comments
{ type: 'OptionalType',
expression: { type: 'NameExpression', name: 'number' } }
// doctrine
// N/A (throws parse error)
// catharsis
{ type: 'NameExpression', name: 'number', optional: true }
Fixture
string=
Result
// parse-comments
{ type: 'OptionalType',
expression: { type: 'NameExpression', name: 'string' } }
// doctrine
// N/A (throws parse error)
// catharsis
{ type: 'NameExpression', name: 'string', optional: true }
Fixture
string|array|number
Result
// parse-comments
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'array' },
{ type: 'NameExpression', name: 'number' } ] }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'array' },
{ type: 'NameExpression', name: 'number' } ] }
// catharsis
{ type: 'TypeUnion',
elements:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'array' },
{ type: 'NameExpression', name: 'number' } ] }
Fixture
string|number
Result
// parse-comments
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'number' } ] }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'number' } ] }
// catharsis
{ type: 'TypeUnion',
elements:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'number' } ] }
Fixture
string|number|Test
Result
// parse-comments
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'number' },
{ type: 'NameExpression', name: 'Test' } ] }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'number' },
{ type: 'NameExpression', name: 'Test' } ] }
// catharsis
{ type: 'TypeUnion',
elements:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'number' },
{ type: 'NameExpression', name: 'Test' } ] }
Fixture
('public'|'protected'|'private')
Result
// parse-comments
{ type: 'UnionType',
elements:
[ { type: 'StringLiteralType', value: 'public' },
{ type: 'StringLiteralType', value: 'protected' },
{ type: 'StringLiteralType', value: 'private' } ] }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'StringLiteralType', value: 'public' },
{ type: 'StringLiteralType', value: 'protected' },
{ type: 'StringLiteralType', value: 'private' } ] }
// catharsis
// N/A (throws parse error)
Fixture
(-42|1.5|0)
Result
// parse-comments
{ type: 'UnionType',
elements:
[ { type: 'NumericLiteralType', value: -42 },
{ type: 'NumericLiteralType', value: 1.5 },
{ type: 'NumericLiteralType', value: 0 } ] }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'NumericLiteralType', value: -42 },
{ type: 'NumericLiteralType', value: 1.5 },
{ type: 'NumericLiteralType', value: 0 } ] }
// catharsis
// N/A (throws parse error)
Fixture
(true|false)
Result
// parse-comments
{ type: 'UnionType',
elements:
[ { type: 'BooleanLiteralType', value: true },
{ type: 'BooleanLiteralType', value: false } ] }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'BooleanLiteralType', value: true },
{ type: 'BooleanLiteralType', value: false } ] }
// catharsis
{ type: 'TypeUnion',
elements:
[ { type: 'NameExpression', name: 'true', reservedWord: true },
{ type: 'NameExpression', name: 'false', reservedWord: true } ] }
Fixture
{ok: true, data: string}
Result
// parse-comments
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: 'ok',
value: { type: 'BooleanLiteralType', value: true } },
{ type: 'FieldType',
key: 'data',
value: { type: 'NameExpression', name: 'string' } } ] }
// doctrine
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: 'ok',
value: { type: 'BooleanLiteralType', value: true } },
{ type: 'FieldType',
key: 'data',
value: { type: 'NameExpression', name: 'string' } } ] }
// catharsis
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: { type: 'NameExpression', name: 'ok' },
value: { type: 'NameExpression', name: 'true', reservedWord: true } },
{ type: 'FieldType',
key: { type: 'NameExpression', name: 'data' },
value: { type: 'NameExpression', name: 'string' } } ] }
Fixture
Array<string, object>
Result
// parse-comments
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'object' } ] }
// doctrine
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'object' } ] }
// catharsis
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'object' } ] }
Fixture
Array<string>
Result
// parse-comments
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications: [ { type: 'NameExpression', name: 'string' } ] }
// doctrine
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications: [ { type: 'NameExpression', name: 'string' } ] }
// catharsis
{ type: 'TypeApplication',
expression: { type: 'NameExpression', name: 'Array' },
applications: [ { type: 'NameExpression', name: 'string' } ] }
Fixture
ClassName
Result
// parse-comments
{ type: 'NameExpression', name: 'ClassName' }
// doctrine
{ type: 'NameExpression', name: 'ClassName' }
// catharsis
{ type: 'NameExpression', name: 'ClassName' }
Fixture
Error
Result
// parse-comments
{ type: 'NameExpression', name: 'Error' }
// doctrine
{ type: 'NameExpression', name: 'Error' }
// catharsis
{ type: 'NameExpression', name: 'Error' }
Fixture
function
Result
// parse-comments
{ type: 'NameExpression', name: 'function' }
// doctrine
{ type: 'NameExpression', name: 'function' }
// catharsis
// N/A (throws parse error)
Fixture
number
Result
// parse-comments
{ type: 'NameExpression', name: 'number' }
// doctrine
{ type: 'NameExpression', name: 'number' }
// catharsis
{ type: 'NameExpression', name: 'number' }
Fixture
Object
Result
// parse-comments
{ type: 'NameExpression', name: 'Object' }
// doctrine
{ type: 'NameExpression', name: 'Object' }
// catharsis
{ type: 'NameExpression', name: 'Object' }
Fixture
object
Result
// parse-comments
{ type: 'NameExpression', name: 'object' }
// doctrine
{ type: 'NameExpression', name: 'object' }
// catharsis
{ type: 'NameExpression', name: 'object' }
Fixture
{ok: false, error: Error}
Result
// parse-comments
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: 'ok',
value: { type: 'BooleanLiteralType', value: false } },
{ type: 'FieldType',
key: 'error',
value: { type: 'NameExpression', name: 'Error' } } ] }
// doctrine
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: 'ok',
value: { type: 'BooleanLiteralType', value: false } },
{ type: 'FieldType',
key: 'error',
value: { type: 'NameExpression', name: 'Error' } } ] }
// catharsis
{ type: 'RecordType',
fields:
[ { type: 'FieldType',
key: { type: 'NameExpression', name: 'ok' },
value:
{ type: 'NameExpression', name: 'false', reservedWord: true } },
{ type: 'FieldType',
key: { type: 'NameExpression', name: 'error' },
value: { type: 'NameExpression', name: 'Error' } } ] }
Fixture
string|array|function
Result
// parse-comments
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'array' },
{ type: 'NameExpression', name: 'function' } ] }
// doctrine
{ type: 'UnionType',
elements:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'array' },
{ type: 'NameExpression', name: 'function' } ] }
// catharsis
{ type: 'TypeUnion',
elements:
[ { type: 'NameExpression', name: 'string' },
{ type: 'NameExpression', name: 'array' },
null ] }
Fixture
String
Result
// parse-comments
{ type: 'NameExpression', name: 'String' }
// doctrine
{ type: 'NameExpression', name: 'String' }
// catharsis
{ type: 'NameExpression', name: 'String' }
Fixture
string
Result
// parse-comments
{ type: 'NameExpression', name: 'string' }
// doctrine
{ type: 'NameExpression', name: 'string' }
// catharsis
{ type: 'NameExpression', name: 'string' }
Fixture
thingName.name
Result
// parse-comments
{ type: 'NameExpression', name: 'thingName.name' }
// doctrine
{ type: 'NameExpression', name: 'thingName.name' }
// catharsis
{ type: 'NameExpression', name: 'thingName.name' }
Fixture
thing
Result
// parse-comments
{ type: 'NameExpression', name: 'thing' }
// doctrine
{ type: 'NameExpression', name: 'thing' }
// catharsis
{ type: 'NameExpression', name: 'thing' }
Fixture
{ok:String
Result
// parse-comments
// N/A (throws parse error)
// doctrine
// N/A (throws parse error)
// catharsis
// N/A (throws parse error)