UNPKG

sucrase

Version:

Super-fast alternative to Babel for when you can target modern JS runtimes

21 lines (20 loc) 927 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * An "atom" in this context is a token that is an expression all by itself, * like an identifier or a literal. */ function isTypeExpressionAtom(tokenType) { return ["name", "num", "string", "false", "true", "null", "void", "this"].includes(tokenType.label); } exports.isTypeExpressionAtom = isTypeExpressionAtom; function isTypeExpressionPrefix(tokenType) { // typeof isn't considered a prefix operator because its operand is an identifier, not a type. // The union and intersection are also allowed in a leading position and have no effect. return ["?", "|", "&"].includes(tokenType.label); } exports.isTypeExpressionPrefix = isTypeExpressionPrefix; function isTypeBinop(token) { return (["|", "&"].includes(token.type.label) || (token.type.label === "name" && token.value === "is")); } exports.isTypeBinop = isTypeBinop;