fix: 优化知识库助手

This commit is contained in:
Shu Guang 2025-05-17 17:11:36 +08:00
parent 255f707e0c
commit fb94445e63
249 changed files with 64537 additions and 55690 deletions

1854
node_modules/.package-lock.json generated vendored

File diff suppressed because it is too large Load Diff

View File

@ -154,7 +154,7 @@ function readEscapedChar(input, pos, lineStart, curLine, inTemplate, errors) {
default: default:
if (ch >= 48 && ch <= 55) { if (ch >= 48 && ch <= 55) {
const startPos = pos - 1; const startPos = pos - 1;
const match = input.slice(startPos, pos + 2).match(/^[0-7]+/); const match = /^[0-7]+/.exec(input.slice(startPos, pos + 2));
let octalStr = match[0]; let octalStr = match[0];
let octal = parseInt(octalStr, 8); let octal = parseInt(octalStr, 8);
if (octal > 255) { if (octal > 255) {

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"name": "@babel/helper-string-parser", "name": "@babel/helper-string-parser",
"version": "7.24.1", "version": "7.27.1",
"description": "A utility package to parse strings", "description": "A utility package to parse strings",
"repository": { "repository": {
"type": "git", "type": "git",
@ -21,7 +21,10 @@
}, },
"author": "The Babel Team (https://babel.dev/team)", "author": "The Babel Team (https://babel.dev/team)",
"exports": { "exports": {
".": "./lib/index.js", ".": {
"types": "./lib/index.d.ts",
"default": "./lib/index.js"
},
"./package.json": "./package.json" "./package.json": "./package.json"
}, },
"type": "commonjs" "type": "commonjs"

View File

@ -6,13 +6,13 @@ Object.defineProperty(exports, "__esModule", {
exports.isIdentifierChar = isIdentifierChar; exports.isIdentifierChar = isIdentifierChar;
exports.isIdentifierName = isIdentifierName; exports.isIdentifierName = isIdentifierName;
exports.isIdentifierStart = isIdentifierStart; exports.isIdentifierStart = isIdentifierStart;
let nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u0870-\u0887\u0889-\u088e\u08a0-\u08c9\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c5d\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cdd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u1711\u171f-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4c\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7ca\ua7d0\ua7d1\ua7d3\ua7d5-\ua7d9\ua7f2-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; let nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u0870-\u0887\u0889-\u088e\u08a0-\u08c9\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c5d\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cdd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u1711\u171f-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4c\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c8a\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7cd\ua7d0\ua7d1\ua7d3\ua7d5-\ua7dc\ua7f2-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
let nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u0898-\u089f\u08ca-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3c\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0cf3\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ece\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u180f-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf-\u1ace\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1dff\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\u30fb\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f\uff65"; let nonASCIIidentifierChars = "\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u0897-\u089f\u08ca-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3c\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0cf3\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ece\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u180f-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf-\u1ace\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1dff\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\u30fb\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f\uff65";
const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
nonASCIIidentifierStartChars = nonASCIIidentifierChars = null; nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
const astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 68, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 20, 1, 64, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 16, 0, 2, 12, 2, 33, 125, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1071, 18, 5, 4026, 582, 8634, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 43, 8, 8936, 3, 2, 6, 2, 1, 2, 290, 16, 0, 30, 2, 3, 0, 15, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 7, 5, 262, 61, 147, 44, 11, 6, 17, 0, 322, 29, 19, 43, 485, 27, 757, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4153, 7, 221, 3, 5761, 15, 7472, 16, 621, 2467, 541, 1507, 4938, 6, 4191]; const astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 4, 51, 13, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 39, 27, 10, 22, 251, 41, 7, 1, 17, 2, 60, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 20, 1, 64, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 31, 9, 2, 0, 3, 0, 2, 37, 2, 0, 26, 0, 2, 0, 45, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 200, 32, 32, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 16, 0, 2, 12, 2, 33, 125, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1071, 18, 5, 26, 3994, 6, 582, 6842, 29, 1763, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 433, 44, 212, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 42, 9, 8936, 3, 2, 6, 2, 1, 2, 290, 16, 0, 30, 2, 3, 0, 15, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 7, 5, 262, 61, 147, 44, 11, 6, 17, 0, 322, 29, 19, 43, 485, 27, 229, 29, 3, 0, 496, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4153, 7, 221, 3, 5761, 15, 7472, 16, 621, 2467, 541, 1507, 4938, 6, 4191];
const astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 81, 2, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 10, 1, 2, 0, 49, 6, 4, 4, 14, 9, 5351, 0, 7, 14, 13835, 9, 87, 9, 39, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4706, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 983, 6, 110, 6, 6, 9, 4759, 9, 787719, 239]; const astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 7, 9, 32, 4, 318, 1, 80, 3, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 68, 8, 2, 0, 3, 0, 2, 3, 2, 4, 2, 0, 15, 1, 83, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 7, 19, 58, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 343, 9, 54, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 10, 1, 2, 0, 49, 6, 4, 4, 14, 10, 5350, 0, 7, 14, 11465, 27, 2343, 9, 87, 9, 39, 4, 60, 6, 26, 9, 535, 9, 470, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4178, 9, 519, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 245, 1, 2, 9, 726, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
function isInAstralSet(code, set) { function isInAstralSet(code, set) {
let pos = 0x10000; let pos = 0x10000;
for (let i = 0, length = set.length; i < length; i += 2) { for (let i = 0, length = set.length; i < length; i += 2) {

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"version":3,"names":["_identifier","require","_keyword"],"sources":["../src/index.ts"],"sourcesContent":["export {\n isIdentifierName,\n isIdentifierChar,\n isIdentifierStart,\n} from \"./identifier.ts\";\nexport {\n isReservedWord,\n isStrictBindOnlyReservedWord,\n isStrictBindReservedWord,\n isStrictReservedWord,\n isKeyword,\n} from \"./keyword.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA"} {"version":3,"names":["_identifier","require","_keyword"],"sources":["../src/index.ts"],"sourcesContent":["export {\n isIdentifierName,\n isIdentifierChar,\n isIdentifierStart,\n} from \"./identifier.ts\";\nexport {\n isReservedWord,\n isStrictBindOnlyReservedWord,\n isStrictBindReservedWord,\n isStrictReservedWord,\n isKeyword,\n} from \"./keyword.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["reservedWords","keyword","strict","strictBind","keywords","Set","reservedWordsStrictSet","reservedWordsStrictBindSet","isReservedWord","word","inModule","isStrictReservedWord","has","isStrictBindOnlyReservedWord","isStrictBindReservedWord","isKeyword"],"sources":["../src/keyword.ts"],"sourcesContent":["const reservedWords = {\n keyword: [\n \"break\",\n \"case\",\n \"catch\",\n \"continue\",\n \"debugger\",\n \"default\",\n \"do\",\n \"else\",\n \"finally\",\n \"for\",\n \"function\",\n \"if\",\n \"return\",\n \"switch\",\n \"throw\",\n \"try\",\n \"var\",\n \"const\",\n \"while\",\n \"with\",\n \"new\",\n \"this\",\n \"super\",\n \"class\",\n \"extends\",\n \"export\",\n \"import\",\n \"null\",\n \"true\",\n \"false\",\n \"in\",\n \"instanceof\",\n \"typeof\",\n \"void\",\n \"delete\",\n ],\n strict: [\n \"implements\",\n \"interface\",\n \"let\",\n \"package\",\n \"private\",\n \"protected\",\n \"public\",\n \"static\",\n \"yield\",\n ],\n strictBind: [\"eval\", \"arguments\"],\n};\nconst keywords = new Set(reservedWords.keyword);\nconst reservedWordsStrictSet = new Set(reservedWords.strict);\nconst reservedWordsStrictBindSet = new Set(reservedWords.strictBind);\n\n/**\n * Checks if word is a reserved word in non-strict mode\n */\nexport function isReservedWord(word: string, inModule: boolean): boolean {\n return (inModule && word === \"await\") || word === \"enum\";\n}\n\n/**\n * Checks if word is a reserved word in non-binding strict mode\n *\n * Includes non-strict reserved words\n */\nexport function isStrictReservedWord(word: string, inModule: boolean): boolean {\n return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);\n}\n\n/**\n * Checks if word is a reserved word in binding strict mode, but it is allowed as\n * a normal identifier.\n */\nexport function isStrictBindOnlyReservedWord(word: string): boolean {\n return reservedWordsStrictBindSet.has(word);\n}\n\n/**\n * Checks if word is a reserved word in binding strict mode\n *\n * Includes non-strict reserved words and non-binding strict reserved words\n */\nexport function isStrictBindReservedWord(\n word: string,\n inModule: boolean,\n): boolean {\n return (\n isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word)\n );\n}\n\nexport function isKeyword(word: string): boolean {\n return keywords.has(word);\n}\n"],"mappings":";;;;;;;;;;AAAA,MAAMA,aAAa,GAAG;EACpBC,OAAO,EAAE,CACP,OAAO,EACP,MAAM,EACN,OAAO,EACP,UAAU,EACV,UAAU,EACV,SAAS,EACT,IAAI,EACJ,MAAM,EACN,SAAS,EACT,KAAK,EACL,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,KAAK,EACL,KAAK,EACL,OAAO,EACP,OAAO,EACP,MAAM,EACN,KAAK,EACL,MAAM,EACN,OAAO,EACP,OAAO,EACP,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,MAAM,EACN,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,QAAQ,CACT;EACDC,MAAM,EAAE,CACN,YAAY,EACZ,WAAW,EACX,KAAK,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,OAAO,CACR;EACDC,UAAU,EAAE,CAAC,MAAM,EAAE,WAAW;AAClC,CAAC;AACD,MAAMC,QAAQ,GAAG,IAAIC,GAAG,CAACL,aAAa,CAACC,OAAO,CAAC;AAC/C,MAAMK,sBAAsB,GAAG,IAAID,GAAG,CAACL,aAAa,CAACE,MAAM,CAAC;AAC5D,MAAMK,0BAA0B,GAAG,IAAIF,GAAG,CAACL,aAAa,CAACG,UAAU,CAAC;AAK7D,SAASK,cAAcA,CAACC,IAAY,EAAEC,QAAiB,EAAW;EACvE,OAAQA,QAAQ,IAAID,IAAI,KAAK,OAAO,IAAKA,IAAI,KAAK,MAAM;AAC1D;AAOO,SAASE,oBAAoBA,CAACF,IAAY,EAAEC,QAAiB,EAAW;EAC7E,OAAOF,cAAc,CAACC,IAAI,EAAEC,QAAQ,CAAC,IAAIJ,sBAAsB,CAACM,GAAG,CAACH,IAAI,CAAC;AAC3E;AAMO,SAASI,4BAA4BA,CAACJ,IAAY,EAAW;EAClE,OAAOF,0BAA0B,CAACK,GAAG,CAACH,IAAI,CAAC;AAC7C;AAOO,SAASK,wBAAwBA,CACtCL,IAAY,EACZC,QAAiB,EACR;EACT,OACEC,oBAAoB,CAACF,IAAI,EAAEC,QAAQ,CAAC,IAAIG,4BAA4B,CAACJ,IAAI,CAAC;AAE9E;AAEO,SAASM,SAASA,CAACN,IAAY,EAAW;EAC/C,OAAOL,QAAQ,CAACQ,GAAG,CAACH,IAAI,CAAC;AAC3B"} {"version":3,"names":["reservedWords","keyword","strict","strictBind","keywords","Set","reservedWordsStrictSet","reservedWordsStrictBindSet","isReservedWord","word","inModule","isStrictReservedWord","has","isStrictBindOnlyReservedWord","isStrictBindReservedWord","isKeyword"],"sources":["../src/keyword.ts"],"sourcesContent":["const reservedWords = {\n keyword: [\n \"break\",\n \"case\",\n \"catch\",\n \"continue\",\n \"debugger\",\n \"default\",\n \"do\",\n \"else\",\n \"finally\",\n \"for\",\n \"function\",\n \"if\",\n \"return\",\n \"switch\",\n \"throw\",\n \"try\",\n \"var\",\n \"const\",\n \"while\",\n \"with\",\n \"new\",\n \"this\",\n \"super\",\n \"class\",\n \"extends\",\n \"export\",\n \"import\",\n \"null\",\n \"true\",\n \"false\",\n \"in\",\n \"instanceof\",\n \"typeof\",\n \"void\",\n \"delete\",\n ],\n strict: [\n \"implements\",\n \"interface\",\n \"let\",\n \"package\",\n \"private\",\n \"protected\",\n \"public\",\n \"static\",\n \"yield\",\n ],\n strictBind: [\"eval\", \"arguments\"],\n};\nconst keywords = new Set(reservedWords.keyword);\nconst reservedWordsStrictSet = new Set(reservedWords.strict);\nconst reservedWordsStrictBindSet = new Set(reservedWords.strictBind);\n\n/**\n * Checks if word is a reserved word in non-strict mode\n */\nexport function isReservedWord(word: string, inModule: boolean): boolean {\n return (inModule && word === \"await\") || word === \"enum\";\n}\n\n/**\n * Checks if word is a reserved word in non-binding strict mode\n *\n * Includes non-strict reserved words\n */\nexport function isStrictReservedWord(word: string, inModule: boolean): boolean {\n return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);\n}\n\n/**\n * Checks if word is a reserved word in binding strict mode, but it is allowed as\n * a normal identifier.\n */\nexport function isStrictBindOnlyReservedWord(word: string): boolean {\n return reservedWordsStrictBindSet.has(word);\n}\n\n/**\n * Checks if word is a reserved word in binding strict mode\n *\n * Includes non-strict reserved words and non-binding strict reserved words\n */\nexport function isStrictBindReservedWord(\n word: string,\n inModule: boolean,\n): boolean {\n return (\n isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word)\n );\n}\n\nexport function isKeyword(word: string): boolean {\n return keywords.has(word);\n}\n"],"mappings":";;;;;;;;;;AAAA,MAAMA,aAAa,GAAG;EACpBC,OAAO,EAAE,CACP,OAAO,EACP,MAAM,EACN,OAAO,EACP,UAAU,EACV,UAAU,EACV,SAAS,EACT,IAAI,EACJ,MAAM,EACN,SAAS,EACT,KAAK,EACL,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,KAAK,EACL,KAAK,EACL,OAAO,EACP,OAAO,EACP,MAAM,EACN,KAAK,EACL,MAAM,EACN,OAAO,EACP,OAAO,EACP,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,MAAM,EACN,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,QAAQ,CACT;EACDC,MAAM,EAAE,CACN,YAAY,EACZ,WAAW,EACX,KAAK,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,OAAO,CACR;EACDC,UAAU,EAAE,CAAC,MAAM,EAAE,WAAW;AAClC,CAAC;AACD,MAAMC,QAAQ,GAAG,IAAIC,GAAG,CAACL,aAAa,CAACC,OAAO,CAAC;AAC/C,MAAMK,sBAAsB,GAAG,IAAID,GAAG,CAACL,aAAa,CAACE,MAAM,CAAC;AAC5D,MAAMK,0BAA0B,GAAG,IAAIF,GAAG,CAACL,aAAa,CAACG,UAAU,CAAC;AAK7D,SAASK,cAAcA,CAACC,IAAY,EAAEC,QAAiB,EAAW;EACvE,OAAQA,QAAQ,IAAID,IAAI,KAAK,OAAO,IAAKA,IAAI,KAAK,MAAM;AAC1D;AAOO,SAASE,oBAAoBA,CAACF,IAAY,EAAEC,QAAiB,EAAW;EAC7E,OAAOF,cAAc,CAACC,IAAI,EAAEC,QAAQ,CAAC,IAAIJ,sBAAsB,CAACM,GAAG,CAACH,IAAI,CAAC;AAC3E;AAMO,SAASI,4BAA4BA,CAACJ,IAAY,EAAW;EAClE,OAAOF,0BAA0B,CAACK,GAAG,CAACH,IAAI,CAAC;AAC7C;AAOO,SAASK,wBAAwBA,CACtCL,IAAY,EACZC,QAAiB,EACR;EACT,OACEC,oBAAoB,CAACF,IAAI,EAAEC,QAAQ,CAAC,IAAIG,4BAA4B,CAACJ,IAAI,CAAC;AAE9E;AAEO,SAASM,SAASA,CAACN,IAAY,EAAW;EAC/C,OAAOL,QAAQ,CAACQ,GAAG,CAACH,IAAI,CAAC;AAC3B","ignoreList":[]}

View File

@ -1,6 +1,6 @@
{ {
"name": "@babel/helper-validator-identifier", "name": "@babel/helper-validator-identifier",
"version": "7.22.20", "version": "7.27.1",
"description": "Validate identifier/keywords name", "description": "Validate identifier/keywords name",
"repository": { "repository": {
"type": "git", "type": "git",
@ -13,11 +13,14 @@
}, },
"main": "./lib/index.js", "main": "./lib/index.js",
"exports": { "exports": {
".": "./lib/index.js", ".": {
"types": "./lib/index.d.ts",
"default": "./lib/index.js"
},
"./package.json": "./package.json" "./package.json": "./package.json"
}, },
"devDependencies": { "devDependencies": {
"@unicode/unicode-15.1.0": "^1.5.2", "@unicode/unicode-16.0.0": "^1.0.0",
"charcodes": "^0.2.0" "charcodes": "^0.2.0"
}, },
"engines": { "engines": {

View File

@ -1,73 +0,0 @@
"use strict";
// Always use the latest available version of Unicode!
// https://tc39.github.io/ecma262/#sec-conformance
const version = "15.1.0";
const start = require(
"@unicode/unicode-" + version + "/Binary_Property/ID_Start/code-points.js"
).filter(function (ch) {
return ch > 0x7f;
});
let last = -1;
const cont = require(
"@unicode/unicode-" + version + "/Binary_Property/ID_Continue/code-points.js"
).filter(function (ch) {
return ch > 0x7f && search(start, ch, last + 1) == -1;
});
function search(arr, ch, starting) {
for (let i = starting; arr[i] <= ch && i < arr.length; last = i++) {
if (arr[i] === ch) return i;
}
return -1;
}
function pad(str, width) {
while (str.length < width) str = "0" + str;
return str;
}
function esc(code) {
const hex = code.toString(16);
if (hex.length <= 2) return "\\x" + pad(hex, 2);
else return "\\u" + pad(hex, 4);
}
function generate(chars) {
const astral = [];
let re = "";
for (let i = 0, at = 0x10000; i < chars.length; i++) {
const from = chars[i];
let to = from;
while (i < chars.length - 1 && chars[i + 1] == to + 1) {
i++;
to++;
}
if (to <= 0xffff) {
if (from == to) re += esc(from);
else if (from + 1 == to) re += esc(from) + esc(to);
else re += esc(from) + "-" + esc(to);
} else {
astral.push(from - at, to - from);
at = to;
}
}
return { nonASCII: re, astral: astral };
}
const startData = generate(start);
const contData = generate(cont);
console.log("/* prettier-ignore */");
console.log('let nonASCIIidentifierStartChars = "' + startData.nonASCII + '";');
console.log("/* prettier-ignore */");
console.log('let nonASCIIidentifierChars = "' + contData.nonASCII + '";');
console.log("/* prettier-ignore */");
console.log(
"const astralIdentifierStartCodes = " + JSON.stringify(startData.astral) + ";"
);
console.log("/* prettier-ignore */");
console.log(
"const astralIdentifierCodes = " + JSON.stringify(contData.astral) + ";"
);

View File

@ -1,5 +1,5 @@
#!/usr/bin/env node #!/usr/bin/env node
/* eslint no-var: 0 */ /* eslint-disable no-var, unicorn/prefer-node-protocol */
var parser = require(".."); var parser = require("..");
var fs = require("fs"); var fs = require("fs");

View File

@ -1,5 +0,0 @@
try {
module.exports = require("./lib/index.cjs");
} catch {
module.exports = require("./lib/index.js");
}

8534
node_modules/@babel/parser/lib/index.js generated vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"name": "@babel/parser", "name": "@babel/parser",
"version": "7.24.4", "version": "7.27.2",
"description": "A JavaScript parser", "description": "A JavaScript parser",
"author": "The Babel Team (https://babel.dev/team)", "author": "The Babel Team (https://babel.dev/team)",
"homepage": "https://babel.dev/docs/en/next/babel-parser", "homepage": "https://babel.dev/docs/en/next/babel-parser",
@ -33,12 +33,16 @@
"engines": { "engines": {
"node": ">=6.0.0" "node": ">=6.0.0"
}, },
"# dependencies": "This package doesn't actually have runtime dependencies. @babel/types is only needed for type definitions.",
"dependencies": {
"@babel/types": "^7.27.1"
},
"devDependencies": { "devDependencies": {
"@babel/code-frame": "^7.24.2", "@babel/code-frame": "^7.27.1",
"@babel/helper-check-duplicate-nodes": "^7.22.5", "@babel/helper-check-duplicate-nodes": "^7.27.1",
"@babel/helper-fixtures": "^7.24.4", "@babel/helper-fixtures": "^7.27.1",
"@babel/helper-string-parser": "^7.24.1", "@babel/helper-string-parser": "^7.27.1",
"@babel/helper-validator-identifier": "^7.22.20", "@babel/helper-validator-identifier": "^7.27.1",
"charcodes": "^0.2.0" "charcodes": "^0.2.0"
}, },
"bin": "./bin/babel-parser.js", "bin": "./bin/babel-parser.js",

View File

@ -1,65 +1,69 @@
// This file is auto-generated! Do not modify it directly. // This file is auto-generated! Do not modify it directly.
/* eslint-disable import/no-extraneous-dependencies, @typescript-eslint/consistent-type-imports, prettier/prettier */ // Run `yarn gulp bundle-dts` to re-generate it.
import * as _babel_types from '@babel/types'; /* eslint-disable @typescript-eslint/consistent-type-imports, @typescript-eslint/no-redundant-type-constituents */
import { File, Expression } from '@babel/types';
type Plugin = type BABEL_8_BREAKING = false;
type IF_BABEL_7<V> = false extends BABEL_8_BREAKING ? V : never;
type Plugin$1 =
| "asyncDoExpressions" | "asyncDoExpressions"
| "asyncGenerators" | IF_BABEL_7<"asyncGenerators">
| "bigInt" | IF_BABEL_7<"bigInt">
| "classPrivateMethods" | IF_BABEL_7<"classPrivateMethods">
| "classPrivateProperties" | IF_BABEL_7<"classPrivateProperties">
| "classProperties" | IF_BABEL_7<"classProperties">
| "classStaticBlock" // Enabled by default | IF_BABEL_7<"classStaticBlock">
| "decimal" | IF_BABEL_7<"decimal">
| "decorators-legacy" | "decorators-legacy"
| "deferredImportEvaluation" | "deferredImportEvaluation"
| "decoratorAutoAccessors" | "decoratorAutoAccessors"
| "destructuringPrivate" | "destructuringPrivate"
| "deprecatedImportAssert"
| "doExpressions" | "doExpressions"
| "dynamicImport" | IF_BABEL_7<"dynamicImport">
| "explicitResourceManagement" | "explicitResourceManagement"
| "exportDefaultFrom" | "exportDefaultFrom"
| "exportNamespaceFrom" // deprecated | IF_BABEL_7<"exportNamespaceFrom">
| "flow" | "flow"
| "flowComments" | "flowComments"
| "functionBind" | "functionBind"
| "functionSent" | "functionSent"
| "importMeta" | "importMeta"
| "jsx" | "jsx"
| "logicalAssignment" | IF_BABEL_7<"jsonStrings">
| "importAssertions" // deprecated | IF_BABEL_7<"logicalAssignment">
| "importAttributes" | IF_BABEL_7<"importAssertions">
| "importReflection" | IF_BABEL_7<"importReflection">
| "moduleBlocks" | "moduleBlocks"
| "moduleStringNames" | IF_BABEL_7<"moduleStringNames">
| "nullishCoalescingOperator" | IF_BABEL_7<"nullishCoalescingOperator">
| "numericSeparator" | IF_BABEL_7<"numericSeparator">
| "objectRestSpread" | IF_BABEL_7<"objectRestSpread">
| "optionalCatchBinding" | IF_BABEL_7<"optionalCatchBinding">
| "optionalChaining" | IF_BABEL_7<"optionalChaining">
| "partialApplication" | "partialApplication"
| "placeholders" | "placeholders"
| "privateIn" // Enabled by default | IF_BABEL_7<"privateIn">
| "regexpUnicodeSets" // Enabled by default | IF_BABEL_7<"regexpUnicodeSets">
| "sourcePhaseImports" | "sourcePhaseImports"
| "throwExpressions" | "throwExpressions"
| "topLevelAwait" | IF_BABEL_7<"topLevelAwait">
| "v8intrinsic" | "v8intrinsic"
| ParserPluginWithOptions[0]; | ParserPluginWithOptions[0];
type ParserPluginWithOptions = type ParserPluginWithOptions =
| ["decorators", DecoratorsPluginOptions] | ["decorators", DecoratorsPluginOptions]
| ["estree", { classFeatures?: boolean }] | ["estree", { classFeatures?: boolean }]
| ["importAttributes", { deprecatedAssertSyntax: boolean }] | IF_BABEL_7<["importAttributes", { deprecatedAssertSyntax: boolean }]>
// @deprecated | IF_BABEL_7<["moduleAttributes", { version: "may-2020" }]>
| ["moduleAttributes", { version: "may-2020" }]
| ["optionalChainingAssign", { version: "2023-07" }] | ["optionalChainingAssign", { version: "2023-07" }]
| ["pipelineOperator", PipelineOperatorPluginOptions] | ["pipelineOperator", PipelineOperatorPluginOptions]
| ["recordAndTuple", RecordAndTuplePluginOptions] | ["recordAndTuple", RecordAndTuplePluginOptions]
| ["flow", FlowPluginOptions] | ["flow", FlowPluginOptions]
| ["typescript", TypeScriptPluginOptions]; | ["typescript", TypeScriptPluginOptions];
type PluginConfig = Plugin | ParserPluginWithOptions; type PluginConfig = Plugin$1 | ParserPluginWithOptions;
interface DecoratorsPluginOptions { interface DecoratorsPluginOptions {
decoratorsBeforeExport?: boolean; decoratorsBeforeExport?: boolean;
@ -67,7 +71,9 @@ interface DecoratorsPluginOptions {
} }
interface PipelineOperatorPluginOptions { interface PipelineOperatorPluginOptions {
proposal: "minimal" | "fsharp" | "hack" | "smart"; proposal: BABEL_8_BREAKING extends false
? "minimal" | "fsharp" | "hack" | "smart"
: "fsharp" | "hack";
topicToken?: "%" | "#" | "@@" | "^^" | "^"; topicToken?: "%" | "#" | "@@" | "^^" | "^";
} }
@ -75,78 +81,59 @@ interface RecordAndTuplePluginOptions {
syntaxType: "bar" | "hash"; syntaxType: "bar" | "hash";
} }
interface FlowPluginOptions { type FlowPluginOptions = BABEL_8_BREAKING extends true
? {
all?: boolean; all?: boolean;
enums?: boolean; enums?: boolean;
} }
: {
all?: boolean;
};
interface TypeScriptPluginOptions { interface TypeScriptPluginOptions {
dts?: boolean; dts?: boolean;
disallowAmbiguousJSXLike?: boolean; disallowAmbiguousJSXLike?: boolean;
} }
// Type definitions for @babel/parser type Plugin = PluginConfig;
// Project: https://github.com/babel/babel/tree/main/packages/babel-parser
// Definitions by: Troy Gerwien <https://github.com/yortus>
// Marvin Hagemeister <https://github.com/marvinhagemeister>
// Avi Vahl <https://github.com/AviVahl>
// TypeScript Version: 2.9
/** interface Options {
* Parse the provided code as an entire ECMAScript program.
*/
declare function parse(
input: string,
options?: ParserOptions
): ParseResult<_babel_types.File>;
/**
* Parse the provided code as a single expression.
*/
declare function parseExpression(
input: string,
options?: ParserOptions
): ParseResult<_babel_types.Expression>;
interface ParserOptions {
/** /**
* By default, import and export declarations can only appear at a program's top level. * By default, import and export declarations can only appear at a program's top level.
* Setting this option to true allows them anywhere where a statement is allowed. * Setting this option to true allows them anywhere where a statement is allowed.
*/ */
allowImportExportEverywhere?: boolean; allowImportExportEverywhere?: boolean;
/** /**
* By default, await use is not allowed outside of an async function. * By default, await use is not allowed outside of an async function.
* Set this to true to accept such code. * Set this to true to accept such code.
*/ */
allowAwaitOutsideFunction?: boolean; allowAwaitOutsideFunction?: boolean;
/** /**
* By default, a return statement at the top level raises an error. * By default, a return statement at the top level raises an error.
* Set this to true to accept such code. * Set this to true to accept such code.
*/ */
allowReturnOutsideFunction?: boolean; allowReturnOutsideFunction?: boolean;
/** /**
* By default, new.target use is not allowed outside of a function or class. * By default, new.target use is not allowed outside of a function or class.
* Set this to true to accept such code. * Set this to true to accept such code.
*/ */
allowNewTargetOutsideFunction?: boolean; allowNewTargetOutsideFunction?: boolean;
allowSuperOutsideMethod?: boolean; allowSuperOutsideMethod?: boolean;
/** /**
* By default, exported identifiers must refer to a declared variable. * By default, exported identifiers must refer to a declared variable.
* Set this to true to allow export statements to reference undeclared variables. * Set this to true to allow export statements to reference undeclared variables.
*/ */
allowUndeclaredExports?: boolean; allowUndeclaredExports?: boolean;
/**
* By default, yield use is not allowed outside of a generator function.
* Set this to true to accept such code.
*/
allowYieldOutsideFunction?: boolean;
/** /**
* By default, Babel parser JavaScript code according to Annex B syntax. * By default, Babel parser JavaScript code according to Annex B syntax.
* Set this to `false` to disable such behavior. * Set this to `false` to disable such behavior.
*/ */
annexB?: boolean; annexB?: boolean;
/** /**
* By default, Babel attaches comments to adjacent AST nodes. * By default, Babel attaches comments to adjacent AST nodes.
* When this option is set to false, comments are not attached. * When this option is set to false, comments are not attached.
@ -157,14 +144,12 @@ interface ParserOptions {
* /* istanbul ignore next *\/ nonfunctional. * /* istanbul ignore next *\/ nonfunctional.
*/ */
attachComment?: boolean; attachComment?: boolean;
/** /**
* By default, Babel always throws an error when it finds some invalid code. * By default, Babel always throws an error when it finds some invalid code.
* When this option is set to true, it will store the parsing error and * When this option is set to true, it will store the parsing error and
* try to continue parsing the invalid input file. * try to continue parsing the invalid input file.
*/ */
errorRecovery?: boolean; errorRecovery?: boolean;
/** /**
* Indicate the mode the code should be parsed in. * Indicate the mode the code should be parsed in.
* Can be one of "script", "module", or "unambiguous". Defaults to "script". * Can be one of "script", "module", or "unambiguous". Defaults to "script".
@ -173,48 +158,46 @@ interface ParserOptions {
* Files with ES6 imports and exports are considered "module" and are otherwise "script". * Files with ES6 imports and exports are considered "module" and are otherwise "script".
*/ */
sourceType?: "script" | "module" | "unambiguous"; sourceType?: "script" | "module" | "unambiguous";
/** /**
* Correlate output AST nodes with their source filename. * Correlate output AST nodes with their source filename.
* Useful when generating code and source maps from the ASTs of multiple input files. * Useful when generating code and source maps from the ASTs of multiple input files.
*/ */
sourceFilename?: string; sourceFilename?: string;
/**
* By default, all source indexes start from 0.
* You can provide a start index to alternatively start with.
* Useful for integration with other source tools.
*/
startIndex?: number;
/** /**
* By default, the first line of code parsed is treated as line 1. * By default, the first line of code parsed is treated as line 1.
* You can provide a line number to alternatively start with. * You can provide a line number to alternatively start with.
* Useful for integration with other source tools. * Useful for integration with other source tools.
*/ */
startLine?: number; startLine?: number;
/** /**
* By default, the parsed code is treated as if it starts from line 1, column 0. * By default, the parsed code is treated as if it starts from line 1, column 0.
* You can provide a column number to alternatively start with. * You can provide a column number to alternatively start with.
* Useful for integration with other source tools. * Useful for integration with other source tools.
*/ */
startColumn?: number; startColumn?: number;
/** /**
* Array containing the plugins that you want to enable. * Array containing the plugins that you want to enable.
*/ */
plugins?: ParserPlugin[]; plugins?: Plugin[];
/** /**
* Should the parser work in strict mode. * Should the parser work in strict mode.
* Defaults to true if sourceType === 'module'. Otherwise, false. * Defaults to true if sourceType === 'module'. Otherwise, false.
*/ */
strictMode?: boolean; strictMode?: boolean;
/** /**
* Adds a ranges property to each node: [node.start, node.end] * Adds a ranges property to each node: [node.start, node.end]
*/ */
ranges?: boolean; ranges?: boolean;
/** /**
* Adds all parsed tokens to a tokens property on the File node. * Adds all parsed tokens to a tokens property on the File node.
*/ */
tokens?: boolean; tokens?: boolean;
/** /**
* By default, the parser adds information about parentheses by setting * By default, the parser adds information about parentheses by setting
* `extra.parenthesized` to `true` as needed. * `extra.parenthesized` to `true` as needed.
@ -222,7 +205,6 @@ interface ParserOptions {
* AST nodes instead of using the `extra` property. * AST nodes instead of using the `extra` property.
*/ */
createParenthesizedExpressions?: boolean; createParenthesizedExpressions?: boolean;
/** /**
* The default is false in Babel 7 and true in Babel 8 * The default is false in Babel 7 and true in Babel 8
* Set this to true to parse it as an `ImportExpression` node. * Set this to true to parse it as an `ImportExpression` node.
@ -231,21 +213,23 @@ interface ParserOptions {
createImportExpressions?: boolean; createImportExpressions?: boolean;
} }
type ParserPlugin = PluginConfig; type ParserOptions = Partial<Options>;
interface ParseError {
code: string;
reasonCode: string;
}
type ParseResult<Result extends File | Expression = File> = Result & {
errors: null | ParseError[];
};
/**
* Parse the provided code as an entire ECMAScript program.
*/
declare function parse(input: string, options?: ParserOptions): ParseResult<File>;
declare function parseExpression(input: string, options?: ParserOptions): ParseResult<Expression>;
declare const tokTypes: { declare const tokTypes: {
// todo(flow->ts) real token type // todo(flow->ts) real token type
[name: string]: any; [name: string]: any;
}; };
interface ParseError { export { DecoratorsPluginOptions, FlowPluginOptions, ParseError, ParseResult, ParserOptions, PluginConfig as ParserPlugin, ParserPluginWithOptions, PipelineOperatorPluginOptions, RecordAndTuplePluginOptions, TypeScriptPluginOptions, parse, parseExpression, tokTypes };
code: string;
reasonCode: string;
}
type ParseResult<Result> = Result & {
errors: ParseError[];
};
export { DecoratorsPluginOptions, FlowPluginOptions, ParseError, ParseResult, ParserOptions, ParserPlugin, ParserPluginWithOptions, PipelineOperatorPluginOptions, RecordAndTuplePluginOptions, TypeScriptPluginOptions, parse, parseExpression, tokTypes };

View File

@ -1 +1 @@
{"version":3,"names":["_isNode","require","assertNode","node","isNode","_node$type","type","JSON","stringify","TypeError"],"sources":["../../src/asserts/assertNode.ts"],"sourcesContent":["import isNode from \"../validators/isNode.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default function assertNode(node?: any): asserts node is t.Node {\n if (!isNode(node)) {\n const type = node?.type ?? JSON.stringify(node);\n throw new TypeError(`Not a valid node of type \"${type}\"`);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAGe,SAASC,UAAUA,CAACC,IAAU,EAA0B;EACrE,IAAI,CAAC,IAAAC,eAAM,EAACD,IAAI,CAAC,EAAE;IAAA,IAAAE,UAAA;IACjB,MAAMC,IAAI,IAAAD,UAAA,GAAGF,IAAI,oBAAJA,IAAI,CAAEG,IAAI,YAAAD,UAAA,GAAIE,IAAI,CAACC,SAAS,CAACL,IAAI,CAAC;IAC/C,MAAM,IAAIM,SAAS,CAAE,6BAA4BH,IAAK,GAAE,CAAC;EAC3D;AACF"} {"version":3,"names":["_isNode","require","assertNode","node","isNode","_node$type","type","JSON","stringify","TypeError"],"sources":["../../src/asserts/assertNode.ts"],"sourcesContent":["import isNode from \"../validators/isNode.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default function assertNode(node?: any): asserts node is t.Node {\n if (!isNode(node)) {\n const type = node?.type ?? JSON.stringify(node);\n throw new TypeError(`Not a valid node of type \"${type}\"`);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAGe,SAASC,UAAUA,CAACC,IAAU,EAA0B;EACrE,IAAI,CAAC,IAAAC,eAAM,EAACD,IAAI,CAAC,EAAE;IAAA,IAAAE,UAAA;IACjB,MAAMC,IAAI,IAAAD,UAAA,GAAGF,IAAI,oBAAJA,IAAI,CAAEG,IAAI,YAAAD,UAAA,GAAIE,IAAI,CAACC,SAAS,CAACL,IAAI,CAAC;IAC/C,MAAM,IAAIM,SAAS,CAAC,6BAA6BH,IAAI,GAAG,CAAC;EAC3D;AACF","ignoreList":[]}

View File

@ -218,6 +218,7 @@ exports.assertTSConstructorType = assertTSConstructorType;
exports.assertTSDeclareFunction = assertTSDeclareFunction; exports.assertTSDeclareFunction = assertTSDeclareFunction;
exports.assertTSDeclareMethod = assertTSDeclareMethod; exports.assertTSDeclareMethod = assertTSDeclareMethod;
exports.assertTSEntityName = assertTSEntityName; exports.assertTSEntityName = assertTSEntityName;
exports.assertTSEnumBody = assertTSEnumBody;
exports.assertTSEnumDeclaration = assertTSEnumDeclaration; exports.assertTSEnumDeclaration = assertTSEnumDeclaration;
exports.assertTSEnumMember = assertTSEnumMember; exports.assertTSEnumMember = assertTSEnumMember;
exports.assertTSExportAssignment = assertTSExportAssignment; exports.assertTSExportAssignment = assertTSExportAssignment;
@ -255,6 +256,7 @@ exports.assertTSRestType = assertTSRestType;
exports.assertTSSatisfiesExpression = assertTSSatisfiesExpression; exports.assertTSSatisfiesExpression = assertTSSatisfiesExpression;
exports.assertTSStringKeyword = assertTSStringKeyword; exports.assertTSStringKeyword = assertTSStringKeyword;
exports.assertTSSymbolKeyword = assertTSSymbolKeyword; exports.assertTSSymbolKeyword = assertTSSymbolKeyword;
exports.assertTSTemplateLiteralType = assertTSTemplateLiteralType;
exports.assertTSThisType = assertTSThisType; exports.assertTSThisType = assertTSThisType;
exports.assertTSTupleType = assertTSTupleType; exports.assertTSTupleType = assertTSTupleType;
exports.assertTSType = assertTSType; exports.assertTSType = assertTSType;
@ -578,6 +580,9 @@ function assertPrivateName(node, opts) {
function assertStaticBlock(node, opts) { function assertStaticBlock(node, opts) {
assert("StaticBlock", node, opts); assert("StaticBlock", node, opts);
} }
function assertImportAttribute(node, opts) {
assert("ImportAttribute", node, opts);
}
function assertAnyTypeAnnotation(node, opts) { function assertAnyTypeAnnotation(node, opts) {
assert("AnyTypeAnnotation", node, opts); assert("AnyTypeAnnotation", node, opts);
} }
@ -833,9 +838,6 @@ function assertArgumentPlaceholder(node, opts) {
function assertBindExpression(node, opts) { function assertBindExpression(node, opts) {
assert("BindExpression", node, opts); assert("BindExpression", node, opts);
} }
function assertImportAttribute(node, opts) {
assert("ImportAttribute", node, opts);
}
function assertDecorator(node, opts) { function assertDecorator(node, opts) {
assert("Decorator", node, opts); assert("Decorator", node, opts);
} }
@ -995,6 +997,9 @@ function assertTSIndexedAccessType(node, opts) {
function assertTSMappedType(node, opts) { function assertTSMappedType(node, opts) {
assert("TSMappedType", node, opts); assert("TSMappedType", node, opts);
} }
function assertTSTemplateLiteralType(node, opts) {
assert("TSTemplateLiteralType", node, opts);
}
function assertTSLiteralType(node, opts) { function assertTSLiteralType(node, opts) {
assert("TSLiteralType", node, opts); assert("TSLiteralType", node, opts);
} }
@ -1022,6 +1027,9 @@ function assertTSSatisfiesExpression(node, opts) {
function assertTSTypeAssertion(node, opts) { function assertTSTypeAssertion(node, opts) {
assert("TSTypeAssertion", node, opts); assert("TSTypeAssertion", node, opts);
} }
function assertTSEnumBody(node, opts) {
assert("TSEnumBody", node, opts);
}
function assertTSEnumDeclaration(node, opts) { function assertTSEnumDeclaration(node, opts) {
assert("TSEnumDeclaration", node, opts); assert("TSEnumDeclaration", node, opts);
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"version":3,"names":["_index","require","_removeTypeDuplicates","createFlowUnionType","types","flattened","removeTypeDuplicates","length","unionTypeAnnotation"],"sources":["../../../src/builders/flow/createFlowUnionType.ts"],"sourcesContent":["import { unionTypeAnnotation } from \"../generated/index.ts\";\nimport removeTypeDuplicates from \"../../modifications/flow/removeTypeDuplicates.ts\";\nimport type * as t from \"../../index.ts\";\n\n/**\n * Takes an array of `types` and flattens them, removing duplicates and\n * returns a `UnionTypeAnnotation` node containing them.\n */\nexport default function createFlowUnionType<T extends t.FlowType>(\n types: [T] | Array<T>,\n): T | t.UnionTypeAnnotation {\n const flattened = removeTypeDuplicates(types);\n\n if (flattened.length === 1) {\n return flattened[0] as T;\n } else {\n return unionTypeAnnotation(flattened);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AAOe,SAASE,mBAAmBA,CACzCC,KAAqB,EACM;EAC3B,MAAMC,SAAS,GAAG,IAAAC,6BAAoB,EAACF,KAAK,CAAC;EAE7C,IAAIC,SAAS,CAACE,MAAM,KAAK,CAAC,EAAE;IAC1B,OAAOF,SAAS,CAAC,CAAC,CAAC;EACrB,CAAC,MAAM;IACL,OAAO,IAAAG,0BAAmB,EAACH,SAAS,CAAC;EACvC;AACF"} {"version":3,"names":["_index","require","_removeTypeDuplicates","createFlowUnionType","types","flattened","removeTypeDuplicates","length","unionTypeAnnotation"],"sources":["../../../src/builders/flow/createFlowUnionType.ts"],"sourcesContent":["import { unionTypeAnnotation } from \"../generated/index.ts\";\nimport removeTypeDuplicates from \"../../modifications/flow/removeTypeDuplicates.ts\";\nimport type * as t from \"../../index.ts\";\n\n/**\n * Takes an array of `types` and flattens them, removing duplicates and\n * returns a `UnionTypeAnnotation` node containing them.\n */\nexport default function createFlowUnionType<T extends t.FlowType>(\n types: [T] | Array<T>,\n): T | t.UnionTypeAnnotation {\n const flattened = removeTypeDuplicates(types);\n\n if (flattened.length === 1) {\n return flattened[0] as T;\n } else {\n return unionTypeAnnotation(flattened);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AAOe,SAASE,mBAAmBA,CACzCC,KAAqB,EACM;EAC3B,MAAMC,SAAS,GAAG,IAAAC,6BAAoB,EAACF,KAAK,CAAC;EAE7C,IAAIC,SAAS,CAACE,MAAM,KAAK,CAAC,EAAE;IAC1B,OAAOF,SAAS,CAAC,CAAC,CAAC;EACrB,CAAC,MAAM;IACL,OAAO,IAAAG,0BAAmB,EAACH,SAAS,CAAC;EACvC;AACF","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["_index","require","_default","exports","default","createTypeAnnotationBasedOnTypeof","type","stringTypeAnnotation","numberTypeAnnotation","voidTypeAnnotation","booleanTypeAnnotation","genericTypeAnnotation","identifier","anyTypeAnnotation","Error"],"sources":["../../../src/builders/flow/createTypeAnnotationBasedOnTypeof.ts"],"sourcesContent":["import {\n anyTypeAnnotation,\n stringTypeAnnotation,\n numberTypeAnnotation,\n voidTypeAnnotation,\n booleanTypeAnnotation,\n genericTypeAnnotation,\n identifier,\n} from \"../generated/index.ts\";\nimport type * as t from \"../../index.ts\";\n\nexport default createTypeAnnotationBasedOnTypeof as {\n (type: \"string\"): t.StringTypeAnnotation;\n (type: \"number\"): t.NumberTypeAnnotation;\n (type: \"undefined\"): t.VoidTypeAnnotation;\n (type: \"boolean\"): t.BooleanTypeAnnotation;\n (type: \"function\"): t.GenericTypeAnnotation;\n (type: \"object\"): t.GenericTypeAnnotation;\n (type: \"symbol\"): t.GenericTypeAnnotation;\n (type: \"bigint\"): t.AnyTypeAnnotation;\n};\n\n/**\n * Create a type annotation based on typeof expression.\n */\nfunction createTypeAnnotationBasedOnTypeof(type: string): t.FlowType {\n switch (type) {\n case \"string\":\n return stringTypeAnnotation();\n case \"number\":\n return numberTypeAnnotation();\n case \"undefined\":\n return voidTypeAnnotation();\n case \"boolean\":\n return booleanTypeAnnotation();\n case \"function\":\n return genericTypeAnnotation(identifier(\"Function\"));\n case \"object\":\n return genericTypeAnnotation(identifier(\"Object\"));\n case \"symbol\":\n return genericTypeAnnotation(identifier(\"Symbol\"));\n case \"bigint\":\n // todo: use BigInt annotation when Flow supports BigInt\n // https://github.com/facebook/flow/issues/6639\n return anyTypeAnnotation();\n }\n throw new Error(\"Invalid typeof value: \" + type);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAQ+B,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGhBC,iCAAiC;AAchD,SAASA,iCAAiCA,CAACC,IAAY,EAAc;EACnE,QAAQA,IAAI;IACV,KAAK,QAAQ;MACX,OAAO,IAAAC,2BAAoB,EAAC,CAAC;IAC/B,KAAK,QAAQ;MACX,OAAO,IAAAC,2BAAoB,EAAC,CAAC;IAC/B,KAAK,WAAW;MACd,OAAO,IAAAC,yBAAkB,EAAC,CAAC;IAC7B,KAAK,SAAS;MACZ,OAAO,IAAAC,4BAAqB,EAAC,CAAC;IAChC,KAAK,UAAU;MACb,OAAO,IAAAC,4BAAqB,EAAC,IAAAC,iBAAU,EAAC,UAAU,CAAC,CAAC;IACtD,KAAK,QAAQ;MACX,OAAO,IAAAD,4BAAqB,EAAC,IAAAC,iBAAU,EAAC,QAAQ,CAAC,CAAC;IACpD,KAAK,QAAQ;MACX,OAAO,IAAAD,4BAAqB,EAAC,IAAAC,iBAAU,EAAC,QAAQ,CAAC,CAAC;IACpD,KAAK,QAAQ;MAGX,OAAO,IAAAC,wBAAiB,EAAC,CAAC;EAC9B;EACA,MAAM,IAAIC,KAAK,CAAC,wBAAwB,GAAGR,IAAI,CAAC;AAClD"} {"version":3,"names":["_index","require","_default","exports","default","createTypeAnnotationBasedOnTypeof","type","stringTypeAnnotation","numberTypeAnnotation","voidTypeAnnotation","booleanTypeAnnotation","genericTypeAnnotation","identifier","anyTypeAnnotation","Error"],"sources":["../../../src/builders/flow/createTypeAnnotationBasedOnTypeof.ts"],"sourcesContent":["import {\n anyTypeAnnotation,\n stringTypeAnnotation,\n numberTypeAnnotation,\n voidTypeAnnotation,\n booleanTypeAnnotation,\n genericTypeAnnotation,\n identifier,\n} from \"../generated/index.ts\";\nimport type * as t from \"../../index.ts\";\n\nexport default createTypeAnnotationBasedOnTypeof as {\n (type: \"string\"): t.StringTypeAnnotation;\n (type: \"number\"): t.NumberTypeAnnotation;\n (type: \"undefined\"): t.VoidTypeAnnotation;\n (type: \"boolean\"): t.BooleanTypeAnnotation;\n (type: \"function\"): t.GenericTypeAnnotation;\n (type: \"object\"): t.GenericTypeAnnotation;\n (type: \"symbol\"): t.GenericTypeAnnotation;\n (type: \"bigint\"): t.AnyTypeAnnotation;\n};\n\n/**\n * Create a type annotation based on typeof expression.\n */\nfunction createTypeAnnotationBasedOnTypeof(type: string): t.FlowType {\n switch (type) {\n case \"string\":\n return stringTypeAnnotation();\n case \"number\":\n return numberTypeAnnotation();\n case \"undefined\":\n return voidTypeAnnotation();\n case \"boolean\":\n return booleanTypeAnnotation();\n case \"function\":\n return genericTypeAnnotation(identifier(\"Function\"));\n case \"object\":\n return genericTypeAnnotation(identifier(\"Object\"));\n case \"symbol\":\n return genericTypeAnnotation(identifier(\"Symbol\"));\n case \"bigint\":\n // todo: use BigInt annotation when Flow supports BigInt\n // https://github.com/facebook/flow/issues/6639\n return anyTypeAnnotation();\n }\n throw new Error(\"Invalid typeof value: \" + type);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAQ+B,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGhBC,iCAAiC;AAchD,SAASA,iCAAiCA,CAACC,IAAY,EAAc;EACnE,QAAQA,IAAI;IACV,KAAK,QAAQ;MACX,OAAO,IAAAC,2BAAoB,EAAC,CAAC;IAC/B,KAAK,QAAQ;MACX,OAAO,IAAAC,2BAAoB,EAAC,CAAC;IAC/B,KAAK,WAAW;MACd,OAAO,IAAAC,yBAAkB,EAAC,CAAC;IAC7B,KAAK,SAAS;MACZ,OAAO,IAAAC,4BAAqB,EAAC,CAAC;IAChC,KAAK,UAAU;MACb,OAAO,IAAAC,4BAAqB,EAAC,IAAAC,iBAAU,EAAC,UAAU,CAAC,CAAC;IACtD,KAAK,QAAQ;MACX,OAAO,IAAAD,4BAAqB,EAAC,IAAAC,iBAAU,EAAC,QAAQ,CAAC,CAAC;IACpD,KAAK,QAAQ;MACX,OAAO,IAAAD,4BAAqB,EAAC,IAAAC,iBAAU,EAAC,QAAQ,CAAC,CAAC;IACpD,KAAK,QAAQ;MAGX,OAAO,IAAAC,wBAAiB,EAAC,CAAC;EAC9B;EACA,MAAM,IAAIC,KAAK,CAAC,wBAAwB,GAAGR,IAAI,CAAC;AAClD","ignoreList":[]}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"version":3,"names":["_index","require","buildUndefinedNode","unaryExpression","numericLiteral"],"sources":["../../src/builders/productions.ts"],"sourcesContent":["import { numericLiteral, unaryExpression } from \"./generated/index.ts\";\n\nexport function buildUndefinedNode() {\n return unaryExpression(\"void\", numericLiteral(0), true);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEO,SAASC,kBAAkBA,CAAA,EAAG;EACnC,OAAO,IAAAC,sBAAe,EAAC,MAAM,EAAE,IAAAC,qBAAc,EAAC,CAAC,CAAC,EAAE,IAAI,CAAC;AACzD"} {"version":3,"names":["_index","require","buildUndefinedNode","unaryExpression","numericLiteral"],"sources":["../../src/builders/productions.ts"],"sourcesContent":["import { numericLiteral, unaryExpression } from \"./generated/index.ts\";\n\nexport function buildUndefinedNode() {\n return unaryExpression(\"void\", numericLiteral(0), true);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEO,SAASC,kBAAkBA,CAAA,EAAG;EACnC,OAAO,IAAAC,sBAAe,EAAC,MAAM,EAAE,IAAAC,qBAAc,EAAC,CAAC,CAAC,EAAE,IAAI,CAAC;AACzD","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["_index","require","_cleanJSXElementLiteralChild","buildChildren","node","elements","i","children","length","child","isJSXText","cleanJSXElementLiteralChild","isJSXExpressionContainer","expression","isJSXEmptyExpression","push"],"sources":["../../../src/builders/react/buildChildren.ts"],"sourcesContent":["import {\n isJSXText,\n isJSXExpressionContainer,\n isJSXEmptyExpression,\n} from \"../../validators/generated/index.ts\";\nimport cleanJSXElementLiteralChild from \"../../utils/react/cleanJSXElementLiteralChild.ts\";\nimport type * as t from \"../../index.ts\";\n\ntype ReturnedChild =\n | t.JSXSpreadChild\n | t.JSXElement\n | t.JSXFragment\n | t.Expression;\n\nexport default function buildChildren(\n node: t.JSXElement | t.JSXFragment,\n): ReturnedChild[] {\n const elements = [];\n\n for (let i = 0; i < node.children.length; i++) {\n let child: any = node.children[i];\n\n if (isJSXText(child)) {\n cleanJSXElementLiteralChild(child, elements);\n continue;\n }\n\n if (isJSXExpressionContainer(child)) child = child.expression;\n if (isJSXEmptyExpression(child)) continue;\n\n elements.push(child);\n }\n\n return elements;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAKA,IAAAC,4BAAA,GAAAD,OAAA;AASe,SAASE,aAAaA,CACnCC,IAAkC,EACjB;EACjB,MAAMC,QAAQ,GAAG,EAAE;EAEnB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,IAAI,CAACG,QAAQ,CAACC,MAAM,EAAEF,CAAC,EAAE,EAAE;IAC7C,IAAIG,KAAU,GAAGL,IAAI,CAACG,QAAQ,CAACD,CAAC,CAAC;IAEjC,IAAI,IAAAI,gBAAS,EAACD,KAAK,CAAC,EAAE;MACpB,IAAAE,oCAA2B,EAACF,KAAK,EAAEJ,QAAQ,CAAC;MAC5C;IACF;IAEA,IAAI,IAAAO,+BAAwB,EAACH,KAAK,CAAC,EAAEA,KAAK,GAAGA,KAAK,CAACI,UAAU;IAC7D,IAAI,IAAAC,2BAAoB,EAACL,KAAK,CAAC,EAAE;IAEjCJ,QAAQ,CAACU,IAAI,CAACN,KAAK,CAAC;EACtB;EAEA,OAAOJ,QAAQ;AACjB"} {"version":3,"names":["_index","require","_cleanJSXElementLiteralChild","buildChildren","node","elements","i","children","length","child","isJSXText","cleanJSXElementLiteralChild","isJSXExpressionContainer","expression","isJSXEmptyExpression","push"],"sources":["../../../src/builders/react/buildChildren.ts"],"sourcesContent":["import {\n isJSXText,\n isJSXExpressionContainer,\n isJSXEmptyExpression,\n} from \"../../validators/generated/index.ts\";\nimport cleanJSXElementLiteralChild from \"../../utils/react/cleanJSXElementLiteralChild.ts\";\nimport type * as t from \"../../index.ts\";\n\ntype ReturnedChild =\n | t.JSXSpreadChild\n | t.JSXElement\n | t.JSXFragment\n | t.Expression;\n\nexport default function buildChildren(\n node: t.JSXElement | t.JSXFragment,\n): ReturnedChild[] {\n const elements = [];\n\n for (let i = 0; i < node.children.length; i++) {\n let child: any = node.children[i];\n\n if (isJSXText(child)) {\n cleanJSXElementLiteralChild(child, elements);\n continue;\n }\n\n if (isJSXExpressionContainer(child)) child = child.expression;\n if (isJSXEmptyExpression(child)) continue;\n\n elements.push(child);\n }\n\n return elements;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAKA,IAAAC,4BAAA,GAAAD,OAAA;AASe,SAASE,aAAaA,CACnCC,IAAkC,EACjB;EACjB,MAAMC,QAAQ,GAAG,EAAE;EAEnB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,IAAI,CAACG,QAAQ,CAACC,MAAM,EAAEF,CAAC,EAAE,EAAE;IAC7C,IAAIG,KAAU,GAAGL,IAAI,CAACG,QAAQ,CAACD,CAAC,CAAC;IAEjC,IAAI,IAAAI,gBAAS,EAACD,KAAK,CAAC,EAAE;MACpB,IAAAE,oCAA2B,EAACF,KAAK,EAAEJ,QAAQ,CAAC;MAC5C;IACF;IAEA,IAAI,IAAAO,+BAAwB,EAACH,KAAK,CAAC,EAAEA,KAAK,GAAGA,KAAK,CAACI,UAAU;IAC7D,IAAI,IAAAC,2BAAoB,EAACL,KAAK,CAAC,EAAE;IAEjCJ,QAAQ,CAACU,IAAI,CAACN,KAAK,CAAC;EACtB;EAEA,OAAOJ,QAAQ;AACjB","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["_index","require","_removeTypeDuplicates","_index2","createTSUnionType","typeAnnotations","types","map","type","isTSTypeAnnotation","typeAnnotation","flattened","removeTypeDuplicates","length","tsUnionType"],"sources":["../../../src/builders/typescript/createTSUnionType.ts"],"sourcesContent":["import { tsUnionType } from \"../generated/index.ts\";\nimport removeTypeDuplicates from \"../../modifications/typescript/removeTypeDuplicates.ts\";\nimport { isTSTypeAnnotation } from \"../../validators/generated/index.ts\";\nimport type * as t from \"../../index.ts\";\n\n/**\n * Takes an array of `types` and flattens them, removing duplicates and\n * returns a `UnionTypeAnnotation` node containing them.\n */\nexport default function createTSUnionType(\n typeAnnotations: Array<t.TSTypeAnnotation | t.TSType>,\n): t.TSType {\n const types = typeAnnotations.map(type => {\n return isTSTypeAnnotation(type) ? type.typeAnnotation : type;\n });\n const flattened = removeTypeDuplicates(types);\n\n if (flattened.length === 1) {\n return flattened[0];\n } else {\n return tsUnionType(flattened);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAOe,SAASG,iBAAiBA,CACvCC,eAAqD,EAC3C;EACV,MAAMC,KAAK,GAAGD,eAAe,CAACE,GAAG,CAACC,IAAI,IAAI;IACxC,OAAO,IAAAC,0BAAkB,EAACD,IAAI,CAAC,GAAGA,IAAI,CAACE,cAAc,GAAGF,IAAI;EAC9D,CAAC,CAAC;EACF,MAAMG,SAAS,GAAG,IAAAC,6BAAoB,EAACN,KAAK,CAAC;EAE7C,IAAIK,SAAS,CAACE,MAAM,KAAK,CAAC,EAAE;IAC1B,OAAOF,SAAS,CAAC,CAAC,CAAC;EACrB,CAAC,MAAM;IACL,OAAO,IAAAG,kBAAW,EAACH,SAAS,CAAC;EAC/B;AACF"} {"version":3,"names":["_index","require","_removeTypeDuplicates","_index2","createTSUnionType","typeAnnotations","types","map","type","isTSTypeAnnotation","typeAnnotation","flattened","removeTypeDuplicates","length","tsUnionType"],"sources":["../../../src/builders/typescript/createTSUnionType.ts"],"sourcesContent":["import { tsUnionType } from \"../generated/index.ts\";\nimport removeTypeDuplicates from \"../../modifications/typescript/removeTypeDuplicates.ts\";\nimport { isTSTypeAnnotation } from \"../../validators/generated/index.ts\";\nimport type * as t from \"../../index.ts\";\n\n/**\n * Takes an array of `types` and flattens them, removing duplicates and\n * returns a `UnionTypeAnnotation` node containing them.\n */\nexport default function createTSUnionType(\n typeAnnotations: Array<t.TSTypeAnnotation | t.TSType>,\n): t.TSType {\n const types = typeAnnotations.map(type => {\n return isTSTypeAnnotation(type) ? type.typeAnnotation : type;\n });\n const flattened = removeTypeDuplicates(types);\n\n if (flattened.length === 1) {\n return flattened[0];\n } else {\n return tsUnionType(flattened);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAOe,SAASG,iBAAiBA,CACvCC,eAAqD,EAC3C;EACV,MAAMC,KAAK,GAAGD,eAAe,CAACE,GAAG,CAACC,IAAI,IAAI;IACxC,OAAO,IAAAC,0BAAkB,EAACD,IAAI,CAAC,GAAGA,IAAI,CAACE,cAAc,GAAGF,IAAI;EAC9D,CAAC,CAAC;EACF,MAAMG,SAAS,GAAG,IAAAC,6BAAoB,EAACN,KAAK,CAAC;EAE7C,IAAIK,SAAS,CAACE,MAAM,KAAK,CAAC,EAAE;IAC1B,OAAOF,SAAS,CAAC,CAAC,CAAC;EACrB,CAAC,MAAM;IACL,OAAO,IAAAG,kBAAW,EAACH,SAAS,CAAC;EAC/B;AACF","ignoreList":[]}

View File

@ -7,9 +7,13 @@ exports.default = validateNode;
var _validate = require("../validators/validate.js"); var _validate = require("../validators/validate.js");
var _index = require("../index.js"); var _index = require("../index.js");
function validateNode(node) { function validateNode(node) {
if (node == null || typeof node !== "object") return;
const fields = _index.NODE_FIELDS[node.type];
if (!fields) return;
const keys = _index.BUILDER_KEYS[node.type]; const keys = _index.BUILDER_KEYS[node.type];
for (const key of keys) { for (const key of keys) {
(0, _validate.default)(node, key, node[key]); const field = fields[key];
if (field != null) (0, _validate.validateInternal)(field, node, key, node[key]);
} }
return node; return node;
} }

View File

@ -1 +1 @@
{"version":3,"names":["_validate","require","_index","validateNode","node","keys","BUILDER_KEYS","type","key","validate"],"sources":["../../src/builders/validateNode.ts"],"sourcesContent":["import validate from \"../validators/validate.ts\";\nimport type * as t from \"../index.ts\";\nimport { BUILDER_KEYS } from \"../index.ts\";\n\nexport default function validateNode<N extends t.Node>(node: N) {\n // todo: because keys not in BUILDER_KEYS are not validated - this actually allows invalid nodes in some cases\n const keys = BUILDER_KEYS[node.type] as (keyof N & string)[];\n for (const key of keys) {\n validate(node, key, node[key]);\n }\n return node;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAEe,SAASE,YAAYA,CAAmBC,IAAO,EAAE;EAE9D,MAAMC,IAAI,GAAGC,mBAAY,CAACF,IAAI,CAACG,IAAI,CAAyB;EAC5D,KAAK,MAAMC,GAAG,IAAIH,IAAI,EAAE;IACtB,IAAAI,iBAAQ,EAACL,IAAI,EAAEI,GAAG,EAAEJ,IAAI,CAACI,GAAG,CAAC,CAAC;EAChC;EACA,OAAOJ,IAAI;AACb"} {"version":3,"names":["_validate","require","_index","validateNode","node","fields","NODE_FIELDS","type","keys","BUILDER_KEYS","key","field","validateInternal"],"sources":["../../src/builders/validateNode.ts"],"sourcesContent":["import { validateInternal } from \"../validators/validate.ts\";\nimport type * as t from \"../index.ts\";\nimport { BUILDER_KEYS, NODE_FIELDS } from \"../index.ts\";\n\nexport default function validateNode<N extends t.Node>(node: N) {\n if (node == null || typeof node !== \"object\") return;\n const fields = NODE_FIELDS[node.type];\n if (!fields) return;\n\n // todo: because keys not in BUILDER_KEYS are not validated - this actually allows invalid nodes in some cases\n const keys = BUILDER_KEYS[node.type] as (keyof N & string)[];\n for (const key of keys) {\n const field = fields[key];\n if (field != null) validateInternal(field, node, key, node[key]);\n }\n return node;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAEe,SAASE,YAAYA,CAAmBC,IAAO,EAAE;EAC9D,IAAIA,IAAI,IAAI,IAAI,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;EAC9C,MAAMC,MAAM,GAAGC,kBAAW,CAACF,IAAI,CAACG,IAAI,CAAC;EACrC,IAAI,CAACF,MAAM,EAAE;EAGb,MAAMG,IAAI,GAAGC,mBAAY,CAACL,IAAI,CAACG,IAAI,CAAyB;EAC5D,KAAK,MAAMG,GAAG,IAAIF,IAAI,EAAE;IACtB,MAAMG,KAAK,GAAGN,MAAM,CAACK,GAAG,CAAC;IACzB,IAAIC,KAAK,IAAI,IAAI,EAAE,IAAAC,0BAAgB,EAACD,KAAK,EAAEP,IAAI,EAAEM,GAAG,EAAEN,IAAI,CAACM,GAAG,CAAC,CAAC;EAClE;EACA,OAAON,IAAI;AACb","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["_cloneNode","require","clone","node","cloneNode"],"sources":["../../src/clone/clone.ts"],"sourcesContent":["import cloneNode from \"./cloneNode.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Create a shallow clone of a `node`, including only\n * properties belonging to the node.\n * @deprecated Use t.cloneNode instead.\n */\nexport default function clone<T extends t.Node>(node: T): T {\n return cloneNode(node, /* deep */ false);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAQe,SAASC,KAAKA,CAAmBC,IAAO,EAAK;EAC1D,OAAO,IAAAC,kBAAS,EAACD,IAAI,EAAa,KAAK,CAAC;AAC1C"} {"version":3,"names":["_cloneNode","require","clone","node","cloneNode"],"sources":["../../src/clone/clone.ts"],"sourcesContent":["import cloneNode from \"./cloneNode.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Create a shallow clone of a `node`, including only\n * properties belonging to the node.\n * @deprecated Use t.cloneNode instead.\n */\nexport default function clone<T extends t.Node>(node: T): T {\n return cloneNode(node, /* deep */ false);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAQe,SAASC,KAAKA,CAAmBC,IAAO,EAAK;EAC1D,OAAO,IAAAC,kBAAS,EAACD,IAAI,EAAa,KAAK,CAAC;AAC1C","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["_cloneNode","require","cloneDeep","node","cloneNode"],"sources":["../../src/clone/cloneDeep.ts"],"sourcesContent":["import cloneNode from \"./cloneNode.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Create a deep clone of a `node` and all of it's child nodes\n * including only properties belonging to the node.\n * @deprecated Use t.cloneNode instead.\n */\nexport default function cloneDeep<T extends t.Node>(node: T): T {\n return cloneNode(node);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAQe,SAASC,SAASA,CAAmBC,IAAO,EAAK;EAC9D,OAAO,IAAAC,kBAAS,EAACD,IAAI,CAAC;AACxB"} {"version":3,"names":["_cloneNode","require","cloneDeep","node","cloneNode"],"sources":["../../src/clone/cloneDeep.ts"],"sourcesContent":["import cloneNode from \"./cloneNode.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Create a deep clone of a `node` and all of it's child nodes\n * including only properties belonging to the node.\n * @deprecated Use t.cloneNode instead.\n */\nexport default function cloneDeep<T extends t.Node>(node: T): T {\n return cloneNode(node);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAQe,SAASC,SAASA,CAAmBC,IAAO,EAAK;EAC9D,OAAO,IAAAC,kBAAS,EAACD,IAAI,CAAC;AACxB","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["_cloneNode","require","cloneDeepWithoutLoc","node","cloneNode"],"sources":["../../src/clone/cloneDeepWithoutLoc.ts"],"sourcesContent":["import cloneNode from \"./cloneNode.ts\";\nimport type * as t from \"../index.ts\";\n/**\n * Create a deep clone of a `node` and all of it's child nodes\n * including only properties belonging to the node.\n * excluding `_private` and location properties.\n */\nexport default function cloneDeepWithoutLoc<T extends t.Node>(node: T): T {\n return cloneNode(node, /* deep */ true, /* withoutLoc */ true);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAOe,SAASC,mBAAmBA,CAAmBC,IAAO,EAAK;EACxE,OAAO,IAAAC,kBAAS,EAACD,IAAI,EAAa,IAAI,EAAmB,IAAI,CAAC;AAChE"} {"version":3,"names":["_cloneNode","require","cloneDeepWithoutLoc","node","cloneNode"],"sources":["../../src/clone/cloneDeepWithoutLoc.ts"],"sourcesContent":["import cloneNode from \"./cloneNode.ts\";\nimport type * as t from \"../index.ts\";\n/**\n * Create a deep clone of a `node` and all of it's child nodes\n * including only properties belonging to the node.\n * excluding `_private` and location properties.\n */\nexport default function cloneDeepWithoutLoc<T extends t.Node>(node: T): T {\n return cloneNode(node, /* deep */ true, /* withoutLoc */ true);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAOe,SAASC,mBAAmBA,CAAmBC,IAAO,EAAK;EACxE,OAAO,IAAAC,kBAAS,EAACD,IAAI,EAAa,IAAI,EAAmB,IAAI,CAAC;AAChE","ignoreList":[]}

View File

@ -42,6 +42,9 @@ function cloneNodeInternal(node, deep = true, withoutLoc = false, commentsCache)
if (hasOwn(node, "typeAnnotation")) { if (hasOwn(node, "typeAnnotation")) {
newNode.typeAnnotation = deep ? cloneIfNodeOrArray(node.typeAnnotation, true, withoutLoc, commentsCache) : node.typeAnnotation; newNode.typeAnnotation = deep ? cloneIfNodeOrArray(node.typeAnnotation, true, withoutLoc, commentsCache) : node.typeAnnotation;
} }
if (hasOwn(node, "decorators")) {
newNode.decorators = deep ? cloneIfNodeOrArray(node.decorators, true, withoutLoc, commentsCache) : node.decorators;
}
} else if (!hasOwn(_index.NODE_FIELDS, type)) { } else if (!hasOwn(_index.NODE_FIELDS, type)) {
throw new Error(`Unknown node type: "${type}"`); throw new Error(`Unknown node type: "${type}"`);
} else { } else {

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"version":3,"names":["_cloneNode","require","cloneWithoutLoc","node","cloneNode"],"sources":["../../src/clone/cloneWithoutLoc.ts"],"sourcesContent":["import cloneNode from \"./cloneNode.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Create a shallow clone of a `node` excluding `_private` and location properties.\n */\nexport default function cloneWithoutLoc<T extends t.Node>(node: T): T {\n return cloneNode(node, /* deep */ false, /* withoutLoc */ true);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAMe,SAASC,eAAeA,CAAmBC,IAAO,EAAK;EACpE,OAAO,IAAAC,kBAAS,EAACD,IAAI,EAAa,KAAK,EAAmB,IAAI,CAAC;AACjE"} {"version":3,"names":["_cloneNode","require","cloneWithoutLoc","node","cloneNode"],"sources":["../../src/clone/cloneWithoutLoc.ts"],"sourcesContent":["import cloneNode from \"./cloneNode.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Create a shallow clone of a `node` excluding `_private` and location properties.\n */\nexport default function cloneWithoutLoc<T extends t.Node>(node: T): T {\n return cloneNode(node, /* deep */ false, /* withoutLoc */ true);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAMe,SAASC,eAAeA,CAAmBC,IAAO,EAAK;EACpE,OAAO,IAAAC,kBAAS,EAACD,IAAI,EAAa,KAAK,EAAmB,IAAI,CAAC;AACjE","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["_addComments","require","addComment","node","type","content","line","addComments","value"],"sources":["../../src/comments/addComment.ts"],"sourcesContent":["import addComments from \"./addComments.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Add comment of certain type to a node.\n */\nexport default function addComment<T extends t.Node>(\n node: T,\n type: t.CommentTypeShorthand,\n content: string,\n line?: boolean,\n): T {\n return addComments(node, type, [\n {\n type: line ? \"CommentLine\" : \"CommentBlock\",\n value: content,\n } as t.Comment,\n ]);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAMe,SAASC,UAAUA,CAChCC,IAAO,EACPC,IAA4B,EAC5BC,OAAe,EACfC,IAAc,EACX;EACH,OAAO,IAAAC,oBAAW,EAACJ,IAAI,EAAEC,IAAI,EAAE,CAC7B;IACEA,IAAI,EAAEE,IAAI,GAAG,aAAa,GAAG,cAAc;IAC3CE,KAAK,EAAEH;EACT,CAAC,CACF,CAAC;AACJ"} {"version":3,"names":["_addComments","require","addComment","node","type","content","line","addComments","value"],"sources":["../../src/comments/addComment.ts"],"sourcesContent":["import addComments from \"./addComments.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Add comment of certain type to a node.\n */\nexport default function addComment<T extends t.Node>(\n node: T,\n type: t.CommentTypeShorthand,\n content: string,\n line?: boolean,\n): T {\n return addComments(node, type, [\n {\n type: line ? \"CommentLine\" : \"CommentBlock\",\n value: content,\n } as t.Comment,\n ]);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAMe,SAASC,UAAUA,CAChCC,IAAO,EACPC,IAA4B,EAC5BC,OAAe,EACfC,IAAc,EACX;EACH,OAAO,IAAAC,oBAAW,EAACJ,IAAI,EAAEC,IAAI,EAAE,CAC7B;IACEA,IAAI,EAAEE,IAAI,GAAG,aAAa,GAAG,cAAc;IAC3CE,KAAK,EAAEH;EACT,CAAC,CACF,CAAC;AACJ","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["addComments","node","type","comments","key","concat","push"],"sources":["../../src/comments/addComments.ts"],"sourcesContent":["import type * as t from \"../index.ts\";\n\n/**\n * Add comments of certain type to a node.\n */\nexport default function addComments<T extends t.Node>(\n node: T,\n type: t.CommentTypeShorthand,\n comments: Array<t.Comment>,\n): T {\n if (!comments || !node) return node;\n\n const key = `${type}Comments` as const;\n\n if (node[key]) {\n if (type === \"leading\") {\n node[key] = comments.concat(node[key]);\n } else {\n node[key].push(...comments);\n }\n } else {\n node[key] = comments;\n }\n\n return node;\n}\n"],"mappings":";;;;;;AAKe,SAASA,WAAWA,CACjCC,IAAO,EACPC,IAA4B,EAC5BC,QAA0B,EACvB;EACH,IAAI,CAACA,QAAQ,IAAI,CAACF,IAAI,EAAE,OAAOA,IAAI;EAEnC,MAAMG,GAAG,GAAI,GAAEF,IAAK,UAAkB;EAEtC,IAAID,IAAI,CAACG,GAAG,CAAC,EAAE;IACb,IAAIF,IAAI,KAAK,SAAS,EAAE;MACtBD,IAAI,CAACG,GAAG,CAAC,GAAGD,QAAQ,CAACE,MAAM,CAACJ,IAAI,CAACG,GAAG,CAAC,CAAC;IACxC,CAAC,MAAM;MACLH,IAAI,CAACG,GAAG,CAAC,CAACE,IAAI,CAAC,GAAGH,QAAQ,CAAC;IAC7B;EACF,CAAC,MAAM;IACLF,IAAI,CAACG,GAAG,CAAC,GAAGD,QAAQ;EACtB;EAEA,OAAOF,IAAI;AACb"} {"version":3,"names":["addComments","node","type","comments","key","concat","push"],"sources":["../../src/comments/addComments.ts"],"sourcesContent":["import type * as t from \"../index.ts\";\n\n/**\n * Add comments of certain type to a node.\n */\nexport default function addComments<T extends t.Node>(\n node: T,\n type: t.CommentTypeShorthand,\n comments: Array<t.Comment>,\n): T {\n if (!comments || !node) return node;\n\n const key = `${type}Comments` as const;\n\n if (node[key]) {\n if (type === \"leading\") {\n node[key] = comments.concat(node[key]);\n } else {\n node[key].push(...comments);\n }\n } else {\n node[key] = comments;\n }\n\n return node;\n}\n"],"mappings":";;;;;;AAKe,SAASA,WAAWA,CACjCC,IAAO,EACPC,IAA4B,EAC5BC,QAA0B,EACvB;EACH,IAAI,CAACA,QAAQ,IAAI,CAACF,IAAI,EAAE,OAAOA,IAAI;EAEnC,MAAMG,GAAG,GAAG,GAAGF,IAAI,UAAmB;EAEtC,IAAID,IAAI,CAACG,GAAG,CAAC,EAAE;IACb,IAAIF,IAAI,KAAK,SAAS,EAAE;MACtBD,IAAI,CAACG,GAAG,CAAC,GAAGD,QAAQ,CAACE,MAAM,CAACJ,IAAI,CAACG,GAAG,CAAC,CAAC;IACxC,CAAC,MAAM;MACLH,IAAI,CAACG,GAAG,CAAC,CAACE,IAAI,CAAC,GAAGH,QAAQ,CAAC;IAC7B;EACF,CAAC,MAAM;IACLF,IAAI,CAACG,GAAG,CAAC,GAAGD,QAAQ;EACtB;EAEA,OAAOF,IAAI;AACb","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["_inherit","require","inheritInnerComments","child","parent","inherit"],"sources":["../../src/comments/inheritInnerComments.ts"],"sourcesContent":["import inherit from \"../utils/inherit.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default function inheritInnerComments(\n child: t.Node,\n parent: t.Node,\n): void {\n inherit(\"innerComments\", child, parent);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAGe,SAASC,oBAAoBA,CAC1CC,KAAa,EACbC,MAAc,EACR;EACN,IAAAC,gBAAO,EAAC,eAAe,EAAEF,KAAK,EAAEC,MAAM,CAAC;AACzC"} {"version":3,"names":["_inherit","require","inheritInnerComments","child","parent","inherit"],"sources":["../../src/comments/inheritInnerComments.ts"],"sourcesContent":["import inherit from \"../utils/inherit.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default function inheritInnerComments(\n child: t.Node,\n parent: t.Node,\n): void {\n inherit(\"innerComments\", child, parent);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAGe,SAASC,oBAAoBA,CAC1CC,KAAa,EACbC,MAAc,EACR;EACN,IAAAC,gBAAO,EAAC,eAAe,EAAEF,KAAK,EAAEC,MAAM,CAAC;AACzC","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["_inherit","require","inheritLeadingComments","child","parent","inherit"],"sources":["../../src/comments/inheritLeadingComments.ts"],"sourcesContent":["import inherit from \"../utils/inherit.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default function inheritLeadingComments(\n child: t.Node,\n parent: t.Node,\n): void {\n inherit(\"leadingComments\", child, parent);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAGe,SAASC,sBAAsBA,CAC5CC,KAAa,EACbC,MAAc,EACR;EACN,IAAAC,gBAAO,EAAC,iBAAiB,EAAEF,KAAK,EAAEC,MAAM,CAAC;AAC3C"} {"version":3,"names":["_inherit","require","inheritLeadingComments","child","parent","inherit"],"sources":["../../src/comments/inheritLeadingComments.ts"],"sourcesContent":["import inherit from \"../utils/inherit.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default function inheritLeadingComments(\n child: t.Node,\n parent: t.Node,\n): void {\n inherit(\"leadingComments\", child, parent);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAGe,SAASC,sBAAsBA,CAC5CC,KAAa,EACbC,MAAc,EACR;EACN,IAAAC,gBAAO,EAAC,iBAAiB,EAAEF,KAAK,EAAEC,MAAM,CAAC;AAC3C","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["_inherit","require","inheritTrailingComments","child","parent","inherit"],"sources":["../../src/comments/inheritTrailingComments.ts"],"sourcesContent":["import inherit from \"../utils/inherit.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default function inheritTrailingComments(\n child: t.Node,\n parent: t.Node,\n): void {\n inherit(\"trailingComments\", child, parent);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAGe,SAASC,uBAAuBA,CAC7CC,KAAa,EACbC,MAAc,EACR;EACN,IAAAC,gBAAO,EAAC,kBAAkB,EAAEF,KAAK,EAAEC,MAAM,CAAC;AAC5C"} {"version":3,"names":["_inherit","require","inheritTrailingComments","child","parent","inherit"],"sources":["../../src/comments/inheritTrailingComments.ts"],"sourcesContent":["import inherit from \"../utils/inherit.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default function inheritTrailingComments(\n child: t.Node,\n parent: t.Node,\n): void {\n inherit(\"trailingComments\", child, parent);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAGe,SAASC,uBAAuBA,CAC7CC,KAAa,EACbC,MAAc,EACR;EACN,IAAAC,gBAAO,EAAC,kBAAkB,EAAEF,KAAK,EAAEC,MAAM,CAAC;AAC5C","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["_inheritTrailingComments","require","_inheritLeadingComments","_inheritInnerComments","inheritsComments","child","parent","inheritTrailingComments","inheritLeadingComments","inheritInnerComments"],"sources":["../../src/comments/inheritsComments.ts"],"sourcesContent":["import inheritTrailingComments from \"./inheritTrailingComments.ts\";\nimport inheritLeadingComments from \"./inheritLeadingComments.ts\";\nimport inheritInnerComments from \"./inheritInnerComments.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Inherit all unique comments from `parent` node to `child` node.\n */\nexport default function inheritsComments<T extends t.Node>(\n child: T,\n parent: t.Node,\n): T {\n inheritTrailingComments(child, parent);\n inheritLeadingComments(child, parent);\n inheritInnerComments(child, parent);\n\n return child;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAD,OAAA;AACA,IAAAE,qBAAA,GAAAF,OAAA;AAMe,SAASG,gBAAgBA,CACtCC,KAAQ,EACRC,MAAc,EACX;EACH,IAAAC,gCAAuB,EAACF,KAAK,EAAEC,MAAM,CAAC;EACtC,IAAAE,+BAAsB,EAACH,KAAK,EAAEC,MAAM,CAAC;EACrC,IAAAG,6BAAoB,EAACJ,KAAK,EAAEC,MAAM,CAAC;EAEnC,OAAOD,KAAK;AACd"} {"version":3,"names":["_inheritTrailingComments","require","_inheritLeadingComments","_inheritInnerComments","inheritsComments","child","parent","inheritTrailingComments","inheritLeadingComments","inheritInnerComments"],"sources":["../../src/comments/inheritsComments.ts"],"sourcesContent":["import inheritTrailingComments from \"./inheritTrailingComments.ts\";\nimport inheritLeadingComments from \"./inheritLeadingComments.ts\";\nimport inheritInnerComments from \"./inheritInnerComments.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Inherit all unique comments from `parent` node to `child` node.\n */\nexport default function inheritsComments<T extends t.Node>(\n child: T,\n parent: t.Node,\n): T {\n inheritTrailingComments(child, parent);\n inheritLeadingComments(child, parent);\n inheritInnerComments(child, parent);\n\n return child;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAD,OAAA;AACA,IAAAE,qBAAA,GAAAF,OAAA;AAMe,SAASG,gBAAgBA,CACtCC,KAAQ,EACRC,MAAc,EACX;EACH,IAAAC,gCAAuB,EAACF,KAAK,EAAEC,MAAM,CAAC;EACtC,IAAAE,+BAAsB,EAACH,KAAK,EAAEC,MAAM,CAAC;EACrC,IAAAG,6BAAoB,EAACJ,KAAK,EAAEC,MAAM,CAAC;EAEnC,OAAOD,KAAK;AACd","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["_index","require","removeComments","node","COMMENT_KEYS","forEach","key"],"sources":["../../src/comments/removeComments.ts"],"sourcesContent":["import { COMMENT_KEYS } from \"../constants/index.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Remove comment properties from a node.\n */\nexport default function removeComments<T extends t.Node>(node: T): T {\n COMMENT_KEYS.forEach(key => {\n node[key] = null;\n });\n\n return node;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAMe,SAASC,cAAcA,CAAmBC,IAAO,EAAK;EACnEC,mBAAY,CAACC,OAAO,CAACC,GAAG,IAAI;IAC1BH,IAAI,CAACG,GAAG,CAAC,GAAG,IAAI;EAClB,CAAC,CAAC;EAEF,OAAOH,IAAI;AACb"} {"version":3,"names":["_index","require","removeComments","node","COMMENT_KEYS","forEach","key"],"sources":["../../src/comments/removeComments.ts"],"sourcesContent":["import { COMMENT_KEYS } from \"../constants/index.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Remove comment properties from a node.\n */\nexport default function removeComments<T extends t.Node>(node: T): T {\n COMMENT_KEYS.forEach(key => {\n node[key] = null;\n });\n\n return node;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAMe,SAASC,cAAcA,CAAmBC,IAAO,EAAK;EACnEC,mBAAY,CAACC,OAAO,CAACC,GAAG,IAAI;IAC1BH,IAAI,CAACG,GAAG,CAAC,GAAG,IAAI;EAClB,CAAC,CAAC;EAEF,OAAOH,IAAI;AACb","ignoreList":[]}

File diff suppressed because one or more lines are too long

View File

@ -3,7 +3,7 @@
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.UPDATE_OPERATORS = exports.UNARY_OPERATORS = exports.STRING_UNARY_OPERATORS = exports.STATEMENT_OR_BLOCK_KEYS = exports.NUMBER_UNARY_OPERATORS = exports.NUMBER_BINARY_OPERATORS = exports.NOT_LOCAL_BINDING = exports.LOGICAL_OPERATORS = exports.INHERIT_KEYS = exports.FOR_INIT_KEYS = exports.FLATTENABLE_KEYS = exports.EQUALITY_BINARY_OPERATORS = exports.COMPARISON_BINARY_OPERATORS = exports.COMMENT_KEYS = exports.BOOLEAN_UNARY_OPERATORS = exports.BOOLEAN_NUMBER_BINARY_OPERATORS = exports.BOOLEAN_BINARY_OPERATORS = exports.BLOCK_SCOPED_SYMBOL = exports.BINARY_OPERATORS = exports.ASSIGNMENT_OPERATORS = void 0; exports.UPDATE_OPERATORS = exports.UNARY_OPERATORS = exports.STRING_UNARY_OPERATORS = exports.STATEMENT_OR_BLOCK_KEYS = exports.NUMBER_UNARY_OPERATORS = exports.NUMBER_BINARY_OPERATORS = exports.LOGICAL_OPERATORS = exports.INHERIT_KEYS = exports.FOR_INIT_KEYS = exports.FLATTENABLE_KEYS = exports.EQUALITY_BINARY_OPERATORS = exports.COMPARISON_BINARY_OPERATORS = exports.COMMENT_KEYS = exports.BOOLEAN_UNARY_OPERATORS = exports.BOOLEAN_NUMBER_BINARY_OPERATORS = exports.BOOLEAN_BINARY_OPERATORS = exports.BINARY_OPERATORS = exports.ASSIGNMENT_OPERATORS = void 0;
const STATEMENT_OR_BLOCK_KEYS = exports.STATEMENT_OR_BLOCK_KEYS = ["consequent", "body", "alternate"]; const STATEMENT_OR_BLOCK_KEYS = exports.STATEMENT_OR_BLOCK_KEYS = ["consequent", "body", "alternate"];
const FLATTENABLE_KEYS = exports.FLATTENABLE_KEYS = ["body", "expressions"]; const FLATTENABLE_KEYS = exports.FLATTENABLE_KEYS = ["body", "expressions"];
const FOR_INIT_KEYS = exports.FOR_INIT_KEYS = ["left", "init"]; const FOR_INIT_KEYS = exports.FOR_INIT_KEYS = ["left", "init"];
@ -25,7 +25,9 @@ const INHERIT_KEYS = exports.INHERIT_KEYS = {
optional: ["typeAnnotation", "typeParameters", "returnType"], optional: ["typeAnnotation", "typeParameters", "returnType"],
force: ["start", "loc", "end"] force: ["start", "loc", "end"]
}; };
const BLOCK_SCOPED_SYMBOL = exports.BLOCK_SCOPED_SYMBOL = Symbol.for("var used to be block scoped"); {
const NOT_LOCAL_BINDING = exports.NOT_LOCAL_BINDING = Symbol.for("should not be considered a local binding"); exports.BLOCK_SCOPED_SYMBOL = Symbol.for("var used to be block scoped");
exports.NOT_LOCAL_BINDING = Symbol.for("should not be considered a local binding");
}
//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map

View File

@ -1 +1 @@
{"version":3,"names":["STATEMENT_OR_BLOCK_KEYS","exports","FLATTENABLE_KEYS","FOR_INIT_KEYS","COMMENT_KEYS","LOGICAL_OPERATORS","UPDATE_OPERATORS","BOOLEAN_NUMBER_BINARY_OPERATORS","EQUALITY_BINARY_OPERATORS","COMPARISON_BINARY_OPERATORS","BOOLEAN_BINARY_OPERATORS","NUMBER_BINARY_OPERATORS","BINARY_OPERATORS","ASSIGNMENT_OPERATORS","map","op","BOOLEAN_UNARY_OPERATORS","NUMBER_UNARY_OPERATORS","STRING_UNARY_OPERATORS","UNARY_OPERATORS","INHERIT_KEYS","optional","force","BLOCK_SCOPED_SYMBOL","Symbol","for","NOT_LOCAL_BINDING"],"sources":["../../src/constants/index.ts"],"sourcesContent":["export const STATEMENT_OR_BLOCK_KEYS = [\"consequent\", \"body\", \"alternate\"];\nexport const FLATTENABLE_KEYS = [\"body\", \"expressions\"];\nexport const FOR_INIT_KEYS = [\"left\", \"init\"];\nexport const COMMENT_KEYS = [\n \"leadingComments\",\n \"trailingComments\",\n \"innerComments\",\n] as const;\n\nexport const LOGICAL_OPERATORS = [\"||\", \"&&\", \"??\"];\nexport const UPDATE_OPERATORS = [\"++\", \"--\"];\n\nexport const BOOLEAN_NUMBER_BINARY_OPERATORS = [\">\", \"<\", \">=\", \"<=\"];\nexport const EQUALITY_BINARY_OPERATORS = [\"==\", \"===\", \"!=\", \"!==\"];\nexport const COMPARISON_BINARY_OPERATORS = [\n ...EQUALITY_BINARY_OPERATORS,\n \"in\",\n \"instanceof\",\n];\nexport const BOOLEAN_BINARY_OPERATORS = [\n ...COMPARISON_BINARY_OPERATORS,\n ...BOOLEAN_NUMBER_BINARY_OPERATORS,\n];\nexport const NUMBER_BINARY_OPERATORS = [\n \"-\",\n \"/\",\n \"%\",\n \"*\",\n \"**\",\n \"&\",\n \"|\",\n \">>\",\n \">>>\",\n \"<<\",\n \"^\",\n];\nexport const BINARY_OPERATORS = [\n \"+\",\n ...NUMBER_BINARY_OPERATORS,\n ...BOOLEAN_BINARY_OPERATORS,\n \"|>\",\n];\n\nexport const ASSIGNMENT_OPERATORS = [\n \"=\",\n \"+=\",\n ...NUMBER_BINARY_OPERATORS.map(op => op + \"=\"),\n ...LOGICAL_OPERATORS.map(op => op + \"=\"),\n];\n\nexport const BOOLEAN_UNARY_OPERATORS = [\"delete\", \"!\"];\nexport const NUMBER_UNARY_OPERATORS = [\"+\", \"-\", \"~\"];\nexport const STRING_UNARY_OPERATORS = [\"typeof\"];\nexport const UNARY_OPERATORS = [\n \"void\",\n \"throw\",\n ...BOOLEAN_UNARY_OPERATORS,\n ...NUMBER_UNARY_OPERATORS,\n ...STRING_UNARY_OPERATORS,\n];\n\nexport const INHERIT_KEYS = {\n optional: [\"typeAnnotation\", \"typeParameters\", \"returnType\"],\n force: [\"start\", \"loc\", \"end\"],\n} as const;\n\nexport const BLOCK_SCOPED_SYMBOL = Symbol.for(\"var used to be block scoped\");\nexport const NOT_LOCAL_BINDING = Symbol.for(\n \"should not be considered a local binding\",\n);\n"],"mappings":";;;;;;AAAO,MAAMA,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC;AACnE,MAAME,gBAAgB,GAAAD,OAAA,CAAAC,gBAAA,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC;AAChD,MAAMC,aAAa,GAAAF,OAAA,CAAAE,aAAA,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;AACtC,MAAMC,YAAY,GAAAH,OAAA,CAAAG,YAAA,GAAG,CAC1B,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,CACP;AAEH,MAAMC,iBAAiB,GAAAJ,OAAA,CAAAI,iBAAA,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;AAC5C,MAAMC,gBAAgB,GAAAL,OAAA,CAAAK,gBAAA,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC;AAErC,MAAMC,+BAA+B,GAAAN,OAAA,CAAAM,+BAAA,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC;AAC9D,MAAMC,yBAAyB,GAAAP,OAAA,CAAAO,yBAAA,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC;AAC5D,MAAMC,2BAA2B,GAAAR,OAAA,CAAAQ,2BAAA,GAAG,CACzC,GAAGD,yBAAyB,EAC5B,IAAI,EACJ,YAAY,CACb;AACM,MAAME,wBAAwB,GAAAT,OAAA,CAAAS,wBAAA,GAAG,CACtC,GAAGD,2BAA2B,EAC9B,GAAGF,+BAA+B,CACnC;AACM,MAAMI,uBAAuB,GAAAV,OAAA,CAAAU,uBAAA,GAAG,CACrC,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,IAAI,EACJ,GAAG,EACH,GAAG,EACH,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,GAAG,CACJ;AACM,MAAMC,gBAAgB,GAAAX,OAAA,CAAAW,gBAAA,GAAG,CAC9B,GAAG,EACH,GAAGD,uBAAuB,EAC1B,GAAGD,wBAAwB,EAC3B,IAAI,CACL;AAEM,MAAMG,oBAAoB,GAAAZ,OAAA,CAAAY,oBAAA,GAAG,CAClC,GAAG,EACH,IAAI,EACJ,GAAGF,uBAAuB,CAACG,GAAG,CAACC,EAAE,IAAIA,EAAE,GAAG,GAAG,CAAC,EAC9C,GAAGV,iBAAiB,CAACS,GAAG,CAACC,EAAE,IAAIA,EAAE,GAAG,GAAG,CAAC,CACzC;AAEM,MAAMC,uBAAuB,GAAAf,OAAA,CAAAe,uBAAA,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC;AAC/C,MAAMC,sBAAsB,GAAAhB,OAAA,CAAAgB,sBAAA,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;AAC9C,MAAMC,sBAAsB,GAAAjB,OAAA,CAAAiB,sBAAA,GAAG,CAAC,QAAQ,CAAC;AACzC,MAAMC,eAAe,GAAAlB,OAAA,CAAAkB,eAAA,GAAG,CAC7B,MAAM,EACN,OAAO,EACP,GAAGH,uBAAuB,EAC1B,GAAGC,sBAAsB,EACzB,GAAGC,sBAAsB,CAC1B;AAEM,MAAME,YAAY,GAAAnB,OAAA,CAAAmB,YAAA,GAAG;EAC1BC,QAAQ,EAAE,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,YAAY,CAAC;EAC5DC,KAAK,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK;AAC/B,CAAU;AAEH,MAAMC,mBAAmB,GAAAtB,OAAA,CAAAsB,mBAAA,GAAGC,MAAM,CAACC,GAAG,CAAC,6BAA6B,CAAC;AACrE,MAAMC,iBAAiB,GAAAzB,OAAA,CAAAyB,iBAAA,GAAGF,MAAM,CAACC,GAAG,CACzC,0CACF,CAAC"} {"version":3,"names":["STATEMENT_OR_BLOCK_KEYS","exports","FLATTENABLE_KEYS","FOR_INIT_KEYS","COMMENT_KEYS","LOGICAL_OPERATORS","UPDATE_OPERATORS","BOOLEAN_NUMBER_BINARY_OPERATORS","EQUALITY_BINARY_OPERATORS","COMPARISON_BINARY_OPERATORS","BOOLEAN_BINARY_OPERATORS","NUMBER_BINARY_OPERATORS","BINARY_OPERATORS","ASSIGNMENT_OPERATORS","map","op","BOOLEAN_UNARY_OPERATORS","NUMBER_UNARY_OPERATORS","STRING_UNARY_OPERATORS","UNARY_OPERATORS","INHERIT_KEYS","optional","force","BLOCK_SCOPED_SYMBOL","Symbol","for","NOT_LOCAL_BINDING"],"sources":["../../src/constants/index.ts"],"sourcesContent":["export const STATEMENT_OR_BLOCK_KEYS = [\"consequent\", \"body\", \"alternate\"];\nexport const FLATTENABLE_KEYS = [\"body\", \"expressions\"];\nexport const FOR_INIT_KEYS = [\"left\", \"init\"];\nexport const COMMENT_KEYS = [\n \"leadingComments\",\n \"trailingComments\",\n \"innerComments\",\n] as const;\n\nexport const LOGICAL_OPERATORS = [\"||\", \"&&\", \"??\"];\nexport const UPDATE_OPERATORS = [\"++\", \"--\"];\n\nexport const BOOLEAN_NUMBER_BINARY_OPERATORS = [\">\", \"<\", \">=\", \"<=\"];\nexport const EQUALITY_BINARY_OPERATORS = [\"==\", \"===\", \"!=\", \"!==\"];\nexport const COMPARISON_BINARY_OPERATORS = [\n ...EQUALITY_BINARY_OPERATORS,\n \"in\",\n \"instanceof\",\n];\nexport const BOOLEAN_BINARY_OPERATORS = [\n ...COMPARISON_BINARY_OPERATORS,\n ...BOOLEAN_NUMBER_BINARY_OPERATORS,\n];\nexport const NUMBER_BINARY_OPERATORS = [\n \"-\",\n \"/\",\n \"%\",\n \"*\",\n \"**\",\n \"&\",\n \"|\",\n \">>\",\n \">>>\",\n \"<<\",\n \"^\",\n];\nexport const BINARY_OPERATORS = [\n \"+\",\n ...NUMBER_BINARY_OPERATORS,\n ...BOOLEAN_BINARY_OPERATORS,\n \"|>\",\n];\n\nexport const ASSIGNMENT_OPERATORS = [\n \"=\",\n \"+=\",\n ...NUMBER_BINARY_OPERATORS.map(op => op + \"=\"),\n ...LOGICAL_OPERATORS.map(op => op + \"=\"),\n];\n\nexport const BOOLEAN_UNARY_OPERATORS = [\"delete\", \"!\"];\nexport const NUMBER_UNARY_OPERATORS = [\"+\", \"-\", \"~\"];\nexport const STRING_UNARY_OPERATORS = [\"typeof\"];\nexport const UNARY_OPERATORS = [\n \"void\",\n \"throw\",\n ...BOOLEAN_UNARY_OPERATORS,\n ...NUMBER_UNARY_OPERATORS,\n ...STRING_UNARY_OPERATORS,\n];\n\nexport const INHERIT_KEYS = {\n optional: [\"typeAnnotation\", \"typeParameters\", \"returnType\"],\n force: [\"start\", \"loc\", \"end\"],\n} as const;\n\nif (!process.env.BABEL_8_BREAKING && !USE_ESM) {\n // eslint-disable-next-line no-restricted-globals\n exports.BLOCK_SCOPED_SYMBOL = Symbol.for(\"var used to be block scoped\");\n // eslint-disable-next-line no-restricted-globals\n exports.NOT_LOCAL_BINDING = Symbol.for(\n \"should not be considered a local binding\",\n );\n}\n"],"mappings":";;;;;;AAAO,MAAMA,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC;AACnE,MAAME,gBAAgB,GAAAD,OAAA,CAAAC,gBAAA,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC;AAChD,MAAMC,aAAa,GAAAF,OAAA,CAAAE,aAAA,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;AACtC,MAAMC,YAAY,GAAAH,OAAA,CAAAG,YAAA,GAAG,CAC1B,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,CACP;AAEH,MAAMC,iBAAiB,GAAAJ,OAAA,CAAAI,iBAAA,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;AAC5C,MAAMC,gBAAgB,GAAAL,OAAA,CAAAK,gBAAA,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC;AAErC,MAAMC,+BAA+B,GAAAN,OAAA,CAAAM,+BAAA,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC;AAC9D,MAAMC,yBAAyB,GAAAP,OAAA,CAAAO,yBAAA,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC;AAC5D,MAAMC,2BAA2B,GAAAR,OAAA,CAAAQ,2BAAA,GAAG,CACzC,GAAGD,yBAAyB,EAC5B,IAAI,EACJ,YAAY,CACb;AACM,MAAME,wBAAwB,GAAAT,OAAA,CAAAS,wBAAA,GAAG,CACtC,GAAGD,2BAA2B,EAC9B,GAAGF,+BAA+B,CACnC;AACM,MAAMI,uBAAuB,GAAAV,OAAA,CAAAU,uBAAA,GAAG,CACrC,GAAG,EACH,GAAG,EACH,GAAG,EACH,GAAG,EACH,IAAI,EACJ,GAAG,EACH,GAAG,EACH,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,GAAG,CACJ;AACM,MAAMC,gBAAgB,GAAAX,OAAA,CAAAW,gBAAA,GAAG,CAC9B,GAAG,EACH,GAAGD,uBAAuB,EAC1B,GAAGD,wBAAwB,EAC3B,IAAI,CACL;AAEM,MAAMG,oBAAoB,GAAAZ,OAAA,CAAAY,oBAAA,GAAG,CAClC,GAAG,EACH,IAAI,EACJ,GAAGF,uBAAuB,CAACG,GAAG,CAACC,EAAE,IAAIA,EAAE,GAAG,GAAG,CAAC,EAC9C,GAAGV,iBAAiB,CAACS,GAAG,CAACC,EAAE,IAAIA,EAAE,GAAG,GAAG,CAAC,CACzC;AAEM,MAAMC,uBAAuB,GAAAf,OAAA,CAAAe,uBAAA,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC;AAC/C,MAAMC,sBAAsB,GAAAhB,OAAA,CAAAgB,sBAAA,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;AAC9C,MAAMC,sBAAsB,GAAAjB,OAAA,CAAAiB,sBAAA,GAAG,CAAC,QAAQ,CAAC;AACzC,MAAMC,eAAe,GAAAlB,OAAA,CAAAkB,eAAA,GAAG,CAC7B,MAAM,EACN,OAAO,EACP,GAAGH,uBAAuB,EAC1B,GAAGC,sBAAsB,EACzB,GAAGC,sBAAsB,CAC1B;AAEM,MAAME,YAAY,GAAAnB,OAAA,CAAAmB,YAAA,GAAG;EAC1BC,QAAQ,EAAE,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,YAAY,CAAC;EAC5DC,KAAK,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK;AAC/B,CAAU;AAEqC;EAE7CrB,OAAO,CAACsB,mBAAmB,GAAGC,MAAM,CAACC,GAAG,CAAC,6BAA6B,CAAC;EAEvExB,OAAO,CAACyB,iBAAiB,GAAGF,MAAM,CAACC,GAAG,CACpC,0CACF,CAAC;AACH","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["_toBlock","require","ensureBlock","node","key","result","toBlock"],"sources":["../../src/converters/ensureBlock.ts"],"sourcesContent":["import toBlock from \"./toBlock.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Ensure the `key` (defaults to \"body\") of a `node` is a block.\n * Casting it to a block if it is not.\n *\n * Returns the BlockStatement\n */\nexport default function ensureBlock(\n node: t.Node,\n key: string = \"body\",\n): t.BlockStatement {\n // @ts-expect-error Fixme: key may not exist in node, consider remove key = \"body\"\n const result = toBlock(node[key], node);\n // @ts-expect-error Fixme: key may not exist in node, consider remove key = \"body\"\n node[key] = result;\n return result;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AASe,SAASC,WAAWA,CACjCC,IAAY,EACZC,GAAW,GAAG,MAAM,EACF;EAElB,MAAMC,MAAM,GAAG,IAAAC,gBAAO,EAACH,IAAI,CAACC,GAAG,CAAC,EAAED,IAAI,CAAC;EAEvCA,IAAI,CAACC,GAAG,CAAC,GAAGC,MAAM;EAClB,OAAOA,MAAM;AACf"} {"version":3,"names":["_toBlock","require","ensureBlock","node","key","result","toBlock"],"sources":["../../src/converters/ensureBlock.ts"],"sourcesContent":["import toBlock from \"./toBlock.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Ensure the `key` (defaults to \"body\") of a `node` is a block.\n * Casting it to a block if it is not.\n *\n * Returns the BlockStatement\n */\nexport default function ensureBlock(\n node: t.Node,\n key: string = \"body\",\n): t.BlockStatement {\n // @ts-expect-error Fixme: key may not exist in node, consider remove key = \"body\"\n const result = toBlock(node[key], node);\n // @ts-expect-error Fixme: key may not exist in node, consider remove key = \"body\"\n node[key] = result;\n return result;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AASe,SAASC,WAAWA,CACjCC,IAAY,EACZC,GAAW,GAAG,MAAM,EACF;EAElB,MAAMC,MAAM,GAAG,IAAAC,gBAAO,EAACH,IAAI,CAACC,GAAG,CAAC,EAAED,IAAI,CAAC;EAEvCA,IAAI,CAACC,GAAG,CAAC,GAAGC,MAAM;EAClB,OAAOA,MAAM;AACf","ignoreList":[]}

View File

@ -7,9 +7,10 @@ exports.default = gatherSequenceExpressions;
var _getBindingIdentifiers = require("../retrievers/getBindingIdentifiers.js"); var _getBindingIdentifiers = require("../retrievers/getBindingIdentifiers.js");
var _index = require("../validators/generated/index.js"); var _index = require("../validators/generated/index.js");
var _index2 = require("../builders/generated/index.js"); var _index2 = require("../builders/generated/index.js");
var _productions = require("../builders/productions.js");
var _cloneNode = require("../clone/cloneNode.js"); var _cloneNode = require("../clone/cloneNode.js");
; ;
function gatherSequenceExpressions(nodes, scope, declars) { function gatherSequenceExpressions(nodes, declars) {
const exprs = []; const exprs = [];
let ensureLastUndefined = true; let ensureLastUndefined = true;
for (const node of nodes) { for (const node of nodes) {
@ -36,12 +37,12 @@ function gatherSequenceExpressions(nodes, scope, declars) {
} }
ensureLastUndefined = true; ensureLastUndefined = true;
} else if ((0, _index.isIfStatement)(node)) { } else if ((0, _index.isIfStatement)(node)) {
const consequent = node.consequent ? gatherSequenceExpressions([node.consequent], scope, declars) : scope.buildUndefinedNode(); const consequent = node.consequent ? gatherSequenceExpressions([node.consequent], declars) : (0, _productions.buildUndefinedNode)();
const alternate = node.alternate ? gatherSequenceExpressions([node.alternate], scope, declars) : scope.buildUndefinedNode(); const alternate = node.alternate ? gatherSequenceExpressions([node.alternate], declars) : (0, _productions.buildUndefinedNode)();
if (!consequent || !alternate) return; if (!consequent || !alternate) return;
exprs.push((0, _index2.conditionalExpression)(node.test, consequent, alternate)); exprs.push((0, _index2.conditionalExpression)(node.test, consequent, alternate));
} else if ((0, _index.isBlockStatement)(node)) { } else if ((0, _index.isBlockStatement)(node)) {
const body = gatherSequenceExpressions(node.body, scope, declars); const body = gatherSequenceExpressions(node.body, declars);
if (!body) return; if (!body) return;
exprs.push(body); exprs.push(body);
} else if ((0, _index.isEmptyStatement)(node)) { } else if ((0, _index.isEmptyStatement)(node)) {
@ -53,7 +54,7 @@ function gatherSequenceExpressions(nodes, scope, declars) {
} }
} }
if (ensureLastUndefined) { if (ensureLastUndefined) {
exprs.push(scope.buildUndefinedNode()); exprs.push((0, _productions.buildUndefinedNode)());
} }
if (exprs.length === 1) { if (exprs.length === 1) {
return exprs[0]; return exprs[0];

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"version":3,"names":["_toIdentifier","require","toBindingIdentifierName","name","toIdentifier"],"sources":["../../src/converters/toBindingIdentifierName.ts"],"sourcesContent":["import toIdentifier from \"./toIdentifier.ts\";\n\nexport default function toBindingIdentifierName(name: string): string {\n name = toIdentifier(name);\n if (name === \"eval\" || name === \"arguments\") name = \"_\" + name;\n\n return name;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAEe,SAASC,uBAAuBA,CAACC,IAAY,EAAU;EACpEA,IAAI,GAAG,IAAAC,qBAAY,EAACD,IAAI,CAAC;EACzB,IAAIA,IAAI,KAAK,MAAM,IAAIA,IAAI,KAAK,WAAW,EAAEA,IAAI,GAAG,GAAG,GAAGA,IAAI;EAE9D,OAAOA,IAAI;AACb"} {"version":3,"names":["_toIdentifier","require","toBindingIdentifierName","name","toIdentifier"],"sources":["../../src/converters/toBindingIdentifierName.ts"],"sourcesContent":["import toIdentifier from \"./toIdentifier.ts\";\n\nexport default function toBindingIdentifierName(name: string): string {\n name = toIdentifier(name);\n if (name === \"eval\" || name === \"arguments\") name = \"_\" + name;\n\n return name;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAEe,SAASC,uBAAuBA,CAACC,IAAY,EAAU;EACpEA,IAAI,GAAG,IAAAC,qBAAY,EAACD,IAAI,CAAC;EACzB,IAAIA,IAAI,KAAK,MAAM,IAAIA,IAAI,KAAK,WAAW,EAAEA,IAAI,GAAG,GAAG,GAAGA,IAAI;EAE9D,OAAOA,IAAI;AACb","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["_index","require","_index2","toBlock","node","parent","isBlockStatement","blockNodes","isEmptyStatement","isStatement","isFunction","returnStatement","expressionStatement","blockStatement"],"sources":["../../src/converters/toBlock.ts"],"sourcesContent":["import {\n isBlockStatement,\n isFunction,\n isEmptyStatement,\n isStatement,\n} from \"../validators/generated/index.ts\";\nimport {\n returnStatement,\n expressionStatement,\n blockStatement,\n} from \"../builders/generated/index.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default function toBlock(\n node: t.Statement | t.Expression,\n parent?: t.Node,\n): t.BlockStatement {\n if (isBlockStatement(node)) {\n return node;\n }\n\n let blockNodes: t.Statement[] = [];\n\n if (isEmptyStatement(node)) {\n blockNodes = [];\n } else {\n if (!isStatement(node)) {\n if (isFunction(parent)) {\n node = returnStatement(node);\n } else {\n node = expressionStatement(node);\n }\n }\n\n blockNodes = [node];\n }\n\n return blockStatement(blockNodes);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAMA,IAAAC,OAAA,GAAAD,OAAA;AAOe,SAASE,OAAOA,CAC7BC,IAAgC,EAChCC,MAAe,EACG;EAClB,IAAI,IAAAC,uBAAgB,EAACF,IAAI,CAAC,EAAE;IAC1B,OAAOA,IAAI;EACb;EAEA,IAAIG,UAAyB,GAAG,EAAE;EAElC,IAAI,IAAAC,uBAAgB,EAACJ,IAAI,CAAC,EAAE;IAC1BG,UAAU,GAAG,EAAE;EACjB,CAAC,MAAM;IACL,IAAI,CAAC,IAAAE,kBAAW,EAACL,IAAI,CAAC,EAAE;MACtB,IAAI,IAAAM,iBAAU,EAACL,MAAM,CAAC,EAAE;QACtBD,IAAI,GAAG,IAAAO,uBAAe,EAACP,IAAI,CAAC;MAC9B,CAAC,MAAM;QACLA,IAAI,GAAG,IAAAQ,2BAAmB,EAACR,IAAI,CAAC;MAClC;IACF;IAEAG,UAAU,GAAG,CAACH,IAAI,CAAC;EACrB;EAEA,OAAO,IAAAS,sBAAc,EAACN,UAAU,CAAC;AACnC"} {"version":3,"names":["_index","require","_index2","toBlock","node","parent","isBlockStatement","blockNodes","isEmptyStatement","isStatement","isFunction","returnStatement","expressionStatement","blockStatement"],"sources":["../../src/converters/toBlock.ts"],"sourcesContent":["import {\n isBlockStatement,\n isFunction,\n isEmptyStatement,\n isStatement,\n} from \"../validators/generated/index.ts\";\nimport {\n returnStatement,\n expressionStatement,\n blockStatement,\n} from \"../builders/generated/index.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default function toBlock(\n node: t.Statement | t.Expression,\n parent?: t.Node,\n): t.BlockStatement {\n if (isBlockStatement(node)) {\n return node;\n }\n\n let blockNodes: t.Statement[] = [];\n\n if (isEmptyStatement(node)) {\n blockNodes = [];\n } else {\n if (!isStatement(node)) {\n if (isFunction(parent)) {\n node = returnStatement(node);\n } else {\n node = expressionStatement(node);\n }\n }\n\n blockNodes = [node];\n }\n\n return blockStatement(blockNodes);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAMA,IAAAC,OAAA,GAAAD,OAAA;AAOe,SAASE,OAAOA,CAC7BC,IAAgC,EAChCC,MAAe,EACG;EAClB,IAAI,IAAAC,uBAAgB,EAACF,IAAI,CAAC,EAAE;IAC1B,OAAOA,IAAI;EACb;EAEA,IAAIG,UAAyB,GAAG,EAAE;EAElC,IAAI,IAAAC,uBAAgB,EAACJ,IAAI,CAAC,EAAE;IAC1BG,UAAU,GAAG,EAAE;EACjB,CAAC,MAAM;IACL,IAAI,CAAC,IAAAE,kBAAW,EAACL,IAAI,CAAC,EAAE;MACtB,IAAI,IAAAM,iBAAU,EAACL,MAAM,CAAC,EAAE;QACtBD,IAAI,GAAG,IAAAO,uBAAe,EAACP,IAAI,CAAC;MAC9B,CAAC,MAAM;QACLA,IAAI,GAAG,IAAAQ,2BAAmB,EAACR,IAAI,CAAC;MAClC;IACF;IAEAG,UAAU,GAAG,CAACH,IAAI,CAAC;EACrB;EAEA,OAAO,IAAAS,sBAAc,EAACN,UAAU,CAAC;AACnC","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["_index","require","_index2","toComputedKey","node","key","property","computed","isIdentifier","stringLiteral","name"],"sources":["../../src/converters/toComputedKey.ts"],"sourcesContent":["import { isIdentifier } from \"../validators/generated/index.ts\";\nimport { stringLiteral } from \"../builders/generated/index.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default function toComputedKey(\n node:\n | t.ObjectMember\n | t.ObjectProperty\n | t.ClassMethod\n | t.ClassProperty\n | t.ClassAccessorProperty\n | t.MemberExpression\n | t.OptionalMemberExpression,\n // @ts-expect-error todo(flow->ts): maybe check the type of node before accessing .key and .property\n key: t.Expression | t.PrivateName = node.key || node.property,\n) {\n if (!node.computed && isIdentifier(key)) key = stringLiteral(key.name);\n\n return key;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAGe,SAASE,aAAaA,CACnCC,IAO8B,EAE9BC,GAAiC,GAAGD,IAAI,CAACC,GAAG,IAAID,IAAI,CAACE,QAAQ,EAC7D;EACA,IAAI,CAACF,IAAI,CAACG,QAAQ,IAAI,IAAAC,mBAAY,EAACH,GAAG,CAAC,EAAEA,GAAG,GAAG,IAAAI,qBAAa,EAACJ,GAAG,CAACK,IAAI,CAAC;EAEtE,OAAOL,GAAG;AACZ"} {"version":3,"names":["_index","require","_index2","toComputedKey","node","key","property","computed","isIdentifier","stringLiteral","name"],"sources":["../../src/converters/toComputedKey.ts"],"sourcesContent":["import { isIdentifier } from \"../validators/generated/index.ts\";\nimport { stringLiteral } from \"../builders/generated/index.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default function toComputedKey(\n node:\n | t.ObjectMember\n | t.ObjectProperty\n | t.ClassMethod\n | t.ClassProperty\n | t.ClassAccessorProperty\n | t.MemberExpression\n | t.OptionalMemberExpression,\n // @ts-expect-error todo(flow->ts): maybe check the type of node before accessing .key and .property\n key: t.Expression | t.PrivateName = node.key || node.property,\n) {\n if (!node.computed && isIdentifier(key)) key = stringLiteral(key.name);\n\n return key;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAGe,SAASE,aAAaA,CACnCC,IAO8B,EAE9BC,GAAiC,GAAGD,IAAI,CAACC,GAAG,IAAID,IAAI,CAACE,QAAQ,EAC7D;EACA,IAAI,CAACF,IAAI,CAACG,QAAQ,IAAI,IAAAC,mBAAY,EAACH,GAAG,CAAC,EAAEA,GAAG,GAAG,IAAAI,qBAAa,EAACJ,GAAG,CAACK,IAAI,CAAC;EAEtE,OAAOL,GAAG;AACZ","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["_index","require","_default","exports","default","toExpression","node","isExpressionStatement","expression","isExpression","isClass","type","isFunction","Error"],"sources":["../../src/converters/toExpression.ts"],"sourcesContent":["import {\n isExpression,\n isFunction,\n isClass,\n isExpressionStatement,\n} from \"../validators/generated/index.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default toExpression as {\n (node: t.Function): t.FunctionExpression;\n (node: t.Class): t.ClassExpression;\n (\n node: t.ExpressionStatement | t.Expression | t.Class | t.Function,\n ): t.Expression;\n};\n\nfunction toExpression(\n node: t.ExpressionStatement | t.Expression | t.Class | t.Function,\n): t.Expression {\n if (isExpressionStatement(node)) {\n node = node.expression;\n }\n\n // return unmodified node\n // important for things like ArrowFunctions where\n // type change from ArrowFunction to FunctionExpression\n // produces bugs like -> `()=>a` to `function () a`\n // without generating a BlockStatement for it\n // ref: https://github.com/babel/babili/issues/130\n if (isExpression(node)) {\n return node;\n }\n\n // convert all classes and functions\n // ClassDeclaration -> ClassExpression\n // FunctionDeclaration, ObjectMethod, ClassMethod -> FunctionExpression\n if (isClass(node)) {\n // @ts-expect-error todo(flow->ts): avoid type unsafe mutations\n node.type = \"ClassExpression\";\n } else if (isFunction(node)) {\n // @ts-expect-error todo(flow->ts): avoid type unsafe mutations\n node.type = \"FunctionExpression\";\n }\n\n // if it's still not an expression\n if (!isExpression(node)) {\n throw new Error(`cannot turn ${node.type} to an expression`);\n }\n\n return node;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAK0C,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAG3BC,YAAY;AAQ3B,SAASA,YAAYA,CACnBC,IAAiE,EACnD;EACd,IAAI,IAAAC,4BAAqB,EAACD,IAAI,CAAC,EAAE;IAC/BA,IAAI,GAAGA,IAAI,CAACE,UAAU;EACxB;EAQA,IAAI,IAAAC,mBAAY,EAACH,IAAI,CAAC,EAAE;IACtB,OAAOA,IAAI;EACb;EAKA,IAAI,IAAAI,cAAO,EAACJ,IAAI,CAAC,EAAE;IAEjBA,IAAI,CAACK,IAAI,GAAG,iBAAiB;EAC/B,CAAC,MAAM,IAAI,IAAAC,iBAAU,EAACN,IAAI,CAAC,EAAE;IAE3BA,IAAI,CAACK,IAAI,GAAG,oBAAoB;EAClC;EAGA,IAAI,CAAC,IAAAF,mBAAY,EAACH,IAAI,CAAC,EAAE;IACvB,MAAM,IAAIO,KAAK,CAAE,eAAcP,IAAI,CAACK,IAAK,mBAAkB,CAAC;EAC9D;EAEA,OAAOL,IAAI;AACb"} {"version":3,"names":["_index","require","_default","exports","default","toExpression","node","isExpressionStatement","expression","isExpression","isClass","type","isFunction","Error"],"sources":["../../src/converters/toExpression.ts"],"sourcesContent":["import {\n isExpression,\n isFunction,\n isClass,\n isExpressionStatement,\n} from \"../validators/generated/index.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default toExpression as {\n (node: t.Function): t.FunctionExpression;\n (node: t.Class): t.ClassExpression;\n (\n node: t.ExpressionStatement | t.Expression | t.Class | t.Function,\n ): t.Expression;\n};\n\nfunction toExpression(\n node: t.ExpressionStatement | t.Expression | t.Class | t.Function,\n): t.Expression {\n if (isExpressionStatement(node)) {\n node = node.expression;\n }\n\n // return unmodified node\n // important for things like ArrowFunctions where\n // type change from ArrowFunction to FunctionExpression\n // produces bugs like -> `()=>a` to `function () a`\n // without generating a BlockStatement for it\n // ref: https://github.com/babel/babili/issues/130\n if (isExpression(node)) {\n return node;\n }\n\n // convert all classes and functions\n // ClassDeclaration -> ClassExpression\n // FunctionDeclaration, ObjectMethod, ClassMethod -> FunctionExpression\n if (isClass(node)) {\n // @ts-expect-error todo(flow->ts): avoid type unsafe mutations\n node.type = \"ClassExpression\";\n } else if (isFunction(node)) {\n // @ts-expect-error todo(flow->ts): avoid type unsafe mutations\n node.type = \"FunctionExpression\";\n }\n\n // if it's still not an expression\n if (!isExpression(node)) {\n throw new Error(`cannot turn ${node.type} to an expression`);\n }\n\n return node;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAK0C,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAG3BC,YAAY;AAQ3B,SAASA,YAAYA,CACnBC,IAAiE,EACnD;EACd,IAAI,IAAAC,4BAAqB,EAACD,IAAI,CAAC,EAAE;IAC/BA,IAAI,GAAGA,IAAI,CAACE,UAAU;EACxB;EAQA,IAAI,IAAAC,mBAAY,EAACH,IAAI,CAAC,EAAE;IACtB,OAAOA,IAAI;EACb;EAKA,IAAI,IAAAI,cAAO,EAACJ,IAAI,CAAC,EAAE;IAEjBA,IAAI,CAACK,IAAI,GAAG,iBAAiB;EAC/B,CAAC,MAAM,IAAI,IAAAC,iBAAU,EAACN,IAAI,CAAC,EAAE;IAE3BA,IAAI,CAACK,IAAI,GAAG,oBAAoB;EAClC;EAGA,IAAI,CAAC,IAAAF,mBAAY,EAACH,IAAI,CAAC,EAAE;IACvB,MAAM,IAAIO,KAAK,CAAC,eAAeP,IAAI,CAACK,IAAI,mBAAmB,CAAC;EAC9D;EAEA,OAAOL,IAAI;AACb","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["_isValidIdentifier","require","_helperValidatorIdentifier","toIdentifier","input","name","c","isIdentifierChar","codePointAt","replace","match","toUpperCase","isValidIdentifier"],"sources":["../../src/converters/toIdentifier.ts"],"sourcesContent":["import isValidIdentifier from \"../validators/isValidIdentifier.ts\";\nimport { isIdentifierChar } from \"@babel/helper-validator-identifier\";\n\nexport default function toIdentifier(input: string): string {\n input = input + \"\";\n\n // replace all non-valid identifiers with dashes\n let name = \"\";\n for (const c of input) {\n name += isIdentifierChar(c.codePointAt(0)) ? c : \"-\";\n }\n\n // remove all dashes and numbers from start of name\n name = name.replace(/^[-0-9]+/, \"\");\n\n // camel case\n name = name.replace(/[-\\s]+(.)?/g, function (match, c) {\n return c ? c.toUpperCase() : \"\";\n });\n\n if (!isValidIdentifier(name)) {\n name = `_${name}`;\n }\n\n return name || \"_\";\n}\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,0BAAA,GAAAD,OAAA;AAEe,SAASE,YAAYA,CAACC,KAAa,EAAU;EAC1DA,KAAK,GAAGA,KAAK,GAAG,EAAE;EAGlB,IAAIC,IAAI,GAAG,EAAE;EACb,KAAK,MAAMC,CAAC,IAAIF,KAAK,EAAE;IACrBC,IAAI,IAAI,IAAAE,2CAAgB,EAACD,CAAC,CAACE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAGF,CAAC,GAAG,GAAG;EACtD;EAGAD,IAAI,GAAGA,IAAI,CAACI,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;EAGnCJ,IAAI,GAAGA,IAAI,CAACI,OAAO,CAAC,aAAa,EAAE,UAAUC,KAAK,EAAEJ,CAAC,EAAE;IACrD,OAAOA,CAAC,GAAGA,CAAC,CAACK,WAAW,CAAC,CAAC,GAAG,EAAE;EACjC,CAAC,CAAC;EAEF,IAAI,CAAC,IAAAC,0BAAiB,EAACP,IAAI,CAAC,EAAE;IAC5BA,IAAI,GAAI,IAAGA,IAAK,EAAC;EACnB;EAEA,OAAOA,IAAI,IAAI,GAAG;AACpB"} {"version":3,"names":["_isValidIdentifier","require","_helperValidatorIdentifier","toIdentifier","input","name","c","isIdentifierChar","codePointAt","replace","match","toUpperCase","isValidIdentifier"],"sources":["../../src/converters/toIdentifier.ts"],"sourcesContent":["import isValidIdentifier from \"../validators/isValidIdentifier.ts\";\nimport { isIdentifierChar } from \"@babel/helper-validator-identifier\";\n\nexport default function toIdentifier(input: string): string {\n input = input + \"\";\n\n // replace all non-valid identifiers with dashes\n let name = \"\";\n for (const c of input) {\n name += isIdentifierChar(c.codePointAt(0)) ? c : \"-\";\n }\n\n // remove all dashes and numbers from start of name\n name = name.replace(/^[-0-9]+/, \"\");\n\n // camel case\n name = name.replace(/[-\\s]+(.)?/g, function (match, c) {\n return c ? c.toUpperCase() : \"\";\n });\n\n if (!isValidIdentifier(name)) {\n name = `_${name}`;\n }\n\n return name || \"_\";\n}\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,0BAAA,GAAAD,OAAA;AAEe,SAASE,YAAYA,CAACC,KAAa,EAAU;EAC1DA,KAAK,GAAGA,KAAK,GAAG,EAAE;EAGlB,IAAIC,IAAI,GAAG,EAAE;EACb,KAAK,MAAMC,CAAC,IAAIF,KAAK,EAAE;IACrBC,IAAI,IAAI,IAAAE,2CAAgB,EAACD,CAAC,CAACE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAGF,CAAC,GAAG,GAAG;EACtD;EAGAD,IAAI,GAAGA,IAAI,CAACI,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;EAGnCJ,IAAI,GAAGA,IAAI,CAACI,OAAO,CAAC,aAAa,EAAE,UAAUC,KAAK,EAAEJ,CAAC,EAAE;IACrD,OAAOA,CAAC,GAAGA,CAAC,CAACK,WAAW,CAAC,CAAC,GAAG,EAAE;EACjC,CAAC,CAAC;EAEF,IAAI,CAAC,IAAAC,0BAAiB,EAACP,IAAI,CAAC,EAAE;IAC5BA,IAAI,GAAG,IAAIA,IAAI,EAAE;EACnB;EAEA,OAAOA,IAAI,IAAI,GAAG;AACpB","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["_index","require","_cloneNode","_removePropertiesDeep","toKeyAlias","node","key","alias","kind","increment","isIdentifier","name","isStringLiteral","JSON","stringify","value","removePropertiesDeep","cloneNode","computed","static","uid","Number","MAX_SAFE_INTEGER"],"sources":["../../src/converters/toKeyAlias.ts"],"sourcesContent":["import {\n isIdentifier,\n isStringLiteral,\n} from \"../validators/generated/index.ts\";\nimport cloneNode from \"../clone/cloneNode.ts\";\nimport removePropertiesDeep from \"../modifications/removePropertiesDeep.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default function toKeyAlias(\n node: t.Method | t.Property,\n key: t.Node = node.key,\n): string {\n let alias;\n\n // @ts-expect-error todo(flow->ts): maybe add node type check before checking `.kind`\n if (node.kind === \"method\") {\n return toKeyAlias.increment() + \"\";\n } else if (isIdentifier(key)) {\n alias = key.name;\n } else if (isStringLiteral(key)) {\n alias = JSON.stringify(key.value);\n } else {\n alias = JSON.stringify(removePropertiesDeep(cloneNode(key)));\n }\n\n // @ts-expect-error todo(flow->ts): maybe add node type check before checking `.computed`\n if (node.computed) {\n alias = `[${alias}]`;\n }\n\n // @ts-expect-error todo(flow->ts): maybe add node type check before checking `.static`\n if (node.static) {\n alias = `static:${alias}`;\n }\n\n return alias;\n}\n\ntoKeyAlias.uid = 0;\n\ntoKeyAlias.increment = function () {\n if (toKeyAlias.uid >= Number.MAX_SAFE_INTEGER) {\n return (toKeyAlias.uid = 0);\n } else {\n return toKeyAlias.uid++;\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAIA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,qBAAA,GAAAF,OAAA;AAGe,SAASG,UAAUA,CAChCC,IAA2B,EAC3BC,GAAW,GAAGD,IAAI,CAACC,GAAG,EACd;EACR,IAAIC,KAAK;EAGT,IAAIF,IAAI,CAACG,IAAI,KAAK,QAAQ,EAAE;IAC1B,OAAOJ,UAAU,CAACK,SAAS,CAAC,CAAC,GAAG,EAAE;EACpC,CAAC,MAAM,IAAI,IAAAC,mBAAY,EAACJ,GAAG,CAAC,EAAE;IAC5BC,KAAK,GAAGD,GAAG,CAACK,IAAI;EAClB,CAAC,MAAM,IAAI,IAAAC,sBAAe,EAACN,GAAG,CAAC,EAAE;IAC/BC,KAAK,GAAGM,IAAI,CAACC,SAAS,CAACR,GAAG,CAACS,KAAK,CAAC;EACnC,CAAC,MAAM;IACLR,KAAK,GAAGM,IAAI,CAACC,SAAS,CAAC,IAAAE,6BAAoB,EAAC,IAAAC,kBAAS,EAACX,GAAG,CAAC,CAAC,CAAC;EAC9D;EAGA,IAAID,IAAI,CAACa,QAAQ,EAAE;IACjBX,KAAK,GAAI,IAAGA,KAAM,GAAE;EACtB;EAGA,IAAIF,IAAI,CAACc,MAAM,EAAE;IACfZ,KAAK,GAAI,UAASA,KAAM,EAAC;EAC3B;EAEA,OAAOA,KAAK;AACd;AAEAH,UAAU,CAACgB,GAAG,GAAG,CAAC;AAElBhB,UAAU,CAACK,SAAS,GAAG,YAAY;EACjC,IAAIL,UAAU,CAACgB,GAAG,IAAIC,MAAM,CAACC,gBAAgB,EAAE;IAC7C,OAAQlB,UAAU,CAACgB,GAAG,GAAG,CAAC;EAC5B,CAAC,MAAM;IACL,OAAOhB,UAAU,CAACgB,GAAG,EAAE;EACzB;AACF,CAAC"} {"version":3,"names":["_index","require","_cloneNode","_removePropertiesDeep","toKeyAlias","node","key","alias","kind","increment","isIdentifier","name","isStringLiteral","JSON","stringify","value","removePropertiesDeep","cloneNode","computed","static","uid","Number","MAX_SAFE_INTEGER"],"sources":["../../src/converters/toKeyAlias.ts"],"sourcesContent":["import {\n isIdentifier,\n isStringLiteral,\n} from \"../validators/generated/index.ts\";\nimport cloneNode from \"../clone/cloneNode.ts\";\nimport removePropertiesDeep from \"../modifications/removePropertiesDeep.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default function toKeyAlias(\n node: t.Method | t.Property,\n key: t.Node = node.key,\n): string {\n let alias;\n\n // @ts-expect-error todo(flow->ts): maybe add node type check before checking `.kind`\n if (node.kind === \"method\") {\n return toKeyAlias.increment() + \"\";\n } else if (isIdentifier(key)) {\n alias = key.name;\n } else if (isStringLiteral(key)) {\n alias = JSON.stringify(key.value);\n } else {\n alias = JSON.stringify(removePropertiesDeep(cloneNode(key)));\n }\n\n // @ts-expect-error todo(flow->ts): maybe add node type check before checking `.computed`\n if (node.computed) {\n alias = `[${alias}]`;\n }\n\n // @ts-expect-error todo(flow->ts): maybe add node type check before checking `.static`\n if (node.static) {\n alias = `static:${alias}`;\n }\n\n return alias;\n}\n\ntoKeyAlias.uid = 0;\n\ntoKeyAlias.increment = function () {\n if (toKeyAlias.uid >= Number.MAX_SAFE_INTEGER) {\n return (toKeyAlias.uid = 0);\n } else {\n return toKeyAlias.uid++;\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAIA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,qBAAA,GAAAF,OAAA;AAGe,SAASG,UAAUA,CAChCC,IAA2B,EAC3BC,GAAW,GAAGD,IAAI,CAACC,GAAG,EACd;EACR,IAAIC,KAAK;EAGT,IAAIF,IAAI,CAACG,IAAI,KAAK,QAAQ,EAAE;IAC1B,OAAOJ,UAAU,CAACK,SAAS,CAAC,CAAC,GAAG,EAAE;EACpC,CAAC,MAAM,IAAI,IAAAC,mBAAY,EAACJ,GAAG,CAAC,EAAE;IAC5BC,KAAK,GAAGD,GAAG,CAACK,IAAI;EAClB,CAAC,MAAM,IAAI,IAAAC,sBAAe,EAACN,GAAG,CAAC,EAAE;IAC/BC,KAAK,GAAGM,IAAI,CAACC,SAAS,CAACR,GAAG,CAACS,KAAK,CAAC;EACnC,CAAC,MAAM;IACLR,KAAK,GAAGM,IAAI,CAACC,SAAS,CAAC,IAAAE,6BAAoB,EAAC,IAAAC,kBAAS,EAACX,GAAG,CAAC,CAAC,CAAC;EAC9D;EAGA,IAAID,IAAI,CAACa,QAAQ,EAAE;IACjBX,KAAK,GAAG,IAAIA,KAAK,GAAG;EACtB;EAGA,IAAIF,IAAI,CAACc,MAAM,EAAE;IACfZ,KAAK,GAAG,UAAUA,KAAK,EAAE;EAC3B;EAEA,OAAOA,KAAK;AACd;AAEAH,UAAU,CAACgB,GAAG,GAAG,CAAC;AAElBhB,UAAU,CAACK,SAAS,GAAG,YAAY;EACjC,IAAIL,UAAU,CAACgB,GAAG,IAAIC,MAAM,CAACC,gBAAgB,EAAE;IAC7C,OAAQlB,UAAU,CAACgB,GAAG,GAAG,CAAC;EAC5B,CAAC,MAAM;IACL,OAAOhB,UAAU,CAACgB,GAAG,EAAE;EACzB;AACF,CAAC","ignoreList":[]}

View File

@ -9,7 +9,7 @@ var _gatherSequenceExpressions = require("./gatherSequenceExpressions.js");
function toSequenceExpression(nodes, scope) { function toSequenceExpression(nodes, scope) {
if (!(nodes != null && nodes.length)) return; if (!(nodes != null && nodes.length)) return;
const declars = []; const declars = [];
const result = (0, _gatherSequenceExpressions.default)(nodes, scope, declars); const result = (0, _gatherSequenceExpressions.default)(nodes, declars);
if (!result) return; if (!result) return;
for (const declar of declars) { for (const declar of declars) {
scope.push(declar); scope.push(declar);

View File

@ -1 +1 @@
{"version":3,"names":["_gatherSequenceExpressions","require","toSequenceExpression","nodes","scope","length","declars","result","gatherSequenceExpressions","declar","push"],"sources":["../../src/converters/toSequenceExpression.ts"],"sourcesContent":["// TODO(Babel 8) Remove this file\nif (process.env.BABEL_8_BREAKING) {\n throw new Error(\n \"Internal Babel error: This file should only be loaded in Babel 7\",\n );\n}\n\nimport gatherSequenceExpressions from \"./gatherSequenceExpressions.ts\";\nimport type * as t from \"../index.ts\";\nimport type { DeclarationInfo } from \"./gatherSequenceExpressions.ts\";\n\n/**\n * Turn an array of statement `nodes` into a `SequenceExpression`.\n *\n * Variable declarations are turned into simple assignments and their\n * declarations hoisted to the top of the current scope.\n *\n * Expression statements are just resolved to their expression.\n */\nexport default function toSequenceExpression(\n nodes: ReadonlyArray<t.Node>,\n scope: any,\n): t.SequenceExpression | undefined {\n if (!nodes?.length) return;\n\n const declars: DeclarationInfo[] = [];\n const result = gatherSequenceExpressions(nodes, scope, declars);\n if (!result) return;\n\n for (const declar of declars) {\n scope.push(declar);\n }\n\n // @ts-expect-error fixme: gatherSequenceExpressions will return an Expression when there are only one element\n return result;\n}\n"],"mappings":";;;;;;AAOA,IAAAA,0BAAA,GAAAC,OAAA;AAAuE;AAYxD,SAASC,oBAAoBA,CAC1CC,KAA4B,EAC5BC,KAAU,EACwB;EAClC,IAAI,EAACD,KAAK,YAALA,KAAK,CAAEE,MAAM,GAAE;EAEpB,MAAMC,OAA0B,GAAG,EAAE;EACrC,MAAMC,MAAM,GAAG,IAAAC,kCAAyB,EAACL,KAAK,EAAEC,KAAK,EAAEE,OAAO,CAAC;EAC/D,IAAI,CAACC,MAAM,EAAE;EAEb,KAAK,MAAME,MAAM,IAAIH,OAAO,EAAE;IAC5BF,KAAK,CAACM,IAAI,CAACD,MAAM,CAAC;EACpB;EAGA,OAAOF,MAAM;AACf"} {"version":3,"names":["_gatherSequenceExpressions","require","toSequenceExpression","nodes","scope","length","declars","result","gatherSequenceExpressions","declar","push"],"sources":["../../src/converters/toSequenceExpression.ts"],"sourcesContent":["// TODO(Babel 8) Remove this file\nif (process.env.BABEL_8_BREAKING && process.env.IS_PUBLISH) {\n throw new Error(\n \"Internal Babel error: This file should only be loaded in Babel 7\",\n );\n}\n\nimport gatherSequenceExpressions from \"./gatherSequenceExpressions.ts\";\nimport type * as t from \"../index.ts\";\nimport type { DeclarationInfo } from \"./gatherSequenceExpressions.ts\";\n\n/**\n * Turn an array of statement `nodes` into a `SequenceExpression`.\n *\n * Variable declarations are turned into simple assignments and their\n * declarations hoisted to the top of the current scope.\n *\n * Expression statements are just resolved to their expression.\n */\nexport default function toSequenceExpression(\n nodes: ReadonlyArray<t.Node>,\n scope: any,\n): t.SequenceExpression | undefined {\n if (!nodes?.length) return;\n\n const declars: DeclarationInfo[] = [];\n const result = gatherSequenceExpressions(nodes, declars);\n if (!result) return;\n\n for (const declar of declars) {\n scope.push(declar);\n }\n\n // @ts-expect-error fixme: gatherSequenceExpressions will return an Expression when there are only one element\n return result;\n}\n"],"mappings":";;;;;;AAOA,IAAAA,0BAAA,GAAAC,OAAA;AAAuE;AAYxD,SAASC,oBAAoBA,CAC1CC,KAA4B,EAC5BC,KAAU,EACwB;EAClC,IAAI,EAACD,KAAK,YAALA,KAAK,CAAEE,MAAM,GAAE;EAEpB,MAAMC,OAA0B,GAAG,EAAE;EACrC,MAAMC,MAAM,GAAG,IAAAC,kCAAyB,EAACL,KAAK,EAAEG,OAAO,CAAC;EACxD,IAAI,CAACC,MAAM,EAAE;EAEb,KAAK,MAAME,MAAM,IAAIH,OAAO,EAAE;IAC5BF,KAAK,CAACM,IAAI,CAACD,MAAM,CAAC;EACpB;EAGA,OAAOF,MAAM;AACf","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["_index","require","_index2","_default","exports","default","toStatement","node","ignore","isStatement","mustHaveId","newType","isClass","isFunction","isAssignmentExpression","expressionStatement","id","Error","type"],"sources":["../../src/converters/toStatement.ts"],"sourcesContent":["import {\n isStatement,\n isFunction,\n isClass,\n isAssignmentExpression,\n} from \"../validators/generated/index.ts\";\nimport { expressionStatement } from \"../builders/generated/index.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default toStatement as {\n (node: t.AssignmentExpression, ignore?: boolean): t.ExpressionStatement;\n\n <T extends t.Statement>(node: T, ignore: false): T;\n <T extends t.Statement>(node: T, ignore?: boolean): T | false;\n\n (node: t.Class, ignore: false): t.ClassDeclaration;\n (node: t.Class, ignore?: boolean): t.ClassDeclaration | false;\n\n (node: t.Function, ignore: false): t.FunctionDeclaration;\n (node: t.Function, ignore?: boolean): t.FunctionDeclaration | false;\n\n (node: t.Node, ignore: false): t.Statement;\n (node: t.Node, ignore?: boolean): t.Statement | false;\n};\n\nfunction toStatement(node: t.Node, ignore?: boolean): t.Statement | false {\n if (isStatement(node)) {\n return node;\n }\n\n let mustHaveId = false;\n let newType;\n\n if (isClass(node)) {\n mustHaveId = true;\n newType = \"ClassDeclaration\" as const;\n } else if (isFunction(node)) {\n mustHaveId = true;\n newType = \"FunctionDeclaration\" as const;\n } else if (isAssignmentExpression(node)) {\n return expressionStatement(node);\n }\n\n // @ts-expect-error todo(flow->ts): node.id might be missing\n if (mustHaveId && !node.id) {\n newType = false;\n }\n\n if (!newType) {\n if (ignore) {\n return false;\n } else {\n throw new Error(`cannot turn ${node.type} to a statement`);\n }\n }\n\n // @ts-expect-error manipulating node.type\n node.type = newType;\n\n // @ts-expect-error todo(flow->ts) refactor to avoid type unsafe mutations like reassigning node type above\n return node;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAMA,IAAAC,OAAA,GAAAD,OAAA;AAAqE,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGtDC,WAAW;AAgB1B,SAASA,WAAWA,CAACC,IAAY,EAAEC,MAAgB,EAAuB;EACxE,IAAI,IAAAC,kBAAW,EAACF,IAAI,CAAC,EAAE;IACrB,OAAOA,IAAI;EACb;EAEA,IAAIG,UAAU,GAAG,KAAK;EACtB,IAAIC,OAAO;EAEX,IAAI,IAAAC,cAAO,EAACL,IAAI,CAAC,EAAE;IACjBG,UAAU,GAAG,IAAI;IACjBC,OAAO,GAAG,kBAA2B;EACvC,CAAC,MAAM,IAAI,IAAAE,iBAAU,EAACN,IAAI,CAAC,EAAE;IAC3BG,UAAU,GAAG,IAAI;IACjBC,OAAO,GAAG,qBAA8B;EAC1C,CAAC,MAAM,IAAI,IAAAG,6BAAsB,EAACP,IAAI,CAAC,EAAE;IACvC,OAAO,IAAAQ,2BAAmB,EAACR,IAAI,CAAC;EAClC;EAGA,IAAIG,UAAU,IAAI,CAACH,IAAI,CAACS,EAAE,EAAE;IAC1BL,OAAO,GAAG,KAAK;EACjB;EAEA,IAAI,CAACA,OAAO,EAAE;IACZ,IAAIH,MAAM,EAAE;MACV,OAAO,KAAK;IACd,CAAC,MAAM;MACL,MAAM,IAAIS,KAAK,CAAE,eAAcV,IAAI,CAACW,IAAK,iBAAgB,CAAC;IAC5D;EACF;EAGAX,IAAI,CAACW,IAAI,GAAGP,OAAO;EAGnB,OAAOJ,IAAI;AACb"} {"version":3,"names":["_index","require","_index2","_default","exports","default","toStatement","node","ignore","isStatement","mustHaveId","newType","isClass","isFunction","isAssignmentExpression","expressionStatement","id","Error","type"],"sources":["../../src/converters/toStatement.ts"],"sourcesContent":["import {\n isStatement,\n isFunction,\n isClass,\n isAssignmentExpression,\n} from \"../validators/generated/index.ts\";\nimport { expressionStatement } from \"../builders/generated/index.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default toStatement as {\n (node: t.AssignmentExpression, ignore?: boolean): t.ExpressionStatement;\n\n <T extends t.Statement>(node: T, ignore: false): T;\n <T extends t.Statement>(node: T, ignore?: boolean): T | false;\n\n (node: t.Class, ignore: false): t.ClassDeclaration;\n (node: t.Class, ignore?: boolean): t.ClassDeclaration | false;\n\n (node: t.Function, ignore: false): t.FunctionDeclaration;\n (node: t.Function, ignore?: boolean): t.FunctionDeclaration | false;\n\n (node: t.Node, ignore: false): t.Statement;\n (node: t.Node, ignore?: boolean): t.Statement | false;\n};\n\nfunction toStatement(node: t.Node, ignore?: boolean): t.Statement | false {\n if (isStatement(node)) {\n return node;\n }\n\n let mustHaveId = false;\n let newType;\n\n if (isClass(node)) {\n mustHaveId = true;\n newType = \"ClassDeclaration\" as const;\n } else if (isFunction(node)) {\n mustHaveId = true;\n newType = \"FunctionDeclaration\" as const;\n } else if (isAssignmentExpression(node)) {\n return expressionStatement(node);\n }\n\n // @ts-expect-error todo(flow->ts): node.id might be missing\n if (mustHaveId && !node.id) {\n newType = false;\n }\n\n if (!newType) {\n if (ignore) {\n return false;\n } else {\n throw new Error(`cannot turn ${node.type} to a statement`);\n }\n }\n\n // @ts-expect-error manipulating node.type\n node.type = newType;\n\n // @ts-expect-error todo(flow->ts) refactor to avoid type unsafe mutations like reassigning node type above\n return node;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAMA,IAAAC,OAAA,GAAAD,OAAA;AAAqE,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGtDC,WAAW;AAgB1B,SAASA,WAAWA,CAACC,IAAY,EAAEC,MAAgB,EAAuB;EACxE,IAAI,IAAAC,kBAAW,EAACF,IAAI,CAAC,EAAE;IACrB,OAAOA,IAAI;EACb;EAEA,IAAIG,UAAU,GAAG,KAAK;EACtB,IAAIC,OAAO;EAEX,IAAI,IAAAC,cAAO,EAACL,IAAI,CAAC,EAAE;IACjBG,UAAU,GAAG,IAAI;IACjBC,OAAO,GAAG,kBAA2B;EACvC,CAAC,MAAM,IAAI,IAAAE,iBAAU,EAACN,IAAI,CAAC,EAAE;IAC3BG,UAAU,GAAG,IAAI;IACjBC,OAAO,GAAG,qBAA8B;EAC1C,CAAC,MAAM,IAAI,IAAAG,6BAAsB,EAACP,IAAI,CAAC,EAAE;IACvC,OAAO,IAAAQ,2BAAmB,EAACR,IAAI,CAAC;EAClC;EAGA,IAAIG,UAAU,IAAI,CAACH,IAAI,CAACS,EAAE,EAAE;IAC1BL,OAAO,GAAG,KAAK;EACjB;EAEA,IAAI,CAACA,OAAO,EAAE;IACZ,IAAIH,MAAM,EAAE;MACV,OAAO,KAAK;IACd,CAAC,MAAM;MACL,MAAM,IAAIS,KAAK,CAAC,eAAeV,IAAI,CAACW,IAAI,iBAAiB,CAAC;IAC5D;EACF;EAGAX,IAAI,CAACW,IAAI,GAAGP,OAAO;EAGnB,OAAOJ,IAAI;AACb","ignoreList":[]}

View File

@ -49,9 +49,12 @@ function valueToNode(value) {
} }
return result; return result;
} }
if (typeof value === "bigint") {
return (0, _index.bigIntLiteral)(value.toString());
}
if (isRegExp(value)) { if (isRegExp(value)) {
const pattern = value.source; const pattern = value.source;
const flags = value.toString().match(/\/([a-z]+|)$/)[1]; const flags = /\/([a-z]*)$/.exec(value.toString())[1];
return (0, _index.regExpLiteral)(pattern, flags); return (0, _index.regExpLiteral)(pattern, flags);
} }
if (Array.isArray(value)) { if (Array.isArray(value)) {
@ -60,13 +63,19 @@ function valueToNode(value) {
if (isPlainObject(value)) { if (isPlainObject(value)) {
const props = []; const props = [];
for (const key of Object.keys(value)) { for (const key of Object.keys(value)) {
let nodeKey; let nodeKey,
computed = false;
if ((0, _isValidIdentifier.default)(key)) { if ((0, _isValidIdentifier.default)(key)) {
if (key === "__proto__") {
computed = true;
nodeKey = (0, _index.stringLiteral)(key);
} else {
nodeKey = (0, _index.identifier)(key); nodeKey = (0, _index.identifier)(key);
}
} else { } else {
nodeKey = (0, _index.stringLiteral)(key); nodeKey = (0, _index.stringLiteral)(key);
} }
props.push((0, _index.objectProperty)(nodeKey, valueToNode(value[key]))); props.push((0, _index.objectProperty)(nodeKey, valueToNode(value[key]), computed));
} }
return (0, _index.objectExpression)(props); return (0, _index.objectExpression)(props);
} }

File diff suppressed because one or more lines are too long

View File

@ -3,7 +3,7 @@
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.patternLikeCommon = exports.functionTypeAnnotationCommon = exports.functionDeclarationCommon = exports.functionCommon = exports.classMethodOrPropertyCommon = exports.classMethodOrDeclareMethodCommon = void 0; exports.patternLikeCommon = exports.importAttributes = exports.functionTypeAnnotationCommon = exports.functionDeclarationCommon = exports.functionCommon = exports.classMethodOrPropertyCommon = exports.classMethodOrDeclareMethodCommon = void 0;
var _is = require("../validators/is.js"); var _is = require("../validators/is.js");
var _isValidIdentifier = require("../validators/isValidIdentifier.js"); var _isValidIdentifier = require("../validators/isValidIdentifier.js");
var _helperValidatorIdentifier = require("@babel/helper-validator-identifier"); var _helperValidatorIdentifier = require("@babel/helper-validator-identifier");
@ -14,7 +14,7 @@ const defineType = (0, _utils.defineAliasedType)("Standardized");
defineType("ArrayExpression", { defineType("ArrayExpression", {
fields: { fields: {
elements: { elements: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeOrValueType)("null", "Expression", "SpreadElement"))), validate: (0, _utils.arrayOf)((0, _utils.assertNodeOrValueType)("null", "Expression", "SpreadElement")),
default: !process.env.BABEL_TYPES_8_BREAKING ? [] : undefined default: !process.env.BABEL_TYPES_8_BREAKING ? [] : undefined
} }
}, },
@ -24,17 +24,16 @@ defineType("ArrayExpression", {
defineType("AssignmentExpression", { defineType("AssignmentExpression", {
fields: { fields: {
operator: { operator: {
validate: function () { validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertValueType)("string") : Object.assign(function () {
if (!process.env.BABEL_TYPES_8_BREAKING) {
return (0, _utils.assertValueType)("string");
}
const identifier = (0, _utils.assertOneOf)(..._index.ASSIGNMENT_OPERATORS); const identifier = (0, _utils.assertOneOf)(..._index.ASSIGNMENT_OPERATORS);
const pattern = (0, _utils.assertOneOf)("="); const pattern = (0, _utils.assertOneOf)("=");
return function (node, key, val) { return function (node, key, val) {
const validator = (0, _is.default)("Pattern", node.left) ? pattern : identifier; const validator = (0, _is.default)("Pattern", node.left) ? pattern : identifier;
validator(node, key, val); validator(node, key, val);
}; };
}() }(), {
type: "string"
})
}, },
left: { left: {
validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("LVal", "OptionalMemberExpression") : (0, _utils.assertNodeType)("Identifier", "MemberExpression", "OptionalMemberExpression", "ArrayPattern", "ObjectPattern", "TSAsExpression", "TSSatisfiesExpression", "TSTypeAssertion", "TSNonNullExpression") validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("LVal", "OptionalMemberExpression") : (0, _utils.assertNodeType)("Identifier", "MemberExpression", "OptionalMemberExpression", "ArrayPattern", "ObjectPattern", "TSAsExpression", "TSSatisfiesExpression", "TSTypeAssertion", "TSNonNullExpression")
@ -102,12 +101,10 @@ defineType("BlockStatement", {
visitor: ["directives", "body"], visitor: ["directives", "body"],
fields: { fields: {
directives: { directives: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Directive"))), validate: (0, _utils.arrayOfType)("Directive"),
default: [] default: []
}, },
body: { body: (0, _utils.validateArrayOfType)("Statement")
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Statement")))
}
}, },
aliases: ["Scopable", "BlockParent", "Block", "Statement"] aliases: ["Scopable", "BlockParent", "Block", "Statement"]
}); });
@ -129,23 +126,25 @@ defineType("CallExpression", {
callee: { callee: {
validate: (0, _utils.assertNodeType)("Expression", "Super", "V8IntrinsicIdentifier") validate: (0, _utils.assertNodeType)("Expression", "Super", "V8IntrinsicIdentifier")
}, },
arguments: { arguments: (0, _utils.validateArrayOfType)("Expression", "SpreadElement", "ArgumentPlaceholder"),
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "SpreadElement", "JSXNamespacedName", "ArgumentPlaceholder")))
}
}, !process.env.BABEL_TYPES_8_BREAKING ? {
optional: {
validate: (0, _utils.assertOneOf)(true, false),
optional: true
}
} : {}, {
typeArguments: { typeArguments: {
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation"), validate: (0, _utils.assertNodeType)("TypeParameterInstantiation"),
optional: true optional: true
}
}, {
optional: {
validate: (0, _utils.assertValueType)("boolean"),
optional: true
}, },
typeParameters: { typeParameters: {
validate: (0, _utils.assertNodeType)("TSTypeParameterInstantiation"), validate: (0, _utils.assertNodeType)("TSTypeParameterInstantiation"),
optional: true optional: true
} }
}, process.env.BABEL_TYPES_8_BREAKING ? {} : {
optional: {
validate: (0, _utils.assertValueType)("boolean"),
optional: true
}
}) })
}); });
defineType("CatchClause", { defineType("CatchClause", {
@ -190,7 +189,8 @@ defineType("DebuggerStatement", {
aliases: ["Statement"] aliases: ["Statement"]
}); });
defineType("DoWhileStatement", { defineType("DoWhileStatement", {
visitor: ["test", "body"], builder: ["test", "body"],
visitor: ["body", "test"],
fields: { fields: {
test: { test: {
validate: (0, _utils.assertNodeType)("Expression") validate: (0, _utils.assertNodeType)("Expression")
@ -273,9 +273,7 @@ defineType("ForStatement", {
} }
}); });
const functionCommon = () => ({ const functionCommon = () => ({
params: { params: (0, _utils.validateArrayOfType)("Identifier", "Pattern", "RestElement"),
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Identifier", "Pattern", "RestElement")))
},
generator: { generator: {
default: false default: false
}, },
@ -308,7 +306,7 @@ const functionDeclarationCommon = () => Object.assign({}, functionCommon(), {
exports.functionDeclarationCommon = functionDeclarationCommon; exports.functionDeclarationCommon = functionDeclarationCommon;
defineType("FunctionDeclaration", { defineType("FunctionDeclaration", {
builder: ["id", "params", "body", "generator", "async"], builder: ["id", "params", "body", "generator", "async"],
visitor: ["id", "params", "body", "returnType", "typeParameters"], visitor: ["id", "typeParameters", "params", "predicate", "returnType", "body"],
fields: Object.assign({}, functionDeclarationCommon(), functionTypeAnnotationCommon(), { fields: Object.assign({}, functionDeclarationCommon(), functionTypeAnnotationCommon(), {
body: { body: {
validate: (0, _utils.assertNodeType)("BlockStatement") validate: (0, _utils.assertNodeType)("BlockStatement")
@ -319,8 +317,7 @@ defineType("FunctionDeclaration", {
} }
}), }),
aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Statement", "Pureish", "Declaration"], aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Statement", "Pureish", "Declaration"],
validate: function () { validate: !process.env.BABEL_TYPES_8_BREAKING ? undefined : function () {
if (!process.env.BABEL_TYPES_8_BREAKING) return () => {};
const identifier = (0, _utils.assertNodeType)("Identifier"); const identifier = (0, _utils.assertNodeType)("Identifier");
return function (parent, key, node) { return function (parent, key, node) {
if (!(0, _is.default)("ExportDefaultDeclaration", parent)) { if (!(0, _is.default)("ExportDefaultDeclaration", parent)) {
@ -356,7 +353,7 @@ const patternLikeCommon = () => ({
optional: true optional: true
}, },
decorators: { decorators: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), validate: (0, _utils.arrayOfType)("Decorator"),
optional: true optional: true
} }
}); });
@ -367,19 +364,17 @@ defineType("Identifier", {
aliases: ["Expression", "PatternLike", "LVal", "TSEntityName"], aliases: ["Expression", "PatternLike", "LVal", "TSEntityName"],
fields: Object.assign({}, patternLikeCommon(), { fields: Object.assign({}, patternLikeCommon(), {
name: { name: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), Object.assign(function (node, key, val) { validate: process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.chain)((0, _utils.assertValueType)("string"), Object.assign(function (node, key, val) {
if (!process.env.BABEL_TYPES_8_BREAKING) return;
if (!(0, _isValidIdentifier.default)(val, false)) { if (!(0, _isValidIdentifier.default)(val, false)) {
throw new TypeError(`"${val}" is not a valid identifier name`); throw new TypeError(`"${val}" is not a valid identifier name`);
} }
}, { }, {
type: "string" type: "string"
})) })) : (0, _utils.assertValueType)("string")
} }
}), }),
validate(parent, key, node) { validate: process.env.BABEL_TYPES_8_BREAKING ? function (parent, key, node) {
if (!process.env.BABEL_TYPES_8_BREAKING) return; const match = /\.(\w+)$/.exec(key.toString());
const match = /\.(\w+)$/.exec(key);
if (!match) return; if (!match) return;
const [, parentKey] = match; const [, parentKey] = match;
const nonComp = { const nonComp = {
@ -405,7 +400,7 @@ defineType("Identifier", {
if (((0, _helperValidatorIdentifier.isKeyword)(node.name) || (0, _helperValidatorIdentifier.isReservedWord)(node.name, false)) && node.name !== "this") { if (((0, _helperValidatorIdentifier.isKeyword)(node.name) || (0, _helperValidatorIdentifier.isReservedWord)(node.name, false)) && node.name !== "this") {
throw new TypeError(`"${node.name}" is not a valid identifier`); throw new TypeError(`"${node.name}" is not a valid identifier`);
} }
} } : undefined
}); });
defineType("IfStatement", { defineType("IfStatement", {
visitor: ["test", "consequent", "alternate"], visitor: ["test", "consequent", "alternate"],
@ -482,15 +477,14 @@ defineType("RegExpLiteral", {
validate: (0, _utils.assertValueType)("string") validate: (0, _utils.assertValueType)("string")
}, },
flags: { flags: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("string"), Object.assign(function (node, key, val) { validate: process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.chain)((0, _utils.assertValueType)("string"), Object.assign(function (node, key, val) {
if (!process.env.BABEL_TYPES_8_BREAKING) return;
const invalid = /[^gimsuy]/.exec(val); const invalid = /[^gimsuy]/.exec(val);
if (invalid) { if (invalid) {
throw new TypeError(`"${invalid[0]}" is not a valid RegExp flag`); throw new TypeError(`"${invalid[0]}" is not a valid RegExp flag`);
} }
}, { }, {
type: "string" type: "string"
})), })) : (0, _utils.assertValueType)("string"),
default: "" default: ""
} }
} }
@ -536,7 +530,7 @@ defineType("MemberExpression", {
} }
}, !process.env.BABEL_TYPES_8_BREAKING ? { }, !process.env.BABEL_TYPES_8_BREAKING ? {
optional: { optional: {
validate: (0, _utils.assertOneOf)(true, false), validate: (0, _utils.assertValueType)("boolean"),
optional: true optional: true
} }
} : {}) } : {})
@ -558,12 +552,10 @@ defineType("Program", {
optional: true optional: true
}, },
directives: { directives: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Directive"))), validate: (0, _utils.arrayOfType)("Directive"),
default: [] default: []
}, },
body: { body: (0, _utils.validateArrayOfType)("Statement")
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Statement")))
}
}, },
aliases: ["Scopable", "BlockParent", "Block"] aliases: ["Scopable", "BlockParent", "Block"]
}); });
@ -571,13 +563,12 @@ defineType("ObjectExpression", {
visitor: ["properties"], visitor: ["properties"],
aliases: ["Expression"], aliases: ["Expression"],
fields: { fields: {
properties: { properties: (0, _utils.validateArrayOfType)("ObjectMethod", "ObjectProperty", "SpreadElement")
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ObjectMethod", "ObjectProperty", "SpreadElement")))
}
} }
}); });
defineType("ObjectMethod", { defineType("ObjectMethod", {
builder: ["kind", "key", "params", "body", "computed", "generator", "async"], builder: ["kind", "key", "params", "body", "computed", "generator", "async"],
visitor: ["decorators", "key", "typeParameters", "params", "returnType", "body"],
fields: Object.assign({}, functionCommon(), functionTypeAnnotationCommon(), { fields: Object.assign({}, functionCommon(), functionTypeAnnotationCommon(), {
kind: Object.assign({ kind: Object.assign({
validate: (0, _utils.assertOneOf)("method", "get", "set") validate: (0, _utils.assertOneOf)("method", "get", "set")
@ -600,14 +591,13 @@ defineType("ObjectMethod", {
}() }()
}, },
decorators: { decorators: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), validate: (0, _utils.arrayOfType)("Decorator"),
optional: true optional: true
}, },
body: { body: {
validate: (0, _utils.assertNodeType)("BlockStatement") validate: (0, _utils.assertNodeType)("BlockStatement")
} }
}), }),
visitor: ["key", "params", "body", "decorators", "returnType", "typeParameters"],
aliases: ["UserWhitespacable", "Function", "Scopable", "BlockParent", "FunctionParent", "Method", "ObjectMember"] aliases: ["UserWhitespacable", "Function", "Scopable", "BlockParent", "FunctionParent", "Method", "ObjectMember"]
}); });
defineType("ObjectProperty", { defineType("ObjectProperty", {
@ -633,33 +623,30 @@ defineType("ObjectProperty", {
validate: (0, _utils.assertNodeType)("Expression", "PatternLike") validate: (0, _utils.assertNodeType)("Expression", "PatternLike")
}, },
shorthand: { shorthand: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("boolean"), Object.assign(function (node, key, val) { validate: process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.chain)((0, _utils.assertValueType)("boolean"), Object.assign(function (node, key, shorthand) {
if (!process.env.BABEL_TYPES_8_BREAKING) return; if (!shorthand) return;
if (val && node.computed) { if (node.computed) {
throw new TypeError("Property shorthand of ObjectProperty cannot be true if computed is true"); throw new TypeError("Property shorthand of ObjectProperty cannot be true if computed is true");
} }
if (!(0, _is.default)("Identifier", node.key)) {
throw new TypeError("Property shorthand of ObjectProperty cannot be true if key is not an Identifier");
}
}, { }, {
type: "boolean" type: "boolean"
}), function (node, key, val) { })) : (0, _utils.assertValueType)("boolean"),
if (!process.env.BABEL_TYPES_8_BREAKING) return;
if (val && !(0, _is.default)("Identifier", node.key)) {
throw new TypeError("Property shorthand of ObjectProperty cannot be true if key is not an Identifier");
}
}),
default: false default: false
}, },
decorators: { decorators: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), validate: (0, _utils.arrayOfType)("Decorator"),
optional: true optional: true
} }
}, },
visitor: ["key", "value", "decorators"], visitor: ["key", "value", "decorators"],
aliases: ["UserWhitespacable", "Property", "ObjectMember"], aliases: ["UserWhitespacable", "Property", "ObjectMember"],
validate: function () { validate: !process.env.BABEL_TYPES_8_BREAKING ? undefined : function () {
const pattern = (0, _utils.assertNodeType)("Identifier", "Pattern", "TSAsExpression", "TSSatisfiesExpression", "TSNonNullExpression", "TSTypeAssertion"); const pattern = (0, _utils.assertNodeType)("Identifier", "Pattern", "TSAsExpression", "TSSatisfiesExpression", "TSNonNullExpression", "TSTypeAssertion");
const expression = (0, _utils.assertNodeType)("Expression"); const expression = (0, _utils.assertNodeType)("Expression");
return function (parent, key, node) { return function (parent, key, node) {
if (!process.env.BABEL_TYPES_8_BREAKING) return;
const validator = (0, _is.default)("ObjectPattern", parent) ? pattern : expression; const validator = (0, _is.default)("ObjectPattern", parent) ? pattern : expression;
validator(node, "value", node.value); validator(node, "value", node.value);
}; };
@ -675,15 +662,14 @@ defineType("RestElement", {
validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("LVal") : (0, _utils.assertNodeType)("Identifier", "ArrayPattern", "ObjectPattern", "MemberExpression", "TSAsExpression", "TSSatisfiesExpression", "TSTypeAssertion", "TSNonNullExpression") validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("LVal") : (0, _utils.assertNodeType)("Identifier", "ArrayPattern", "ObjectPattern", "MemberExpression", "TSAsExpression", "TSSatisfiesExpression", "TSTypeAssertion", "TSNonNullExpression")
} }
}), }),
validate(parent, key) { validate: process.env.BABEL_TYPES_8_BREAKING ? function (parent, key) {
if (!process.env.BABEL_TYPES_8_BREAKING) return; const match = /(\w+)\[(\d+)\]/.exec(key.toString());
const match = /(\w+)\[(\d+)\]/.exec(key);
if (!match) throw new Error("Internal Babel error: malformed key."); if (!match) throw new Error("Internal Babel error: malformed key.");
const [, listKey, index] = match; const [, listKey, index] = match;
if (parent[listKey].length > +index + 1) { if (parent[listKey].length > +index + 1) {
throw new TypeError(`RestElement must be last element of ${listKey}`); throw new TypeError(`RestElement must be last element of ${listKey}`);
} }
} } : undefined
}); });
defineType("ReturnStatement", { defineType("ReturnStatement", {
visitor: ["argument"], visitor: ["argument"],
@ -698,9 +684,7 @@ defineType("ReturnStatement", {
defineType("SequenceExpression", { defineType("SequenceExpression", {
visitor: ["expressions"], visitor: ["expressions"],
fields: { fields: {
expressions: { expressions: (0, _utils.validateArrayOfType)("Expression")
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression")))
}
}, },
aliases: ["Expression"] aliases: ["Expression"]
}); });
@ -720,9 +704,7 @@ defineType("SwitchCase", {
validate: (0, _utils.assertNodeType)("Expression"), validate: (0, _utils.assertNodeType)("Expression"),
optional: true optional: true
}, },
consequent: { consequent: (0, _utils.validateArrayOfType)("Statement")
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Statement")))
}
} }
}); });
defineType("SwitchStatement", { defineType("SwitchStatement", {
@ -732,9 +714,7 @@ defineType("SwitchStatement", {
discriminant: { discriminant: {
validate: (0, _utils.assertNodeType)("Expression") validate: (0, _utils.assertNodeType)("Expression")
}, },
cases: { cases: (0, _utils.validateArrayOfType)("SwitchCase")
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("SwitchCase")))
}
} }
}); });
defineType("ThisExpression", { defineType("ThisExpression", {
@ -754,14 +734,13 @@ defineType("TryStatement", {
aliases: ["Statement"], aliases: ["Statement"],
fields: { fields: {
block: { block: {
validate: (0, _utils.chain)((0, _utils.assertNodeType)("BlockStatement"), Object.assign(function (node) { validate: process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.chain)((0, _utils.assertNodeType)("BlockStatement"), Object.assign(function (node) {
if (!process.env.BABEL_TYPES_8_BREAKING) return;
if (!node.handler && !node.finalizer) { if (!node.handler && !node.finalizer) {
throw new TypeError("TryStatement expects either a handler or finalizer, or both"); throw new TypeError("TryStatement expects either a handler or finalizer, or both");
} }
}, { }, {
oneOfNodeTypes: ["BlockStatement"] oneOfNodeTypes: ["BlockStatement"]
})) })) : (0, _utils.assertNodeType)("BlockStatement")
}, },
handler: { handler: {
optional: true, optional: true,
@ -817,35 +796,44 @@ defineType("VariableDeclaration", {
kind: { kind: {
validate: (0, _utils.assertOneOf)("var", "let", "const", "using", "await using") validate: (0, _utils.assertOneOf)("var", "let", "const", "using", "await using")
}, },
declarations: { declarations: (0, _utils.validateArrayOfType)("VariableDeclarator")
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("VariableDeclarator")))
}
}, },
validate(parent, key, node) { validate: process.env.BABEL_TYPES_8_BREAKING ? (() => {
if (!process.env.BABEL_TYPES_8_BREAKING) return; const withoutInit = (0, _utils.assertNodeType)("Identifier", "Placeholder");
if (!(0, _is.default)("ForXStatement", parent, { const constOrLetOrVar = (0, _utils.assertNodeType)("Identifier", "ArrayPattern", "ObjectPattern", "Placeholder");
const usingOrAwaitUsing = withoutInit;
return function (parent, key, node) {
const {
kind,
declarations
} = node;
const parentIsForX = (0, _is.default)("ForXStatement", parent, {
left: node left: node
})) return; });
if (node.declarations.length !== 1) { if (parentIsForX) {
if (declarations.length !== 1) {
throw new TypeError(`Exactly one VariableDeclarator is required in the VariableDeclaration of a ${parent.type}`); throw new TypeError(`Exactly one VariableDeclarator is required in the VariableDeclaration of a ${parent.type}`);
} }
} }
for (const decl of declarations) {
if (kind === "const" || kind === "let" || kind === "var") {
if (!parentIsForX && !decl.init) {
withoutInit(decl, "id", decl.id);
} else {
constOrLetOrVar(decl, "id", decl.id);
}
} else {
usingOrAwaitUsing(decl, "id", decl.id);
}
}
};
})() : undefined
}); });
defineType("VariableDeclarator", { defineType("VariableDeclarator", {
visitor: ["id", "init"], visitor: ["id", "init"],
fields: { fields: {
id: { id: {
validate: function () { validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertNodeType)("LVal") : (0, _utils.assertNodeType)("Identifier", "ArrayPattern", "ObjectPattern")
if (!process.env.BABEL_TYPES_8_BREAKING) {
return (0, _utils.assertNodeType)("LVal");
}
const normal = (0, _utils.assertNodeType)("Identifier", "ArrayPattern", "ObjectPattern");
const without = (0, _utils.assertNodeType)("Identifier");
return function (node, key, val) {
const validator = node.init ? normal : without;
validator(node, key, val);
};
}()
}, },
definite: { definite: {
optional: true, optional: true,
@ -893,7 +881,7 @@ defineType("AssignmentPattern", {
validate: (0, _utils.assertNodeType)("Expression") validate: (0, _utils.assertNodeType)("Expression")
}, },
decorators: { decorators: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), validate: (0, _utils.arrayOfType)("Decorator"),
optional: true optional: true
} }
}) })
@ -910,7 +898,7 @@ defineType("ArrayPattern", {
}); });
defineType("ArrowFunctionExpression", { defineType("ArrowFunctionExpression", {
builder: ["params", "body", "async"], builder: ["params", "body", "async"],
visitor: ["params", "body", "returnType", "typeParameters"], visitor: ["typeParameters", "params", "predicate", "returnType", "body"],
aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Expression", "Pureish"], aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Expression", "Pureish"],
fields: Object.assign({}, functionCommon(), functionTypeAnnotationCommon(), { fields: Object.assign({}, functionCommon(), functionTypeAnnotationCommon(), {
expression: { expression: {
@ -928,14 +916,12 @@ defineType("ArrowFunctionExpression", {
defineType("ClassBody", { defineType("ClassBody", {
visitor: ["body"], visitor: ["body"],
fields: { fields: {
body: { body: (0, _utils.validateArrayOfType)("ClassMethod", "ClassPrivateMethod", "ClassProperty", "ClassPrivateProperty", "ClassAccessorProperty", "TSDeclareMethod", "TSIndexSignature", "StaticBlock")
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ClassMethod", "ClassPrivateMethod", "ClassProperty", "ClassPrivateProperty", "ClassAccessorProperty", "TSDeclareMethod", "TSIndexSignature", "StaticBlock")))
}
} }
}); });
defineType("ClassExpression", { defineType("ClassExpression", {
builder: ["id", "superClass", "body", "decorators"], builder: ["id", "superClass", "body", "decorators"],
visitor: ["id", "body", "superClass", "mixins", "typeParameters", "superTypeParameters", "implements", "decorators"], visitor: ["decorators", "id", "typeParameters", "superClass", "superTypeParameters", "mixins", "implements", "body"],
aliases: ["Scopable", "Class", "Expression"], aliases: ["Scopable", "Class", "Expression"],
fields: { fields: {
id: { id: {
@ -953,16 +939,16 @@ defineType("ClassExpression", {
optional: true, optional: true,
validate: (0, _utils.assertNodeType)("Expression") validate: (0, _utils.assertNodeType)("Expression")
}, },
superTypeParameters: { ["superTypeParameters"]: {
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"), validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"),
optional: true optional: true
}, },
implements: { implements: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TSExpressionWithTypeArguments", "ClassImplements"))), validate: (0, _utils.arrayOfType)("TSExpressionWithTypeArguments", "ClassImplements"),
optional: true optional: true
}, },
decorators: { decorators: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), validate: (0, _utils.arrayOfType)("Decorator"),
optional: true optional: true
}, },
mixins: { mixins: {
@ -990,16 +976,16 @@ defineType("ClassDeclaration", {
optional: true, optional: true,
validate: (0, _utils.assertNodeType)("Expression") validate: (0, _utils.assertNodeType)("Expression")
}, },
superTypeParameters: { ["superTypeParameters"]: {
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"), validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"),
optional: true optional: true
}, },
implements: { implements: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TSExpressionWithTypeArguments", "ClassImplements"))), validate: (0, _utils.arrayOfType)("TSExpressionWithTypeArguments", "ClassImplements"),
optional: true optional: true
}, },
decorators: { decorators: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), validate: (0, _utils.arrayOfType)("Decorator"),
optional: true optional: true
}, },
mixins: { mixins: {
@ -1015,92 +1001,84 @@ defineType("ClassDeclaration", {
optional: true optional: true
} }
}, },
validate: function () { validate: !process.env.BABEL_TYPES_8_BREAKING ? undefined : function () {
const identifier = (0, _utils.assertNodeType)("Identifier"); const identifier = (0, _utils.assertNodeType)("Identifier");
return function (parent, key, node) { return function (parent, key, node) {
if (!process.env.BABEL_TYPES_8_BREAKING) return;
if (!(0, _is.default)("ExportDefaultDeclaration", parent)) { if (!(0, _is.default)("ExportDefaultDeclaration", parent)) {
identifier(node, "id", node.id); identifier(node, "id", node.id);
} }
}; };
}() }()
}); });
const importAttributes = exports.importAttributes = {
attributes: {
optional: true,
validate: (0, _utils.arrayOfType)("ImportAttribute")
},
assertions: {
deprecated: true,
optional: true,
validate: (0, _utils.arrayOfType)("ImportAttribute")
}
};
defineType("ExportAllDeclaration", { defineType("ExportAllDeclaration", {
builder: ["source"], builder: ["source"],
visitor: ["source", "attributes", "assertions"], visitor: ["source", "attributes", "assertions"],
aliases: ["Statement", "Declaration", "ImportOrExportDeclaration", "ExportDeclaration"], aliases: ["Statement", "Declaration", "ImportOrExportDeclaration", "ExportDeclaration"],
fields: { fields: Object.assign({
source: { source: {
validate: (0, _utils.assertNodeType)("StringLiteral") validate: (0, _utils.assertNodeType)("StringLiteral")
}, },
exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("type", "value")), exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("type", "value"))
attributes: { }, importAttributes)
optional: true,
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportAttribute")))
},
assertions: {
optional: true,
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportAttribute")))
}
}
}); });
defineType("ExportDefaultDeclaration", { defineType("ExportDefaultDeclaration", {
visitor: ["declaration"], visitor: ["declaration"],
aliases: ["Statement", "Declaration", "ImportOrExportDeclaration", "ExportDeclaration"], aliases: ["Statement", "Declaration", "ImportOrExportDeclaration", "ExportDeclaration"],
fields: { fields: {
declaration: { declaration: (0, _utils.validateType)("TSDeclareFunction", "FunctionDeclaration", "ClassDeclaration", "Expression"),
validate: (0, _utils.assertNodeType)("TSDeclareFunction", "FunctionDeclaration", "ClassDeclaration", "Expression")
},
exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("value")) exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("value"))
} }
}); });
defineType("ExportNamedDeclaration", { defineType("ExportNamedDeclaration", {
builder: ["declaration", "specifiers", "source"], builder: ["declaration", "specifiers", "source"],
visitor: ["declaration", "specifiers", "source", "attributes", "assertions"], visitor: process.env ? ["declaration", "specifiers", "source", "attributes"] : ["declaration", "specifiers", "source", "attributes", "assertions"],
aliases: ["Statement", "Declaration", "ImportOrExportDeclaration", "ExportDeclaration"], aliases: ["Statement", "Declaration", "ImportOrExportDeclaration", "ExportDeclaration"],
fields: { fields: Object.assign({
declaration: { declaration: {
optional: true, optional: true,
validate: (0, _utils.chain)((0, _utils.assertNodeType)("Declaration"), Object.assign(function (node, key, val) { validate: process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.chain)((0, _utils.assertNodeType)("Declaration"), Object.assign(function (node, key, val) {
if (!process.env.BABEL_TYPES_8_BREAKING) return;
if (val && node.specifiers.length) { if (val && node.specifiers.length) {
throw new TypeError("Only declaration or specifiers is allowed on ExportNamedDeclaration"); throw new TypeError("Only declaration or specifiers is allowed on ExportNamedDeclaration");
} }
}, {
oneOfNodeTypes: ["Declaration"]
}), function (node, key, val) {
if (!process.env.BABEL_TYPES_8_BREAKING) return;
if (val && node.source) { if (val && node.source) {
throw new TypeError("Cannot export a declaration from a source"); throw new TypeError("Cannot export a declaration from a source");
} }
}) }, {
}, oneOfNodeTypes: ["Declaration"]
attributes: { })) : (0, _utils.assertNodeType)("Declaration")
optional: true, }
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportAttribute"))) }, importAttributes, {
},
assertions: {
optional: true,
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportAttribute")))
},
specifiers: { specifiers: {
default: [], default: [],
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)(function () { validate: (0, _utils.arrayOf)(function () {
const sourced = (0, _utils.assertNodeType)("ExportSpecifier", "ExportDefaultSpecifier", "ExportNamespaceSpecifier"); const sourced = (0, _utils.assertNodeType)("ExportSpecifier", "ExportDefaultSpecifier", "ExportNamespaceSpecifier");
const sourceless = (0, _utils.assertNodeType)("ExportSpecifier"); const sourceless = (0, _utils.assertNodeType)("ExportSpecifier");
if (!process.env.BABEL_TYPES_8_BREAKING) return sourced; if (!process.env.BABEL_TYPES_8_BREAKING) return sourced;
return function (node, key, val) { return Object.assign(function (node, key, val) {
const validator = node.source ? sourced : sourceless; const validator = node.source ? sourced : sourceless;
validator(node, key, val); validator(node, key, val);
}; }, {
}())) oneOfNodeTypes: ["ExportSpecifier", "ExportDefaultSpecifier", "ExportNamespaceSpecifier"]
});
}())
}, },
source: { source: {
validate: (0, _utils.assertNodeType)("StringLiteral"), validate: (0, _utils.assertNodeType)("StringLiteral"),
optional: true optional: true
}, },
exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("type", "value")) exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("type", "value"))
} })
}); });
defineType("ExportSpecifier", { defineType("ExportSpecifier", {
visitor: ["local", "exported"], visitor: ["local", "exported"],
@ -1130,13 +1108,15 @@ defineType("ForOfStatement", {
} }
const declaration = (0, _utils.assertNodeType)("VariableDeclaration"); const declaration = (0, _utils.assertNodeType)("VariableDeclaration");
const lval = (0, _utils.assertNodeType)("Identifier", "MemberExpression", "ArrayPattern", "ObjectPattern", "TSAsExpression", "TSSatisfiesExpression", "TSTypeAssertion", "TSNonNullExpression"); const lval = (0, _utils.assertNodeType)("Identifier", "MemberExpression", "ArrayPattern", "ObjectPattern", "TSAsExpression", "TSSatisfiesExpression", "TSTypeAssertion", "TSNonNullExpression");
return function (node, key, val) { return Object.assign(function (node, key, val) {
if ((0, _is.default)("VariableDeclaration", val)) { if ((0, _is.default)("VariableDeclaration", val)) {
declaration(node, key, val); declaration(node, key, val);
} else { } else {
lval(node, key, val); lval(node, key, val);
} }
}; }, {
oneOfNodeTypes: ["VariableDeclaration", "Identifier", "MemberExpression", "ArrayPattern", "ObjectPattern", "TSAsExpression", "TSSatisfiesExpression", "TSTypeAssertion", "TSNonNullExpression"]
});
}() }()
}, },
right: { right: {
@ -1154,15 +1134,7 @@ defineType("ImportDeclaration", {
builder: ["specifiers", "source"], builder: ["specifiers", "source"],
visitor: ["specifiers", "source", "attributes", "assertions"], visitor: ["specifiers", "source", "attributes", "assertions"],
aliases: ["Statement", "Declaration", "ImportOrExportDeclaration"], aliases: ["Statement", "Declaration", "ImportOrExportDeclaration"],
fields: { fields: Object.assign({}, importAttributes, {
attributes: {
optional: true,
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportAttribute")))
},
assertions: {
optional: true,
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportAttribute")))
},
module: { module: {
optional: true, optional: true,
validate: (0, _utils.assertValueType)("boolean") validate: (0, _utils.assertValueType)("boolean")
@ -1171,9 +1143,7 @@ defineType("ImportDeclaration", {
default: null, default: null,
validate: (0, _utils.assertOneOf)("source", "defer") validate: (0, _utils.assertOneOf)("source", "defer")
}, },
specifiers: { specifiers: (0, _utils.validateArrayOfType)("ImportSpecifier", "ImportDefaultSpecifier", "ImportNamespaceSpecifier"),
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ImportSpecifier", "ImportDefaultSpecifier", "ImportNamespaceSpecifier")))
},
source: { source: {
validate: (0, _utils.assertNodeType)("StringLiteral") validate: (0, _utils.assertNodeType)("StringLiteral")
}, },
@ -1181,7 +1151,7 @@ defineType("ImportDeclaration", {
validate: (0, _utils.assertOneOf)("type", "typeof", "value"), validate: (0, _utils.assertOneOf)("type", "typeof", "value"),
optional: true optional: true
} }
} })
}); });
defineType("ImportDefaultSpecifier", { defineType("ImportDefaultSpecifier", {
visitor: ["local"], visitor: ["local"],
@ -1202,7 +1172,8 @@ defineType("ImportNamespaceSpecifier", {
} }
}); });
defineType("ImportSpecifier", { defineType("ImportSpecifier", {
visitor: ["local", "imported"], visitor: ["imported", "local"],
builder: ["local", "imported"],
aliases: ["ModuleSpecifier"], aliases: ["ModuleSpecifier"],
fields: { fields: {
local: { local: {
@ -1239,8 +1210,7 @@ defineType("MetaProperty", {
aliases: ["Expression"], aliases: ["Expression"],
fields: { fields: {
meta: { meta: {
validate: (0, _utils.chain)((0, _utils.assertNodeType)("Identifier"), Object.assign(function (node, key, val) { validate: process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.chain)((0, _utils.assertNodeType)("Identifier"), Object.assign(function (node, key, val) {
if (!process.env.BABEL_TYPES_8_BREAKING) return;
let property; let property;
switch (val.name) { switch (val.name) {
case "function": case "function":
@ -1260,7 +1230,7 @@ defineType("MetaProperty", {
} }
}, { }, {
oneOfNodeTypes: ["Identifier"] oneOfNodeTypes: ["Identifier"]
})) })) : (0, _utils.assertNodeType)("Identifier")
}, },
property: { property: {
validate: (0, _utils.assertNodeType)("Identifier") validate: (0, _utils.assertNodeType)("Identifier")
@ -1302,9 +1272,7 @@ const classMethodOrPropertyCommon = () => ({
}); });
exports.classMethodOrPropertyCommon = classMethodOrPropertyCommon; exports.classMethodOrPropertyCommon = classMethodOrPropertyCommon;
const classMethodOrDeclareMethodCommon = () => Object.assign({}, functionCommon(), classMethodOrPropertyCommon(), { const classMethodOrDeclareMethodCommon = () => Object.assign({}, functionCommon(), classMethodOrPropertyCommon(), {
params: { params: (0, _utils.validateArrayOfType)("Identifier", "Pattern", "RestElement", "TSParameterProperty"),
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Identifier", "Pattern", "RestElement", "TSParameterProperty")))
},
kind: { kind: {
validate: (0, _utils.assertOneOf)("get", "set", "method", "constructor"), validate: (0, _utils.assertOneOf)("get", "set", "method", "constructor"),
default: "method" default: "method"
@ -1314,7 +1282,7 @@ const classMethodOrDeclareMethodCommon = () => Object.assign({}, functionCommon(
optional: true optional: true
}, },
decorators: { decorators: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), validate: (0, _utils.arrayOfType)("Decorator"),
optional: true optional: true
} }
}); });
@ -1322,7 +1290,7 @@ exports.classMethodOrDeclareMethodCommon = classMethodOrDeclareMethodCommon;
defineType("ClassMethod", { defineType("ClassMethod", {
aliases: ["Function", "Scopable", "BlockParent", "FunctionParent", "Method"], aliases: ["Function", "Scopable", "BlockParent", "FunctionParent", "Method"],
builder: ["kind", "key", "params", "body", "computed", "static", "generator", "async"], builder: ["kind", "key", "params", "body", "computed", "static", "generator", "async"],
visitor: ["key", "params", "body", "decorators", "returnType", "typeParameters"], visitor: ["decorators", "key", "typeParameters", "params", "returnType", "body"],
fields: Object.assign({}, classMethodOrDeclareMethodCommon(), functionTypeAnnotationCommon(), { fields: Object.assign({}, classMethodOrDeclareMethodCommon(), functionTypeAnnotationCommon(), {
body: { body: {
validate: (0, _utils.assertNodeType)("BlockStatement") validate: (0, _utils.assertNodeType)("BlockStatement")
@ -1334,9 +1302,7 @@ defineType("ObjectPattern", {
builder: ["properties"], builder: ["properties"],
aliases: ["Pattern", "PatternLike", "LVal"], aliases: ["Pattern", "PatternLike", "LVal"],
fields: Object.assign({}, patternLikeCommon(), { fields: Object.assign({}, patternLikeCommon(), {
properties: { properties: (0, _utils.validateArrayOfType)("RestElement", "ObjectProperty")
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("RestElement", "ObjectProperty")))
}
}) })
}); });
defineType("SpreadElement", { defineType("SpreadElement", {
@ -1353,7 +1319,7 @@ defineType("Super", {
aliases: ["Expression"] aliases: ["Expression"]
}); });
defineType("TaggedTemplateExpression", { defineType("TaggedTemplateExpression", {
visitor: ["tag", "quasi", "typeParameters"], visitor: ["tag", "typeParameters", "quasi"],
builder: ["tag", "quasi"], builder: ["tag", "quasi"],
aliases: ["Expression"], aliases: ["Expression"],
fields: { fields: {
@ -1363,7 +1329,7 @@ defineType("TaggedTemplateExpression", {
quasi: { quasi: {
validate: (0, _utils.assertNodeType)("TemplateLiteral") validate: (0, _utils.assertNodeType)("TemplateLiteral")
}, },
typeParameters: { ["typeParameters"]: {
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"), validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"),
optional: true optional: true
} }
@ -1414,9 +1380,7 @@ defineType("TemplateLiteral", {
visitor: ["quasis", "expressions"], visitor: ["quasis", "expressions"],
aliases: ["Expression", "Literal"], aliases: ["Expression", "Literal"],
fields: { fields: {
quasis: { quasis: (0, _utils.validateArrayOfType)("TemplateElement"),
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TemplateElement")))
},
expressions: { expressions: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "TSType")), function (node, key, val) { validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "TSType")), function (node, key, val) {
if (node.quasis.length !== val.length + 1) { if (node.quasis.length !== val.length + 1) {
@ -1432,14 +1396,13 @@ defineType("YieldExpression", {
aliases: ["Expression", "Terminatorless"], aliases: ["Expression", "Terminatorless"],
fields: { fields: {
delegate: { delegate: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("boolean"), Object.assign(function (node, key, val) { validate: process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.chain)((0, _utils.assertValueType)("boolean"), Object.assign(function (node, key, val) {
if (!process.env.BABEL_TYPES_8_BREAKING) return;
if (val && !node.argument) { if (val && !node.argument) {
throw new TypeError("Property delegate of YieldExpression cannot be true if there is no argument"); throw new TypeError("Property delegate of YieldExpression cannot be true if there is no argument");
} }
}, { }, {
type: "boolean" type: "boolean"
})), })) : (0, _utils.assertValueType)("boolean"),
default: false default: false
}, },
argument: { argument: {
@ -1512,28 +1475,27 @@ defineType("OptionalCallExpression", {
visitor: ["callee", "arguments", "typeParameters", "typeArguments"], visitor: ["callee", "arguments", "typeParameters", "typeArguments"],
builder: ["callee", "arguments", "optional"], builder: ["callee", "arguments", "optional"],
aliases: ["Expression"], aliases: ["Expression"],
fields: { fields: Object.assign({
callee: { callee: {
validate: (0, _utils.assertNodeType)("Expression") validate: (0, _utils.assertNodeType)("Expression")
}, },
arguments: { arguments: (0, _utils.validateArrayOfType)("Expression", "SpreadElement", "ArgumentPlaceholder"),
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "SpreadElement", "JSXNamespacedName", "ArgumentPlaceholder")))
},
optional: { optional: {
validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertValueType)("boolean") : (0, _utils.chain)((0, _utils.assertValueType)("boolean"), (0, _utils.assertOptionalChainStart)()) validate: !process.env.BABEL_TYPES_8_BREAKING ? (0, _utils.assertValueType)("boolean") : (0, _utils.chain)((0, _utils.assertValueType)("boolean"), (0, _utils.assertOptionalChainStart)())
}, },
typeArguments: { typeArguments: {
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation"), validate: (0, _utils.assertNodeType)("TypeParameterInstantiation"),
optional: true optional: true
}, }
}, {
typeParameters: { typeParameters: {
validate: (0, _utils.assertNodeType)("TSTypeParameterInstantiation"), validate: (0, _utils.assertNodeType)("TSTypeParameterInstantiation"),
optional: true optional: true
} }
} })
}); });
defineType("ClassProperty", { defineType("ClassProperty", {
visitor: ["key", "value", "typeAnnotation", "decorators"], visitor: ["decorators", "variance", "key", "typeAnnotation", "value"],
builder: ["key", "value", "typeAnnotation", "decorators", "computed", "static"], builder: ["key", "value", "typeAnnotation", "decorators", "computed", "static"],
aliases: ["Property"], aliases: ["Property"],
fields: Object.assign({}, classMethodOrPropertyCommon(), { fields: Object.assign({}, classMethodOrPropertyCommon(), {
@ -1550,7 +1512,7 @@ defineType("ClassProperty", {
optional: true optional: true
}, },
decorators: { decorators: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), validate: (0, _utils.arrayOfType)("Decorator"),
optional: true optional: true
}, },
readonly: { readonly: {
@ -1568,7 +1530,7 @@ defineType("ClassProperty", {
}) })
}); });
defineType("ClassAccessorProperty", { defineType("ClassAccessorProperty", {
visitor: ["key", "value", "typeAnnotation", "decorators"], visitor: ["decorators", "key", "typeAnnotation", "value"],
builder: ["key", "value", "typeAnnotation", "decorators", "computed", "static"], builder: ["key", "value", "typeAnnotation", "decorators", "computed", "static"],
aliases: ["Property", "Accessor"], aliases: ["Property", "Accessor"],
fields: Object.assign({}, classMethodOrPropertyCommon(), { fields: Object.assign({}, classMethodOrPropertyCommon(), {
@ -1595,7 +1557,7 @@ defineType("ClassAccessorProperty", {
optional: true optional: true
}, },
decorators: { decorators: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), validate: (0, _utils.arrayOfType)("Decorator"),
optional: true optional: true
}, },
readonly: { readonly: {
@ -1613,7 +1575,7 @@ defineType("ClassAccessorProperty", {
}) })
}); });
defineType("ClassPrivateProperty", { defineType("ClassPrivateProperty", {
visitor: ["key", "value", "decorators", "typeAnnotation"], visitor: ["decorators", "variance", "key", "typeAnnotation", "value"],
builder: ["key", "value", "decorators", "static"], builder: ["key", "value", "decorators", "static"],
aliases: ["Property", "Private"], aliases: ["Property", "Private"],
fields: { fields: {
@ -1629,7 +1591,7 @@ defineType("ClassPrivateProperty", {
optional: true optional: true
}, },
decorators: { decorators: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), validate: (0, _utils.arrayOfType)("Decorator"),
optional: true optional: true
}, },
static: { static: {
@ -1640,6 +1602,10 @@ defineType("ClassPrivateProperty", {
validate: (0, _utils.assertValueType)("boolean"), validate: (0, _utils.assertValueType)("boolean"),
optional: true optional: true
}, },
optional: {
validate: (0, _utils.assertValueType)("boolean"),
optional: true
},
definite: { definite: {
validate: (0, _utils.assertValueType)("boolean"), validate: (0, _utils.assertValueType)("boolean"),
optional: true optional: true
@ -1652,7 +1618,7 @@ defineType("ClassPrivateProperty", {
}); });
defineType("ClassPrivateMethod", { defineType("ClassPrivateMethod", {
builder: ["kind", "key", "params", "body", "static"], builder: ["kind", "key", "params", "body", "static"],
visitor: ["key", "params", "body", "decorators", "returnType", "typeParameters"], visitor: ["decorators", "key", "typeParameters", "params", "returnType", "body"],
aliases: ["Function", "Scopable", "BlockParent", "FunctionParent", "Method", "Private"], aliases: ["Function", "Scopable", "BlockParent", "FunctionParent", "Method", "Private"],
fields: Object.assign({}, classMethodOrDeclareMethodCommon(), functionTypeAnnotationCommon(), { fields: Object.assign({}, classMethodOrDeclareMethodCommon(), functionTypeAnnotationCommon(), {
kind: { kind: {
@ -1679,11 +1645,20 @@ defineType("PrivateName", {
defineType("StaticBlock", { defineType("StaticBlock", {
visitor: ["body"], visitor: ["body"],
fields: { fields: {
body: { body: (0, _utils.validateArrayOfType)("Statement")
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Statement")))
}
}, },
aliases: ["Scopable", "BlockParent", "FunctionParent"] aliases: ["Scopable", "BlockParent", "FunctionParent"]
}); });
defineType("ImportAttribute", {
visitor: ["key", "value"],
fields: {
key: {
validate: (0, _utils.assertNodeType)("Identifier", "StringLiteral")
},
value: {
validate: (0, _utils.assertNodeType)("StringLiteral")
}
}
});
//# sourceMappingURL=core.js.map //# sourceMappingURL=core.js.map

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"version":3,"names":["DEPRECATED_ALIASES","exports","ModuleDeclaration"],"sources":["../../src/definitions/deprecated-aliases.ts"],"sourcesContent":["export const DEPRECATED_ALIASES = {\n ModuleDeclaration: \"ImportOrExportDeclaration\",\n};\n"],"mappings":";;;;;;AAAO,MAAMA,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG;EAChCE,iBAAiB,EAAE;AACrB,CAAC"} {"version":3,"names":["DEPRECATED_ALIASES","exports","ModuleDeclaration"],"sources":["../../src/definitions/deprecated-aliases.ts"],"sourcesContent":["export const DEPRECATED_ALIASES = {\n ModuleDeclaration: \"ImportOrExportDeclaration\",\n};\n"],"mappings":";;;;;;AAAO,MAAMA,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG;EAChCE,iBAAiB,EAAE;AACrB,CAAC","ignoreList":[]}

View File

@ -25,17 +25,6 @@ var _utils = require("./utils.js");
} }
} }
}); });
(0, _utils.default)("ImportAttribute", {
visitor: ["key", "value"],
fields: {
key: {
validate: (0, _utils.assertNodeType)("Identifier", "StringLiteral")
},
value: {
validate: (0, _utils.assertNodeType)("StringLiteral")
}
}
});
(0, _utils.default)("Decorator", { (0, _utils.default)("Decorator", {
visitor: ["expression"], visitor: ["expression"],
fields: { fields: {
@ -71,21 +60,20 @@ var _utils = require("./utils.js");
visitor: ["properties"], visitor: ["properties"],
aliases: ["Expression"], aliases: ["Expression"],
fields: { fields: {
properties: { properties: (0, _utils.validateArrayOfType)("ObjectProperty", "SpreadElement")
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ObjectProperty", "SpreadElement")))
}
} }
}); });
(0, _utils.default)("TupleExpression", { (0, _utils.default)("TupleExpression", {
fields: { fields: {
elements: { elements: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "SpreadElement"))), validate: (0, _utils.arrayOfType)("Expression", "SpreadElement"),
default: [] default: []
} }
}, },
visitor: ["elements"], visitor: ["elements"],
aliases: ["Expression"] aliases: ["Expression"]
}); });
{
(0, _utils.default)("DecimalLiteral", { (0, _utils.default)("DecimalLiteral", {
builder: ["value"], builder: ["value"],
fields: { fields: {
@ -95,6 +83,7 @@ var _utils = require("./utils.js");
}, },
aliases: ["Expression", "Pureish", "Literal", "Immutable"] aliases: ["Expression", "Pureish", "Literal", "Immutable"]
}); });
}
(0, _utils.default)("ModuleExpression", { (0, _utils.default)("ModuleExpression", {
visitor: ["body"], visitor: ["body"],
fields: { fields: {

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,6 @@
"use strict"; "use strict";
var _core = require("./core.js");
var _utils = require("./utils.js"); var _utils = require("./utils.js");
const defineType = (0, _utils.defineAliasedType)("Flow"); const defineType = (0, _utils.defineAliasedType)("Flow");
const defineInterfaceishType = name => { const defineInterfaceishType = name => {
@ -52,7 +53,8 @@ defineType("ClassImplements", {
}); });
defineInterfaceishType("DeclareClass"); defineInterfaceishType("DeclareClass");
defineType("DeclareFunction", { defineType("DeclareFunction", {
visitor: ["id"], builder: ["id"],
visitor: ["id", "predicate"],
aliases: ["FlowDeclaration", "Statement", "Declaration"], aliases: ["FlowDeclaration", "Statement", "Declaration"],
fields: { fields: {
id: (0, _utils.validateType)("Identifier"), id: (0, _utils.validateType)("Identifier"),
@ -65,7 +67,7 @@ defineType("DeclareModule", {
visitor: ["id", "body"], visitor: ["id", "body"],
aliases: ["FlowDeclaration", "Statement", "Declaration"], aliases: ["FlowDeclaration", "Statement", "Declaration"],
fields: { fields: {
id: (0, _utils.validateType)(["Identifier", "StringLiteral"]), id: (0, _utils.validateType)("Identifier", "StringLiteral"),
body: (0, _utils.validateType)("BlockStatement"), body: (0, _utils.validateType)("BlockStatement"),
kind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("CommonJS", "ES")) kind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("CommonJS", "ES"))
} }
@ -104,22 +106,22 @@ defineType("DeclareVariable", {
} }
}); });
defineType("DeclareExportDeclaration", { defineType("DeclareExportDeclaration", {
visitor: ["declaration", "specifiers", "source"], visitor: ["declaration", "specifiers", "source", "attributes"],
aliases: ["FlowDeclaration", "Statement", "Declaration"], aliases: ["FlowDeclaration", "Statement", "Declaration"],
fields: { fields: Object.assign({
declaration: (0, _utils.validateOptionalType)("Flow"), declaration: (0, _utils.validateOptionalType)("Flow"),
specifiers: (0, _utils.validateOptional)((0, _utils.arrayOfType)(["ExportSpecifier", "ExportNamespaceSpecifier"])), specifiers: (0, _utils.validateOptional)((0, _utils.arrayOfType)("ExportSpecifier", "ExportNamespaceSpecifier")),
source: (0, _utils.validateOptionalType)("StringLiteral"), source: (0, _utils.validateOptionalType)("StringLiteral"),
default: (0, _utils.validateOptional)((0, _utils.assertValueType)("boolean")) default: (0, _utils.validateOptional)((0, _utils.assertValueType)("boolean"))
} }, _core.importAttributes)
}); });
defineType("DeclareExportAllDeclaration", { defineType("DeclareExportAllDeclaration", {
visitor: ["source"], visitor: ["source", "attributes"],
aliases: ["FlowDeclaration", "Statement", "Declaration"], aliases: ["FlowDeclaration", "Statement", "Declaration"],
fields: { fields: Object.assign({
source: (0, _utils.validateType)("StringLiteral"), source: (0, _utils.validateType)("StringLiteral"),
exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("type", "value")) exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("type", "value"))
} }, _core.importAttributes)
}); });
defineType("DeclaredPredicate", { defineType("DeclaredPredicate", {
visitor: ["value"], visitor: ["value"],
@ -132,11 +134,12 @@ defineType("ExistsTypeAnnotation", {
aliases: ["FlowType"] aliases: ["FlowType"]
}); });
defineType("FunctionTypeAnnotation", { defineType("FunctionTypeAnnotation", {
visitor: ["typeParameters", "params", "rest", "returnType"], builder: ["typeParameters", "params", "rest", "returnType"],
visitor: ["typeParameters", "this", "params", "rest", "returnType"],
aliases: ["FlowType"], aliases: ["FlowType"],
fields: { fields: {
typeParameters: (0, _utils.validateOptionalType)("TypeParameterDeclaration"), typeParameters: (0, _utils.validateOptionalType)("TypeParameterDeclaration"),
params: (0, _utils.validate)((0, _utils.arrayOfType)("FunctionTypeParam")), params: (0, _utils.validateArrayOfType)("FunctionTypeParam"),
rest: (0, _utils.validateOptionalType)("FunctionTypeParam"), rest: (0, _utils.validateOptionalType)("FunctionTypeParam"),
this: (0, _utils.validateOptionalType)("FunctionTypeParam"), this: (0, _utils.validateOptionalType)("FunctionTypeParam"),
returnType: (0, _utils.validateType)("FlowType") returnType: (0, _utils.validateType)("FlowType")
@ -154,7 +157,7 @@ defineType("GenericTypeAnnotation", {
visitor: ["id", "typeParameters"], visitor: ["id", "typeParameters"],
aliases: ["FlowType"], aliases: ["FlowType"],
fields: { fields: {
id: (0, _utils.validateType)(["Identifier", "QualifiedTypeIdentifier"]), id: (0, _utils.validateType)("Identifier", "QualifiedTypeIdentifier"),
typeParameters: (0, _utils.validateOptionalType)("TypeParameterInstantiation") typeParameters: (0, _utils.validateOptionalType)("TypeParameterInstantiation")
} }
}); });
@ -164,7 +167,7 @@ defineType("InferredPredicate", {
defineType("InterfaceExtends", { defineType("InterfaceExtends", {
visitor: ["id", "typeParameters"], visitor: ["id", "typeParameters"],
fields: { fields: {
id: (0, _utils.validateType)(["Identifier", "QualifiedTypeIdentifier"]), id: (0, _utils.validateType)("Identifier", "QualifiedTypeIdentifier"),
typeParameters: (0, _utils.validateOptionalType)("TypeParameterInstantiation") typeParameters: (0, _utils.validateOptionalType)("TypeParameterInstantiation")
} }
}); });
@ -212,7 +215,7 @@ defineType("ObjectTypeAnnotation", {
aliases: ["FlowType"], aliases: ["FlowType"],
builder: ["properties", "indexers", "callProperties", "internalSlots", "exact"], builder: ["properties", "indexers", "callProperties", "internalSlots", "exact"],
fields: { fields: {
properties: (0, _utils.validate)((0, _utils.arrayOfType)(["ObjectTypeProperty", "ObjectTypeSpreadProperty"])), properties: (0, _utils.validate)((0, _utils.arrayOfType)("ObjectTypeProperty", "ObjectTypeSpreadProperty")),
indexers: { indexers: {
validate: (0, _utils.arrayOfType)("ObjectTypeIndexer"), validate: (0, _utils.arrayOfType)("ObjectTypeIndexer"),
optional: true, optional: true,
@ -236,7 +239,8 @@ defineType("ObjectTypeAnnotation", {
} }
}); });
defineType("ObjectTypeInternalSlot", { defineType("ObjectTypeInternalSlot", {
visitor: ["id", "value", "optional", "static", "method"], visitor: ["id", "value"],
builder: ["id", "value", "optional", "static", "method"],
aliases: ["UserWhitespacable"], aliases: ["UserWhitespacable"],
fields: { fields: {
id: (0, _utils.validateType)("Identifier"), id: (0, _utils.validateType)("Identifier"),
@ -255,7 +259,8 @@ defineType("ObjectTypeCallProperty", {
} }
}); });
defineType("ObjectTypeIndexer", { defineType("ObjectTypeIndexer", {
visitor: ["id", "key", "value", "variance"], visitor: ["variance", "id", "key", "value"],
builder: ["id", "key", "value", "variance"],
aliases: ["UserWhitespacable"], aliases: ["UserWhitespacable"],
fields: { fields: {
id: (0, _utils.validateOptionalType)("Identifier"), id: (0, _utils.validateOptionalType)("Identifier"),
@ -269,7 +274,7 @@ defineType("ObjectTypeProperty", {
visitor: ["key", "value", "variance"], visitor: ["key", "value", "variance"],
aliases: ["UserWhitespacable"], aliases: ["UserWhitespacable"],
fields: { fields: {
key: (0, _utils.validateType)(["Identifier", "StringLiteral"]), key: (0, _utils.validateType)("Identifier", "StringLiteral"),
value: (0, _utils.validateType)("FlowType"), value: (0, _utils.validateType)("FlowType"),
kind: (0, _utils.validate)((0, _utils.assertOneOf)("init", "get", "set")), kind: (0, _utils.validate)((0, _utils.assertOneOf)("init", "get", "set")),
static: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), static: (0, _utils.validate)((0, _utils.assertValueType)("boolean")),
@ -297,10 +302,11 @@ defineType("OpaqueType", {
} }
}); });
defineType("QualifiedTypeIdentifier", { defineType("QualifiedTypeIdentifier", {
visitor: ["id", "qualification"], visitor: ["qualification", "id"],
builder: ["id", "qualification"],
fields: { fields: {
id: (0, _utils.validateType)("Identifier"), id: (0, _utils.validateType)("Identifier"),
qualification: (0, _utils.validateType)(["Identifier", "QualifiedTypeIdentifier"]) qualification: (0, _utils.validateType)("Identifier", "QualifiedTypeIdentifier")
} }
}); });
defineType("StringLiteralTypeAnnotation", { defineType("StringLiteralTypeAnnotation", {
@ -398,7 +404,7 @@ defineType("EnumDeclaration", {
visitor: ["id", "body"], visitor: ["id", "body"],
fields: { fields: {
id: (0, _utils.validateType)("Identifier"), id: (0, _utils.validateType)("Identifier"),
body: (0, _utils.validateType)(["EnumBooleanBody", "EnumNumberBody", "EnumStringBody", "EnumSymbolBody"]) body: (0, _utils.validateType)("EnumBooleanBody", "EnumNumberBody", "EnumStringBody", "EnumSymbolBody")
} }
}); });
defineType("EnumBooleanBody", { defineType("EnumBooleanBody", {
@ -424,7 +430,7 @@ defineType("EnumStringBody", {
visitor: ["members"], visitor: ["members"],
fields: { fields: {
explicitType: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), explicitType: (0, _utils.validate)((0, _utils.assertValueType)("boolean")),
members: (0, _utils.validateArrayOfType)(["EnumStringMember", "EnumDefaultedMember"]), members: (0, _utils.validateArrayOfType)("EnumStringMember", "EnumDefaultedMember"),
hasUnknownMembers: (0, _utils.validate)((0, _utils.assertValueType)("boolean")) hasUnknownMembers: (0, _utils.validate)((0, _utils.assertValueType)("boolean"))
} }
}); });
@ -438,7 +444,8 @@ defineType("EnumSymbolBody", {
}); });
defineType("EnumBooleanMember", { defineType("EnumBooleanMember", {
aliases: ["EnumMember"], aliases: ["EnumMember"],
visitor: ["id"], builder: ["id"],
visitor: ["id", "init"],
fields: { fields: {
id: (0, _utils.validateType)("Identifier"), id: (0, _utils.validateType)("Identifier"),
init: (0, _utils.validateType)("BooleanLiteral") init: (0, _utils.validateType)("BooleanLiteral")

File diff suppressed because one or more lines are too long

View File

@ -70,7 +70,6 @@ Object.defineProperty(exports, "VISITOR_KEYS", {
return _utils.VISITOR_KEYS; return _utils.VISITOR_KEYS;
} }
}); });
var _toFastProperties = require("to-fast-properties");
require("./core.js"); require("./core.js");
require("./flow.js"); require("./flow.js");
require("./jsx.js"); require("./jsx.js");
@ -83,14 +82,19 @@ var _deprecatedAliases = require("./deprecated-aliases.js");
Object.keys(_deprecatedAliases.DEPRECATED_ALIASES).forEach(deprecatedAlias => { Object.keys(_deprecatedAliases.DEPRECATED_ALIASES).forEach(deprecatedAlias => {
_utils.FLIPPED_ALIAS_KEYS[deprecatedAlias] = _utils.FLIPPED_ALIAS_KEYS[_deprecatedAliases.DEPRECATED_ALIASES[deprecatedAlias]]; _utils.FLIPPED_ALIAS_KEYS[deprecatedAlias] = _utils.FLIPPED_ALIAS_KEYS[_deprecatedAliases.DEPRECATED_ALIASES[deprecatedAlias]];
}); });
_toFastProperties(_utils.VISITOR_KEYS); for (const {
_toFastProperties(_utils.ALIAS_KEYS); types,
_toFastProperties(_utils.FLIPPED_ALIAS_KEYS); set
_toFastProperties(_utils.NODE_FIELDS); } of _utils.allExpandedTypes) {
_toFastProperties(_utils.BUILDER_KEYS); for (const type of types) {
_toFastProperties(_utils.DEPRECATED_KEYS); const aliases = _utils.FLIPPED_ALIAS_KEYS[type];
_toFastProperties(_placeholders.PLACEHOLDERS_ALIAS); if (aliases) {
_toFastProperties(_placeholders.PLACEHOLDERS_FLIPPED_ALIAS); aliases.forEach(set.add, set);
} else {
set.add(type);
}
}
}
const TYPES = exports.TYPES = [].concat(Object.keys(_utils.VISITOR_KEYS), Object.keys(_utils.FLIPPED_ALIAS_KEYS), Object.keys(_utils.DEPRECATED_KEYS)); const TYPES = exports.TYPES = [].concat(Object.keys(_utils.VISITOR_KEYS), Object.keys(_utils.FLIPPED_ALIAS_KEYS), Object.keys(_utils.DEPRECATED_KEYS));
//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map

View File

@ -1 +1 @@
{"version":3,"names":["_toFastProperties","require","_utils","_placeholders","_deprecatedAliases","Object","keys","DEPRECATED_ALIASES","forEach","deprecatedAlias","FLIPPED_ALIAS_KEYS","toFastProperties","VISITOR_KEYS","ALIAS_KEYS","NODE_FIELDS","BUILDER_KEYS","DEPRECATED_KEYS","PLACEHOLDERS_ALIAS","PLACEHOLDERS_FLIPPED_ALIAS","TYPES","exports","concat"],"sources":["../../src/definitions/index.ts"],"sourcesContent":["import toFastProperties from \"to-fast-properties\";\nimport \"./core.ts\";\nimport \"./flow.ts\";\nimport \"./jsx.ts\";\nimport \"./misc.ts\";\nimport \"./experimental.ts\";\nimport \"./typescript.ts\";\nimport {\n VISITOR_KEYS,\n ALIAS_KEYS,\n FLIPPED_ALIAS_KEYS,\n NODE_FIELDS,\n BUILDER_KEYS,\n DEPRECATED_KEYS,\n NODE_PARENT_VALIDATIONS,\n} from \"./utils.ts\";\nimport {\n PLACEHOLDERS,\n PLACEHOLDERS_ALIAS,\n PLACEHOLDERS_FLIPPED_ALIAS,\n} from \"./placeholders.ts\";\nimport { DEPRECATED_ALIASES } from \"./deprecated-aliases.ts\";\n\n(\n Object.keys(DEPRECATED_ALIASES) as (keyof typeof DEPRECATED_ALIASES)[]\n).forEach(deprecatedAlias => {\n FLIPPED_ALIAS_KEYS[deprecatedAlias] =\n FLIPPED_ALIAS_KEYS[DEPRECATED_ALIASES[deprecatedAlias]];\n});\n\n// We do this here, because at this point the visitor keys should be ready and setup\ntoFastProperties(VISITOR_KEYS);\ntoFastProperties(ALIAS_KEYS);\ntoFastProperties(FLIPPED_ALIAS_KEYS);\ntoFastProperties(NODE_FIELDS);\ntoFastProperties(BUILDER_KEYS);\ntoFastProperties(DEPRECATED_KEYS);\n\ntoFastProperties(PLACEHOLDERS_ALIAS);\ntoFastProperties(PLACEHOLDERS_FLIPPED_ALIAS);\n\nconst TYPES: Array<string> = [].concat(\n Object.keys(VISITOR_KEYS),\n Object.keys(FLIPPED_ALIAS_KEYS),\n Object.keys(DEPRECATED_KEYS),\n);\n\nexport {\n VISITOR_KEYS,\n ALIAS_KEYS,\n FLIPPED_ALIAS_KEYS,\n NODE_FIELDS,\n BUILDER_KEYS,\n DEPRECATED_ALIASES,\n DEPRECATED_KEYS,\n NODE_PARENT_VALIDATIONS,\n PLACEHOLDERS,\n PLACEHOLDERS_ALIAS,\n PLACEHOLDERS_FLIPPED_ALIAS,\n TYPES,\n};\n\nexport type { FieldOptions } from \"./utils.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AASA,IAAAE,aAAA,GAAAF,OAAA;AAKA,IAAAG,kBAAA,GAAAH,OAAA;AAGEI,MAAM,CAACC,IAAI,CAACC,qCAAkB,CAAC,CAC/BC,OAAO,CAACC,eAAe,IAAI;EAC3BC,yBAAkB,CAACD,eAAe,CAAC,GACjCC,yBAAkB,CAACH,qCAAkB,CAACE,eAAe,CAAC,CAAC;AAC3D,CAAC,CAAC;AAGFE,iBAAgB,CAACC,mBAAY,CAAC;AAC9BD,iBAAgB,CAACE,iBAAU,CAAC;AAC5BF,iBAAgB,CAACD,yBAAkB,CAAC;AACpCC,iBAAgB,CAACG,kBAAW,CAAC;AAC7BH,iBAAgB,CAACI,mBAAY,CAAC;AAC9BJ,iBAAgB,CAACK,sBAAe,CAAC;AAEjCL,iBAAgB,CAACM,gCAAkB,CAAC;AACpCN,iBAAgB,CAACO,wCAA0B,CAAC;AAE5C,MAAMC,KAAoB,GAAAC,OAAA,CAAAD,KAAA,GAAG,EAAE,CAACE,MAAM,CACpChB,MAAM,CAACC,IAAI,CAACM,mBAAY,CAAC,EACzBP,MAAM,CAACC,IAAI,CAACI,yBAAkB,CAAC,EAC/BL,MAAM,CAACC,IAAI,CAACU,sBAAe,CAC7B,CAAC"} {"version":3,"names":["require","_utils","_placeholders","_deprecatedAliases","Object","keys","DEPRECATED_ALIASES","forEach","deprecatedAlias","FLIPPED_ALIAS_KEYS","types","set","allExpandedTypes","type","aliases","add","TYPES","exports","concat","VISITOR_KEYS","DEPRECATED_KEYS"],"sources":["../../src/definitions/index.ts"],"sourcesContent":["import \"./core.ts\";\nimport \"./flow.ts\";\nimport \"./jsx.ts\";\nimport \"./misc.ts\";\nimport \"./experimental.ts\";\nimport \"./typescript.ts\";\nimport {\n VISITOR_KEYS,\n ALIAS_KEYS,\n FLIPPED_ALIAS_KEYS,\n NODE_FIELDS,\n BUILDER_KEYS,\n DEPRECATED_KEYS,\n NODE_PARENT_VALIDATIONS,\n allExpandedTypes,\n} from \"./utils.ts\";\nimport {\n PLACEHOLDERS,\n PLACEHOLDERS_ALIAS,\n PLACEHOLDERS_FLIPPED_ALIAS,\n} from \"./placeholders.ts\";\nimport { DEPRECATED_ALIASES } from \"./deprecated-aliases.ts\";\n\n(\n Object.keys(DEPRECATED_ALIASES) as (keyof typeof DEPRECATED_ALIASES)[]\n).forEach(deprecatedAlias => {\n FLIPPED_ALIAS_KEYS[deprecatedAlias] =\n FLIPPED_ALIAS_KEYS[DEPRECATED_ALIASES[deprecatedAlias]];\n});\n\nfor (const { types, set } of allExpandedTypes) {\n for (const type of types) {\n const aliases = FLIPPED_ALIAS_KEYS[type];\n if (aliases) {\n aliases.forEach(set.add, set);\n } else {\n set.add(type);\n }\n }\n}\n\nconst TYPES: Array<string> = [].concat(\n Object.keys(VISITOR_KEYS),\n Object.keys(FLIPPED_ALIAS_KEYS),\n Object.keys(DEPRECATED_KEYS),\n);\n\nexport {\n VISITOR_KEYS,\n ALIAS_KEYS,\n FLIPPED_ALIAS_KEYS,\n NODE_FIELDS,\n BUILDER_KEYS,\n DEPRECATED_ALIASES,\n DEPRECATED_KEYS,\n NODE_PARENT_VALIDATIONS,\n PLACEHOLDERS,\n PLACEHOLDERS_ALIAS,\n PLACEHOLDERS_FLIPPED_ALIAS,\n TYPES,\n};\n\nexport type { FieldOptions } from \"./utils.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAUA,IAAAE,aAAA,GAAAF,OAAA;AAKA,IAAAG,kBAAA,GAAAH,OAAA;AAGEI,MAAM,CAACC,IAAI,CAACC,qCAAkB,CAAC,CAC/BC,OAAO,CAACC,eAAe,IAAI;EAC3BC,yBAAkB,CAACD,eAAe,CAAC,GACjCC,yBAAkB,CAACH,qCAAkB,CAACE,eAAe,CAAC,CAAC;AAC3D,CAAC,CAAC;AAEF,KAAK,MAAM;EAAEE,KAAK;EAAEC;AAAI,CAAC,IAAIC,uBAAgB,EAAE;EAC7C,KAAK,MAAMC,IAAI,IAAIH,KAAK,EAAE;IACxB,MAAMI,OAAO,GAAGL,yBAAkB,CAACI,IAAI,CAAC;IACxC,IAAIC,OAAO,EAAE;MACXA,OAAO,CAACP,OAAO,CAACI,GAAG,CAACI,GAAG,EAAEJ,GAAG,CAAC;IAC/B,CAAC,MAAM;MACLA,GAAG,CAACI,GAAG,CAACF,IAAI,CAAC;IACf;EACF;AACF;AAEA,MAAMG,KAAoB,GAAAC,OAAA,CAAAD,KAAA,GAAG,EAAE,CAACE,MAAM,CACpCd,MAAM,CAACC,IAAI,CAACc,mBAAY,CAAC,EACzBf,MAAM,CAACC,IAAI,CAACI,yBAAkB,CAAC,EAC/BL,MAAM,CAACC,IAAI,CAACe,sBAAe,CAC7B,CAAC","ignoreList":[]}

View File

@ -36,9 +36,7 @@ defineType("JSXElement", {
optional: true, optional: true,
validate: (0, _utils.assertNodeType)("JSXClosingElement") validate: (0, _utils.assertNodeType)("JSXClosingElement")
}, },
children: { children: (0, _utils.validateArrayOfType)("JSXText", "JSXExpressionContainer", "JSXSpreadChild", "JSXElement", "JSXFragment")
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("JSXText", "JSXExpressionContainer", "JSXSpreadChild", "JSXElement", "JSXFragment")))
}
}, { }, {
selfClosing: { selfClosing: {
validate: (0, _utils.assertValueType)("boolean"), validate: (0, _utils.assertValueType)("boolean"),
@ -97,23 +95,26 @@ defineType("JSXNamespacedName", {
}); });
defineType("JSXOpeningElement", { defineType("JSXOpeningElement", {
builder: ["name", "attributes", "selfClosing"], builder: ["name", "attributes", "selfClosing"],
visitor: ["name", "attributes"], visitor: ["name", "typeParameters", "typeArguments", "attributes"],
aliases: ["Immutable"], aliases: ["Immutable"],
fields: { fields: Object.assign({
name: { name: {
validate: (0, _utils.assertNodeType)("JSXIdentifier", "JSXMemberExpression", "JSXNamespacedName") validate: (0, _utils.assertNodeType)("JSXIdentifier", "JSXMemberExpression", "JSXNamespacedName")
}, },
selfClosing: { selfClosing: {
default: false default: false
}, },
attributes: { attributes: (0, _utils.validateArrayOfType)("JSXAttribute", "JSXSpreadAttribute"),
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("JSXAttribute", "JSXSpreadAttribute"))) typeArguments: {
}, validate: (0, _utils.assertNodeType)("TypeParameterInstantiation"),
typeParameters: {
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"),
optional: true optional: true
} }
}, {
typeParameters: {
validate: (0, _utils.assertNodeType)("TSTypeParameterInstantiation"),
optional: true
} }
})
}); });
defineType("JSXSpreadAttribute", { defineType("JSXSpreadAttribute", {
visitor: ["argument"], visitor: ["argument"],
@ -143,9 +144,7 @@ defineType("JSXFragment", {
closingFragment: { closingFragment: {
validate: (0, _utils.assertNodeType)("JSXClosingFragment") validate: (0, _utils.assertNodeType)("JSXClosingFragment")
}, },
children: { children: (0, _utils.validateArrayOfType)("JSXText", "JSXExpressionContainer", "JSXSpreadChild", "JSXElement", "JSXFragment")
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("JSXText", "JSXExpressionContainer", "JSXSpreadChild", "JSXElement", "JSXFragment")))
}
} }
}); });
defineType("JSXOpeningFragment", { defineType("JSXOpeningFragment", {

File diff suppressed because one or more lines are too long

View File

@ -2,6 +2,7 @@
var _utils = require("./utils.js"); var _utils = require("./utils.js");
var _placeholders = require("./placeholders.js"); var _placeholders = require("./placeholders.js");
var _core = require("./core.js");
const defineType = (0, _utils.defineAliasedType)("Miscellaneous"); const defineType = (0, _utils.defineAliasedType)("Miscellaneous");
{ {
defineType("Noop", { defineType("Noop", {
@ -11,14 +12,14 @@ const defineType = (0, _utils.defineAliasedType)("Miscellaneous");
defineType("Placeholder", { defineType("Placeholder", {
visitor: [], visitor: [],
builder: ["expectedNode", "name"], builder: ["expectedNode", "name"],
fields: { fields: Object.assign({
name: { name: {
validate: (0, _utils.assertNodeType)("Identifier") validate: (0, _utils.assertNodeType)("Identifier")
}, },
expectedNode: { expectedNode: {
validate: (0, _utils.assertOneOf)(..._placeholders.PLACEHOLDERS) validate: (0, _utils.assertOneOf)(..._placeholders.PLACEHOLDERS)
} }
} }, (0, _core.patternLikeCommon)())
}); });
defineType("V8IntrinsicIdentifier", { defineType("V8IntrinsicIdentifier", {
builder: ["name"], builder: ["name"],

View File

@ -1 +1 @@
{"version":3,"names":["_utils","require","_placeholders","defineType","defineAliasedType","visitor","builder","fields","name","validate","assertNodeType","expectedNode","assertOneOf","PLACEHOLDERS","assertValueType"],"sources":["../../src/definitions/misc.ts"],"sourcesContent":["import {\n defineAliasedType,\n assertNodeType,\n assertOneOf,\n assertValueType,\n} from \"./utils.ts\";\nimport { PLACEHOLDERS } from \"./placeholders.ts\";\n\nconst defineType = defineAliasedType(\"Miscellaneous\");\n\nif (!process.env.BABEL_8_BREAKING) {\n defineType(\"Noop\", {\n visitor: [],\n });\n}\n\ndefineType(\"Placeholder\", {\n visitor: [],\n builder: [\"expectedNode\", \"name\"],\n // aliases: [], defined in placeholders.js\n fields: {\n name: {\n validate: assertNodeType(\"Identifier\"),\n },\n expectedNode: {\n validate: assertOneOf(...PLACEHOLDERS),\n },\n },\n});\n\ndefineType(\"V8IntrinsicIdentifier\", {\n builder: [\"name\"],\n fields: {\n name: {\n validate: assertValueType(\"string\"),\n },\n },\n});\n"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAMA,IAAAC,aAAA,GAAAD,OAAA;AAEA,MAAME,UAAU,GAAG,IAAAC,wBAAiB,EAAC,eAAe,CAAC;AAElB;EACjCD,UAAU,CAAC,MAAM,EAAE;IACjBE,OAAO,EAAE;EACX,CAAC,CAAC;AACJ;AAEAF,UAAU,CAAC,aAAa,EAAE;EACxBE,OAAO,EAAE,EAAE;EACXC,OAAO,EAAE,CAAC,cAAc,EAAE,MAAM,CAAC;EAEjCC,MAAM,EAAE;IACNC,IAAI,EAAE;MACJC,QAAQ,EAAE,IAAAC,qBAAc,EAAC,YAAY;IACvC,CAAC;IACDC,YAAY,EAAE;MACZF,QAAQ,EAAE,IAAAG,kBAAW,EAAC,GAAGC,0BAAY;IACvC;EACF;AACF,CAAC,CAAC;AAEFV,UAAU,CAAC,uBAAuB,EAAE;EAClCG,OAAO,EAAE,CAAC,MAAM,CAAC;EACjBC,MAAM,EAAE;IACNC,IAAI,EAAE;MACJC,QAAQ,EAAE,IAAAK,sBAAe,EAAC,QAAQ;IACpC;EACF;AACF,CAAC,CAAC"} {"version":3,"names":["_utils","require","_placeholders","_core","defineType","defineAliasedType","visitor","builder","fields","Object","assign","name","validate","assertNodeType","expectedNode","assertOneOf","PLACEHOLDERS","patternLikeCommon","assertValueType"],"sources":["../../src/definitions/misc.ts"],"sourcesContent":["import {\n defineAliasedType,\n assertNodeType,\n assertOneOf,\n assertValueType,\n} from \"./utils.ts\";\nimport { PLACEHOLDERS } from \"./placeholders.ts\";\nimport { patternLikeCommon } from \"./core.ts\";\n\nconst defineType = defineAliasedType(\"Miscellaneous\");\n\nif (!process.env.BABEL_8_BREAKING) {\n defineType(\"Noop\", {\n visitor: [],\n });\n}\n\ndefineType(\"Placeholder\", {\n visitor: [],\n builder: [\"expectedNode\", \"name\"],\n // aliases: [], defined in placeholders.js\n fields: {\n name: {\n validate: assertNodeType(\"Identifier\"),\n },\n expectedNode: {\n validate: assertOneOf(...PLACEHOLDERS),\n },\n ...patternLikeCommon(),\n },\n});\n\ndefineType(\"V8IntrinsicIdentifier\", {\n builder: [\"name\"],\n fields: {\n name: {\n validate: assertValueType(\"string\"),\n },\n },\n});\n"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAMA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAEA,MAAMG,UAAU,GAAG,IAAAC,wBAAiB,EAAC,eAAe,CAAC;AAElB;EACjCD,UAAU,CAAC,MAAM,EAAE;IACjBE,OAAO,EAAE;EACX,CAAC,CAAC;AACJ;AAEAF,UAAU,CAAC,aAAa,EAAE;EACxBE,OAAO,EAAE,EAAE;EACXC,OAAO,EAAE,CAAC,cAAc,EAAE,MAAM,CAAC;EAEjCC,MAAM,EAAAC,MAAA,CAAAC,MAAA;IACJC,IAAI,EAAE;MACJC,QAAQ,EAAE,IAAAC,qBAAc,EAAC,YAAY;IACvC,CAAC;IACDC,YAAY,EAAE;MACZF,QAAQ,EAAE,IAAAG,kBAAW,EAAC,GAAGC,0BAAY;IACvC;EAAC,GACE,IAAAC,uBAAiB,EAAC,CAAC;AAE1B,CAAC,CAAC;AAEFb,UAAU,CAAC,uBAAuB,EAAE;EAClCG,OAAO,EAAE,CAAC,MAAM,CAAC;EACjBC,MAAM,EAAE;IACNG,IAAI,EAAE;MACJC,QAAQ,EAAE,IAAAM,sBAAe,EAAC,QAAQ;IACpC;EACF;AACF,CAAC,CAAC","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["_utils","require","PLACEHOLDERS","exports","PLACEHOLDERS_ALIAS","Declaration","Pattern","type","alias","ALIAS_KEYS","length","PLACEHOLDERS_FLIPPED_ALIAS","Object","keys","forEach","hasOwnProperty","call","push"],"sources":["../../src/definitions/placeholders.ts"],"sourcesContent":["import { ALIAS_KEYS } from \"./utils.ts\";\n\nexport const PLACEHOLDERS = [\n \"Identifier\",\n \"StringLiteral\",\n \"Expression\",\n \"Statement\",\n \"Declaration\",\n \"BlockStatement\",\n \"ClassBody\",\n \"Pattern\",\n] as const;\n\nexport const PLACEHOLDERS_ALIAS: Record<string, string[]> = {\n Declaration: [\"Statement\"],\n Pattern: [\"PatternLike\", \"LVal\"],\n};\n\nfor (const type of PLACEHOLDERS) {\n const alias = ALIAS_KEYS[type];\n if (alias?.length) PLACEHOLDERS_ALIAS[type] = alias;\n}\n\nexport const PLACEHOLDERS_FLIPPED_ALIAS: Record<string, string[]> = {};\n\nObject.keys(PLACEHOLDERS_ALIAS).forEach(type => {\n PLACEHOLDERS_ALIAS[type].forEach(alias => {\n if (!Object.hasOwn(PLACEHOLDERS_FLIPPED_ALIAS, alias)) {\n PLACEHOLDERS_FLIPPED_ALIAS[alias] = [];\n }\n PLACEHOLDERS_FLIPPED_ALIAS[alias].push(type);\n });\n});\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEO,MAAMC,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,CAC1B,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,SAAS,CACD;AAEH,MAAME,kBAA4C,GAAAD,OAAA,CAAAC,kBAAA,GAAG;EAC1DC,WAAW,EAAE,CAAC,WAAW,CAAC;EAC1BC,OAAO,EAAE,CAAC,aAAa,EAAE,MAAM;AACjC,CAAC;AAED,KAAK,MAAMC,IAAI,IAAIL,YAAY,EAAE;EAC/B,MAAMM,KAAK,GAAGC,iBAAU,CAACF,IAAI,CAAC;EAC9B,IAAIC,KAAK,YAALA,KAAK,CAAEE,MAAM,EAAEN,kBAAkB,CAACG,IAAI,CAAC,GAAGC,KAAK;AACrD;AAEO,MAAMG,0BAAoD,GAAAR,OAAA,CAAAQ,0BAAA,GAAG,CAAC,CAAC;AAEtEC,MAAM,CAACC,IAAI,CAACT,kBAAkB,CAAC,CAACU,OAAO,CAACP,IAAI,IAAI;EAC9CH,kBAAkB,CAACG,IAAI,CAAC,CAACO,OAAO,CAACN,KAAK,IAAI;IACxC,IAAI,CAACO,cAAA,CAAAC,IAAA,CAAcL,0BAA0B,EAAEH,KAAK,CAAC,EAAE;MACrDG,0BAA0B,CAACH,KAAK,CAAC,GAAG,EAAE;IACxC;IACAG,0BAA0B,CAACH,KAAK,CAAC,CAACS,IAAI,CAACV,IAAI,CAAC;EAC9C,CAAC,CAAC;AACJ,CAAC,CAAC"} {"version":3,"names":["_utils","require","PLACEHOLDERS","exports","PLACEHOLDERS_ALIAS","Declaration","Pattern","type","alias","ALIAS_KEYS","length","PLACEHOLDERS_FLIPPED_ALIAS","Object","keys","forEach","hasOwnProperty","call","push"],"sources":["../../src/definitions/placeholders.ts"],"sourcesContent":["import { ALIAS_KEYS } from \"./utils.ts\";\n\nexport const PLACEHOLDERS = [\n \"Identifier\",\n \"StringLiteral\",\n \"Expression\",\n \"Statement\",\n \"Declaration\",\n \"BlockStatement\",\n \"ClassBody\",\n \"Pattern\",\n] as const;\n\nexport const PLACEHOLDERS_ALIAS: Record<string, string[]> = {\n Declaration: [\"Statement\"],\n Pattern: [\"PatternLike\", \"LVal\"],\n};\n\nfor (const type of PLACEHOLDERS) {\n const alias = ALIAS_KEYS[type];\n if (alias?.length) PLACEHOLDERS_ALIAS[type] = alias;\n}\n\nexport const PLACEHOLDERS_FLIPPED_ALIAS: Record<string, string[]> = {};\n\nObject.keys(PLACEHOLDERS_ALIAS).forEach(type => {\n PLACEHOLDERS_ALIAS[type].forEach(alias => {\n if (!Object.hasOwn(PLACEHOLDERS_FLIPPED_ALIAS, alias)) {\n PLACEHOLDERS_FLIPPED_ALIAS[alias] = [];\n }\n PLACEHOLDERS_FLIPPED_ALIAS[alias].push(type);\n });\n});\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEO,MAAMC,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,CAC1B,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,SAAS,CACD;AAEH,MAAME,kBAA4C,GAAAD,OAAA,CAAAC,kBAAA,GAAG;EAC1DC,WAAW,EAAE,CAAC,WAAW,CAAC;EAC1BC,OAAO,EAAE,CAAC,aAAa,EAAE,MAAM;AACjC,CAAC;AAED,KAAK,MAAMC,IAAI,IAAIL,YAAY,EAAE;EAC/B,MAAMM,KAAK,GAAGC,iBAAU,CAACF,IAAI,CAAC;EAC9B,IAAIC,KAAK,YAALA,KAAK,CAAEE,MAAM,EAAEN,kBAAkB,CAACG,IAAI,CAAC,GAAGC,KAAK;AACrD;AAEO,MAAMG,0BAAoD,GAAAR,OAAA,CAAAQ,0BAAA,GAAG,CAAC,CAAC;AAEtEC,MAAM,CAACC,IAAI,CAACT,kBAAkB,CAAC,CAACU,OAAO,CAACP,IAAI,IAAI;EAC9CH,kBAAkB,CAACG,IAAI,CAAC,CAACO,OAAO,CAACN,KAAK,IAAI;IACxC,IAAI,CAACO,cAAA,CAAAC,IAAA,CAAcL,0BAA0B,EAAEH,KAAK,CAAC,EAAE;MACrDG,0BAA0B,CAACH,KAAK,CAAC,GAAG,EAAE;IACxC;IACAG,0BAA0B,CAACH,KAAK,CAAC,CAACS,IAAI,CAACV,IAAI,CAAC;EAC9C,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}

View File

@ -35,7 +35,7 @@ defineType("TSParameterProperty", {
optional: true optional: true
}, },
decorators: { decorators: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), validate: (0, _utils.arrayOfType)("Decorator"),
optional: true optional: true
} }
} }
@ -59,7 +59,7 @@ defineType("TSQualifiedName", {
}); });
const signatureDeclarationCommon = () => ({ const signatureDeclarationCommon = () => ({
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterDeclaration"), typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterDeclaration"),
["parameters"]: (0, _utils.validateArrayOfType)(["ArrayPattern", "Identifier", "ObjectPattern", "RestElement"]), ["parameters"]: (0, _utils.validateArrayOfType)("ArrayPattern", "Identifier", "ObjectPattern", "RestElement"),
["typeAnnotation"]: (0, _utils.validateOptionalType)("TSTypeAnnotation") ["typeAnnotation"]: (0, _utils.validateOptionalType)("TSTypeAnnotation")
}); });
const callConstructSignatureDeclaration = { const callConstructSignatureDeclaration = {
@ -83,6 +83,7 @@ defineType("TSPropertySignature", {
readonly: (0, _utils.validateOptional)(bool), readonly: (0, _utils.validateOptional)(bool),
typeAnnotation: (0, _utils.validateOptionalType)("TSTypeAnnotation"), typeAnnotation: (0, _utils.validateOptionalType)("TSTypeAnnotation"),
kind: { kind: {
optional: true,
validate: (0, _utils.assertOneOf)("get", "set") validate: (0, _utils.assertOneOf)("get", "set")
} }
}) })
@ -136,7 +137,7 @@ defineType("TSTypeReference", {
visitor: ["typeName", "typeParameters"], visitor: ["typeName", "typeParameters"],
fields: { fields: {
typeName: (0, _utils.validateType)("TSEntityName"), typeName: (0, _utils.validateType)("TSEntityName"),
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation") ["typeParameters"]: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation")
} }
}); });
defineType("TSTypePredicate", { defineType("TSTypePredicate", {
@ -144,7 +145,7 @@ defineType("TSTypePredicate", {
visitor: ["parameterName", "typeAnnotation"], visitor: ["parameterName", "typeAnnotation"],
builder: ["parameterName", "typeAnnotation", "asserts"], builder: ["parameterName", "typeAnnotation", "asserts"],
fields: { fields: {
parameterName: (0, _utils.validateType)(["Identifier", "TSThisType"]), parameterName: (0, _utils.validateType)("Identifier", "TSThisType"),
typeAnnotation: (0, _utils.validateOptionalType)("TSTypeAnnotation"), typeAnnotation: (0, _utils.validateOptionalType)("TSTypeAnnotation"),
asserts: (0, _utils.validateOptional)(bool) asserts: (0, _utils.validateOptional)(bool)
} }
@ -153,8 +154,8 @@ defineType("TSTypeQuery", {
aliases: ["TSType"], aliases: ["TSType"],
visitor: ["exprName", "typeParameters"], visitor: ["exprName", "typeParameters"],
fields: { fields: {
exprName: (0, _utils.validateType)(["TSEntityName", "TSImportType"]), exprName: (0, _utils.validateType)("TSEntityName", "TSImportType"),
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation") ["typeParameters"]: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation")
} }
}); });
defineType("TSTypeLiteral", { defineType("TSTypeLiteral", {
@ -175,7 +176,7 @@ defineType("TSTupleType", {
aliases: ["TSType"], aliases: ["TSType"],
visitor: ["elementTypes"], visitor: ["elementTypes"],
fields: { fields: {
elementTypes: (0, _utils.validateArrayOfType)(["TSType", "TSNamedTupleMember"]) elementTypes: (0, _utils.validateArrayOfType)("TSType", "TSNamedTupleMember")
} }
}); });
defineType("TSOptionalType", { defineType("TSOptionalType", {
@ -255,13 +256,29 @@ defineType("TSIndexedAccessType", {
}); });
defineType("TSMappedType", { defineType("TSMappedType", {
aliases: ["TSType"], aliases: ["TSType"],
visitor: ["typeParameter", "typeAnnotation", "nameType"], visitor: ["typeParameter", "nameType", "typeAnnotation"],
fields: { builder: ["typeParameter", "typeAnnotation", "nameType"],
fields: Object.assign({}, {
typeParameter: (0, _utils.validateType)("TSTypeParameter")
}, {
readonly: (0, _utils.validateOptional)((0, _utils.assertOneOf)(true, false, "+", "-")), readonly: (0, _utils.validateOptional)((0, _utils.assertOneOf)(true, false, "+", "-")),
typeParameter: (0, _utils.validateType)("TSTypeParameter"),
optional: (0, _utils.validateOptional)((0, _utils.assertOneOf)(true, false, "+", "-")), optional: (0, _utils.validateOptional)((0, _utils.assertOneOf)(true, false, "+", "-")),
typeAnnotation: (0, _utils.validateOptionalType)("TSType"), typeAnnotation: (0, _utils.validateOptionalType)("TSType"),
nameType: (0, _utils.validateOptionalType)("TSType") nameType: (0, _utils.validateOptionalType)("TSType")
})
});
defineType("TSTemplateLiteralType", {
aliases: ["TSType", "TSBaseType"],
visitor: ["quasis", "types"],
fields: {
quasis: (0, _utils.validateArrayOfType)("TemplateElement"),
types: {
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TSType")), function (node, key, val) {
if (node.quasis.length !== val.length + 1) {
throw new TypeError(`Number of ${node.type} quasis should be exactly one more than the number of types.\nExpected ${val.length + 1} quasis but got ${node.quasis.length}`);
}
})
}
} }
}); });
defineType("TSLiteralType", { defineType("TSLiteralType", {
@ -287,6 +304,7 @@ defineType("TSLiteralType", {
} }
} }
}); });
{
defineType("TSExpressionWithTypeArguments", { defineType("TSExpressionWithTypeArguments", {
aliases: ["TSType"], aliases: ["TSType"],
visitor: ["expression", "typeParameters"], visitor: ["expression", "typeParameters"],
@ -295,6 +313,7 @@ defineType("TSExpressionWithTypeArguments", {
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation") typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation")
} }
}); });
}
defineType("TSInterfaceDeclaration", { defineType("TSInterfaceDeclaration", {
aliases: ["Statement", "Declaration"], aliases: ["Statement", "Declaration"],
visitor: ["id", "typeParameters", "extends", "body"], visitor: ["id", "typeParameters", "extends", "body"],
@ -327,7 +346,7 @@ defineType("TSInstantiationExpression", {
visitor: ["expression", "typeParameters"], visitor: ["expression", "typeParameters"],
fields: { fields: {
expression: (0, _utils.validateType)("Expression"), expression: (0, _utils.validateType)("Expression"),
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation") ["typeParameters"]: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation")
} }
}); });
const TSTypeExpression = { const TSTypeExpression = {
@ -348,6 +367,13 @@ defineType("TSTypeAssertion", {
expression: (0, _utils.validateType)("Expression") expression: (0, _utils.validateType)("Expression")
} }
}); });
defineType("TSEnumBody", {
visitor: ["members"],
fields: {
members: (0, _utils.validateArrayOfType)("TSEnumMember")
}
});
{
defineType("TSEnumDeclaration", { defineType("TSEnumDeclaration", {
aliases: ["Statement", "Declaration"], aliases: ["Statement", "Declaration"],
visitor: ["id", "members"], visitor: ["id", "members"],
@ -356,25 +382,32 @@ defineType("TSEnumDeclaration", {
const: (0, _utils.validateOptional)(bool), const: (0, _utils.validateOptional)(bool),
id: (0, _utils.validateType)("Identifier"), id: (0, _utils.validateType)("Identifier"),
members: (0, _utils.validateArrayOfType)("TSEnumMember"), members: (0, _utils.validateArrayOfType)("TSEnumMember"),
initializer: (0, _utils.validateOptionalType)("Expression") initializer: (0, _utils.validateOptionalType)("Expression"),
body: (0, _utils.validateOptionalType)("TSEnumBody")
} }
}); });
}
defineType("TSEnumMember", { defineType("TSEnumMember", {
visitor: ["id", "initializer"], visitor: ["id", "initializer"],
fields: { fields: {
id: (0, _utils.validateType)(["Identifier", "StringLiteral"]), id: (0, _utils.validateType)("Identifier", "StringLiteral"),
initializer: (0, _utils.validateOptionalType)("Expression") initializer: (0, _utils.validateOptionalType)("Expression")
} }
}); });
defineType("TSModuleDeclaration", { defineType("TSModuleDeclaration", {
aliases: ["Statement", "Declaration"], aliases: ["Statement", "Declaration"],
visitor: ["id", "body"], visitor: ["id", "body"],
fields: { fields: Object.assign({
declare: (0, _utils.validateOptional)(bool), kind: {
global: (0, _utils.validateOptional)(bool), validate: (0, _utils.assertOneOf)("global", "module", "namespace")
id: (0, _utils.validateType)(["Identifier", "StringLiteral"]), },
body: (0, _utils.validateType)(["TSModuleBlock", "TSModuleDeclaration"]) declare: (0, _utils.validateOptional)(bool)
} }, {
global: (0, _utils.validateOptional)(bool)
}, {
id: (0, _utils.validateType)("Identifier", "StringLiteral"),
body: (0, _utils.validateType)("TSModuleBlock", "TSModuleDeclaration")
})
}); });
defineType("TSModuleBlock", { defineType("TSModuleBlock", {
aliases: ["Scopable", "Block", "BlockParent", "FunctionParent"], aliases: ["Scopable", "Block", "BlockParent", "FunctionParent"],
@ -385,29 +418,31 @@ defineType("TSModuleBlock", {
}); });
defineType("TSImportType", { defineType("TSImportType", {
aliases: ["TSType"], aliases: ["TSType"],
visitor: ["argument", "qualifier", "typeParameters"], builder: ["argument", "qualifier", "typeParameters"],
visitor: ["argument", "options", "qualifier", "typeParameters"],
fields: { fields: {
argument: (0, _utils.validateType)("StringLiteral"), argument: (0, _utils.validateType)("StringLiteral"),
qualifier: (0, _utils.validateOptionalType)("TSEntityName"), qualifier: (0, _utils.validateOptionalType)("TSEntityName"),
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation"), ["typeParameters"]: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation"),
options: { options: {
validate: (0, _utils.assertNodeType)("Expression"), validate: (0, _utils.assertNodeType)("ObjectExpression"),
optional: true optional: true
} }
} }
}); });
defineType("TSImportEqualsDeclaration", { defineType("TSImportEqualsDeclaration", {
aliases: ["Statement"], aliases: ["Statement", "Declaration"],
visitor: ["id", "moduleReference"], visitor: ["id", "moduleReference"],
fields: { fields: Object.assign({}, {
isExport: (0, _utils.validate)(bool), isExport: (0, _utils.validate)(bool)
}, {
id: (0, _utils.validateType)("Identifier"), id: (0, _utils.validateType)("Identifier"),
moduleReference: (0, _utils.validateType)(["TSEntityName", "TSExternalModuleReference"]), moduleReference: (0, _utils.validateType)("TSEntityName", "TSExternalModuleReference"),
importKind: { importKind: {
validate: (0, _utils.assertOneOf)("type", "value"), validate: (0, _utils.assertOneOf)("type", "value"),
optional: true optional: true
} }
} })
}); });
defineType("TSExternalModuleReference", { defineType("TSExternalModuleReference", {
visitor: ["expression"], visitor: ["expression"],
@ -447,17 +482,13 @@ defineType("TSTypeAnnotation", {
defineType("TSTypeParameterInstantiation", { defineType("TSTypeParameterInstantiation", {
visitor: ["params"], visitor: ["params"],
fields: { fields: {
params: { params: (0, _utils.validateArrayOfType)("TSType")
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TSType")))
}
} }
}); });
defineType("TSTypeParameterDeclaration", { defineType("TSTypeParameterDeclaration", {
visitor: ["params"], visitor: ["params"],
fields: { fields: {
params: { params: (0, _utils.validateArrayOfType)("TSTypeParameter")
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TSTypeParameter")))
}
} }
}); });
defineType("TSTypeParameter", { defineType("TSTypeParameter", {

File diff suppressed because one or more lines are too long

View File

@ -3,7 +3,7 @@
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
exports.VISITOR_KEYS = exports.NODE_PARENT_VALIDATIONS = exports.NODE_FIELDS = exports.FLIPPED_ALIAS_KEYS = exports.DEPRECATED_KEYS = exports.BUILDER_KEYS = exports.ALIAS_KEYS = void 0; exports.allExpandedTypes = exports.VISITOR_KEYS = exports.NODE_PARENT_VALIDATIONS = exports.NODE_FIELDS = exports.FLIPPED_ALIAS_KEYS = exports.DEPRECATED_KEYS = exports.BUILDER_KEYS = exports.ALIAS_KEYS = void 0;
exports.arrayOf = arrayOf; exports.arrayOf = arrayOf;
exports.arrayOfType = arrayOfType; exports.arrayOfType = arrayOfType;
exports.assertEach = assertEach; exports.assertEach = assertEach;
@ -16,7 +16,6 @@ exports.assertValueType = assertValueType;
exports.chain = chain; exports.chain = chain;
exports.default = defineType; exports.default = defineType;
exports.defineAliasedType = defineAliasedType; exports.defineAliasedType = defineAliasedType;
exports.typeIs = typeIs;
exports.validate = validate; exports.validate = validate;
exports.validateArrayOfType = validateArrayOfType; exports.validateArrayOfType = validateArrayOfType;
exports.validateOptional = validateOptional; exports.validateOptional = validateOptional;
@ -45,11 +44,8 @@ function validate(validate) {
validate validate
}; };
} }
function typeIs(typeName) { function validateType(...typeNames) {
return typeof typeName === "string" ? assertNodeType(typeName) : assertNodeType(...typeName); return validate(assertNodeType(...typeNames));
}
function validateType(typeName) {
return validate(typeIs(typeName));
} }
function validateOptional(validate) { function validateOptional(validate) {
return { return {
@ -57,29 +53,35 @@ function validateOptional(validate) {
optional: true optional: true
}; };
} }
function validateOptionalType(typeName) { function validateOptionalType(...typeNames) {
return { return {
validate: typeIs(typeName), validate: assertNodeType(...typeNames),
optional: true optional: true
}; };
} }
function arrayOf(elementType) { function arrayOf(elementType) {
return chain(assertValueType("array"), assertEach(elementType)); return chain(assertValueType("array"), assertEach(elementType));
} }
function arrayOfType(typeName) { function arrayOfType(...typeNames) {
return arrayOf(typeIs(typeName)); return arrayOf(assertNodeType(...typeNames));
} }
function validateArrayOfType(typeName) { function validateArrayOfType(...typeNames) {
return validate(arrayOfType(typeName)); return validate(arrayOfType(...typeNames));
} }
function assertEach(callback) { function assertEach(callback) {
const childValidator = process.env.BABEL_TYPES_8_BREAKING ? _validate.validateChild : () => {};
function validator(node, key, val) { function validator(node, key, val) {
if (!Array.isArray(val)) return; if (!Array.isArray(val)) return;
for (let i = 0; i < val.length; i++) { let i = 0;
const subkey = `${key}[${i}]`; const subKey = {
toString() {
return `${key}[${i}]`;
}
};
for (; i < val.length; i++) {
const v = val[i]; const v = val[i];
callback(node, subkey, v); callback(node, subKey, v);
if (process.env.BABEL_TYPES_8_BREAKING) (0, _validate.validateChild)(node, subkey, v); childValidator(node, subKey, v);
} }
} }
validator.each = callback; validator.each = callback;
@ -87,30 +89,46 @@ function assertEach(callback) {
} }
function assertOneOf(...values) { function assertOneOf(...values) {
function validate(node, key, val) { function validate(node, key, val) {
if (values.indexOf(val) < 0) { if (!values.includes(val)) {
throw new TypeError(`Property ${key} expected value to be one of ${JSON.stringify(values)} but got ${JSON.stringify(val)}`); throw new TypeError(`Property ${key} expected value to be one of ${JSON.stringify(values)} but got ${JSON.stringify(val)}`);
} }
} }
validate.oneOf = values; validate.oneOf = values;
return validate; return validate;
} }
const allExpandedTypes = exports.allExpandedTypes = [];
function assertNodeType(...types) { function assertNodeType(...types) {
const expandedTypes = new Set();
allExpandedTypes.push({
types,
set: expandedTypes
});
function validate(node, key, val) { function validate(node, key, val) {
const valType = val == null ? void 0 : val.type;
if (valType != null) {
if (expandedTypes.has(valType)) {
(0, _validate.validateChild)(node, key, val);
return;
}
if (valType === "Placeholder") {
for (const type of types) { for (const type of types) {
if ((0, _is.default)(type, val)) { if ((0, _is.default)(type, val)) {
(0, _validate.validateChild)(node, key, val); (0, _validate.validateChild)(node, key, val);
return; return;
} }
} }
throw new TypeError(`Property ${key} of ${node.type} expected node to be of a type ${JSON.stringify(types)} but instead got ${JSON.stringify(val == null ? void 0 : val.type)}`); }
}
throw new TypeError(`Property ${key} of ${node.type} expected node to be of a type ${JSON.stringify(types)} but instead got ${JSON.stringify(valType)}`);
} }
validate.oneOfNodeTypes = types; validate.oneOfNodeTypes = types;
return validate; return validate;
} }
function assertNodeOrValueType(...types) { function assertNodeOrValueType(...types) {
function validate(node, key, val) { function validate(node, key, val) {
const primitiveType = getType(val);
for (const type of types) { for (const type of types) {
if (getType(val) === type || (0, _is.default)(type, val)) { if (primitiveType === type || (0, _is.default)(type, val)) {
(0, _validate.validateChild)(node, key, val); (0, _validate.validateChild)(node, key, val);
return; return;
} }
@ -122,18 +140,19 @@ function assertNodeOrValueType(...types) {
} }
function assertValueType(type) { function assertValueType(type) {
function validate(node, key, val) { function validate(node, key, val) {
const valid = getType(val) === type; if (getType(val) === type) {
if (!valid) { return;
throw new TypeError(`Property ${key} expected type of ${type} but got ${getType(val)}`);
} }
throw new TypeError(`Property ${key} expected type of ${type} but got ${getType(val)}`);
} }
validate.type = type; validate.type = type;
return validate; return validate;
} }
function assertShape(shape) { function assertShape(shape) {
const keys = Object.keys(shape);
function validate(node, key, val) { function validate(node, key, val) {
const errors = []; const errors = [];
for (const property of Object.keys(shape)) { for (const property of keys) {
try { try {
(0, _validate.validateField)(node, property, val[property], shape[property]); (0, _validate.validateField)(node, property, val[property], shape[property]);
} catch (error) { } catch (error) {
@ -187,16 +206,16 @@ function chain(...fns) {
} }
return validate; return validate;
} }
const validTypeOpts = ["aliases", "builder", "deprecatedAlias", "fields", "inherits", "visitor", "validate"]; const validTypeOpts = new Set(["aliases", "builder", "deprecatedAlias", "fields", "inherits", "visitor", "validate"]);
const validFieldKeys = ["default", "optional", "deprecated", "validate"]; const validFieldKeys = new Set(["default", "optional", "deprecated", "validate"]);
const store = {}; const store = {};
function defineAliasedType(...aliases) { function defineAliasedType(...aliases) {
return (type, opts = {}) => { return (type, opts = {}) => {
let defined = opts.aliases; let defined = opts.aliases;
if (!defined) { if (!defined) {
var _store$opts$inherits$, _defined; var _store$opts$inherits$;
if (opts.inherits) defined = (_store$opts$inherits$ = store[opts.inherits].aliases) == null ? void 0 : _store$opts$inherits$.slice(); if (opts.inherits) defined = (_store$opts$inherits$ = store[opts.inherits].aliases) == null ? void 0 : _store$opts$inherits$.slice();
(_defined = defined) != null ? _defined : defined = []; defined != null ? defined : defined = [];
opts.aliases = defined; opts.aliases = defined;
} }
const additional = aliases.filter(a => !defined.includes(a)); const additional = aliases.filter(a => !defined.includes(a));
@ -230,7 +249,7 @@ function defineType(type, opts = {}) {
const aliases = opts.aliases || inherits.aliases || []; const aliases = opts.aliases || inherits.aliases || [];
const builder = opts.builder || inherits.builder || opts.visitor || []; const builder = opts.builder || inherits.builder || opts.visitor || [];
for (const k of Object.keys(opts)) { for (const k of Object.keys(opts)) {
if (validTypeOpts.indexOf(k) === -1) { if (!validTypeOpts.has(k)) {
throw new Error(`Unknown type option "${k}" on ${type}`); throw new Error(`Unknown type option "${k}" on ${type}`);
} }
} }
@ -242,7 +261,7 @@ function defineType(type, opts = {}) {
} }
for (const key of Object.keys(fields)) { for (const key of Object.keys(fields)) {
const field = fields[key]; const field = fields[key];
if (field.default !== undefined && builder.indexOf(key) === -1) { if (field.default !== undefined && !builder.includes(key)) {
field.optional = true; field.optional = true;
} }
if (field.default === undefined) { if (field.default === undefined) {
@ -251,7 +270,7 @@ function defineType(type, opts = {}) {
field.validate = assertValueType(getType(field.default)); field.validate = assertValueType(getType(field.default));
} }
for (const k of Object.keys(field)) { for (const k of Object.keys(field)) {
if (validFieldKeys.indexOf(k) === -1) { if (!validFieldKeys.has(k)) {
throw new Error(`Unknown field key "${k}" on ${type}.${key}`); throw new Error(`Unknown field key "${k}" on ${type}.${key}`);
} }
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -37,8 +37,10 @@ var _exportNames = {
removeProperties: true, removeProperties: true,
removePropertiesDeep: true, removePropertiesDeep: true,
removeTypeDuplicates: true, removeTypeDuplicates: true,
getAssignmentIdentifiers: true,
getBindingIdentifiers: true, getBindingIdentifiers: true,
getOuterBindingIdentifiers: true, getOuterBindingIdentifiers: true,
getFunctionName: true,
traverse: true, traverse: true,
traverseFast: true, traverseFast: true,
shallowEqual: true, shallowEqual: true,
@ -158,12 +160,24 @@ Object.defineProperty(exports, "ensureBlock", {
return _ensureBlock.default; return _ensureBlock.default;
} }
}); });
Object.defineProperty(exports, "getAssignmentIdentifiers", {
enumerable: true,
get: function () {
return _getAssignmentIdentifiers.default;
}
});
Object.defineProperty(exports, "getBindingIdentifiers", { Object.defineProperty(exports, "getBindingIdentifiers", {
enumerable: true, enumerable: true,
get: function () { get: function () {
return _getBindingIdentifiers.default; return _getBindingIdentifiers.default;
} }
}); });
Object.defineProperty(exports, "getFunctionName", {
enumerable: true,
get: function () {
return _getFunctionName.default;
}
});
Object.defineProperty(exports, "getOuterBindingIdentifiers", { Object.defineProperty(exports, "getOuterBindingIdentifiers", {
enumerable: true, enumerable: true,
get: function () { get: function () {
@ -418,30 +432,6 @@ Object.keys(_index).forEach(function (key) {
var _createTypeAnnotationBasedOnTypeof = require("./builders/flow/createTypeAnnotationBasedOnTypeof.js"); var _createTypeAnnotationBasedOnTypeof = require("./builders/flow/createTypeAnnotationBasedOnTypeof.js");
var _createFlowUnionType = require("./builders/flow/createFlowUnionType.js"); var _createFlowUnionType = require("./builders/flow/createFlowUnionType.js");
var _createTSUnionType = require("./builders/typescript/createTSUnionType.js"); var _createTSUnionType = require("./builders/typescript/createTSUnionType.js");
var _index2 = require("./builders/generated/index.js");
Object.keys(_index2).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _index2[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _index2[key];
}
});
});
var _uppercase = require("./builders/generated/uppercase.js");
Object.keys(_uppercase).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _uppercase[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _uppercase[key];
}
});
});
var _productions = require("./builders/productions.js"); var _productions = require("./builders/productions.js");
Object.keys(_productions).forEach(function (key) { Object.keys(_productions).forEach(function (key) {
if (key === "default" || key === "__esModule") return; if (key === "default" || key === "__esModule") return;
@ -454,6 +444,18 @@ Object.keys(_productions).forEach(function (key) {
} }
}); });
}); });
var _index2 = require("./builders/generated/index.js");
Object.keys(_index2).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _index2[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _index2[key];
}
});
});
var _cloneNode = require("./clone/cloneNode.js"); var _cloneNode = require("./clone/cloneNode.js");
var _clone = require("./clone/clone.js"); var _clone = require("./clone/clone.js");
var _cloneDeep = require("./clone/cloneDeep.js"); var _cloneDeep = require("./clone/cloneDeep.js");
@ -517,8 +519,10 @@ var _prependToMemberExpression = require("./modifications/prependToMemberExpress
var _removeProperties = require("./modifications/removeProperties.js"); var _removeProperties = require("./modifications/removeProperties.js");
var _removePropertiesDeep = require("./modifications/removePropertiesDeep.js"); var _removePropertiesDeep = require("./modifications/removePropertiesDeep.js");
var _removeTypeDuplicates = require("./modifications/flow/removeTypeDuplicates.js"); var _removeTypeDuplicates = require("./modifications/flow/removeTypeDuplicates.js");
var _getAssignmentIdentifiers = require("./retrievers/getAssignmentIdentifiers.js");
var _getBindingIdentifiers = require("./retrievers/getBindingIdentifiers.js"); var _getBindingIdentifiers = require("./retrievers/getBindingIdentifiers.js");
var _getOuterBindingIdentifiers = require("./retrievers/getOuterBindingIdentifiers.js"); var _getOuterBindingIdentifiers = require("./retrievers/getOuterBindingIdentifiers.js");
var _getFunctionName = require("./retrievers/getFunctionName.js");
var _traverse = require("./traverse/traverse.js"); var _traverse = require("./traverse/traverse.js");
Object.keys(_traverse).forEach(function (key) { Object.keys(_traverse).forEach(function (key) {
if (key === "default" || key === "__esModule") return; if (key === "default" || key === "__esModule") return;
@ -564,13 +568,17 @@ Object.keys(_index6).forEach(function (key) {
}); });
}); });
var _deprecationWarning = require("./utils/deprecationWarning.js"); var _deprecationWarning = require("./utils/deprecationWarning.js");
var _toSequenceExpression = require("./converters/toSequenceExpression.js");
const react = exports.react = { const react = exports.react = {
isReactComponent: _isReactComponent.default, isReactComponent: _isReactComponent.default,
isCompatTag: _isCompatTag.default, isCompatTag: _isCompatTag.default,
buildChildren: _buildChildren.default buildChildren: _buildChildren.default
}; };
{ {
exports.toSequenceExpression = require("./converters/toSequenceExpression.js").default; exports.toSequenceExpression = _toSequenceExpression.default;
}
if (process.env.BABEL_TYPES_8_BREAKING) {
console.warn("BABEL_TYPES_8_BREAKING is not supported anymore. Use the latest Babel 8.0.0 pre-release instead!");
} }
//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map

View File

@ -86,8 +86,8 @@ declare class BabelNodeBreakStatement extends BabelNode {
declare class BabelNodeCallExpression extends BabelNode { declare class BabelNodeCallExpression extends BabelNode {
type: "CallExpression"; type: "CallExpression";
callee: BabelNodeExpression | BabelNodeSuper | BabelNodeV8IntrinsicIdentifier; callee: BabelNodeExpression | BabelNodeSuper | BabelNodeV8IntrinsicIdentifier;
arguments: Array<BabelNodeExpression | BabelNodeSpreadElement | BabelNodeJSXNamespacedName | BabelNodeArgumentPlaceholder>; arguments: Array<BabelNodeExpression | BabelNodeSpreadElement | BabelNodeArgumentPlaceholder>;
optional?: true | false; optional?: boolean;
typeArguments?: BabelNodeTypeParameterInstantiation; typeArguments?: BabelNodeTypeParameterInstantiation;
typeParameters?: BabelNodeTSTypeParameterInstantiation; typeParameters?: BabelNodeTSTypeParameterInstantiation;
} }
@ -234,14 +234,14 @@ declare class BabelNodeMemberExpression extends BabelNode {
object: BabelNodeExpression | BabelNodeSuper; object: BabelNodeExpression | BabelNodeSuper;
property: BabelNodeExpression | BabelNodeIdentifier | BabelNodePrivateName; property: BabelNodeExpression | BabelNodeIdentifier | BabelNodePrivateName;
computed?: boolean; computed?: boolean;
optional?: true | false; optional?: boolean;
} }
declare class BabelNodeNewExpression extends BabelNode { declare class BabelNodeNewExpression extends BabelNode {
type: "NewExpression"; type: "NewExpression";
callee: BabelNodeExpression | BabelNodeSuper | BabelNodeV8IntrinsicIdentifier; callee: BabelNodeExpression | BabelNodeSuper | BabelNodeV8IntrinsicIdentifier;
arguments: Array<BabelNodeExpression | BabelNodeSpreadElement | BabelNodeJSXNamespacedName | BabelNodeArgumentPlaceholder>; arguments: Array<BabelNodeExpression | BabelNodeSpreadElement | BabelNodeArgumentPlaceholder>;
optional?: true | false; optional?: boolean;
typeArguments?: BabelNodeTypeParameterInstantiation; typeArguments?: BabelNodeTypeParameterInstantiation;
typeParameters?: BabelNodeTSTypeParameterInstantiation; typeParameters?: BabelNodeTSTypeParameterInstantiation;
} }
@ -601,7 +601,7 @@ declare class BabelNodeOptionalMemberExpression extends BabelNode {
declare class BabelNodeOptionalCallExpression extends BabelNode { declare class BabelNodeOptionalCallExpression extends BabelNode {
type: "OptionalCallExpression"; type: "OptionalCallExpression";
callee: BabelNodeExpression; callee: BabelNodeExpression;
arguments: Array<BabelNodeExpression | BabelNodeSpreadElement | BabelNodeJSXNamespacedName | BabelNodeArgumentPlaceholder>; arguments: Array<BabelNodeExpression | BabelNodeSpreadElement | BabelNodeArgumentPlaceholder>;
optional: boolean; optional: boolean;
typeArguments?: BabelNodeTypeParameterInstantiation; typeArguments?: BabelNodeTypeParameterInstantiation;
typeParameters?: BabelNodeTSTypeParameterInstantiation; typeParameters?: BabelNodeTSTypeParameterInstantiation;
@ -647,6 +647,7 @@ declare class BabelNodeClassPrivateProperty extends BabelNode {
value?: BabelNodeExpression; value?: BabelNodeExpression;
decorators?: Array<BabelNodeDecorator>; decorators?: Array<BabelNodeDecorator>;
definite?: boolean; definite?: boolean;
optional?: boolean;
readonly?: boolean; readonly?: boolean;
typeAnnotation?: BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop; typeAnnotation?: BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop;
variance?: BabelNodeVariance; variance?: BabelNodeVariance;
@ -681,6 +682,12 @@ declare class BabelNodeStaticBlock extends BabelNode {
body: Array<BabelNodeStatement>; body: Array<BabelNodeStatement>;
} }
declare class BabelNodeImportAttribute extends BabelNode {
type: "ImportAttribute";
key: BabelNodeIdentifier | BabelNodeStringLiteral;
value: BabelNodeStringLiteral;
}
declare class BabelNodeAnyTypeAnnotation extends BabelNode { declare class BabelNodeAnyTypeAnnotation extends BabelNode {
type: "AnyTypeAnnotation"; type: "AnyTypeAnnotation";
} }
@ -767,11 +774,15 @@ declare class BabelNodeDeclareExportDeclaration extends BabelNode {
declaration?: BabelNodeFlow; declaration?: BabelNodeFlow;
specifiers?: Array<BabelNodeExportSpecifier | BabelNodeExportNamespaceSpecifier>; specifiers?: Array<BabelNodeExportSpecifier | BabelNodeExportNamespaceSpecifier>;
source?: BabelNodeStringLiteral; source?: BabelNodeStringLiteral;
attributes?: Array<BabelNodeImportAttribute>;
assertions?: Array<BabelNodeImportAttribute>;
} }
declare class BabelNodeDeclareExportAllDeclaration extends BabelNode { declare class BabelNodeDeclareExportAllDeclaration extends BabelNode {
type: "DeclareExportAllDeclaration"; type: "DeclareExportAllDeclaration";
source: BabelNodeStringLiteral; source: BabelNodeStringLiteral;
attributes?: Array<BabelNodeImportAttribute>;
assertions?: Array<BabelNodeImportAttribute>;
exportKind?: "type" | "value"; exportKind?: "type" | "value";
} }
@ -1115,7 +1126,8 @@ declare class BabelNodeJSXOpeningElement extends BabelNode {
name: BabelNodeJSXIdentifier | BabelNodeJSXMemberExpression | BabelNodeJSXNamespacedName; name: BabelNodeJSXIdentifier | BabelNodeJSXMemberExpression | BabelNodeJSXNamespacedName;
attributes: Array<BabelNodeJSXAttribute | BabelNodeJSXSpreadAttribute>; attributes: Array<BabelNodeJSXAttribute | BabelNodeJSXSpreadAttribute>;
selfClosing?: boolean; selfClosing?: boolean;
typeParameters?: BabelNodeTypeParameterInstantiation | BabelNodeTSTypeParameterInstantiation; typeArguments?: BabelNodeTypeParameterInstantiation;
typeParameters?: BabelNodeTSTypeParameterInstantiation;
} }
declare class BabelNodeJSXSpreadAttribute extends BabelNode { declare class BabelNodeJSXSpreadAttribute extends BabelNode {
@ -1151,6 +1163,9 @@ declare class BabelNodePlaceholder extends BabelNode {
type: "Placeholder"; type: "Placeholder";
expectedNode: "Identifier" | "StringLiteral" | "Expression" | "Statement" | "Declaration" | "BlockStatement" | "ClassBody" | "Pattern"; expectedNode: "Identifier" | "StringLiteral" | "Expression" | "Statement" | "Declaration" | "BlockStatement" | "ClassBody" | "Pattern";
name: BabelNodeIdentifier; name: BabelNodeIdentifier;
decorators?: Array<BabelNodeDecorator>;
optional?: boolean;
typeAnnotation?: BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop;
} }
declare class BabelNodeV8IntrinsicIdentifier extends BabelNode { declare class BabelNodeV8IntrinsicIdentifier extends BabelNode {
@ -1168,12 +1183,6 @@ declare class BabelNodeBindExpression extends BabelNode {
callee: BabelNodeExpression; callee: BabelNodeExpression;
} }
declare class BabelNodeImportAttribute extends BabelNode {
type: "ImportAttribute";
key: BabelNodeIdentifier | BabelNodeStringLiteral;
value: BabelNodeStringLiteral;
}
declare class BabelNodeDecorator extends BabelNode { declare class BabelNodeDecorator extends BabelNode {
type: "Decorator"; type: "Decorator";
expression: BabelNodeExpression; expression: BabelNodeExpression;
@ -1291,7 +1300,7 @@ declare class BabelNodeTSPropertySignature extends BabelNode {
key: BabelNodeExpression; key: BabelNodeExpression;
typeAnnotation?: BabelNodeTSTypeAnnotation; typeAnnotation?: BabelNodeTSTypeAnnotation;
computed?: boolean; computed?: boolean;
kind: "get" | "set"; kind?: "get" | "set";
optional?: boolean; optional?: boolean;
readonly?: boolean; readonly?: boolean;
} }
@ -1485,6 +1494,12 @@ declare class BabelNodeTSMappedType extends BabelNode {
readonly?: true | false | "+" | "-"; readonly?: true | false | "+" | "-";
} }
declare class BabelNodeTSTemplateLiteralType extends BabelNode {
type: "TSTemplateLiteralType";
quasis: Array<BabelNodeTemplateElement>;
types: Array<BabelNodeTSType>;
}
declare class BabelNodeTSLiteralType extends BabelNode { declare class BabelNodeTSLiteralType extends BabelNode {
type: "TSLiteralType"; type: "TSLiteralType";
literal: BabelNodeNumericLiteral | BabelNodeStringLiteral | BabelNodeBooleanLiteral | BabelNodeBigIntLiteral | BabelNodeTemplateLiteral | BabelNodeUnaryExpression; literal: BabelNodeNumericLiteral | BabelNodeStringLiteral | BabelNodeBooleanLiteral | BabelNodeBigIntLiteral | BabelNodeTemplateLiteral | BabelNodeUnaryExpression;
@ -1541,10 +1556,16 @@ declare class BabelNodeTSTypeAssertion extends BabelNode {
expression: BabelNodeExpression; expression: BabelNodeExpression;
} }
declare class BabelNodeTSEnumBody extends BabelNode {
type: "TSEnumBody";
members: Array<BabelNodeTSEnumMember>;
}
declare class BabelNodeTSEnumDeclaration extends BabelNode { declare class BabelNodeTSEnumDeclaration extends BabelNode {
type: "TSEnumDeclaration"; type: "TSEnumDeclaration";
id: BabelNodeIdentifier; id: BabelNodeIdentifier;
members: Array<BabelNodeTSEnumMember>; members: Array<BabelNodeTSEnumMember>;
body?: BabelNodeTSEnumBody;
declare?: boolean; declare?: boolean;
initializer?: BabelNodeExpression; initializer?: BabelNodeExpression;
} }
@ -1561,6 +1582,7 @@ declare class BabelNodeTSModuleDeclaration extends BabelNode {
body: BabelNodeTSModuleBlock | BabelNodeTSModuleDeclaration; body: BabelNodeTSModuleBlock | BabelNodeTSModuleDeclaration;
declare?: boolean; declare?: boolean;
global?: boolean; global?: boolean;
kind: "global" | "module" | "namespace";
} }
declare class BabelNodeTSModuleBlock extends BabelNode { declare class BabelNodeTSModuleBlock extends BabelNode {
@ -1573,7 +1595,7 @@ declare class BabelNodeTSImportType extends BabelNode {
argument: BabelNodeStringLiteral; argument: BabelNodeStringLiteral;
qualifier?: BabelNodeTSEntityName; qualifier?: BabelNodeTSEntityName;
typeParameters?: BabelNodeTSTypeParameterInstantiation; typeParameters?: BabelNodeTSTypeParameterInstantiation;
options?: BabelNodeExpression; options?: BabelNodeObjectExpression;
} }
declare class BabelNodeTSImportEqualsDeclaration extends BabelNode { declare class BabelNodeTSImportEqualsDeclaration extends BabelNode {
@ -1626,7 +1648,7 @@ declare class BabelNodeTSTypeParameter extends BabelNode {
out?: boolean; out?: boolean;
} }
type BabelNodeStandardized = BabelNodeArrayExpression | BabelNodeAssignmentExpression | BabelNodeBinaryExpression | BabelNodeInterpreterDirective | BabelNodeDirective | BabelNodeDirectiveLiteral | BabelNodeBlockStatement | BabelNodeBreakStatement | BabelNodeCallExpression | BabelNodeCatchClause | BabelNodeConditionalExpression | BabelNodeContinueStatement | BabelNodeDebuggerStatement | BabelNodeDoWhileStatement | BabelNodeEmptyStatement | BabelNodeExpressionStatement | BabelNodeFile | BabelNodeForInStatement | BabelNodeForStatement | BabelNodeFunctionDeclaration | BabelNodeFunctionExpression | BabelNodeIdentifier | BabelNodeIfStatement | BabelNodeLabeledStatement | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeNullLiteral | BabelNodeBooleanLiteral | BabelNodeRegExpLiteral | BabelNodeLogicalExpression | BabelNodeMemberExpression | BabelNodeNewExpression | BabelNodeProgram | BabelNodeObjectExpression | BabelNodeObjectMethod | BabelNodeObjectProperty | BabelNodeRestElement | BabelNodeReturnStatement | BabelNodeSequenceExpression | BabelNodeParenthesizedExpression | BabelNodeSwitchCase | BabelNodeSwitchStatement | BabelNodeThisExpression | BabelNodeThrowStatement | BabelNodeTryStatement | BabelNodeUnaryExpression | BabelNodeUpdateExpression | BabelNodeVariableDeclaration | BabelNodeVariableDeclarator | BabelNodeWhileStatement | BabelNodeWithStatement | BabelNodeAssignmentPattern | BabelNodeArrayPattern | BabelNodeArrowFunctionExpression | BabelNodeClassBody | BabelNodeClassExpression | BabelNodeClassDeclaration | BabelNodeExportAllDeclaration | BabelNodeExportDefaultDeclaration | BabelNodeExportNamedDeclaration | BabelNodeExportSpecifier | BabelNodeForOfStatement | BabelNodeImportDeclaration | BabelNodeImportDefaultSpecifier | BabelNodeImportNamespaceSpecifier | BabelNodeImportSpecifier | BabelNodeImportExpression | BabelNodeMetaProperty | BabelNodeClassMethod | BabelNodeObjectPattern | BabelNodeSpreadElement | BabelNodeSuper | BabelNodeTaggedTemplateExpression | BabelNodeTemplateElement | BabelNodeTemplateLiteral | BabelNodeYieldExpression | BabelNodeAwaitExpression | BabelNodeImport | BabelNodeBigIntLiteral | BabelNodeExportNamespaceSpecifier | BabelNodeOptionalMemberExpression | BabelNodeOptionalCallExpression | BabelNodeClassProperty | BabelNodeClassAccessorProperty | BabelNodeClassPrivateProperty | BabelNodeClassPrivateMethod | BabelNodePrivateName | BabelNodeStaticBlock; type BabelNodeStandardized = BabelNodeArrayExpression | BabelNodeAssignmentExpression | BabelNodeBinaryExpression | BabelNodeInterpreterDirective | BabelNodeDirective | BabelNodeDirectiveLiteral | BabelNodeBlockStatement | BabelNodeBreakStatement | BabelNodeCallExpression | BabelNodeCatchClause | BabelNodeConditionalExpression | BabelNodeContinueStatement | BabelNodeDebuggerStatement | BabelNodeDoWhileStatement | BabelNodeEmptyStatement | BabelNodeExpressionStatement | BabelNodeFile | BabelNodeForInStatement | BabelNodeForStatement | BabelNodeFunctionDeclaration | BabelNodeFunctionExpression | BabelNodeIdentifier | BabelNodeIfStatement | BabelNodeLabeledStatement | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeNullLiteral | BabelNodeBooleanLiteral | BabelNodeRegExpLiteral | BabelNodeLogicalExpression | BabelNodeMemberExpression | BabelNodeNewExpression | BabelNodeProgram | BabelNodeObjectExpression | BabelNodeObjectMethod | BabelNodeObjectProperty | BabelNodeRestElement | BabelNodeReturnStatement | BabelNodeSequenceExpression | BabelNodeParenthesizedExpression | BabelNodeSwitchCase | BabelNodeSwitchStatement | BabelNodeThisExpression | BabelNodeThrowStatement | BabelNodeTryStatement | BabelNodeUnaryExpression | BabelNodeUpdateExpression | BabelNodeVariableDeclaration | BabelNodeVariableDeclarator | BabelNodeWhileStatement | BabelNodeWithStatement | BabelNodeAssignmentPattern | BabelNodeArrayPattern | BabelNodeArrowFunctionExpression | BabelNodeClassBody | BabelNodeClassExpression | BabelNodeClassDeclaration | BabelNodeExportAllDeclaration | BabelNodeExportDefaultDeclaration | BabelNodeExportNamedDeclaration | BabelNodeExportSpecifier | BabelNodeForOfStatement | BabelNodeImportDeclaration | BabelNodeImportDefaultSpecifier | BabelNodeImportNamespaceSpecifier | BabelNodeImportSpecifier | BabelNodeImportExpression | BabelNodeMetaProperty | BabelNodeClassMethod | BabelNodeObjectPattern | BabelNodeSpreadElement | BabelNodeSuper | BabelNodeTaggedTemplateExpression | BabelNodeTemplateElement | BabelNodeTemplateLiteral | BabelNodeYieldExpression | BabelNodeAwaitExpression | BabelNodeImport | BabelNodeBigIntLiteral | BabelNodeExportNamespaceSpecifier | BabelNodeOptionalMemberExpression | BabelNodeOptionalCallExpression | BabelNodeClassProperty | BabelNodeClassAccessorProperty | BabelNodeClassPrivateProperty | BabelNodeClassPrivateMethod | BabelNodePrivateName | BabelNodeStaticBlock | BabelNodeImportAttribute;
type BabelNodeExpression = BabelNodeArrayExpression | BabelNodeAssignmentExpression | BabelNodeBinaryExpression | BabelNodeCallExpression | BabelNodeConditionalExpression | BabelNodeFunctionExpression | BabelNodeIdentifier | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeNullLiteral | BabelNodeBooleanLiteral | BabelNodeRegExpLiteral | BabelNodeLogicalExpression | BabelNodeMemberExpression | BabelNodeNewExpression | BabelNodeObjectExpression | BabelNodeSequenceExpression | BabelNodeParenthesizedExpression | BabelNodeThisExpression | BabelNodeUnaryExpression | BabelNodeUpdateExpression | BabelNodeArrowFunctionExpression | BabelNodeClassExpression | BabelNodeImportExpression | BabelNodeMetaProperty | BabelNodeSuper | BabelNodeTaggedTemplateExpression | BabelNodeTemplateLiteral | BabelNodeYieldExpression | BabelNodeAwaitExpression | BabelNodeImport | BabelNodeBigIntLiteral | BabelNodeOptionalMemberExpression | BabelNodeOptionalCallExpression | BabelNodeTypeCastExpression | BabelNodeJSXElement | BabelNodeJSXFragment | BabelNodeBindExpression | BabelNodeDoExpression | BabelNodeRecordExpression | BabelNodeTupleExpression | BabelNodeDecimalLiteral | BabelNodeModuleExpression | BabelNodeTopicReference | BabelNodePipelineTopicExpression | BabelNodePipelineBareFunction | BabelNodePipelinePrimaryTopicReference | BabelNodeTSInstantiationExpression | BabelNodeTSAsExpression | BabelNodeTSSatisfiesExpression | BabelNodeTSTypeAssertion | BabelNodeTSNonNullExpression; type BabelNodeExpression = BabelNodeArrayExpression | BabelNodeAssignmentExpression | BabelNodeBinaryExpression | BabelNodeCallExpression | BabelNodeConditionalExpression | BabelNodeFunctionExpression | BabelNodeIdentifier | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeNullLiteral | BabelNodeBooleanLiteral | BabelNodeRegExpLiteral | BabelNodeLogicalExpression | BabelNodeMemberExpression | BabelNodeNewExpression | BabelNodeObjectExpression | BabelNodeSequenceExpression | BabelNodeParenthesizedExpression | BabelNodeThisExpression | BabelNodeUnaryExpression | BabelNodeUpdateExpression | BabelNodeArrowFunctionExpression | BabelNodeClassExpression | BabelNodeImportExpression | BabelNodeMetaProperty | BabelNodeSuper | BabelNodeTaggedTemplateExpression | BabelNodeTemplateLiteral | BabelNodeYieldExpression | BabelNodeAwaitExpression | BabelNodeImport | BabelNodeBigIntLiteral | BabelNodeOptionalMemberExpression | BabelNodeOptionalCallExpression | BabelNodeTypeCastExpression | BabelNodeJSXElement | BabelNodeJSXFragment | BabelNodeBindExpression | BabelNodeDoExpression | BabelNodeRecordExpression | BabelNodeTupleExpression | BabelNodeDecimalLiteral | BabelNodeModuleExpression | BabelNodeTopicReference | BabelNodePipelineTopicExpression | BabelNodePipelineBareFunction | BabelNodePipelinePrimaryTopicReference | BabelNodeTSInstantiationExpression | BabelNodeTSAsExpression | BabelNodeTSSatisfiesExpression | BabelNodeTSTypeAssertion | BabelNodeTSNonNullExpression;
type BabelNodeBinary = BabelNodeBinaryExpression | BabelNodeLogicalExpression; type BabelNodeBinary = BabelNodeBinaryExpression | BabelNodeLogicalExpression;
type BabelNodeScopable = BabelNodeBlockStatement | BabelNodeCatchClause | BabelNodeDoWhileStatement | BabelNodeForInStatement | BabelNodeForStatement | BabelNodeFunctionDeclaration | BabelNodeFunctionExpression | BabelNodeProgram | BabelNodeObjectMethod | BabelNodeSwitchStatement | BabelNodeWhileStatement | BabelNodeArrowFunctionExpression | BabelNodeClassExpression | BabelNodeClassDeclaration | BabelNodeForOfStatement | BabelNodeClassMethod | BabelNodeClassPrivateMethod | BabelNodeStaticBlock | BabelNodeTSModuleBlock; type BabelNodeScopable = BabelNodeBlockStatement | BabelNodeCatchClause | BabelNodeDoWhileStatement | BabelNodeForInStatement | BabelNodeForStatement | BabelNodeFunctionDeclaration | BabelNodeFunctionExpression | BabelNodeProgram | BabelNodeObjectMethod | BabelNodeSwitchStatement | BabelNodeWhileStatement | BabelNodeArrowFunctionExpression | BabelNodeClassExpression | BabelNodeClassDeclaration | BabelNodeForOfStatement | BabelNodeClassMethod | BabelNodeClassPrivateMethod | BabelNodeStaticBlock | BabelNodeTSModuleBlock;
@ -1644,7 +1666,7 @@ type BabelNodeForXStatement = BabelNodeForInStatement | BabelNodeForOfStatement;
type BabelNodeFunction = BabelNodeFunctionDeclaration | BabelNodeFunctionExpression | BabelNodeObjectMethod | BabelNodeArrowFunctionExpression | BabelNodeClassMethod | BabelNodeClassPrivateMethod; type BabelNodeFunction = BabelNodeFunctionDeclaration | BabelNodeFunctionExpression | BabelNodeObjectMethod | BabelNodeArrowFunctionExpression | BabelNodeClassMethod | BabelNodeClassPrivateMethod;
type BabelNodeFunctionParent = BabelNodeFunctionDeclaration | BabelNodeFunctionExpression | BabelNodeObjectMethod | BabelNodeArrowFunctionExpression | BabelNodeClassMethod | BabelNodeClassPrivateMethod | BabelNodeStaticBlock | BabelNodeTSModuleBlock; type BabelNodeFunctionParent = BabelNodeFunctionDeclaration | BabelNodeFunctionExpression | BabelNodeObjectMethod | BabelNodeArrowFunctionExpression | BabelNodeClassMethod | BabelNodeClassPrivateMethod | BabelNodeStaticBlock | BabelNodeTSModuleBlock;
type BabelNodePureish = BabelNodeFunctionDeclaration | BabelNodeFunctionExpression | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeNullLiteral | BabelNodeBooleanLiteral | BabelNodeRegExpLiteral | BabelNodeArrowFunctionExpression | BabelNodeBigIntLiteral | BabelNodeDecimalLiteral; type BabelNodePureish = BabelNodeFunctionDeclaration | BabelNodeFunctionExpression | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeNullLiteral | BabelNodeBooleanLiteral | BabelNodeRegExpLiteral | BabelNodeArrowFunctionExpression | BabelNodeBigIntLiteral | BabelNodeDecimalLiteral;
type BabelNodeDeclaration = BabelNodeFunctionDeclaration | BabelNodeVariableDeclaration | BabelNodeClassDeclaration | BabelNodeExportAllDeclaration | BabelNodeExportDefaultDeclaration | BabelNodeExportNamedDeclaration | BabelNodeImportDeclaration | BabelNodeDeclareClass | BabelNodeDeclareFunction | BabelNodeDeclareInterface | BabelNodeDeclareModule | BabelNodeDeclareModuleExports | BabelNodeDeclareTypeAlias | BabelNodeDeclareOpaqueType | BabelNodeDeclareVariable | BabelNodeDeclareExportDeclaration | BabelNodeDeclareExportAllDeclaration | BabelNodeInterfaceDeclaration | BabelNodeOpaqueType | BabelNodeTypeAlias | BabelNodeEnumDeclaration | BabelNodeTSDeclareFunction | BabelNodeTSInterfaceDeclaration | BabelNodeTSTypeAliasDeclaration | BabelNodeTSEnumDeclaration | BabelNodeTSModuleDeclaration; type BabelNodeDeclaration = BabelNodeFunctionDeclaration | BabelNodeVariableDeclaration | BabelNodeClassDeclaration | BabelNodeExportAllDeclaration | BabelNodeExportDefaultDeclaration | BabelNodeExportNamedDeclaration | BabelNodeImportDeclaration | BabelNodeDeclareClass | BabelNodeDeclareFunction | BabelNodeDeclareInterface | BabelNodeDeclareModule | BabelNodeDeclareModuleExports | BabelNodeDeclareTypeAlias | BabelNodeDeclareOpaqueType | BabelNodeDeclareVariable | BabelNodeDeclareExportDeclaration | BabelNodeDeclareExportAllDeclaration | BabelNodeInterfaceDeclaration | BabelNodeOpaqueType | BabelNodeTypeAlias | BabelNodeEnumDeclaration | BabelNodeTSDeclareFunction | BabelNodeTSInterfaceDeclaration | BabelNodeTSTypeAliasDeclaration | BabelNodeTSEnumDeclaration | BabelNodeTSModuleDeclaration | BabelNodeTSImportEqualsDeclaration;
type BabelNodePatternLike = BabelNodeIdentifier | BabelNodeRestElement | BabelNodeAssignmentPattern | BabelNodeArrayPattern | BabelNodeObjectPattern | BabelNodeTSAsExpression | BabelNodeTSSatisfiesExpression | BabelNodeTSTypeAssertion | BabelNodeTSNonNullExpression; type BabelNodePatternLike = BabelNodeIdentifier | BabelNodeRestElement | BabelNodeAssignmentPattern | BabelNodeArrayPattern | BabelNodeObjectPattern | BabelNodeTSAsExpression | BabelNodeTSSatisfiesExpression | BabelNodeTSTypeAssertion | BabelNodeTSNonNullExpression;
type BabelNodeLVal = BabelNodeIdentifier | BabelNodeMemberExpression | BabelNodeRestElement | BabelNodeAssignmentPattern | BabelNodeArrayPattern | BabelNodeObjectPattern | BabelNodeTSParameterProperty | BabelNodeTSAsExpression | BabelNodeTSSatisfiesExpression | BabelNodeTSTypeAssertion | BabelNodeTSNonNullExpression; type BabelNodeLVal = BabelNodeIdentifier | BabelNodeMemberExpression | BabelNodeRestElement | BabelNodeAssignmentPattern | BabelNodeArrayPattern | BabelNodeObjectPattern | BabelNodeTSParameterProperty | BabelNodeTSAsExpression | BabelNodeTSSatisfiesExpression | BabelNodeTSTypeAssertion | BabelNodeTSNonNullExpression;
type BabelNodeTSEntityName = BabelNodeIdentifier | BabelNodeTSQualifiedName; type BabelNodeTSEntityName = BabelNodeIdentifier | BabelNodeTSQualifiedName;
@ -1671,10 +1693,10 @@ type BabelNodeEnumBody = BabelNodeEnumBooleanBody | BabelNodeEnumNumberBody | Ba
type BabelNodeEnumMember = BabelNodeEnumBooleanMember | BabelNodeEnumNumberMember | BabelNodeEnumStringMember | BabelNodeEnumDefaultedMember; type BabelNodeEnumMember = BabelNodeEnumBooleanMember | BabelNodeEnumNumberMember | BabelNodeEnumStringMember | BabelNodeEnumDefaultedMember;
type BabelNodeJSX = BabelNodeJSXAttribute | BabelNodeJSXClosingElement | BabelNodeJSXElement | BabelNodeJSXEmptyExpression | BabelNodeJSXExpressionContainer | BabelNodeJSXSpreadChild | BabelNodeJSXIdentifier | BabelNodeJSXMemberExpression | BabelNodeJSXNamespacedName | BabelNodeJSXOpeningElement | BabelNodeJSXSpreadAttribute | BabelNodeJSXText | BabelNodeJSXFragment | BabelNodeJSXOpeningFragment | BabelNodeJSXClosingFragment; type BabelNodeJSX = BabelNodeJSXAttribute | BabelNodeJSXClosingElement | BabelNodeJSXElement | BabelNodeJSXEmptyExpression | BabelNodeJSXExpressionContainer | BabelNodeJSXSpreadChild | BabelNodeJSXIdentifier | BabelNodeJSXMemberExpression | BabelNodeJSXNamespacedName | BabelNodeJSXOpeningElement | BabelNodeJSXSpreadAttribute | BabelNodeJSXText | BabelNodeJSXFragment | BabelNodeJSXOpeningFragment | BabelNodeJSXClosingFragment;
type BabelNodeMiscellaneous = BabelNodeNoop | BabelNodePlaceholder | BabelNodeV8IntrinsicIdentifier; type BabelNodeMiscellaneous = BabelNodeNoop | BabelNodePlaceholder | BabelNodeV8IntrinsicIdentifier;
type BabelNodeTypeScript = BabelNodeTSParameterProperty | BabelNodeTSDeclareFunction | BabelNodeTSDeclareMethod | BabelNodeTSQualifiedName | BabelNodeTSCallSignatureDeclaration | BabelNodeTSConstructSignatureDeclaration | BabelNodeTSPropertySignature | BabelNodeTSMethodSignature | BabelNodeTSIndexSignature | BabelNodeTSAnyKeyword | BabelNodeTSBooleanKeyword | BabelNodeTSBigIntKeyword | BabelNodeTSIntrinsicKeyword | BabelNodeTSNeverKeyword | BabelNodeTSNullKeyword | BabelNodeTSNumberKeyword | BabelNodeTSObjectKeyword | BabelNodeTSStringKeyword | BabelNodeTSSymbolKeyword | BabelNodeTSUndefinedKeyword | BabelNodeTSUnknownKeyword | BabelNodeTSVoidKeyword | BabelNodeTSThisType | BabelNodeTSFunctionType | BabelNodeTSConstructorType | BabelNodeTSTypeReference | BabelNodeTSTypePredicate | BabelNodeTSTypeQuery | BabelNodeTSTypeLiteral | BabelNodeTSArrayType | BabelNodeTSTupleType | BabelNodeTSOptionalType | BabelNodeTSRestType | BabelNodeTSNamedTupleMember | BabelNodeTSUnionType | BabelNodeTSIntersectionType | BabelNodeTSConditionalType | BabelNodeTSInferType | BabelNodeTSParenthesizedType | BabelNodeTSTypeOperator | BabelNodeTSIndexedAccessType | BabelNodeTSMappedType | BabelNodeTSLiteralType | BabelNodeTSExpressionWithTypeArguments | BabelNodeTSInterfaceDeclaration | BabelNodeTSInterfaceBody | BabelNodeTSTypeAliasDeclaration | BabelNodeTSInstantiationExpression | BabelNodeTSAsExpression | BabelNodeTSSatisfiesExpression | BabelNodeTSTypeAssertion | BabelNodeTSEnumDeclaration | BabelNodeTSEnumMember | BabelNodeTSModuleDeclaration | BabelNodeTSModuleBlock | BabelNodeTSImportType | BabelNodeTSImportEqualsDeclaration | BabelNodeTSExternalModuleReference | BabelNodeTSNonNullExpression | BabelNodeTSExportAssignment | BabelNodeTSNamespaceExportDeclaration | BabelNodeTSTypeAnnotation | BabelNodeTSTypeParameterInstantiation | BabelNodeTSTypeParameterDeclaration | BabelNodeTSTypeParameter; type BabelNodeTypeScript = BabelNodeTSParameterProperty | BabelNodeTSDeclareFunction | BabelNodeTSDeclareMethod | BabelNodeTSQualifiedName | BabelNodeTSCallSignatureDeclaration | BabelNodeTSConstructSignatureDeclaration | BabelNodeTSPropertySignature | BabelNodeTSMethodSignature | BabelNodeTSIndexSignature | BabelNodeTSAnyKeyword | BabelNodeTSBooleanKeyword | BabelNodeTSBigIntKeyword | BabelNodeTSIntrinsicKeyword | BabelNodeTSNeverKeyword | BabelNodeTSNullKeyword | BabelNodeTSNumberKeyword | BabelNodeTSObjectKeyword | BabelNodeTSStringKeyword | BabelNodeTSSymbolKeyword | BabelNodeTSUndefinedKeyword | BabelNodeTSUnknownKeyword | BabelNodeTSVoidKeyword | BabelNodeTSThisType | BabelNodeTSFunctionType | BabelNodeTSConstructorType | BabelNodeTSTypeReference | BabelNodeTSTypePredicate | BabelNodeTSTypeQuery | BabelNodeTSTypeLiteral | BabelNodeTSArrayType | BabelNodeTSTupleType | BabelNodeTSOptionalType | BabelNodeTSRestType | BabelNodeTSNamedTupleMember | BabelNodeTSUnionType | BabelNodeTSIntersectionType | BabelNodeTSConditionalType | BabelNodeTSInferType | BabelNodeTSParenthesizedType | BabelNodeTSTypeOperator | BabelNodeTSIndexedAccessType | BabelNodeTSMappedType | BabelNodeTSTemplateLiteralType | BabelNodeTSLiteralType | BabelNodeTSExpressionWithTypeArguments | BabelNodeTSInterfaceDeclaration | BabelNodeTSInterfaceBody | BabelNodeTSTypeAliasDeclaration | BabelNodeTSInstantiationExpression | BabelNodeTSAsExpression | BabelNodeTSSatisfiesExpression | BabelNodeTSTypeAssertion | BabelNodeTSEnumBody | BabelNodeTSEnumDeclaration | BabelNodeTSEnumMember | BabelNodeTSModuleDeclaration | BabelNodeTSModuleBlock | BabelNodeTSImportType | BabelNodeTSImportEqualsDeclaration | BabelNodeTSExternalModuleReference | BabelNodeTSNonNullExpression | BabelNodeTSExportAssignment | BabelNodeTSNamespaceExportDeclaration | BabelNodeTSTypeAnnotation | BabelNodeTSTypeParameterInstantiation | BabelNodeTSTypeParameterDeclaration | BabelNodeTSTypeParameter;
type BabelNodeTSTypeElement = BabelNodeTSCallSignatureDeclaration | BabelNodeTSConstructSignatureDeclaration | BabelNodeTSPropertySignature | BabelNodeTSMethodSignature | BabelNodeTSIndexSignature; type BabelNodeTSTypeElement = BabelNodeTSCallSignatureDeclaration | BabelNodeTSConstructSignatureDeclaration | BabelNodeTSPropertySignature | BabelNodeTSMethodSignature | BabelNodeTSIndexSignature;
type BabelNodeTSType = BabelNodeTSAnyKeyword | BabelNodeTSBooleanKeyword | BabelNodeTSBigIntKeyword | BabelNodeTSIntrinsicKeyword | BabelNodeTSNeverKeyword | BabelNodeTSNullKeyword | BabelNodeTSNumberKeyword | BabelNodeTSObjectKeyword | BabelNodeTSStringKeyword | BabelNodeTSSymbolKeyword | BabelNodeTSUndefinedKeyword | BabelNodeTSUnknownKeyword | BabelNodeTSVoidKeyword | BabelNodeTSThisType | BabelNodeTSFunctionType | BabelNodeTSConstructorType | BabelNodeTSTypeReference | BabelNodeTSTypePredicate | BabelNodeTSTypeQuery | BabelNodeTSTypeLiteral | BabelNodeTSArrayType | BabelNodeTSTupleType | BabelNodeTSOptionalType | BabelNodeTSRestType | BabelNodeTSUnionType | BabelNodeTSIntersectionType | BabelNodeTSConditionalType | BabelNodeTSInferType | BabelNodeTSParenthesizedType | BabelNodeTSTypeOperator | BabelNodeTSIndexedAccessType | BabelNodeTSMappedType | BabelNodeTSLiteralType | BabelNodeTSExpressionWithTypeArguments | BabelNodeTSImportType; type BabelNodeTSType = BabelNodeTSAnyKeyword | BabelNodeTSBooleanKeyword | BabelNodeTSBigIntKeyword | BabelNodeTSIntrinsicKeyword | BabelNodeTSNeverKeyword | BabelNodeTSNullKeyword | BabelNodeTSNumberKeyword | BabelNodeTSObjectKeyword | BabelNodeTSStringKeyword | BabelNodeTSSymbolKeyword | BabelNodeTSUndefinedKeyword | BabelNodeTSUnknownKeyword | BabelNodeTSVoidKeyword | BabelNodeTSThisType | BabelNodeTSFunctionType | BabelNodeTSConstructorType | BabelNodeTSTypeReference | BabelNodeTSTypePredicate | BabelNodeTSTypeQuery | BabelNodeTSTypeLiteral | BabelNodeTSArrayType | BabelNodeTSTupleType | BabelNodeTSOptionalType | BabelNodeTSRestType | BabelNodeTSUnionType | BabelNodeTSIntersectionType | BabelNodeTSConditionalType | BabelNodeTSInferType | BabelNodeTSParenthesizedType | BabelNodeTSTypeOperator | BabelNodeTSIndexedAccessType | BabelNodeTSMappedType | BabelNodeTSTemplateLiteralType | BabelNodeTSLiteralType | BabelNodeTSExpressionWithTypeArguments | BabelNodeTSImportType;
type BabelNodeTSBaseType = BabelNodeTSAnyKeyword | BabelNodeTSBooleanKeyword | BabelNodeTSBigIntKeyword | BabelNodeTSIntrinsicKeyword | BabelNodeTSNeverKeyword | BabelNodeTSNullKeyword | BabelNodeTSNumberKeyword | BabelNodeTSObjectKeyword | BabelNodeTSStringKeyword | BabelNodeTSSymbolKeyword | BabelNodeTSUndefinedKeyword | BabelNodeTSUnknownKeyword | BabelNodeTSVoidKeyword | BabelNodeTSThisType | BabelNodeTSLiteralType; type BabelNodeTSBaseType = BabelNodeTSAnyKeyword | BabelNodeTSBooleanKeyword | BabelNodeTSBigIntKeyword | BabelNodeTSIntrinsicKeyword | BabelNodeTSNeverKeyword | BabelNodeTSNullKeyword | BabelNodeTSNumberKeyword | BabelNodeTSObjectKeyword | BabelNodeTSStringKeyword | BabelNodeTSSymbolKeyword | BabelNodeTSUndefinedKeyword | BabelNodeTSUnknownKeyword | BabelNodeTSVoidKeyword | BabelNodeTSThisType | BabelNodeTSTemplateLiteralType | BabelNodeTSLiteralType;
type BabelNodeModuleDeclaration = BabelNodeExportAllDeclaration | BabelNodeExportDefaultDeclaration | BabelNodeExportNamedDeclaration | BabelNodeImportDeclaration; type BabelNodeModuleDeclaration = BabelNodeExportAllDeclaration | BabelNodeExportDefaultDeclaration | BabelNodeExportNamedDeclaration | BabelNodeImportDeclaration;
declare module "@babel/types" { declare module "@babel/types" {
@ -1686,7 +1708,7 @@ declare module "@babel/types" {
declare export function directiveLiteral(value: string): BabelNodeDirectiveLiteral; declare export function directiveLiteral(value: string): BabelNodeDirectiveLiteral;
declare export function blockStatement(body: Array<BabelNodeStatement>, directives?: Array<BabelNodeDirective>): BabelNodeBlockStatement; declare export function blockStatement(body: Array<BabelNodeStatement>, directives?: Array<BabelNodeDirective>): BabelNodeBlockStatement;
declare export function breakStatement(label?: BabelNodeIdentifier): BabelNodeBreakStatement; declare export function breakStatement(label?: BabelNodeIdentifier): BabelNodeBreakStatement;
declare export function callExpression(callee: BabelNodeExpression | BabelNodeSuper | BabelNodeV8IntrinsicIdentifier, _arguments: Array<BabelNodeExpression | BabelNodeSpreadElement | BabelNodeJSXNamespacedName | BabelNodeArgumentPlaceholder>): BabelNodeCallExpression; declare export function callExpression(callee: BabelNodeExpression | BabelNodeSuper | BabelNodeV8IntrinsicIdentifier, _arguments: Array<BabelNodeExpression | BabelNodeSpreadElement | BabelNodeArgumentPlaceholder>): BabelNodeCallExpression;
declare export function catchClause(param?: BabelNodeIdentifier | BabelNodeArrayPattern | BabelNodeObjectPattern, body: BabelNodeBlockStatement): BabelNodeCatchClause; declare export function catchClause(param?: BabelNodeIdentifier | BabelNodeArrayPattern | BabelNodeObjectPattern, body: BabelNodeBlockStatement): BabelNodeCatchClause;
declare export function conditionalExpression(test: BabelNodeExpression, consequent: BabelNodeExpression, alternate: BabelNodeExpression): BabelNodeConditionalExpression; declare export function conditionalExpression(test: BabelNodeExpression, consequent: BabelNodeExpression, alternate: BabelNodeExpression): BabelNodeConditionalExpression;
declare export function continueStatement(label?: BabelNodeIdentifier): BabelNodeContinueStatement; declare export function continueStatement(label?: BabelNodeIdentifier): BabelNodeContinueStatement;
@ -1708,8 +1730,8 @@ declare module "@babel/types" {
declare export function booleanLiteral(value: boolean): BabelNodeBooleanLiteral; declare export function booleanLiteral(value: boolean): BabelNodeBooleanLiteral;
declare export function regExpLiteral(pattern: string, flags?: string): BabelNodeRegExpLiteral; declare export function regExpLiteral(pattern: string, flags?: string): BabelNodeRegExpLiteral;
declare export function logicalExpression(operator: "||" | "&&" | "??", left: BabelNodeExpression, right: BabelNodeExpression): BabelNodeLogicalExpression; declare export function logicalExpression(operator: "||" | "&&" | "??", left: BabelNodeExpression, right: BabelNodeExpression): BabelNodeLogicalExpression;
declare export function memberExpression(object: BabelNodeExpression | BabelNodeSuper, property: BabelNodeExpression | BabelNodeIdentifier | BabelNodePrivateName, computed?: boolean, optional?: true | false): BabelNodeMemberExpression; declare export function memberExpression(object: BabelNodeExpression | BabelNodeSuper, property: BabelNodeExpression | BabelNodeIdentifier | BabelNodePrivateName, computed?: boolean, optional?: boolean): BabelNodeMemberExpression;
declare export function newExpression(callee: BabelNodeExpression | BabelNodeSuper | BabelNodeV8IntrinsicIdentifier, _arguments: Array<BabelNodeExpression | BabelNodeSpreadElement | BabelNodeJSXNamespacedName | BabelNodeArgumentPlaceholder>): BabelNodeNewExpression; declare export function newExpression(callee: BabelNodeExpression | BabelNodeSuper | BabelNodeV8IntrinsicIdentifier, _arguments: Array<BabelNodeExpression | BabelNodeSpreadElement | BabelNodeArgumentPlaceholder>): BabelNodeNewExpression;
declare export function program(body: Array<BabelNodeStatement>, directives?: Array<BabelNodeDirective>, sourceType?: "script" | "module", interpreter?: BabelNodeInterpreterDirective): BabelNodeProgram; declare export function program(body: Array<BabelNodeStatement>, directives?: Array<BabelNodeDirective>, sourceType?: "script" | "module", interpreter?: BabelNodeInterpreterDirective): BabelNodeProgram;
declare export function objectExpression(properties: Array<BabelNodeObjectMethod | BabelNodeObjectProperty | BabelNodeSpreadElement>): BabelNodeObjectExpression; declare export function objectExpression(properties: Array<BabelNodeObjectMethod | BabelNodeObjectProperty | BabelNodeSpreadElement>): BabelNodeObjectExpression;
declare export function objectMethod(kind?: "method" | "get" | "set", key: BabelNodeExpression | BabelNodeIdentifier | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeBigIntLiteral, params: Array<BabelNodeIdentifier | BabelNodePattern | BabelNodeRestElement>, body: BabelNodeBlockStatement, computed?: boolean, generator?: boolean, async?: boolean): BabelNodeObjectMethod; declare export function objectMethod(kind?: "method" | "get" | "set", key: BabelNodeExpression | BabelNodeIdentifier | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeBigIntLiteral, params: Array<BabelNodeIdentifier | BabelNodePattern | BabelNodeRestElement>, body: BabelNodeBlockStatement, computed?: boolean, generator?: boolean, async?: boolean): BabelNodeObjectMethod;
@ -1761,13 +1783,14 @@ declare module "@babel/types" {
declare export function bigIntLiteral(value: string): BabelNodeBigIntLiteral; declare export function bigIntLiteral(value: string): BabelNodeBigIntLiteral;
declare export function exportNamespaceSpecifier(exported: BabelNodeIdentifier): BabelNodeExportNamespaceSpecifier; declare export function exportNamespaceSpecifier(exported: BabelNodeIdentifier): BabelNodeExportNamespaceSpecifier;
declare export function optionalMemberExpression(object: BabelNodeExpression, property: BabelNodeExpression | BabelNodeIdentifier, computed?: boolean, optional: boolean): BabelNodeOptionalMemberExpression; declare export function optionalMemberExpression(object: BabelNodeExpression, property: BabelNodeExpression | BabelNodeIdentifier, computed?: boolean, optional: boolean): BabelNodeOptionalMemberExpression;
declare export function optionalCallExpression(callee: BabelNodeExpression, _arguments: Array<BabelNodeExpression | BabelNodeSpreadElement | BabelNodeJSXNamespacedName | BabelNodeArgumentPlaceholder>, optional: boolean): BabelNodeOptionalCallExpression; declare export function optionalCallExpression(callee: BabelNodeExpression, _arguments: Array<BabelNodeExpression | BabelNodeSpreadElement | BabelNodeArgumentPlaceholder>, optional: boolean): BabelNodeOptionalCallExpression;
declare export function classProperty(key: BabelNodeIdentifier | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeBigIntLiteral | BabelNodeExpression, value?: BabelNodeExpression, typeAnnotation?: BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop, decorators?: Array<BabelNodeDecorator>, computed?: boolean, _static?: boolean): BabelNodeClassProperty; declare export function classProperty(key: BabelNodeIdentifier | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeBigIntLiteral | BabelNodeExpression, value?: BabelNodeExpression, typeAnnotation?: BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop, decorators?: Array<BabelNodeDecorator>, computed?: boolean, _static?: boolean): BabelNodeClassProperty;
declare export function classAccessorProperty(key: BabelNodeIdentifier | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeBigIntLiteral | BabelNodeExpression | BabelNodePrivateName, value?: BabelNodeExpression, typeAnnotation?: BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop, decorators?: Array<BabelNodeDecorator>, computed?: boolean, _static?: boolean): BabelNodeClassAccessorProperty; declare export function classAccessorProperty(key: BabelNodeIdentifier | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeBigIntLiteral | BabelNodeExpression | BabelNodePrivateName, value?: BabelNodeExpression, typeAnnotation?: BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop, decorators?: Array<BabelNodeDecorator>, computed?: boolean, _static?: boolean): BabelNodeClassAccessorProperty;
declare export function classPrivateProperty(key: BabelNodePrivateName, value?: BabelNodeExpression, decorators?: Array<BabelNodeDecorator>, _static?: boolean): BabelNodeClassPrivateProperty; declare export function classPrivateProperty(key: BabelNodePrivateName, value?: BabelNodeExpression, decorators?: Array<BabelNodeDecorator>, _static?: boolean): BabelNodeClassPrivateProperty;
declare export function classPrivateMethod(kind?: "get" | "set" | "method", key: BabelNodePrivateName, params: Array<BabelNodeIdentifier | BabelNodePattern | BabelNodeRestElement | BabelNodeTSParameterProperty>, body: BabelNodeBlockStatement, _static?: boolean): BabelNodeClassPrivateMethod; declare export function classPrivateMethod(kind?: "get" | "set" | "method", key: BabelNodePrivateName, params: Array<BabelNodeIdentifier | BabelNodePattern | BabelNodeRestElement | BabelNodeTSParameterProperty>, body: BabelNodeBlockStatement, _static?: boolean): BabelNodeClassPrivateMethod;
declare export function privateName(id: BabelNodeIdentifier): BabelNodePrivateName; declare export function privateName(id: BabelNodeIdentifier): BabelNodePrivateName;
declare export function staticBlock(body: Array<BabelNodeStatement>): BabelNodeStaticBlock; declare export function staticBlock(body: Array<BabelNodeStatement>): BabelNodeStaticBlock;
declare export function importAttribute(key: BabelNodeIdentifier | BabelNodeStringLiteral, value: BabelNodeStringLiteral): BabelNodeImportAttribute;
declare export function anyTypeAnnotation(): BabelNodeAnyTypeAnnotation; declare export function anyTypeAnnotation(): BabelNodeAnyTypeAnnotation;
declare export function arrayTypeAnnotation(elementType: BabelNodeFlowType): BabelNodeArrayTypeAnnotation; declare export function arrayTypeAnnotation(elementType: BabelNodeFlowType): BabelNodeArrayTypeAnnotation;
declare export function booleanTypeAnnotation(): BabelNodeBooleanTypeAnnotation; declare export function booleanTypeAnnotation(): BabelNodeBooleanTypeAnnotation;
@ -1782,8 +1805,8 @@ declare module "@babel/types" {
declare export function declareTypeAlias(id: BabelNodeIdentifier, typeParameters?: BabelNodeTypeParameterDeclaration, right: BabelNodeFlowType): BabelNodeDeclareTypeAlias; declare export function declareTypeAlias(id: BabelNodeIdentifier, typeParameters?: BabelNodeTypeParameterDeclaration, right: BabelNodeFlowType): BabelNodeDeclareTypeAlias;
declare export function declareOpaqueType(id: BabelNodeIdentifier, typeParameters?: BabelNodeTypeParameterDeclaration, supertype?: BabelNodeFlowType): BabelNodeDeclareOpaqueType; declare export function declareOpaqueType(id: BabelNodeIdentifier, typeParameters?: BabelNodeTypeParameterDeclaration, supertype?: BabelNodeFlowType): BabelNodeDeclareOpaqueType;
declare export function declareVariable(id: BabelNodeIdentifier): BabelNodeDeclareVariable; declare export function declareVariable(id: BabelNodeIdentifier): BabelNodeDeclareVariable;
declare export function declareExportDeclaration(declaration?: BabelNodeFlow, specifiers?: Array<BabelNodeExportSpecifier | BabelNodeExportNamespaceSpecifier>, source?: BabelNodeStringLiteral): BabelNodeDeclareExportDeclaration; declare export function declareExportDeclaration(declaration?: BabelNodeFlow, specifiers?: Array<BabelNodeExportSpecifier | BabelNodeExportNamespaceSpecifier>, source?: BabelNodeStringLiteral, attributes?: Array<BabelNodeImportAttribute>): BabelNodeDeclareExportDeclaration;
declare export function declareExportAllDeclaration(source: BabelNodeStringLiteral): BabelNodeDeclareExportAllDeclaration; declare export function declareExportAllDeclaration(source: BabelNodeStringLiteral, attributes?: Array<BabelNodeImportAttribute>): BabelNodeDeclareExportAllDeclaration;
declare export function declaredPredicate(value: BabelNodeFlow): BabelNodeDeclaredPredicate; declare export function declaredPredicate(value: BabelNodeFlow): BabelNodeDeclaredPredicate;
declare export function existsTypeAnnotation(): BabelNodeExistsTypeAnnotation; declare export function existsTypeAnnotation(): BabelNodeExistsTypeAnnotation;
declare export function functionTypeAnnotation(typeParameters?: BabelNodeTypeParameterDeclaration, params: Array<BabelNodeFunctionTypeParam>, rest?: BabelNodeFunctionTypeParam, returnType: BabelNodeFlowType): BabelNodeFunctionTypeAnnotation; declare export function functionTypeAnnotation(typeParameters?: BabelNodeTypeParameterDeclaration, params: Array<BabelNodeFunctionTypeParam>, rest?: BabelNodeFunctionTypeParam, returnType: BabelNodeFlowType): BabelNodeFunctionTypeAnnotation;
@ -1853,7 +1876,6 @@ declare module "@babel/types" {
declare export function v8IntrinsicIdentifier(name: string): BabelNodeV8IntrinsicIdentifier; declare export function v8IntrinsicIdentifier(name: string): BabelNodeV8IntrinsicIdentifier;
declare export function argumentPlaceholder(): BabelNodeArgumentPlaceholder; declare export function argumentPlaceholder(): BabelNodeArgumentPlaceholder;
declare export function bindExpression(object: BabelNodeExpression, callee: BabelNodeExpression): BabelNodeBindExpression; declare export function bindExpression(object: BabelNodeExpression, callee: BabelNodeExpression): BabelNodeBindExpression;
declare export function importAttribute(key: BabelNodeIdentifier | BabelNodeStringLiteral, value: BabelNodeStringLiteral): BabelNodeImportAttribute;
declare export function decorator(expression: BabelNodeExpression): BabelNodeDecorator; declare export function decorator(expression: BabelNodeExpression): BabelNodeDecorator;
declare export function doExpression(body: BabelNodeBlockStatement, async?: boolean): BabelNodeDoExpression; declare export function doExpression(body: BabelNodeBlockStatement, async?: boolean): BabelNodeDoExpression;
declare export function exportDefaultSpecifier(exported: BabelNodeIdentifier): BabelNodeExportDefaultSpecifier; declare export function exportDefaultSpecifier(exported: BabelNodeIdentifier): BabelNodeExportDefaultSpecifier;
@ -1907,6 +1929,7 @@ declare module "@babel/types" {
declare export function tsTypeOperator(typeAnnotation: BabelNodeTSType): BabelNodeTSTypeOperator; declare export function tsTypeOperator(typeAnnotation: BabelNodeTSType): BabelNodeTSTypeOperator;
declare export function tsIndexedAccessType(objectType: BabelNodeTSType, indexType: BabelNodeTSType): BabelNodeTSIndexedAccessType; declare export function tsIndexedAccessType(objectType: BabelNodeTSType, indexType: BabelNodeTSType): BabelNodeTSIndexedAccessType;
declare export function tsMappedType(typeParameter: BabelNodeTSTypeParameter, typeAnnotation?: BabelNodeTSType, nameType?: BabelNodeTSType): BabelNodeTSMappedType; declare export function tsMappedType(typeParameter: BabelNodeTSTypeParameter, typeAnnotation?: BabelNodeTSType, nameType?: BabelNodeTSType): BabelNodeTSMappedType;
declare export function tsTemplateLiteralType(quasis: Array<BabelNodeTemplateElement>, types: Array<BabelNodeTSType>): BabelNodeTSTemplateLiteralType;
declare export function tsLiteralType(literal: BabelNodeNumericLiteral | BabelNodeStringLiteral | BabelNodeBooleanLiteral | BabelNodeBigIntLiteral | BabelNodeTemplateLiteral | BabelNodeUnaryExpression): BabelNodeTSLiteralType; declare export function tsLiteralType(literal: BabelNodeNumericLiteral | BabelNodeStringLiteral | BabelNodeBooleanLiteral | BabelNodeBigIntLiteral | BabelNodeTemplateLiteral | BabelNodeUnaryExpression): BabelNodeTSLiteralType;
declare export function tsExpressionWithTypeArguments(expression: BabelNodeTSEntityName, typeParameters?: BabelNodeTSTypeParameterInstantiation): BabelNodeTSExpressionWithTypeArguments; declare export function tsExpressionWithTypeArguments(expression: BabelNodeTSEntityName, typeParameters?: BabelNodeTSTypeParameterInstantiation): BabelNodeTSExpressionWithTypeArguments;
declare export function tsInterfaceDeclaration(id: BabelNodeIdentifier, typeParameters?: BabelNodeTSTypeParameterDeclaration, _extends?: Array<BabelNodeTSExpressionWithTypeArguments>, body: BabelNodeTSInterfaceBody): BabelNodeTSInterfaceDeclaration; declare export function tsInterfaceDeclaration(id: BabelNodeIdentifier, typeParameters?: BabelNodeTSTypeParameterDeclaration, _extends?: Array<BabelNodeTSExpressionWithTypeArguments>, body: BabelNodeTSInterfaceBody): BabelNodeTSInterfaceDeclaration;
@ -1916,6 +1939,7 @@ declare module "@babel/types" {
declare export function tsAsExpression(expression: BabelNodeExpression, typeAnnotation: BabelNodeTSType): BabelNodeTSAsExpression; declare export function tsAsExpression(expression: BabelNodeExpression, typeAnnotation: BabelNodeTSType): BabelNodeTSAsExpression;
declare export function tsSatisfiesExpression(expression: BabelNodeExpression, typeAnnotation: BabelNodeTSType): BabelNodeTSSatisfiesExpression; declare export function tsSatisfiesExpression(expression: BabelNodeExpression, typeAnnotation: BabelNodeTSType): BabelNodeTSSatisfiesExpression;
declare export function tsTypeAssertion(typeAnnotation: BabelNodeTSType, expression: BabelNodeExpression): BabelNodeTSTypeAssertion; declare export function tsTypeAssertion(typeAnnotation: BabelNodeTSType, expression: BabelNodeExpression): BabelNodeTSTypeAssertion;
declare export function tsEnumBody(members: Array<BabelNodeTSEnumMember>): BabelNodeTSEnumBody;
declare export function tsEnumDeclaration(id: BabelNodeIdentifier, members: Array<BabelNodeTSEnumMember>): BabelNodeTSEnumDeclaration; declare export function tsEnumDeclaration(id: BabelNodeIdentifier, members: Array<BabelNodeTSEnumMember>): BabelNodeTSEnumDeclaration;
declare export function tsEnumMember(id: BabelNodeIdentifier | BabelNodeStringLiteral, initializer?: BabelNodeExpression): BabelNodeTSEnumMember; declare export function tsEnumMember(id: BabelNodeIdentifier | BabelNodeStringLiteral, initializer?: BabelNodeExpression): BabelNodeTSEnumMember;
declare export function tsModuleDeclaration(id: BabelNodeIdentifier | BabelNodeStringLiteral, body: BabelNodeTSModuleBlock | BabelNodeTSModuleDeclaration): BabelNodeTSModuleDeclaration; declare export function tsModuleDeclaration(id: BabelNodeIdentifier | BabelNodeStringLiteral, body: BabelNodeTSModuleBlock | BabelNodeTSModuleDeclaration): BabelNodeTSModuleDeclaration;
@ -2106,6 +2130,8 @@ declare module "@babel/types" {
declare export function assertPrivateName(node: ?Object, opts?: ?Object): void declare export function assertPrivateName(node: ?Object, opts?: ?Object): void
declare export function isStaticBlock(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeStaticBlock) declare export function isStaticBlock(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeStaticBlock)
declare export function assertStaticBlock(node: ?Object, opts?: ?Object): void declare export function assertStaticBlock(node: ?Object, opts?: ?Object): void
declare export function isImportAttribute(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeImportAttribute)
declare export function assertImportAttribute(node: ?Object, opts?: ?Object): void
declare export function isAnyTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeAnyTypeAnnotation) declare export function isAnyTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeAnyTypeAnnotation)
declare export function assertAnyTypeAnnotation(node: ?Object, opts?: ?Object): void declare export function assertAnyTypeAnnotation(node: ?Object, opts?: ?Object): void
declare export function isArrayTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeArrayTypeAnnotation) declare export function isArrayTypeAnnotation(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeArrayTypeAnnotation)
@ -2276,8 +2302,6 @@ declare module "@babel/types" {
declare export function assertArgumentPlaceholder(node: ?Object, opts?: ?Object): void declare export function assertArgumentPlaceholder(node: ?Object, opts?: ?Object): void
declare export function isBindExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeBindExpression) declare export function isBindExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeBindExpression)
declare export function assertBindExpression(node: ?Object, opts?: ?Object): void declare export function assertBindExpression(node: ?Object, opts?: ?Object): void
declare export function isImportAttribute(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeImportAttribute)
declare export function assertImportAttribute(node: ?Object, opts?: ?Object): void
declare export function isDecorator(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeDecorator) declare export function isDecorator(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeDecorator)
declare export function assertDecorator(node: ?Object, opts?: ?Object): void declare export function assertDecorator(node: ?Object, opts?: ?Object): void
declare export function isDoExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeDoExpression) declare export function isDoExpression(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeDoExpression)
@ -2384,6 +2408,8 @@ declare module "@babel/types" {
declare export function assertTSIndexedAccessType(node: ?Object, opts?: ?Object): void declare export function assertTSIndexedAccessType(node: ?Object, opts?: ?Object): void
declare export function isTSMappedType(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSMappedType) declare export function isTSMappedType(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSMappedType)
declare export function assertTSMappedType(node: ?Object, opts?: ?Object): void declare export function assertTSMappedType(node: ?Object, opts?: ?Object): void
declare export function isTSTemplateLiteralType(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSTemplateLiteralType)
declare export function assertTSTemplateLiteralType(node: ?Object, opts?: ?Object): void
declare export function isTSLiteralType(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSLiteralType) declare export function isTSLiteralType(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSLiteralType)
declare export function assertTSLiteralType(node: ?Object, opts?: ?Object): void declare export function assertTSLiteralType(node: ?Object, opts?: ?Object): void
declare export function isTSExpressionWithTypeArguments(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSExpressionWithTypeArguments) declare export function isTSExpressionWithTypeArguments(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSExpressionWithTypeArguments)
@ -2402,6 +2428,8 @@ declare module "@babel/types" {
declare export function assertTSSatisfiesExpression(node: ?Object, opts?: ?Object): void declare export function assertTSSatisfiesExpression(node: ?Object, opts?: ?Object): void
declare export function isTSTypeAssertion(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSTypeAssertion) declare export function isTSTypeAssertion(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSTypeAssertion)
declare export function assertTSTypeAssertion(node: ?Object, opts?: ?Object): void declare export function assertTSTypeAssertion(node: ?Object, opts?: ?Object): void
declare export function isTSEnumBody(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSEnumBody)
declare export function assertTSEnumBody(node: ?Object, opts?: ?Object): void
declare export function isTSEnumDeclaration(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSEnumDeclaration) declare export function isTSEnumDeclaration(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSEnumDeclaration)
declare export function assertTSEnumDeclaration(node: ?Object, opts?: ?Object): void declare export function assertTSEnumDeclaration(node: ?Object, opts?: ?Object): void
declare export function isTSEnumMember(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSEnumMember) declare export function isTSEnumMember(node: ?Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeTSEnumMember)

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"version":3,"names":["_index","require","appendToMemberExpression","member","append","computed","object","memberExpression","property"],"sources":["../../src/modifications/appendToMemberExpression.ts"],"sourcesContent":["import { memberExpression } from \"../builders/generated/index.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Append a node to a member expression.\n */\nexport default function appendToMemberExpression(\n member: t.MemberExpression,\n append: t.MemberExpression[\"property\"],\n computed: boolean = false,\n): t.MemberExpression {\n member.object = memberExpression(\n member.object,\n member.property,\n member.computed,\n );\n member.property = append;\n member.computed = !!computed;\n\n return member;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAMe,SAASC,wBAAwBA,CAC9CC,MAA0B,EAC1BC,MAAsC,EACtCC,QAAiB,GAAG,KAAK,EACL;EACpBF,MAAM,CAACG,MAAM,GAAG,IAAAC,uBAAgB,EAC9BJ,MAAM,CAACG,MAAM,EACbH,MAAM,CAACK,QAAQ,EACfL,MAAM,CAACE,QACT,CAAC;EACDF,MAAM,CAACK,QAAQ,GAAGJ,MAAM;EACxBD,MAAM,CAACE,QAAQ,GAAG,CAAC,CAACA,QAAQ;EAE5B,OAAOF,MAAM;AACf"} {"version":3,"names":["_index","require","appendToMemberExpression","member","append","computed","object","memberExpression","property"],"sources":["../../src/modifications/appendToMemberExpression.ts"],"sourcesContent":["import { memberExpression } from \"../builders/generated/index.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Append a node to a member expression.\n */\nexport default function appendToMemberExpression(\n member: t.MemberExpression,\n append: t.MemberExpression[\"property\"],\n computed: boolean = false,\n): t.MemberExpression {\n member.object = memberExpression(\n member.object,\n member.property,\n member.computed,\n );\n member.property = append;\n member.computed = !!computed;\n\n return member;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAMe,SAASC,wBAAwBA,CAC9CC,MAA0B,EAC1BC,MAAsC,EACtCC,QAAiB,GAAG,KAAK,EACL;EACpBF,MAAM,CAACG,MAAM,GAAG,IAAAC,uBAAgB,EAC9BJ,MAAM,CAACG,MAAM,EACbH,MAAM,CAACK,QAAQ,EACfL,MAAM,CAACE,QACT,CAAC;EACDF,MAAM,CAACK,QAAQ,GAAGJ,MAAM;EACxBD,MAAM,CAACE,QAAQ,GAAG,CAAC,CAACA,QAAQ;EAE5B,OAAOF,MAAM;AACf","ignoreList":[]}

View File

@ -17,7 +17,7 @@ function removeTypeDuplicates(nodesIn) {
for (let i = 0; i < nodes.length; i++) { for (let i = 0; i < nodes.length; i++) {
const node = nodes[i]; const node = nodes[i];
if (!node) continue; if (!node) continue;
if (types.indexOf(node) >= 0) { if (types.includes(node)) {
continue; continue;
} }
if ((0, _index.isAnyTypeAnnotation)(node)) { if ((0, _index.isAnyTypeAnnotation)(node)) {

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"version":3,"names":["_index","require","_inheritsComments","inherits","child","parent","key","INHERIT_KEYS","optional","Object","keys","force","inheritsComments"],"sources":["../../src/modifications/inherits.ts"],"sourcesContent":["import { INHERIT_KEYS } from \"../constants/index.ts\";\nimport inheritsComments from \"../comments/inheritsComments.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Inherit all contextual properties from `parent` node to `child` node.\n */\nexport default function inherits<T extends t.Node | null | undefined>(\n child: T,\n parent: t.Node | null | undefined,\n): T {\n if (!child || !parent) return child;\n\n // optionally inherit specific properties if not null\n for (const key of INHERIT_KEYS.optional) {\n // @ts-expect-error Fixme: refine parent types\n if (child[key] == null) {\n // @ts-expect-error Fixme: refine parent types\n child[key] = parent[key];\n }\n }\n\n // force inherit \"private\" properties\n for (const key of Object.keys(parent)) {\n if (key[0] === \"_\" && key !== \"__clone\") {\n // @ts-expect-error Fixme: refine parent types\n child[key] = parent[key];\n }\n }\n\n // force inherit select properties\n for (const key of INHERIT_KEYS.force) {\n // @ts-expect-error Fixme: refine parent types\n child[key] = parent[key];\n }\n\n inheritsComments(child, parent);\n\n return child;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAMe,SAASE,QAAQA,CAC9BC,KAAQ,EACRC,MAAiC,EAC9B;EACH,IAAI,CAACD,KAAK,IAAI,CAACC,MAAM,EAAE,OAAOD,KAAK;EAGnC,KAAK,MAAME,GAAG,IAAIC,mBAAY,CAACC,QAAQ,EAAE;IAEvC,IAAIJ,KAAK,CAACE,GAAG,CAAC,IAAI,IAAI,EAAE;MAEtBF,KAAK,CAACE,GAAG,CAAC,GAAGD,MAAM,CAACC,GAAG,CAAC;IAC1B;EACF;EAGA,KAAK,MAAMA,GAAG,IAAIG,MAAM,CAACC,IAAI,CAACL,MAAM,CAAC,EAAE;IACrC,IAAIC,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IAAIA,GAAG,KAAK,SAAS,EAAE;MAEvCF,KAAK,CAACE,GAAG,CAAC,GAAGD,MAAM,CAACC,GAAG,CAAC;IAC1B;EACF;EAGA,KAAK,MAAMA,GAAG,IAAIC,mBAAY,CAACI,KAAK,EAAE;IAEpCP,KAAK,CAACE,GAAG,CAAC,GAAGD,MAAM,CAACC,GAAG,CAAC;EAC1B;EAEA,IAAAM,yBAAgB,EAACR,KAAK,EAAEC,MAAM,CAAC;EAE/B,OAAOD,KAAK;AACd"} {"version":3,"names":["_index","require","_inheritsComments","inherits","child","parent","key","INHERIT_KEYS","optional","Object","keys","force","inheritsComments"],"sources":["../../src/modifications/inherits.ts"],"sourcesContent":["import { INHERIT_KEYS } from \"../constants/index.ts\";\nimport inheritsComments from \"../comments/inheritsComments.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Inherit all contextual properties from `parent` node to `child` node.\n */\nexport default function inherits<T extends t.Node | null | undefined>(\n child: T,\n parent: t.Node | null | undefined,\n): T {\n if (!child || !parent) return child;\n\n // optionally inherit specific properties if not null\n for (const key of INHERIT_KEYS.optional) {\n // @ts-expect-error Fixme: refine parent types\n if (child[key] == null) {\n // @ts-expect-error Fixme: refine parent types\n child[key] = parent[key];\n }\n }\n\n // force inherit \"private\" properties\n for (const key of Object.keys(parent)) {\n if (key[0] === \"_\" && key !== \"__clone\") {\n // @ts-expect-error Fixme: refine parent types\n child[key] = parent[key];\n }\n }\n\n // force inherit select properties\n for (const key of INHERIT_KEYS.force) {\n // @ts-expect-error Fixme: refine parent types\n child[key] = parent[key];\n }\n\n inheritsComments(child, parent);\n\n return child;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAMe,SAASE,QAAQA,CAC9BC,KAAQ,EACRC,MAAiC,EAC9B;EACH,IAAI,CAACD,KAAK,IAAI,CAACC,MAAM,EAAE,OAAOD,KAAK;EAGnC,KAAK,MAAME,GAAG,IAAIC,mBAAY,CAACC,QAAQ,EAAE;IAEvC,IAAIJ,KAAK,CAACE,GAAG,CAAC,IAAI,IAAI,EAAE;MAEtBF,KAAK,CAACE,GAAG,CAAC,GAAGD,MAAM,CAACC,GAAG,CAAC;IAC1B;EACF;EAGA,KAAK,MAAMA,GAAG,IAAIG,MAAM,CAACC,IAAI,CAACL,MAAM,CAAC,EAAE;IACrC,IAAIC,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IAAIA,GAAG,KAAK,SAAS,EAAE;MAEvCF,KAAK,CAACE,GAAG,CAAC,GAAGD,MAAM,CAACC,GAAG,CAAC;IAC1B;EACF;EAGA,KAAK,MAAMA,GAAG,IAAIC,mBAAY,CAACI,KAAK,EAAE;IAEpCP,KAAK,CAACE,GAAG,CAAC,GAAGD,MAAM,CAACC,GAAG,CAAC;EAC1B;EAEA,IAAAM,yBAAgB,EAACR,KAAK,EAAEC,MAAM,CAAC;EAE/B,OAAOD,KAAK;AACd","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["_index","require","_index2","prependToMemberExpression","member","prepend","isSuper","object","Error","memberExpression"],"sources":["../../src/modifications/prependToMemberExpression.ts"],"sourcesContent":["import { memberExpression } from \"../builders/generated/index.ts\";\nimport { isSuper } from \"../index.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Prepend a node to a member expression.\n */\nexport default function prependToMemberExpression<\n T extends Pick<t.MemberExpression, \"object\" | \"property\">,\n>(member: T, prepend: t.MemberExpression[\"object\"]): T {\n if (isSuper(member.object)) {\n throw new Error(\n \"Cannot prepend node to super property access (`super.foo`).\",\n );\n }\n member.object = memberExpression(prepend, member.object);\n\n return member;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAMe,SAASE,yBAAyBA,CAE/CC,MAAS,EAAEC,OAAqC,EAAK;EACrD,IAAI,IAAAC,eAAO,EAACF,MAAM,CAACG,MAAM,CAAC,EAAE;IAC1B,MAAM,IAAIC,KAAK,CACb,6DACF,CAAC;EACH;EACAJ,MAAM,CAACG,MAAM,GAAG,IAAAE,uBAAgB,EAACJ,OAAO,EAAED,MAAM,CAACG,MAAM,CAAC;EAExD,OAAOH,MAAM;AACf"} {"version":3,"names":["_index","require","_index2","prependToMemberExpression","member","prepend","isSuper","object","Error","memberExpression"],"sources":["../../src/modifications/prependToMemberExpression.ts"],"sourcesContent":["import { memberExpression } from \"../builders/generated/index.ts\";\nimport { isSuper } from \"../index.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * Prepend a node to a member expression.\n */\nexport default function prependToMemberExpression<\n T extends Pick<t.MemberExpression, \"object\" | \"property\">,\n>(member: T, prepend: t.MemberExpression[\"object\"]): T {\n if (isSuper(member.object)) {\n throw new Error(\n \"Cannot prepend node to super property access (`super.foo`).\",\n );\n }\n member.object = memberExpression(prepend, member.object);\n\n return member;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAMe,SAASE,yBAAyBA,CAE/CC,MAAS,EAAEC,OAAqC,EAAK;EACrD,IAAI,IAAAC,eAAO,EAACF,MAAM,CAACG,MAAM,CAAC,EAAE;IAC1B,MAAM,IAAIC,KAAK,CACb,6DACF,CAAC;EACH;EACAJ,MAAM,CAACG,MAAM,GAAG,IAAAE,uBAAgB,EAACJ,OAAO,EAAED,MAAM,CAACG,MAAM,CAAC;EAExD,OAAOH,MAAM;AACf","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["_index","require","CLEAR_KEYS","CLEAR_KEYS_PLUS_COMMENTS","COMMENT_KEYS","removeProperties","node","opts","map","preserveComments","key","undefined","Object","keys","symbols","getOwnPropertySymbols","sym"],"sources":["../../src/modifications/removeProperties.ts"],"sourcesContent":["import { COMMENT_KEYS } from \"../constants/index.ts\";\nimport type * as t from \"../index.ts\";\n\nconst CLEAR_KEYS = [\n \"tokens\", // only exist in t.File\n \"start\",\n \"end\",\n \"loc\",\n // Fixme: should be extra.raw / extra.rawValue?\n \"raw\",\n \"rawValue\",\n] as const;\n\nconst CLEAR_KEYS_PLUS_COMMENTS = [\n ...COMMENT_KEYS,\n \"comments\",\n ...CLEAR_KEYS,\n] as const;\n\nexport type Options = { preserveComments?: boolean };\n/**\n * Remove all of the _* properties from a node along with the additional metadata\n * properties like location data and raw token data.\n */\nexport default function removeProperties(\n node: t.Node,\n opts: Options = {},\n): void {\n const map = opts.preserveComments ? CLEAR_KEYS : CLEAR_KEYS_PLUS_COMMENTS;\n for (const key of map) {\n // @ts-expect-error tokens only exist in t.File\n if (node[key] != null) node[key] = undefined;\n }\n\n for (const key of Object.keys(node)) {\n // @ts-expect-error string can not index node\n if (key[0] === \"_\" && node[key] != null) node[key] = undefined;\n }\n\n const symbols: Array<symbol> = Object.getOwnPropertySymbols(node);\n for (const sym of symbols) {\n // @ts-expect-error Fixme: document symbol properties\n node[sym] = null;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGA,MAAMC,UAAU,GAAG,CACjB,QAAQ,EACR,OAAO,EACP,KAAK,EACL,KAAK,EAEL,KAAK,EACL,UAAU,CACF;AAEV,MAAMC,wBAAwB,GAAG,CAC/B,GAAGC,mBAAY,EACf,UAAU,EACV,GAAGF,UAAU,CACL;AAOK,SAASG,gBAAgBA,CACtCC,IAAY,EACZC,IAAa,GAAG,CAAC,CAAC,EACZ;EACN,MAAMC,GAAG,GAAGD,IAAI,CAACE,gBAAgB,GAAGP,UAAU,GAAGC,wBAAwB;EACzE,KAAK,MAAMO,GAAG,IAAIF,GAAG,EAAE;IAErB,IAAIF,IAAI,CAACI,GAAG,CAAC,IAAI,IAAI,EAAEJ,IAAI,CAACI,GAAG,CAAC,GAAGC,SAAS;EAC9C;EAEA,KAAK,MAAMD,GAAG,IAAIE,MAAM,CAACC,IAAI,CAACP,IAAI,CAAC,EAAE;IAEnC,IAAII,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IAAIJ,IAAI,CAACI,GAAG,CAAC,IAAI,IAAI,EAAEJ,IAAI,CAACI,GAAG,CAAC,GAAGC,SAAS;EAChE;EAEA,MAAMG,OAAsB,GAAGF,MAAM,CAACG,qBAAqB,CAACT,IAAI,CAAC;EACjE,KAAK,MAAMU,GAAG,IAAIF,OAAO,EAAE;IAEzBR,IAAI,CAACU,GAAG,CAAC,GAAG,IAAI;EAClB;AACF"} {"version":3,"names":["_index","require","CLEAR_KEYS","CLEAR_KEYS_PLUS_COMMENTS","COMMENT_KEYS","removeProperties","node","opts","map","preserveComments","key","undefined","Object","keys","symbols","getOwnPropertySymbols","sym"],"sources":["../../src/modifications/removeProperties.ts"],"sourcesContent":["import { COMMENT_KEYS } from \"../constants/index.ts\";\nimport type * as t from \"../index.ts\";\n\nconst CLEAR_KEYS = [\n \"tokens\", // only exist in t.File\n \"start\",\n \"end\",\n \"loc\",\n // Fixme: should be extra.raw / extra.rawValue?\n \"raw\",\n \"rawValue\",\n] as const;\n\nconst CLEAR_KEYS_PLUS_COMMENTS = [\n ...COMMENT_KEYS,\n \"comments\",\n ...CLEAR_KEYS,\n] as const;\n\nexport type Options = { preserveComments?: boolean };\n/**\n * Remove all of the _* properties from a node along with the additional metadata\n * properties like location data and raw token data.\n */\nexport default function removeProperties(\n node: t.Node,\n opts: Options = {},\n): void {\n const map = opts.preserveComments ? CLEAR_KEYS : CLEAR_KEYS_PLUS_COMMENTS;\n for (const key of map) {\n // @ts-expect-error tokens only exist in t.File\n if (node[key] != null) node[key] = undefined;\n }\n\n for (const key of Object.keys(node)) {\n // @ts-expect-error string can not index node\n if (key[0] === \"_\" && node[key] != null) node[key] = undefined;\n }\n\n const symbols: Array<symbol> = Object.getOwnPropertySymbols(node);\n for (const sym of symbols) {\n // @ts-expect-error Fixme: document symbol properties\n node[sym] = null;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGA,MAAMC,UAAU,GAAG,CACjB,QAAQ,EACR,OAAO,EACP,KAAK,EACL,KAAK,EAEL,KAAK,EACL,UAAU,CACF;AAEV,MAAMC,wBAAwB,GAAG,CAC/B,GAAGC,mBAAY,EACf,UAAU,EACV,GAAGF,UAAU,CACL;AAOK,SAASG,gBAAgBA,CACtCC,IAAY,EACZC,IAAa,GAAG,CAAC,CAAC,EACZ;EACN,MAAMC,GAAG,GAAGD,IAAI,CAACE,gBAAgB,GAAGP,UAAU,GAAGC,wBAAwB;EACzE,KAAK,MAAMO,GAAG,IAAIF,GAAG,EAAE;IAErB,IAAIF,IAAI,CAACI,GAAG,CAAC,IAAI,IAAI,EAAEJ,IAAI,CAACI,GAAG,CAAC,GAAGC,SAAS;EAC9C;EAEA,KAAK,MAAMD,GAAG,IAAIE,MAAM,CAACC,IAAI,CAACP,IAAI,CAAC,EAAE;IAEnC,IAAII,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IAAIJ,IAAI,CAACI,GAAG,CAAC,IAAI,IAAI,EAAEJ,IAAI,CAACI,GAAG,CAAC,GAAGC,SAAS;EAChE;EAEA,MAAMG,OAAsB,GAAGF,MAAM,CAACG,qBAAqB,CAACT,IAAI,CAAC;EACjE,KAAK,MAAMU,GAAG,IAAIF,OAAO,EAAE;IAEzBR,IAAI,CAACU,GAAG,CAAC,GAAG,IAAI;EAClB;AACF","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["_traverseFast","require","_removeProperties","removePropertiesDeep","tree","opts","traverseFast","removeProperties"],"sources":["../../src/modifications/removePropertiesDeep.ts"],"sourcesContent":["import traverseFast from \"../traverse/traverseFast.ts\";\nimport removeProperties from \"./removeProperties.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default function removePropertiesDeep<T extends t.Node>(\n tree: T,\n opts?: { preserveComments: boolean } | null,\n): T {\n traverseFast(tree, removeProperties, opts);\n\n return tree;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAGe,SAASE,oBAAoBA,CAC1CC,IAAO,EACPC,IAA2C,EACxC;EACH,IAAAC,qBAAY,EAACF,IAAI,EAAEG,yBAAgB,EAAEF,IAAI,CAAC;EAE1C,OAAOD,IAAI;AACb"} {"version":3,"names":["_traverseFast","require","_removeProperties","removePropertiesDeep","tree","opts","traverseFast","removeProperties"],"sources":["../../src/modifications/removePropertiesDeep.ts"],"sourcesContent":["import traverseFast from \"../traverse/traverseFast.ts\";\nimport removeProperties from \"./removeProperties.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default function removePropertiesDeep<T extends t.Node>(\n tree: T,\n opts?: { preserveComments: boolean } | null,\n): T {\n traverseFast(tree, removeProperties, opts);\n\n return tree;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAGe,SAASE,oBAAoBA,CAC1CC,IAAO,EACPC,IAA2C,EACxC;EACH,IAAAC,qBAAY,EAACF,IAAI,EAAEG,yBAAgB,EAAEF,IAAI,CAAC;EAE1C,OAAOD,IAAI;AACb","ignoreList":[]}

View File

@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
exports.default = removeTypeDuplicates; exports.default = removeTypeDuplicates;
var _index = require("../../validators/generated/index.js"); var _index = require("../../validators/generated/index.js");
function getQualifiedName(node) { function getQualifiedName(node) {
return (0, _index.isIdentifier)(node) ? node.name : `${node.right.name}.${getQualifiedName(node.left)}`; return (0, _index.isIdentifier)(node) ? node.name : (0, _index.isThisExpression)(node) ? "this" : `${node.right.name}.${getQualifiedName(node.left)}`;
} }
function removeTypeDuplicates(nodesIn) { function removeTypeDuplicates(nodesIn) {
const nodes = Array.from(nodesIn); const nodes = Array.from(nodesIn);
@ -17,7 +17,7 @@ function removeTypeDuplicates(nodesIn) {
for (let i = 0; i < nodes.length; i++) { for (let i = 0; i < nodes.length; i++) {
const node = nodes[i]; const node = nodes[i];
if (!node) continue; if (!node) continue;
if (types.indexOf(node) >= 0) { if (types.includes(node)) {
continue; continue;
} }
if ((0, _index.isTSAnyKeyword)(node)) { if ((0, _index.isTSAnyKeyword)(node)) {
@ -34,17 +34,18 @@ function removeTypeDuplicates(nodesIn) {
} }
continue; continue;
} }
if ((0, _index.isTSTypeReference)(node) && node.typeParameters) { const typeArgumentsKey = "typeParameters";
if ((0, _index.isTSTypeReference)(node) && node[typeArgumentsKey]) {
const typeArguments = node[typeArgumentsKey];
const name = getQualifiedName(node.typeName); const name = getQualifiedName(node.typeName);
if (generics.has(name)) { if (generics.has(name)) {
let existing = generics.get(name); let existing = generics.get(name);
if (existing.typeParameters) { const existingTypeArguments = existing[typeArgumentsKey];
if (node.typeParameters) { if (existingTypeArguments) {
existing.typeParameters.params.push(...node.typeParameters.params); existingTypeArguments.params.push(...typeArguments.params);
existing.typeParameters.params = removeTypeDuplicates(existing.typeParameters.params); existingTypeArguments.params = removeTypeDuplicates(existingTypeArguments.params);
}
} else { } else {
existing = node.typeParameters; existing = typeArguments;
} }
} else { } else {
generics.set(name, node); generics.set(name, node);

File diff suppressed because one or more lines are too long

View File

@ -11,10 +11,9 @@ function getBindingIdentifiers(node, duplicates, outerOnly, newBindingsOnly) {
while (search.length) { while (search.length) {
const id = search.shift(); const id = search.shift();
if (!id) continue; if (!id) continue;
if (newBindingsOnly && ((0, _index.isAssignmentExpression)(id) || (0, _index.isUnaryExpression)(id))) { if (newBindingsOnly && ((0, _index.isAssignmentExpression)(id) || (0, _index.isUnaryExpression)(id) || (0, _index.isUpdateExpression)(id))) {
continue; continue;
} }
const keys = getBindingIdentifiers.keys[id.type];
if ((0, _index.isIdentifier)(id)) { if ((0, _index.isIdentifier)(id)) {
if (duplicates) { if (duplicates) {
const _ids = ids[id.name] = ids[id.name] || []; const _ids = ids[id.name] = ids[id.name] || [];
@ -39,19 +38,24 @@ function getBindingIdentifiers(node, duplicates, outerOnly, newBindingsOnly) {
continue; continue;
} }
} }
const keys = getBindingIdentifiers.keys[id.type];
if (keys) { if (keys) {
for (let i = 0; i < keys.length; i++) { for (let i = 0; i < keys.length; i++) {
const key = keys[i]; const key = keys[i];
const nodes = id[key]; const nodes = id[key];
if (nodes) { if (nodes) {
Array.isArray(nodes) ? search.push(...nodes) : search.push(nodes); if (Array.isArray(nodes)) {
search.push(...nodes);
} else {
search.push(nodes);
}
} }
} }
} }
} }
return ids; return ids;
} }
getBindingIdentifiers.keys = { const keys = {
DeclareClass: ["id"], DeclareClass: ["id"],
DeclareFunction: ["id"], DeclareFunction: ["id"],
DeclareModule: ["id"], DeclareModule: ["id"],
@ -70,6 +74,7 @@ getBindingIdentifiers.keys = {
ImportNamespaceSpecifier: ["local"], ImportNamespaceSpecifier: ["local"],
ImportDefaultSpecifier: ["local"], ImportDefaultSpecifier: ["local"],
ImportDeclaration: ["specifiers"], ImportDeclaration: ["specifiers"],
TSImportEqualsDeclaration: ["id"],
ExportSpecifier: ["exported"], ExportSpecifier: ["exported"],
ExportNamespaceSpecifier: ["exported"], ExportNamespaceSpecifier: ["exported"],
ExportDefaultSpecifier: ["exported"], ExportDefaultSpecifier: ["exported"],
@ -92,5 +97,6 @@ getBindingIdentifiers.keys = {
VariableDeclaration: ["declarations"], VariableDeclaration: ["declarations"],
VariableDeclarator: ["id"] VariableDeclarator: ["id"]
}; };
getBindingIdentifiers.keys = keys;
//# sourceMappingURL=getBindingIdentifiers.js.map //# sourceMappingURL=getBindingIdentifiers.js.map

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"version":3,"names":["_getBindingIdentifiers","require","_default","exports","default","getOuterBindingIdentifiers","node","duplicates","getBindingIdentifiers"],"sources":["../../src/retrievers/getOuterBindingIdentifiers.ts"],"sourcesContent":["import getBindingIdentifiers from \"./getBindingIdentifiers.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default getOuterBindingIdentifiers as {\n (node: t.Node, duplicates: true): Record<string, Array<t.Identifier>>;\n (node: t.Node, duplicates?: false): Record<string, t.Identifier>;\n (\n node: t.Node,\n duplicates?: boolean,\n ): Record<string, t.Identifier> | Record<string, Array<t.Identifier>>;\n};\n\nfunction getOuterBindingIdentifiers(\n node: t.Node,\n duplicates: boolean,\n): Record<string, t.Identifier> | Record<string, Array<t.Identifier>> {\n return getBindingIdentifiers(node, duplicates, true);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AAA+D,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGhDC,0BAA0B;AASzC,SAASA,0BAA0BA,CACjCC,IAAY,EACZC,UAAmB,EACiD;EACpE,OAAO,IAAAC,8BAAqB,EAACF,IAAI,EAAEC,UAAU,EAAE,IAAI,CAAC;AACtD"} {"version":3,"names":["_getBindingIdentifiers","require","_default","exports","default","getOuterBindingIdentifiers","node","duplicates","getBindingIdentifiers"],"sources":["../../src/retrievers/getOuterBindingIdentifiers.ts"],"sourcesContent":["import getBindingIdentifiers from \"./getBindingIdentifiers.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default getOuterBindingIdentifiers as {\n (node: t.Node, duplicates: true): Record<string, Array<t.Identifier>>;\n (node: t.Node, duplicates?: false): Record<string, t.Identifier>;\n (\n node: t.Node,\n duplicates?: boolean,\n ): Record<string, t.Identifier> | Record<string, Array<t.Identifier>>;\n};\n\nfunction getOuterBindingIdentifiers(\n node: t.Node,\n duplicates: boolean,\n): Record<string, t.Identifier> | Record<string, Array<t.Identifier>> {\n return getBindingIdentifiers(node, duplicates, true);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AAA+D,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGhDC,0BAA0B;AASzC,SAASA,0BAA0BA,CACjCC,IAAY,EACZC,UAAmB,EACiD;EACpE,OAAO,IAAAC,8BAAqB,EAACF,IAAI,EAAEC,UAAU,EAAE,IAAI,CAAC;AACtD","ignoreList":[]}

View File

@ -1 +1 @@
{"version":3,"names":["_index","require","traverse","node","handlers","state","enter","exit","traverseSimpleImpl","ancestors","keys","VISITOR_KEYS","type","key","subNode","Array","isArray","i","length","child","push","index","pop"],"sources":["../../src/traverse/traverse.ts"],"sourcesContent":["import { VISITOR_KEYS } from \"../definitions/index.ts\";\nimport type * as t from \"../index.ts\";\n\nexport type TraversalAncestors = Array<{\n node: t.Node;\n key: string;\n index?: number;\n}>;\n\nexport type TraversalHandler<T> = (\n this: undefined,\n node: t.Node,\n parent: TraversalAncestors,\n state: T,\n) => void;\n\nexport type TraversalHandlers<T> = {\n enter?: TraversalHandler<T>;\n exit?: TraversalHandler<T>;\n};\n\n/**\n * A general AST traversal with both prefix and postfix handlers, and a\n * state object. Exposes ancestry data to each handler so that more complex\n * AST data can be taken into account.\n */\nexport default function traverse<T>(\n node: t.Node,\n handlers: TraversalHandler<T> | TraversalHandlers<T>,\n state?: T,\n): void {\n if (typeof handlers === \"function\") {\n handlers = { enter: handlers };\n }\n\n const { enter, exit } = handlers;\n\n traverseSimpleImpl(node, enter, exit, state, []);\n}\n\nfunction traverseSimpleImpl<T>(\n node: any,\n enter: Function | undefined,\n exit: Function | undefined,\n state: T | undefined,\n ancestors: TraversalAncestors,\n) {\n const keys = VISITOR_KEYS[node.type];\n if (!keys) return;\n\n if (enter) enter(node, ancestors, state);\n\n for (const key of keys) {\n const subNode = node[key];\n\n if (Array.isArray(subNode)) {\n for (let i = 0; i < subNode.length; i++) {\n const child = subNode[i];\n if (!child) continue;\n\n ancestors.push({\n node,\n key,\n index: i,\n });\n\n traverseSimpleImpl(child, enter, exit, state, ancestors);\n\n ancestors.pop();\n }\n } else if (subNode) {\n ancestors.push({\n node,\n key,\n });\n\n traverseSimpleImpl(subNode, enter, exit, state, ancestors);\n\n ancestors.pop();\n }\n }\n\n if (exit) exit(node, ancestors, state);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AA0Be,SAASC,QAAQA,CAC9BC,IAAY,EACZC,QAAoD,EACpDC,KAAS,EACH;EACN,IAAI,OAAOD,QAAQ,KAAK,UAAU,EAAE;IAClCA,QAAQ,GAAG;MAAEE,KAAK,EAAEF;IAAS,CAAC;EAChC;EAEA,MAAM;IAAEE,KAAK;IAAEC;EAAK,CAAC,GAAGH,QAAQ;EAEhCI,kBAAkB,CAACL,IAAI,EAAEG,KAAK,EAAEC,IAAI,EAAEF,KAAK,EAAE,EAAE,CAAC;AAClD;AAEA,SAASG,kBAAkBA,CACzBL,IAAS,EACTG,KAA2B,EAC3BC,IAA0B,EAC1BF,KAAoB,EACpBI,SAA6B,EAC7B;EACA,MAAMC,IAAI,GAAGC,mBAAY,CAACR,IAAI,CAACS,IAAI,CAAC;EACpC,IAAI,CAACF,IAAI,EAAE;EAEX,IAAIJ,KAAK,EAAEA,KAAK,CAACH,IAAI,EAAEM,SAAS,EAAEJ,KAAK,CAAC;EAExC,KAAK,MAAMQ,GAAG,IAAIH,IAAI,EAAE;IACtB,MAAMI,OAAO,GAAGX,IAAI,CAACU,GAAG,CAAC;IAEzB,IAAIE,KAAK,CAACC,OAAO,CAACF,OAAO,CAAC,EAAE;MAC1B,KAAK,IAAIG,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,OAAO,CAACI,MAAM,EAAED,CAAC,EAAE,EAAE;QACvC,MAAME,KAAK,GAAGL,OAAO,CAACG,CAAC,CAAC;QACxB,IAAI,CAACE,KAAK,EAAE;QAEZV,SAAS,CAACW,IAAI,CAAC;UACbjB,IAAI;UACJU,GAAG;UACHQ,KAAK,EAAEJ;QACT,CAAC,CAAC;QAEFT,kBAAkB,CAACW,KAAK,EAAEb,KAAK,EAAEC,IAAI,EAAEF,KAAK,EAAEI,SAAS,CAAC;QAExDA,SAAS,CAACa,GAAG,CAAC,CAAC;MACjB;IACF,CAAC,MAAM,IAAIR,OAAO,EAAE;MAClBL,SAAS,CAACW,IAAI,CAAC;QACbjB,IAAI;QACJU;MACF,CAAC,CAAC;MAEFL,kBAAkB,CAACM,OAAO,EAAER,KAAK,EAAEC,IAAI,EAAEF,KAAK,EAAEI,SAAS,CAAC;MAE1DA,SAAS,CAACa,GAAG,CAAC,CAAC;IACjB;EACF;EAEA,IAAIf,IAAI,EAAEA,IAAI,CAACJ,IAAI,EAAEM,SAAS,EAAEJ,KAAK,CAAC;AACxC"} {"version":3,"names":["_index","require","traverse","node","handlers","state","enter","exit","traverseSimpleImpl","ancestors","keys","VISITOR_KEYS","type","key","subNode","Array","isArray","i","length","child","push","index","pop"],"sources":["../../src/traverse/traverse.ts"],"sourcesContent":["import { VISITOR_KEYS } from \"../definitions/index.ts\";\nimport type * as t from \"../index.ts\";\n\nexport type TraversalAncestors = Array<{\n node: t.Node;\n key: string;\n index?: number;\n}>;\n\nexport type TraversalHandler<T> = (\n this: undefined,\n node: t.Node,\n parent: TraversalAncestors,\n state: T,\n) => void;\n\nexport type TraversalHandlers<T> = {\n enter?: TraversalHandler<T>;\n exit?: TraversalHandler<T>;\n};\n\n/**\n * A general AST traversal with both prefix and postfix handlers, and a\n * state object. Exposes ancestry data to each handler so that more complex\n * AST data can be taken into account.\n */\nexport default function traverse<T>(\n node: t.Node,\n handlers: TraversalHandler<T> | TraversalHandlers<T>,\n state?: T,\n): void {\n if (typeof handlers === \"function\") {\n handlers = { enter: handlers };\n }\n\n const { enter, exit } = handlers;\n\n traverseSimpleImpl(node, enter, exit, state, []);\n}\n\nfunction traverseSimpleImpl<T>(\n node: any,\n enter: Function | undefined,\n exit: Function | undefined,\n state: T | undefined,\n ancestors: TraversalAncestors,\n) {\n const keys = VISITOR_KEYS[node.type];\n if (!keys) return;\n\n if (enter) enter(node, ancestors, state);\n\n for (const key of keys) {\n const subNode = node[key];\n\n if (Array.isArray(subNode)) {\n for (let i = 0; i < subNode.length; i++) {\n const child = subNode[i];\n if (!child) continue;\n\n ancestors.push({\n node,\n key,\n index: i,\n });\n\n traverseSimpleImpl(child, enter, exit, state, ancestors);\n\n ancestors.pop();\n }\n } else if (subNode) {\n ancestors.push({\n node,\n key,\n });\n\n traverseSimpleImpl(subNode, enter, exit, state, ancestors);\n\n ancestors.pop();\n }\n }\n\n if (exit) exit(node, ancestors, state);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AA0Be,SAASC,QAAQA,CAC9BC,IAAY,EACZC,QAAoD,EACpDC,KAAS,EACH;EACN,IAAI,OAAOD,QAAQ,KAAK,UAAU,EAAE;IAClCA,QAAQ,GAAG;MAAEE,KAAK,EAAEF;IAAS,CAAC;EAChC;EAEA,MAAM;IAAEE,KAAK;IAAEC;EAAK,CAAC,GAAGH,QAAQ;EAEhCI,kBAAkB,CAACL,IAAI,EAAEG,KAAK,EAAEC,IAAI,EAAEF,KAAK,EAAE,EAAE,CAAC;AAClD;AAEA,SAASG,kBAAkBA,CACzBL,IAAS,EACTG,KAA2B,EAC3BC,IAA0B,EAC1BF,KAAoB,EACpBI,SAA6B,EAC7B;EACA,MAAMC,IAAI,GAAGC,mBAAY,CAACR,IAAI,CAACS,IAAI,CAAC;EACpC,IAAI,CAACF,IAAI,EAAE;EAEX,IAAIJ,KAAK,EAAEA,KAAK,CAACH,IAAI,EAAEM,SAAS,EAAEJ,KAAK,CAAC;EAExC,KAAK,MAAMQ,GAAG,IAAIH,IAAI,EAAE;IACtB,MAAMI,OAAO,GAAGX,IAAI,CAACU,GAAG,CAAC;IAEzB,IAAIE,KAAK,CAACC,OAAO,CAACF,OAAO,CAAC,EAAE;MAC1B,KAAK,IAAIG,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,OAAO,CAACI,MAAM,EAAED,CAAC,EAAE,EAAE;QACvC,MAAME,KAAK,GAAGL,OAAO,CAACG,CAAC,CAAC;QACxB,IAAI,CAACE,KAAK,EAAE;QAEZV,SAAS,CAACW,IAAI,CAAC;UACbjB,IAAI;UACJU,GAAG;UACHQ,KAAK,EAAEJ;QACT,CAAC,CAAC;QAEFT,kBAAkB,CAACW,KAAK,EAAEb,KAAK,EAAEC,IAAI,EAAEF,KAAK,EAAEI,SAAS,CAAC;QAExDA,SAAS,CAACa,GAAG,CAAC,CAAC;MACjB;IACF,CAAC,MAAM,IAAIR,OAAO,EAAE;MAClBL,SAAS,CAACW,IAAI,CAAC;QACbjB,IAAI;QACJU;MACF,CAAC,CAAC;MAEFL,kBAAkB,CAACM,OAAO,EAAER,KAAK,EAAEC,IAAI,EAAEF,KAAK,EAAEI,SAAS,CAAC;MAE1DA,SAAS,CAACa,GAAG,CAAC,CAAC;IACjB;EACF;EAEA,IAAIf,IAAI,EAAEA,IAAI,CAACJ,IAAI,EAAEM,SAAS,EAAEJ,KAAK,CAAC;AACxC","ignoreList":[]}

View File

@ -5,22 +5,36 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = traverseFast; exports.default = traverseFast;
var _index = require("../definitions/index.js"); var _index = require("../definitions/index.js");
const _skip = Symbol();
const _stop = Symbol();
function traverseFast(node, enter, opts) { function traverseFast(node, enter, opts) {
if (!node) return; if (!node) return false;
const keys = _index.VISITOR_KEYS[node.type]; const keys = _index.VISITOR_KEYS[node.type];
if (!keys) return; if (!keys) return false;
opts = opts || {}; opts = opts || {};
enter(node, opts); const ret = enter(node, opts);
if (ret !== undefined) {
switch (ret) {
case _skip:
return false;
case _stop:
return true;
}
}
for (const key of keys) { for (const key of keys) {
const subNode = node[key]; const subNode = node[key];
if (!subNode) continue;
if (Array.isArray(subNode)) { if (Array.isArray(subNode)) {
for (const node of subNode) { for (const node of subNode) {
traverseFast(node, enter, opts); if (traverseFast(node, enter, opts)) return true;
} }
} else { } else {
traverseFast(subNode, enter, opts); if (traverseFast(subNode, enter, opts)) return true;
} }
} }
return false;
} }
traverseFast.skip = _skip;
traverseFast.stop = _stop;
//# sourceMappingURL=traverseFast.js.map //# sourceMappingURL=traverseFast.js.map

View File

@ -1 +1 @@
{"version":3,"names":["_index","require","traverseFast","node","enter","opts","keys","VISITOR_KEYS","type","key","subNode","Array","isArray"],"sources":["../../src/traverse/traverseFast.ts"],"sourcesContent":["import { VISITOR_KEYS } from \"../definitions/index.ts\";\nimport type * as t from \"../index.ts\";\n\n/**\n * A prefix AST traversal implementation meant for simple searching\n * and processing.\n */\nexport default function traverseFast<Options = {}>(\n node: t.Node | null | undefined,\n enter: (node: t.Node, opts?: Options) => void,\n opts?: Options,\n): void {\n if (!node) return;\n\n const keys = VISITOR_KEYS[node.type];\n if (!keys) return;\n\n opts = opts || ({} as Options);\n enter(node, opts);\n\n for (const key of keys) {\n const subNode: t.Node | undefined | null =\n // @ts-expect-error key must present in node\n node[key];\n\n if (Array.isArray(subNode)) {\n for (const node of subNode) {\n traverseFast(node, enter, opts);\n }\n } else {\n traverseFast(subNode, enter, opts);\n }\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAOe,SAASC,YAAYA,CAClCC,IAA+B,EAC/BC,KAA6C,EAC7CC,IAAc,EACR;EACN,IAAI,CAACF,IAAI,EAAE;EAEX,MAAMG,IAAI,GAAGC,mBAAY,CAACJ,IAAI,CAACK,IAAI,CAAC;EACpC,IAAI,CAACF,IAAI,EAAE;EAEXD,IAAI,GAAGA,IAAI,IAAK,CAAC,CAAa;EAC9BD,KAAK,CAACD,IAAI,EAAEE,IAAI,CAAC;EAEjB,KAAK,MAAMI,GAAG,IAAIH,IAAI,EAAE;IACtB,MAAMI,OAAkC,GAEtCP,IAAI,CAACM,GAAG,CAAC;IAEX,IAAIE,KAAK,CAACC,OAAO,CAACF,OAAO,CAAC,EAAE;MAC1B,KAAK,MAAMP,IAAI,IAAIO,OAAO,EAAE;QAC1BR,YAAY,CAACC,IAAI,EAAEC,KAAK,EAAEC,IAAI,CAAC;MACjC;IACF,CAAC,MAAM;MACLH,YAAY,CAACQ,OAAO,EAAEN,KAAK,EAAEC,IAAI,CAAC;IACpC;EACF;AACF"} {"version":3,"names":["_index","require","_skip","Symbol","_stop","traverseFast","node","enter","opts","keys","VISITOR_KEYS","type","ret","undefined","key","subNode","Array","isArray","skip","stop"],"sources":["../../src/traverse/traverseFast.ts"],"sourcesContent":["import { VISITOR_KEYS } from \"../definitions/index.ts\";\nimport type * as t from \"../index.ts\";\n\nconst _skip = Symbol();\nconst _stop = Symbol();\n\n/**\n * A prefix AST traversal implementation meant for simple searching and processing.\n * @param enter The callback can return `traverseFast.skip` to skip the subtree of the current node, or `traverseFast.stop` to stop the traversal.\n * @returns `true` if the traversal was stopped by callback, `false` otherwise.\n */\nexport default function traverseFast<Options = object>(\n node: t.Node | null | undefined,\n enter: (\n node: t.Node,\n opts?: Options,\n ) => void | typeof traverseFast.skip | typeof traverseFast.stop,\n opts?: Options,\n): boolean {\n if (!node) return false;\n\n const keys = VISITOR_KEYS[node.type];\n if (!keys) return false;\n\n opts = opts || ({} as Options);\n const ret = enter(node, opts);\n if (ret !== undefined) {\n switch (ret) {\n case _skip:\n return false;\n case _stop:\n return true;\n }\n }\n\n for (const key of keys) {\n const subNode: t.Node | undefined | null =\n // @ts-expect-error key must present in node\n node[key];\n\n if (!subNode) continue;\n\n if (Array.isArray(subNode)) {\n for (const node of subNode) {\n if (traverseFast(node, enter, opts)) return true;\n }\n } else {\n if (traverseFast(subNode, enter, opts)) return true;\n }\n }\n return false;\n}\n\ntraverseFast.skip = _skip;\ntraverseFast.stop = _stop;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGA,MAAMC,KAAK,GAAGC,MAAM,CAAC,CAAC;AACtB,MAAMC,KAAK,GAAGD,MAAM,CAAC,CAAC;AAOP,SAASE,YAAYA,CAClCC,IAA+B,EAC/BC,KAG+D,EAC/DC,IAAc,EACL;EACT,IAAI,CAACF,IAAI,EAAE,OAAO,KAAK;EAEvB,MAAMG,IAAI,GAAGC,mBAAY,CAACJ,IAAI,CAACK,IAAI,CAAC;EACpC,IAAI,CAACF,IAAI,EAAE,OAAO,KAAK;EAEvBD,IAAI,GAAGA,IAAI,IAAK,CAAC,CAAa;EAC9B,MAAMI,GAAG,GAAGL,KAAK,CAACD,IAAI,EAAEE,IAAI,CAAC;EAC7B,IAAII,GAAG,KAAKC,SAAS,EAAE;IACrB,QAAQD,GAAG;MACT,KAAKV,KAAK;QACR,OAAO,KAAK;MACd,KAAKE,KAAK;QACR,OAAO,IAAI;IACf;EACF;EAEA,KAAK,MAAMU,GAAG,IAAIL,IAAI,EAAE;IACtB,MAAMM,OAAkC,GAEtCT,IAAI,CAACQ,GAAG,CAAC;IAEX,IAAI,CAACC,OAAO,EAAE;IAEd,IAAIC,KAAK,CAACC,OAAO,CAACF,OAAO,CAAC,EAAE;MAC1B,KAAK,MAAMT,IAAI,IAAIS,OAAO,EAAE;QAC1B,IAAIV,YAAY,CAACC,IAAI,EAAEC,KAAK,EAAEC,IAAI,CAAC,EAAE,OAAO,IAAI;MAClD;IACF,CAAC,MAAM;MACL,IAAIH,YAAY,CAACU,OAAO,EAAER,KAAK,EAAEC,IAAI,CAAC,EAAE,OAAO,IAAI;IACrD;EACF;EACA,OAAO,KAAK;AACd;AAEAH,YAAY,CAACa,IAAI,GAAGhB,KAAK;AACzBG,YAAY,CAACc,IAAI,GAAGf,KAAK","ignoreList":[]}

View File

@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
}); });
exports.default = deprecationWarning; exports.default = deprecationWarning;
const warnings = new Set(); const warnings = new Set();
function deprecationWarning(oldName, newName, prefix = "") { function deprecationWarning(oldName, newName, prefix = "", cacheKey = oldName) {
if (warnings.has(oldName)) return; if (warnings.has(cacheKey)) return;
warnings.add(oldName); warnings.add(cacheKey);
const { const {
internal, internal,
trace trace

Some files were not shown because too many files have changed in this diff Show More