Typescript all the parser things
This commit is contained in:
11
app/imports/parser/toPrimitiveOrString.ts
Normal file
11
app/imports/parser/toPrimitiveOrString.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import ParseNode from '/imports/parser/parseTree/ParseNode';
|
||||
import { ConstantValueType } from '/imports/parser/parseTree/constant';
|
||||
import toString from './toString';
|
||||
|
||||
|
||||
export default function toPrimitiveOrString(node: ParseNode): ConstantValueType {
|
||||
if (!node) return '';
|
||||
if (node.parseType === 'constant') return node.value;
|
||||
if (node.parseType === 'error') return undefined;
|
||||
return toString(node);
|
||||
}
|
||||
Reference in New Issue
Block a user