diff --git a/scripts/generators/typescript.js b/scripts/generators/typescript.js index d2dcd13e9fa1..0cd5ff4042e2 100644 --- a/scripts/generators/typescript.js +++ b/scripts/generators/typescript.js @@ -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};`); } });