Skip to content

Instantly share code, notes, and snippets.

@sbdchd
Created January 18, 2019 00:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbdchd/82c961f64035708ce289652458f922c2 to your computer and use it in GitHub Desktop.
Save sbdchd/82c961f64035708ce289652458f922c2 to your computer and use it in GitHub Desktop.
function isValidPropertyName(node: ts.ComputedPropertyName): boolean {
if (
ts.isStringLiteral(node.expression) &&
isValidEs6Identifier(node.expression.text)
) {
return true
}
if (ts.isNumericLiteral(node.expression)) {
return true
}
return false
}
function isValidPropertyName2(node: ts.ComputedPropertyName): boolean {
return (
(ts.isStringLiteral(node.expression) &&
isValidEs6Identifier(node.expression.text)) ||
ts.isNumericLiteral(node.expression)
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment