Skip to content

Commit

Permalink
ts generator: allow reserved keywords in interfaces (#8627)
Browse files Browse the repository at this point in the history
  • Loading branch information
43081j authored and existentialism committed Sep 10, 2018
1 parent 0e7d7cf commit 252660f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion scripts/generators/typescript.js
Expand Up @@ -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};`);
} else {
struct.push(`"${fieldName}": ${typeAnnotation};`);
}
});

Expand Down

0 comments on commit 252660f

Please sign in to comment.