mirror of
https://github.com/photonstorm/phaser
synced 2024-11-28 15:41:37 +00:00
Merge pull request #6030 from xmahle/handle-nullable-in-parser
Handle nullable in parser.parseType
This commit is contained in:
commit
a9793f3261
1 changed files with 5 additions and 2 deletions
|
@ -490,7 +490,7 @@ export class Parser {
|
|||
continue;
|
||||
}
|
||||
|
||||
let param = dom.create.parameter(paramDoc.name, this.parseType(paramDoc));
|
||||
let param = dom.create.parameter(paramDoc.name, this.parseType(paramDoc, dom.type.undefined));
|
||||
parameters.push(param);
|
||||
|
||||
if (optional && paramDoc.optional != true) {
|
||||
|
@ -514,7 +514,7 @@ export class Parser {
|
|||
obj.parameters = parameters;
|
||||
}
|
||||
|
||||
private parseType(typeDoc: any): dom.Type {
|
||||
private parseType(typeDoc: any, nullableType = dom.type.null): dom.Type {
|
||||
if (!typeDoc || !typeDoc.type) {
|
||||
return dom.type.any;
|
||||
} else {
|
||||
|
@ -527,6 +527,9 @@ export class Parser {
|
|||
|
||||
types.push(type);
|
||||
}
|
||||
if (typeDoc.nullable) {
|
||||
types.push(nullableType);
|
||||
}
|
||||
if (types.length == 1) return types[0];
|
||||
else return dom.create.union(types);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue