Comparing version 3.15.0 to 3.16.0
@@ -0,1 +1,6 @@ | ||
# 3.16.0 (2020-10-12) | ||
* Add support for TypeScript 4.0 type syntax: labeled tuples, catch clause | ||
`unknown`. ([#556]) (Patrik Oldsberg) | ||
# 3.15.0 (2020-05-18) | ||
@@ -296,1 +301,2 @@ | ||
[#537]: https://github.com/alangpierce/sucrase/pull/537 | ||
[#556]: https://github.com/alangpierce/sucrase/pull/556 |
@@ -370,2 +370,3 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); | ||
while (!_index.eat.call(void 0, _types.TokenType.bracketR) && !_base.state.error) { | ||
// Do not validate presence of either none or only labeled elements | ||
tsParseTupleElementType(); | ||
@@ -380,7 +381,13 @@ _index.eat.call(void 0, _types.TokenType.comma); | ||
tsParseType(); | ||
return; | ||
} else { | ||
// parses `TsType?` | ||
tsParseType(); | ||
_index.eat.call(void 0, _types.TokenType.question); | ||
} | ||
// parses `TsType?` | ||
tsParseType(); | ||
_index.eat.call(void 0, _types.TokenType.question); | ||
// The type we parsed above was actually a label | ||
if (_index.eat.call(void 0, _types.TokenType.colon)) { | ||
// Labeled tuple types must affix the label with `...` or `?`, so no need to handle those here | ||
tsParseType(); | ||
} | ||
} | ||
@@ -417,2 +424,4 @@ | ||
case _types.TokenType.num: | ||
case _types.TokenType.bigint: | ||
case _types.TokenType.decimal: | ||
case _types.TokenType._true: | ||
@@ -419,0 +428,0 @@ case _types.TokenType._false: |
@@ -58,2 +58,5 @@ import { ContextualKeyword } from "./keywords"; | ||
export declare function lookaheadTypeAndKeyword(): TypeAndKeyword; | ||
export declare function nextTokenStart(): number; | ||
export declare function nextTokenStartSince(pos: number): number; | ||
export declare function lookaheadCharCode(): number; | ||
export declare function nextToken(): void; | ||
@@ -60,0 +63,0 @@ export declare function skipLineComment(startSkip: number): void; |
@@ -221,2 +221,16 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }/* eslint max-len: 0 */ | ||
function nextTokenStart() { | ||
return nextTokenStartSince(_base.state.pos); | ||
} exports.nextTokenStart = nextTokenStart; | ||
function nextTokenStartSince(pos) { | ||
_whitespace.skipWhiteSpace.lastIndex = pos; | ||
const skip = _whitespace.skipWhiteSpace.exec(_base.input); | ||
return pos + skip[0].length; | ||
} exports.nextTokenStartSince = nextTokenStartSince; | ||
function lookaheadCharCode() { | ||
return _base.input.charCodeAt(nextTokenStart()); | ||
} exports.lookaheadCharCode = lookaheadCharCode; | ||
// Read a single token, updating the parser object's token-related | ||
@@ -753,2 +767,3 @@ // properties. | ||
let isBigInt = false; | ||
const start = _base.state.pos; | ||
@@ -758,5 +773,8 @@ _base.state.pos += 2; // 0x | ||
if (_base.input.charCodeAt(_base.state.pos) === _charcodes.charCodes.lowercaseN) { | ||
const nextChar = _base.input.charCodeAt(_base.state.pos); | ||
if (nextChar === _charcodes.charCodes.lowercaseN) { | ||
++_base.state.pos; | ||
isBigInt = true; | ||
} else if (nextChar === _charcodes.charCodes.lowercaseM) { | ||
_util.unexpected.call(void 0, "Invalid decimal", start); | ||
} | ||
@@ -775,2 +793,3 @@ | ||
let isBigInt = false; | ||
let isDecimal = false; | ||
@@ -800,2 +819,5 @@ if (!startsWithDot) { | ||
isBigInt = true; | ||
} else if (nextChar === _charcodes.charCodes.lowercaseM) { | ||
++_base.state.pos; | ||
isDecimal = true; | ||
} | ||
@@ -807,2 +829,8 @@ | ||
} | ||
if (isDecimal) { | ||
finishToken(_types.TokenType.decimal); | ||
return; | ||
} | ||
finishToken(_types.TokenType.num); | ||
@@ -809,0 +837,0 @@ } |
@@ -13,110 +13,111 @@ /** | ||
bigint = 512, | ||
regexp = 1024, | ||
string = 1536, | ||
name = 2048, | ||
eof = 2560, | ||
bracketL = 3072, | ||
bracketR = 3584, | ||
braceL = 4096, | ||
braceBarL = 4608, | ||
braceR = 5120, | ||
braceBarR = 5632, | ||
parenL = 6144, | ||
parenR = 6656, | ||
comma = 7168, | ||
semi = 7680, | ||
colon = 8192, | ||
doubleColon = 8704, | ||
dot = 9216, | ||
question = 9728, | ||
questionDot = 10240, | ||
arrow = 10752, | ||
template = 11264, | ||
ellipsis = 11776, | ||
backQuote = 12288, | ||
dollarBraceL = 12800, | ||
at = 13312, | ||
hash = 13824, | ||
eq = 14368, | ||
assign = 14880, | ||
preIncDec = 15744, | ||
postIncDec = 16256, | ||
bang = 16512, | ||
tilde = 17024, | ||
pipeline = 17409, | ||
nullishCoalescing = 17922, | ||
logicalOR = 18434, | ||
logicalAND = 18947, | ||
bitwiseOR = 19460, | ||
bitwiseXOR = 19973, | ||
bitwiseAND = 20486, | ||
equality = 20999, | ||
lessThan = 21512, | ||
greaterThan = 22024, | ||
relationalOrEqual = 22536, | ||
bitShift = 23049, | ||
plus = 23690, | ||
minus = 24202, | ||
modulo = 24587, | ||
star = 25099, | ||
slash = 25611, | ||
exponent = 26188, | ||
jsxName = 26624, | ||
jsxText = 27136, | ||
jsxTagStart = 27648, | ||
jsxTagEnd = 28160, | ||
typeParameterStart = 28672, | ||
nonNullAssertion = 29184, | ||
_break = 29712, | ||
_case = 30224, | ||
_catch = 30736, | ||
_continue = 31248, | ||
_debugger = 31760, | ||
_default = 32272, | ||
_do = 32784, | ||
_else = 33296, | ||
_finally = 33808, | ||
_for = 34320, | ||
_function = 34832, | ||
_if = 35344, | ||
_return = 35856, | ||
_switch = 36368, | ||
_throw = 37008, | ||
_try = 37392, | ||
_var = 37904, | ||
_let = 38416, | ||
_const = 38928, | ||
_while = 39440, | ||
_with = 39952, | ||
_new = 40464, | ||
_this = 40976, | ||
_super = 41488, | ||
_class = 42000, | ||
_extends = 42512, | ||
_export = 43024, | ||
_import = 43536, | ||
_yield = 44048, | ||
_null = 44560, | ||
_true = 45072, | ||
_false = 45584, | ||
_in = 46104, | ||
_instanceof = 46616, | ||
_typeof = 47248, | ||
_void = 47760, | ||
_delete = 48272, | ||
_async = 48656, | ||
_get = 49168, | ||
_set = 49680, | ||
_declare = 50192, | ||
_readonly = 50704, | ||
_abstract = 51216, | ||
_static = 51728, | ||
_public = 52240, | ||
_private = 52752, | ||
_protected = 53264, | ||
_as = 53776, | ||
_enum = 54288, | ||
_type = 54800, | ||
_implements = 55312 | ||
decimal = 1024, | ||
regexp = 1536, | ||
string = 2048, | ||
name = 2560, | ||
eof = 3072, | ||
bracketL = 3584, | ||
bracketR = 4096, | ||
braceL = 4608, | ||
braceBarL = 5120, | ||
braceR = 5632, | ||
braceBarR = 6144, | ||
parenL = 6656, | ||
parenR = 7168, | ||
comma = 7680, | ||
semi = 8192, | ||
colon = 8704, | ||
doubleColon = 9216, | ||
dot = 9728, | ||
question = 10240, | ||
questionDot = 10752, | ||
arrow = 11264, | ||
template = 11776, | ||
ellipsis = 12288, | ||
backQuote = 12800, | ||
dollarBraceL = 13312, | ||
at = 13824, | ||
hash = 14336, | ||
eq = 14880, | ||
assign = 15392, | ||
preIncDec = 16256, | ||
postIncDec = 16768, | ||
bang = 17024, | ||
tilde = 17536, | ||
pipeline = 17921, | ||
nullishCoalescing = 18434, | ||
logicalOR = 18946, | ||
logicalAND = 19459, | ||
bitwiseOR = 19972, | ||
bitwiseXOR = 20485, | ||
bitwiseAND = 20998, | ||
equality = 21511, | ||
lessThan = 22024, | ||
greaterThan = 22536, | ||
relationalOrEqual = 23048, | ||
bitShift = 23561, | ||
plus = 24202, | ||
minus = 24714, | ||
modulo = 25099, | ||
star = 25611, | ||
slash = 26123, | ||
exponent = 26700, | ||
jsxName = 27136, | ||
jsxText = 27648, | ||
jsxTagStart = 28160, | ||
jsxTagEnd = 28672, | ||
typeParameterStart = 29184, | ||
nonNullAssertion = 29696, | ||
_break = 30224, | ||
_case = 30736, | ||
_catch = 31248, | ||
_continue = 31760, | ||
_debugger = 32272, | ||
_default = 32784, | ||
_do = 33296, | ||
_else = 33808, | ||
_finally = 34320, | ||
_for = 34832, | ||
_function = 35344, | ||
_if = 35856, | ||
_return = 36368, | ||
_switch = 36880, | ||
_throw = 37520, | ||
_try = 37904, | ||
_var = 38416, | ||
_let = 38928, | ||
_const = 39440, | ||
_while = 39952, | ||
_with = 40464, | ||
_new = 40976, | ||
_this = 41488, | ||
_super = 42000, | ||
_class = 42512, | ||
_extends = 43024, | ||
_export = 43536, | ||
_import = 44048, | ||
_yield = 44560, | ||
_null = 45072, | ||
_true = 45584, | ||
_false = 46096, | ||
_in = 46616, | ||
_instanceof = 47128, | ||
_typeof = 47760, | ||
_void = 48272, | ||
_delete = 48784, | ||
_async = 49168, | ||
_get = 49680, | ||
_set = 50192, | ||
_declare = 50704, | ||
_readonly = 51216, | ||
_abstract = 51728, | ||
_static = 52240, | ||
_public = 52752, | ||
_private = 53264, | ||
_protected = 53776, | ||
_as = 54288, | ||
_enum = 54800, | ||
_type = 55312, | ||
_implements = 55824 | ||
} | ||
export declare function formatTokenType(tokenType: TokenType): string; |
@@ -16,109 +16,110 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// Generated file, do not edit! Run "yarn generate" to re-generate this file. | ||
const bigint = 512; TokenType[TokenType["bigint"] = bigint] = "bigint"; // bigint | ||
const regexp = 1024; TokenType[TokenType["regexp"] = regexp] = "regexp"; // regexp | ||
const string = 1536; TokenType[TokenType["string"] = string] = "string"; // string | ||
const name = 2048; TokenType[TokenType["name"] = name] = "name"; // name | ||
const eof = 2560; TokenType[TokenType["eof"] = eof] = "eof"; // eof | ||
const bracketL = 3072; TokenType[TokenType["bracketL"] = bracketL] = "bracketL"; // [ | ||
const bracketR = 3584; TokenType[TokenType["bracketR"] = bracketR] = "bracketR"; // ] | ||
const braceL = 4096; TokenType[TokenType["braceL"] = braceL] = "braceL"; // { | ||
const braceBarL = 4608; TokenType[TokenType["braceBarL"] = braceBarL] = "braceBarL"; // {| | ||
const braceR = 5120; TokenType[TokenType["braceR"] = braceR] = "braceR"; // } | ||
const braceBarR = 5632; TokenType[TokenType["braceBarR"] = braceBarR] = "braceBarR"; // |} | ||
const parenL = 6144; TokenType[TokenType["parenL"] = parenL] = "parenL"; // ( | ||
const parenR = 6656; TokenType[TokenType["parenR"] = parenR] = "parenR"; // ) | ||
const comma = 7168; TokenType[TokenType["comma"] = comma] = "comma"; // , | ||
const semi = 7680; TokenType[TokenType["semi"] = semi] = "semi"; // ; | ||
const colon = 8192; TokenType[TokenType["colon"] = colon] = "colon"; // : | ||
const doubleColon = 8704; TokenType[TokenType["doubleColon"] = doubleColon] = "doubleColon"; // :: | ||
const dot = 9216; TokenType[TokenType["dot"] = dot] = "dot"; // . | ||
const question = 9728; TokenType[TokenType["question"] = question] = "question"; // ? | ||
const questionDot = 10240; TokenType[TokenType["questionDot"] = questionDot] = "questionDot"; // ?. | ||
const arrow = 10752; TokenType[TokenType["arrow"] = arrow] = "arrow"; // => | ||
const template = 11264; TokenType[TokenType["template"] = template] = "template"; // template | ||
const ellipsis = 11776; TokenType[TokenType["ellipsis"] = ellipsis] = "ellipsis"; // ... | ||
const backQuote = 12288; TokenType[TokenType["backQuote"] = backQuote] = "backQuote"; // ` | ||
const dollarBraceL = 12800; TokenType[TokenType["dollarBraceL"] = dollarBraceL] = "dollarBraceL"; // ${ | ||
const at = 13312; TokenType[TokenType["at"] = at] = "at"; // @ | ||
const hash = 13824; TokenType[TokenType["hash"] = hash] = "hash"; // # | ||
const eq = 14368; TokenType[TokenType["eq"] = eq] = "eq"; // = isAssign | ||
const assign = 14880; TokenType[TokenType["assign"] = assign] = "assign"; // _= isAssign | ||
const preIncDec = 15744; TokenType[TokenType["preIncDec"] = preIncDec] = "preIncDec"; // ++/-- prefix postfix | ||
const postIncDec = 16256; TokenType[TokenType["postIncDec"] = postIncDec] = "postIncDec"; // ++/-- prefix postfix | ||
const bang = 16512; TokenType[TokenType["bang"] = bang] = "bang"; // ! prefix | ||
const tilde = 17024; TokenType[TokenType["tilde"] = tilde] = "tilde"; // ~ prefix | ||
const pipeline = 17409; TokenType[TokenType["pipeline"] = pipeline] = "pipeline"; // |> prec:1 | ||
const nullishCoalescing = 17922; TokenType[TokenType["nullishCoalescing"] = nullishCoalescing] = "nullishCoalescing"; // ?? prec:2 | ||
const logicalOR = 18434; TokenType[TokenType["logicalOR"] = logicalOR] = "logicalOR"; // || prec:2 | ||
const logicalAND = 18947; TokenType[TokenType["logicalAND"] = logicalAND] = "logicalAND"; // && prec:3 | ||
const bitwiseOR = 19460; TokenType[TokenType["bitwiseOR"] = bitwiseOR] = "bitwiseOR"; // | prec:4 | ||
const bitwiseXOR = 19973; TokenType[TokenType["bitwiseXOR"] = bitwiseXOR] = "bitwiseXOR"; // ^ prec:5 | ||
const bitwiseAND = 20486; TokenType[TokenType["bitwiseAND"] = bitwiseAND] = "bitwiseAND"; // & prec:6 | ||
const equality = 20999; TokenType[TokenType["equality"] = equality] = "equality"; // ==/!= prec:7 | ||
const lessThan = 21512; TokenType[TokenType["lessThan"] = lessThan] = "lessThan"; // < prec:8 | ||
const greaterThan = 22024; TokenType[TokenType["greaterThan"] = greaterThan] = "greaterThan"; // > prec:8 | ||
const relationalOrEqual = 22536; TokenType[TokenType["relationalOrEqual"] = relationalOrEqual] = "relationalOrEqual"; // <=/>= prec:8 | ||
const bitShift = 23049; TokenType[TokenType["bitShift"] = bitShift] = "bitShift"; // <</>> prec:9 | ||
const plus = 23690; TokenType[TokenType["plus"] = plus] = "plus"; // + prec:10 prefix | ||
const minus = 24202; TokenType[TokenType["minus"] = minus] = "minus"; // - prec:10 prefix | ||
const modulo = 24587; TokenType[TokenType["modulo"] = modulo] = "modulo"; // % prec:11 | ||
const star = 25099; TokenType[TokenType["star"] = star] = "star"; // * prec:11 | ||
const slash = 25611; TokenType[TokenType["slash"] = slash] = "slash"; // / prec:11 | ||
const exponent = 26188; TokenType[TokenType["exponent"] = exponent] = "exponent"; // ** prec:12 rightAssociative | ||
const jsxName = 26624; TokenType[TokenType["jsxName"] = jsxName] = "jsxName"; // jsxName | ||
const jsxText = 27136; TokenType[TokenType["jsxText"] = jsxText] = "jsxText"; // jsxText | ||
const jsxTagStart = 27648; TokenType[TokenType["jsxTagStart"] = jsxTagStart] = "jsxTagStart"; // jsxTagStart | ||
const jsxTagEnd = 28160; TokenType[TokenType["jsxTagEnd"] = jsxTagEnd] = "jsxTagEnd"; // jsxTagEnd | ||
const typeParameterStart = 28672; TokenType[TokenType["typeParameterStart"] = typeParameterStart] = "typeParameterStart"; // typeParameterStart | ||
const nonNullAssertion = 29184; TokenType[TokenType["nonNullAssertion"] = nonNullAssertion] = "nonNullAssertion"; // nonNullAssertion | ||
const _break = 29712; TokenType[TokenType["_break"] = _break] = "_break"; // break keyword | ||
const _case = 30224; TokenType[TokenType["_case"] = _case] = "_case"; // case keyword | ||
const _catch = 30736; TokenType[TokenType["_catch"] = _catch] = "_catch"; // catch keyword | ||
const _continue = 31248; TokenType[TokenType["_continue"] = _continue] = "_continue"; // continue keyword | ||
const _debugger = 31760; TokenType[TokenType["_debugger"] = _debugger] = "_debugger"; // debugger keyword | ||
const _default = 32272; TokenType[TokenType["_default"] = _default] = "_default"; // default keyword | ||
const _do = 32784; TokenType[TokenType["_do"] = _do] = "_do"; // do keyword | ||
const _else = 33296; TokenType[TokenType["_else"] = _else] = "_else"; // else keyword | ||
const _finally = 33808; TokenType[TokenType["_finally"] = _finally] = "_finally"; // finally keyword | ||
const _for = 34320; TokenType[TokenType["_for"] = _for] = "_for"; // for keyword | ||
const _function = 34832; TokenType[TokenType["_function"] = _function] = "_function"; // function keyword | ||
const _if = 35344; TokenType[TokenType["_if"] = _if] = "_if"; // if keyword | ||
const _return = 35856; TokenType[TokenType["_return"] = _return] = "_return"; // return keyword | ||
const _switch = 36368; TokenType[TokenType["_switch"] = _switch] = "_switch"; // switch keyword | ||
const _throw = 37008; TokenType[TokenType["_throw"] = _throw] = "_throw"; // throw keyword prefix | ||
const _try = 37392; TokenType[TokenType["_try"] = _try] = "_try"; // try keyword | ||
const _var = 37904; TokenType[TokenType["_var"] = _var] = "_var"; // var keyword | ||
const _let = 38416; TokenType[TokenType["_let"] = _let] = "_let"; // let keyword | ||
const _const = 38928; TokenType[TokenType["_const"] = _const] = "_const"; // const keyword | ||
const _while = 39440; TokenType[TokenType["_while"] = _while] = "_while"; // while keyword | ||
const _with = 39952; TokenType[TokenType["_with"] = _with] = "_with"; // with keyword | ||
const _new = 40464; TokenType[TokenType["_new"] = _new] = "_new"; // new keyword | ||
const _this = 40976; TokenType[TokenType["_this"] = _this] = "_this"; // this keyword | ||
const _super = 41488; TokenType[TokenType["_super"] = _super] = "_super"; // super keyword | ||
const _class = 42000; TokenType[TokenType["_class"] = _class] = "_class"; // class keyword | ||
const _extends = 42512; TokenType[TokenType["_extends"] = _extends] = "_extends"; // extends keyword | ||
const _export = 43024; TokenType[TokenType["_export"] = _export] = "_export"; // export keyword | ||
const _import = 43536; TokenType[TokenType["_import"] = _import] = "_import"; // import keyword | ||
const _yield = 44048; TokenType[TokenType["_yield"] = _yield] = "_yield"; // yield keyword | ||
const _null = 44560; TokenType[TokenType["_null"] = _null] = "_null"; // null keyword | ||
const _true = 45072; TokenType[TokenType["_true"] = _true] = "_true"; // true keyword | ||
const _false = 45584; TokenType[TokenType["_false"] = _false] = "_false"; // false keyword | ||
const _in = 46104; TokenType[TokenType["_in"] = _in] = "_in"; // in prec:8 keyword | ||
const _instanceof = 46616; TokenType[TokenType["_instanceof"] = _instanceof] = "_instanceof"; // instanceof prec:8 keyword | ||
const _typeof = 47248; TokenType[TokenType["_typeof"] = _typeof] = "_typeof"; // typeof keyword prefix | ||
const _void = 47760; TokenType[TokenType["_void"] = _void] = "_void"; // void keyword prefix | ||
const _delete = 48272; TokenType[TokenType["_delete"] = _delete] = "_delete"; // delete keyword prefix | ||
const _async = 48656; TokenType[TokenType["_async"] = _async] = "_async"; // async keyword | ||
const _get = 49168; TokenType[TokenType["_get"] = _get] = "_get"; // get keyword | ||
const _set = 49680; TokenType[TokenType["_set"] = _set] = "_set"; // set keyword | ||
const _declare = 50192; TokenType[TokenType["_declare"] = _declare] = "_declare"; // declare keyword | ||
const _readonly = 50704; TokenType[TokenType["_readonly"] = _readonly] = "_readonly"; // readonly keyword | ||
const _abstract = 51216; TokenType[TokenType["_abstract"] = _abstract] = "_abstract"; // abstract keyword | ||
const _static = 51728; TokenType[TokenType["_static"] = _static] = "_static"; // static keyword | ||
const _public = 52240; TokenType[TokenType["_public"] = _public] = "_public"; // public keyword | ||
const _private = 52752; TokenType[TokenType["_private"] = _private] = "_private"; // private keyword | ||
const _protected = 53264; TokenType[TokenType["_protected"] = _protected] = "_protected"; // protected keyword | ||
const _as = 53776; TokenType[TokenType["_as"] = _as] = "_as"; // as keyword | ||
const _enum = 54288; TokenType[TokenType["_enum"] = _enum] = "_enum"; // enum keyword | ||
const _type = 54800; TokenType[TokenType["_type"] = _type] = "_type"; // type keyword | ||
const _implements = 55312; TokenType[TokenType["_implements"] = _implements] = "_implements"; // implements keyword | ||
const decimal = 1024; TokenType[TokenType["decimal"] = decimal] = "decimal"; // decimal | ||
const regexp = 1536; TokenType[TokenType["regexp"] = regexp] = "regexp"; // regexp | ||
const string = 2048; TokenType[TokenType["string"] = string] = "string"; // string | ||
const name = 2560; TokenType[TokenType["name"] = name] = "name"; // name | ||
const eof = 3072; TokenType[TokenType["eof"] = eof] = "eof"; // eof | ||
const bracketL = 3584; TokenType[TokenType["bracketL"] = bracketL] = "bracketL"; // [ | ||
const bracketR = 4096; TokenType[TokenType["bracketR"] = bracketR] = "bracketR"; // ] | ||
const braceL = 4608; TokenType[TokenType["braceL"] = braceL] = "braceL"; // { | ||
const braceBarL = 5120; TokenType[TokenType["braceBarL"] = braceBarL] = "braceBarL"; // {| | ||
const braceR = 5632; TokenType[TokenType["braceR"] = braceR] = "braceR"; // } | ||
const braceBarR = 6144; TokenType[TokenType["braceBarR"] = braceBarR] = "braceBarR"; // |} | ||
const parenL = 6656; TokenType[TokenType["parenL"] = parenL] = "parenL"; // ( | ||
const parenR = 7168; TokenType[TokenType["parenR"] = parenR] = "parenR"; // ) | ||
const comma = 7680; TokenType[TokenType["comma"] = comma] = "comma"; // , | ||
const semi = 8192; TokenType[TokenType["semi"] = semi] = "semi"; // ; | ||
const colon = 8704; TokenType[TokenType["colon"] = colon] = "colon"; // : | ||
const doubleColon = 9216; TokenType[TokenType["doubleColon"] = doubleColon] = "doubleColon"; // :: | ||
const dot = 9728; TokenType[TokenType["dot"] = dot] = "dot"; // . | ||
const question = 10240; TokenType[TokenType["question"] = question] = "question"; // ? | ||
const questionDot = 10752; TokenType[TokenType["questionDot"] = questionDot] = "questionDot"; // ?. | ||
const arrow = 11264; TokenType[TokenType["arrow"] = arrow] = "arrow"; // => | ||
const template = 11776; TokenType[TokenType["template"] = template] = "template"; // template | ||
const ellipsis = 12288; TokenType[TokenType["ellipsis"] = ellipsis] = "ellipsis"; // ... | ||
const backQuote = 12800; TokenType[TokenType["backQuote"] = backQuote] = "backQuote"; // ` | ||
const dollarBraceL = 13312; TokenType[TokenType["dollarBraceL"] = dollarBraceL] = "dollarBraceL"; // ${ | ||
const at = 13824; TokenType[TokenType["at"] = at] = "at"; // @ | ||
const hash = 14336; TokenType[TokenType["hash"] = hash] = "hash"; // # | ||
const eq = 14880; TokenType[TokenType["eq"] = eq] = "eq"; // = isAssign | ||
const assign = 15392; TokenType[TokenType["assign"] = assign] = "assign"; // _= isAssign | ||
const preIncDec = 16256; TokenType[TokenType["preIncDec"] = preIncDec] = "preIncDec"; // ++/-- prefix postfix | ||
const postIncDec = 16768; TokenType[TokenType["postIncDec"] = postIncDec] = "postIncDec"; // ++/-- prefix postfix | ||
const bang = 17024; TokenType[TokenType["bang"] = bang] = "bang"; // ! prefix | ||
const tilde = 17536; TokenType[TokenType["tilde"] = tilde] = "tilde"; // ~ prefix | ||
const pipeline = 17921; TokenType[TokenType["pipeline"] = pipeline] = "pipeline"; // |> prec:1 | ||
const nullishCoalescing = 18434; TokenType[TokenType["nullishCoalescing"] = nullishCoalescing] = "nullishCoalescing"; // ?? prec:2 | ||
const logicalOR = 18946; TokenType[TokenType["logicalOR"] = logicalOR] = "logicalOR"; // || prec:2 | ||
const logicalAND = 19459; TokenType[TokenType["logicalAND"] = logicalAND] = "logicalAND"; // && prec:3 | ||
const bitwiseOR = 19972; TokenType[TokenType["bitwiseOR"] = bitwiseOR] = "bitwiseOR"; // | prec:4 | ||
const bitwiseXOR = 20485; TokenType[TokenType["bitwiseXOR"] = bitwiseXOR] = "bitwiseXOR"; // ^ prec:5 | ||
const bitwiseAND = 20998; TokenType[TokenType["bitwiseAND"] = bitwiseAND] = "bitwiseAND"; // & prec:6 | ||
const equality = 21511; TokenType[TokenType["equality"] = equality] = "equality"; // ==/!= prec:7 | ||
const lessThan = 22024; TokenType[TokenType["lessThan"] = lessThan] = "lessThan"; // < prec:8 | ||
const greaterThan = 22536; TokenType[TokenType["greaterThan"] = greaterThan] = "greaterThan"; // > prec:8 | ||
const relationalOrEqual = 23048; TokenType[TokenType["relationalOrEqual"] = relationalOrEqual] = "relationalOrEqual"; // <=/>= prec:8 | ||
const bitShift = 23561; TokenType[TokenType["bitShift"] = bitShift] = "bitShift"; // <</>> prec:9 | ||
const plus = 24202; TokenType[TokenType["plus"] = plus] = "plus"; // + prec:10 prefix | ||
const minus = 24714; TokenType[TokenType["minus"] = minus] = "minus"; // - prec:10 prefix | ||
const modulo = 25099; TokenType[TokenType["modulo"] = modulo] = "modulo"; // % prec:11 | ||
const star = 25611; TokenType[TokenType["star"] = star] = "star"; // * prec:11 | ||
const slash = 26123; TokenType[TokenType["slash"] = slash] = "slash"; // / prec:11 | ||
const exponent = 26700; TokenType[TokenType["exponent"] = exponent] = "exponent"; // ** prec:12 rightAssociative | ||
const jsxName = 27136; TokenType[TokenType["jsxName"] = jsxName] = "jsxName"; // jsxName | ||
const jsxText = 27648; TokenType[TokenType["jsxText"] = jsxText] = "jsxText"; // jsxText | ||
const jsxTagStart = 28160; TokenType[TokenType["jsxTagStart"] = jsxTagStart] = "jsxTagStart"; // jsxTagStart | ||
const jsxTagEnd = 28672; TokenType[TokenType["jsxTagEnd"] = jsxTagEnd] = "jsxTagEnd"; // jsxTagEnd | ||
const typeParameterStart = 29184; TokenType[TokenType["typeParameterStart"] = typeParameterStart] = "typeParameterStart"; // typeParameterStart | ||
const nonNullAssertion = 29696; TokenType[TokenType["nonNullAssertion"] = nonNullAssertion] = "nonNullAssertion"; // nonNullAssertion | ||
const _break = 30224; TokenType[TokenType["_break"] = _break] = "_break"; // break keyword | ||
const _case = 30736; TokenType[TokenType["_case"] = _case] = "_case"; // case keyword | ||
const _catch = 31248; TokenType[TokenType["_catch"] = _catch] = "_catch"; // catch keyword | ||
const _continue = 31760; TokenType[TokenType["_continue"] = _continue] = "_continue"; // continue keyword | ||
const _debugger = 32272; TokenType[TokenType["_debugger"] = _debugger] = "_debugger"; // debugger keyword | ||
const _default = 32784; TokenType[TokenType["_default"] = _default] = "_default"; // default keyword | ||
const _do = 33296; TokenType[TokenType["_do"] = _do] = "_do"; // do keyword | ||
const _else = 33808; TokenType[TokenType["_else"] = _else] = "_else"; // else keyword | ||
const _finally = 34320; TokenType[TokenType["_finally"] = _finally] = "_finally"; // finally keyword | ||
const _for = 34832; TokenType[TokenType["_for"] = _for] = "_for"; // for keyword | ||
const _function = 35344; TokenType[TokenType["_function"] = _function] = "_function"; // function keyword | ||
const _if = 35856; TokenType[TokenType["_if"] = _if] = "_if"; // if keyword | ||
const _return = 36368; TokenType[TokenType["_return"] = _return] = "_return"; // return keyword | ||
const _switch = 36880; TokenType[TokenType["_switch"] = _switch] = "_switch"; // switch keyword | ||
const _throw = 37520; TokenType[TokenType["_throw"] = _throw] = "_throw"; // throw keyword prefix | ||
const _try = 37904; TokenType[TokenType["_try"] = _try] = "_try"; // try keyword | ||
const _var = 38416; TokenType[TokenType["_var"] = _var] = "_var"; // var keyword | ||
const _let = 38928; TokenType[TokenType["_let"] = _let] = "_let"; // let keyword | ||
const _const = 39440; TokenType[TokenType["_const"] = _const] = "_const"; // const keyword | ||
const _while = 39952; TokenType[TokenType["_while"] = _while] = "_while"; // while keyword | ||
const _with = 40464; TokenType[TokenType["_with"] = _with] = "_with"; // with keyword | ||
const _new = 40976; TokenType[TokenType["_new"] = _new] = "_new"; // new keyword | ||
const _this = 41488; TokenType[TokenType["_this"] = _this] = "_this"; // this keyword | ||
const _super = 42000; TokenType[TokenType["_super"] = _super] = "_super"; // super keyword | ||
const _class = 42512; TokenType[TokenType["_class"] = _class] = "_class"; // class keyword | ||
const _extends = 43024; TokenType[TokenType["_extends"] = _extends] = "_extends"; // extends keyword | ||
const _export = 43536; TokenType[TokenType["_export"] = _export] = "_export"; // export keyword | ||
const _import = 44048; TokenType[TokenType["_import"] = _import] = "_import"; // import keyword | ||
const _yield = 44560; TokenType[TokenType["_yield"] = _yield] = "_yield"; // yield keyword | ||
const _null = 45072; TokenType[TokenType["_null"] = _null] = "_null"; // null keyword | ||
const _true = 45584; TokenType[TokenType["_true"] = _true] = "_true"; // true keyword | ||
const _false = 46096; TokenType[TokenType["_false"] = _false] = "_false"; // false keyword | ||
const _in = 46616; TokenType[TokenType["_in"] = _in] = "_in"; // in prec:8 keyword | ||
const _instanceof = 47128; TokenType[TokenType["_instanceof"] = _instanceof] = "_instanceof"; // instanceof prec:8 keyword | ||
const _typeof = 47760; TokenType[TokenType["_typeof"] = _typeof] = "_typeof"; // typeof keyword prefix | ||
const _void = 48272; TokenType[TokenType["_void"] = _void] = "_void"; // void keyword prefix | ||
const _delete = 48784; TokenType[TokenType["_delete"] = _delete] = "_delete"; // delete keyword prefix | ||
const _async = 49168; TokenType[TokenType["_async"] = _async] = "_async"; // async keyword | ||
const _get = 49680; TokenType[TokenType["_get"] = _get] = "_get"; // get keyword | ||
const _set = 50192; TokenType[TokenType["_set"] = _set] = "_set"; // set keyword | ||
const _declare = 50704; TokenType[TokenType["_declare"] = _declare] = "_declare"; // declare keyword | ||
const _readonly = 51216; TokenType[TokenType["_readonly"] = _readonly] = "_readonly"; // readonly keyword | ||
const _abstract = 51728; TokenType[TokenType["_abstract"] = _abstract] = "_abstract"; // abstract keyword | ||
const _static = 52240; TokenType[TokenType["_static"] = _static] = "_static"; // static keyword | ||
const _public = 52752; TokenType[TokenType["_public"] = _public] = "_public"; // public keyword | ||
const _private = 53264; TokenType[TokenType["_private"] = _private] = "_private"; // private keyword | ||
const _protected = 53776; TokenType[TokenType["_protected"] = _protected] = "_protected"; // protected keyword | ||
const _as = 54288; TokenType[TokenType["_as"] = _as] = "_as"; // as keyword | ||
const _enum = 54800; TokenType[TokenType["_enum"] = _enum] = "_enum"; // enum keyword | ||
const _type = 55312; TokenType[TokenType["_type"] = _type] = "_type"; // type keyword | ||
const _implements = 55824; TokenType[TokenType["_implements"] = _implements] = "_implements"; // implements keyword | ||
})(TokenType || (exports.TokenType = TokenType = {})); | ||
@@ -131,2 +132,4 @@ function formatTokenType(tokenType) { | ||
return "bigint"; | ||
case TokenType.decimal: | ||
return "decimal"; | ||
case TokenType.regexp: | ||
@@ -133,0 +136,0 @@ return "regexp"; |
@@ -55,2 +55,3 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true});/* eslint max-len: 0 */ | ||
var _index3 = require('../tokenizer/index'); | ||
@@ -60,2 +61,4 @@ var _keywords = require('../tokenizer/keywords'); | ||
var _types3 = require('../tokenizer/types'); | ||
var _charcodes = require('../util/charcodes'); | ||
var _identifier = require('../util/identifier'); | ||
var _base = require('./base'); | ||
@@ -330,3 +333,3 @@ | ||
} else { | ||
parseIdentifier(); | ||
parseMaybePrivateName(); | ||
} | ||
@@ -462,2 +465,3 @@ } else if (_index3.eat.call(void 0, _types3.TokenType.dot)) { | ||
case _types3.TokenType.bigint: | ||
case _types3.TokenType.decimal: | ||
case _types3.TokenType.string: | ||
@@ -569,4 +573,9 @@ case _types3.TokenType._null: | ||
case _types3.TokenType.hash: { | ||
const code = _index3.lookaheadCharCode.call(void 0, ); | ||
if (_identifier.IS_IDENTIFIER_START[code] || code === _charcodes.charCodes.backslash) { | ||
parseMaybePrivateName(); | ||
} else { | ||
_index3.next.call(void 0, ); | ||
} | ||
// Smart pipeline topic reference. | ||
_index3.next.call(void 0, ); | ||
return false; | ||
@@ -795,5 +804,5 @@ } | ||
(_index3.match.call(void 0, _types3.TokenType.string) || // get "string"() {} | ||
_index3.match.call(void 0, _types3.TokenType.num) || // get 1() {} | ||
_index3.match.call(void 0, _types3.TokenType.bracketL) || // get ["string"]() {} | ||
_index3.match.call(void 0, _types3.TokenType.name) || // get foo() {} | ||
_index3.match.call(void 0, _types3.TokenType.num) || // get 1() {} | ||
_index3.match.call(void 0, _types3.TokenType.bracketL) || // get ["string"]() {} | ||
_index3.match.call(void 0, _types3.TokenType.name) || // get foo() {} | ||
!!(_base.state.type & _types3.TokenType.IS_KEYWORD)) // get debugger() {} | ||
@@ -876,3 +885,3 @@ ); | ||
} else { | ||
if (_index3.match.call(void 0, _types3.TokenType.num) || _index3.match.call(void 0, _types3.TokenType.string) || _index3.match.call(void 0, _types3.TokenType.bigint)) { | ||
if (_index3.match.call(void 0, _types3.TokenType.num) || _index3.match.call(void 0, _types3.TokenType.string) || _index3.match.call(void 0, _types3.TokenType.bigint) || _index3.match.call(void 0, _types3.TokenType.decimal)) { | ||
parseExprAtom(); | ||
@@ -879,0 +888,0 @@ } else { |
@@ -46,2 +46,4 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true});/* eslint max-len: 0 */ | ||
var _tokenizer = require('../tokenizer'); | ||
@@ -51,2 +53,3 @@ var _keywords = require('../tokenizer/keywords'); | ||
var _types = require('../tokenizer/types'); | ||
var _charcodes = require('../util/charcodes'); | ||
var _base = require('./base'); | ||
@@ -412,2 +415,10 @@ | ||
function parseCatchClauseParam() { | ||
_lval.parseBindingAtom.call(void 0, true /* isBlockScope */); | ||
if (_base.isTypeScriptEnabled) { | ||
_typescript.tsTryParseTypeAnnotation.call(void 0, ); | ||
} | ||
} | ||
function parseTryStatement() { | ||
@@ -425,3 +436,3 @@ _tokenizer.next.call(void 0, ); | ||
_util.expect.call(void 0, _types.TokenType.parenL); | ||
_lval.parseBindingAtom.call(void 0, true /* isBlockScope */); | ||
parseCatchClauseParam(); | ||
_util.expect.call(void 0, _types.TokenType.parenR); | ||
@@ -951,7 +962,15 @@ } | ||
const _next = _tokenizer.nextTokenStart.call(void 0, ); | ||
const lookahead = _tokenizer.lookaheadTypeAndKeyword.call(void 0, ); | ||
return ( | ||
lookahead.type === _types.TokenType.comma || | ||
(lookahead.type === _types.TokenType.name && lookahead.contextualKeyword === _keywords.ContextualKeyword._from) | ||
); | ||
const hasFrom = | ||
lookahead.type === _types.TokenType.name && lookahead.contextualKeyword === _keywords.ContextualKeyword._from; | ||
if (lookahead.type === _types.TokenType.comma) { | ||
return true; | ||
} | ||
// lookahead again when `export default from` is seen | ||
if (hasFrom) { | ||
const nextAfterFrom = _base.input.charCodeAt(_tokenizer.nextTokenStartSince.call(void 0, _next + 4)); | ||
return nextAfterFrom === _charcodes.charCodes.quotationMark || nextAfterFrom === _charcodes.charCodes.apostrophe; | ||
} | ||
return false; | ||
} | ||
@@ -958,0 +977,0 @@ |
export declare const WHITESPACE_CHARS: Array<number>; | ||
export declare const skipWhiteSpace: RegExp; | ||
export declare const IS_WHITESPACE: Uint8Array; |
@@ -28,2 +28,4 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _charcodes = require('./charcodes'); | ||
const skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g; exports.skipWhiteSpace = skipWhiteSpace; | ||
const IS_WHITESPACE = new Uint8Array(65536); exports.IS_WHITESPACE = IS_WHITESPACE; | ||
@@ -30,0 +32,0 @@ for (const char of exports.WHITESPACE_CHARS) { |
{ | ||
"name": "sucrase", | ||
"version": "3.15.0", | ||
"version": "3.16.0", | ||
"description": "Super-fast alternative to Babel for when you can target modern JS runtimes", | ||
@@ -61,3 +61,2 @@ "author": "Alan Pierce <alangpierce@gmail.com>", | ||
"@types/node": "^12.12.7", | ||
"@types/yargs-parser": "^13.1.0", | ||
"@typescript-eslint/parser": "^2.33.0", | ||
@@ -75,3 +74,3 @@ "chalk": "2.4.1", | ||
"prettier": "^2.0.5", | ||
"sucrase": "^3.14.1", | ||
"sucrase": "^3.15.0", | ||
"test262-harness": "^6.5.0", | ||
@@ -82,3 +81,3 @@ "ts-interface-builder": "^0.2.1", | ||
"typescript-tslint-plugin": "^0.5.4", | ||
"yargs-parser": "^16.1.0" | ||
"yargs-parser": "^19.0.4" | ||
}, | ||
@@ -85,0 +84,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
944793
31
24027