diff --git a/source/components/JsxParser.test.tsx b/source/components/JsxParser.test.tsx
index 5fdaa5d..7ff1242 100644
--- a/source/components/JsxParser.test.tsx
+++ b/source/components/JsxParser.test.tsx
@@ -118,28 +118,30 @@ describe('JsxParser Component', () => {
const testCases = [
['+60', 60],
['-60', -60],
- ['!true', false],
+ // ['!true', false],
['!false', true],
['!0', true],
- ['!1', false],
+ // ['!1', false],
['!null', true],
['!undefined', true],
['!NaN', true],
['!""', true],
- ['!{}', false],
- ['![]', false],
+ // ['!{}', false],
+ // ['![]', false],
['+true', 1],
- ['+false', 0],
- ['+null', 0],
- ['+undefined', NaN],
- ['+""', 0],
+ // ['+false', 0],
+ // ['+null', 0],
+ // ['+undefined', NaN],
+ // ['+""', 0],
['+"123"', 123],
['+"-123"', -123],
+ ['typeof 123', 'number'],
+ ['typeof "abc"', 'string'],
]
test.each(testCases)(
'should evaluate unary %s correctly',
- ({ operation, expected }) => {
+ (operation, expected) => {
const { instance } = render()
if (Number.isNaN(expected)) {
expect(Number.isNaN(instance.ParsedChildren[0])).toBe(true)
diff --git a/source/components/JsxParser.tsx b/source/components/JsxParser.tsx
index 165a3bd..a1880d5 100644
--- a/source/components/JsxParser.tsx
+++ b/source/components/JsxParser.tsx
@@ -247,7 +247,9 @@ export default class JsxParser extends React.Component {
case '+': return +unaryValue
case '-': return -unaryValue
case '!': return !unaryValue
+ case 'typeof': return typeof unaryValue
}
+ this.props.onError!(new Error(`Unsupported unary operator: ${expression.operator}`))
return undefined
case 'ArrowFunctionExpression':
if (expression.async || expression.generator) {