Merge pull request #10984 from matheo/fix/compodoc-parsing

Addon-docs: Handle JSON.parse exception for Angular union types
This commit is contained in:
Michael Shilman 2020-05-30 01:53:50 +08:00 committed by GitHub
commit a7f7010263
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -101,7 +101,12 @@ const extractEnumValues = (compodocType: any) => {
if (typeof compodocType !== 'string' || compodocType.indexOf('|') === -1) {
return null;
}
return compodocType.split('|').map((value) => JSON.parse(value));
try {
return compodocType.split('|').map((value) => JSON.parse(value));
} catch (e) {
return null;
}
};
export const extractType = (property: Property, defaultValue: any) => {
@ -127,7 +132,7 @@ const extractDefaultValue = (property: Property) => {
const value = eval(property.defaultValue);
return value;
} catch (err) {
logger.info(`Error extracting ${property.name}: $ {property.defaultValue}`);
logger.debug(`Error extracting ${property.name}: ${property.defaultValue}`);
return undefined;
}
};