@typedefs/parser
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -114,3 +114,3 @@ const { Fn, fn, | ||
const parseType = (specialAllowed = true) => { | ||
const parseType = (specialAllowed = true, union = []) => { | ||
/** @type {!_typedefsParser.Type} */ | ||
@@ -131,3 +131,3 @@ let type = {} | ||
type = { | ||
...parseType(), | ||
...parseType(true, []), | ||
...type, // preserve nullable | ||
@@ -170,9 +170,9 @@ } | ||
const union = [type] | ||
union.push(type) | ||
while(peek() == '|') { | ||
consume() | ||
const nextType = parseType(true) | ||
const nextType = parseType(true, union) | ||
const u = nextType.union ? nextType.union : [nextType] | ||
union.push(...u) | ||
// const u = nextType.union ? nextType.union : [nextType] | ||
if(nextType.union !== union) union.push(nextType) | ||
} | ||
@@ -179,0 +179,0 @@ return { union } |
@@ -0,1 +1,7 @@ | ||
## 28 April 2019 | ||
### [1.2.0](https://github.com/artdecocode/parser/compare/v1.1.1...v1.2.0) | ||
- [feature] Group unions correctly (allow `Type|?(string|number)`). | ||
## 27 April 2019 | ||
@@ -2,0 +8,0 @@ |
{ | ||
"name": "@typedefs/parser", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "The Parser For JSDoc Types.", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -114,3 +114,3 @@ import { Fn, fn, | ||
const parseType = (specialAllowed = true) => { | ||
const parseType = (specialAllowed = true, union = []) => { | ||
/** @type {!_typedefsParser.Type} */ | ||
@@ -131,3 +131,3 @@ let type = {} | ||
type = { | ||
...parseType(), | ||
...parseType(true, []), | ||
...type, // preserve nullable | ||
@@ -170,9 +170,9 @@ } | ||
const union = [type] | ||
union.push(type) | ||
while(peek() == '|') { | ||
consume() | ||
const nextType = parseType(true) | ||
const nextType = parseType(true, union) | ||
const u = nextType.union ? nextType.union : [nextType] | ||
union.push(...u) | ||
// const u = nextType.union ? nextType.union : [nextType] | ||
if(nextType.union !== union) union.push(nextType) | ||
} | ||
@@ -179,0 +179,0 @@ return { union } |
27462