ts generator: allow reserved keywords in interfaces (#8627)

This commit is contained in:
James Garbutt 2018-09-10 15:22:36 +01:00 committed by Brian Ng
parent 0e7d7cfccc
commit 252660f248

View File

@ -81,8 +81,12 @@ for (const type in t.NODE_FIELDS) {
); );
} }
if (t.isValidIdentifier(fieldName)) { const alphaNumeric = /^\w+$/;
if (t.isValidIdentifier(fieldName) || alphaNumeric.test(fieldName)) {
struct.push(`${fieldName}: ${typeAnnotation};`); struct.push(`${fieldName}: ${typeAnnotation};`);
} else {
struct.push(`"${fieldName}": ${typeAnnotation};`);
} }
}); });