From c34cb8de77695e73edc237d8e702e03dd30471a8 Mon Sep 17 00:00:00 2001 From: JamesIves Date: Tue, 31 Mar 2020 08:54:41 -0400 Subject: [PATCH] 3.4.3 Dependencies --- node_modules/@babel/parser/CHANGELOG.md | 1073 -- node_modules/@babel/parser/LICENSE | 19 - node_modules/@babel/parser/README.md | 19 - .../@babel/parser/bin/babel-parser.js | 15 - node_modules/@babel/parser/lib/index.js | 12736 ---------------- node_modules/@babel/parser/lib/index.js.map | 1 - .../@babel/parser/typings/babel-parser.d.ts | 146 - node_modules/@jest/test-sequencer/LICENSE | 21 - .../@jest/test-sequencer/build/index.d.ts | 52 - .../@jest/test-sequencer/build/index.d.ts.map | 1 - .../@jest/test-sequencer/build/index.js | 213 - .../test-sequencer/build/ts3.4/index.d.ts | 52 - .../node_modules/.bin/jest-runtime | 1 - node_modules/babel-jest/LICENSE | 21 - node_modules/babel-jest/README.md | 25 - node_modules/babel-jest/build/index.d.ts | 16 - node_modules/babel-jest/build/index.d.ts.map | 1 - node_modules/babel-jest/build/index.js | 283 - .../babel-jest/build/ts3.4/index.d.ts | 16 - .../babel-plugin-istanbul/CHANGELOG.md | 306 - node_modules/babel-plugin-istanbul/LICENSE | 27 - node_modules/babel-plugin-istanbul/README.md | 137 - .../babel-plugin-istanbul/lib/index.js | 170 - .../lib/load-nyc-config-sync.js | 20 - .../istanbul-lib-instrument/CHANGELOG.md | 548 - node_modules/istanbul-lib-instrument/LICENSE | 24 - .../istanbul-lib-instrument/README.md | 21 - .../istanbul-lib-instrument/dist/constants.js | 22 - .../istanbul-lib-instrument/dist/index.js | 42 - .../dist/instrumenter.js | 182 - .../dist/read-coverage.js | 87 - .../dist/source-coverage.js | 121 - .../istanbul-lib-instrument/dist/visitor.js | 680 - .../@babel/core/node_modules/.bin/json5 | 1 - .../@babel/core/node_modules/.bin/parser | 1 - .../@babel/core/node_modules/.bin/semver | 1 - .../node_modules/semver/CHANGELOG.md | 70 - .../node_modules/semver/LICENSE | 15 - .../node_modules/semver/README.md | 443 - .../node_modules/semver/bin/semver.js | 174 - .../node_modules/semver/range.bnf | 16 - .../node_modules/semver/semver.js | 1596 -- node_modules/jest-config/LICENSE | 21 - node_modules/jest-config/build/Defaults.d.ts | 10 - .../jest-config/build/Defaults.d.ts.map | 1 - node_modules/jest-config/build/Defaults.js | 94 - .../jest-config/build/Deprecated.d.ts | 9 - .../jest-config/build/Deprecated.d.ts.map | 1 - node_modules/jest-config/build/Deprecated.js | 98 - .../jest-config/build/Descriptions.d.ts | 12 - .../jest-config/build/Descriptions.d.ts.map | 1 - .../jest-config/build/Descriptions.js | 102 - .../build/ReporterValidationErrors.d.ts | 20 - .../build/ReporterValidationErrors.d.ts.map | 1 - .../build/ReporterValidationErrors.js | 138 - .../jest-config/build/ValidConfig.d.ts | 10 - .../jest-config/build/ValidConfig.d.ts.map | 1 - node_modules/jest-config/build/ValidConfig.js | 179 - node_modules/jest-config/build/color.d.ts | 8 - node_modules/jest-config/build/color.d.ts.map | 1 - node_modules/jest-config/build/color.js | 51 - node_modules/jest-config/build/constants.d.ts | 17 - .../jest-config/build/constants.d.ts.map | 1 - node_modules/jest-config/build/constants.js | 90 - .../jest-config/build/getCacheDirectory.d.ts | 9 - .../build/getCacheDirectory.d.ts.map | 1 - .../jest-config/build/getCacheDirectory.js | 104 - .../jest-config/build/getMaxWorkers.d.ts | 9 - .../jest-config/build/getMaxWorkers.d.ts.map | 1 - .../jest-config/build/getMaxWorkers.js | 57 - node_modules/jest-config/build/importEsm.d.ts | 11 - .../jest-config/build/importEsm.d.ts.map | 1 - node_modules/jest-config/build/importEsm.js | 30 - node_modules/jest-config/build/index.d.ts | 28 - node_modules/jest-config/build/index.d.ts.map | 1 - node_modules/jest-config/build/index.js | 474 - node_modules/jest-config/build/normalize.d.ts | 14 - .../jest-config/build/normalize.d.ts.map | 1 - node_modules/jest-config/build/normalize.js | 1311 -- .../build/readConfigFileAndSetRootDir.d.ts | 9 - .../readConfigFileAndSetRootDir.d.ts.map | 1 - .../build/readConfigFileAndSetRootDir.js | 157 - .../jest-config/build/resolveConfigPath.d.ts | 9 - .../build/resolveConfigPath.d.ts.map | 1 - .../jest-config/build/resolveConfigPath.js | 153 - .../jest-config/build/setFromArgv.d.ts | 9 - .../jest-config/build/setFromArgv.d.ts.map | 1 - node_modules/jest-config/build/setFromArgv.js | 119 - .../jest-config/build/ts3.4/Defaults.d.ts | 10 - .../jest-config/build/ts3.4/Deprecated.d.ts | 9 - .../jest-config/build/ts3.4/Descriptions.d.ts | 12 - .../build/ts3.4/ReporterValidationErrors.d.ts | 20 - .../jest-config/build/ts3.4/ValidConfig.d.ts | 10 - .../jest-config/build/ts3.4/color.d.ts | 8 - .../jest-config/build/ts3.4/constants.d.ts | 17 - .../build/ts3.4/getCacheDirectory.d.ts | 9 - .../build/ts3.4/getMaxWorkers.d.ts | 9 - .../jest-config/build/ts3.4/importEsm.d.ts | 11 - .../jest-config/build/ts3.4/index.d.ts | 28 - .../jest-config/build/ts3.4/normalize.d.ts | 14 - .../ts3.4/readConfigFileAndSetRootDir.d.ts | 9 - .../build/ts3.4/resolveConfigPath.d.ts | 9 - .../jest-config/build/ts3.4/setFromArgv.d.ts | 9 - .../jest-config/build/ts3.4/utils.d.ts | 75 - .../build/ts3.4/validatePattern.d.ts | 8 - node_modules/jest-config/build/utils.d.ts | 75 - node_modules/jest-config/build/utils.d.ts.map | 1 - node_modules/jest-config/build/utils.js | 313 - .../jest-config/build/validatePattern.d.ts | 8 - .../build/validatePattern.d.ts.map | 1 - .../jest-config/build/validatePattern.js | 25 - .../jest-config/build/vendor/jsonlint.js | 917 -- node_modules/jest-runner/LICENSE | 21 - node_modules/jest-runner/build/index.d.ts | 27 - node_modules/jest-runner/build/index.d.ts.map | 1 - node_modules/jest-runner/build/index.js | 252 - node_modules/jest-runner/build/runTest.d.ts | 13 - .../jest-runner/build/runTest.d.ts.map | 1 - node_modules/jest-runner/build/runTest.js | 506 - .../jest-runner/build/testWorker.d.ts | 27 - .../jest-runner/build/testWorker.d.ts.map | 1 - node_modules/jest-runner/build/testWorker.js | 184 - .../jest-runner/build/ts3.4/index.d.ts | 27 - .../jest-runner/build/ts3.4/runTest.d.ts | 13 - .../jest-runner/build/ts3.4/testWorker.d.ts | 27 - .../jest-runner/build/ts3.4/types.d.ts | 55 - node_modules/jest-runner/build/types.d.ts | 54 - node_modules/jest-runner/build/types.d.ts.map | 1 - node_modules/jest-runner/build/types.js | 25 - .../node_modules/.bin/jest-runtime | 1 - node_modules/jest-runtime/LICENSE | 21 - node_modules/jest-runtime/bin/jest-runtime.js | 13 - node_modules/jest-runtime/build/cli/args.d.ts | 10 - .../jest-runtime/build/cli/args.d.ts.map | 1 - node_modules/jest-runtime/build/cli/args.js | 46 - .../jest-runtime/build/cli/index.d.ts | 9 - .../jest-runtime/build/cli/index.d.ts.map | 1 - node_modules/jest-runtime/build/cli/index.js | 291 - node_modules/jest-runtime/build/helpers.d.ts | 8 - .../jest-runtime/build/helpers.d.ts.map | 1 - node_modules/jest-runtime/build/helpers.js | 131 - node_modules/jest-runtime/build/index.d.ts | 113 - .../jest-runtime/build/index.d.ts.map | 1 - node_modules/jest-runtime/build/index.js | 1551 -- .../jest-runtime/build/ts3.4/cli/args.d.ts | 10 - .../jest-runtime/build/ts3.4/cli/index.d.ts | 9 - .../jest-runtime/build/ts3.4/helpers.d.ts | 8 - .../jest-runtime/build/ts3.4/index.d.ts | 113 - .../jest-runtime/build/ts3.4/types.d.ts | 16 - .../jest-runtime/build/ts3.4/version.d.ts | 8 - node_modules/jest-runtime/build/types.d.ts | 16 - .../jest-runtime/build/types.d.ts.map | 1 - node_modules/jest-runtime/build/types.js | 15 - node_modules/jest-runtime/build/version.d.ts | 8 - .../jest-runtime/build/version.d.ts.map | 1 - node_modules/jest-runtime/build/version.js | 17 - .../node_modules/strip-bom/index.d.ts | 14 - .../node_modules/strip-bom/index.js | 15 - .../node_modules/strip-bom/license | 9 - .../node_modules/strip-bom/readme.md | 54 - node_modules/jest/LICENSE | 21 - node_modules/jest/README.md | 11 - node_modules/jest/bin/jest.js | 13 - node_modules/jest/build/jest.d.ts | 9 - node_modules/jest/build/jest.d.ts.map | 1 - node_modules/jest/build/jest.js | 61 - node_modules/jest/build/ts3.4/jest.d.ts | 9 - .../node_modules/.bin/import-local-fixture | 1 - .../jest/node_modules/jest-cli/LICENSE | 21 - .../jest/node_modules/jest-cli/README.md | 11 - .../jest/node_modules/jest-cli/bin/jest.js | 17 - .../node_modules/jest-cli/build/cli/args.d.ts | 498 - .../jest-cli/build/cli/args.d.ts.map | 1 - .../node_modules/jest-cli/build/cli/args.js | 761 - .../jest-cli/build/cli/index.d.ts | 97 - .../jest-cli/build/cli/index.d.ts.map | 1 - .../node_modules/jest-cli/build/cli/index.js | 322 - .../node_modules/jest-cli/build/index.d.ts | 8 - .../jest-cli/build/index.d.ts.map | 1 - .../jest/node_modules/jest-cli/build/index.js | 13 - .../jest-cli/build/init/errors.d.ts | 13 - .../jest-cli/build/init/errors.d.ts.map | 1 - .../jest-cli/build/init/errors.js | 35 - .../build/init/generate_config_file.d.ts | 9 - .../build/init/generate_config_file.d.ts.map | 1 - .../build/init/generate_config_file.js | 87 - .../jest-cli/build/init/index.d.ts | 9 - .../jest-cli/build/init/index.d.ts.map | 1 - .../node_modules/jest-cli/build/init/index.js | 250 - .../build/init/modify_package_json.d.ts | 13 - .../build/init/modify_package_json.d.ts.map | 1 - .../build/init/modify_package_json.js | 28 - .../jest-cli/build/init/questions.d.ts | 11 - .../jest-cli/build/init/questions.d.ts.map | 1 - .../jest-cli/build/init/questions.js | 53 - .../jest-cli/build/init/types.d.ts | 13 - .../jest-cli/build/init/types.d.ts.map | 1 - .../node_modules/jest-cli/build/init/types.js | 1 - .../jest-cli/build/ts3.4/cli/args.d.ts | 498 - .../jest-cli/build/ts3.4/cli/index.d.ts | 97 - .../jest-cli/build/ts3.4/index.d.ts | 8 - .../jest-cli/build/ts3.4/init/errors.d.ts | 13 - .../ts3.4/init/generate_config_file.d.ts | 9 - .../jest-cli/build/ts3.4/init/index.d.ts | 9 - .../build/ts3.4/init/modify_package_json.d.ts | 13 - .../jest-cli/build/ts3.4/init/questions.d.ts | 11 - .../jest-cli/build/ts3.4/init/types.d.ts | 13 - 207 files changed, 31222 deletions(-) delete mode 100644 node_modules/@babel/parser/CHANGELOG.md delete mode 100644 node_modules/@babel/parser/LICENSE delete mode 100644 node_modules/@babel/parser/README.md delete mode 100755 node_modules/@babel/parser/bin/babel-parser.js delete mode 100644 node_modules/@babel/parser/lib/index.js delete mode 100644 node_modules/@babel/parser/lib/index.js.map delete mode 100644 node_modules/@babel/parser/typings/babel-parser.d.ts delete mode 100644 node_modules/@jest/test-sequencer/LICENSE delete mode 100644 node_modules/@jest/test-sequencer/build/index.d.ts delete mode 100644 node_modules/@jest/test-sequencer/build/index.d.ts.map delete mode 100644 node_modules/@jest/test-sequencer/build/index.js delete mode 100644 node_modules/@jest/test-sequencer/build/ts3.4/index.d.ts delete mode 120000 node_modules/@jest/test-sequencer/node_modules/.bin/jest-runtime delete mode 100644 node_modules/babel-jest/LICENSE delete mode 100644 node_modules/babel-jest/README.md delete mode 100644 node_modules/babel-jest/build/index.d.ts delete mode 100644 node_modules/babel-jest/build/index.d.ts.map delete mode 100644 node_modules/babel-jest/build/index.js delete mode 100644 node_modules/babel-jest/build/ts3.4/index.d.ts delete mode 100644 node_modules/babel-plugin-istanbul/CHANGELOG.md delete mode 100644 node_modules/babel-plugin-istanbul/LICENSE delete mode 100644 node_modules/babel-plugin-istanbul/README.md delete mode 100644 node_modules/babel-plugin-istanbul/lib/index.js delete mode 100644 node_modules/babel-plugin-istanbul/lib/load-nyc-config-sync.js delete mode 100644 node_modules/istanbul-lib-instrument/CHANGELOG.md delete mode 100644 node_modules/istanbul-lib-instrument/LICENSE delete mode 100644 node_modules/istanbul-lib-instrument/README.md delete mode 100644 node_modules/istanbul-lib-instrument/dist/constants.js delete mode 100644 node_modules/istanbul-lib-instrument/dist/index.js delete mode 100644 node_modules/istanbul-lib-instrument/dist/instrumenter.js delete mode 100644 node_modules/istanbul-lib-instrument/dist/read-coverage.js delete mode 100644 node_modules/istanbul-lib-instrument/dist/source-coverage.js delete mode 100644 node_modules/istanbul-lib-instrument/dist/visitor.js delete mode 120000 node_modules/istanbul-lib-instrument/node_modules/@babel/core/node_modules/.bin/json5 delete mode 120000 node_modules/istanbul-lib-instrument/node_modules/@babel/core/node_modules/.bin/parser delete mode 120000 node_modules/istanbul-lib-instrument/node_modules/@babel/core/node_modules/.bin/semver delete mode 100644 node_modules/istanbul-lib-instrument/node_modules/semver/CHANGELOG.md delete mode 100644 node_modules/istanbul-lib-instrument/node_modules/semver/LICENSE delete mode 100644 node_modules/istanbul-lib-instrument/node_modules/semver/README.md delete mode 100755 node_modules/istanbul-lib-instrument/node_modules/semver/bin/semver.js delete mode 100644 node_modules/istanbul-lib-instrument/node_modules/semver/range.bnf delete mode 100644 node_modules/istanbul-lib-instrument/node_modules/semver/semver.js delete mode 100644 node_modules/jest-config/LICENSE delete mode 100644 node_modules/jest-config/build/Defaults.d.ts delete mode 100644 node_modules/jest-config/build/Defaults.d.ts.map delete mode 100644 node_modules/jest-config/build/Defaults.js delete mode 100644 node_modules/jest-config/build/Deprecated.d.ts delete mode 100644 node_modules/jest-config/build/Deprecated.d.ts.map delete mode 100644 node_modules/jest-config/build/Deprecated.js delete mode 100644 node_modules/jest-config/build/Descriptions.d.ts delete mode 100644 node_modules/jest-config/build/Descriptions.d.ts.map delete mode 100644 node_modules/jest-config/build/Descriptions.js delete mode 100644 node_modules/jest-config/build/ReporterValidationErrors.d.ts delete mode 100644 node_modules/jest-config/build/ReporterValidationErrors.d.ts.map delete mode 100644 node_modules/jest-config/build/ReporterValidationErrors.js delete mode 100644 node_modules/jest-config/build/ValidConfig.d.ts delete mode 100644 node_modules/jest-config/build/ValidConfig.d.ts.map delete mode 100644 node_modules/jest-config/build/ValidConfig.js delete mode 100644 node_modules/jest-config/build/color.d.ts delete mode 100644 node_modules/jest-config/build/color.d.ts.map delete mode 100644 node_modules/jest-config/build/color.js delete mode 100644 node_modules/jest-config/build/constants.d.ts delete mode 100644 node_modules/jest-config/build/constants.d.ts.map delete mode 100644 node_modules/jest-config/build/constants.js delete mode 100644 node_modules/jest-config/build/getCacheDirectory.d.ts delete mode 100644 node_modules/jest-config/build/getCacheDirectory.d.ts.map delete mode 100644 node_modules/jest-config/build/getCacheDirectory.js delete mode 100644 node_modules/jest-config/build/getMaxWorkers.d.ts delete mode 100644 node_modules/jest-config/build/getMaxWorkers.d.ts.map delete mode 100644 node_modules/jest-config/build/getMaxWorkers.js delete mode 100644 node_modules/jest-config/build/importEsm.d.ts delete mode 100644 node_modules/jest-config/build/importEsm.d.ts.map delete mode 100644 node_modules/jest-config/build/importEsm.js delete mode 100644 node_modules/jest-config/build/index.d.ts delete mode 100644 node_modules/jest-config/build/index.d.ts.map delete mode 100644 node_modules/jest-config/build/index.js delete mode 100644 node_modules/jest-config/build/normalize.d.ts delete mode 100644 node_modules/jest-config/build/normalize.d.ts.map delete mode 100644 node_modules/jest-config/build/normalize.js delete mode 100644 node_modules/jest-config/build/readConfigFileAndSetRootDir.d.ts delete mode 100644 node_modules/jest-config/build/readConfigFileAndSetRootDir.d.ts.map delete mode 100644 node_modules/jest-config/build/readConfigFileAndSetRootDir.js delete mode 100644 node_modules/jest-config/build/resolveConfigPath.d.ts delete mode 100644 node_modules/jest-config/build/resolveConfigPath.d.ts.map delete mode 100644 node_modules/jest-config/build/resolveConfigPath.js delete mode 100644 node_modules/jest-config/build/setFromArgv.d.ts delete mode 100644 node_modules/jest-config/build/setFromArgv.d.ts.map delete mode 100644 node_modules/jest-config/build/setFromArgv.js delete mode 100644 node_modules/jest-config/build/ts3.4/Defaults.d.ts delete mode 100644 node_modules/jest-config/build/ts3.4/Deprecated.d.ts delete mode 100644 node_modules/jest-config/build/ts3.4/Descriptions.d.ts delete mode 100644 node_modules/jest-config/build/ts3.4/ReporterValidationErrors.d.ts delete mode 100644 node_modules/jest-config/build/ts3.4/ValidConfig.d.ts delete mode 100644 node_modules/jest-config/build/ts3.4/color.d.ts delete mode 100644 node_modules/jest-config/build/ts3.4/constants.d.ts delete mode 100644 node_modules/jest-config/build/ts3.4/getCacheDirectory.d.ts delete mode 100644 node_modules/jest-config/build/ts3.4/getMaxWorkers.d.ts delete mode 100644 node_modules/jest-config/build/ts3.4/importEsm.d.ts delete mode 100644 node_modules/jest-config/build/ts3.4/index.d.ts delete mode 100644 node_modules/jest-config/build/ts3.4/normalize.d.ts delete mode 100644 node_modules/jest-config/build/ts3.4/readConfigFileAndSetRootDir.d.ts delete mode 100644 node_modules/jest-config/build/ts3.4/resolveConfigPath.d.ts delete mode 100644 node_modules/jest-config/build/ts3.4/setFromArgv.d.ts delete mode 100644 node_modules/jest-config/build/ts3.4/utils.d.ts delete mode 100644 node_modules/jest-config/build/ts3.4/validatePattern.d.ts delete mode 100644 node_modules/jest-config/build/utils.d.ts delete mode 100644 node_modules/jest-config/build/utils.d.ts.map delete mode 100644 node_modules/jest-config/build/utils.js delete mode 100644 node_modules/jest-config/build/validatePattern.d.ts delete mode 100644 node_modules/jest-config/build/validatePattern.d.ts.map delete mode 100644 node_modules/jest-config/build/validatePattern.js delete mode 100644 node_modules/jest-config/build/vendor/jsonlint.js delete mode 100644 node_modules/jest-runner/LICENSE delete mode 100644 node_modules/jest-runner/build/index.d.ts delete mode 100644 node_modules/jest-runner/build/index.d.ts.map delete mode 100644 node_modules/jest-runner/build/index.js delete mode 100644 node_modules/jest-runner/build/runTest.d.ts delete mode 100644 node_modules/jest-runner/build/runTest.d.ts.map delete mode 100644 node_modules/jest-runner/build/runTest.js delete mode 100644 node_modules/jest-runner/build/testWorker.d.ts delete mode 100644 node_modules/jest-runner/build/testWorker.d.ts.map delete mode 100644 node_modules/jest-runner/build/testWorker.js delete mode 100644 node_modules/jest-runner/build/ts3.4/index.d.ts delete mode 100644 node_modules/jest-runner/build/ts3.4/runTest.d.ts delete mode 100644 node_modules/jest-runner/build/ts3.4/testWorker.d.ts delete mode 100644 node_modules/jest-runner/build/ts3.4/types.d.ts delete mode 100644 node_modules/jest-runner/build/types.d.ts delete mode 100644 node_modules/jest-runner/build/types.d.ts.map delete mode 100644 node_modules/jest-runner/build/types.js delete mode 120000 node_modules/jest-runner/node_modules/.bin/jest-runtime delete mode 100644 node_modules/jest-runtime/LICENSE delete mode 100755 node_modules/jest-runtime/bin/jest-runtime.js delete mode 100644 node_modules/jest-runtime/build/cli/args.d.ts delete mode 100644 node_modules/jest-runtime/build/cli/args.d.ts.map delete mode 100644 node_modules/jest-runtime/build/cli/args.js delete mode 100644 node_modules/jest-runtime/build/cli/index.d.ts delete mode 100644 node_modules/jest-runtime/build/cli/index.d.ts.map delete mode 100644 node_modules/jest-runtime/build/cli/index.js delete mode 100644 node_modules/jest-runtime/build/helpers.d.ts delete mode 100644 node_modules/jest-runtime/build/helpers.d.ts.map delete mode 100644 node_modules/jest-runtime/build/helpers.js delete mode 100644 node_modules/jest-runtime/build/index.d.ts delete mode 100644 node_modules/jest-runtime/build/index.d.ts.map delete mode 100644 node_modules/jest-runtime/build/index.js delete mode 100644 node_modules/jest-runtime/build/ts3.4/cli/args.d.ts delete mode 100644 node_modules/jest-runtime/build/ts3.4/cli/index.d.ts delete mode 100644 node_modules/jest-runtime/build/ts3.4/helpers.d.ts delete mode 100644 node_modules/jest-runtime/build/ts3.4/index.d.ts delete mode 100644 node_modules/jest-runtime/build/ts3.4/types.d.ts delete mode 100644 node_modules/jest-runtime/build/ts3.4/version.d.ts delete mode 100644 node_modules/jest-runtime/build/types.d.ts delete mode 100644 node_modules/jest-runtime/build/types.d.ts.map delete mode 100644 node_modules/jest-runtime/build/types.js delete mode 100644 node_modules/jest-runtime/build/version.d.ts delete mode 100644 node_modules/jest-runtime/build/version.d.ts.map delete mode 100644 node_modules/jest-runtime/build/version.js delete mode 100644 node_modules/jest-runtime/node_modules/strip-bom/index.d.ts delete mode 100644 node_modules/jest-runtime/node_modules/strip-bom/index.js delete mode 100644 node_modules/jest-runtime/node_modules/strip-bom/license delete mode 100644 node_modules/jest-runtime/node_modules/strip-bom/readme.md delete mode 100644 node_modules/jest/LICENSE delete mode 100644 node_modules/jest/README.md delete mode 100755 node_modules/jest/bin/jest.js delete mode 100644 node_modules/jest/build/jest.d.ts delete mode 100644 node_modules/jest/build/jest.d.ts.map delete mode 100644 node_modules/jest/build/jest.js delete mode 100644 node_modules/jest/build/ts3.4/jest.d.ts delete mode 120000 node_modules/jest/node_modules/.bin/import-local-fixture delete mode 100644 node_modules/jest/node_modules/jest-cli/LICENSE delete mode 100644 node_modules/jest/node_modules/jest-cli/README.md delete mode 100755 node_modules/jest/node_modules/jest-cli/bin/jest.js delete mode 100644 node_modules/jest/node_modules/jest-cli/build/cli/args.d.ts delete mode 100644 node_modules/jest/node_modules/jest-cli/build/cli/args.d.ts.map delete mode 100644 node_modules/jest/node_modules/jest-cli/build/cli/args.js delete mode 100644 node_modules/jest/node_modules/jest-cli/build/cli/index.d.ts delete mode 100644 node_modules/jest/node_modules/jest-cli/build/cli/index.d.ts.map delete mode 100644 node_modules/jest/node_modules/jest-cli/build/cli/index.js delete mode 100644 node_modules/jest/node_modules/jest-cli/build/index.d.ts delete mode 100644 node_modules/jest/node_modules/jest-cli/build/index.d.ts.map delete mode 100644 node_modules/jest/node_modules/jest-cli/build/index.js delete mode 100644 node_modules/jest/node_modules/jest-cli/build/init/errors.d.ts delete mode 100644 node_modules/jest/node_modules/jest-cli/build/init/errors.d.ts.map delete mode 100644 node_modules/jest/node_modules/jest-cli/build/init/errors.js delete mode 100644 node_modules/jest/node_modules/jest-cli/build/init/generate_config_file.d.ts delete mode 100644 node_modules/jest/node_modules/jest-cli/build/init/generate_config_file.d.ts.map delete mode 100644 node_modules/jest/node_modules/jest-cli/build/init/generate_config_file.js delete mode 100644 node_modules/jest/node_modules/jest-cli/build/init/index.d.ts delete mode 100644 node_modules/jest/node_modules/jest-cli/build/init/index.d.ts.map delete mode 100644 node_modules/jest/node_modules/jest-cli/build/init/index.js delete mode 100644 node_modules/jest/node_modules/jest-cli/build/init/modify_package_json.d.ts delete mode 100644 node_modules/jest/node_modules/jest-cli/build/init/modify_package_json.d.ts.map delete mode 100644 node_modules/jest/node_modules/jest-cli/build/init/modify_package_json.js delete mode 100644 node_modules/jest/node_modules/jest-cli/build/init/questions.d.ts delete mode 100644 node_modules/jest/node_modules/jest-cli/build/init/questions.d.ts.map delete mode 100644 node_modules/jest/node_modules/jest-cli/build/init/questions.js delete mode 100644 node_modules/jest/node_modules/jest-cli/build/init/types.d.ts delete mode 100644 node_modules/jest/node_modules/jest-cli/build/init/types.d.ts.map delete mode 100644 node_modules/jest/node_modules/jest-cli/build/init/types.js delete mode 100644 node_modules/jest/node_modules/jest-cli/build/ts3.4/cli/args.d.ts delete mode 100644 node_modules/jest/node_modules/jest-cli/build/ts3.4/cli/index.d.ts delete mode 100644 node_modules/jest/node_modules/jest-cli/build/ts3.4/index.d.ts delete mode 100644 node_modules/jest/node_modules/jest-cli/build/ts3.4/init/errors.d.ts delete mode 100644 node_modules/jest/node_modules/jest-cli/build/ts3.4/init/generate_config_file.d.ts delete mode 100644 node_modules/jest/node_modules/jest-cli/build/ts3.4/init/index.d.ts delete mode 100644 node_modules/jest/node_modules/jest-cli/build/ts3.4/init/modify_package_json.d.ts delete mode 100644 node_modules/jest/node_modules/jest-cli/build/ts3.4/init/questions.d.ts delete mode 100644 node_modules/jest/node_modules/jest-cli/build/ts3.4/init/types.d.ts diff --git a/node_modules/@babel/parser/CHANGELOG.md b/node_modules/@babel/parser/CHANGELOG.md deleted file mode 100644 index 8a43406d..00000000 --- a/node_modules/@babel/parser/CHANGELOG.md +++ /dev/null @@ -1,1073 +0,0 @@ -# Changelog - -> **Tags:** -> - :boom: [Breaking Change] -> - :eyeglasses: [Spec Compliance] -> - :rocket: [New Feature] -> - :bug: [Bug Fix] -> - :memo: [Documentation] -> - :house: [Internal] -> - :nail_care: [Polish] - -> Semver Policy: https://github.com/babel/babel/tree/master/packages/babel-parser#semver - -_Note: Gaps between patch versions are faulty, broken or test releases._ - -See the [Babel Changelog](https://github.com/babel/babel/blob/master/CHANGELOG.md) for the pre-6.8.0 version Changelog. - -## 6.17.1 (2017-05-10) - -### :bug: Bug Fix - * Fix typo in flow spread operator error (Brian Ng) - * Fixed invalid number literal parsing ([#473](https://github.com/babel/babylon/pull/473)) (Alex Kuzmenko) - * Fix number parser ([#433](https://github.com/babel/babylon/pull/433)) (Alex Kuzmenko) - * Ensure non pattern shorthand props are checked for reserved words ([#479](https://github.com/babel/babylon/pull/479)) (Brian Ng) - * Remove jsx context when parsing arrow functions ([#475](https://github.com/babel/babylon/pull/475)) (Brian Ng) - * Allow super in class properties ([#499](https://github.com/babel/babylon/pull/499)) (Brian Ng) - * Allow flow class field to be named constructor ([#510](https://github.com/babel/babylon/pull/510)) (Brian Ng) - -## 6.17.0 (2017-04-20) - -### :bug: Bug Fix - * Cherry-pick #418 to 6.x ([#476](https://github.com/babel/babylon/pull/476)) (Sebastian McKenzie) - * Add support for invalid escapes in tagged templates ([#274](https://github.com/babel/babylon/pull/274)) (Kevin Gibbons) - * Throw error if new.target is used outside of a function ([#402](https://github.com/babel/babylon/pull/402)) (Brian Ng) - * Fix parsing of class properties ([#351](https://github.com/babel/babylon/pull/351)) (Kevin Gibbons) - * Fix parsing yield with dynamicImport ([#383](https://github.com/babel/babylon/pull/383)) (Brian Ng) - * Ensure consistent start args for parseParenItem ([#386](https://github.com/babel/babylon/pull/386)) (Brian Ng) - -## 7.0.0-beta.8 (2017-04-04) - -### New Feature -* Add support for flow type spread (#418) (Conrad Buck) -* Allow statics in flow interfaces (#427) (Brian Ng) - -### Bug Fix -* Fix predicate attachment to match flow parser (#428) (Brian Ng) -* Add extra.raw back to JSXText and JSXAttribute (#344) (Alex Rattray) -* Fix rest parameters with array and objects (#424) (Brian Ng) -* Fix number parser (#433) (Alex Kuzmenko) - -### Docs -* Fix CONTRIBUTING.md [skip ci] (#432) (Alex Kuzmenko) - -### Internal -* Use babel-register script when running babel smoke tests (#442) (Brian Ng) - -## 7.0.0-beta.7 (2017-03-22) - -### Spec Compliance -* Remove babylon plugin for template revision since it's stage-4 (#426) (Henry Zhu) - -### Bug Fix - -* Fix push-pop logic in flow (#405) (Daniel Tschinder) - -## 7.0.0-beta.6 (2017-03-21) - -### New Feature -* Add support for invalid escapes in tagged templates (#274) (Kevin Gibbons) - -### Polish -* Improves error message when super is called outside of constructor (#408) (Arshabh Kumar Agarwal) - -### Docs - -* [7.0] Moved value field in spec from ObjectMember to ObjectProperty as ObjectMethod's don't have it (#415) [skip ci] (James Browning) - -## 7.0.0-beta.5 (2017-03-21) - -### Bug Fix -* Throw error if new.target is used outside of a function (#402) (Brian Ng) -* Fix parsing of class properties (#351) (Kevin Gibbons) - -### Other - * Test runner: Detect extra property in 'actual' but not in 'expected'. (#407) (Andy) - * Optimize travis builds (#419) (Daniel Tschinder) - * Update codecov to 2.0 (#412) (Daniel Tschinder) - * Fix spec for ClassMethod: It doesn't have a function, it *is* a function. (#406) [skip ci] (Andy) - * Changed Non-existent RestPattern to RestElement which is what is actually parsed (#409) [skip ci] (James Browning) - * Upgrade flow to 0.41 (Daniel Tschinder) - * Fix watch command (#403) (Brian Ng) - * Update yarn lock (Daniel Tschinder) - * Fix watch command (#403) (Brian Ng) - * chore(package): update flow-bin to version 0.41.0 (#395) (greenkeeper[bot]) - * Add estree test for correct order of directives (Daniel Tschinder) - * Add DoExpression to spec (#364) (Alex Kuzmenko) - * Mention cloning of repository in CONTRIBUTING.md (#391) [skip ci] (Sumedh Nimkarde) - * Explain how to run only one test (#389) [skip ci] (Aaron Ang) - - ## 7.0.0-beta.4 (2017-03-01) - -* Don't consume async when checking for async func decl (#377) (Brian Ng) -* add `ranges` option [skip ci] (Henry Zhu) -* Don't parse class properties without initializers when classProperties is disabled and Flow is enabled (#300) (Andrew Levine) - -## 7.0.0-beta.3 (2017-02-28) - -- [7.0] Change RestProperty/SpreadProperty to RestElement/SpreadElement (#384) -- Merge changes from 6.x - -## 7.0.0-beta.2 (2017-02-20) - -- estree: correctly change literals in all cases (#368) (Daniel Tschinder) - -## 7.0.0-beta.1 (2017-02-20) - -- Fix negative number literal typeannotations (#366) (Daniel Tschinder) -- Update contributing with more test info [skip ci] (#355) (Brian Ng) - -## 7.0.0-beta.0 (2017-02-15) - -- Reintroduce Variance node (#333) (Daniel Tschinder) -- Rename NumericLiteralTypeAnnotation to NumberLiteralTypeAnnotation (#332) (Charles Pick) -- [7.0] Remove ForAwaitStatement, add await flag to ForOfStatement (#349) (Brandon Dail) -- chore(package): update ava to version 0.18.0 (#345) (greenkeeper[bot]) -- chore(package): update babel-plugin-istanbul to version 4.0.0 (#350) (greenkeeper[bot]) -- Change location of ObjectTypeIndexer to match flow (#228) (Daniel Tschinder) -- Rename flow AST Type ExistentialTypeParam to ExistsTypeAnnotation (#322) (Toru Kobayashi) -- Revert "Temporary rollback for erroring on trailing comma with spread (#154)" (#290) (Daniel Tschinder) -- Remove classConstructorCall plugin (#291) (Brian Ng) -- Update yarn.lock (Daniel Tschinder) -- Update cross-env to 3.x (Daniel Tschinder) -- [7.0] Remove node 0.10, 0.12 and 5 from Travis (#284) (Sergey Rubanov) -- Remove `String.fromCodePoint` shim (#279) (Mathias Bynens) - -## 6.16.1 (2017-02-23) - -### :bug: Regression - -- Revert "Fix export default async function to be FunctionDeclaration" ([#375](https://github.com/babel/babylon/pull/375)) - -Need to modify Babel for this AST node change, so moving to 7.0. - -- Revert "Don't parse class properties without initializers when classProperties plugin is disabled, and Flow is enabled" ([#376](https://github.com/babel/babylon/pull/376)) - -[react-native](https://github.com/facebook/react-native/issues/12542) broke with this so we reverted. - -## 6.16.0 (2017-02-23) - -### :rocket: New Feature - -***ESTree*** compatibility as plugin ([#277](https://github.com/babel/babylon/pull/277)) (Daniel Tschinder) - -We finally introduce a new compatibility layer for ESTree. To put babylon into ESTree-compatible mode the new plugin `estree` can be enabled. In this mode the parser will output an AST that is compliant to the specs of [ESTree](https://github.com/estree/estree/) - -We highly recommend everyone who uses babylon outside of babel to use this plugin. This will make it much easier for users to switch between different ESTree-compatible parsers. We so far tested several projects with different parsers and exchanged their parser to babylon and in nearly all cases it worked out of the box. Some other estree-compatible parsers include `acorn`, `esprima`, `espree`, `flow-parser`, etc. - -To enable `estree` mode simply add the plugin in the config: -```json -{ - "plugins": [ "estree" ] -} -``` - -If you want to migrate your project from non-ESTree mode to ESTree, have a look at our [Readme](https://github.com/babel/babylon/#output), where all deviations are mentioned. - -Add a parseExpression public method ([#213](https://github.com/babel/babylon/pull/213)) (jeromew) - -Babylon exports a new function to parse a single expression - -```js -import { parseExpression } from 'babylon'; - -const ast = parseExpression('x || y && z', options); -``` - -The returned AST will only consist of the expression. The options are the same as for `parse()` - -Add startLine option ([#346](https://github.com/babel/babylon/pull/346)) (Raphael Mu) - -A new option was added to babylon allowing to change the initial linenumber for the first line which is usually `1`. -Changing this for example to `100` will make line `1` of the input source to be marked as line `100`, line `2` as `101`, line `3` as `102`, ... - -Function predicate declaration ([#103](https://github.com/babel/babylon/pull/103)) (Panagiotis Vekris) - -Added support for function predicates which flow introduced in version 0.33.0 - -```js -declare function is_number(x: mixed): boolean %checks(typeof x === "number"); -``` - -Allow imports in declare module ([#315](https://github.com/babel/babylon/pull/315)) (Daniel Tschinder) - -Added support for imports within module declarations which flow introduced in version 0.37.0 - -```js -declare module "C" { - import type { DT } from "D"; - declare export type CT = { D: DT }; -} -``` - -### :eyeglasses: Spec Compliance - -Forbid semicolons after decorators in classes ([#352](https://github.com/babel/babylon/pull/352)) (Kevin Gibbons) - -This example now correctly throws an error when there is a semicolon after the decorator: - -```js -class A { -@a; -foo(){} -} -``` - -Keywords are not allowed as local specifier ([#307](https://github.com/babel/babylon/pull/307)) (Daniel Tschinder) - -Using keywords in imports is not allowed anymore: - -```js -import { default } from "foo"; -import { a as debugger } from "foo"; -``` - -Do not allow overwritting of primitive types ([#314](https://github.com/babel/babylon/pull/314)) (Daniel Tschinder) - -In flow it is now forbidden to overwrite the primitive types `"any"`, `"mixed"`, `"empty"`, `"bool"`, `"boolean"`, `"number"`, `"string"`, `"void"` and `"null"` with your own type declaration. - -Disallow import type { type a } from … ([#305](https://github.com/babel/babylon/pull/305)) (Daniel Tschinder) - -The following code now correctly throws an error - -```js -import type { type a } from "foo"; -``` - -Don't parse class properties without initializers when classProperties is disabled and Flow is enabled ([#300](https://github.com/babel/babylon/pull/300)) (Andrew Levine) - -Ensure that you enable the `classProperties` plugin in order to enable correct parsing of class properties. Prior to this version it was possible to parse them by enabling the `flow` plugin but this was not intended the behaviour. - -If you enable the flow plugin you can only define the type of the class properties, but not initialize them. - -Fix export default async function to be FunctionDeclaration ([#324](https://github.com/babel/babylon/pull/324)) (Daniel Tschinder) - -Parsing the following code now returns a `FunctionDeclaration` AST node instead of `FunctionExpression`. - -```js -export default async function bar() {}; -``` - -### :nail_care: Polish - -Improve error message on attempt to destructure named import ([#288](https://github.com/babel/babylon/pull/288)) (Brian Ng) - -### :bug: Bug Fix - -Fix negative number literal typeannotations ([#366](https://github.com/babel/babylon/pull/366)) (Daniel Tschinder) - -Ensure takeDecorators is called on exported class ([#358](https://github.com/babel/babylon/pull/358)) (Brian Ng) - -ESTree: correctly change literals in all cases ([#368](https://github.com/babel/babylon/pull/368)) (Daniel Tschinder) - -Correctly convert RestProperty to Assignable ([#339](https://github.com/babel/babylon/pull/339)) (Daniel Tschinder) - -Fix #321 by allowing question marks in type params ([#338](https://github.com/babel/babylon/pull/338)) (Daniel Tschinder) - -Fix #336 by correctly setting arrow-param ([#337](https://github.com/babel/babylon/pull/337)) (Daniel Tschinder) - -Fix parse error when destructuring `set` with default value ([#317](https://github.com/babel/babylon/pull/317)) (Brian Ng) - -Fix ObjectTypeCallProperty static ([#298](https://github.com/babel/babylon/pull/298)) (Dan Harper) - - -### :house: Internal - -Fix generator-method-with-computed-name spec ([#360](https://github.com/babel/babylon/pull/360)) (Alex Rattray) - -Fix flow type-parameter-declaration test with unintended semantic ([#361](https://github.com/babel/babylon/pull/361)) (Alex Rattray) - -Cleanup and splitup parser functions ([#295](https://github.com/babel/babylon/pull/295)) (Daniel Tschinder) - -chore(package): update flow-bin to version 0.38.0 ([#313](https://github.com/babel/babylon/pull/313)) (greenkeeper[bot]) - -Call inner function instead of 1:1 copy to plugin ([#294](https://github.com/babel/babylon/pull/294)) (Daniel Tschinder) - -Update eslint-config-babel to the latest version πŸš€ ([#299](https://github.com/babel/babylon/pull/299)) (greenkeeper[bot]) - -Update eslint-config-babel to the latest version πŸš€ ([#293](https://github.com/babel/babylon/pull/293)) (greenkeeper[bot]) - -devDeps: remove eslint-plugin-babel ([#292](https://github.com/babel/babylon/pull/292)) (Kai Cataldo) - -Correct indent eslint rule config ([#276](https://github.com/babel/babylon/pull/276)) (Daniel Tschinder) - -Fail tests that have expected.json and throws-option ([#285](https://github.com/babel/babylon/pull/285)) (Daniel Tschinder) - -### :memo: Documentation - -Update contributing with more test info [skip ci] ([#355](https://github.com/babel/babylon/pull/355)) (Brian Ng) - -Update API documentation ([#330](https://github.com/babel/babylon/pull/330)) (Timothy Gu) - -Added keywords to package.json ([#323](https://github.com/babel/babylon/pull/323)) (Dmytro) - -AST spec: fix casing of `RegExpLiteral` ([#318](https://github.com/babel/babylon/pull/318)) (Mathias Bynens) - -## 6.15.0 (2017-01-10) - -### :eyeglasses: Spec Compliance - -Add support for Flow shorthand import type ([#267](https://github.com/babel/babylon/pull/267)) (Jeff Morrison) - -This change implements flows new shorthand import syntax -and where previously you had to write this code: - -```js -import {someValue} from "blah"; -import type {someType} from "blah"; -import typeof {someOtherValue} from "blah"; -``` - -you can now write it like this: - -```js -import { - someValue, - type someType, - typeof someOtherValue, -} from "blah"; -``` - -For more information look at [this](https://github.com/facebook/flow/pull/2890) pull request. - -flow: allow leading pipes in all positions ([#256](https://github.com/babel/babylon/pull/256)) (Vladimir Kurchatkin) - -This change now allows a leading pipe everywhere types can be used: -```js -var f = (x): | 1 | 2 => 1; -``` - -Throw error when exporting non-declaration ([#241](https://github.com/babel/babylon/pull/241)) (Kai Cataldo) - -Previously babylon parsed the following exports, although they are not valid: -```js -export typeof foo; -export new Foo(); -export function() {}; -export for (;;); -export while(foo); -``` - -### :bug: Bug Fix - -Don't set inType flag when parsing property names ([#266](https://github.com/babel/babylon/pull/266)) (Vladimir Kurchatkin) - -This fixes parsing of this case: - -```js -const map = { - [age <= 17] : 'Too young' -}; -``` - -Fix source location for JSXEmptyExpression nodes (fixes #248) ([#249](https://github.com/babel/babylon/pull/249)) (James Long) - -The following case produced an invalid AST -```js -
{/* foo */}
-``` - -Use fromCodePoint to convert high value unicode entities ([#243](https://github.com/babel/babylon/pull/243)) (Ryan Duffy) - -When high value unicode entities (e.g. πŸ’©) were used in the input source code they are now correctly encoded in the resulting AST. - -Rename folder to avoid Windows-illegal characters ([#281](https://github.com/babel/babylon/pull/281)) (Ryan Plant) - -Allow this.state.clone() when parsing decorators ([#262](https://github.com/babel/babylon/pull/262)) (Alex Rattray) - -### :house: Internal - -User external-helpers ([#254](https://github.com/babel/babylon/pull/254)) (Daniel Tschinder) - -Add watch script for dev ([#234](https://github.com/babel/babylon/pull/234)) (Kai Cataldo) - -Freeze current plugins list for "*" option, and remove from README.md ([#245](https://github.com/babel/babylon/pull/245)) (Andrew Levine) - -Prepare tests for multiple fixture runners. ([#240](https://github.com/babel/babylon/pull/240)) (Daniel Tschinder) - -Add some test coverage for decorators stage-0 plugin ([#250](https://github.com/babel/babylon/pull/250)) (Andrew Levine) - -Refactor tokenizer types file ([#263](https://github.com/babel/babylon/pull/263)) (Sven SAULEAU) - -Update eslint-config-babel to the latest version πŸš€ ([#273](https://github.com/babel/babylon/pull/273)) (greenkeeper[bot]) - -chore(package): update rollup to version 0.41.0 ([#272](https://github.com/babel/babylon/pull/272)) (greenkeeper[bot]) - -chore(package): update flow-bin to version 0.37.0 ([#255](https://github.com/babel/babylon/pull/255)) (greenkeeper[bot]) - -## 6.14.1 (2016-11-17) - -### :bug: Bug Fix - -Allow `"plugins": ["*"]` ([#229](https://github.com/babel/babylon/pull/229)) (Daniel Tschinder) - -```js -{ - "plugins": ["*"] -} -``` - -Will include all parser plugins instead of specifying each one individually. Useful for tools like babel-eslint, jscodeshift, and ast-explorer. - -## 6.14.0 (2016-11-16) - -### :eyeglasses: Spec Compliance - -Throw error for reserved words `enum` and `await` ([#195](https://github.com/babel/babylon/pull/195)) (Kai Cataldo) - -[11.6.2.2 Future Reserved Words](http://www.ecma-international.org/ecma-262/6.0/#sec-future-reserved-words) - -Babylon will throw for more reserved words such as `enum` or `await` (in strict mode). - -``` -class enum {} // throws -class await {} // throws in strict mode (module) -``` - -Optional names for function types and object type indexers ([#197](https://github.com/babel/babylon/pull/197)) (Gabe Levi) - -So where you used to have to write - -```js -type A = (x: string, y: boolean) => number; -type B = (z: string) => number; -type C = { [key: string]: number }; -``` - -you can now write (with flow 0.34.0) - -```js -type A = (string, boolean) => number; -type B = string => number; -type C = { [string]: number }; -``` - -Parse flow nested array type annotations like `number[][]` ([#219](https://github.com/babel/babylon/pull/219)) (Bernhard HΓ€ussner) - -Supports these form now of specifying array types: - -```js -var a: number[][][][]; -var b: string[][]; -``` - -### :bug: Bug Fix - -Correctly eat semicolon at the end of `DelcareModuleExports` ([#223](https://github.com/babel/babylon/pull/223)) (Daniel Tschinder) - -``` -declare module "foo" { declare module.exports: number } -declare module "foo" { declare module.exports: number; } // also allowed now -``` - -### :house: Internal - - * Count Babel tests towards Babylon code coverage ([#182](https://github.com/babel/babylon/pull/182)) (Moti Zilberman) - * Fix strange line endings ([#214](https://github.com/babel/babylon/pull/214)) (Thomas Grainger) - * Add node 7 (Daniel Tschinder) - * chore(package): update flow-bin to version 0.34.0 ([#204](https://github.com/babel/babylon/pull/204)) (Greenkeeper) - -## v6.13.1 (2016-10-26) - -### :nail_care: Polish - -- Use rollup for bundling to speed up startup time ([#190](https://github.com/babel/babylon/pull/190)) ([@drewml](https://github.com/DrewML)) - -```js -const babylon = require('babylon'); -const ast = babylon.parse('var foo = "lol";'); -``` - -With that test case, there was a ~95ms savings by removing the need for node to build/traverse the dependency graph. - -**Without bundling** -![image](https://cloud.githubusercontent.com/assets/5233399/19420264/3133497e-93ad-11e6-9a6a-2da59c4f5c13.png) - -**With bundling** -![image](https://cloud.githubusercontent.com/assets/5233399/19420267/388f556e-93ad-11e6-813e-7c5c396be322.png) - -- add clean command [skip ci] ([#201](https://github.com/babel/babylon/pull/201)) (Henry Zhu) -- add ForAwaitStatement (async generator already added) [skip ci] ([#196](https://github.com/babel/babylon/pull/196)) (Henry Zhu) - -## v6.13.0 (2016-10-21) - -### :eyeglasses: Spec Compliance - -Property variance type annotations for Flow plugin ([#161](https://github.com/babel/babylon/pull/161)) (Sam Goldman) - -> See https://flowtype.org/docs/variance.html for more information - -```js -type T = { +p: T }; -interface T { -p: T }; -declare class T { +[k:K]: V }; -class T { -[k:K]: V }; -class C2 { +p: T = e }; -``` - -Raise error on duplicate definition of __proto__ ([#183](https://github.com/babel/babylon/pull/183)) (Moti Zilberman) - -```js -({ __proto__: 1, __proto__: 2 }) // Throws an error now -``` - -### :bug: Bug Fix - -Flow: Allow class properties to be named `static` ([#184](https://github.com/babel/babylon/pull/184)) (Moti Zilberman) - -```js -declare class A { - static: T; -} -``` - -Allow "async" as identifier for object literal property shorthand ([#187](https://github.com/babel/babylon/pull/187)) (Andrew Levine) - -```js -var foo = { async, bar }; -``` - -### :nail_care: Polish - -Fix flowtype and add inType to state ([#189](https://github.com/babel/babylon/pull/189)) (Daniel Tschinder) - -> This improves the performance slightly (because of hidden classes) - -### :house: Internal - -Fix .gitattributes line ending setting ([#191](https://github.com/babel/babylon/pull/191)) (Moti Zilberman) - -Increase test coverage ([#175](https://github.com/babel/babylon/pull/175) (Moti Zilberman) - -Readd missin .eslinignore for IDEs (Daniel Tschinder) - -Error on missing expected.json fixture in CI ([#188](https://github.com/babel/babylon/pull/188)) (Moti Zilberman) - -Add .gitattributes and .editorconfig for LF line endings ([#179](https://github.com/babel/babylon/pull/179)) (Moti Zilberman) - -Fixes two tests that are failing after the merge of #172 ([#177](https://github.com/babel/babylon/pull/177)) (Moti Zilberman) - -## v6.12.0 (2016-10-14) - -### :eyeglasses: Spec Compliance - -Implement import() syntax ([#163](https://github.com/babel/babylon/pull/163)) (Jordan Gensler) - -#### Dynamic Import - -- Proposal Repo: https://github.com/domenic/proposal-dynamic-import -- Championed by [@domenic](https://github.com/domenic) -- stage-2 -- [sept-28 tc39 notes](https://github.com/rwaldron/tc39-notes/blob/master/es7/2016-09/sept-28.md#113a-import) - -> This repository contains a proposal for adding a "function-like" import() module loading syntactic form to JavaScript - -```js -import(`./section-modules/${link.dataset.entryModule}.js`) -.then(module => { - module.loadPageInto(main); -}) -``` - -Add EmptyTypeAnnotation ([#171](https://github.com/babel/babylon/pull/171)) (Sam Goldman) - -#### EmptyTypeAnnotation - -Just wasn't covered before. - -```js -type T = empty; -``` - -### :bug: Bug Fix - -Fix crash when exporting with destructuring and sparse array ([#170](https://github.com/babel/babylon/pull/170)) (Jeroen Engels) - -```js -// was failing due to sparse array -export const { foo: [ ,, qux7 ] } = bar; -``` - -Allow keyword in Flow object declaration property names with type parameters ([#146](https://github.com/babel/babylon/pull/146)) (Dan Harper) - -```js -declare class X { - foobar(): void; - static foobar(): void; -} -``` - -Allow keyword in object/class property names with Flow type parameters ([#145](https://github.com/babel/babylon/pull/145)) (Dan Harper) - -```js -class Foo { - delete(item: T): T { - return item; - } -} -``` - -Allow typeAnnotations for yield expressions ([#174](https://github.com/babel/babylon/pull/174))) (Daniel Tschinder) - -```js -function *foo() { - const x = (yield 5: any); -} -``` - -### :nail_care: Polish - -Annotate more errors with expected token ([#172](https://github.com/babel/babylon/pull/172))) (Moti Zilberman) - -```js -// Unexpected token, expected ; (1:6) -{ set 1 } -``` - -### :house: Internal - -Remove kcheck ([#173](https://github.com/babel/babylon/pull/173))) (Daniel Tschinder) - -Also run flow, linting, babel tests on separate instances (add back node 0.10) - -## v6.11.6 (2016-10-12) - -### :bug: Bug Fix/Regression - -Fix crash when exporting with destructuring and sparse array ([#170](https://github.com/babel/babylon/pull/170)) (Jeroen Engels) - -```js -// was failing with `Cannot read property 'type' of null` because of null identifiers -export const { foo: [ ,, qux7 ] } = bar; -``` - -## v6.11.5 (2016-10-12) - -### :eyeglasses: Spec Compliance - -Fix: Check for duplicate named exports in exported destructuring assignments ([#144](https://github.com/babel/babylon/pull/144)) (Kai Cataldo) - -```js -// `foo` has already been exported. Exported identifiers must be unique. (2:20) -export function foo() {}; -export const { a: [{foo}] } = bar; -``` - -Fix: Check for duplicate named exports in exported rest elements/properties ([#164](https://github.com/babel/babylon/pull/164)) (Kai Cataldo) - -```js -// `foo` has already been exported. Exported identifiers must be unique. (2:22) -export const foo = 1; -export const [bar, ...foo] = baz; -``` - -### :bug: Bug Fix - -Fix: Allow identifier `async` for default param in arrow expression ([#165](https://github.com/babel/babylon/pull/165)) (Kai Cataldo) - -```js -// this is ok now -const test = ({async = true}) => {}; -``` - -### :nail_care: Polish - -Babylon will now print out the token it's expecting if there's a `SyntaxError` ([#150](https://github.com/babel/babylon/pull/150)) (Daniel Tschinder) - -```bash -# So in the case of a missing ending curly (`}`) -Module build failed: SyntaxError: Unexpected token, expected } (30:0) - 28 | } - 29 | -> 30 | - | ^ -``` - -## v6.11.4 (2016-10-03) - -Temporary rollback for erroring on trailing comma with spread (#154) (Henry Zhu) - -## v6.11.3 (2016-10-01) - -### :eyeglasses: Spec Compliance - -Add static errors for object rest (#149) ([@danez](https://github.com/danez)) - -> https://github.com/sebmarkbage/ecmascript-rest-spread - -Object rest copies the *rest* of properties from the right hand side `obj` starting from the left to right. - -```js -let { x, y, ...z } = { x: 1, y: 2, z: 3 }; -// x = 1 -// y = 2 -// z = { z: 3 } -``` - -#### New Syntax Errors: - -**SyntaxError**: The rest element has to be the last element when destructuring (1:10) -```bash -> 1 | let { ...x, y, z } = { x: 1, y: 2, z: 3}; - | ^ -# Previous behavior: -# x = { x: 1, y: 2, z: 3 } -# y = 2 -# z = 3 -``` - -Before, this was just a more verbose way of shallow copying `obj` since it doesn't actually do what you think. - -**SyntaxError**: Cannot have multiple rest elements when destructuring (1:13) - -```bash -> 1 | let { x, ...y, ...z } = { x: 1, y: 2, z: 3}; - | ^ -# Previous behavior: -# x = 1 -# y = { y: 2, z: 3 } -# z = { y: 2, z: 3 } -``` - -Before y and z would just be the same value anyway so there is no reason to need to have both. - -**SyntaxError**: A trailing comma is not permitted after the rest element (1:16) - -```js -let { x, y, ...z, } = obj; -``` - -The rationale for this is that the use case for trailing comma is that you can add something at the end without affecting the line above. Since a RestProperty always has to be the last property it doesn't make sense. - ---- - -get / set are valid property names in default assignment (#142) ([@jezell](https://github.com/jezell)) - -```js -// valid -function something({ set = null, get = null }) {} -``` - -## v6.11.2 (2016-09-23) - -### Bug Fix - -- [#139](https://github.com/babel/babylon/issues/139) Don't do the duplicate check if not an identifier (#140) @hzoo - -```js -// regression with duplicate export check -SyntaxError: ./typography.js: `undefined` has already been exported. Exported identifiers must be unique. (22:13) - 20 | - 21 | export const { rhythm } = typography; -> 22 | export const { TypographyStyle } = typography -``` - -Bail out for now, and make a change to account for destructuring in the next release. - -## 6.11.1 (2016-09-22) - -### Bug Fix -- [#137](https://github.com/babel/babylon/pull/137) - Fix a regression with duplicate exports - it was erroring on all keys in `Object.prototype`. @danez - -```javascript -export toString from './toString'; -``` - -```bash -`toString` has already been exported. Exported identifiers must be unique. (1:7) -> 1 | export toString from './toString'; - | ^ - 2 | -``` - -## 6.11.0 (2016-09-22) - -### Spec Compliance (will break CI) - -- Disallow duplicate named exports ([#107](https://github.com/babel/babylon/pull/107)) @kaicataldo - -```js -// Only one default export allowed per module. (2:9) -export default function() {}; -export { foo as default }; - -// Only one default export allowed per module. (2:0) -export default {}; -export default function() {}; - -// `Foo` has already been exported. Exported identifiers must be unique. (2:0) -export { Foo }; -export class Foo {}; -``` - -### New Feature (Syntax) - -- Add support for computed class property names ([#121](https://github.com/babel/babylon/pull/121)) @motiz88 - -```js -// AST -interface ClassProperty <: Node { - type: "ClassProperty"; - key: Identifier; - value: Expression; - computed: boolean; // added -} -``` - -```js -// with "plugins": ["classProperties"] -class Foo { - [x] - ['y'] -} - -class Bar { - [p] - [m] () {} -} - ``` - -### Bug Fix - -- Fix `static` property falling through in the declare class Flow AST ([#135](https://github.com/babel/babylon/pull/135)) @danharper - -```js -declare class X { - a: number; - static b: number; // static - c: number; // this was being marked as static in the AST as well -} -``` - -### Polish - -- Rephrase "assigning/binding to rvalue" errors to include context ([#119](https://github.com/babel/babylon/pull/119)) @motiz88 - -```js -// Used to error with: -// SyntaxError: Assigning to rvalue (1:0) - -// Now: -// Invalid left-hand side in assignment expression (1:0) -3 = 4 - -// Invalid left-hand side in for-in statement (1:5) -for (+i in {}); -``` - -### Internal - -- Fix call to `this.parseMaybeAssign` with correct arguments ([#133](https://github.com/babel/babylon/pull/133)) @danez -- Add semver note to changelog ([#131](https://github.com/babel/babylon/pull/131)) @hzoo - -## 6.10.0 (2016-09-19) - -> We plan to include some spec compliance bugs in patch versions. An example was the multiple default exports issue. - -### Spec Compliance - -* Implement ES2016 check for simple parameter list in strict mode ([#106](https://github.com/babel/babylon/pull/106)) (Timothy Gu) - -> It is a Syntax Error if ContainsUseStrict of FunctionBody is true and IsSimpleParameterList of FormalParameters is false. https://tc39.github.io/ecma262/2016/#sec-function-definitions-static-semantics-early-errors - -More Context: [tc39-notes](https://github.com/rwaldron/tc39-notes/blob/master/es7/2015-07/july-29.md#611-the-scope-of-use-strict-with-respect-to-destructuring-in-parameter-lists) - -For example: - -```js -// this errors because it uses destructuring and default parameters -// in a function with a "use strict" directive -function a([ option1, option2 ] = []) { - "use strict"; -} - ``` - -The solution would be to use a top level "use strict" or to remove the destructuring or default parameters when using a function + "use strict" or to. - -### New Feature - -* Exact object type annotations for Flow plugin ([#104](https://github.com/babel/babylon/pull/104)) (Basil Hosmer) - -Added to flow in https://github.com/facebook/flow/commit/c710c40aa2a115435098d6c0dfeaadb023cd39b8 - -Looks like: - -```js -var a : {| x: number, y: string |} = { x: 0, y: 'foo' }; -``` - -### Bug Fixes - -* Include `typeParameter` location in `ArrowFunctionExpression` ([#126](https://github.com/babel/babylon/pull/126)) (Daniel Tschinder) -* Error on invalid flow type annotation with default assignment ([#122](https://github.com/babel/babylon/pull/122)) (Dan Harper) -* Fix Flow return types on arrow functions ([#124](https://github.com/babel/babylon/pull/124)) (Dan Harper) - -### Misc - -* Add tests for export extensions ([#127](https://github.com/babel/babylon/pull/127)) (Daniel Tschinder) -* Fix Contributing guidelines [skip ci] (Daniel Tschinder) - -## 6.9.2 (2016-09-09) - -The only change is to remove the `babel-runtime` dependency by compiling with Babel's ES2015 loose mode. So using babylon standalone should be smaller. - -## 6.9.1 (2016-08-23) - -This release contains mainly small bugfixes but also updates babylons default mode to es2017. The features for `exponentiationOperator`, `asyncFunctions` and `trailingFunctionCommas` which previously needed to be activated via plugin are now enabled by default and the plugins are now no-ops. - -### Bug Fixes - -- Fix issues with default object params in async functions ([#96](https://github.com/babel/babylon/pull/96)) @danez -- Fix issues with flow-types and async function ([#95](https://github.com/babel/babylon/pull/95)) @danez -- Fix arrow functions with destructuring, types & default value ([#94](https://github.com/babel/babylon/pull/94)) @danharper -- Fix declare class with qualified type identifier ([#97](https://github.com/babel/babylon/pull/97)) @danez -- Remove exponentiationOperator, asyncFunctions, trailingFunctionCommas plugins and enable them by default ([#98](https://github.com/babel/babylon/pull/98)) @danez - -## 6.9.0 (2016-08-16) - -### New syntax support - -- Add JSX spread children ([#42](https://github.com/babel/babylon/pull/42)) @calebmer - -(Be aware that React is not going to support this syntax) - -```js -
- {...todos.map(todo => )} -
-``` - -- Add support for declare module.exports ([#72](https://github.com/babel/babylon/pull/72)) @danez - -```js -declare module "foo" { - declare module.exports: {} -} -``` - -### New Features - -- If supplied, attach filename property to comment node loc. ([#80](https://github.com/babel/babylon/pull/80)) @divmain -- Add identifier name to node loc field ([#90](https://github.com/babel/babylon/pull/90)) @kittens - -### Bug Fixes - -- Fix exponential operator to behave according to spec ([#75](https://github.com/babel/babylon/pull/75)) @danez -- Fix lookahead to not add comments to arrays which are not cloned ([#76](https://github.com/babel/babylon/pull/76)) @danez -- Fix accidental fall-through in Flow type parsing. ([#82](https://github.com/babel/babylon/pull/82)) @xiemaisi -- Only allow declares inside declare module ([#73](https://github.com/babel/babylon/pull/73)) @danez -- Small fix for parsing type parameter declarations ([#83](https://github.com/babel/babylon/pull/83)) @gabelevi -- Fix arrow param locations with flow types ([#57](https://github.com/babel/babylon/pull/57)) @danez -- Fixes SyntaxError position with flow optional type ([#65](https://github.com/babel/babylon/pull/65)) @danez - -### Internal - -- Add codecoverage to tests @danez -- Fix tests to not save expected output if we expect the test to fail @danez -- Make a shallow clone of babel for testing @danez -- chore(package): update cross-env to version 2.0.0 ([#77](https://github.com/babel/babylon/pull/77)) @greenkeeperio-bot -- chore(package): update ava to version 0.16.0 ([#86](https://github.com/babel/babylon/pull/86)) @greenkeeperio-bot -- chore(package): update babel-plugin-istanbul to version 2.0.0 ([#89](https://github.com/babel/babylon/pull/89)) @greenkeeperio-bot -- chore(package): update nyc to version 8.0.0 ([#88](https://github.com/babel/babylon/pull/88)) @greenkeeperio-bot - -## 6.8.4 (2016-07-06) - -### Bug Fixes - -- Fix the location of params, when flow and default value used ([#68](https://github.com/babel/babylon/pull/68)) @danez - -## 6.8.3 (2016-07-02) - -### Bug Fixes - -- Fix performance regression introduced in 6.8.2 with conditionals ([#63](https://github.com/babel/babylon/pull/63)) @danez - -## 6.8.2 (2016-06-24) - -### Bug Fixes - -- Fix parse error with yielding jsx elements in generators `function* it() { yield ; }` ([#31](https://github.com/babel/babylon/pull/31)) @eldereal -- When cloning nodes do not clone its comments ([#24](https://github.com/babel/babylon/pull/24)) @danez -- Fix parse errors when using arrow functions with an spread element and return type `(...props): void => {}` ([#10](https://github.com/babel/babylon/pull/10)) @danez -- Fix leading comments added from previous node ([#23](https://github.com/babel/babylon/pull/23)) @danez -- Fix parse errors with flow's optional arguments `(arg?) => {}` ([#19](https://github.com/babel/babylon/pull/19)) @danez -- Support negative numeric type literals @kittens -- Remove line terminator restriction after await keyword @kittens -- Remove grouped type arrow restriction as it seems flow no longer has it @kittens -- Fix parse error with generic methods that have the name `get` or `set` `class foo { get() {} }` ([#55](https://github.com/babel/babylon/pull/55)) @vkurchatkin -- Fix parse error with arrow functions that have flow type parameter declarations `(x: T): T => x;` ([#54](https://github.com/babel/babylon/pull/54)) @gabelevi - -### Documentation - -- Document AST differences from ESTree ([#41](https://github.com/babel/babylon/pull/41)) @nene -- Move ast spec from babel/babel ([#46](https://github.com/babel/babylon/pull/46)) @hzoo - -### Internal - -- Enable skipped tests ([#16](https://github.com/babel/babylon/pull/16)) @danez -- Add script to test latest version of babylon with babel ([#21](https://github.com/babel/babylon/pull/21)) @danez -- Upgrade test runner ava @kittens -- Add missing generate-identifier-regex script @kittens -- Rename parser context types @kittens -- Add node v6 to travis testing @hzoo -- Update to Unicode v9 ([#45](https://github.com/babel/babylon/pull/45)) @mathiasbynens - -## 6.8.1 (2016-06-06) - -### New Feature - -- Parse type parameter declarations with defaults like `type Foo = T` - -### Bug Fixes -- Type parameter declarations need 1 or more type parameters. -- The existential type `*` is not a valid type parameter. -- The existential type `*` is a primary type - -### Spec Compliance -- The param list for type parameter declarations now consists of `TypeParameter` nodes -- New `TypeParameter` AST Node (replaces using the `Identifier` node before) - -``` -interface TypeParameter <: Node { - bound: TypeAnnotation; - default: TypeAnnotation; - name: string; - variance: "plus" | "minus"; -} -``` - -## 6.8.0 (2016-05-02) - -#### New Feature - -##### Parse Method Parameter Decorators ([#12](https://github.com/babel/babylon/pull/12)) - -> [Method Parameter Decorators](https://goo.gl/8MmCMG) is now a TC39 [stage 0 proposal](https://github.com/tc39/ecma262/blob/master/stage0.md). - -Examples: - -```js -class Foo { - constructor(@foo() x, @bar({ a: 123 }) @baz() y) {} -} - -export default function func(@foo() x, @bar({ a: 123 }) @baz() y) {} - -var obj = { - method(@foo() x, @bar({ a: 123 }) @baz() y) {} -}; -``` - -##### Parse for-await statements (w/ `asyncGenerators` plugin) ([#17](https://github.com/babel/babylon/pull/17)) - -There is also a new node type, `ForAwaitStatement`. - -> [Async generators and for-await](https://github.com/tc39/proposal-async-iteration) are now a [stage 2 proposal](https://github.com/tc39/ecma262#current-proposals). - -Example: - -```js -async function f() { - for await (let x of y); -} -``` diff --git a/node_modules/@babel/parser/LICENSE b/node_modules/@babel/parser/LICENSE deleted file mode 100644 index d4c7fc58..00000000 --- a/node_modules/@babel/parser/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (C) 2012-2014 by various contributors (see AUTHORS) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/node_modules/@babel/parser/README.md b/node_modules/@babel/parser/README.md deleted file mode 100644 index 65092a05..00000000 --- a/node_modules/@babel/parser/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# @babel/parser - -> A JavaScript parser - -See our website [@babel/parser](https://babeljs.io/docs/en/next/babel-parser.html) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A+parser+%28babylon%29%22+is%3Aopen) associated with this package. - -## Install - -Using npm: - -```sh -npm install --save-dev @babel/parser -``` - -or using yarn: - -```sh -yarn add @babel/parser --dev -``` diff --git a/node_modules/@babel/parser/bin/babel-parser.js b/node_modules/@babel/parser/bin/babel-parser.js deleted file mode 100755 index 3aca3145..00000000 --- a/node_modules/@babel/parser/bin/babel-parser.js +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env node -/* eslint no-var: 0 */ - -var parser = require(".."); -var fs = require("fs"); - -var filename = process.argv[2]; -if (!filename) { - console.error("no filename specified"); -} else { - var file = fs.readFileSync(filename, "utf8"); - var ast = parser.parse(file); - - console.log(JSON.stringify(ast, null, " ")); -} diff --git a/node_modules/@babel/parser/lib/index.js b/node_modules/@babel/parser/lib/index.js deleted file mode 100644 index 95d1f465..00000000 --- a/node_modules/@babel/parser/lib/index.js +++ /dev/null @@ -1,12736 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -const beforeExpr = true; -const startsExpr = true; -const isLoop = true; -const isAssign = true; -const prefix = true; -const postfix = true; -class TokenType { - constructor(label, conf = {}) { - this.label = label; - this.keyword = conf.keyword; - this.beforeExpr = !!conf.beforeExpr; - this.startsExpr = !!conf.startsExpr; - this.rightAssociative = !!conf.rightAssociative; - this.isLoop = !!conf.isLoop; - this.isAssign = !!conf.isAssign; - this.prefix = !!conf.prefix; - this.postfix = !!conf.postfix; - this.binop = conf.binop != null ? conf.binop : null; - this.updateContext = null; - } - -} -const keywords = new Map(); - -function createKeyword(name, options = {}) { - options.keyword = name; - const token = new TokenType(name, options); - keywords.set(name, token); - return token; -} - -function createBinop(name, binop) { - return new TokenType(name, { - beforeExpr, - binop - }); -} - -const types = { - num: new TokenType("num", { - startsExpr - }), - bigint: new TokenType("bigint", { - startsExpr - }), - regexp: new TokenType("regexp", { - startsExpr - }), - string: new TokenType("string", { - startsExpr - }), - name: new TokenType("name", { - startsExpr - }), - eof: new TokenType("eof"), - bracketL: new TokenType("[", { - beforeExpr, - startsExpr - }), - bracketHashL: new TokenType("#[", { - beforeExpr, - startsExpr - }), - bracketBarL: new TokenType("[|", { - beforeExpr, - startsExpr - }), - bracketR: new TokenType("]"), - bracketBarR: new TokenType("|]"), - braceL: new TokenType("{", { - beforeExpr, - startsExpr - }), - braceBarL: new TokenType("{|", { - beforeExpr, - startsExpr - }), - braceHashL: new TokenType("#{", { - beforeExpr, - startsExpr - }), - braceR: new TokenType("}"), - braceBarR: new TokenType("|}"), - parenL: new TokenType("(", { - beforeExpr, - startsExpr - }), - parenR: new TokenType(")"), - comma: new TokenType(",", { - beforeExpr - }), - semi: new TokenType(";", { - beforeExpr - }), - colon: new TokenType(":", { - beforeExpr - }), - doubleColon: new TokenType("::", { - beforeExpr - }), - dot: new TokenType("."), - question: new TokenType("?", { - beforeExpr - }), - questionDot: new TokenType("?."), - arrow: new TokenType("=>", { - beforeExpr - }), - template: new TokenType("template"), - ellipsis: new TokenType("...", { - beforeExpr - }), - backQuote: new TokenType("`", { - startsExpr - }), - dollarBraceL: new TokenType("${", { - beforeExpr, - startsExpr - }), - at: new TokenType("@"), - hash: new TokenType("#", { - startsExpr - }), - interpreterDirective: new TokenType("#!..."), - eq: new TokenType("=", { - beforeExpr, - isAssign - }), - assign: new TokenType("_=", { - beforeExpr, - isAssign - }), - incDec: new TokenType("++/--", { - prefix, - postfix, - startsExpr - }), - bang: new TokenType("!", { - beforeExpr, - prefix, - startsExpr - }), - tilde: new TokenType("~", { - beforeExpr, - prefix, - startsExpr - }), - pipeline: createBinop("|>", 0), - nullishCoalescing: createBinop("??", 1), - logicalOR: createBinop("||", 1), - logicalAND: createBinop("&&", 2), - bitwiseOR: createBinop("|", 3), - bitwiseXOR: createBinop("^", 4), - bitwiseAND: createBinop("&", 5), - equality: createBinop("==/!=/===/!==", 6), - relational: createBinop("/<=/>=", 7), - bitShift: createBinop("<>/>>>", 8), - plusMin: new TokenType("+/-", { - beforeExpr, - binop: 9, - prefix, - startsExpr - }), - modulo: new TokenType("%", { - beforeExpr, - binop: 10, - startsExpr - }), - star: createBinop("*", 10), - slash: createBinop("/", 10), - exponent: new TokenType("**", { - beforeExpr, - binop: 11, - rightAssociative: true - }), - _break: createKeyword("break"), - _case: createKeyword("case", { - beforeExpr - }), - _catch: createKeyword("catch"), - _continue: createKeyword("continue"), - _debugger: createKeyword("debugger"), - _default: createKeyword("default", { - beforeExpr - }), - _do: createKeyword("do", { - isLoop, - beforeExpr - }), - _else: createKeyword("else", { - beforeExpr - }), - _finally: createKeyword("finally"), - _for: createKeyword("for", { - isLoop - }), - _function: createKeyword("function", { - startsExpr - }), - _if: createKeyword("if"), - _return: createKeyword("return", { - beforeExpr - }), - _switch: createKeyword("switch"), - _throw: createKeyword("throw", { - beforeExpr, - prefix, - startsExpr - }), - _try: createKeyword("try"), - _var: createKeyword("var"), - _const: createKeyword("const"), - _while: createKeyword("while", { - isLoop - }), - _with: createKeyword("with"), - _new: createKeyword("new", { - beforeExpr, - startsExpr - }), - _this: createKeyword("this", { - startsExpr - }), - _super: createKeyword("super", { - startsExpr - }), - _class: createKeyword("class", { - startsExpr - }), - _extends: createKeyword("extends", { - beforeExpr - }), - _export: createKeyword("export"), - _import: createKeyword("import", { - startsExpr - }), - _null: createKeyword("null", { - startsExpr - }), - _true: createKeyword("true", { - startsExpr - }), - _false: createKeyword("false", { - startsExpr - }), - _in: createKeyword("in", { - beforeExpr, - binop: 7 - }), - _instanceof: createKeyword("instanceof", { - beforeExpr, - binop: 7 - }), - _typeof: createKeyword("typeof", { - beforeExpr, - prefix, - startsExpr - }), - _void: createKeyword("void", { - beforeExpr, - prefix, - startsExpr - }), - _delete: createKeyword("delete", { - beforeExpr, - prefix, - startsExpr - }) -}; - -const SCOPE_OTHER = 0b00000000, - SCOPE_PROGRAM = 0b00000001, - SCOPE_FUNCTION = 0b00000010, - SCOPE_ARROW = 0b00000100, - SCOPE_SIMPLE_CATCH = 0b00001000, - SCOPE_SUPER = 0b00010000, - SCOPE_DIRECT_SUPER = 0b00100000, - SCOPE_CLASS = 0b01000000, - SCOPE_TS_MODULE = 0b10000000, - SCOPE_VAR = SCOPE_PROGRAM | SCOPE_FUNCTION | SCOPE_TS_MODULE; -const BIND_KIND_VALUE = 0b00000000001, - BIND_KIND_TYPE = 0b00000000010, - BIND_SCOPE_VAR = 0b00000000100, - BIND_SCOPE_LEXICAL = 0b00000001000, - BIND_SCOPE_FUNCTION = 0b00000010000, - BIND_FLAGS_NONE = 0b00001000000, - BIND_FLAGS_CLASS = 0b00010000000, - BIND_FLAGS_TS_ENUM = 0b00100000000, - BIND_FLAGS_TS_CONST_ENUM = 0b01000000000, - BIND_FLAGS_TS_EXPORT_ONLY = 0b10000000000; -const BIND_CLASS = BIND_KIND_VALUE | BIND_KIND_TYPE | BIND_SCOPE_LEXICAL | BIND_FLAGS_CLASS, - BIND_LEXICAL = BIND_KIND_VALUE | 0 | BIND_SCOPE_LEXICAL | 0, - BIND_VAR = BIND_KIND_VALUE | 0 | BIND_SCOPE_VAR | 0, - BIND_FUNCTION = BIND_KIND_VALUE | 0 | BIND_SCOPE_FUNCTION | 0, - BIND_TS_INTERFACE = 0 | BIND_KIND_TYPE | 0 | BIND_FLAGS_CLASS, - BIND_TS_TYPE = 0 | BIND_KIND_TYPE | 0 | 0, - BIND_TS_ENUM = BIND_KIND_VALUE | BIND_KIND_TYPE | BIND_SCOPE_LEXICAL | BIND_FLAGS_TS_ENUM, - BIND_TS_AMBIENT = 0 | 0 | 0 | BIND_FLAGS_TS_EXPORT_ONLY, - BIND_NONE = 0 | 0 | 0 | BIND_FLAGS_NONE, - BIND_OUTSIDE = BIND_KIND_VALUE | 0 | 0 | BIND_FLAGS_NONE, - BIND_TS_CONST_ENUM = BIND_TS_ENUM | BIND_FLAGS_TS_CONST_ENUM, - BIND_TS_NAMESPACE = 0 | 0 | 0 | BIND_FLAGS_TS_EXPORT_ONLY; -const CLASS_ELEMENT_FLAG_STATIC = 0b100, - CLASS_ELEMENT_KIND_GETTER = 0b010, - CLASS_ELEMENT_KIND_SETTER = 0b001, - CLASS_ELEMENT_KIND_ACCESSOR = CLASS_ELEMENT_KIND_GETTER | CLASS_ELEMENT_KIND_SETTER; -const CLASS_ELEMENT_STATIC_GETTER = CLASS_ELEMENT_KIND_GETTER | CLASS_ELEMENT_FLAG_STATIC, - CLASS_ELEMENT_STATIC_SETTER = CLASS_ELEMENT_KIND_SETTER | CLASS_ELEMENT_FLAG_STATIC, - CLASS_ELEMENT_INSTANCE_GETTER = CLASS_ELEMENT_KIND_GETTER, - CLASS_ELEMENT_INSTANCE_SETTER = CLASS_ELEMENT_KIND_SETTER, - CLASS_ELEMENT_OTHER = 0; - -const lineBreak = /\r\n?|[\n\u2028\u2029]/; -const lineBreakG = new RegExp(lineBreak.source, "g"); -function isNewLine(code) { - switch (code) { - case 10: - case 13: - case 8232: - case 8233: - return true; - - default: - return false; - } -} -const skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g; -function isWhitespace(code) { - switch (code) { - case 0x0009: - case 0x000b: - case 0x000c: - case 32: - case 160: - case 5760: - case 0x2000: - case 0x2001: - case 0x2002: - case 0x2003: - case 0x2004: - case 0x2005: - case 0x2006: - case 0x2007: - case 0x2008: - case 0x2009: - case 0x200a: - case 0x202f: - case 0x205f: - case 0x3000: - case 0xfeff: - return true; - - default: - return false; - } -} - -class Position { - constructor(line, col) { - this.line = line; - this.column = col; - } - -} -class SourceLocation { - constructor(start, end) { - this.start = start; - this.end = end; - } - -} -function getLineInfo(input, offset) { - let line = 1; - let lineStart = 0; - let match; - lineBreakG.lastIndex = 0; - - while ((match = lineBreakG.exec(input)) && match.index < offset) { - line++; - lineStart = lineBreakG.lastIndex; - } - - return new Position(line, offset - lineStart); -} - -class BaseParser { - constructor() { - this.sawUnambiguousESM = false; - this.ambiguousScriptDifferentAst = false; - } - - hasPlugin(name) { - return this.plugins.has(name); - } - - getPluginOption(plugin, name) { - if (this.hasPlugin(plugin)) return this.plugins.get(plugin)[name]; - } - -} - -function last(stack) { - return stack[stack.length - 1]; -} - -class CommentsParser extends BaseParser { - addComment(comment) { - if (this.filename) comment.loc.filename = this.filename; - this.state.trailingComments.push(comment); - this.state.leadingComments.push(comment); - } - - adjustCommentsAfterTrailingComma(node, elements, takeAllComments) { - if (this.state.leadingComments.length === 0) { - return; - } - - let lastElement = null; - let i = elements.length; - - while (lastElement === null && i > 0) { - lastElement = elements[--i]; - } - - if (lastElement === null) { - return; - } - - for (let j = 0; j < this.state.leadingComments.length; j++) { - if (this.state.leadingComments[j].end < this.state.commentPreviousNode.end) { - this.state.leadingComments.splice(j, 1); - j--; - } - } - - const newTrailingComments = []; - - for (let i = 0; i < this.state.leadingComments.length; i++) { - const leadingComment = this.state.leadingComments[i]; - - if (leadingComment.end < node.end) { - newTrailingComments.push(leadingComment); - - if (!takeAllComments) { - this.state.leadingComments.splice(i, 1); - i--; - } - } else { - if (node.trailingComments === undefined) { - node.trailingComments = []; - } - - node.trailingComments.push(leadingComment); - } - } - - if (takeAllComments) this.state.leadingComments = []; - - if (newTrailingComments.length > 0) { - lastElement.trailingComments = newTrailingComments; - } else if (lastElement.trailingComments !== undefined) { - lastElement.trailingComments = []; - } - } - - processComment(node) { - if (node.type === "Program" && node.body.length > 0) return; - const stack = this.state.commentStack; - let firstChild, lastChild, trailingComments, i, j; - - if (this.state.trailingComments.length > 0) { - if (this.state.trailingComments[0].start >= node.end) { - trailingComments = this.state.trailingComments; - this.state.trailingComments = []; - } else { - this.state.trailingComments.length = 0; - } - } else if (stack.length > 0) { - const lastInStack = last(stack); - - if (lastInStack.trailingComments && lastInStack.trailingComments[0].start >= node.end) { - trailingComments = lastInStack.trailingComments; - delete lastInStack.trailingComments; - } - } - - if (stack.length > 0 && last(stack).start >= node.start) { - firstChild = stack.pop(); - } - - while (stack.length > 0 && last(stack).start >= node.start) { - lastChild = stack.pop(); - } - - if (!lastChild && firstChild) lastChild = firstChild; - - if (firstChild) { - switch (node.type) { - case "ObjectExpression": - this.adjustCommentsAfterTrailingComma(node, node.properties); - break; - - case "ObjectPattern": - this.adjustCommentsAfterTrailingComma(node, node.properties, true); - break; - - case "CallExpression": - this.adjustCommentsAfterTrailingComma(node, node.arguments); - break; - - case "ArrayExpression": - this.adjustCommentsAfterTrailingComma(node, node.elements); - break; - - case "ArrayPattern": - this.adjustCommentsAfterTrailingComma(node, node.elements, true); - break; - } - } else if (this.state.commentPreviousNode && (this.state.commentPreviousNode.type === "ImportSpecifier" && node.type !== "ImportSpecifier" || this.state.commentPreviousNode.type === "ExportSpecifier" && node.type !== "ExportSpecifier")) { - this.adjustCommentsAfterTrailingComma(node, [this.state.commentPreviousNode]); - } - - if (lastChild) { - if (lastChild.leadingComments) { - if (lastChild !== node && lastChild.leadingComments.length > 0 && last(lastChild.leadingComments).end <= node.start) { - node.leadingComments = lastChild.leadingComments; - delete lastChild.leadingComments; - } else { - for (i = lastChild.leadingComments.length - 2; i >= 0; --i) { - if (lastChild.leadingComments[i].end <= node.start) { - node.leadingComments = lastChild.leadingComments.splice(0, i + 1); - break; - } - } - } - } - } else if (this.state.leadingComments.length > 0) { - if (last(this.state.leadingComments).end <= node.start) { - if (this.state.commentPreviousNode) { - for (j = 0; j < this.state.leadingComments.length; j++) { - if (this.state.leadingComments[j].end < this.state.commentPreviousNode.end) { - this.state.leadingComments.splice(j, 1); - j--; - } - } - } - - if (this.state.leadingComments.length > 0) { - node.leadingComments = this.state.leadingComments; - this.state.leadingComments = []; - } - } else { - for (i = 0; i < this.state.leadingComments.length; i++) { - if (this.state.leadingComments[i].end > node.start) { - break; - } - } - - const leadingComments = this.state.leadingComments.slice(0, i); - - if (leadingComments.length) { - node.leadingComments = leadingComments; - } - - trailingComments = this.state.leadingComments.slice(i); - - if (trailingComments.length === 0) { - trailingComments = null; - } - } - } - - this.state.commentPreviousNode = node; - - if (trailingComments) { - if (trailingComments.length && trailingComments[0].start >= node.start && last(trailingComments).end <= node.end) { - node.innerComments = trailingComments; - } else { - node.trailingComments = trailingComments; - } - } - - stack.push(node); - } - -} - -const Errors = Object.freeze({ - ArgumentsDisallowedInInitializer: "'arguments' is not allowed in class field initializer", - AsyncFunctionInSingleStatementContext: "Async functions can only be declared at the top level or inside a block", - AwaitBindingIdentifier: "Can not use 'await' as identifier inside an async function", - AwaitExpressionFormalParameter: "await is not allowed in async function parameters", - AwaitNotInAsyncFunction: "Can not use keyword 'await' outside an async function", - BadGetterArity: "getter must not have any formal parameters", - BadSetterArity: "setter must have exactly one formal parameter", - BadSetterRestParameter: "setter function argument must not be a rest parameter", - ConstructorClassField: "Classes may not have a field named 'constructor'", - ConstructorClassPrivateField: "Classes may not have a private field named '#constructor'", - ConstructorIsAccessor: "Class constructor may not be an accessor", - ConstructorIsAsync: "Constructor can't be an async function", - ConstructorIsGenerator: "Constructor can't be a generator", - DeclarationMissingInitializer: "%0 require an initialization value", - DecoratorBeforeExport: "Decorators must be placed *before* the 'export' keyword. You can set the 'decoratorsBeforeExport' option to false to use the 'export @decorator class {}' syntax", - DecoratorConstructor: "Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?", - DecoratorExportClass: "Using the export keyword between a decorator and a class is not allowed. Please use `export @dec class` instead.", - DecoratorSemicolon: "Decorators must not be followed by a semicolon", - DeletePrivateField: "Deleting a private field is not allowed", - DestructureNamedImport: "ES2015 named imports do not destructure. Use another statement for destructuring after the import.", - DuplicateConstructor: "Duplicate constructor in the same class", - DuplicateDefaultExport: "Only one default export allowed per module.", - DuplicateExport: "`%0` has already been exported. Exported identifiers must be unique.", - DuplicateProto: "Redefinition of __proto__ property", - DuplicateRegExpFlags: "Duplicate regular expression flag", - ElementAfterRest: "Rest element must be last element", - EscapedCharNotAnIdentifier: "Invalid Unicode escape", - ForInOfLoopInitializer: "%0 loop variable declaration may not have an initializer", - GeneratorInSingleStatementContext: "Generators can only be declared at the top level or inside a block", - IllegalBreakContinue: "Unsyntactic %0", - IllegalLanguageModeDirective: "Illegal 'use strict' directive in function with non-simple parameter list", - IllegalReturn: "'return' outside of function", - ImportCallArgumentTrailingComma: "Trailing comma is disallowed inside import(...) arguments", - ImportCallArity: "import() requires exactly one argument", - ImportCallArityLtOne: "Dynamic imports require a parameter: import('a.js')", - ImportCallNotNewExpression: "Cannot use new with import(...)", - ImportCallSpreadArgument: "... is not allowed in import()", - ImportMetaOutsideModule: `import.meta may appear only with 'sourceType: "module"'`, - ImportOutsideModule: `'import' and 'export' may appear only with 'sourceType: "module"'`, - InvalidCodePoint: "Code point out of bounds", - InvalidDigit: "Expected number in radix %0", - InvalidEscapeSequence: "Bad character escape sequence", - InvalidEscapeSequenceTemplate: "Invalid escape sequence in template", - InvalidEscapedReservedWord: "Escape sequence in keyword %0", - InvalidIdentifier: "Invalid identifier %0", - InvalidLhs: "Invalid left-hand side in %0", - InvalidLhsBinding: "Binding invalid left-hand side in %0", - InvalidNumber: "Invalid number", - InvalidOrUnexpectedToken: "Unexpected character '%0'", - InvalidParenthesizedAssignment: "Invalid parenthesized assignment pattern", - InvalidPrivateFieldResolution: "Private name #%0 is not defined", - InvalidPropertyBindingPattern: "Binding member expression", - InvalidRestAssignmentPattern: "Invalid rest operator's argument", - LabelRedeclaration: "Label '%0' is already declared", - LetInLexicalBinding: "'let' is not allowed to be used as a name in 'let' or 'const' declarations.", - MalformedRegExpFlags: "Invalid regular expression flag", - MissingClassName: "A class name is required", - MissingEqInAssignment: "Only '=' operator can be used for specifying default value.", - MissingUnicodeEscape: "Expecting Unicode escape sequence \\uXXXX", - MixingCoalesceWithLogical: "Nullish coalescing operator(??) requires parens when mixing with logical operators", - ModuleExportUndefined: "Export '%0' is not defined", - MultipleDefaultsInSwitch: "Multiple default clauses", - NewlineAfterThrow: "Illegal newline after throw", - NoCatchOrFinally: "Missing catch or finally clause", - NumberIdentifier: "Identifier directly after number", - NumericSeparatorInEscapeSequence: "Numeric separators are not allowed inside unicode escape sequences or hex escape sequences", - ObsoleteAwaitStar: "await* has been removed from the async functions proposal. Use Promise.all() instead.", - OptionalChainingNoNew: "constructors in/after an Optional Chain are not allowed", - OptionalChainingNoTemplate: "Tagged Template Literals are not allowed in optionalChain", - ParamDupe: "Argument name clash", - PatternHasAccessor: "Object pattern can't contain getter or setter", - PatternHasMethod: "Object pattern can't contain methods", - PipelineBodyNoArrow: 'Unexpected arrow "=>" after pipeline body; arrow function in pipeline body must be parenthesized', - PipelineBodySequenceExpression: "Pipeline body may not be a comma-separated sequence expression", - PipelineHeadSequenceExpression: "Pipeline head should not be a comma-separated sequence expression", - PipelineTopicUnused: "Pipeline is in topic style but does not use topic reference", - PrimaryTopicNotAllowed: "Topic reference was used in a lexical context without topic binding", - PrimaryTopicRequiresSmartPipeline: "Primary Topic Reference found but pipelineOperator not passed 'smart' for 'proposal' option.", - PrivateNameRedeclaration: "Duplicate private name #%0", - RecordExpressionBarIncorrectEndSyntaxType: "Record expressions ending with '|}' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'", - RecordExpressionBarIncorrectStartSyntaxType: "Record expressions starting with '{|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'", - RecordExpressionHashIncorrectStartSyntaxType: "Record expressions starting with '#{' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'", - RestTrailingComma: "Unexpected trailing comma after rest element", - SloppyFunction: "In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement", - StaticPrototype: "Classes may not have static property named prototype", - StrictDelete: "Deleting local variable in strict mode", - StrictEvalArguments: "Assigning to '%0' in strict mode", - StrictEvalArgumentsBinding: "Binding '%0' in strict mode", - StrictFunction: "In strict mode code, functions can only be declared at top level or inside a block", - StrictOctalLiteral: "Legacy octal literals are not allowed in strict mode", - StrictWith: "'with' in strict mode", - SuperNotAllowed: "super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class?", - SuperPrivateField: "Private fields can't be accessed on super", - TrailingDecorator: "Decorators must be attached to a class element", - TupleExpressionBarIncorrectEndSyntaxType: "Tuple expressions ending with '|]' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'", - TupleExpressionBarIncorrectStartSyntaxType: "Tuple expressions starting with '[|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'", - TupleExpressionHashIncorrectStartSyntaxType: "Tuple expressions starting with '#[' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'", - UnexpectedArgumentPlaceholder: "Unexpected argument placeholder", - UnexpectedAwaitAfterPipelineBody: 'Unexpected "await" after pipeline body; await must have parentheses in minimal proposal', - UnexpectedDigitAfterHash: "Unexpected digit after hash token", - UnexpectedImportExport: "'import' and 'export' may only appear at the top level", - UnexpectedKeyword: "Unexpected keyword '%0'", - UnexpectedLeadingDecorator: "Leading decorators must be attached to a class declaration", - UnexpectedLexicalDeclaration: "Lexical declaration cannot appear in a single-statement context", - UnexpectedNewTarget: "new.target can only be used in functions", - UnexpectedNumericSeparator: "A numeric separator is only allowed between two digits", - UnexpectedPrivateField: "Private names can only be used as the name of a class element (i.e. class C { #p = 42; #m() {} } )\n or a property of member expression (i.e. this.#p).", - UnexpectedReservedWord: "Unexpected reserved word '%0'", - UnexpectedSuper: "super is only allowed in object methods and classes", - UnexpectedToken: "Unexpected token '%'", - UnexpectedTokenUnaryExponentiation: "Illegal expression. Wrap left hand side or entire exponentiation in parentheses.", - UnsupportedBind: "Binding should be performed on object property.", - UnsupportedDecoratorExport: "A decorated export must export a class declaration", - UnsupportedDefaultExport: "Only expressions, functions or classes are allowed as the `default` export.", - UnsupportedImport: "import can only be used in import() or import.meta", - UnsupportedMetaProperty: "The only valid meta property for %0 is %0.%1", - UnsupportedParameterDecorator: "Decorators cannot be used to decorate parameters", - UnsupportedPropertyDecorator: "Decorators cannot be used to decorate object literal properties", - UnsupportedSuper: "super can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop])", - UnterminatedComment: "Unterminated comment", - UnterminatedRegExp: "Unterminated regular expression", - UnterminatedString: "Unterminated string constant", - UnterminatedTemplate: "Unterminated template", - VarRedeclaration: "Identifier '%0' has already been declared", - YieldBindingIdentifier: "Can not use 'yield' as identifier inside a generator", - YieldInParameter: "yield is not allowed in generator parameters", - ZeroDigitNumericSeparator: "Numeric separator can not be used after leading 0" -}); -class LocationParser extends CommentsParser { - getLocationForPosition(pos) { - let loc; - if (pos === this.state.start) loc = this.state.startLoc;else if (pos === this.state.lastTokStart) loc = this.state.lastTokStartLoc;else if (pos === this.state.end) loc = this.state.endLoc;else if (pos === this.state.lastTokEnd) loc = this.state.lastTokEndLoc;else loc = getLineInfo(this.input, pos); - return loc; - } - - raise(pos, errorTemplate, ...params) { - return this.raiseWithData(pos, undefined, errorTemplate, ...params); - } - - raiseWithData(pos, data, errorTemplate, ...params) { - const loc = this.getLocationForPosition(pos); - const message = errorTemplate.replace(/%(\d+)/g, (_, i) => params[i]) + ` (${loc.line}:${loc.column})`; - return this._raise(Object.assign({ - loc, - pos - }, data), message); - } - - _raise(errorContext, message) { - const err = new SyntaxError(message); - Object.assign(err, errorContext); - - if (this.options.errorRecovery) { - if (!this.isLookahead) this.state.errors.push(err); - return err; - } else { - throw err; - } - } - -} - -function isSimpleProperty(node) { - return node != null && node.type === "Property" && node.kind === "init" && node.method === false; -} - -var estree = (superClass => class extends superClass { - estreeParseRegExpLiteral({ - pattern, - flags - }) { - let regex = null; - - try { - regex = new RegExp(pattern, flags); - } catch (e) {} - - const node = this.estreeParseLiteral(regex); - node.regex = { - pattern, - flags - }; - return node; - } - - estreeParseBigIntLiteral(value) { - const bigInt = typeof BigInt !== "undefined" ? BigInt(value) : null; - const node = this.estreeParseLiteral(bigInt); - node.bigint = String(node.value || value); - return node; - } - - estreeParseLiteral(value) { - return this.parseLiteral(value, "Literal"); - } - - directiveToStmt(directive) { - const directiveLiteral = directive.value; - const stmt = this.startNodeAt(directive.start, directive.loc.start); - const expression = this.startNodeAt(directiveLiteral.start, directiveLiteral.loc.start); - expression.value = directiveLiteral.value; - expression.raw = directiveLiteral.extra.raw; - stmt.expression = this.finishNodeAt(expression, "Literal", directiveLiteral.end, directiveLiteral.loc.end); - stmt.directive = directiveLiteral.extra.raw.slice(1, -1); - return this.finishNodeAt(stmt, "ExpressionStatement", directive.end, directive.loc.end); - } - - initFunction(node, isAsync) { - super.initFunction(node, isAsync); - node.expression = false; - } - - checkDeclaration(node) { - if (isSimpleProperty(node)) { - this.checkDeclaration(node.value); - } else { - super.checkDeclaration(node); - } - } - - checkGetterSetterParams(method) { - const prop = method; - const paramCount = prop.kind === "get" ? 0 : 1; - const start = prop.start; - - if (prop.value.params.length !== paramCount) { - if (method.kind === "get") { - this.raise(start, Errors.BadGetterArity); - } else { - this.raise(start, Errors.BadSetterArity); - } - } else if (prop.kind === "set" && prop.value.params[0].type === "RestElement") { - this.raise(start, Errors.BadSetterRestParameter); - } - } - - checkLVal(expr, bindingType = BIND_NONE, checkClashes, contextDescription, disallowLetBinding) { - switch (expr.type) { - case "ObjectPattern": - expr.properties.forEach(prop => { - this.checkLVal(prop.type === "Property" ? prop.value : prop, bindingType, checkClashes, "object destructuring pattern", disallowLetBinding); - }); - break; - - default: - super.checkLVal(expr, bindingType, checkClashes, contextDescription, disallowLetBinding); - } - } - - checkDuplicatedProto(prop, protoRef, refExpressionErrors) { - if (prop.type === "SpreadElement" || prop.computed || prop.method || prop.shorthand) { - return; - } - - const key = prop.key; - const name = key.type === "Identifier" ? key.name : String(key.value); - - if (name === "__proto__" && prop.kind === "init") { - if (protoRef.used) { - if (refExpressionErrors && refExpressionErrors.doubleProto === -1) { - refExpressionErrors.doubleProto = key.start; - } else { - this.raise(key.start, Errors.DuplicateProto); - } - } - - protoRef.used = true; - } - } - - isValidDirective(stmt) { - return stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && typeof stmt.expression.value === "string" && (!stmt.expression.extra || !stmt.expression.extra.parenthesized); - } - - stmtToDirective(stmt) { - const directive = super.stmtToDirective(stmt); - const value = stmt.expression.value; - directive.value.value = value; - return directive; - } - - parseBlockBody(node, allowDirectives, topLevel, end) { - super.parseBlockBody(node, allowDirectives, topLevel, end); - const directiveStatements = node.directives.map(d => this.directiveToStmt(d)); - node.body = directiveStatements.concat(node.body); - delete node.directives; - } - - pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) { - this.parseMethod(method, isGenerator, isAsync, isConstructor, allowsDirectSuper, "ClassMethod", true); - - if (method.typeParameters) { - method.value.typeParameters = method.typeParameters; - delete method.typeParameters; - } - - classBody.body.push(method); - } - - parseExprAtom(refExpressionErrors) { - switch (this.state.type) { - case types.num: - case types.string: - return this.estreeParseLiteral(this.state.value); - - case types.regexp: - return this.estreeParseRegExpLiteral(this.state.value); - - case types.bigint: - return this.estreeParseBigIntLiteral(this.state.value); - - case types._null: - return this.estreeParseLiteral(null); - - case types._true: - return this.estreeParseLiteral(true); - - case types._false: - return this.estreeParseLiteral(false); - - default: - return super.parseExprAtom(refExpressionErrors); - } - } - - parseLiteral(value, type, startPos, startLoc) { - const node = super.parseLiteral(value, type, startPos, startLoc); - node.raw = node.extra.raw; - delete node.extra; - return node; - } - - parseFunctionBody(node, allowExpression, isMethod = false) { - super.parseFunctionBody(node, allowExpression, isMethod); - node.expression = node.body.type !== "BlockStatement"; - } - - parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) { - let funcNode = this.startNode(); - funcNode.kind = node.kind; - funcNode = super.parseMethod(funcNode, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope); - funcNode.type = "FunctionExpression"; - delete funcNode.kind; - node.value = funcNode; - type = type === "ClassMethod" ? "MethodDefinition" : type; - return this.finishNode(node, type); - } - - parseObjectMethod(prop, isGenerator, isAsync, isPattern, containsEsc) { - const node = super.parseObjectMethod(prop, isGenerator, isAsync, isPattern, containsEsc); - - if (node) { - node.type = "Property"; - if (node.kind === "method") node.kind = "init"; - node.shorthand = false; - } - - return node; - } - - parseObjectProperty(prop, startPos, startLoc, isPattern, refExpressionErrors) { - const node = super.parseObjectProperty(prop, startPos, startLoc, isPattern, refExpressionErrors); - - if (node) { - node.kind = "init"; - node.type = "Property"; - } - - return node; - } - - toAssignable(node) { - if (isSimpleProperty(node)) { - this.toAssignable(node.value); - return node; - } - - return super.toAssignable(node); - } - - toAssignableObjectExpressionProp(prop, isLast) { - if (prop.kind === "get" || prop.kind === "set") { - throw this.raise(prop.key.start, Errors.PatternHasAccessor); - } else if (prop.method) { - throw this.raise(prop.key.start, Errors.PatternHasMethod); - } else { - super.toAssignableObjectExpressionProp(prop, isLast); - } - } - - finishCallExpression(node, optional) { - super.finishCallExpression(node, optional); - - if (node.callee.type === "Import") { - node.type = "ImportExpression"; - node.source = node.arguments[0]; - delete node.arguments; - delete node.callee; - } - - return node; - } - - toReferencedListDeep(exprList, isParenthesizedExpr) { - if (!exprList) { - return; - } - - super.toReferencedListDeep(exprList, isParenthesizedExpr); - } - - parseExport(node) { - super.parseExport(node); - - switch (node.type) { - case "ExportAllDeclaration": - node.exported = null; - break; - - case "ExportNamedDeclaration": - if (node.specifiers.length === 1 && node.specifiers[0].type === "ExportNamespaceSpecifier") { - node.type = "ExportAllDeclaration"; - node.exported = node.specifiers[0].exported; - delete node.specifiers; - } - - break; - } - - return node; - } - -}); - -class TokContext { - constructor(token, isExpr, preserveSpace, override) { - this.token = token; - this.isExpr = !!isExpr; - this.preserveSpace = !!preserveSpace; - this.override = override; - } - -} -const types$1 = { - braceStatement: new TokContext("{", false), - braceExpression: new TokContext("{", true), - templateQuasi: new TokContext("${", false), - parenStatement: new TokContext("(", false), - parenExpression: new TokContext("(", true), - template: new TokContext("`", true, true, p => p.readTmplToken()), - functionExpression: new TokContext("function", true), - functionStatement: new TokContext("function", false) -}; - -types.parenR.updateContext = types.braceR.updateContext = function () { - if (this.state.context.length === 1) { - this.state.exprAllowed = true; - return; - } - - let out = this.state.context.pop(); - - if (out === types$1.braceStatement && this.curContext().token === "function") { - out = this.state.context.pop(); - } - - this.state.exprAllowed = !out.isExpr; -}; - -types.name.updateContext = function (prevType) { - let allowed = false; - - if (prevType !== types.dot) { - if (this.state.value === "of" && !this.state.exprAllowed || this.state.value === "yield" && this.prodParam.hasYield) { - allowed = true; - } - } - - this.state.exprAllowed = allowed; - - if (this.state.isIterator) { - this.state.isIterator = false; - } -}; - -types.braceL.updateContext = function (prevType) { - this.state.context.push(this.braceIsBlock(prevType) ? types$1.braceStatement : types$1.braceExpression); - this.state.exprAllowed = true; -}; - -types.dollarBraceL.updateContext = function () { - this.state.context.push(types$1.templateQuasi); - this.state.exprAllowed = true; -}; - -types.parenL.updateContext = function (prevType) { - const statementParens = prevType === types._if || prevType === types._for || prevType === types._with || prevType === types._while; - this.state.context.push(statementParens ? types$1.parenStatement : types$1.parenExpression); - this.state.exprAllowed = true; -}; - -types.incDec.updateContext = function () {}; - -types._function.updateContext = types._class.updateContext = function (prevType) { - if (prevType.beforeExpr && prevType !== types.semi && prevType !== types._else && !(prevType === types._return && lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.start))) && !((prevType === types.colon || prevType === types.braceL) && this.curContext() === types$1.b_stat)) { - this.state.context.push(types$1.functionExpression); - } else { - this.state.context.push(types$1.functionStatement); - } - - this.state.exprAllowed = false; -}; - -types.backQuote.updateContext = function () { - if (this.curContext() === types$1.template) { - this.state.context.pop(); - } else { - this.state.context.push(types$1.template); - } - - this.state.exprAllowed = false; -}; - -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\u08a0-\u08b4\u08b6-\u08c7\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\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\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-\u170c\u170e-\u1711\u1720-\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-\u1b4b\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-\u2c2e\u2c30-\u2c5e\u2c60-\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-\u9ffc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7ca\ua7f5-\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\u08d3-\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\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\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-\u0ecd\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-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf\u1ac0\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-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\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"; -const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); -const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); -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, 157, 310, 10, 21, 11, 7, 153, 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, 107, 20, 28, 22, 13, 52, 76, 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, 85, 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, 230, 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, 35, 56, 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, 190, 0, 80, 921, 103, 110, 18, 195, 2749, 1070, 4050, 582, 8634, 568, 8, 30, 114, 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, 8952, 286, 50, 2, 18, 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, 2357, 44, 11, 6, 17, 0, 370, 43, 1301, 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, 42717, 35, 4148, 12, 221, 3, 5761, 15, 7472, 3104, 541, 1507, 4938]; -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, 154, 10, 176, 2, 54, 14, 32, 9, 16, 3, 46, 10, 54, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 161, 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, 19306, 9, 135, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 5319, 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, 262, 6, 10, 9, 419, 13, 1495, 6, 110, 6, 6, 9, 4759, 9, 787719, 239]; - -function isInAstralSet(code, set) { - let pos = 0x10000; - - for (let i = 0, length = set.length; i < length; i += 2) { - pos += set[i]; - if (pos > code) return false; - pos += set[i + 1]; - if (pos >= code) return true; - } - - return false; -} - -function isIdentifierStart(code) { - if (code < 65) return code === 36; - if (code <= 90) return true; - if (code < 97) return code === 95; - if (code <= 122) return true; - - if (code <= 0xffff) { - return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)); - } - - return isInAstralSet(code, astralIdentifierStartCodes); -} -function isIdentifierChar(code) { - if (code < 48) return code === 36; - if (code < 58) return true; - if (code < 65) return false; - if (code <= 90) return true; - if (code < 97) return code === 95; - if (code <= 122) return true; - - if (code <= 0xffff) { - return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)); - } - - return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes); -} - -const reservedWords = { - keyword: ["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete"], - strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"], - strictBind: ["eval", "arguments"] -}; -const keywords$1 = new Set(reservedWords.keyword); -const reservedWordsStrictSet = new Set(reservedWords.strict); -const reservedWordsStrictBindSet = new Set(reservedWords.strictBind); -function isReservedWord(word, inModule) { - return inModule && word === "await" || word === "enum"; -} -function isStrictReservedWord(word, inModule) { - return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word); -} -function isStrictBindOnlyReservedWord(word) { - return reservedWordsStrictBindSet.has(word); -} -function isStrictBindReservedWord(word, inModule) { - return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word); -} -function isKeyword(word) { - return keywords$1.has(word); -} - -const keywordRelationalOperator = /^in(stanceof)?$/; -function isIteratorStart(current, next) { - return current === 64 && next === 64; -} - -const reservedTypes = new Set(["_", "any", "bool", "boolean", "empty", "extends", "false", "interface", "mixed", "null", "number", "static", "string", "true", "typeof", "void"]); -const FlowErrors = Object.freeze({ - AmbiguousConditionalArrow: "Ambiguous expression: wrap the arrow functions in parentheses to disambiguate.", - AmbiguousDeclareModuleKind: "Found both `declare module.exports` and `declare export` in the same module. Modules can only have 1 since they are either an ES module or they are a CommonJS module", - AssignReservedType: "Cannot overwrite reserved type %0", - DeclareClassElement: "The `declare` modifier can only appear on class fields.", - DeclareClassFieldInitializer: "Initializers are not allowed in fields with the `declare` modifier.", - DuplicateDeclareModuleExports: "Duplicate `declare module.exports` statement", - EnumBooleanMemberNotInitialized: "Boolean enum members need to be initialized. Use either `%0 = true,` or `%0 = false,` in enum `%1`.", - EnumDuplicateMemberName: "Enum member names need to be unique, but the name `%0` has already been used before in enum `%1`.", - EnumInconsistentMemberValues: "Enum `%0` has inconsistent member initializers. Either use no initializers, or consistently use literals (either booleans, numbers, or strings) for all member initializers.", - EnumInvalidExplicitType: "Enum type `%1` is not valid. Use one of `boolean`, `number`, `string`, or `symbol` in enum `%0`.", - EnumInvalidExplicitTypeUnknownSupplied: "Supplied enum type is not valid. Use one of `boolean`, `number`, `string`, or `symbol` in enum `%0`.", - EnumInvalidMemberInitializerPrimaryType: "Enum `%0` has type `%2`, so the initializer of `%1` needs to be a %2 literal.", - EnumInvalidMemberInitializerSymbolType: "Symbol enum members cannot be initialized. Use `%1,` in enum `%0`.", - EnumInvalidMemberInitializerUnknownType: "The enum member initializer for `%1` needs to be a literal (either a boolean, number, or string) in enum `%0`.", - EnumInvalidMemberName: "Enum member names cannot start with lowercase 'a' through 'z'. Instead of using `%0`, consider using `%1`, in enum `%2`.", - EnumNumberMemberNotInitialized: "Number enum members need to be initialized, e.g. `%1 = 1` in enum `%0`.", - EnumStringMemberInconsistentlyInitailized: "String enum members need to consistently either all use initializers, or use no initializers, in enum `%0`.", - ImportTypeShorthandOnlyInPureImport: "The `type` and `typeof` keywords on named imports can only be used on regular `import` statements. It cannot be used with `import type` or `import typeof` statements", - InexactInsideExact: "Explicit inexact syntax cannot appear inside an explicit exact object type", - InexactInsideNonObject: "Explicit inexact syntax cannot appear in class or interface definitions", - InexactVariance: "Explicit inexact syntax cannot have variance", - InvalidNonTypeImportInDeclareModule: "Imports within a `declare module` body must always be `import type` or `import typeof`", - MissingTypeParamDefault: "Type parameter declaration needs a default, since a preceding type parameter declaration has a default.", - NestedDeclareModule: "`declare module` cannot be used inside another `declare module`", - NestedFlowComment: "Cannot have a flow comment inside another flow comment", - OptionalBindingPattern: "A binding pattern parameter cannot be optional in an implementation signature.", - SpreadVariance: "Spread properties cannot have variance", - TypeBeforeInitializer: "Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`", - TypeCastInPattern: "The type cast expression is expected to be wrapped with parenthesis", - UnexpectedExplicitInexactInObject: "Explicit inexact syntax must appear at the end of an inexact object", - UnexpectedReservedType: "Unexpected reserved type %0", - UnexpectedReservedUnderscore: "`_` is only allowed as a type argument to call or new", - UnexpectedSpaceBetweenModuloChecks: "Spaces between `%` and `checks` are not allowed here.", - UnexpectedSpreadType: "Spread operator cannot appear in class or interface definitions", - UnexpectedSubtractionOperand: 'Unexpected token, expected "number" or "bigint"', - UnexpectedTokenAfterTypeParameter: "Expected an arrow function after this type parameter declaration", - UnsupportedDeclareExportKind: "`declare export %0` is not supported. Use `%1` instead", - UnsupportedStatementInDeclareModule: "Only declares and type imports are allowed inside declare module", - UnterminatedFlowComment: "Unterminated flow-comment" -}); - -function isEsModuleType(bodyElement) { - return bodyElement.type === "DeclareExportAllDeclaration" || bodyElement.type === "DeclareExportDeclaration" && (!bodyElement.declaration || bodyElement.declaration.type !== "TypeAlias" && bodyElement.declaration.type !== "InterfaceDeclaration"); -} - -function hasTypeImportKind(node) { - return node.importKind === "type" || node.importKind === "typeof"; -} - -function isMaybeDefaultImport(state) { - return (state.type === types.name || !!state.type.keyword) && state.value !== "from"; -} - -const exportSuggestions = { - const: "declare export var", - let: "declare export var", - type: "export type", - interface: "export interface" -}; - -function partition(list, test) { - const list1 = []; - const list2 = []; - - for (let i = 0; i < list.length; i++) { - (test(list[i], i, list) ? list1 : list2).push(list[i]); - } - - return [list1, list2]; -} - -const FLOW_PRAGMA_REGEX = /\*?\s*@((?:no)?flow)\b/; -var flow = (superClass => class extends superClass { - constructor(options, input) { - super(options, input); - this.flowPragma = undefined; - } - - shouldParseTypes() { - return this.getPluginOption("flow", "all") || this.flowPragma === "flow"; - } - - shouldParseEnums() { - return !!this.getPluginOption("flow", "enums"); - } - - finishToken(type, val) { - if (type !== types.string && type !== types.semi && type !== types.interpreterDirective) { - if (this.flowPragma === undefined) { - this.flowPragma = null; - } - } - - return super.finishToken(type, val); - } - - addComment(comment) { - if (this.flowPragma === undefined) { - const matches = FLOW_PRAGMA_REGEX.exec(comment.value); - - if (!matches) ; else if (matches[1] === "flow") { - this.flowPragma = "flow"; - } else if (matches[1] === "noflow") { - this.flowPragma = "noflow"; - } else { - throw new Error("Unexpected flow pragma"); - } - } - - return super.addComment(comment); - } - - flowParseTypeInitialiser(tok) { - const oldInType = this.state.inType; - this.state.inType = true; - this.expect(tok || types.colon); - const type = this.flowParseType(); - this.state.inType = oldInType; - return type; - } - - flowParsePredicate() { - const node = this.startNode(); - const moduloLoc = this.state.startLoc; - const moduloPos = this.state.start; - this.expect(types.modulo); - const checksLoc = this.state.startLoc; - this.expectContextual("checks"); - - if (moduloLoc.line !== checksLoc.line || moduloLoc.column !== checksLoc.column - 1) { - this.raise(moduloPos, FlowErrors.UnexpectedSpaceBetweenModuloChecks); - } - - if (this.eat(types.parenL)) { - node.value = this.parseExpression(); - this.expect(types.parenR); - return this.finishNode(node, "DeclaredPredicate"); - } else { - return this.finishNode(node, "InferredPredicate"); - } - } - - flowParseTypeAndPredicateInitialiser() { - const oldInType = this.state.inType; - this.state.inType = true; - this.expect(types.colon); - let type = null; - let predicate = null; - - if (this.match(types.modulo)) { - this.state.inType = oldInType; - predicate = this.flowParsePredicate(); - } else { - type = this.flowParseType(); - this.state.inType = oldInType; - - if (this.match(types.modulo)) { - predicate = this.flowParsePredicate(); - } - } - - return [type, predicate]; - } - - flowParseDeclareClass(node) { - this.next(); - this.flowParseInterfaceish(node, true); - return this.finishNode(node, "DeclareClass"); - } - - flowParseDeclareFunction(node) { - this.next(); - const id = node.id = this.parseIdentifier(); - const typeNode = this.startNode(); - const typeContainer = this.startNode(); - - if (this.isRelational("<")) { - typeNode.typeParameters = this.flowParseTypeParameterDeclaration(); - } else { - typeNode.typeParameters = null; - } - - this.expect(types.parenL); - const tmp = this.flowParseFunctionTypeParams(); - typeNode.params = tmp.params; - typeNode.rest = tmp.rest; - this.expect(types.parenR); - [typeNode.returnType, node.predicate] = this.flowParseTypeAndPredicateInitialiser(); - typeContainer.typeAnnotation = this.finishNode(typeNode, "FunctionTypeAnnotation"); - id.typeAnnotation = this.finishNode(typeContainer, "TypeAnnotation"); - this.resetEndLocation(id); - this.semicolon(); - return this.finishNode(node, "DeclareFunction"); - } - - flowParseDeclare(node, insideModule) { - if (this.match(types._class)) { - return this.flowParseDeclareClass(node); - } else if (this.match(types._function)) { - return this.flowParseDeclareFunction(node); - } else if (this.match(types._var)) { - return this.flowParseDeclareVariable(node); - } else if (this.eatContextual("module")) { - if (this.match(types.dot)) { - return this.flowParseDeclareModuleExports(node); - } else { - if (insideModule) { - this.raise(this.state.lastTokStart, FlowErrors.NestedDeclareModule); - } - - return this.flowParseDeclareModule(node); - } - } else if (this.isContextual("type")) { - return this.flowParseDeclareTypeAlias(node); - } else if (this.isContextual("opaque")) { - return this.flowParseDeclareOpaqueType(node); - } else if (this.isContextual("interface")) { - return this.flowParseDeclareInterface(node); - } else if (this.match(types._export)) { - return this.flowParseDeclareExportDeclaration(node, insideModule); - } else { - throw this.unexpected(); - } - } - - flowParseDeclareVariable(node) { - this.next(); - node.id = this.flowParseTypeAnnotatableIdentifier(true); - this.scope.declareName(node.id.name, BIND_VAR, node.id.start); - this.semicolon(); - return this.finishNode(node, "DeclareVariable"); - } - - flowParseDeclareModule(node) { - this.scope.enter(SCOPE_OTHER); - - if (this.match(types.string)) { - node.id = this.parseExprAtom(); - } else { - node.id = this.parseIdentifier(); - } - - const bodyNode = node.body = this.startNode(); - const body = bodyNode.body = []; - this.expect(types.braceL); - - while (!this.match(types.braceR)) { - let bodyNode = this.startNode(); - - if (this.match(types._import)) { - this.next(); - - if (!this.isContextual("type") && !this.match(types._typeof)) { - this.raise(this.state.lastTokStart, FlowErrors.InvalidNonTypeImportInDeclareModule); - } - - this.parseImport(bodyNode); - } else { - this.expectContextual("declare", FlowErrors.UnsupportedStatementInDeclareModule); - bodyNode = this.flowParseDeclare(bodyNode, true); - } - - body.push(bodyNode); - } - - this.scope.exit(); - this.expect(types.braceR); - this.finishNode(bodyNode, "BlockStatement"); - let kind = null; - let hasModuleExport = false; - body.forEach(bodyElement => { - if (isEsModuleType(bodyElement)) { - if (kind === "CommonJS") { - this.raise(bodyElement.start, FlowErrors.AmbiguousDeclareModuleKind); - } - - kind = "ES"; - } else if (bodyElement.type === "DeclareModuleExports") { - if (hasModuleExport) { - this.raise(bodyElement.start, FlowErrors.DuplicateDeclareModuleExports); - } - - if (kind === "ES") { - this.raise(bodyElement.start, FlowErrors.AmbiguousDeclareModuleKind); - } - - kind = "CommonJS"; - hasModuleExport = true; - } - }); - node.kind = kind || "CommonJS"; - return this.finishNode(node, "DeclareModule"); - } - - flowParseDeclareExportDeclaration(node, insideModule) { - this.expect(types._export); - - if (this.eat(types._default)) { - if (this.match(types._function) || this.match(types._class)) { - node.declaration = this.flowParseDeclare(this.startNode()); - } else { - node.declaration = this.flowParseType(); - this.semicolon(); - } - - node.default = true; - return this.finishNode(node, "DeclareExportDeclaration"); - } else { - if (this.match(types._const) || this.isLet() || (this.isContextual("type") || this.isContextual("interface")) && !insideModule) { - const label = this.state.value; - const suggestion = exportSuggestions[label]; - throw this.raise(this.state.start, FlowErrors.UnsupportedDeclareExportKind, label, suggestion); - } - - if (this.match(types._var) || this.match(types._function) || this.match(types._class) || this.isContextual("opaque")) { - node.declaration = this.flowParseDeclare(this.startNode()); - node.default = false; - return this.finishNode(node, "DeclareExportDeclaration"); - } else if (this.match(types.star) || this.match(types.braceL) || this.isContextual("interface") || this.isContextual("type") || this.isContextual("opaque")) { - node = this.parseExport(node); - - if (node.type === "ExportNamedDeclaration") { - node.type = "ExportDeclaration"; - node.default = false; - delete node.exportKind; - } - - node.type = "Declare" + node.type; - return node; - } - } - - throw this.unexpected(); - } - - flowParseDeclareModuleExports(node) { - this.next(); - this.expectContextual("exports"); - node.typeAnnotation = this.flowParseTypeAnnotation(); - this.semicolon(); - return this.finishNode(node, "DeclareModuleExports"); - } - - flowParseDeclareTypeAlias(node) { - this.next(); - this.flowParseTypeAlias(node); - node.type = "DeclareTypeAlias"; - return node; - } - - flowParseDeclareOpaqueType(node) { - this.next(); - this.flowParseOpaqueType(node, true); - node.type = "DeclareOpaqueType"; - return node; - } - - flowParseDeclareInterface(node) { - this.next(); - this.flowParseInterfaceish(node); - return this.finishNode(node, "DeclareInterface"); - } - - flowParseInterfaceish(node, isClass = false) { - node.id = this.flowParseRestrictedIdentifier(!isClass, true); - this.scope.declareName(node.id.name, isClass ? BIND_FUNCTION : BIND_LEXICAL, node.id.start); - - if (this.isRelational("<")) { - node.typeParameters = this.flowParseTypeParameterDeclaration(); - } else { - node.typeParameters = null; - } - - node.extends = []; - node.implements = []; - node.mixins = []; - - if (this.eat(types._extends)) { - do { - node.extends.push(this.flowParseInterfaceExtends()); - } while (!isClass && this.eat(types.comma)); - } - - if (this.isContextual("mixins")) { - this.next(); - - do { - node.mixins.push(this.flowParseInterfaceExtends()); - } while (this.eat(types.comma)); - } - - if (this.isContextual("implements")) { - this.next(); - - do { - node.implements.push(this.flowParseInterfaceExtends()); - } while (this.eat(types.comma)); - } - - node.body = this.flowParseObjectType({ - allowStatic: isClass, - allowExact: false, - allowSpread: false, - allowProto: isClass, - allowInexact: false - }); - } - - flowParseInterfaceExtends() { - const node = this.startNode(); - node.id = this.flowParseQualifiedTypeIdentifier(); - - if (this.isRelational("<")) { - node.typeParameters = this.flowParseTypeParameterInstantiation(); - } else { - node.typeParameters = null; - } - - return this.finishNode(node, "InterfaceExtends"); - } - - flowParseInterface(node) { - this.flowParseInterfaceish(node); - return this.finishNode(node, "InterfaceDeclaration"); - } - - checkNotUnderscore(word) { - if (word === "_") { - this.raise(this.state.start, FlowErrors.UnexpectedReservedUnderscore); - } - } - - checkReservedType(word, startLoc, declaration) { - if (!reservedTypes.has(word)) return; - this.raise(startLoc, declaration ? FlowErrors.AssignReservedType : FlowErrors.UnexpectedReservedType, word); - } - - flowParseRestrictedIdentifier(liberal, declaration) { - this.checkReservedType(this.state.value, this.state.start, declaration); - return this.parseIdentifier(liberal); - } - - flowParseTypeAlias(node) { - node.id = this.flowParseRestrictedIdentifier(false, true); - this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start); - - if (this.isRelational("<")) { - node.typeParameters = this.flowParseTypeParameterDeclaration(); - } else { - node.typeParameters = null; - } - - node.right = this.flowParseTypeInitialiser(types.eq); - this.semicolon(); - return this.finishNode(node, "TypeAlias"); - } - - flowParseOpaqueType(node, declare) { - this.expectContextual("type"); - node.id = this.flowParseRestrictedIdentifier(true, true); - this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start); - - if (this.isRelational("<")) { - node.typeParameters = this.flowParseTypeParameterDeclaration(); - } else { - node.typeParameters = null; - } - - node.supertype = null; - - if (this.match(types.colon)) { - node.supertype = this.flowParseTypeInitialiser(types.colon); - } - - node.impltype = null; - - if (!declare) { - node.impltype = this.flowParseTypeInitialiser(types.eq); - } - - this.semicolon(); - return this.finishNode(node, "OpaqueType"); - } - - flowParseTypeParameter(requireDefault = false) { - const nodeStart = this.state.start; - const node = this.startNode(); - const variance = this.flowParseVariance(); - const ident = this.flowParseTypeAnnotatableIdentifier(); - node.name = ident.name; - node.variance = variance; - node.bound = ident.typeAnnotation; - - if (this.match(types.eq)) { - this.eat(types.eq); - node.default = this.flowParseType(); - } else { - if (requireDefault) { - this.raise(nodeStart, FlowErrors.MissingTypeParamDefault); - } - } - - return this.finishNode(node, "TypeParameter"); - } - - flowParseTypeParameterDeclaration() { - const oldInType = this.state.inType; - const node = this.startNode(); - node.params = []; - this.state.inType = true; - - if (this.isRelational("<") || this.match(types.jsxTagStart)) { - this.next(); - } else { - this.unexpected(); - } - - let defaultRequired = false; - - do { - const typeParameter = this.flowParseTypeParameter(defaultRequired); - node.params.push(typeParameter); - - if (typeParameter.default) { - defaultRequired = true; - } - - if (!this.isRelational(">")) { - this.expect(types.comma); - } - } while (!this.isRelational(">")); - - this.expectRelational(">"); - this.state.inType = oldInType; - return this.finishNode(node, "TypeParameterDeclaration"); - } - - flowParseTypeParameterInstantiation() { - const node = this.startNode(); - const oldInType = this.state.inType; - node.params = []; - this.state.inType = true; - this.expectRelational("<"); - const oldNoAnonFunctionType = this.state.noAnonFunctionType; - this.state.noAnonFunctionType = false; - - while (!this.isRelational(">")) { - node.params.push(this.flowParseType()); - - if (!this.isRelational(">")) { - this.expect(types.comma); - } - } - - this.state.noAnonFunctionType = oldNoAnonFunctionType; - this.expectRelational(">"); - this.state.inType = oldInType; - return this.finishNode(node, "TypeParameterInstantiation"); - } - - flowParseTypeParameterInstantiationCallOrNew() { - const node = this.startNode(); - const oldInType = this.state.inType; - node.params = []; - this.state.inType = true; - this.expectRelational("<"); - - while (!this.isRelational(">")) { - node.params.push(this.flowParseTypeOrImplicitInstantiation()); - - if (!this.isRelational(">")) { - this.expect(types.comma); - } - } - - this.expectRelational(">"); - this.state.inType = oldInType; - return this.finishNode(node, "TypeParameterInstantiation"); - } - - flowParseInterfaceType() { - const node = this.startNode(); - this.expectContextual("interface"); - node.extends = []; - - if (this.eat(types._extends)) { - do { - node.extends.push(this.flowParseInterfaceExtends()); - } while (this.eat(types.comma)); - } - - node.body = this.flowParseObjectType({ - allowStatic: false, - allowExact: false, - allowSpread: false, - allowProto: false, - allowInexact: false - }); - return this.finishNode(node, "InterfaceTypeAnnotation"); - } - - flowParseObjectPropertyKey() { - return this.match(types.num) || this.match(types.string) ? this.parseExprAtom() : this.parseIdentifier(true); - } - - flowParseObjectTypeIndexer(node, isStatic, variance) { - node.static = isStatic; - - if (this.lookahead().type === types.colon) { - node.id = this.flowParseObjectPropertyKey(); - node.key = this.flowParseTypeInitialiser(); - } else { - node.id = null; - node.key = this.flowParseType(); - } - - this.expect(types.bracketR); - node.value = this.flowParseTypeInitialiser(); - node.variance = variance; - return this.finishNode(node, "ObjectTypeIndexer"); - } - - flowParseObjectTypeInternalSlot(node, isStatic) { - node.static = isStatic; - node.id = this.flowParseObjectPropertyKey(); - this.expect(types.bracketR); - this.expect(types.bracketR); - - if (this.isRelational("<") || this.match(types.parenL)) { - node.method = true; - node.optional = false; - node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.start, node.loc.start)); - } else { - node.method = false; - - if (this.eat(types.question)) { - node.optional = true; - } - - node.value = this.flowParseTypeInitialiser(); - } - - return this.finishNode(node, "ObjectTypeInternalSlot"); - } - - flowParseObjectTypeMethodish(node) { - node.params = []; - node.rest = null; - node.typeParameters = null; - - if (this.isRelational("<")) { - node.typeParameters = this.flowParseTypeParameterDeclaration(); - } - - this.expect(types.parenL); - - while (!this.match(types.parenR) && !this.match(types.ellipsis)) { - node.params.push(this.flowParseFunctionTypeParam()); - - if (!this.match(types.parenR)) { - this.expect(types.comma); - } - } - - if (this.eat(types.ellipsis)) { - node.rest = this.flowParseFunctionTypeParam(); - } - - this.expect(types.parenR); - node.returnType = this.flowParseTypeInitialiser(); - return this.finishNode(node, "FunctionTypeAnnotation"); - } - - flowParseObjectTypeCallProperty(node, isStatic) { - const valueNode = this.startNode(); - node.static = isStatic; - node.value = this.flowParseObjectTypeMethodish(valueNode); - return this.finishNode(node, "ObjectTypeCallProperty"); - } - - flowParseObjectType({ - allowStatic, - allowExact, - allowSpread, - allowProto, - allowInexact - }) { - const oldInType = this.state.inType; - this.state.inType = true; - const nodeStart = this.startNode(); - nodeStart.callProperties = []; - nodeStart.properties = []; - nodeStart.indexers = []; - nodeStart.internalSlots = []; - let endDelim; - let exact; - let inexact = false; - - if (allowExact && this.match(types.braceBarL)) { - this.expect(types.braceBarL); - endDelim = types.braceBarR; - exact = true; - } else { - this.expect(types.braceL); - endDelim = types.braceR; - exact = false; - } - - nodeStart.exact = exact; - - while (!this.match(endDelim)) { - let isStatic = false; - let protoStart = null; - let inexactStart = null; - const node = this.startNode(); - - if (allowProto && this.isContextual("proto")) { - const lookahead = this.lookahead(); - - if (lookahead.type !== types.colon && lookahead.type !== types.question) { - this.next(); - protoStart = this.state.start; - allowStatic = false; - } - } - - if (allowStatic && this.isContextual("static")) { - const lookahead = this.lookahead(); - - if (lookahead.type !== types.colon && lookahead.type !== types.question) { - this.next(); - isStatic = true; - } - } - - const variance = this.flowParseVariance(); - - if (this.eat(types.bracketL)) { - if (protoStart != null) { - this.unexpected(protoStart); - } - - if (this.eat(types.bracketL)) { - if (variance) { - this.unexpected(variance.start); - } - - nodeStart.internalSlots.push(this.flowParseObjectTypeInternalSlot(node, isStatic)); - } else { - nodeStart.indexers.push(this.flowParseObjectTypeIndexer(node, isStatic, variance)); - } - } else if (this.match(types.parenL) || this.isRelational("<")) { - if (protoStart != null) { - this.unexpected(protoStart); - } - - if (variance) { - this.unexpected(variance.start); - } - - nodeStart.callProperties.push(this.flowParseObjectTypeCallProperty(node, isStatic)); - } else { - let kind = "init"; - - if (this.isContextual("get") || this.isContextual("set")) { - const lookahead = this.lookahead(); - - if (lookahead.type === types.name || lookahead.type === types.string || lookahead.type === types.num) { - kind = this.state.value; - this.next(); - } - } - - const propOrInexact = this.flowParseObjectTypeProperty(node, isStatic, protoStart, variance, kind, allowSpread, allowInexact != null ? allowInexact : !exact); - - if (propOrInexact === null) { - inexact = true; - inexactStart = this.state.lastTokStart; - } else { - nodeStart.properties.push(propOrInexact); - } - } - - this.flowObjectTypeSemicolon(); - - if (inexactStart && !this.match(types.braceR) && !this.match(types.braceBarR)) { - this.raise(inexactStart, FlowErrors.UnexpectedExplicitInexactInObject); - } - } - - this.expect(endDelim); - - if (allowSpread) { - nodeStart.inexact = inexact; - } - - const out = this.finishNode(nodeStart, "ObjectTypeAnnotation"); - this.state.inType = oldInType; - return out; - } - - flowParseObjectTypeProperty(node, isStatic, protoStart, variance, kind, allowSpread, allowInexact) { - if (this.eat(types.ellipsis)) { - const isInexactToken = this.match(types.comma) || this.match(types.semi) || this.match(types.braceR) || this.match(types.braceBarR); - - if (isInexactToken) { - if (!allowSpread) { - this.raise(this.state.lastTokStart, FlowErrors.InexactInsideNonObject); - } else if (!allowInexact) { - this.raise(this.state.lastTokStart, FlowErrors.InexactInsideExact); - } - - if (variance) { - this.raise(variance.start, FlowErrors.InexactVariance); - } - - return null; - } - - if (!allowSpread) { - this.raise(this.state.lastTokStart, FlowErrors.UnexpectedSpreadType); - } - - if (protoStart != null) { - this.unexpected(protoStart); - } - - if (variance) { - this.raise(variance.start, FlowErrors.SpreadVariance); - } - - node.argument = this.flowParseType(); - return this.finishNode(node, "ObjectTypeSpreadProperty"); - } else { - node.key = this.flowParseObjectPropertyKey(); - node.static = isStatic; - node.proto = protoStart != null; - node.kind = kind; - let optional = false; - - if (this.isRelational("<") || this.match(types.parenL)) { - node.method = true; - - if (protoStart != null) { - this.unexpected(protoStart); - } - - if (variance) { - this.unexpected(variance.start); - } - - node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.start, node.loc.start)); - - if (kind === "get" || kind === "set") { - this.flowCheckGetterSetterParams(node); - } - } else { - if (kind !== "init") this.unexpected(); - node.method = false; - - if (this.eat(types.question)) { - optional = true; - } - - node.value = this.flowParseTypeInitialiser(); - node.variance = variance; - } - - node.optional = optional; - return this.finishNode(node, "ObjectTypeProperty"); - } - } - - flowCheckGetterSetterParams(property) { - const paramCount = property.kind === "get" ? 0 : 1; - const start = property.start; - const length = property.value.params.length + (property.value.rest ? 1 : 0); - - if (length !== paramCount) { - if (property.kind === "get") { - this.raise(start, Errors.BadGetterArity); - } else { - this.raise(start, Errors.BadSetterArity); - } - } - - if (property.kind === "set" && property.value.rest) { - this.raise(start, Errors.BadSetterRestParameter); - } - } - - flowObjectTypeSemicolon() { - if (!this.eat(types.semi) && !this.eat(types.comma) && !this.match(types.braceR) && !this.match(types.braceBarR)) { - this.unexpected(); - } - } - - flowParseQualifiedTypeIdentifier(startPos, startLoc, id) { - startPos = startPos || this.state.start; - startLoc = startLoc || this.state.startLoc; - let node = id || this.flowParseRestrictedIdentifier(true); - - while (this.eat(types.dot)) { - const node2 = this.startNodeAt(startPos, startLoc); - node2.qualification = node; - node2.id = this.flowParseRestrictedIdentifier(true); - node = this.finishNode(node2, "QualifiedTypeIdentifier"); - } - - return node; - } - - flowParseGenericType(startPos, startLoc, id) { - const node = this.startNodeAt(startPos, startLoc); - node.typeParameters = null; - node.id = this.flowParseQualifiedTypeIdentifier(startPos, startLoc, id); - - if (this.isRelational("<")) { - node.typeParameters = this.flowParseTypeParameterInstantiation(); - } - - return this.finishNode(node, "GenericTypeAnnotation"); - } - - flowParseTypeofType() { - const node = this.startNode(); - this.expect(types._typeof); - node.argument = this.flowParsePrimaryType(); - return this.finishNode(node, "TypeofTypeAnnotation"); - } - - flowParseTupleType() { - const node = this.startNode(); - node.types = []; - this.expect(types.bracketL); - - while (this.state.pos < this.length && !this.match(types.bracketR)) { - node.types.push(this.flowParseType()); - if (this.match(types.bracketR)) break; - this.expect(types.comma); - } - - this.expect(types.bracketR); - return this.finishNode(node, "TupleTypeAnnotation"); - } - - flowParseFunctionTypeParam() { - let name = null; - let optional = false; - let typeAnnotation = null; - const node = this.startNode(); - const lh = this.lookahead(); - - if (lh.type === types.colon || lh.type === types.question) { - name = this.parseIdentifier(); - - if (this.eat(types.question)) { - optional = true; - } - - typeAnnotation = this.flowParseTypeInitialiser(); - } else { - typeAnnotation = this.flowParseType(); - } - - node.name = name; - node.optional = optional; - node.typeAnnotation = typeAnnotation; - return this.finishNode(node, "FunctionTypeParam"); - } - - reinterpretTypeAsFunctionTypeParam(type) { - const node = this.startNodeAt(type.start, type.loc.start); - node.name = null; - node.optional = false; - node.typeAnnotation = type; - return this.finishNode(node, "FunctionTypeParam"); - } - - flowParseFunctionTypeParams(params = []) { - let rest = null; - - while (!this.match(types.parenR) && !this.match(types.ellipsis)) { - params.push(this.flowParseFunctionTypeParam()); - - if (!this.match(types.parenR)) { - this.expect(types.comma); - } - } - - if (this.eat(types.ellipsis)) { - rest = this.flowParseFunctionTypeParam(); - } - - return { - params, - rest - }; - } - - flowIdentToTypeAnnotation(startPos, startLoc, node, id) { - switch (id.name) { - case "any": - return this.finishNode(node, "AnyTypeAnnotation"); - - case "bool": - case "boolean": - return this.finishNode(node, "BooleanTypeAnnotation"); - - case "mixed": - return this.finishNode(node, "MixedTypeAnnotation"); - - case "empty": - return this.finishNode(node, "EmptyTypeAnnotation"); - - case "number": - return this.finishNode(node, "NumberTypeAnnotation"); - - case "string": - return this.finishNode(node, "StringTypeAnnotation"); - - case "symbol": - return this.finishNode(node, "SymbolTypeAnnotation"); - - default: - this.checkNotUnderscore(id.name); - return this.flowParseGenericType(startPos, startLoc, id); - } - } - - flowParsePrimaryType() { - const startPos = this.state.start; - const startLoc = this.state.startLoc; - const node = this.startNode(); - let tmp; - let type; - let isGroupedType = false; - const oldNoAnonFunctionType = this.state.noAnonFunctionType; - - switch (this.state.type) { - case types.name: - if (this.isContextual("interface")) { - return this.flowParseInterfaceType(); - } - - return this.flowIdentToTypeAnnotation(startPos, startLoc, node, this.parseIdentifier()); - - case types.braceL: - return this.flowParseObjectType({ - allowStatic: false, - allowExact: false, - allowSpread: true, - allowProto: false, - allowInexact: true - }); - - case types.braceBarL: - return this.flowParseObjectType({ - allowStatic: false, - allowExact: true, - allowSpread: true, - allowProto: false, - allowInexact: false - }); - - case types.bracketL: - this.state.noAnonFunctionType = false; - type = this.flowParseTupleType(); - this.state.noAnonFunctionType = oldNoAnonFunctionType; - return type; - - case types.relational: - if (this.state.value === "<") { - node.typeParameters = this.flowParseTypeParameterDeclaration(); - this.expect(types.parenL); - tmp = this.flowParseFunctionTypeParams(); - node.params = tmp.params; - node.rest = tmp.rest; - this.expect(types.parenR); - this.expect(types.arrow); - node.returnType = this.flowParseType(); - return this.finishNode(node, "FunctionTypeAnnotation"); - } - - break; - - case types.parenL: - this.next(); - - if (!this.match(types.parenR) && !this.match(types.ellipsis)) { - if (this.match(types.name)) { - const token = this.lookahead().type; - isGroupedType = token !== types.question && token !== types.colon; - } else { - isGroupedType = true; - } - } - - if (isGroupedType) { - this.state.noAnonFunctionType = false; - type = this.flowParseType(); - this.state.noAnonFunctionType = oldNoAnonFunctionType; - - if (this.state.noAnonFunctionType || !(this.match(types.comma) || this.match(types.parenR) && this.lookahead().type === types.arrow)) { - this.expect(types.parenR); - return type; - } else { - this.eat(types.comma); - } - } - - if (type) { - tmp = this.flowParseFunctionTypeParams([this.reinterpretTypeAsFunctionTypeParam(type)]); - } else { - tmp = this.flowParseFunctionTypeParams(); - } - - node.params = tmp.params; - node.rest = tmp.rest; - this.expect(types.parenR); - this.expect(types.arrow); - node.returnType = this.flowParseType(); - node.typeParameters = null; - return this.finishNode(node, "FunctionTypeAnnotation"); - - case types.string: - return this.parseLiteral(this.state.value, "StringLiteralTypeAnnotation"); - - case types._true: - case types._false: - node.value = this.match(types._true); - this.next(); - return this.finishNode(node, "BooleanLiteralTypeAnnotation"); - - case types.plusMin: - if (this.state.value === "-") { - this.next(); - - if (this.match(types.num)) { - return this.parseLiteral(-this.state.value, "NumberLiteralTypeAnnotation", node.start, node.loc.start); - } - - if (this.match(types.bigint)) { - return this.parseLiteral(-this.state.value, "BigIntLiteralTypeAnnotation", node.start, node.loc.start); - } - - throw this.raise(this.state.start, FlowErrors.UnexpectedSubtractionOperand); - } - - throw this.unexpected(); - - case types.num: - return this.parseLiteral(this.state.value, "NumberLiteralTypeAnnotation"); - - case types.bigint: - return this.parseLiteral(this.state.value, "BigIntLiteralTypeAnnotation"); - - case types._void: - this.next(); - return this.finishNode(node, "VoidTypeAnnotation"); - - case types._null: - this.next(); - return this.finishNode(node, "NullLiteralTypeAnnotation"); - - case types._this: - this.next(); - return this.finishNode(node, "ThisTypeAnnotation"); - - case types.star: - this.next(); - return this.finishNode(node, "ExistsTypeAnnotation"); - - default: - if (this.state.type.keyword === "typeof") { - return this.flowParseTypeofType(); - } else if (this.state.type.keyword) { - const label = this.state.type.label; - this.next(); - return super.createIdentifier(node, label); - } - - } - - throw this.unexpected(); - } - - flowParsePostfixType() { - const startPos = this.state.start, - startLoc = this.state.startLoc; - let type = this.flowParsePrimaryType(); - - while (this.match(types.bracketL) && !this.canInsertSemicolon()) { - const node = this.startNodeAt(startPos, startLoc); - node.elementType = type; - this.expect(types.bracketL); - this.expect(types.bracketR); - type = this.finishNode(node, "ArrayTypeAnnotation"); - } - - return type; - } - - flowParsePrefixType() { - const node = this.startNode(); - - if (this.eat(types.question)) { - node.typeAnnotation = this.flowParsePrefixType(); - return this.finishNode(node, "NullableTypeAnnotation"); - } else { - return this.flowParsePostfixType(); - } - } - - flowParseAnonFunctionWithoutParens() { - const param = this.flowParsePrefixType(); - - if (!this.state.noAnonFunctionType && this.eat(types.arrow)) { - const node = this.startNodeAt(param.start, param.loc.start); - node.params = [this.reinterpretTypeAsFunctionTypeParam(param)]; - node.rest = null; - node.returnType = this.flowParseType(); - node.typeParameters = null; - return this.finishNode(node, "FunctionTypeAnnotation"); - } - - return param; - } - - flowParseIntersectionType() { - const node = this.startNode(); - this.eat(types.bitwiseAND); - const type = this.flowParseAnonFunctionWithoutParens(); - node.types = [type]; - - while (this.eat(types.bitwiseAND)) { - node.types.push(this.flowParseAnonFunctionWithoutParens()); - } - - return node.types.length === 1 ? type : this.finishNode(node, "IntersectionTypeAnnotation"); - } - - flowParseUnionType() { - const node = this.startNode(); - this.eat(types.bitwiseOR); - const type = this.flowParseIntersectionType(); - node.types = [type]; - - while (this.eat(types.bitwiseOR)) { - node.types.push(this.flowParseIntersectionType()); - } - - return node.types.length === 1 ? type : this.finishNode(node, "UnionTypeAnnotation"); - } - - flowParseType() { - const oldInType = this.state.inType; - this.state.inType = true; - const type = this.flowParseUnionType(); - this.state.inType = oldInType; - this.state.exprAllowed = this.state.exprAllowed || this.state.noAnonFunctionType; - return type; - } - - flowParseTypeOrImplicitInstantiation() { - if (this.state.type === types.name && this.state.value === "_") { - const startPos = this.state.start; - const startLoc = this.state.startLoc; - const node = this.parseIdentifier(); - return this.flowParseGenericType(startPos, startLoc, node); - } else { - return this.flowParseType(); - } - } - - flowParseTypeAnnotation() { - const node = this.startNode(); - node.typeAnnotation = this.flowParseTypeInitialiser(); - return this.finishNode(node, "TypeAnnotation"); - } - - flowParseTypeAnnotatableIdentifier(allowPrimitiveOverride) { - const ident = allowPrimitiveOverride ? this.parseIdentifier() : this.flowParseRestrictedIdentifier(); - - if (this.match(types.colon)) { - ident.typeAnnotation = this.flowParseTypeAnnotation(); - this.resetEndLocation(ident); - } - - return ident; - } - - typeCastToParameter(node) { - node.expression.typeAnnotation = node.typeAnnotation; - this.resetEndLocation(node.expression, node.typeAnnotation.end, node.typeAnnotation.loc.end); - return node.expression; - } - - flowParseVariance() { - let variance = null; - - if (this.match(types.plusMin)) { - variance = this.startNode(); - - if (this.state.value === "+") { - variance.kind = "plus"; - } else { - variance.kind = "minus"; - } - - this.next(); - this.finishNode(variance, "Variance"); - } - - return variance; - } - - parseFunctionBody(node, allowExpressionBody, isMethod = false) { - if (allowExpressionBody) { - return this.forwardNoArrowParamsConversionAt(node, () => super.parseFunctionBody(node, true, isMethod)); - } - - return super.parseFunctionBody(node, false, isMethod); - } - - parseFunctionBodyAndFinish(node, type, isMethod = false) { - if (this.match(types.colon)) { - const typeNode = this.startNode(); - [typeNode.typeAnnotation, node.predicate] = this.flowParseTypeAndPredicateInitialiser(); - node.returnType = typeNode.typeAnnotation ? this.finishNode(typeNode, "TypeAnnotation") : null; - } - - super.parseFunctionBodyAndFinish(node, type, isMethod); - } - - parseStatement(context, topLevel) { - if (this.state.strict && this.match(types.name) && this.state.value === "interface") { - const node = this.startNode(); - this.next(); - return this.flowParseInterface(node); - } else if (this.shouldParseEnums() && this.isContextual("enum")) { - const node = this.startNode(); - this.next(); - return this.flowParseEnumDeclaration(node); - } else { - const stmt = super.parseStatement(context, topLevel); - - if (this.flowPragma === undefined && !this.isValidDirective(stmt)) { - this.flowPragma = null; - } - - return stmt; - } - } - - parseExpressionStatement(node, expr) { - if (expr.type === "Identifier") { - if (expr.name === "declare") { - if (this.match(types._class) || this.match(types.name) || this.match(types._function) || this.match(types._var) || this.match(types._export)) { - return this.flowParseDeclare(node); - } - } else if (this.match(types.name)) { - if (expr.name === "interface") { - return this.flowParseInterface(node); - } else if (expr.name === "type") { - return this.flowParseTypeAlias(node); - } else if (expr.name === "opaque") { - return this.flowParseOpaqueType(node, false); - } - } - } - - return super.parseExpressionStatement(node, expr); - } - - shouldParseExportDeclaration() { - return this.isContextual("type") || this.isContextual("interface") || this.isContextual("opaque") || this.shouldParseEnums() && this.isContextual("enum") || super.shouldParseExportDeclaration(); - } - - isExportDefaultSpecifier() { - if (this.match(types.name) && (this.state.value === "type" || this.state.value === "interface" || this.state.value === "opaque" || this.shouldParseEnums() && this.state.value === "enum")) { - return false; - } - - return super.isExportDefaultSpecifier(); - } - - parseExportDefaultExpression() { - if (this.shouldParseEnums() && this.isContextual("enum")) { - const node = this.startNode(); - this.next(); - return this.flowParseEnumDeclaration(node); - } - - return super.parseExportDefaultExpression(); - } - - parseConditional(expr, noIn, startPos, startLoc, refNeedsArrowPos) { - if (!this.match(types.question)) return expr; - - if (refNeedsArrowPos) { - const result = this.tryParse(() => super.parseConditional(expr, noIn, startPos, startLoc)); - - if (!result.node) { - refNeedsArrowPos.start = result.error.pos || this.state.start; - return expr; - } - - if (result.error) this.state = result.failState; - return result.node; - } - - this.expect(types.question); - const state = this.state.clone(); - const originalNoArrowAt = this.state.noArrowAt; - const node = this.startNodeAt(startPos, startLoc); - let { - consequent, - failed - } = this.tryParseConditionalConsequent(); - let [valid, invalid] = this.getArrowLikeExpressions(consequent); - - if (failed || invalid.length > 0) { - const noArrowAt = [...originalNoArrowAt]; - - if (invalid.length > 0) { - this.state = state; - this.state.noArrowAt = noArrowAt; - - for (let i = 0; i < invalid.length; i++) { - noArrowAt.push(invalid[i].start); - } - - ({ - consequent, - failed - } = this.tryParseConditionalConsequent()); - [valid, invalid] = this.getArrowLikeExpressions(consequent); - } - - if (failed && valid.length > 1) { - this.raise(state.start, FlowErrors.AmbiguousConditionalArrow); - } - - if (failed && valid.length === 1) { - this.state = state; - this.state.noArrowAt = noArrowAt.concat(valid[0].start); - ({ - consequent, - failed - } = this.tryParseConditionalConsequent()); - } - } - - this.getArrowLikeExpressions(consequent, true); - this.state.noArrowAt = originalNoArrowAt; - this.expect(types.colon); - node.test = expr; - node.consequent = consequent; - node.alternate = this.forwardNoArrowParamsConversionAt(node, () => this.parseMaybeAssign(noIn, undefined, undefined, undefined)); - return this.finishNode(node, "ConditionalExpression"); - } - - tryParseConditionalConsequent() { - this.state.noArrowParamsConversionAt.push(this.state.start); - const consequent = this.parseMaybeAssign(); - const failed = !this.match(types.colon); - this.state.noArrowParamsConversionAt.pop(); - return { - consequent, - failed - }; - } - - getArrowLikeExpressions(node, disallowInvalid) { - const stack = [node]; - const arrows = []; - - while (stack.length !== 0) { - const node = stack.pop(); - - if (node.type === "ArrowFunctionExpression") { - if (node.typeParameters || !node.returnType) { - this.finishArrowValidation(node); - } else { - arrows.push(node); - } - - stack.push(node.body); - } else if (node.type === "ConditionalExpression") { - stack.push(node.consequent); - stack.push(node.alternate); - } - } - - if (disallowInvalid) { - arrows.forEach(node => this.finishArrowValidation(node)); - return [arrows, []]; - } - - return partition(arrows, node => node.params.every(param => this.isAssignable(param, true))); - } - - finishArrowValidation(node) { - var _node$extra; - - this.toAssignableList(node.params, (_node$extra = node.extra) == null ? void 0 : _node$extra.trailingComma); - this.scope.enter(SCOPE_FUNCTION | SCOPE_ARROW); - super.checkParams(node, false, true); - this.scope.exit(); - } - - forwardNoArrowParamsConversionAt(node, parse) { - let result; - - if (this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) { - this.state.noArrowParamsConversionAt.push(this.state.start); - result = parse(); - this.state.noArrowParamsConversionAt.pop(); - } else { - result = parse(); - } - - return result; - } - - parseParenItem(node, startPos, startLoc) { - node = super.parseParenItem(node, startPos, startLoc); - - if (this.eat(types.question)) { - node.optional = true; - this.resetEndLocation(node); - } - - if (this.match(types.colon)) { - const typeCastNode = this.startNodeAt(startPos, startLoc); - typeCastNode.expression = node; - typeCastNode.typeAnnotation = this.flowParseTypeAnnotation(); - return this.finishNode(typeCastNode, "TypeCastExpression"); - } - - return node; - } - - assertModuleNodeAllowed(node) { - if (node.type === "ImportDeclaration" && (node.importKind === "type" || node.importKind === "typeof") || node.type === "ExportNamedDeclaration" && node.exportKind === "type" || node.type === "ExportAllDeclaration" && node.exportKind === "type") { - return; - } - - super.assertModuleNodeAllowed(node); - } - - parseExport(node) { - const decl = super.parseExport(node); - - if (decl.type === "ExportNamedDeclaration" || decl.type === "ExportAllDeclaration") { - decl.exportKind = decl.exportKind || "value"; - } - - return decl; - } - - parseExportDeclaration(node) { - if (this.isContextual("type")) { - node.exportKind = "type"; - const declarationNode = this.startNode(); - this.next(); - - if (this.match(types.braceL)) { - node.specifiers = this.parseExportSpecifiers(); - this.parseExportFrom(node); - return null; - } else { - return this.flowParseTypeAlias(declarationNode); - } - } else if (this.isContextual("opaque")) { - node.exportKind = "type"; - const declarationNode = this.startNode(); - this.next(); - return this.flowParseOpaqueType(declarationNode, false); - } else if (this.isContextual("interface")) { - node.exportKind = "type"; - const declarationNode = this.startNode(); - this.next(); - return this.flowParseInterface(declarationNode); - } else if (this.shouldParseEnums() && this.isContextual("enum")) { - node.exportKind = "value"; - const declarationNode = this.startNode(); - this.next(); - return this.flowParseEnumDeclaration(declarationNode); - } else { - return super.parseExportDeclaration(node); - } - } - - eatExportStar(node) { - if (super.eatExportStar(...arguments)) return true; - - if (this.isContextual("type") && this.lookahead().type === types.star) { - node.exportKind = "type"; - this.next(); - this.next(); - return true; - } - - return false; - } - - maybeParseExportNamespaceSpecifier(node) { - const pos = this.state.start; - const hasNamespace = super.maybeParseExportNamespaceSpecifier(node); - - if (hasNamespace && node.exportKind === "type") { - this.unexpected(pos); - } - - return hasNamespace; - } - - parseClassId(node, isStatement, optionalId) { - super.parseClassId(node, isStatement, optionalId); - - if (this.isRelational("<")) { - node.typeParameters = this.flowParseTypeParameterDeclaration(); - } - } - - parseClassMember(classBody, member, state, constructorAllowsSuper) { - const pos = this.state.start; - - if (this.isContextual("declare")) { - if (this.parseClassMemberFromModifier(classBody, member)) { - return; - } - - member.declare = true; - } - - super.parseClassMember(classBody, member, state, constructorAllowsSuper); - - if (member.declare) { - if (member.type !== "ClassProperty" && member.type !== "ClassPrivateProperty") { - this.raise(pos, FlowErrors.DeclareClassElement); - } else if (member.value) { - this.raise(member.value.start, FlowErrors.DeclareClassFieldInitializer); - } - } - } - - getTokenFromCode(code) { - const next = this.input.charCodeAt(this.state.pos + 1); - - if (code === 123 && next === 124) { - return this.finishOp(types.braceBarL, 2); - } else if (this.state.inType && (code === 62 || code === 60)) { - return this.finishOp(types.relational, 1); - } else if (isIteratorStart(code, next)) { - this.state.isIterator = true; - return super.readWord(); - } else { - return super.getTokenFromCode(code); - } - } - - isAssignable(node, isBinding) { - switch (node.type) { - case "Identifier": - case "ObjectPattern": - case "ArrayPattern": - case "AssignmentPattern": - return true; - - case "ObjectExpression": - { - const last = node.properties.length - 1; - return node.properties.every((prop, i) => { - return prop.type !== "ObjectMethod" && (i === last || prop.type === "SpreadElement") && this.isAssignable(prop); - }); - } - - case "ObjectProperty": - return this.isAssignable(node.value); - - case "SpreadElement": - return this.isAssignable(node.argument); - - case "ArrayExpression": - return node.elements.every(element => this.isAssignable(element)); - - case "AssignmentExpression": - return node.operator === "="; - - case "ParenthesizedExpression": - case "TypeCastExpression": - return this.isAssignable(node.expression); - - case "MemberExpression": - case "OptionalMemberExpression": - return !isBinding; - - default: - return false; - } - } - - toAssignable(node) { - if (node.type === "TypeCastExpression") { - return super.toAssignable(this.typeCastToParameter(node)); - } else { - return super.toAssignable(node); - } - } - - toAssignableList(exprList, trailingCommaPos) { - for (let i = 0; i < exprList.length; i++) { - const expr = exprList[i]; - - if (expr && expr.type === "TypeCastExpression") { - exprList[i] = this.typeCastToParameter(expr); - } - } - - return super.toAssignableList(exprList, trailingCommaPos); - } - - toReferencedList(exprList, isParenthesizedExpr) { - for (let i = 0; i < exprList.length; i++) { - const expr = exprList[i]; - - if (expr && expr.type === "TypeCastExpression" && (!expr.extra || !expr.extra.parenthesized) && (exprList.length > 1 || !isParenthesizedExpr)) { - this.raise(expr.typeAnnotation.start, FlowErrors.TypeCastInPattern); - } - } - - return exprList; - } - - checkLVal(expr, bindingType = BIND_NONE, checkClashes, contextDescription) { - if (expr.type !== "TypeCastExpression") { - return super.checkLVal(expr, bindingType, checkClashes, contextDescription); - } - } - - parseClassProperty(node) { - if (this.match(types.colon)) { - node.typeAnnotation = this.flowParseTypeAnnotation(); - } - - return super.parseClassProperty(node); - } - - parseClassPrivateProperty(node) { - if (this.match(types.colon)) { - node.typeAnnotation = this.flowParseTypeAnnotation(); - } - - return super.parseClassPrivateProperty(node); - } - - isClassMethod() { - return this.isRelational("<") || super.isClassMethod(); - } - - isClassProperty() { - return this.match(types.colon) || super.isClassProperty(); - } - - isNonstaticConstructor(method) { - return !this.match(types.colon) && super.isNonstaticConstructor(method); - } - - pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) { - if (method.variance) { - this.unexpected(method.variance.start); - } - - delete method.variance; - - if (this.isRelational("<")) { - method.typeParameters = this.flowParseTypeParameterDeclaration(); - } - - super.pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper); - } - - pushClassPrivateMethod(classBody, method, isGenerator, isAsync) { - if (method.variance) { - this.unexpected(method.variance.start); - } - - delete method.variance; - - if (this.isRelational("<")) { - method.typeParameters = this.flowParseTypeParameterDeclaration(); - } - - super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync); - } - - parseClassSuper(node) { - super.parseClassSuper(node); - - if (node.superClass && this.isRelational("<")) { - node.superTypeParameters = this.flowParseTypeParameterInstantiation(); - } - - if (this.isContextual("implements")) { - this.next(); - const implemented = node.implements = []; - - do { - const node = this.startNode(); - node.id = this.flowParseRestrictedIdentifier(true); - - if (this.isRelational("<")) { - node.typeParameters = this.flowParseTypeParameterInstantiation(); - } else { - node.typeParameters = null; - } - - implemented.push(this.finishNode(node, "ClassImplements")); - } while (this.eat(types.comma)); - } - } - - parsePropertyName(node, isPrivateNameAllowed) { - const variance = this.flowParseVariance(); - const key = super.parsePropertyName(node, isPrivateNameAllowed); - node.variance = variance; - return key; - } - - parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, refExpressionErrors, containsEsc) { - if (prop.variance) { - this.unexpected(prop.variance.start); - } - - delete prop.variance; - let typeParameters; - - if (this.isRelational("<")) { - typeParameters = this.flowParseTypeParameterDeclaration(); - if (!this.match(types.parenL)) this.unexpected(); - } - - super.parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, refExpressionErrors, containsEsc); - - if (typeParameters) { - (prop.value || prop).typeParameters = typeParameters; - } - } - - parseAssignableListItemTypes(param) { - if (this.eat(types.question)) { - if (param.type !== "Identifier") { - this.raise(param.start, FlowErrors.OptionalBindingPattern); - } - - param.optional = true; - } - - if (this.match(types.colon)) { - param.typeAnnotation = this.flowParseTypeAnnotation(); - } - - this.resetEndLocation(param); - return param; - } - - parseMaybeDefault(startPos, startLoc, left) { - const node = super.parseMaybeDefault(startPos, startLoc, left); - - if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) { - this.raise(node.typeAnnotation.start, FlowErrors.TypeBeforeInitializer); - } - - return node; - } - - shouldParseDefaultImport(node) { - if (!hasTypeImportKind(node)) { - return super.shouldParseDefaultImport(node); - } - - return isMaybeDefaultImport(this.state); - } - - parseImportSpecifierLocal(node, specifier, type, contextDescription) { - specifier.local = hasTypeImportKind(node) ? this.flowParseRestrictedIdentifier(true, true) : this.parseIdentifier(); - this.checkLVal(specifier.local, BIND_LEXICAL, undefined, contextDescription); - node.specifiers.push(this.finishNode(specifier, type)); - } - - maybeParseDefaultImportSpecifier(node) { - node.importKind = "value"; - let kind = null; - - if (this.match(types._typeof)) { - kind = "typeof"; - } else if (this.isContextual("type")) { - kind = "type"; - } - - if (kind) { - const lh = this.lookahead(); - - if (kind === "type" && lh.type === types.star) { - this.unexpected(lh.start); - } - - if (isMaybeDefaultImport(lh) || lh.type === types.braceL || lh.type === types.star) { - this.next(); - node.importKind = kind; - } - } - - return super.maybeParseDefaultImportSpecifier(node); - } - - parseImportSpecifier(node) { - const specifier = this.startNode(); - const firstIdentLoc = this.state.start; - const firstIdent = this.parseIdentifier(true); - let specifierTypeKind = null; - - if (firstIdent.name === "type") { - specifierTypeKind = "type"; - } else if (firstIdent.name === "typeof") { - specifierTypeKind = "typeof"; - } - - let isBinding = false; - - if (this.isContextual("as") && !this.isLookaheadContextual("as")) { - const as_ident = this.parseIdentifier(true); - - if (specifierTypeKind !== null && !this.match(types.name) && !this.state.type.keyword) { - specifier.imported = as_ident; - specifier.importKind = specifierTypeKind; - specifier.local = as_ident.__clone(); - } else { - specifier.imported = firstIdent; - specifier.importKind = null; - specifier.local = this.parseIdentifier(); - } - } else if (specifierTypeKind !== null && (this.match(types.name) || this.state.type.keyword)) { - specifier.imported = this.parseIdentifier(true); - specifier.importKind = specifierTypeKind; - - if (this.eatContextual("as")) { - specifier.local = this.parseIdentifier(); - } else { - isBinding = true; - specifier.local = specifier.imported.__clone(); - } - } else { - isBinding = true; - specifier.imported = firstIdent; - specifier.importKind = null; - specifier.local = specifier.imported.__clone(); - } - - const nodeIsTypeImport = hasTypeImportKind(node); - const specifierIsTypeImport = hasTypeImportKind(specifier); - - if (nodeIsTypeImport && specifierIsTypeImport) { - this.raise(firstIdentLoc, FlowErrors.ImportTypeShorthandOnlyInPureImport); - } - - if (nodeIsTypeImport || specifierIsTypeImport) { - this.checkReservedType(specifier.local.name, specifier.local.start, true); - } - - if (isBinding && !nodeIsTypeImport && !specifierIsTypeImport) { - this.checkReservedWord(specifier.local.name, specifier.start, true, true); - } - - this.checkLVal(specifier.local, BIND_LEXICAL, undefined, "import specifier"); - node.specifiers.push(this.finishNode(specifier, "ImportSpecifier")); - } - - parseFunctionParams(node, allowModifiers) { - const kind = node.kind; - - if (kind !== "get" && kind !== "set" && this.isRelational("<")) { - node.typeParameters = this.flowParseTypeParameterDeclaration(); - } - - super.parseFunctionParams(node, allowModifiers); - } - - parseVarId(decl, kind) { - super.parseVarId(decl, kind); - - if (this.match(types.colon)) { - decl.id.typeAnnotation = this.flowParseTypeAnnotation(); - this.resetEndLocation(decl.id); - } - } - - parseAsyncArrowFromCallExpression(node, call) { - if (this.match(types.colon)) { - const oldNoAnonFunctionType = this.state.noAnonFunctionType; - this.state.noAnonFunctionType = true; - node.returnType = this.flowParseTypeAnnotation(); - this.state.noAnonFunctionType = oldNoAnonFunctionType; - } - - return super.parseAsyncArrowFromCallExpression(node, call); - } - - shouldParseAsyncArrow() { - return this.match(types.colon) || super.shouldParseAsyncArrow(); - } - - parseMaybeAssign(noIn, refExpressionErrors, afterLeftParse, refNeedsArrowPos) { - let state = null; - let jsx; - - if (this.hasPlugin("jsx") && (this.match(types.jsxTagStart) || this.isRelational("<"))) { - state = this.state.clone(); - jsx = this.tryParse(() => super.parseMaybeAssign(noIn, refExpressionErrors, afterLeftParse, refNeedsArrowPos), state); - if (!jsx.error) return jsx.node; - const { - context - } = this.state; - - if (context[context.length - 1] === types$1.j_oTag) { - context.length -= 2; - } else if (context[context.length - 1] === types$1.j_expr) { - context.length -= 1; - } - } - - if (jsx && jsx.error || this.isRelational("<")) { - state = state || this.state.clone(); - let typeParameters; - const arrow = this.tryParse(() => { - typeParameters = this.flowParseTypeParameterDeclaration(); - const arrowExpression = this.forwardNoArrowParamsConversionAt(typeParameters, () => super.parseMaybeAssign(noIn, refExpressionErrors, afterLeftParse, refNeedsArrowPos)); - arrowExpression.typeParameters = typeParameters; - this.resetStartLocationFromNode(arrowExpression, typeParameters); - return arrowExpression; - }, state); - const arrowExpression = arrow.node && arrow.node.type === "ArrowFunctionExpression" ? arrow.node : null; - if (!arrow.error && arrowExpression) return arrowExpression; - - if (jsx && jsx.node) { - this.state = jsx.failState; - return jsx.node; - } - - if (arrowExpression) { - this.state = arrow.failState; - return arrowExpression; - } - - if (jsx && jsx.thrown) throw jsx.error; - if (arrow.thrown) throw arrow.error; - throw this.raise(typeParameters.start, FlowErrors.UnexpectedTokenAfterTypeParameter); - } - - return super.parseMaybeAssign(noIn, refExpressionErrors, afterLeftParse, refNeedsArrowPos); - } - - parseArrow(node) { - if (this.match(types.colon)) { - const result = this.tryParse(() => { - const oldNoAnonFunctionType = this.state.noAnonFunctionType; - this.state.noAnonFunctionType = true; - const typeNode = this.startNode(); - [typeNode.typeAnnotation, node.predicate] = this.flowParseTypeAndPredicateInitialiser(); - this.state.noAnonFunctionType = oldNoAnonFunctionType; - if (this.canInsertSemicolon()) this.unexpected(); - if (!this.match(types.arrow)) this.unexpected(); - return typeNode; - }); - if (result.thrown) return null; - if (result.error) this.state = result.failState; - node.returnType = result.node.typeAnnotation ? this.finishNode(result.node, "TypeAnnotation") : null; - } - - return super.parseArrow(node); - } - - shouldParseArrow() { - return this.match(types.colon) || super.shouldParseArrow(); - } - - setArrowFunctionParameters(node, params) { - if (this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) { - node.params = params; - } else { - super.setArrowFunctionParameters(node, params); - } - } - - checkParams(node, allowDuplicates, isArrowFunction) { - if (isArrowFunction && this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) { - return; - } - - return super.checkParams(...arguments); - } - - parseParenAndDistinguishExpression(canBeArrow) { - return super.parseParenAndDistinguishExpression(canBeArrow && this.state.noArrowAt.indexOf(this.state.start) === -1); - } - - parseSubscripts(base, startPos, startLoc, noCalls) { - if (base.type === "Identifier" && base.name === "async" && this.state.noArrowAt.indexOf(startPos) !== -1) { - this.next(); - const node = this.startNodeAt(startPos, startLoc); - node.callee = base; - node.arguments = this.parseCallExpressionArguments(types.parenR, false); - base = this.finishNode(node, "CallExpression"); - } else if (base.type === "Identifier" && base.name === "async" && this.isRelational("<")) { - const state = this.state.clone(); - const arrow = this.tryParse(abort => this.parseAsyncArrowWithTypeParameters(startPos, startLoc) || abort(), state); - if (!arrow.error && !arrow.aborted) return arrow.node; - const result = this.tryParse(() => super.parseSubscripts(base, startPos, startLoc, noCalls), state); - if (result.node && !result.error) return result.node; - - if (arrow.node) { - this.state = arrow.failState; - return arrow.node; - } - - if (result.node) { - this.state = result.failState; - return result.node; - } - - throw arrow.error || result.error; - } - - return super.parseSubscripts(base, startPos, startLoc, noCalls); - } - - parseSubscript(base, startPos, startLoc, noCalls, subscriptState) { - if (this.match(types.questionDot) && this.isLookaheadRelational("<")) { - subscriptState.optionalChainMember = true; - - if (noCalls) { - subscriptState.stop = true; - return base; - } - - this.next(); - const node = this.startNodeAt(startPos, startLoc); - node.callee = base; - node.typeArguments = this.flowParseTypeParameterInstantiation(); - this.expect(types.parenL); - node.arguments = this.parseCallExpressionArguments(types.parenR, false); - node.optional = true; - return this.finishCallExpression(node, true); - } else if (!noCalls && this.shouldParseTypes() && this.isRelational("<")) { - const node = this.startNodeAt(startPos, startLoc); - node.callee = base; - const result = this.tryParse(() => { - node.typeArguments = this.flowParseTypeParameterInstantiationCallOrNew(); - this.expect(types.parenL); - node.arguments = this.parseCallExpressionArguments(types.parenR, false); - if (subscriptState.optionalChainMember) node.optional = false; - return this.finishCallExpression(node, subscriptState.optionalChainMember); - }); - - if (result.node) { - if (result.error) this.state = result.failState; - return result.node; - } - } - - return super.parseSubscript(base, startPos, startLoc, noCalls, subscriptState); - } - - parseNewArguments(node) { - let targs = null; - - if (this.shouldParseTypes() && this.isRelational("<")) { - targs = this.tryParse(() => this.flowParseTypeParameterInstantiationCallOrNew()).node; - } - - node.typeArguments = targs; - super.parseNewArguments(node); - } - - parseAsyncArrowWithTypeParameters(startPos, startLoc) { - const node = this.startNodeAt(startPos, startLoc); - this.parseFunctionParams(node); - if (!this.parseArrow(node)) return; - return this.parseArrowExpression(node, undefined, true); - } - - readToken_mult_modulo(code) { - const next = this.input.charCodeAt(this.state.pos + 1); - - if (code === 42 && next === 47 && this.state.hasFlowComment) { - this.state.hasFlowComment = false; - this.state.pos += 2; - this.nextToken(); - return; - } - - super.readToken_mult_modulo(code); - } - - readToken_pipe_amp(code) { - const next = this.input.charCodeAt(this.state.pos + 1); - - if (code === 124 && next === 125) { - this.finishOp(types.braceBarR, 2); - return; - } - - super.readToken_pipe_amp(code); - } - - parseTopLevel(file, program) { - const fileNode = super.parseTopLevel(file, program); - - if (this.state.hasFlowComment) { - this.raise(this.state.pos, FlowErrors.UnterminatedFlowComment); - } - - return fileNode; - } - - skipBlockComment() { - if (this.hasPlugin("flowComments") && this.skipFlowComment()) { - if (this.state.hasFlowComment) { - this.unexpected(null, FlowErrors.NestedFlowComment); - } - - this.hasFlowCommentCompletion(); - this.state.pos += this.skipFlowComment(); - this.state.hasFlowComment = true; - return; - } - - if (this.state.hasFlowComment) { - const end = this.input.indexOf("*-/", this.state.pos += 2); - - if (end === -1) { - throw this.raise(this.state.pos - 2, Errors.UnterminatedComment); - } - - this.state.pos = end + 3; - return; - } - - super.skipBlockComment(); - } - - skipFlowComment() { - const { - pos - } = this.state; - let shiftToFirstNonWhiteSpace = 2; - - while ([32, 9].includes(this.input.charCodeAt(pos + shiftToFirstNonWhiteSpace))) { - shiftToFirstNonWhiteSpace++; - } - - const ch2 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos); - const ch3 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos + 1); - - if (ch2 === 58 && ch3 === 58) { - return shiftToFirstNonWhiteSpace + 2; - } - - if (this.input.slice(shiftToFirstNonWhiteSpace + pos, shiftToFirstNonWhiteSpace + pos + 12) === "flow-include") { - return shiftToFirstNonWhiteSpace + 12; - } - - if (ch2 === 58 && ch3 !== 58) { - return shiftToFirstNonWhiteSpace; - } - - return false; - } - - hasFlowCommentCompletion() { - const end = this.input.indexOf("*/", this.state.pos); - - if (end === -1) { - throw this.raise(this.state.pos, Errors.UnterminatedComment); - } - } - - flowEnumErrorBooleanMemberNotInitialized(pos, { - enumName, - memberName - }) { - this.raise(pos, FlowErrors.EnumBooleanMemberNotInitialized, memberName, enumName); - } - - flowEnumErrorInvalidMemberName(pos, { - enumName, - memberName - }) { - const suggestion = memberName[0].toUpperCase() + memberName.slice(1); - this.raise(pos, FlowErrors.EnumInvalidMemberName, memberName, suggestion, enumName); - } - - flowEnumErrorDuplicateMemberName(pos, { - enumName, - memberName - }) { - this.raise(pos, FlowErrors.EnumDuplicateMemberName, memberName, enumName); - } - - flowEnumErrorInconsistentMemberValues(pos, { - enumName - }) { - this.raise(pos, FlowErrors.EnumInconsistentMemberValues, enumName); - } - - flowEnumErrorInvalidExplicitType(pos, { - enumName, - suppliedType - }) { - return this.raise(pos, suppliedType === null ? FlowErrors.EnumInvalidExplicitTypeUnknownSupplied : FlowErrors.EnumInvalidExplicitType, enumName, suppliedType); - } - - flowEnumErrorInvalidMemberInitializer(pos, { - enumName, - explicitType, - memberName - }) { - let message = null; - - switch (explicitType) { - case "boolean": - case "number": - case "string": - message = FlowErrors.EnumInvalidMemberInitializerPrimaryType; - break; - - case "symbol": - message = FlowErrors.EnumInvalidMemberInitializerSymbolType; - break; - - default: - message = FlowErrors.EnumInvalidMemberInitializerUnknownType; - } - - return this.raise(pos, message, enumName, memberName, explicitType); - } - - flowEnumErrorNumberMemberNotInitialized(pos, { - enumName, - memberName - }) { - this.raise(pos, FlowErrors.EnumNumberMemberNotInitialized, enumName, memberName); - } - - flowEnumErrorStringMemberInconsistentlyInitailized(pos, { - enumName - }) { - this.raise(pos, FlowErrors.EnumStringMemberInconsistentlyInitailized, enumName); - } - - flowEnumMemberInit() { - const startPos = this.state.start; - - const endOfInit = () => this.match(types.comma) || this.match(types.braceR); - - switch (this.state.type) { - case types.num: - { - const literal = this.parseLiteral(this.state.value, "NumericLiteral"); - - if (endOfInit()) { - return { - type: "number", - pos: literal.start, - value: literal - }; - } - - return { - type: "invalid", - pos: startPos - }; - } - - case types.string: - { - const literal = this.parseLiteral(this.state.value, "StringLiteral"); - - if (endOfInit()) { - return { - type: "string", - pos: literal.start, - value: literal - }; - } - - return { - type: "invalid", - pos: startPos - }; - } - - case types._true: - case types._false: - { - const literal = this.parseBooleanLiteral(); - - if (endOfInit()) { - return { - type: "boolean", - pos: literal.start, - value: literal - }; - } - - return { - type: "invalid", - pos: startPos - }; - } - - default: - return { - type: "invalid", - pos: startPos - }; - } - } - - flowEnumMemberRaw() { - const pos = this.state.start; - const id = this.parseIdentifier(true); - const init = this.eat(types.eq) ? this.flowEnumMemberInit() : { - type: "none", - pos - }; - return { - id, - init - }; - } - - flowEnumCheckExplicitTypeMismatch(pos, context, expectedType) { - const { - explicitType - } = context; - - if (explicitType === null) { - return; - } - - if (explicitType !== expectedType) { - this.flowEnumErrorInvalidMemberInitializer(pos, context); - } - } - - flowEnumMembers({ - enumName, - explicitType - }) { - const seenNames = new Set(); - const members = { - booleanMembers: [], - numberMembers: [], - stringMembers: [], - defaultedMembers: [] - }; - - while (!this.match(types.braceR)) { - const memberNode = this.startNode(); - const { - id, - init - } = this.flowEnumMemberRaw(); - const memberName = id.name; - - if (memberName === "") { - continue; - } - - if (/^[a-z]/.test(memberName)) { - this.flowEnumErrorInvalidMemberName(id.start, { - enumName, - memberName - }); - } - - if (seenNames.has(memberName)) { - this.flowEnumErrorDuplicateMemberName(id.start, { - enumName, - memberName - }); - } - - seenNames.add(memberName); - const context = { - enumName, - explicitType, - memberName - }; - memberNode.id = id; - - switch (init.type) { - case "boolean": - { - this.flowEnumCheckExplicitTypeMismatch(init.pos, context, "boolean"); - memberNode.init = init.value; - members.booleanMembers.push(this.finishNode(memberNode, "EnumBooleanMember")); - break; - } - - case "number": - { - this.flowEnumCheckExplicitTypeMismatch(init.pos, context, "number"); - memberNode.init = init.value; - members.numberMembers.push(this.finishNode(memberNode, "EnumNumberMember")); - break; - } - - case "string": - { - this.flowEnumCheckExplicitTypeMismatch(init.pos, context, "string"); - memberNode.init = init.value; - members.stringMembers.push(this.finishNode(memberNode, "EnumStringMember")); - break; - } - - case "invalid": - { - throw this.flowEnumErrorInvalidMemberInitializer(init.pos, context); - } - - case "none": - { - switch (explicitType) { - case "boolean": - this.flowEnumErrorBooleanMemberNotInitialized(init.pos, context); - break; - - case "number": - this.flowEnumErrorNumberMemberNotInitialized(init.pos, context); - break; - - default: - members.defaultedMembers.push(this.finishNode(memberNode, "EnumDefaultedMember")); - } - } - } - - if (!this.match(types.braceR)) { - this.expect(types.comma); - } - } - - return members; - } - - flowEnumStringMembers(initializedMembers, defaultedMembers, { - enumName - }) { - if (initializedMembers.length === 0) { - return defaultedMembers; - } else if (defaultedMembers.length === 0) { - return initializedMembers; - } else if (defaultedMembers.length > initializedMembers.length) { - for (let _i = 0; _i < initializedMembers.length; _i++) { - const member = initializedMembers[_i]; - this.flowEnumErrorStringMemberInconsistentlyInitailized(member.start, { - enumName - }); - } - - return defaultedMembers; - } else { - for (let _i2 = 0; _i2 < defaultedMembers.length; _i2++) { - const member = defaultedMembers[_i2]; - this.flowEnumErrorStringMemberInconsistentlyInitailized(member.start, { - enumName - }); - } - - return initializedMembers; - } - } - - flowEnumParseExplicitType({ - enumName - }) { - if (this.eatContextual("of")) { - if (!this.match(types.name)) { - throw this.flowEnumErrorInvalidExplicitType(this.state.start, { - enumName, - suppliedType: null - }); - } - - const { - value - } = this.state; - this.next(); - - if (value !== "boolean" && value !== "number" && value !== "string" && value !== "symbol") { - this.flowEnumErrorInvalidExplicitType(this.state.start, { - enumName, - suppliedType: value - }); - } - - return value; - } - - return null; - } - - flowEnumBody(node, { - enumName, - nameLoc - }) { - const explicitType = this.flowEnumParseExplicitType({ - enumName - }); - this.expect(types.braceL); - const members = this.flowEnumMembers({ - enumName, - explicitType - }); - - switch (explicitType) { - case "boolean": - node.explicitType = true; - node.members = members.booleanMembers; - this.expect(types.braceR); - return this.finishNode(node, "EnumBooleanBody"); - - case "number": - node.explicitType = true; - node.members = members.numberMembers; - this.expect(types.braceR); - return this.finishNode(node, "EnumNumberBody"); - - case "string": - node.explicitType = true; - node.members = this.flowEnumStringMembers(members.stringMembers, members.defaultedMembers, { - enumName - }); - this.expect(types.braceR); - return this.finishNode(node, "EnumStringBody"); - - case "symbol": - node.members = members.defaultedMembers; - this.expect(types.braceR); - return this.finishNode(node, "EnumSymbolBody"); - - default: - { - const empty = () => { - node.members = []; - this.expect(types.braceR); - return this.finishNode(node, "EnumStringBody"); - }; - - node.explicitType = false; - const boolsLen = members.booleanMembers.length; - const numsLen = members.numberMembers.length; - const strsLen = members.stringMembers.length; - const defaultedLen = members.defaultedMembers.length; - - if (!boolsLen && !numsLen && !strsLen && !defaultedLen) { - return empty(); - } else if (!boolsLen && !numsLen) { - node.members = this.flowEnumStringMembers(members.stringMembers, members.defaultedMembers, { - enumName - }); - this.expect(types.braceR); - return this.finishNode(node, "EnumStringBody"); - } else if (!numsLen && !strsLen && boolsLen >= defaultedLen) { - for (let _i3 = 0, _members$defaultedMem = members.defaultedMembers; _i3 < _members$defaultedMem.length; _i3++) { - const member = _members$defaultedMem[_i3]; - this.flowEnumErrorBooleanMemberNotInitialized(member.start, { - enumName, - memberName: member.id.name - }); - } - - node.members = members.booleanMembers; - this.expect(types.braceR); - return this.finishNode(node, "EnumBooleanBody"); - } else if (!boolsLen && !strsLen && numsLen >= defaultedLen) { - for (let _i4 = 0, _members$defaultedMem2 = members.defaultedMembers; _i4 < _members$defaultedMem2.length; _i4++) { - const member = _members$defaultedMem2[_i4]; - this.flowEnumErrorNumberMemberNotInitialized(member.start, { - enumName, - memberName: member.id.name - }); - } - - node.members = members.numberMembers; - this.expect(types.braceR); - return this.finishNode(node, "EnumNumberBody"); - } else { - this.flowEnumErrorInconsistentMemberValues(nameLoc, { - enumName - }); - return empty(); - } - } - } - } - - flowParseEnumDeclaration(node) { - const id = this.parseIdentifier(); - node.id = id; - node.body = this.flowEnumBody(this.startNode(), { - enumName: id.name, - nameLoc: id.start - }); - return this.finishNode(node, "EnumDeclaration"); - } - -}); - -const entities = { - quot: "\u0022", - amp: "&", - apos: "\u0027", - lt: "<", - gt: ">", - nbsp: "\u00A0", - iexcl: "\u00A1", - cent: "\u00A2", - pound: "\u00A3", - curren: "\u00A4", - yen: "\u00A5", - brvbar: "\u00A6", - sect: "\u00A7", - uml: "\u00A8", - copy: "\u00A9", - ordf: "\u00AA", - laquo: "\u00AB", - not: "\u00AC", - shy: "\u00AD", - reg: "\u00AE", - macr: "\u00AF", - deg: "\u00B0", - plusmn: "\u00B1", - sup2: "\u00B2", - sup3: "\u00B3", - acute: "\u00B4", - micro: "\u00B5", - para: "\u00B6", - middot: "\u00B7", - cedil: "\u00B8", - sup1: "\u00B9", - ordm: "\u00BA", - raquo: "\u00BB", - frac14: "\u00BC", - frac12: "\u00BD", - frac34: "\u00BE", - iquest: "\u00BF", - Agrave: "\u00C0", - Aacute: "\u00C1", - Acirc: "\u00C2", - Atilde: "\u00C3", - Auml: "\u00C4", - Aring: "\u00C5", - AElig: "\u00C6", - Ccedil: "\u00C7", - Egrave: "\u00C8", - Eacute: "\u00C9", - Ecirc: "\u00CA", - Euml: "\u00CB", - Igrave: "\u00CC", - Iacute: "\u00CD", - Icirc: "\u00CE", - Iuml: "\u00CF", - ETH: "\u00D0", - Ntilde: "\u00D1", - Ograve: "\u00D2", - Oacute: "\u00D3", - Ocirc: "\u00D4", - Otilde: "\u00D5", - Ouml: "\u00D6", - times: "\u00D7", - Oslash: "\u00D8", - Ugrave: "\u00D9", - Uacute: "\u00DA", - Ucirc: "\u00DB", - Uuml: "\u00DC", - Yacute: "\u00DD", - THORN: "\u00DE", - szlig: "\u00DF", - agrave: "\u00E0", - aacute: "\u00E1", - acirc: "\u00E2", - atilde: "\u00E3", - auml: "\u00E4", - aring: "\u00E5", - aelig: "\u00E6", - ccedil: "\u00E7", - egrave: "\u00E8", - eacute: "\u00E9", - ecirc: "\u00EA", - euml: "\u00EB", - igrave: "\u00EC", - iacute: "\u00ED", - icirc: "\u00EE", - iuml: "\u00EF", - eth: "\u00F0", - ntilde: "\u00F1", - ograve: "\u00F2", - oacute: "\u00F3", - ocirc: "\u00F4", - otilde: "\u00F5", - ouml: "\u00F6", - divide: "\u00F7", - oslash: "\u00F8", - ugrave: "\u00F9", - uacute: "\u00FA", - ucirc: "\u00FB", - uuml: "\u00FC", - yacute: "\u00FD", - thorn: "\u00FE", - yuml: "\u00FF", - OElig: "\u0152", - oelig: "\u0153", - Scaron: "\u0160", - scaron: "\u0161", - Yuml: "\u0178", - fnof: "\u0192", - circ: "\u02C6", - tilde: "\u02DC", - Alpha: "\u0391", - Beta: "\u0392", - Gamma: "\u0393", - Delta: "\u0394", - Epsilon: "\u0395", - Zeta: "\u0396", - Eta: "\u0397", - Theta: "\u0398", - Iota: "\u0399", - Kappa: "\u039A", - Lambda: "\u039B", - Mu: "\u039C", - Nu: "\u039D", - Xi: "\u039E", - Omicron: "\u039F", - Pi: "\u03A0", - Rho: "\u03A1", - Sigma: "\u03A3", - Tau: "\u03A4", - Upsilon: "\u03A5", - Phi: "\u03A6", - Chi: "\u03A7", - Psi: "\u03A8", - Omega: "\u03A9", - alpha: "\u03B1", - beta: "\u03B2", - gamma: "\u03B3", - delta: "\u03B4", - epsilon: "\u03B5", - zeta: "\u03B6", - eta: "\u03B7", - theta: "\u03B8", - iota: "\u03B9", - kappa: "\u03BA", - lambda: "\u03BB", - mu: "\u03BC", - nu: "\u03BD", - xi: "\u03BE", - omicron: "\u03BF", - pi: "\u03C0", - rho: "\u03C1", - sigmaf: "\u03C2", - sigma: "\u03C3", - tau: "\u03C4", - upsilon: "\u03C5", - phi: "\u03C6", - chi: "\u03C7", - psi: "\u03C8", - omega: "\u03C9", - thetasym: "\u03D1", - upsih: "\u03D2", - piv: "\u03D6", - ensp: "\u2002", - emsp: "\u2003", - thinsp: "\u2009", - zwnj: "\u200C", - zwj: "\u200D", - lrm: "\u200E", - rlm: "\u200F", - ndash: "\u2013", - mdash: "\u2014", - lsquo: "\u2018", - rsquo: "\u2019", - sbquo: "\u201A", - ldquo: "\u201C", - rdquo: "\u201D", - bdquo: "\u201E", - dagger: "\u2020", - Dagger: "\u2021", - bull: "\u2022", - hellip: "\u2026", - permil: "\u2030", - prime: "\u2032", - Prime: "\u2033", - lsaquo: "\u2039", - rsaquo: "\u203A", - oline: "\u203E", - frasl: "\u2044", - euro: "\u20AC", - image: "\u2111", - weierp: "\u2118", - real: "\u211C", - trade: "\u2122", - alefsym: "\u2135", - larr: "\u2190", - uarr: "\u2191", - rarr: "\u2192", - darr: "\u2193", - harr: "\u2194", - crarr: "\u21B5", - lArr: "\u21D0", - uArr: "\u21D1", - rArr: "\u21D2", - dArr: "\u21D3", - hArr: "\u21D4", - forall: "\u2200", - part: "\u2202", - exist: "\u2203", - empty: "\u2205", - nabla: "\u2207", - isin: "\u2208", - notin: "\u2209", - ni: "\u220B", - prod: "\u220F", - sum: "\u2211", - minus: "\u2212", - lowast: "\u2217", - radic: "\u221A", - prop: "\u221D", - infin: "\u221E", - ang: "\u2220", - and: "\u2227", - or: "\u2228", - cap: "\u2229", - cup: "\u222A", - int: "\u222B", - there4: "\u2234", - sim: "\u223C", - cong: "\u2245", - asymp: "\u2248", - ne: "\u2260", - equiv: "\u2261", - le: "\u2264", - ge: "\u2265", - sub: "\u2282", - sup: "\u2283", - nsub: "\u2284", - sube: "\u2286", - supe: "\u2287", - oplus: "\u2295", - otimes: "\u2297", - perp: "\u22A5", - sdot: "\u22C5", - lceil: "\u2308", - rceil: "\u2309", - lfloor: "\u230A", - rfloor: "\u230B", - lang: "\u2329", - rang: "\u232A", - loz: "\u25CA", - spades: "\u2660", - clubs: "\u2663", - hearts: "\u2665", - diams: "\u2666" -}; - -const HEX_NUMBER = /^[\da-fA-F]+$/; -const DECIMAL_NUMBER = /^\d+$/; -const JsxErrors = Object.freeze({ - AttributeIsEmpty: "JSX attributes must only be assigned a non-empty expression", - MissingClosingTagFragment: "Expected corresponding JSX closing tag for <>", - MissingClosingTagElement: "Expected corresponding JSX closing tag for <%0>", - UnsupportedJsxValue: "JSX value should be either an expression or a quoted JSX text", - UnterminatedJsxContent: "Unterminated JSX contents", - UnwrappedAdjacentJSXElements: "Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...?" -}); -types$1.j_oTag = new TokContext("...", true, true); -types.jsxName = new TokenType("jsxName"); -types.jsxText = new TokenType("jsxText", { - beforeExpr: true -}); -types.jsxTagStart = new TokenType("jsxTagStart", { - startsExpr: true -}); -types.jsxTagEnd = new TokenType("jsxTagEnd"); - -types.jsxTagStart.updateContext = function () { - this.state.context.push(types$1.j_expr); - this.state.context.push(types$1.j_oTag); - this.state.exprAllowed = false; -}; - -types.jsxTagEnd.updateContext = function (prevType) { - const out = this.state.context.pop(); - - if (out === types$1.j_oTag && prevType === types.slash || out === types$1.j_cTag) { - this.state.context.pop(); - this.state.exprAllowed = this.curContext() === types$1.j_expr; - } else { - this.state.exprAllowed = true; - } -}; - -function isFragment(object) { - return object ? object.type === "JSXOpeningFragment" || object.type === "JSXClosingFragment" : false; -} - -function getQualifiedJSXName(object) { - if (object.type === "JSXIdentifier") { - return object.name; - } - - if (object.type === "JSXNamespacedName") { - return object.namespace.name + ":" + object.name.name; - } - - if (object.type === "JSXMemberExpression") { - return getQualifiedJSXName(object.object) + "." + getQualifiedJSXName(object.property); - } - - throw new Error("Node had unexpected type: " + object.type); -} - -var jsx = (superClass => class extends superClass { - jsxReadToken() { - let out = ""; - let chunkStart = this.state.pos; - - for (;;) { - if (this.state.pos >= this.length) { - throw this.raise(this.state.start, JsxErrors.UnterminatedJsxContent); - } - - const ch = this.input.charCodeAt(this.state.pos); - - switch (ch) { - case 60: - case 123: - if (this.state.pos === this.state.start) { - if (ch === 60 && this.state.exprAllowed) { - ++this.state.pos; - return this.finishToken(types.jsxTagStart); - } - - return super.getTokenFromCode(ch); - } - - out += this.input.slice(chunkStart, this.state.pos); - return this.finishToken(types.jsxText, out); - - case 38: - out += this.input.slice(chunkStart, this.state.pos); - out += this.jsxReadEntity(); - chunkStart = this.state.pos; - break; - - default: - if (isNewLine(ch)) { - out += this.input.slice(chunkStart, this.state.pos); - out += this.jsxReadNewLine(true); - chunkStart = this.state.pos; - } else { - ++this.state.pos; - } - - } - } - } - - jsxReadNewLine(normalizeCRLF) { - const ch = this.input.charCodeAt(this.state.pos); - let out; - ++this.state.pos; - - if (ch === 13 && this.input.charCodeAt(this.state.pos) === 10) { - ++this.state.pos; - out = normalizeCRLF ? "\n" : "\r\n"; - } else { - out = String.fromCharCode(ch); - } - - ++this.state.curLine; - this.state.lineStart = this.state.pos; - return out; - } - - jsxReadString(quote) { - let out = ""; - let chunkStart = ++this.state.pos; - - for (;;) { - if (this.state.pos >= this.length) { - throw this.raise(this.state.start, Errors.UnterminatedString); - } - - const ch = this.input.charCodeAt(this.state.pos); - if (ch === quote) break; - - if (ch === 38) { - out += this.input.slice(chunkStart, this.state.pos); - out += this.jsxReadEntity(); - chunkStart = this.state.pos; - } else if (isNewLine(ch)) { - out += this.input.slice(chunkStart, this.state.pos); - out += this.jsxReadNewLine(false); - chunkStart = this.state.pos; - } else { - ++this.state.pos; - } - } - - out += this.input.slice(chunkStart, this.state.pos++); - return this.finishToken(types.string, out); - } - - jsxReadEntity() { - let str = ""; - let count = 0; - let entity; - let ch = this.input[this.state.pos]; - const startPos = ++this.state.pos; - - while (this.state.pos < this.length && count++ < 10) { - ch = this.input[this.state.pos++]; - - if (ch === ";") { - if (str[0] === "#") { - if (str[1] === "x") { - str = str.substr(2); - - if (HEX_NUMBER.test(str)) { - entity = String.fromCodePoint(parseInt(str, 16)); - } - } else { - str = str.substr(1); - - if (DECIMAL_NUMBER.test(str)) { - entity = String.fromCodePoint(parseInt(str, 10)); - } - } - } else { - entity = entities[str]; - } - - break; - } - - str += ch; - } - - if (!entity) { - this.state.pos = startPos; - return "&"; - } - - return entity; - } - - jsxReadWord() { - let ch; - const start = this.state.pos; - - do { - ch = this.input.charCodeAt(++this.state.pos); - } while (isIdentifierChar(ch) || ch === 45); - - return this.finishToken(types.jsxName, this.input.slice(start, this.state.pos)); - } - - jsxParseIdentifier() { - const node = this.startNode(); - - if (this.match(types.jsxName)) { - node.name = this.state.value; - } else if (this.state.type.keyword) { - node.name = this.state.type.keyword; - } else { - this.unexpected(); - } - - this.next(); - return this.finishNode(node, "JSXIdentifier"); - } - - jsxParseNamespacedName() { - const startPos = this.state.start; - const startLoc = this.state.startLoc; - const name = this.jsxParseIdentifier(); - if (!this.eat(types.colon)) return name; - const node = this.startNodeAt(startPos, startLoc); - node.namespace = name; - node.name = this.jsxParseIdentifier(); - return this.finishNode(node, "JSXNamespacedName"); - } - - jsxParseElementName() { - const startPos = this.state.start; - const startLoc = this.state.startLoc; - let node = this.jsxParseNamespacedName(); - - if (node.type === "JSXNamespacedName") { - return node; - } - - while (this.eat(types.dot)) { - const newNode = this.startNodeAt(startPos, startLoc); - newNode.object = node; - newNode.property = this.jsxParseIdentifier(); - node = this.finishNode(newNode, "JSXMemberExpression"); - } - - return node; - } - - jsxParseAttributeValue() { - let node; - - switch (this.state.type) { - case types.braceL: - node = this.startNode(); - this.next(); - node = this.jsxParseExpressionContainer(node); - - if (node.expression.type === "JSXEmptyExpression") { - this.raise(node.start, JsxErrors.AttributeIsEmpty); - } - - return node; - - case types.jsxTagStart: - case types.string: - return this.parseExprAtom(); - - default: - throw this.raise(this.state.start, JsxErrors.UnsupportedJsxValue); - } - } - - jsxParseEmptyExpression() { - const node = this.startNodeAt(this.state.lastTokEnd, this.state.lastTokEndLoc); - return this.finishNodeAt(node, "JSXEmptyExpression", this.state.start, this.state.startLoc); - } - - jsxParseSpreadChild(node) { - this.next(); - node.expression = this.parseExpression(); - this.expect(types.braceR); - return this.finishNode(node, "JSXSpreadChild"); - } - - jsxParseExpressionContainer(node) { - if (this.match(types.braceR)) { - node.expression = this.jsxParseEmptyExpression(); - } else { - node.expression = this.parseExpression(); - } - - this.expect(types.braceR); - return this.finishNode(node, "JSXExpressionContainer"); - } - - jsxParseAttribute() { - const node = this.startNode(); - - if (this.eat(types.braceL)) { - this.expect(types.ellipsis); - node.argument = this.parseMaybeAssign(); - this.expect(types.braceR); - return this.finishNode(node, "JSXSpreadAttribute"); - } - - node.name = this.jsxParseNamespacedName(); - node.value = this.eat(types.eq) ? this.jsxParseAttributeValue() : null; - return this.finishNode(node, "JSXAttribute"); - } - - jsxParseOpeningElementAt(startPos, startLoc) { - const node = this.startNodeAt(startPos, startLoc); - - if (this.match(types.jsxTagEnd)) { - this.expect(types.jsxTagEnd); - return this.finishNode(node, "JSXOpeningFragment"); - } - - node.name = this.jsxParseElementName(); - return this.jsxParseOpeningElementAfterName(node); - } - - jsxParseOpeningElementAfterName(node) { - const attributes = []; - - while (!this.match(types.slash) && !this.match(types.jsxTagEnd)) { - attributes.push(this.jsxParseAttribute()); - } - - node.attributes = attributes; - node.selfClosing = this.eat(types.slash); - this.expect(types.jsxTagEnd); - return this.finishNode(node, "JSXOpeningElement"); - } - - jsxParseClosingElementAt(startPos, startLoc) { - const node = this.startNodeAt(startPos, startLoc); - - if (this.match(types.jsxTagEnd)) { - this.expect(types.jsxTagEnd); - return this.finishNode(node, "JSXClosingFragment"); - } - - node.name = this.jsxParseElementName(); - this.expect(types.jsxTagEnd); - return this.finishNode(node, "JSXClosingElement"); - } - - jsxParseElementAt(startPos, startLoc) { - const node = this.startNodeAt(startPos, startLoc); - const children = []; - const openingElement = this.jsxParseOpeningElementAt(startPos, startLoc); - let closingElement = null; - - if (!openingElement.selfClosing) { - contents: for (;;) { - switch (this.state.type) { - case types.jsxTagStart: - startPos = this.state.start; - startLoc = this.state.startLoc; - this.next(); - - if (this.eat(types.slash)) { - closingElement = this.jsxParseClosingElementAt(startPos, startLoc); - break contents; - } - - children.push(this.jsxParseElementAt(startPos, startLoc)); - break; - - case types.jsxText: - children.push(this.parseExprAtom()); - break; - - case types.braceL: - { - const node = this.startNode(); - this.next(); - - if (this.match(types.ellipsis)) { - children.push(this.jsxParseSpreadChild(node)); - } else { - children.push(this.jsxParseExpressionContainer(node)); - } - - break; - } - - default: - throw this.unexpected(); - } - } - - if (isFragment(openingElement) && !isFragment(closingElement)) { - this.raise(closingElement.start, JsxErrors.MissingClosingTagFragment); - } else if (!isFragment(openingElement) && isFragment(closingElement)) { - this.raise(closingElement.start, JsxErrors.MissingClosingTagElement, getQualifiedJSXName(openingElement.name)); - } else if (!isFragment(openingElement) && !isFragment(closingElement)) { - if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) { - this.raise(closingElement.start, JsxErrors.MissingClosingTagElement, getQualifiedJSXName(openingElement.name)); - } - } - } - - if (isFragment(openingElement)) { - node.openingFragment = openingElement; - node.closingFragment = closingElement; - } else { - node.openingElement = openingElement; - node.closingElement = closingElement; - } - - node.children = children; - - if (this.isRelational("<")) { - throw this.raise(this.state.start, JsxErrors.UnwrappedAdjacentJSXElements); - } - - return isFragment(openingElement) ? this.finishNode(node, "JSXFragment") : this.finishNode(node, "JSXElement"); - } - - jsxParseElement() { - const startPos = this.state.start; - const startLoc = this.state.startLoc; - this.next(); - return this.jsxParseElementAt(startPos, startLoc); - } - - parseExprAtom(refExpressionErrors) { - if (this.match(types.jsxText)) { - return this.parseLiteral(this.state.value, "JSXText"); - } else if (this.match(types.jsxTagStart)) { - return this.jsxParseElement(); - } else if (this.isRelational("<") && this.input.charCodeAt(this.state.pos) !== 33) { - this.finishToken(types.jsxTagStart); - return this.jsxParseElement(); - } else { - return super.parseExprAtom(refExpressionErrors); - } - } - - getTokenFromCode(code) { - if (this.state.inPropertyName) return super.getTokenFromCode(code); - const context = this.curContext(); - - if (context === types$1.j_expr) { - return this.jsxReadToken(); - } - - if (context === types$1.j_oTag || context === types$1.j_cTag) { - if (isIdentifierStart(code)) { - return this.jsxReadWord(); - } - - if (code === 62) { - ++this.state.pos; - return this.finishToken(types.jsxTagEnd); - } - - if ((code === 34 || code === 39) && context === types$1.j_oTag) { - return this.jsxReadString(code); - } - } - - if (code === 60 && this.state.exprAllowed && this.input.charCodeAt(this.state.pos + 1) !== 33) { - ++this.state.pos; - return this.finishToken(types.jsxTagStart); - } - - return super.getTokenFromCode(code); - } - - updateContext(prevType) { - if (this.match(types.braceL)) { - const curContext = this.curContext(); - - if (curContext === types$1.j_oTag) { - this.state.context.push(types$1.braceExpression); - } else if (curContext === types$1.j_expr) { - this.state.context.push(types$1.templateQuasi); - } else { - super.updateContext(prevType); - } - - this.state.exprAllowed = true; - } else if (this.match(types.slash) && prevType === types.jsxTagStart) { - this.state.context.length -= 2; - this.state.context.push(types$1.j_cTag); - this.state.exprAllowed = false; - } else { - return super.updateContext(prevType); - } - } - -}); - -class Scope { - constructor(flags) { - this.var = []; - this.lexical = []; - this.functions = []; - this.flags = flags; - } - -} -class ScopeHandler { - constructor(raise, inModule) { - this.scopeStack = []; - this.undefinedExports = new Map(); - this.undefinedPrivateNames = new Map(); - this.raise = raise; - this.inModule = inModule; - } - - get inFunction() { - return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0; - } - - get allowSuper() { - return (this.currentThisScope().flags & SCOPE_SUPER) > 0; - } - - get allowDirectSuper() { - return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0; - } - - get inClass() { - return (this.currentThisScope().flags & SCOPE_CLASS) > 0; - } - - get inNonArrowFunction() { - return (this.currentThisScope().flags & SCOPE_FUNCTION) > 0; - } - - get treatFunctionsAsVar() { - return this.treatFunctionsAsVarInScope(this.currentScope()); - } - - createScope(flags) { - return new Scope(flags); - } - - enter(flags) { - this.scopeStack.push(this.createScope(flags)); - } - - exit() { - this.scopeStack.pop(); - } - - treatFunctionsAsVarInScope(scope) { - return !!(scope.flags & SCOPE_FUNCTION || !this.inModule && scope.flags & SCOPE_PROGRAM); - } - - declareName(name, bindingType, pos) { - let scope = this.currentScope(); - - if (bindingType & BIND_SCOPE_LEXICAL || bindingType & BIND_SCOPE_FUNCTION) { - this.checkRedeclarationInScope(scope, name, bindingType, pos); - - if (bindingType & BIND_SCOPE_FUNCTION) { - scope.functions.push(name); - } else { - scope.lexical.push(name); - } - - if (bindingType & BIND_SCOPE_LEXICAL) { - this.maybeExportDefined(scope, name); - } - } else if (bindingType & BIND_SCOPE_VAR) { - for (let i = this.scopeStack.length - 1; i >= 0; --i) { - scope = this.scopeStack[i]; - this.checkRedeclarationInScope(scope, name, bindingType, pos); - scope.var.push(name); - this.maybeExportDefined(scope, name); - if (scope.flags & SCOPE_VAR) break; - } - } - - if (this.inModule && scope.flags & SCOPE_PROGRAM) { - this.undefinedExports.delete(name); - } - } - - maybeExportDefined(scope, name) { - if (this.inModule && scope.flags & SCOPE_PROGRAM) { - this.undefinedExports.delete(name); - } - } - - checkRedeclarationInScope(scope, name, bindingType, pos) { - if (this.isRedeclaredInScope(scope, name, bindingType)) { - this.raise(pos, Errors.VarRedeclaration, name); - } - } - - isRedeclaredInScope(scope, name, bindingType) { - if (!(bindingType & BIND_KIND_VALUE)) return false; - - if (bindingType & BIND_SCOPE_LEXICAL) { - return scope.lexical.indexOf(name) > -1 || scope.functions.indexOf(name) > -1 || scope.var.indexOf(name) > -1; - } - - if (bindingType & BIND_SCOPE_FUNCTION) { - return scope.lexical.indexOf(name) > -1 || !this.treatFunctionsAsVarInScope(scope) && scope.var.indexOf(name) > -1; - } - - return scope.lexical.indexOf(name) > -1 && !(scope.flags & SCOPE_SIMPLE_CATCH && scope.lexical[0] === name) || !this.treatFunctionsAsVarInScope(scope) && scope.functions.indexOf(name) > -1; - } - - checkLocalExport(id) { - if (this.scopeStack[0].lexical.indexOf(id.name) === -1 && this.scopeStack[0].var.indexOf(id.name) === -1 && this.scopeStack[0].functions.indexOf(id.name) === -1) { - this.undefinedExports.set(id.name, id.start); - } - } - - currentScope() { - return this.scopeStack[this.scopeStack.length - 1]; - } - - currentVarScope() { - for (let i = this.scopeStack.length - 1;; i--) { - const scope = this.scopeStack[i]; - - if (scope.flags & SCOPE_VAR) { - return scope; - } - } - } - - currentThisScope() { - for (let i = this.scopeStack.length - 1;; i--) { - const scope = this.scopeStack[i]; - - if ((scope.flags & SCOPE_VAR || scope.flags & SCOPE_CLASS) && !(scope.flags & SCOPE_ARROW)) { - return scope; - } - } - } - -} - -class TypeScriptScope extends Scope { - constructor(...args) { - super(...args); - this.types = []; - this.enums = []; - this.constEnums = []; - this.classes = []; - this.exportOnlyBindings = []; - } - -} - -class TypeScriptScopeHandler extends ScopeHandler { - createScope(flags) { - return new TypeScriptScope(flags); - } - - declareName(name, bindingType, pos) { - const scope = this.currentScope(); - - if (bindingType & BIND_FLAGS_TS_EXPORT_ONLY) { - this.maybeExportDefined(scope, name); - scope.exportOnlyBindings.push(name); - return; - } - - super.declareName(...arguments); - - if (bindingType & BIND_KIND_TYPE) { - if (!(bindingType & BIND_KIND_VALUE)) { - this.checkRedeclarationInScope(scope, name, bindingType, pos); - this.maybeExportDefined(scope, name); - } - - scope.types.push(name); - } - - if (bindingType & BIND_FLAGS_TS_ENUM) scope.enums.push(name); - if (bindingType & BIND_FLAGS_TS_CONST_ENUM) scope.constEnums.push(name); - if (bindingType & BIND_FLAGS_CLASS) scope.classes.push(name); - } - - isRedeclaredInScope(scope, name, bindingType) { - if (scope.enums.indexOf(name) > -1) { - if (bindingType & BIND_FLAGS_TS_ENUM) { - const isConst = !!(bindingType & BIND_FLAGS_TS_CONST_ENUM); - const wasConst = scope.constEnums.indexOf(name) > -1; - return isConst !== wasConst; - } - - return true; - } - - if (bindingType & BIND_FLAGS_CLASS && scope.classes.indexOf(name) > -1) { - if (scope.lexical.indexOf(name) > -1) { - return !!(bindingType & BIND_KIND_VALUE); - } else { - return false; - } - } - - if (bindingType & BIND_KIND_TYPE && scope.types.indexOf(name) > -1) { - return true; - } - - return super.isRedeclaredInScope(...arguments); - } - - checkLocalExport(id) { - if (this.scopeStack[0].types.indexOf(id.name) === -1 && this.scopeStack[0].exportOnlyBindings.indexOf(id.name) === -1) { - super.checkLocalExport(id); - } - } - -} - -const PARAM = 0b000, - PARAM_YIELD = 0b001, - PARAM_AWAIT = 0b010, - PARAM_RETURN = 0b100; -class ProductionParameterHandler { - constructor() { - this.stacks = []; - } - - enter(flags) { - this.stacks.push(flags); - } - - exit() { - this.stacks.pop(); - } - - currentFlags() { - return this.stacks[this.stacks.length - 1]; - } - - get hasAwait() { - return (this.currentFlags() & PARAM_AWAIT) > 0; - } - - get hasYield() { - return (this.currentFlags() & PARAM_YIELD) > 0; - } - - get hasReturn() { - return (this.currentFlags() & PARAM_RETURN) > 0; - } - -} -function functionFlags(isAsync, isGenerator) { - return (isAsync ? PARAM_AWAIT : 0) | (isGenerator ? PARAM_YIELD : 0); -} - -function nonNull(x) { - if (x == null) { - throw new Error(`Unexpected ${x} value.`); - } - - return x; -} - -function assert(x) { - if (!x) { - throw new Error("Assert fail"); - } -} - -const TSErrors = Object.freeze({ - ClassMethodHasDeclare: "Class methods cannot have the 'declare' modifier", - ClassMethodHasReadonly: "Class methods cannot have the 'readonly' modifier", - DeclareClassFieldHasInitializer: "'declare' class fields cannot have an initializer", - DuplicateModifier: "Duplicate modifier: '%0'", - EmptyHeritageClauseType: "'%0' list cannot be empty.", - IndexSignatureHasAbstract: "Index signatures cannot have the 'abstract' modifier", - IndexSignatureHasAccessibility: "Index signatures cannot have an accessibility modifier ('%0')", - IndexSignatureHasStatic: "Index signatures cannot have the 'static' modifier", - OptionalTypeBeforeRequired: "A required element cannot follow an optional element.", - PatternIsOptional: "A binding pattern parameter cannot be optional in an implementation signature.", - PrivateElementHasAbstract: "Private elements cannot have the 'abstract' modifier.", - PrivateElementHasAccessibility: "Private elements cannot have an accessibility modifier ('%0')", - TemplateTypeHasSubstitution: "Template literal types cannot have any substitution", - TypeAnnotationAfterAssign: "Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`", - UnexpectedReadonly: "'readonly' type modifier is only permitted on array and tuple literal types.", - UnexpectedTypeAnnotation: "Did not expect a type annotation here.", - UnexpectedTypeCastInParameter: "Unexpected type cast in parameter position.", - UnsupportedImportTypeArgument: "Argument in a type import must be a string literal", - UnsupportedParameterPropertyKind: "A parameter property may not be declared using a binding pattern.", - UnsupportedSignatureParameterKind: "Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got %0" -}); - -function keywordTypeFromName(value) { - switch (value) { - case "any": - return "TSAnyKeyword"; - - case "boolean": - return "TSBooleanKeyword"; - - case "bigint": - return "TSBigIntKeyword"; - - case "never": - return "TSNeverKeyword"; - - case "number": - return "TSNumberKeyword"; - - case "object": - return "TSObjectKeyword"; - - case "string": - return "TSStringKeyword"; - - case "symbol": - return "TSSymbolKeyword"; - - case "undefined": - return "TSUndefinedKeyword"; - - case "unknown": - return "TSUnknownKeyword"; - - default: - return undefined; - } -} - -var typescript = (superClass => class extends superClass { - getScopeHandler() { - return TypeScriptScopeHandler; - } - - tsIsIdentifier() { - return this.match(types.name); - } - - tsNextTokenCanFollowModifier() { - this.next(); - return !this.hasPrecedingLineBreak() && !this.match(types.parenL) && !this.match(types.parenR) && !this.match(types.colon) && !this.match(types.eq) && !this.match(types.question) && !this.match(types.bang); - } - - tsParseModifier(allowedModifiers) { - if (!this.match(types.name)) { - return undefined; - } - - const modifier = this.state.value; - - if (allowedModifiers.indexOf(modifier) !== -1 && this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this))) { - return modifier; - } - - return undefined; - } - - tsParseModifiers(modified, allowedModifiers) { - for (;;) { - const startPos = this.state.start; - const modifier = this.tsParseModifier(allowedModifiers); - if (!modifier) break; - - if (Object.hasOwnProperty.call(modified, modifier)) { - this.raise(startPos, TSErrors.DuplicateModifier, modifier); - } - - modified[modifier] = true; - } - } - - tsIsListTerminator(kind) { - switch (kind) { - case "EnumMembers": - case "TypeMembers": - return this.match(types.braceR); - - case "HeritageClauseElement": - return this.match(types.braceL); - - case "TupleElementTypes": - return this.match(types.bracketR); - - case "TypeParametersOrArguments": - return this.isRelational(">"); - } - - throw new Error("Unreachable"); - } - - tsParseList(kind, parseElement) { - const result = []; - - while (!this.tsIsListTerminator(kind)) { - result.push(parseElement()); - } - - return result; - } - - tsParseDelimitedList(kind, parseElement) { - return nonNull(this.tsParseDelimitedListWorker(kind, parseElement, true)); - } - - tsParseDelimitedListWorker(kind, parseElement, expectSuccess) { - const result = []; - - for (;;) { - if (this.tsIsListTerminator(kind)) { - break; - } - - const element = parseElement(); - - if (element == null) { - return undefined; - } - - result.push(element); - - if (this.eat(types.comma)) { - continue; - } - - if (this.tsIsListTerminator(kind)) { - break; - } - - if (expectSuccess) { - this.expect(types.comma); - } - - return undefined; - } - - return result; - } - - tsParseBracketedList(kind, parseElement, bracket, skipFirstToken) { - if (!skipFirstToken) { - if (bracket) { - this.expect(types.bracketL); - } else { - this.expectRelational("<"); - } - } - - const result = this.tsParseDelimitedList(kind, parseElement); - - if (bracket) { - this.expect(types.bracketR); - } else { - this.expectRelational(">"); - } - - return result; - } - - tsParseImportType() { - const node = this.startNode(); - this.expect(types._import); - this.expect(types.parenL); - - if (!this.match(types.string)) { - this.raise(this.state.start, TSErrors.UnsupportedImportTypeArgument); - } - - node.argument = this.parseExprAtom(); - this.expect(types.parenR); - - if (this.eat(types.dot)) { - node.qualifier = this.tsParseEntityName(true); - } - - if (this.isRelational("<")) { - node.typeParameters = this.tsParseTypeArguments(); - } - - return this.finishNode(node, "TSImportType"); - } - - tsParseEntityName(allowReservedWords) { - let entity = this.parseIdentifier(); - - while (this.eat(types.dot)) { - const node = this.startNodeAtNode(entity); - node.left = entity; - node.right = this.parseIdentifier(allowReservedWords); - entity = this.finishNode(node, "TSQualifiedName"); - } - - return entity; - } - - tsParseTypeReference() { - const node = this.startNode(); - node.typeName = this.tsParseEntityName(false); - - if (!this.hasPrecedingLineBreak() && this.isRelational("<")) { - node.typeParameters = this.tsParseTypeArguments(); - } - - return this.finishNode(node, "TSTypeReference"); - } - - tsParseThisTypePredicate(lhs) { - this.next(); - const node = this.startNodeAtNode(lhs); - node.parameterName = lhs; - node.typeAnnotation = this.tsParseTypeAnnotation(false); - return this.finishNode(node, "TSTypePredicate"); - } - - tsParseThisTypeNode() { - const node = this.startNode(); - this.next(); - return this.finishNode(node, "TSThisType"); - } - - tsParseTypeQuery() { - const node = this.startNode(); - this.expect(types._typeof); - - if (this.match(types._import)) { - node.exprName = this.tsParseImportType(); - } else { - node.exprName = this.tsParseEntityName(true); - } - - return this.finishNode(node, "TSTypeQuery"); - } - - tsParseTypeParameter() { - const node = this.startNode(); - node.name = this.parseIdentifierName(node.start); - node.constraint = this.tsEatThenParseType(types._extends); - node.default = this.tsEatThenParseType(types.eq); - return this.finishNode(node, "TSTypeParameter"); - } - - tsTryParseTypeParameters() { - if (this.isRelational("<")) { - return this.tsParseTypeParameters(); - } - } - - tsParseTypeParameters() { - const node = this.startNode(); - - if (this.isRelational("<") || this.match(types.jsxTagStart)) { - this.next(); - } else { - this.unexpected(); - } - - node.params = this.tsParseBracketedList("TypeParametersOrArguments", this.tsParseTypeParameter.bind(this), false, true); - return this.finishNode(node, "TSTypeParameterDeclaration"); - } - - tsTryNextParseConstantContext() { - if (this.lookahead().type === types._const) { - this.next(); - return this.tsParseTypeReference(); - } - - return null; - } - - tsFillSignature(returnToken, signature) { - const returnTokenRequired = returnToken === types.arrow; - signature.typeParameters = this.tsTryParseTypeParameters(); - this.expect(types.parenL); - signature.parameters = this.tsParseBindingListForSignature(); - - if (returnTokenRequired) { - signature.typeAnnotation = this.tsParseTypeOrTypePredicateAnnotation(returnToken); - } else if (this.match(returnToken)) { - signature.typeAnnotation = this.tsParseTypeOrTypePredicateAnnotation(returnToken); - } - } - - tsParseBindingListForSignature() { - return this.parseBindingList(types.parenR, 41).map(pattern => { - if (pattern.type !== "Identifier" && pattern.type !== "RestElement" && pattern.type !== "ObjectPattern" && pattern.type !== "ArrayPattern") { - this.raise(pattern.start, TSErrors.UnsupportedSignatureParameterKind, pattern.type); - } - - return pattern; - }); - } - - tsParseTypeMemberSemicolon() { - if (!this.eat(types.comma)) { - this.semicolon(); - } - } - - tsParseSignatureMember(kind, node) { - this.tsFillSignature(types.colon, node); - this.tsParseTypeMemberSemicolon(); - return this.finishNode(node, kind); - } - - tsIsUnambiguouslyIndexSignature() { - this.next(); - return this.eat(types.name) && this.match(types.colon); - } - - tsTryParseIndexSignature(node) { - if (!(this.match(types.bracketL) && this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this)))) { - return undefined; - } - - this.expect(types.bracketL); - const id = this.parseIdentifier(); - id.typeAnnotation = this.tsParseTypeAnnotation(); - this.resetEndLocation(id); - this.expect(types.bracketR); - node.parameters = [id]; - const type = this.tsTryParseTypeAnnotation(); - if (type) node.typeAnnotation = type; - this.tsParseTypeMemberSemicolon(); - return this.finishNode(node, "TSIndexSignature"); - } - - tsParsePropertyOrMethodSignature(node, readonly) { - if (this.eat(types.question)) node.optional = true; - const nodeAny = node; - - if (!readonly && (this.match(types.parenL) || this.isRelational("<"))) { - const method = nodeAny; - this.tsFillSignature(types.colon, method); - this.tsParseTypeMemberSemicolon(); - return this.finishNode(method, "TSMethodSignature"); - } else { - const property = nodeAny; - if (readonly) property.readonly = true; - const type = this.tsTryParseTypeAnnotation(); - if (type) property.typeAnnotation = type; - this.tsParseTypeMemberSemicolon(); - return this.finishNode(property, "TSPropertySignature"); - } - } - - tsParseTypeMember() { - const node = this.startNode(); - - if (this.match(types.parenL) || this.isRelational("<")) { - return this.tsParseSignatureMember("TSCallSignatureDeclaration", node); - } - - if (this.match(types._new)) { - const id = this.startNode(); - this.next(); - - if (this.match(types.parenL) || this.isRelational("<")) { - return this.tsParseSignatureMember("TSConstructSignatureDeclaration", node); - } else { - node.key = this.createIdentifier(id, "new"); - return this.tsParsePropertyOrMethodSignature(node, false); - } - } - - const readonly = !!this.tsParseModifier(["readonly"]); - const idx = this.tsTryParseIndexSignature(node); - - if (idx) { - if (readonly) node.readonly = true; - return idx; - } - - this.parsePropertyName(node, false); - return this.tsParsePropertyOrMethodSignature(node, readonly); - } - - tsParseTypeLiteral() { - const node = this.startNode(); - node.members = this.tsParseObjectTypeMembers(); - return this.finishNode(node, "TSTypeLiteral"); - } - - tsParseObjectTypeMembers() { - this.expect(types.braceL); - const members = this.tsParseList("TypeMembers", this.tsParseTypeMember.bind(this)); - this.expect(types.braceR); - return members; - } - - tsIsStartOfMappedType() { - this.next(); - - if (this.eat(types.plusMin)) { - return this.isContextual("readonly"); - } - - if (this.isContextual("readonly")) { - this.next(); - } - - if (!this.match(types.bracketL)) { - return false; - } - - this.next(); - - if (!this.tsIsIdentifier()) { - return false; - } - - this.next(); - return this.match(types._in); - } - - tsParseMappedTypeParameter() { - const node = this.startNode(); - node.name = this.parseIdentifierName(node.start); - node.constraint = this.tsExpectThenParseType(types._in); - return this.finishNode(node, "TSTypeParameter"); - } - - tsParseMappedType() { - const node = this.startNode(); - this.expect(types.braceL); - - if (this.match(types.plusMin)) { - node.readonly = this.state.value; - this.next(); - this.expectContextual("readonly"); - } else if (this.eatContextual("readonly")) { - node.readonly = true; - } - - this.expect(types.bracketL); - node.typeParameter = this.tsParseMappedTypeParameter(); - this.expect(types.bracketR); - - if (this.match(types.plusMin)) { - node.optional = this.state.value; - this.next(); - this.expect(types.question); - } else if (this.eat(types.question)) { - node.optional = true; - } - - node.typeAnnotation = this.tsTryParseType(); - this.semicolon(); - this.expect(types.braceR); - return this.finishNode(node, "TSMappedType"); - } - - tsParseTupleType() { - const node = this.startNode(); - node.elementTypes = this.tsParseBracketedList("TupleElementTypes", this.tsParseTupleElementType.bind(this), true, false); - let seenOptionalElement = false; - node.elementTypes.forEach(elementNode => { - if (elementNode.type === "TSOptionalType") { - seenOptionalElement = true; - } else if (seenOptionalElement && elementNode.type !== "TSRestType") { - this.raise(elementNode.start, TSErrors.OptionalTypeBeforeRequired); - } - }); - return this.finishNode(node, "TSTupleType"); - } - - tsParseTupleElementType() { - if (this.match(types.ellipsis)) { - const restNode = this.startNode(); - this.next(); - restNode.typeAnnotation = this.tsParseType(); - - if (this.match(types.comma) && this.lookaheadCharCode() !== 93) { - this.raiseRestNotLast(this.state.start); - } - - return this.finishNode(restNode, "TSRestType"); - } - - const type = this.tsParseType(); - - if (this.eat(types.question)) { - const optionalTypeNode = this.startNodeAtNode(type); - optionalTypeNode.typeAnnotation = type; - return this.finishNode(optionalTypeNode, "TSOptionalType"); - } - - return type; - } - - tsParseParenthesizedType() { - const node = this.startNode(); - this.expect(types.parenL); - node.typeAnnotation = this.tsParseType(); - this.expect(types.parenR); - return this.finishNode(node, "TSParenthesizedType"); - } - - tsParseFunctionOrConstructorType(type) { - const node = this.startNode(); - - if (type === "TSConstructorType") { - this.expect(types._new); - } - - this.tsFillSignature(types.arrow, node); - return this.finishNode(node, type); - } - - tsParseLiteralTypeNode() { - const node = this.startNode(); - - node.literal = (() => { - switch (this.state.type) { - case types.num: - case types.string: - case types._true: - case types._false: - return this.parseExprAtom(); - - default: - throw this.unexpected(); - } - })(); - - return this.finishNode(node, "TSLiteralType"); - } - - tsParseTemplateLiteralType() { - const node = this.startNode(); - const templateNode = this.parseTemplate(false); - - if (templateNode.expressions.length > 0) { - this.raise(templateNode.expressions[0].start, TSErrors.TemplateTypeHasSubstitution); - } - - node.literal = templateNode; - return this.finishNode(node, "TSLiteralType"); - } - - tsParseThisTypeOrThisTypePredicate() { - const thisKeyword = this.tsParseThisTypeNode(); - - if (this.isContextual("is") && !this.hasPrecedingLineBreak()) { - return this.tsParseThisTypePredicate(thisKeyword); - } else { - return thisKeyword; - } - } - - tsParseNonArrayType() { - switch (this.state.type) { - case types.name: - case types._void: - case types._null: - { - const type = this.match(types._void) ? "TSVoidKeyword" : this.match(types._null) ? "TSNullKeyword" : keywordTypeFromName(this.state.value); - - if (type !== undefined && this.lookaheadCharCode() !== 46) { - const node = this.startNode(); - this.next(); - return this.finishNode(node, type); - } - - return this.tsParseTypeReference(); - } - - case types.string: - case types.num: - case types._true: - case types._false: - return this.tsParseLiteralTypeNode(); - - case types.plusMin: - if (this.state.value === "-") { - const node = this.startNode(); - - if (this.lookahead().type !== types.num) { - throw this.unexpected(); - } - - node.literal = this.parseMaybeUnary(); - return this.finishNode(node, "TSLiteralType"); - } - - break; - - case types._this: - return this.tsParseThisTypeOrThisTypePredicate(); - - case types._typeof: - return this.tsParseTypeQuery(); - - case types._import: - return this.tsParseImportType(); - - case types.braceL: - return this.tsLookAhead(this.tsIsStartOfMappedType.bind(this)) ? this.tsParseMappedType() : this.tsParseTypeLiteral(); - - case types.bracketL: - return this.tsParseTupleType(); - - case types.parenL: - return this.tsParseParenthesizedType(); - - case types.backQuote: - return this.tsParseTemplateLiteralType(); - } - - throw this.unexpected(); - } - - tsParseArrayTypeOrHigher() { - let type = this.tsParseNonArrayType(); - - while (!this.hasPrecedingLineBreak() && this.eat(types.bracketL)) { - if (this.match(types.bracketR)) { - const node = this.startNodeAtNode(type); - node.elementType = type; - this.expect(types.bracketR); - type = this.finishNode(node, "TSArrayType"); - } else { - const node = this.startNodeAtNode(type); - node.objectType = type; - node.indexType = this.tsParseType(); - this.expect(types.bracketR); - type = this.finishNode(node, "TSIndexedAccessType"); - } - } - - return type; - } - - tsParseTypeOperator(operator) { - const node = this.startNode(); - this.expectContextual(operator); - node.operator = operator; - node.typeAnnotation = this.tsParseTypeOperatorOrHigher(); - - if (operator === "readonly") { - this.tsCheckTypeAnnotationForReadOnly(node); - } - - return this.finishNode(node, "TSTypeOperator"); - } - - tsCheckTypeAnnotationForReadOnly(node) { - switch (node.typeAnnotation.type) { - case "TSTupleType": - case "TSArrayType": - return; - - default: - this.raise(node.start, TSErrors.UnexpectedReadonly); - } - } - - tsParseInferType() { - const node = this.startNode(); - this.expectContextual("infer"); - const typeParameter = this.startNode(); - typeParameter.name = this.parseIdentifierName(typeParameter.start); - node.typeParameter = this.finishNode(typeParameter, "TSTypeParameter"); - return this.finishNode(node, "TSInferType"); - } - - tsParseTypeOperatorOrHigher() { - const operator = ["keyof", "unique", "readonly"].find(kw => this.isContextual(kw)); - return operator ? this.tsParseTypeOperator(operator) : this.isContextual("infer") ? this.tsParseInferType() : this.tsParseArrayTypeOrHigher(); - } - - tsParseUnionOrIntersectionType(kind, parseConstituentType, operator) { - this.eat(operator); - let type = parseConstituentType(); - - if (this.match(operator)) { - const types = [type]; - - while (this.eat(operator)) { - types.push(parseConstituentType()); - } - - const node = this.startNodeAtNode(type); - node.types = types; - type = this.finishNode(node, kind); - } - - return type; - } - - tsParseIntersectionTypeOrHigher() { - return this.tsParseUnionOrIntersectionType("TSIntersectionType", this.tsParseTypeOperatorOrHigher.bind(this), types.bitwiseAND); - } - - tsParseUnionTypeOrHigher() { - return this.tsParseUnionOrIntersectionType("TSUnionType", this.tsParseIntersectionTypeOrHigher.bind(this), types.bitwiseOR); - } - - tsIsStartOfFunctionType() { - if (this.isRelational("<")) { - return true; - } - - return this.match(types.parenL) && this.tsLookAhead(this.tsIsUnambiguouslyStartOfFunctionType.bind(this)); - } - - tsSkipParameterStart() { - if (this.match(types.name) || this.match(types._this)) { - this.next(); - return true; - } - - if (this.match(types.braceL)) { - let braceStackCounter = 1; - this.next(); - - while (braceStackCounter > 0) { - if (this.match(types.braceL)) { - ++braceStackCounter; - } else if (this.match(types.braceR)) { - --braceStackCounter; - } - - this.next(); - } - - return true; - } - - if (this.match(types.bracketL)) { - let braceStackCounter = 1; - this.next(); - - while (braceStackCounter > 0) { - if (this.match(types.bracketL)) { - ++braceStackCounter; - } else if (this.match(types.bracketR)) { - --braceStackCounter; - } - - this.next(); - } - - return true; - } - - return false; - } - - tsIsUnambiguouslyStartOfFunctionType() { - this.next(); - - if (this.match(types.parenR) || this.match(types.ellipsis)) { - return true; - } - - if (this.tsSkipParameterStart()) { - if (this.match(types.colon) || this.match(types.comma) || this.match(types.question) || this.match(types.eq)) { - return true; - } - - if (this.match(types.parenR)) { - this.next(); - - if (this.match(types.arrow)) { - return true; - } - } - } - - return false; - } - - tsParseTypeOrTypePredicateAnnotation(returnToken) { - return this.tsInType(() => { - const t = this.startNode(); - this.expect(returnToken); - const asserts = this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this)); - - if (asserts && this.match(types._this)) { - let thisTypePredicate = this.tsParseThisTypeOrThisTypePredicate(); - - if (thisTypePredicate.type === "TSThisType") { - const node = this.startNodeAtNode(t); - node.parameterName = thisTypePredicate; - node.asserts = true; - thisTypePredicate = this.finishNode(node, "TSTypePredicate"); - } else { - thisTypePredicate.asserts = true; - } - - t.typeAnnotation = thisTypePredicate; - return this.finishNode(t, "TSTypeAnnotation"); - } - - const typePredicateVariable = this.tsIsIdentifier() && this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this)); - - if (!typePredicateVariable) { - if (!asserts) { - return this.tsParseTypeAnnotation(false, t); - } - - const node = this.startNodeAtNode(t); - node.parameterName = this.parseIdentifier(); - node.asserts = asserts; - t.typeAnnotation = this.finishNode(node, "TSTypePredicate"); - return this.finishNode(t, "TSTypeAnnotation"); - } - - const type = this.tsParseTypeAnnotation(false); - const node = this.startNodeAtNode(t); - node.parameterName = typePredicateVariable; - node.typeAnnotation = type; - node.asserts = asserts; - t.typeAnnotation = this.finishNode(node, "TSTypePredicate"); - return this.finishNode(t, "TSTypeAnnotation"); - }); - } - - tsTryParseTypeOrTypePredicateAnnotation() { - return this.match(types.colon) ? this.tsParseTypeOrTypePredicateAnnotation(types.colon) : undefined; - } - - tsTryParseTypeAnnotation() { - return this.match(types.colon) ? this.tsParseTypeAnnotation() : undefined; - } - - tsTryParseType() { - return this.tsEatThenParseType(types.colon); - } - - tsParseTypePredicatePrefix() { - const id = this.parseIdentifier(); - - if (this.isContextual("is") && !this.hasPrecedingLineBreak()) { - this.next(); - return id; - } - } - - tsParseTypePredicateAsserts() { - if (!this.match(types.name) || this.state.value !== "asserts" || this.hasPrecedingLineBreak()) { - return false; - } - - const containsEsc = this.state.containsEsc; - this.next(); - - if (!this.match(types.name) && !this.match(types._this)) { - return false; - } - - if (containsEsc) { - this.raise(this.state.lastTokStart, Errors.InvalidEscapedReservedWord, "asserts"); - } - - return true; - } - - tsParseTypeAnnotation(eatColon = true, t = this.startNode()) { - this.tsInType(() => { - if (eatColon) this.expect(types.colon); - t.typeAnnotation = this.tsParseType(); - }); - return this.finishNode(t, "TSTypeAnnotation"); - } - - tsParseType() { - assert(this.state.inType); - const type = this.tsParseNonConditionalType(); - - if (this.hasPrecedingLineBreak() || !this.eat(types._extends)) { - return type; - } - - const node = this.startNodeAtNode(type); - node.checkType = type; - node.extendsType = this.tsParseNonConditionalType(); - this.expect(types.question); - node.trueType = this.tsParseType(); - this.expect(types.colon); - node.falseType = this.tsParseType(); - return this.finishNode(node, "TSConditionalType"); - } - - tsParseNonConditionalType() { - if (this.tsIsStartOfFunctionType()) { - return this.tsParseFunctionOrConstructorType("TSFunctionType"); - } - - if (this.match(types._new)) { - return this.tsParseFunctionOrConstructorType("TSConstructorType"); - } - - return this.tsParseUnionTypeOrHigher(); - } - - tsParseTypeAssertion() { - const node = this.startNode(); - - const _const = this.tsTryNextParseConstantContext(); - - node.typeAnnotation = _const || this.tsNextThenParseType(); - this.expectRelational(">"); - node.expression = this.parseMaybeUnary(); - return this.finishNode(node, "TSTypeAssertion"); - } - - tsParseHeritageClause(descriptor) { - const originalStart = this.state.start; - const delimitedList = this.tsParseDelimitedList("HeritageClauseElement", this.tsParseExpressionWithTypeArguments.bind(this)); - - if (!delimitedList.length) { - this.raise(originalStart, TSErrors.EmptyHeritageClauseType, descriptor); - } - - return delimitedList; - } - - tsParseExpressionWithTypeArguments() { - const node = this.startNode(); - node.expression = this.tsParseEntityName(false); - - if (this.isRelational("<")) { - node.typeParameters = this.tsParseTypeArguments(); - } - - return this.finishNode(node, "TSExpressionWithTypeArguments"); - } - - tsParseInterfaceDeclaration(node) { - node.id = this.parseIdentifier(); - this.checkLVal(node.id, BIND_TS_INTERFACE, undefined, "typescript interface declaration"); - node.typeParameters = this.tsTryParseTypeParameters(); - - if (this.eat(types._extends)) { - node.extends = this.tsParseHeritageClause("extends"); - } - - const body = this.startNode(); - body.body = this.tsInType(this.tsParseObjectTypeMembers.bind(this)); - node.body = this.finishNode(body, "TSInterfaceBody"); - return this.finishNode(node, "TSInterfaceDeclaration"); - } - - tsParseTypeAliasDeclaration(node) { - node.id = this.parseIdentifier(); - this.checkLVal(node.id, BIND_TS_TYPE, undefined, "typescript type alias"); - node.typeParameters = this.tsTryParseTypeParameters(); - node.typeAnnotation = this.tsExpectThenParseType(types.eq); - this.semicolon(); - return this.finishNode(node, "TSTypeAliasDeclaration"); - } - - tsInNoContext(cb) { - const oldContext = this.state.context; - this.state.context = [oldContext[0]]; - - try { - return cb(); - } finally { - this.state.context = oldContext; - } - } - - tsInType(cb) { - const oldInType = this.state.inType; - this.state.inType = true; - - try { - return cb(); - } finally { - this.state.inType = oldInType; - } - } - - tsEatThenParseType(token) { - return !this.match(token) ? undefined : this.tsNextThenParseType(); - } - - tsExpectThenParseType(token) { - return this.tsDoThenParseType(() => this.expect(token)); - } - - tsNextThenParseType() { - return this.tsDoThenParseType(() => this.next()); - } - - tsDoThenParseType(cb) { - return this.tsInType(() => { - cb(); - return this.tsParseType(); - }); - } - - tsParseEnumMember() { - const node = this.startNode(); - node.id = this.match(types.string) ? this.parseExprAtom() : this.parseIdentifier(true); - - if (this.eat(types.eq)) { - node.initializer = this.parseMaybeAssign(); - } - - return this.finishNode(node, "TSEnumMember"); - } - - tsParseEnumDeclaration(node, isConst) { - if (isConst) node.const = true; - node.id = this.parseIdentifier(); - this.checkLVal(node.id, isConst ? BIND_TS_CONST_ENUM : BIND_TS_ENUM, undefined, "typescript enum declaration"); - this.expect(types.braceL); - node.members = this.tsParseDelimitedList("EnumMembers", this.tsParseEnumMember.bind(this)); - this.expect(types.braceR); - return this.finishNode(node, "TSEnumDeclaration"); - } - - tsParseModuleBlock() { - const node = this.startNode(); - this.scope.enter(SCOPE_OTHER); - this.expect(types.braceL); - this.parseBlockOrModuleBlockBody(node.body = [], undefined, true, types.braceR); - this.scope.exit(); - return this.finishNode(node, "TSModuleBlock"); - } - - tsParseModuleOrNamespaceDeclaration(node, nested = false) { - node.id = this.parseIdentifier(); - - if (!nested) { - this.checkLVal(node.id, BIND_TS_NAMESPACE, null, "module or namespace declaration"); - } - - if (this.eat(types.dot)) { - const inner = this.startNode(); - this.tsParseModuleOrNamespaceDeclaration(inner, true); - node.body = inner; - } else { - this.scope.enter(SCOPE_TS_MODULE); - this.prodParam.enter(PARAM); - node.body = this.tsParseModuleBlock(); - this.prodParam.exit(); - this.scope.exit(); - } - - return this.finishNode(node, "TSModuleDeclaration"); - } - - tsParseAmbientExternalModuleDeclaration(node) { - if (this.isContextual("global")) { - node.global = true; - node.id = this.parseIdentifier(); - } else if (this.match(types.string)) { - node.id = this.parseExprAtom(); - } else { - this.unexpected(); - } - - if (this.match(types.braceL)) { - this.scope.enter(SCOPE_TS_MODULE); - this.prodParam.enter(PARAM); - node.body = this.tsParseModuleBlock(); - this.prodParam.exit(); - this.scope.exit(); - } else { - this.semicolon(); - } - - return this.finishNode(node, "TSModuleDeclaration"); - } - - tsParseImportEqualsDeclaration(node, isExport) { - node.isExport = isExport || false; - node.id = this.parseIdentifier(); - this.checkLVal(node.id, BIND_LEXICAL, undefined, "import equals declaration"); - this.expect(types.eq); - node.moduleReference = this.tsParseModuleReference(); - this.semicolon(); - return this.finishNode(node, "TSImportEqualsDeclaration"); - } - - tsIsExternalModuleReference() { - return this.isContextual("require") && this.lookaheadCharCode() === 40; - } - - tsParseModuleReference() { - return this.tsIsExternalModuleReference() ? this.tsParseExternalModuleReference() : this.tsParseEntityName(false); - } - - tsParseExternalModuleReference() { - const node = this.startNode(); - this.expectContextual("require"); - this.expect(types.parenL); - - if (!this.match(types.string)) { - throw this.unexpected(); - } - - node.expression = this.parseExprAtom(); - this.expect(types.parenR); - return this.finishNode(node, "TSExternalModuleReference"); - } - - tsLookAhead(f) { - const state = this.state.clone(); - const res = f(); - this.state = state; - return res; - } - - tsTryParseAndCatch(f) { - const result = this.tryParse(abort => f() || abort()); - if (result.aborted || !result.node) return undefined; - if (result.error) this.state = result.failState; - return result.node; - } - - tsTryParse(f) { - const state = this.state.clone(); - const result = f(); - - if (result !== undefined && result !== false) { - return result; - } else { - this.state = state; - return undefined; - } - } - - tsTryParseDeclare(nany) { - if (this.isLineTerminator()) { - return; - } - - let starttype = this.state.type; - let kind; - - if (this.isContextual("let")) { - starttype = types._var; - kind = "let"; - } - - switch (starttype) { - case types._function: - return this.parseFunctionStatement(nany, false, true); - - case types._class: - nany.declare = true; - return this.parseClass(nany, true, false); - - case types._const: - if (this.match(types._const) && this.isLookaheadContextual("enum")) { - this.expect(types._const); - this.expectContextual("enum"); - return this.tsParseEnumDeclaration(nany, true); - } - - case types._var: - kind = kind || this.state.value; - return this.parseVarStatement(nany, kind); - - case types.name: - { - const value = this.state.value; - - if (value === "global") { - return this.tsParseAmbientExternalModuleDeclaration(nany); - } else { - return this.tsParseDeclaration(nany, value, true); - } - } - } - } - - tsTryParseExportDeclaration() { - return this.tsParseDeclaration(this.startNode(), this.state.value, true); - } - - tsParseExpressionStatement(node, expr) { - switch (expr.name) { - case "declare": - { - const declaration = this.tsTryParseDeclare(node); - - if (declaration) { - declaration.declare = true; - return declaration; - } - - break; - } - - case "global": - if (this.match(types.braceL)) { - this.scope.enter(SCOPE_TS_MODULE); - this.prodParam.enter(PARAM); - const mod = node; - mod.global = true; - mod.id = expr; - mod.body = this.tsParseModuleBlock(); - this.scope.exit(); - this.prodParam.exit(); - return this.finishNode(mod, "TSModuleDeclaration"); - } - - break; - - default: - return this.tsParseDeclaration(node, expr.name, false); - } - } - - tsParseDeclaration(node, value, next) { - switch (value) { - case "abstract": - if (this.tsCheckLineTerminatorAndMatch(types._class, next)) { - const cls = node; - cls.abstract = true; - - if (next) { - this.next(); - - if (!this.match(types._class)) { - this.unexpected(null, types._class); - } - } - - return this.parseClass(cls, true, false); - } - - break; - - case "enum": - if (next || this.match(types.name)) { - if (next) this.next(); - return this.tsParseEnumDeclaration(node, false); - } - - break; - - case "interface": - if (this.tsCheckLineTerminatorAndMatch(types.name, next)) { - if (next) this.next(); - return this.tsParseInterfaceDeclaration(node); - } - - break; - - case "module": - if (next) this.next(); - - if (this.match(types.string)) { - return this.tsParseAmbientExternalModuleDeclaration(node); - } else if (this.tsCheckLineTerminatorAndMatch(types.name, next)) { - return this.tsParseModuleOrNamespaceDeclaration(node); - } - - break; - - case "namespace": - if (this.tsCheckLineTerminatorAndMatch(types.name, next)) { - if (next) this.next(); - return this.tsParseModuleOrNamespaceDeclaration(node); - } - - break; - - case "type": - if (this.tsCheckLineTerminatorAndMatch(types.name, next)) { - if (next) this.next(); - return this.tsParseTypeAliasDeclaration(node); - } - - break; - } - } - - tsCheckLineTerminatorAndMatch(tokenType, next) { - return (next || this.match(tokenType)) && !this.isLineTerminator(); - } - - tsTryParseGenericAsyncArrowFunction(startPos, startLoc) { - if (!this.isRelational("<")) { - return undefined; - } - - const oldMaybeInArrowParameters = this.state.maybeInArrowParameters; - const oldYieldPos = this.state.yieldPos; - const oldAwaitPos = this.state.awaitPos; - this.state.maybeInArrowParameters = true; - this.state.yieldPos = -1; - this.state.awaitPos = -1; - const res = this.tsTryParseAndCatch(() => { - const node = this.startNodeAt(startPos, startLoc); - node.typeParameters = this.tsParseTypeParameters(); - super.parseFunctionParams(node); - node.returnType = this.tsTryParseTypeOrTypePredicateAnnotation(); - this.expect(types.arrow); - return node; - }); - this.state.maybeInArrowParameters = oldMaybeInArrowParameters; - this.state.yieldPos = oldYieldPos; - this.state.awaitPos = oldAwaitPos; - - if (!res) { - return undefined; - } - - return this.parseArrowExpression(res, null, true); - } - - tsParseTypeArguments() { - const node = this.startNode(); - node.params = this.tsInType(() => this.tsInNoContext(() => { - this.expectRelational("<"); - return this.tsParseDelimitedList("TypeParametersOrArguments", this.tsParseType.bind(this)); - })); - this.state.exprAllowed = false; - this.expectRelational(">"); - return this.finishNode(node, "TSTypeParameterInstantiation"); - } - - tsIsDeclarationStart() { - if (this.match(types.name)) { - switch (this.state.value) { - case "abstract": - case "declare": - case "enum": - case "interface": - case "module": - case "namespace": - case "type": - return true; - } - } - - return false; - } - - isExportDefaultSpecifier() { - if (this.tsIsDeclarationStart()) return false; - return super.isExportDefaultSpecifier(); - } - - parseAssignableListItem(allowModifiers, decorators) { - const startPos = this.state.start; - const startLoc = this.state.startLoc; - let accessibility; - let readonly = false; - - if (allowModifiers) { - accessibility = this.parseAccessModifier(); - readonly = !!this.tsParseModifier(["readonly"]); - } - - const left = this.parseMaybeDefault(); - this.parseAssignableListItemTypes(left); - const elt = this.parseMaybeDefault(left.start, left.loc.start, left); - - if (accessibility || readonly) { - const pp = this.startNodeAt(startPos, startLoc); - - if (decorators.length) { - pp.decorators = decorators; - } - - if (accessibility) pp.accessibility = accessibility; - if (readonly) pp.readonly = readonly; - - if (elt.type !== "Identifier" && elt.type !== "AssignmentPattern") { - this.raise(pp.start, TSErrors.UnsupportedParameterPropertyKind); - } - - pp.parameter = elt; - return this.finishNode(pp, "TSParameterProperty"); - } - - if (decorators.length) { - left.decorators = decorators; - } - - return elt; - } - - parseFunctionBodyAndFinish(node, type, isMethod = false) { - if (this.match(types.colon)) { - node.returnType = this.tsParseTypeOrTypePredicateAnnotation(types.colon); - } - - const bodilessType = type === "FunctionDeclaration" ? "TSDeclareFunction" : type === "ClassMethod" ? "TSDeclareMethod" : undefined; - - if (bodilessType && !this.match(types.braceL) && this.isLineTerminator()) { - this.finishNode(node, bodilessType); - return; - } - - super.parseFunctionBodyAndFinish(node, type, isMethod); - } - - registerFunctionStatementId(node) { - if (!node.body && node.id) { - this.checkLVal(node.id, BIND_TS_AMBIENT, null, "function name"); - } else { - super.registerFunctionStatementId(...arguments); - } - } - - parseSubscript(base, startPos, startLoc, noCalls, state) { - if (!this.hasPrecedingLineBreak() && this.match(types.bang)) { - this.state.exprAllowed = false; - this.next(); - const nonNullExpression = this.startNodeAt(startPos, startLoc); - nonNullExpression.expression = base; - return this.finishNode(nonNullExpression, "TSNonNullExpression"); - } - - if (this.isRelational("<")) { - const result = this.tsTryParseAndCatch(() => { - if (!noCalls && this.atPossibleAsyncArrow(base)) { - const asyncArrowFn = this.tsTryParseGenericAsyncArrowFunction(startPos, startLoc); - - if (asyncArrowFn) { - return asyncArrowFn; - } - } - - const node = this.startNodeAt(startPos, startLoc); - node.callee = base; - const typeArguments = this.tsParseTypeArguments(); - - if (typeArguments) { - if (!noCalls && this.eat(types.parenL)) { - node.arguments = this.parseCallExpressionArguments(types.parenR, false); - node.typeParameters = typeArguments; - return this.finishCallExpression(node, state.optionalChainMember); - } else if (this.match(types.backQuote)) { - return this.parseTaggedTemplateExpression(startPos, startLoc, base, state, typeArguments); - } - } - - this.unexpected(); - }); - if (result) return result; - } - - return super.parseSubscript(base, startPos, startLoc, noCalls, state); - } - - parseNewArguments(node) { - if (this.isRelational("<")) { - const typeParameters = this.tsTryParseAndCatch(() => { - const args = this.tsParseTypeArguments(); - if (!this.match(types.parenL)) this.unexpected(); - return args; - }); - - if (typeParameters) { - node.typeParameters = typeParameters; - } - } - - super.parseNewArguments(node); - } - - parseExprOp(left, leftStartPos, leftStartLoc, minPrec, noIn) { - if (nonNull(types._in.binop) > minPrec && !this.hasPrecedingLineBreak() && this.isContextual("as")) { - const node = this.startNodeAt(leftStartPos, leftStartLoc); - node.expression = left; - - const _const = this.tsTryNextParseConstantContext(); - - if (_const) { - node.typeAnnotation = _const; - } else { - node.typeAnnotation = this.tsNextThenParseType(); - } - - this.finishNode(node, "TSAsExpression"); - return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn); - } - - return super.parseExprOp(left, leftStartPos, leftStartLoc, minPrec, noIn); - } - - checkReservedWord(word, startLoc, checkKeywords, isBinding) {} - - checkDuplicateExports() {} - - parseImport(node) { - if (this.match(types.name) || this.match(types.star) || this.match(types.braceL)) { - const ahead = this.lookahead(); - - if (this.match(types.name) && ahead.type === types.eq) { - return this.tsParseImportEqualsDeclaration(node); - } - - if (this.isContextual("type") && ahead.type !== types.comma && !(ahead.type === types.name && ahead.value === "from")) { - node.importKind = "type"; - this.next(); - } else { - node.importKind = "value"; - } - } - - const importNode = super.parseImport(node); - - if (importNode.importKind === "type" && importNode.specifiers.length > 1 && importNode.specifiers[0].type === "ImportDefaultSpecifier") { - this.raise(importNode.start, "A type-only import can specify a default import or named bindings, but not both."); - } - - return importNode; - } - - parseExport(node) { - if (this.match(types._import)) { - this.expect(types._import); - return this.tsParseImportEqualsDeclaration(node, true); - } else if (this.eat(types.eq)) { - const assign = node; - assign.expression = this.parseExpression(); - this.semicolon(); - return this.finishNode(assign, "TSExportAssignment"); - } else if (this.eatContextual("as")) { - const decl = node; - this.expectContextual("namespace"); - decl.id = this.parseIdentifier(); - this.semicolon(); - return this.finishNode(decl, "TSNamespaceExportDeclaration"); - } else { - if (this.isContextual("type") && this.lookahead().type === types.braceL) { - this.next(); - node.exportKind = "type"; - } else { - node.exportKind = "value"; - } - - return super.parseExport(node); - } - } - - isAbstractClass() { - return this.isContextual("abstract") && this.lookahead().type === types._class; - } - - parseExportDefaultExpression() { - if (this.isAbstractClass()) { - const cls = this.startNode(); - this.next(); - this.parseClass(cls, true, true); - cls.abstract = true; - return cls; - } - - if (this.state.value === "interface") { - const result = this.tsParseDeclaration(this.startNode(), this.state.value, true); - if (result) return result; - } - - return super.parseExportDefaultExpression(); - } - - parseStatementContent(context, topLevel) { - if (this.state.type === types._const) { - const ahead = this.lookahead(); - - if (ahead.type === types.name && ahead.value === "enum") { - const node = this.startNode(); - this.expect(types._const); - this.expectContextual("enum"); - return this.tsParseEnumDeclaration(node, true); - } - } - - return super.parseStatementContent(context, topLevel); - } - - parseAccessModifier() { - return this.tsParseModifier(["public", "protected", "private"]); - } - - parseClassMember(classBody, member, state, constructorAllowsSuper) { - this.tsParseModifiers(member, ["declare"]); - const accessibility = this.parseAccessModifier(); - if (accessibility) member.accessibility = accessibility; - this.tsParseModifiers(member, ["declare"]); - super.parseClassMember(classBody, member, state, constructorAllowsSuper); - } - - parseClassMemberWithIsStatic(classBody, member, state, isStatic, constructorAllowsSuper) { - this.tsParseModifiers(member, ["abstract", "readonly", "declare"]); - const idx = this.tsTryParseIndexSignature(member); - - if (idx) { - classBody.body.push(idx); - - if (member.abstract) { - this.raise(member.start, TSErrors.IndexSignatureHasAbstract); - } - - if (isStatic) { - this.raise(member.start, TSErrors.IndexSignatureHasStatic); - } - - if (member.accessibility) { - this.raise(member.start, TSErrors.IndexSignatureHasAccessibility, member.accessibility); - } - - return; - } - - super.parseClassMemberWithIsStatic(classBody, member, state, isStatic, constructorAllowsSuper); - } - - parsePostMemberNameModifiers(methodOrProp) { - const optional = this.eat(types.question); - if (optional) methodOrProp.optional = true; - - if (methodOrProp.readonly && this.match(types.parenL)) { - this.raise(methodOrProp.start, TSErrors.ClassMethodHasReadonly); - } - - if (methodOrProp.declare && this.match(types.parenL)) { - this.raise(methodOrProp.start, TSErrors.ClassMethodHasDeclare); - } - } - - parseExpressionStatement(node, expr) { - const decl = expr.type === "Identifier" ? this.tsParseExpressionStatement(node, expr) : undefined; - return decl || super.parseExpressionStatement(node, expr); - } - - shouldParseExportDeclaration() { - if (this.tsIsDeclarationStart()) return true; - return super.shouldParseExportDeclaration(); - } - - parseConditional(expr, noIn, startPos, startLoc, refNeedsArrowPos) { - if (!refNeedsArrowPos || !this.match(types.question)) { - return super.parseConditional(expr, noIn, startPos, startLoc, refNeedsArrowPos); - } - - const result = this.tryParse(() => super.parseConditional(expr, noIn, startPos, startLoc)); - - if (!result.node) { - refNeedsArrowPos.start = result.error.pos || this.state.start; - return expr; - } - - if (result.error) this.state = result.failState; - return result.node; - } - - parseParenItem(node, startPos, startLoc) { - node = super.parseParenItem(node, startPos, startLoc); - - if (this.eat(types.question)) { - node.optional = true; - this.resetEndLocation(node); - } - - if (this.match(types.colon)) { - const typeCastNode = this.startNodeAt(startPos, startLoc); - typeCastNode.expression = node; - typeCastNode.typeAnnotation = this.tsParseTypeAnnotation(); - return this.finishNode(typeCastNode, "TSTypeCastExpression"); - } - - return node; - } - - parseExportDeclaration(node) { - const startPos = this.state.start; - const startLoc = this.state.startLoc; - const isDeclare = this.eatContextual("declare"); - let declaration; - - if (this.match(types.name)) { - declaration = this.tsTryParseExportDeclaration(); - } - - if (!declaration) { - declaration = super.parseExportDeclaration(node); - } - - if (declaration && (declaration.type === "TSInterfaceDeclaration" || declaration.type === "TSTypeAliasDeclaration" || isDeclare)) { - node.exportKind = "type"; - } - - if (declaration && isDeclare) { - this.resetStartLocation(declaration, startPos, startLoc); - declaration.declare = true; - } - - return declaration; - } - - parseClassId(node, isStatement, optionalId) { - if ((!isStatement || optionalId) && this.isContextual("implements")) { - return; - } - - super.parseClassId(node, isStatement, optionalId, node.declare ? BIND_TS_AMBIENT : BIND_CLASS); - const typeParameters = this.tsTryParseTypeParameters(); - if (typeParameters) node.typeParameters = typeParameters; - } - - parseClassPropertyAnnotation(node) { - if (!node.optional && this.eat(types.bang)) { - node.definite = true; - } - - const type = this.tsTryParseTypeAnnotation(); - if (type) node.typeAnnotation = type; - } - - parseClassProperty(node) { - this.parseClassPropertyAnnotation(node); - - if (node.declare && this.match(types.equal)) { - this.raise(this.state.start, TSErrors.DeclareClassFieldHasInitializer); - } - - return super.parseClassProperty(node); - } - - parseClassPrivateProperty(node) { - if (node.abstract) { - this.raise(node.start, TSErrors.PrivateElementHasAbstract); - } - - if (node.accessibility) { - this.raise(node.start, TSErrors.PrivateElementHasAccessibility, node.accessibility); - } - - this.parseClassPropertyAnnotation(node); - return super.parseClassPrivateProperty(node); - } - - pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) { - const typeParameters = this.tsTryParseTypeParameters(); - if (typeParameters) method.typeParameters = typeParameters; - super.pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper); - } - - pushClassPrivateMethod(classBody, method, isGenerator, isAsync) { - const typeParameters = this.tsTryParseTypeParameters(); - if (typeParameters) method.typeParameters = typeParameters; - super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync); - } - - parseClassSuper(node) { - super.parseClassSuper(node); - - if (node.superClass && this.isRelational("<")) { - node.superTypeParameters = this.tsParseTypeArguments(); - } - - if (this.eatContextual("implements")) { - node.implements = this.tsParseHeritageClause("implements"); - } - } - - parseObjPropValue(prop, ...args) { - const typeParameters = this.tsTryParseTypeParameters(); - if (typeParameters) prop.typeParameters = typeParameters; - super.parseObjPropValue(prop, ...args); - } - - parseFunctionParams(node, allowModifiers) { - const typeParameters = this.tsTryParseTypeParameters(); - if (typeParameters) node.typeParameters = typeParameters; - super.parseFunctionParams(node, allowModifiers); - } - - parseVarId(decl, kind) { - super.parseVarId(decl, kind); - - if (decl.id.type === "Identifier" && this.eat(types.bang)) { - decl.definite = true; - } - - const type = this.tsTryParseTypeAnnotation(); - - if (type) { - decl.id.typeAnnotation = type; - this.resetEndLocation(decl.id); - } - } - - parseAsyncArrowFromCallExpression(node, call) { - if (this.match(types.colon)) { - node.returnType = this.tsParseTypeAnnotation(); - } - - return super.parseAsyncArrowFromCallExpression(node, call); - } - - parseMaybeAssign(...args) { - let state; - let jsx; - let typeCast; - - if (this.match(types.jsxTagStart)) { - state = this.state.clone(); - jsx = this.tryParse(() => super.parseMaybeAssign(...args), state); - if (!jsx.error) return jsx.node; - const { - context - } = this.state; - - if (context[context.length - 1] === types$1.j_oTag) { - context.length -= 2; - } else if (context[context.length - 1] === types$1.j_expr) { - context.length -= 1; - } - } - - if (!(jsx && jsx.error) && !this.isRelational("<")) { - return super.parseMaybeAssign(...args); - } - - let typeParameters; - state = state || this.state.clone(); - const arrow = this.tryParse(abort => { - typeParameters = this.tsParseTypeParameters(); - const expr = super.parseMaybeAssign(...args); - - if (expr.type !== "ArrowFunctionExpression" || expr.extra && expr.extra.parenthesized) { - abort(); - } - - if (typeParameters && typeParameters.params.length !== 0) { - this.resetStartLocationFromNode(expr, typeParameters); - } - - expr.typeParameters = typeParameters; - return expr; - }, state); - if (!arrow.error && !arrow.aborted) return arrow.node; - - if (!jsx) { - assert(!this.hasPlugin("jsx")); - typeCast = this.tryParse(() => super.parseMaybeAssign(...args), state); - if (!typeCast.error) return typeCast.node; - } - - if (jsx && jsx.node) { - this.state = jsx.failState; - return jsx.node; - } - - if (arrow.node) { - this.state = arrow.failState; - return arrow.node; - } - - if (typeCast && typeCast.node) { - this.state = typeCast.failState; - return typeCast.node; - } - - if (jsx && jsx.thrown) throw jsx.error; - if (arrow.thrown) throw arrow.error; - if (typeCast && typeCast.thrown) throw typeCast.error; - throw jsx && jsx.error || arrow.error || typeCast && typeCast.error; - } - - parseMaybeUnary(refExpressionErrors) { - if (!this.hasPlugin("jsx") && this.isRelational("<")) { - return this.tsParseTypeAssertion(); - } else { - return super.parseMaybeUnary(refExpressionErrors); - } - } - - parseArrow(node) { - if (this.match(types.colon)) { - const result = this.tryParse(abort => { - const returnType = this.tsParseTypeOrTypePredicateAnnotation(types.colon); - if (this.canInsertSemicolon() || !this.match(types.arrow)) abort(); - return returnType; - }); - if (result.aborted) return; - - if (!result.thrown) { - if (result.error) this.state = result.failState; - node.returnType = result.node; - } - } - - return super.parseArrow(node); - } - - parseAssignableListItemTypes(param) { - if (this.eat(types.question)) { - if (param.type !== "Identifier") { - this.raise(param.start, TSErrors.PatternIsOptional); - } - - param.optional = true; - } - - const type = this.tsTryParseTypeAnnotation(); - if (type) param.typeAnnotation = type; - this.resetEndLocation(param); - return param; - } - - toAssignable(node) { - switch (node.type) { - case "TSTypeCastExpression": - return super.toAssignable(this.typeCastToParameter(node)); - - case "TSParameterProperty": - return super.toAssignable(node); - - case "TSAsExpression": - case "TSNonNullExpression": - case "TSTypeAssertion": - node.expression = this.toAssignable(node.expression); - return node; - - default: - return super.toAssignable(node); - } - } - - checkLVal(expr, bindingType = BIND_NONE, checkClashes, contextDescription) { - switch (expr.type) { - case "TSTypeCastExpression": - return; - - case "TSParameterProperty": - this.checkLVal(expr.parameter, bindingType, checkClashes, "parameter property"); - return; - - case "TSAsExpression": - case "TSNonNullExpression": - case "TSTypeAssertion": - this.checkLVal(expr.expression, bindingType, checkClashes, contextDescription); - return; - - default: - super.checkLVal(expr, bindingType, checkClashes, contextDescription); - return; - } - } - - parseBindingAtom() { - switch (this.state.type) { - case types._this: - return this.parseIdentifier(true); - - default: - return super.parseBindingAtom(); - } - } - - parseMaybeDecoratorArguments(expr) { - if (this.isRelational("<")) { - const typeArguments = this.tsParseTypeArguments(); - - if (this.match(types.parenL)) { - const call = super.parseMaybeDecoratorArguments(expr); - call.typeParameters = typeArguments; - return call; - } - - this.unexpected(this.state.start, types.parenL); - } - - return super.parseMaybeDecoratorArguments(expr); - } - - isClassMethod() { - return this.isRelational("<") || super.isClassMethod(); - } - - isClassProperty() { - return this.match(types.bang) || this.match(types.colon) || super.isClassProperty(); - } - - parseMaybeDefault(...args) { - const node = super.parseMaybeDefault(...args); - - if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) { - this.raise(node.typeAnnotation.start, TSErrors.TypeAnnotationAfterAssign); - } - - return node; - } - - getTokenFromCode(code) { - if (this.state.inType && (code === 62 || code === 60)) { - return this.finishOp(types.relational, 1); - } else { - return super.getTokenFromCode(code); - } - } - - toAssignableList(exprList) { - for (let i = 0; i < exprList.length; i++) { - const expr = exprList[i]; - if (!expr) continue; - - switch (expr.type) { - case "TSTypeCastExpression": - exprList[i] = this.typeCastToParameter(expr); - break; - - case "TSAsExpression": - case "TSTypeAssertion": - if (!this.state.maybeInArrowParameters) { - exprList[i] = this.typeCastToParameter(expr); - } else { - this.raise(expr.start, TSErrors.UnexpectedTypeCastInParameter); - } - - break; - } - } - - return super.toAssignableList(...arguments); - } - - typeCastToParameter(node) { - node.expression.typeAnnotation = node.typeAnnotation; - this.resetEndLocation(node.expression, node.typeAnnotation.end, node.typeAnnotation.loc.end); - return node.expression; - } - - toReferencedList(exprList, isInParens) { - for (let i = 0; i < exprList.length; i++) { - const expr = exprList[i]; - - if (expr && expr.type === "TSTypeCastExpression") { - this.raise(expr.start, TSErrors.UnexpectedTypeAnnotation); - } - } - - return exprList; - } - - shouldParseArrow() { - return this.match(types.colon) || super.shouldParseArrow(); - } - - shouldParseAsyncArrow() { - return this.match(types.colon) || super.shouldParseAsyncArrow(); - } - - canHaveLeadingDecorator() { - return super.canHaveLeadingDecorator() || this.isAbstractClass(); - } - - jsxParseOpeningElementAfterName(node) { - if (this.isRelational("<")) { - const typeArguments = this.tsTryParseAndCatch(() => this.tsParseTypeArguments()); - if (typeArguments) node.typeParameters = typeArguments; - } - - return super.jsxParseOpeningElementAfterName(node); - } - - getGetterSetterExpectedParamCount(method) { - const baseCount = super.getGetterSetterExpectedParamCount(method); - const firstParam = method.params[0]; - const hasContextParam = firstParam && firstParam.type === "Identifier" && firstParam.name === "this"; - return hasContextParam ? baseCount + 1 : baseCount; - } - -}); - -types.placeholder = new TokenType("%%", { - startsExpr: true -}); -var placeholders = (superClass => class extends superClass { - parsePlaceholder(expectedNode) { - if (this.match(types.placeholder)) { - const node = this.startNode(); - this.next(); - this.assertNoSpace("Unexpected space in placeholder."); - node.name = super.parseIdentifier(true); - this.assertNoSpace("Unexpected space in placeholder."); - this.expect(types.placeholder); - return this.finishPlaceholder(node, expectedNode); - } - } - - finishPlaceholder(node, expectedNode) { - const isFinished = !!(node.expectedNode && node.type === "Placeholder"); - node.expectedNode = expectedNode; - return isFinished ? node : this.finishNode(node, "Placeholder"); - } - - getTokenFromCode(code) { - if (code === 37 && this.input.charCodeAt(this.state.pos + 1) === 37) { - return this.finishOp(types.placeholder, 2); - } - - return super.getTokenFromCode(...arguments); - } - - parseExprAtom() { - return this.parsePlaceholder("Expression") || super.parseExprAtom(...arguments); - } - - parseIdentifier() { - return this.parsePlaceholder("Identifier") || super.parseIdentifier(...arguments); - } - - checkReservedWord(word) { - if (word !== undefined) super.checkReservedWord(...arguments); - } - - parseBindingAtom() { - return this.parsePlaceholder("Pattern") || super.parseBindingAtom(...arguments); - } - - checkLVal(expr) { - if (expr.type !== "Placeholder") super.checkLVal(...arguments); - } - - toAssignable(node) { - if (node && node.type === "Placeholder" && node.expectedNode === "Expression") { - node.expectedNode = "Pattern"; - return node; - } - - return super.toAssignable(...arguments); - } - - verifyBreakContinue(node) { - if (node.label && node.label.type === "Placeholder") return; - super.verifyBreakContinue(...arguments); - } - - parseExpressionStatement(node, expr) { - if (expr.type !== "Placeholder" || expr.extra && expr.extra.parenthesized) { - return super.parseExpressionStatement(...arguments); - } - - if (this.match(types.colon)) { - const stmt = node; - stmt.label = this.finishPlaceholder(expr, "Identifier"); - this.next(); - stmt.body = this.parseStatement("label"); - return this.finishNode(stmt, "LabeledStatement"); - } - - this.semicolon(); - node.name = expr.name; - return this.finishPlaceholder(node, "Statement"); - } - - parseBlock() { - return this.parsePlaceholder("BlockStatement") || super.parseBlock(...arguments); - } - - parseFunctionId() { - return this.parsePlaceholder("Identifier") || super.parseFunctionId(...arguments); - } - - parseClass(node, isStatement, optionalId) { - const type = isStatement ? "ClassDeclaration" : "ClassExpression"; - this.next(); - this.takeDecorators(node); - const placeholder = this.parsePlaceholder("Identifier"); - - if (placeholder) { - if (this.match(types._extends) || this.match(types.placeholder) || this.match(types.braceL)) { - node.id = placeholder; - } else if (optionalId || !isStatement) { - node.id = null; - node.body = this.finishPlaceholder(placeholder, "ClassBody"); - return this.finishNode(node, type); - } else { - this.unexpected(null, "A class name is required"); - } - } else { - this.parseClassId(node, isStatement, optionalId); - } - - this.parseClassSuper(node); - node.body = this.parsePlaceholder("ClassBody") || this.parseClassBody(!!node.superClass); - return this.finishNode(node, type); - } - - parseExport(node) { - const placeholder = this.parsePlaceholder("Identifier"); - if (!placeholder) return super.parseExport(...arguments); - - if (!this.isContextual("from") && !this.match(types.comma)) { - node.specifiers = []; - node.source = null; - node.declaration = this.finishPlaceholder(placeholder, "Declaration"); - return this.finishNode(node, "ExportNamedDeclaration"); - } - - this.expectPlugin("exportDefaultFrom"); - const specifier = this.startNode(); - specifier.exported = placeholder; - node.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")]; - return super.parseExport(node); - } - - maybeParseExportDefaultSpecifier(node) { - if (node.specifiers && node.specifiers.length > 0) { - return true; - } - - return super.maybeParseExportDefaultSpecifier(...arguments); - } - - checkExport(node) { - const { - specifiers - } = node; - - if (specifiers && specifiers.length) { - node.specifiers = specifiers.filter(node => node.exported.type === "Placeholder"); - } - - super.checkExport(node); - node.specifiers = specifiers; - } - - parseImport(node) { - const placeholder = this.parsePlaceholder("Identifier"); - if (!placeholder) return super.parseImport(...arguments); - node.specifiers = []; - - if (!this.isContextual("from") && !this.match(types.comma)) { - node.source = this.finishPlaceholder(placeholder, "StringLiteral"); - this.semicolon(); - return this.finishNode(node, "ImportDeclaration"); - } - - const specifier = this.startNodeAtNode(placeholder); - specifier.local = placeholder; - this.finishNode(specifier, "ImportDefaultSpecifier"); - node.specifiers.push(specifier); - - if (this.eat(types.comma)) { - const hasStarImport = this.maybeParseStarImportSpecifier(node); - if (!hasStarImport) this.parseNamedImportSpecifiers(node); - } - - this.expectContextual("from"); - node.source = this.parseImportSource(); - this.semicolon(); - return this.finishNode(node, "ImportDeclaration"); - } - - parseImportSource() { - return this.parsePlaceholder("StringLiteral") || super.parseImportSource(...arguments); - } - -}); - -var v8intrinsic = (superClass => class extends superClass { - parseV8Intrinsic() { - if (this.match(types.modulo)) { - const v8IntrinsicStart = this.state.start; - const node = this.startNode(); - this.eat(types.modulo); - - if (this.match(types.name)) { - const name = this.parseIdentifierName(this.state.start); - const identifier = this.createIdentifier(node, name); - identifier.type = "V8IntrinsicIdentifier"; - - if (this.match(types.parenL)) { - return identifier; - } - } - - this.unexpected(v8IntrinsicStart); - } - } - - parseExprAtom() { - return this.parseV8Intrinsic() || super.parseExprAtom(...arguments); - } - -}); - -function hasPlugin(plugins, name) { - return plugins.some(plugin => { - if (Array.isArray(plugin)) { - return plugin[0] === name; - } else { - return plugin === name; - } - }); -} -function getPluginOption(plugins, name, option) { - const plugin = plugins.find(plugin => { - if (Array.isArray(plugin)) { - return plugin[0] === name; - } else { - return plugin === name; - } - }); - - if (plugin && Array.isArray(plugin)) { - return plugin[1][option]; - } - - return null; -} -const PIPELINE_PROPOSALS = ["minimal", "smart", "fsharp"]; -const RECORD_AND_TUPLE_SYNTAX_TYPES = ["hash", "bar"]; -function validatePlugins(plugins) { - if (hasPlugin(plugins, "decorators")) { - if (hasPlugin(plugins, "decorators-legacy")) { - throw new Error("Cannot use the decorators and decorators-legacy plugin together"); - } - - const decoratorsBeforeExport = getPluginOption(plugins, "decorators", "decoratorsBeforeExport"); - - if (decoratorsBeforeExport == null) { - throw new Error("The 'decorators' plugin requires a 'decoratorsBeforeExport' option," + " whose value must be a boolean. If you are migrating from" + " Babylon/Babel 6 or want to use the old decorators proposal, you" + " should use the 'decorators-legacy' plugin instead of 'decorators'."); - } else if (typeof decoratorsBeforeExport !== "boolean") { - throw new Error("'decoratorsBeforeExport' must be a boolean."); - } - } - - if (hasPlugin(plugins, "flow") && hasPlugin(plugins, "typescript")) { - throw new Error("Cannot combine flow and typescript plugins."); - } - - if (hasPlugin(plugins, "placeholders") && hasPlugin(plugins, "v8intrinsic")) { - throw new Error("Cannot combine placeholders and v8intrinsic plugins."); - } - - if (hasPlugin(plugins, "pipelineOperator") && !PIPELINE_PROPOSALS.includes(getPluginOption(plugins, "pipelineOperator", "proposal"))) { - throw new Error("'pipelineOperator' requires 'proposal' option whose value should be one of: " + PIPELINE_PROPOSALS.map(p => `'${p}'`).join(", ")); - } - - if (hasPlugin(plugins, "recordAndTuple") && !RECORD_AND_TUPLE_SYNTAX_TYPES.includes(getPluginOption(plugins, "recordAndTuple", "syntaxType"))) { - throw new Error("'recordAndTuple' requires 'syntaxType' option whose value should be one of: " + RECORD_AND_TUPLE_SYNTAX_TYPES.map(p => `'${p}'`).join(", ")); - } -} -const mixinPlugins = { - estree, - jsx, - flow, - typescript, - v8intrinsic, - placeholders -}; -const mixinPluginNames = Object.keys(mixinPlugins); - -const defaultOptions = { - sourceType: "script", - sourceFilename: undefined, - startLine: 1, - allowAwaitOutsideFunction: false, - allowReturnOutsideFunction: false, - allowImportExportEverywhere: false, - allowSuperOutsideMethod: false, - allowUndeclaredExports: false, - plugins: [], - strictMode: null, - ranges: false, - tokens: false, - createParenthesizedExpressions: false, - errorRecovery: false -}; -function getOptions(opts) { - const options = {}; - - for (let _i = 0, _Object$keys = Object.keys(defaultOptions); _i < _Object$keys.length; _i++) { - const key = _Object$keys[_i]; - options[key] = opts && opts[key] != null ? opts[key] : defaultOptions[key]; - } - - return options; -} - -class State { - constructor() { - this.errors = []; - this.potentialArrowAt = -1; - this.noArrowAt = []; - this.noArrowParamsConversionAt = []; - this.inParameters = false; - this.maybeInArrowParameters = false; - this.maybeInAsyncArrowHead = false; - this.inPipeline = false; - this.inType = false; - this.noAnonFunctionType = false; - this.inPropertyName = false; - this.hasFlowComment = false; - this.isIterator = false; - this.topicContext = { - maxNumOfResolvableTopics: 0, - maxTopicIndex: null - }; - this.soloAwait = false; - this.inFSharpPipelineDirectBody = false; - this.labels = []; - this.decoratorStack = [[]]; - this.yieldPos = -1; - this.awaitPos = -1; - this.comments = []; - this.trailingComments = []; - this.leadingComments = []; - this.commentStack = []; - this.commentPreviousNode = null; - this.pos = 0; - this.lineStart = 0; - this.type = types.eof; - this.value = null; - this.start = 0; - this.end = 0; - this.lastTokEndLoc = null; - this.lastTokStartLoc = null; - this.lastTokStart = 0; - this.lastTokEnd = 0; - this.context = [types$1.braceStatement]; - this.exprAllowed = true; - this.containsEsc = false; - this.octalPositions = []; - this.exportedIdentifiers = []; - this.tokensLength = 0; - } - - init(options) { - this.strict = options.strictMode === false ? false : options.sourceType === "module"; - this.curLine = options.startLine; - this.startLoc = this.endLoc = this.curPosition(); - } - - curPosition() { - return new Position(this.curLine, this.pos - this.lineStart); - } - - clone(skipArrays) { - const state = new State(); - const keys = Object.keys(this); - - for (let i = 0, length = keys.length; i < length; i++) { - const key = keys[i]; - let val = this[key]; - - if (!skipArrays && Array.isArray(val)) { - val = val.slice(); - } - - state[key] = val; - } - - return state; - } - -} - -var _isDigit = function isDigit(code) { - return code >= 48 && code <= 57; -}; -const VALID_REGEX_FLAGS = new Set(["g", "m", "s", "i", "y", "u"]); -const forbiddenNumericSeparatorSiblings = { - decBinOct: [46, 66, 69, 79, 95, 98, 101, 111], - hex: [46, 88, 95, 120] -}; -const allowedNumericSeparatorSiblings = {}; -allowedNumericSeparatorSiblings.bin = [48, 49]; -allowedNumericSeparatorSiblings.oct = [...allowedNumericSeparatorSiblings.bin, 50, 51, 52, 53, 54, 55]; -allowedNumericSeparatorSiblings.dec = [...allowedNumericSeparatorSiblings.oct, 56, 57]; -allowedNumericSeparatorSiblings.hex = [...allowedNumericSeparatorSiblings.dec, 65, 66, 67, 68, 69, 70, 97, 98, 99, 100, 101, 102]; -class Token { - constructor(state) { - this.type = state.type; - this.value = state.value; - this.start = state.start; - this.end = state.end; - this.loc = new SourceLocation(state.startLoc, state.endLoc); - } - -} -class Tokenizer extends LocationParser { - constructor(options, input) { - super(); - this.tokens = []; - this.state = new State(); - this.state.init(options); - this.input = input; - this.length = input.length; - this.isLookahead = false; - } - - pushToken(token) { - this.tokens.length = this.state.tokensLength; - this.tokens.push(token); - ++this.state.tokensLength; - } - - next() { - if (!this.isLookahead) { - this.checkKeywordEscapes(); - - if (this.options.tokens) { - this.pushToken(new Token(this.state)); - } - } - - this.state.lastTokEnd = this.state.end; - this.state.lastTokStart = this.state.start; - this.state.lastTokEndLoc = this.state.endLoc; - this.state.lastTokStartLoc = this.state.startLoc; - this.nextToken(); - } - - eat(type) { - if (this.match(type)) { - this.next(); - return true; - } else { - return false; - } - } - - match(type) { - return this.state.type === type; - } - - lookahead() { - const old = this.state; - this.state = old.clone(true); - this.isLookahead = true; - this.next(); - this.isLookahead = false; - const curr = this.state; - this.state = old; - return curr; - } - - nextTokenStart() { - const thisTokEnd = this.state.pos; - skipWhiteSpace.lastIndex = thisTokEnd; - const skip = skipWhiteSpace.exec(this.input); - return thisTokEnd + skip[0].length; - } - - lookaheadCharCode() { - return this.input.charCodeAt(this.nextTokenStart()); - } - - setStrict(strict) { - this.state.strict = strict; - if (!this.match(types.num) && !this.match(types.string)) return; - this.state.pos = this.state.start; - - while (this.state.pos < this.state.lineStart) { - this.state.lineStart = this.input.lastIndexOf("\n", this.state.lineStart - 2) + 1; - --this.state.curLine; - } - - this.nextToken(); - } - - curContext() { - return this.state.context[this.state.context.length - 1]; - } - - nextToken() { - const curContext = this.curContext(); - if (!curContext || !curContext.preserveSpace) this.skipSpace(); - this.state.octalPositions = []; - this.state.start = this.state.pos; - this.state.startLoc = this.state.curPosition(); - - if (this.state.pos >= this.length) { - this.finishToken(types.eof); - return; - } - - const override = curContext == null ? void 0 : curContext.override; - - if (override) { - override(this); - } else { - this.getTokenFromCode(this.input.codePointAt(this.state.pos)); - } - } - - pushComment(block, text, start, end, startLoc, endLoc) { - const comment = { - type: block ? "CommentBlock" : "CommentLine", - value: text, - start: start, - end: end, - loc: new SourceLocation(startLoc, endLoc) - }; - if (this.options.tokens) this.pushToken(comment); - this.state.comments.push(comment); - this.addComment(comment); - } - - skipBlockComment() { - const startLoc = this.state.curPosition(); - const start = this.state.pos; - const end = this.input.indexOf("*/", this.state.pos + 2); - if (end === -1) throw this.raise(start, Errors.UnterminatedComment); - this.state.pos = end + 2; - lineBreakG.lastIndex = start; - let match; - - while ((match = lineBreakG.exec(this.input)) && match.index < this.state.pos) { - ++this.state.curLine; - this.state.lineStart = match.index + match[0].length; - } - - if (this.isLookahead) return; - this.pushComment(true, this.input.slice(start + 2, end), start, this.state.pos, startLoc, this.state.curPosition()); - } - - skipLineComment(startSkip) { - const start = this.state.pos; - const startLoc = this.state.curPosition(); - let ch = this.input.charCodeAt(this.state.pos += startSkip); - - if (this.state.pos < this.length) { - while (!isNewLine(ch) && ++this.state.pos < this.length) { - ch = this.input.charCodeAt(this.state.pos); - } - } - - if (this.isLookahead) return; - this.pushComment(false, this.input.slice(start + startSkip, this.state.pos), start, this.state.pos, startLoc, this.state.curPosition()); - } - - skipSpace() { - loop: while (this.state.pos < this.length) { - const ch = this.input.charCodeAt(this.state.pos); - - switch (ch) { - case 32: - case 160: - case 9: - ++this.state.pos; - break; - - case 13: - if (this.input.charCodeAt(this.state.pos + 1) === 10) { - ++this.state.pos; - } - - case 10: - case 8232: - case 8233: - ++this.state.pos; - ++this.state.curLine; - this.state.lineStart = this.state.pos; - break; - - case 47: - switch (this.input.charCodeAt(this.state.pos + 1)) { - case 42: - this.skipBlockComment(); - break; - - case 47: - this.skipLineComment(2); - break; - - default: - break loop; - } - - break; - - default: - if (isWhitespace(ch)) { - ++this.state.pos; - } else { - break loop; - } - - } - } - } - - finishToken(type, val) { - this.state.end = this.state.pos; - this.state.endLoc = this.state.curPosition(); - const prevType = this.state.type; - this.state.type = type; - this.state.value = val; - if (!this.isLookahead) this.updateContext(prevType); - } - - readToken_numberSign() { - if (this.state.pos === 0 && this.readToken_interpreter()) { - return; - } - - const nextPos = this.state.pos + 1; - const next = this.input.charCodeAt(nextPos); - - if (next >= 48 && next <= 57) { - throw this.raise(this.state.pos, Errors.UnexpectedDigitAfterHash); - } - - if (this.hasPlugin("recordAndTuple") && (next === 123 || next === 91)) { - if (this.getPluginOption("recordAndTuple", "syntaxType") !== "hash") { - throw this.raise(this.state.pos, next === 123 ? Errors.RecordExpressionHashIncorrectStartSyntaxType : Errors.TupleExpressionHashIncorrectStartSyntaxType); - } - - if (next === 123) { - this.finishToken(types.braceHashL); - } else { - this.finishToken(types.bracketHashL); - } - - this.state.pos += 2; - } else if (this.hasPlugin("classPrivateProperties") || this.hasPlugin("classPrivateMethods") || this.getPluginOption("pipelineOperator", "proposal") === "smart") { - this.finishOp(types.hash, 1); - } else { - throw this.raise(this.state.pos, Errors.InvalidOrUnexpectedToken, "#"); - } - } - - readToken_dot() { - const next = this.input.charCodeAt(this.state.pos + 1); - - if (next >= 48 && next <= 57) { - this.readNumber(true); - return; - } - - if (next === 46 && this.input.charCodeAt(this.state.pos + 2) === 46) { - this.state.pos += 3; - this.finishToken(types.ellipsis); - } else { - ++this.state.pos; - this.finishToken(types.dot); - } - } - - readToken_slash() { - if (this.state.exprAllowed && !this.state.inType) { - ++this.state.pos; - this.readRegexp(); - return; - } - - const next = this.input.charCodeAt(this.state.pos + 1); - - if (next === 61) { - this.finishOp(types.assign, 2); - } else { - this.finishOp(types.slash, 1); - } - } - - readToken_interpreter() { - if (this.state.pos !== 0 || this.length < 2) return false; - let ch = this.input.charCodeAt(this.state.pos + 1); - if (ch !== 33) return false; - const start = this.state.pos; - this.state.pos += 1; - - while (!isNewLine(ch) && ++this.state.pos < this.length) { - ch = this.input.charCodeAt(this.state.pos); - } - - const value = this.input.slice(start + 2, this.state.pos); - this.finishToken(types.interpreterDirective, value); - return true; - } - - readToken_mult_modulo(code) { - let type = code === 42 ? types.star : types.modulo; - let width = 1; - let next = this.input.charCodeAt(this.state.pos + 1); - const exprAllowed = this.state.exprAllowed; - - if (code === 42 && next === 42) { - width++; - next = this.input.charCodeAt(this.state.pos + 2); - type = types.exponent; - } - - if (next === 61 && !exprAllowed) { - width++; - type = types.assign; - } - - this.finishOp(type, width); - } - - readToken_pipe_amp(code) { - const next = this.input.charCodeAt(this.state.pos + 1); - - if (next === code) { - if (this.input.charCodeAt(this.state.pos + 2) === 61) { - this.finishOp(types.assign, 3); - } else { - this.finishOp(code === 124 ? types.logicalOR : types.logicalAND, 2); - } - - return; - } - - if (code === 124) { - if (next === 62) { - this.finishOp(types.pipeline, 2); - return; - } - - if (this.hasPlugin("recordAndTuple") && next === 125) { - if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") { - throw this.raise(this.state.pos, Errors.RecordExpressionBarIncorrectEndSyntaxType); - } - - this.finishOp(types.braceBarR, 2); - return; - } - - if (this.hasPlugin("recordAndTuple") && next === 93) { - if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") { - throw this.raise(this.state.pos, Errors.TupleExpressionBarIncorrectEndSyntaxType); - } - - this.finishOp(types.bracketBarR, 2); - return; - } - } - - if (next === 61) { - this.finishOp(types.assign, 2); - return; - } - - this.finishOp(code === 124 ? types.bitwiseOR : types.bitwiseAND, 1); - } - - readToken_caret() { - const next = this.input.charCodeAt(this.state.pos + 1); - - if (next === 61) { - this.finishOp(types.assign, 2); - } else { - this.finishOp(types.bitwiseXOR, 1); - } - } - - readToken_plus_min(code) { - const next = this.input.charCodeAt(this.state.pos + 1); - - if (next === code) { - if (next === 45 && !this.inModule && this.input.charCodeAt(this.state.pos + 2) === 62 && (this.state.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.pos)))) { - this.skipLineComment(3); - this.skipSpace(); - this.nextToken(); - return; - } - - this.finishOp(types.incDec, 2); - return; - } - - if (next === 61) { - this.finishOp(types.assign, 2); - } else { - this.finishOp(types.plusMin, 1); - } - } - - readToken_lt_gt(code) { - const next = this.input.charCodeAt(this.state.pos + 1); - let size = 1; - - if (next === code) { - size = code === 62 && this.input.charCodeAt(this.state.pos + 2) === 62 ? 3 : 2; - - if (this.input.charCodeAt(this.state.pos + size) === 61) { - this.finishOp(types.assign, size + 1); - return; - } - - this.finishOp(types.bitShift, size); - return; - } - - if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.state.pos + 2) === 45 && this.input.charCodeAt(this.state.pos + 3) === 45) { - this.skipLineComment(4); - this.skipSpace(); - this.nextToken(); - return; - } - - if (next === 61) { - size = 2; - } - - this.finishOp(types.relational, size); - } - - readToken_eq_excl(code) { - const next = this.input.charCodeAt(this.state.pos + 1); - - if (next === 61) { - this.finishOp(types.equality, this.input.charCodeAt(this.state.pos + 2) === 61 ? 3 : 2); - return; - } - - if (code === 61 && next === 62) { - this.state.pos += 2; - this.finishToken(types.arrow); - return; - } - - this.finishOp(code === 61 ? types.eq : types.bang, 1); - } - - readToken_question() { - const next = this.input.charCodeAt(this.state.pos + 1); - const next2 = this.input.charCodeAt(this.state.pos + 2); - - if (next === 63 && !this.state.inType) { - if (next2 === 61) { - this.finishOp(types.assign, 3); - } else { - this.finishOp(types.nullishCoalescing, 2); - } - } else if (next === 46 && !(next2 >= 48 && next2 <= 57)) { - this.state.pos += 2; - this.finishToken(types.questionDot); - } else { - ++this.state.pos; - this.finishToken(types.question); - } - } - - getTokenFromCode(code) { - switch (code) { - case 46: - this.readToken_dot(); - return; - - case 40: - ++this.state.pos; - this.finishToken(types.parenL); - return; - - case 41: - ++this.state.pos; - this.finishToken(types.parenR); - return; - - case 59: - ++this.state.pos; - this.finishToken(types.semi); - return; - - case 44: - ++this.state.pos; - this.finishToken(types.comma); - return; - - case 91: - if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) { - if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") { - throw this.raise(this.state.pos, Errors.TupleExpressionBarIncorrectStartSyntaxType); - } - - this.finishToken(types.bracketBarL); - this.state.pos += 2; - } else { - ++this.state.pos; - this.finishToken(types.bracketL); - } - - return; - - case 93: - ++this.state.pos; - this.finishToken(types.bracketR); - return; - - case 123: - if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) { - if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") { - throw this.raise(this.state.pos, Errors.RecordExpressionBarIncorrectStartSyntaxType); - } - - this.finishToken(types.braceBarL); - this.state.pos += 2; - } else { - ++this.state.pos; - this.finishToken(types.braceL); - } - - return; - - case 125: - ++this.state.pos; - this.finishToken(types.braceR); - return; - - case 58: - if (this.hasPlugin("functionBind") && this.input.charCodeAt(this.state.pos + 1) === 58) { - this.finishOp(types.doubleColon, 2); - } else { - ++this.state.pos; - this.finishToken(types.colon); - } - - return; - - case 63: - this.readToken_question(); - return; - - case 96: - ++this.state.pos; - this.finishToken(types.backQuote); - return; - - case 48: - { - const next = this.input.charCodeAt(this.state.pos + 1); - - if (next === 120 || next === 88) { - this.readRadixNumber(16); - return; - } - - if (next === 111 || next === 79) { - this.readRadixNumber(8); - return; - } - - if (next === 98 || next === 66) { - this.readRadixNumber(2); - return; - } - } - - case 49: - case 50: - case 51: - case 52: - case 53: - case 54: - case 55: - case 56: - case 57: - this.readNumber(false); - return; - - case 34: - case 39: - this.readString(code); - return; - - case 47: - this.readToken_slash(); - return; - - case 37: - case 42: - this.readToken_mult_modulo(code); - return; - - case 124: - case 38: - this.readToken_pipe_amp(code); - return; - - case 94: - this.readToken_caret(); - return; - - case 43: - case 45: - this.readToken_plus_min(code); - return; - - case 60: - case 62: - this.readToken_lt_gt(code); - return; - - case 61: - case 33: - this.readToken_eq_excl(code); - return; - - case 126: - this.finishOp(types.tilde, 1); - return; - - case 64: - ++this.state.pos; - this.finishToken(types.at); - return; - - case 35: - this.readToken_numberSign(); - return; - - case 92: - this.readWord(); - return; - - default: - if (isIdentifierStart(code)) { - this.readWord(); - return; - } - - } - - throw this.raise(this.state.pos, Errors.InvalidOrUnexpectedToken, String.fromCodePoint(code)); - } - - finishOp(type, size) { - const str = this.input.slice(this.state.pos, this.state.pos + size); - this.state.pos += size; - this.finishToken(type, str); - } - - readRegexp() { - const start = this.state.pos; - let escaped, inClass; - - for (;;) { - if (this.state.pos >= this.length) { - throw this.raise(start, Errors.UnterminatedRegExp); - } - - const ch = this.input.charAt(this.state.pos); - - if (lineBreak.test(ch)) { - throw this.raise(start, Errors.UnterminatedRegExp); - } - - if (escaped) { - escaped = false; - } else { - if (ch === "[") { - inClass = true; - } else if (ch === "]" && inClass) { - inClass = false; - } else if (ch === "/" && !inClass) { - break; - } - - escaped = ch === "\\"; - } - - ++this.state.pos; - } - - const content = this.input.slice(start, this.state.pos); - ++this.state.pos; - let mods = ""; - - while (this.state.pos < this.length) { - const char = this.input[this.state.pos]; - const charCode = this.input.codePointAt(this.state.pos); - - if (VALID_REGEX_FLAGS.has(char)) { - if (mods.indexOf(char) > -1) { - this.raise(this.state.pos + 1, Errors.DuplicateRegExpFlags); - } - } else if (isIdentifierChar(charCode) || charCode === 92) { - this.raise(this.state.pos + 1, Errors.MalformedRegExpFlags); - } else { - break; - } - - ++this.state.pos; - mods += char; - } - - this.finishToken(types.regexp, { - pattern: content, - flags: mods - }); - } - - readInt(radix, len, forceLen, allowNumSeparator = true) { - const start = this.state.pos; - const forbiddenSiblings = radix === 16 ? forbiddenNumericSeparatorSiblings.hex : forbiddenNumericSeparatorSiblings.decBinOct; - const allowedSiblings = radix === 16 ? allowedNumericSeparatorSiblings.hex : radix === 10 ? allowedNumericSeparatorSiblings.dec : radix === 8 ? allowedNumericSeparatorSiblings.oct : allowedNumericSeparatorSiblings.bin; - let invalid = false; - let total = 0; - - for (let i = 0, e = len == null ? Infinity : len; i < e; ++i) { - const code = this.input.charCodeAt(this.state.pos); - let val; - - if (this.hasPlugin("numericSeparator")) { - if (code === 95) { - const prev = this.input.charCodeAt(this.state.pos - 1); - const next = this.input.charCodeAt(this.state.pos + 1); - - if (allowedSiblings.indexOf(next) === -1) { - this.raise(this.state.pos, Errors.UnexpectedNumericSeparator); - } else if (forbiddenSiblings.indexOf(prev) > -1 || forbiddenSiblings.indexOf(next) > -1 || Number.isNaN(next)) { - this.raise(this.state.pos, Errors.UnexpectedNumericSeparator); - } - - if (!allowNumSeparator) { - this.raise(this.state.pos, Errors.NumericSeparatorInEscapeSequence); - } - - ++this.state.pos; - continue; - } - } - - if (code >= 97) { - val = code - 97 + 10; - } else if (code >= 65) { - val = code - 65 + 10; - } else if (_isDigit(code)) { - val = code - 48; - } else { - val = Infinity; - } - - if (val >= radix) { - if (this.options.errorRecovery && val <= 9) { - val = 0; - this.raise(this.state.start + i + 2, Errors.InvalidDigit, radix); - } else if (forceLen) { - val = 0; - invalid = true; - } else { - break; - } - } - - ++this.state.pos; - total = total * radix + val; - } - - if (this.state.pos === start || len != null && this.state.pos - start !== len || invalid) { - return null; - } - - return total; - } - - readRadixNumber(radix) { - const start = this.state.pos; - let isBigInt = false; - this.state.pos += 2; - const val = this.readInt(radix); - - if (val == null) { - this.raise(this.state.start + 2, Errors.InvalidDigit, radix); - } - - if (this.input.charCodeAt(this.state.pos) === 110) { - ++this.state.pos; - isBigInt = true; - } - - if (isIdentifierStart(this.input.codePointAt(this.state.pos))) { - throw this.raise(this.state.pos, Errors.NumberIdentifier); - } - - if (isBigInt) { - const str = this.input.slice(start, this.state.pos).replace(/[_n]/g, ""); - this.finishToken(types.bigint, str); - return; - } - - this.finishToken(types.num, val); - } - - readNumber(startsWithDot) { - const start = this.state.pos; - let isFloat = false; - let isBigInt = false; - let isNonOctalDecimalInt = false; - - if (!startsWithDot && this.readInt(10) === null) { - this.raise(start, Errors.InvalidNumber); - } - - let octal = this.state.pos - start >= 2 && this.input.charCodeAt(start) === 48; - - if (octal) { - if (this.state.strict) { - this.raise(start, Errors.StrictOctalLiteral); - } - - if (/[89]/.test(this.input.slice(start, this.state.pos))) { - octal = false; - isNonOctalDecimalInt = true; - } - } - - let next = this.input.charCodeAt(this.state.pos); - - if (next === 46 && !octal) { - ++this.state.pos; - this.readInt(10); - isFloat = true; - next = this.input.charCodeAt(this.state.pos); - } - - if ((next === 69 || next === 101) && !octal) { - next = this.input.charCodeAt(++this.state.pos); - - if (next === 43 || next === 45) { - ++this.state.pos; - } - - if (this.readInt(10) === null) this.raise(start, "Invalid number"); - isFloat = true; - next = this.input.charCodeAt(this.state.pos); - } - - if (this.hasPlugin("numericSeparator") && (octal || isNonOctalDecimalInt)) { - const underscorePos = this.input.slice(start, this.state.pos).indexOf("_"); - - if (underscorePos > 0) { - this.raise(underscorePos + start, Errors.ZeroDigitNumericSeparator); - } - } - - if (next === 110) { - if (isFloat || octal || isNonOctalDecimalInt) { - this.raise(start, "Invalid BigIntLiteral"); - } - - ++this.state.pos; - isBigInt = true; - } - - if (isIdentifierStart(this.input.codePointAt(this.state.pos))) { - throw this.raise(this.state.pos, Errors.NumberIdentifier); - } - - const str = this.input.slice(start, this.state.pos).replace(/[_n]/g, ""); - - if (isBigInt) { - this.finishToken(types.bigint, str); - return; - } - - const val = octal ? parseInt(str, 8) : parseFloat(str); - this.finishToken(types.num, val); - } - - readCodePoint(throwOnInvalid) { - const ch = this.input.charCodeAt(this.state.pos); - let code; - - if (ch === 123) { - const codePos = ++this.state.pos; - code = this.readHexChar(this.input.indexOf("}", this.state.pos) - this.state.pos, true, throwOnInvalid); - ++this.state.pos; - - if (code !== null && code > 0x10ffff) { - if (throwOnInvalid) { - this.raise(codePos, Errors.InvalidCodePoint); - } else { - return null; - } - } - } else { - code = this.readHexChar(4, false, throwOnInvalid); - } - - return code; - } - - readString(quote) { - let out = "", - chunkStart = ++this.state.pos; - - for (;;) { - if (this.state.pos >= this.length) { - throw this.raise(this.state.start, Errors.UnterminatedString); - } - - const ch = this.input.charCodeAt(this.state.pos); - if (ch === quote) break; - - if (ch === 92) { - out += this.input.slice(chunkStart, this.state.pos); - out += this.readEscapedChar(false); - chunkStart = this.state.pos; - } else if (ch === 8232 || ch === 8233) { - ++this.state.pos; - ++this.state.curLine; - this.state.lineStart = this.state.pos; - } else if (isNewLine(ch)) { - throw this.raise(this.state.start, Errors.UnterminatedString); - } else { - ++this.state.pos; - } - } - - out += this.input.slice(chunkStart, this.state.pos++); - this.finishToken(types.string, out); - } - - readTmplToken() { - let out = "", - chunkStart = this.state.pos, - containsInvalid = false; - - for (;;) { - if (this.state.pos >= this.length) { - throw this.raise(this.state.start, Errors.UnterminatedTemplate); - } - - const ch = this.input.charCodeAt(this.state.pos); - - if (ch === 96 || ch === 36 && this.input.charCodeAt(this.state.pos + 1) === 123) { - if (this.state.pos === this.state.start && this.match(types.template)) { - if (ch === 36) { - this.state.pos += 2; - this.finishToken(types.dollarBraceL); - return; - } else { - ++this.state.pos; - this.finishToken(types.backQuote); - return; - } - } - - out += this.input.slice(chunkStart, this.state.pos); - this.finishToken(types.template, containsInvalid ? null : out); - return; - } - - if (ch === 92) { - out += this.input.slice(chunkStart, this.state.pos); - const escaped = this.readEscapedChar(true); - - if (escaped === null) { - containsInvalid = true; - } else { - out += escaped; - } - - chunkStart = this.state.pos; - } else if (isNewLine(ch)) { - out += this.input.slice(chunkStart, this.state.pos); - ++this.state.pos; - - switch (ch) { - case 13: - if (this.input.charCodeAt(this.state.pos) === 10) { - ++this.state.pos; - } - - case 10: - out += "\n"; - break; - - default: - out += String.fromCharCode(ch); - break; - } - - ++this.state.curLine; - this.state.lineStart = this.state.pos; - chunkStart = this.state.pos; - } else { - ++this.state.pos; - } - } - } - - readEscapedChar(inTemplate) { - const throwOnInvalid = !inTemplate; - const ch = this.input.charCodeAt(++this.state.pos); - ++this.state.pos; - - switch (ch) { - case 110: - return "\n"; - - case 114: - return "\r"; - - case 120: - { - const code = this.readHexChar(2, false, throwOnInvalid); - return code === null ? null : String.fromCharCode(code); - } - - case 117: - { - const code = this.readCodePoint(throwOnInvalid); - return code === null ? null : String.fromCodePoint(code); - } - - case 116: - return "\t"; - - case 98: - return "\b"; - - case 118: - return "\u000b"; - - case 102: - return "\f"; - - case 13: - if (this.input.charCodeAt(this.state.pos) === 10) { - ++this.state.pos; - } - - case 10: - this.state.lineStart = this.state.pos; - ++this.state.curLine; - - case 8232: - case 8233: - return ""; - - case 56: - case 57: - if (inTemplate) { - return null; - } - - default: - if (ch >= 48 && ch <= 55) { - const codePos = this.state.pos - 1; - let octalStr = this.input.substr(this.state.pos - 1, 3).match(/^[0-7]+/)[0]; - let octal = parseInt(octalStr, 8); - - if (octal > 255) { - octalStr = octalStr.slice(0, -1); - octal = parseInt(octalStr, 8); - } - - this.state.pos += octalStr.length - 1; - const next = this.input.charCodeAt(this.state.pos); - - if (octalStr !== "0" || next === 56 || next === 57) { - if (inTemplate) { - return null; - } else if (this.state.strict) { - this.raise(codePos, Errors.StrictOctalLiteral); - } else { - this.state.octalPositions.push(codePos); - } - } - - return String.fromCharCode(octal); - } - - return String.fromCharCode(ch); - } - } - - readHexChar(len, forceLen, throwOnInvalid) { - const codePos = this.state.pos; - const n = this.readInt(16, len, forceLen, false); - - if (n === null) { - if (throwOnInvalid) { - this.raise(codePos, Errors.InvalidEscapeSequence); - } else { - this.state.pos = codePos - 1; - } - } - - return n; - } - - readWord1() { - let word = ""; - this.state.containsEsc = false; - const start = this.state.pos; - let chunkStart = this.state.pos; - - while (this.state.pos < this.length) { - const ch = this.input.codePointAt(this.state.pos); - - if (isIdentifierChar(ch)) { - this.state.pos += ch <= 0xffff ? 1 : 2; - } else if (this.state.isIterator && ch === 64) { - ++this.state.pos; - } else if (ch === 92) { - this.state.containsEsc = true; - word += this.input.slice(chunkStart, this.state.pos); - const escStart = this.state.pos; - const identifierCheck = this.state.pos === start ? isIdentifierStart : isIdentifierChar; - - if (this.input.charCodeAt(++this.state.pos) !== 117) { - this.raise(this.state.pos, Errors.MissingUnicodeEscape); - continue; - } - - ++this.state.pos; - const esc = this.readCodePoint(true); - - if (esc !== null) { - if (!identifierCheck(esc)) { - this.raise(escStart, Errors.EscapedCharNotAnIdentifier); - } - - word += String.fromCodePoint(esc); - } - - chunkStart = this.state.pos; - } else { - break; - } - } - - return word + this.input.slice(chunkStart, this.state.pos); - } - - isIterator(word) { - return word === "@@iterator" || word === "@@asyncIterator"; - } - - readWord() { - const word = this.readWord1(); - const type = keywords.get(word) || types.name; - - if (this.state.isIterator && (!this.isIterator(word) || !this.state.inType)) { - this.raise(this.state.pos, Errors.InvalidIdentifier, word); - } - - this.finishToken(type, word); - } - - checkKeywordEscapes() { - const kw = this.state.type.keyword; - - if (kw && this.state.containsEsc) { - this.raise(this.state.start, Errors.InvalidEscapedReservedWord, kw); - } - } - - braceIsBlock(prevType) { - const parent = this.curContext(); - - if (parent === types$1.functionExpression || parent === types$1.functionStatement) { - return true; - } - - if (prevType === types.colon && (parent === types$1.braceStatement || parent === types$1.braceExpression)) { - return !parent.isExpr; - } - - if (prevType === types._return || prevType === types.name && this.state.exprAllowed) { - return lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.start)); - } - - if (prevType === types._else || prevType === types.semi || prevType === types.eof || prevType === types.parenR || prevType === types.arrow) { - return true; - } - - if (prevType === types.braceL) { - return parent === types$1.braceStatement; - } - - if (prevType === types._var || prevType === types._const || prevType === types.name) { - return false; - } - - if (prevType === types.relational) { - return true; - } - - return !this.state.exprAllowed; - } - - updateContext(prevType) { - const type = this.state.type; - let update; - - if (type.keyword && (prevType === types.dot || prevType === types.questionDot)) { - this.state.exprAllowed = false; - } else if (update = type.updateContext) { - update.call(this, prevType); - } else { - this.state.exprAllowed = type.beforeExpr; - } - } - -} - -class UtilParser extends Tokenizer { - addExtra(node, key, val) { - if (!node) return; - const extra = node.extra = node.extra || {}; - extra[key] = val; - } - - isRelational(op) { - return this.match(types.relational) && this.state.value === op; - } - - isLookaheadRelational(op) { - const next = this.nextTokenStart(); - - if (this.input.charAt(next) === op) { - if (next + 1 === this.input.length) { - return true; - } - - const afterNext = this.input.charCodeAt(next + 1); - return afterNext !== op.charCodeAt(0) && afterNext !== 61; - } - - return false; - } - - expectRelational(op) { - if (this.isRelational(op)) { - this.next(); - } else { - this.unexpected(null, types.relational); - } - } - - isContextual(name) { - return this.match(types.name) && this.state.value === name && !this.state.containsEsc; - } - - isUnparsedContextual(nameStart, name) { - const nameEnd = nameStart + name.length; - return this.input.slice(nameStart, nameEnd) === name && (nameEnd === this.input.length || !isIdentifierChar(this.input.charCodeAt(nameEnd))); - } - - isLookaheadContextual(name) { - const next = this.nextTokenStart(); - return this.isUnparsedContextual(next, name); - } - - eatContextual(name) { - return this.isContextual(name) && this.eat(types.name); - } - - expectContextual(name, message) { - if (!this.eatContextual(name)) this.unexpected(null, message); - } - - canInsertSemicolon() { - return this.match(types.eof) || this.match(types.braceR) || this.hasPrecedingLineBreak(); - } - - hasPrecedingLineBreak() { - return lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.start)); - } - - isLineTerminator() { - return this.eat(types.semi) || this.canInsertSemicolon(); - } - - semicolon() { - if (!this.isLineTerminator()) this.unexpected(null, types.semi); - } - - expect(type, pos) { - this.eat(type) || this.unexpected(pos, type); - } - - assertNoSpace(message = "Unexpected space.") { - if (this.state.start > this.state.lastTokEnd) { - this.raise(this.state.lastTokEnd, message); - } - } - - unexpected(pos, messageOrType = "Unexpected token") { - if (typeof messageOrType !== "string") { - messageOrType = `Unexpected token, expected "${messageOrType.label}"`; - } - - throw this.raise(pos != null ? pos : this.state.start, messageOrType); - } - - expectPlugin(name, pos) { - if (!this.hasPlugin(name)) { - throw this.raiseWithData(pos != null ? pos : this.state.start, { - missingPlugin: [name] - }, `This experimental syntax requires enabling the parser plugin: '${name}'`); - } - - return true; - } - - expectOnePlugin(names, pos) { - if (!names.some(n => this.hasPlugin(n))) { - throw this.raiseWithData(pos != null ? pos : this.state.start, { - missingPlugin: names - }, `This experimental syntax requires enabling one of the following parser plugin(s): '${names.join(", ")}'`); - } - } - - checkYieldAwaitInDefaultParams() { - if (this.state.yieldPos !== -1 && (this.state.awaitPos === -1 || this.state.yieldPos < this.state.awaitPos)) { - this.raise(this.state.yieldPos, "Yield cannot be used as name inside a generator function"); - } - - if (this.state.awaitPos !== -1) { - this.raise(this.state.awaitPos, "Await cannot be used as name inside an async function"); - } - } - - tryParse(fn, oldState = this.state.clone()) { - const abortSignal = { - node: null - }; - - try { - const node = fn((node = null) => { - abortSignal.node = node; - throw abortSignal; - }); - - if (this.state.errors.length > oldState.errors.length) { - const failState = this.state; - this.state = oldState; - return { - node, - error: failState.errors[oldState.errors.length], - thrown: false, - aborted: false, - failState - }; - } - - return { - node, - error: null, - thrown: false, - aborted: false, - failState: null - }; - } catch (error) { - const failState = this.state; - this.state = oldState; - - if (error instanceof SyntaxError) { - return { - node: null, - error, - thrown: true, - aborted: false, - failState - }; - } - - if (error === abortSignal) { - return { - node: abortSignal.node, - error: null, - thrown: false, - aborted: true, - failState - }; - } - - throw error; - } - } - - checkExpressionErrors(refExpressionErrors, andThrow) { - if (!refExpressionErrors) return false; - const { - shorthandAssign, - doubleProto - } = refExpressionErrors; - if (!andThrow) return shorthandAssign >= 0 || doubleProto >= 0; - - if (shorthandAssign >= 0) { - this.unexpected(shorthandAssign); - } - - if (doubleProto >= 0) { - this.raise(doubleProto, Errors.DuplicateProto); - } - } - -} -class ExpressionErrors { - constructor() { - this.shorthandAssign = -1; - this.doubleProto = -1; - } - -} - -class Node { - constructor(parser, pos, loc) { - this.type = ""; - this.start = pos; - this.end = 0; - this.loc = new SourceLocation(loc); - if (parser && parser.options.ranges) this.range = [pos, 0]; - if (parser && parser.filename) this.loc.filename = parser.filename; - } - - __clone() { - const newNode = new Node(); - const keys = Object.keys(this); - - for (let i = 0, length = keys.length; i < length; i++) { - const key = keys[i]; - - if (key !== "leadingComments" && key !== "trailingComments" && key !== "innerComments") { - newNode[key] = this[key]; - } - } - - return newNode; - } - -} - -class NodeUtils extends UtilParser { - startNode() { - return new Node(this, this.state.start, this.state.startLoc); - } - - startNodeAt(pos, loc) { - return new Node(this, pos, loc); - } - - startNodeAtNode(type) { - return this.startNodeAt(type.start, type.loc.start); - } - - finishNode(node, type) { - return this.finishNodeAt(node, type, this.state.lastTokEnd, this.state.lastTokEndLoc); - } - - finishNodeAt(node, type, pos, loc) { - - node.type = type; - node.end = pos; - node.loc.end = loc; - if (this.options.ranges) node.range[1] = pos; - this.processComment(node); - return node; - } - - resetStartLocation(node, start, startLoc) { - node.start = start; - node.loc.start = startLoc; - if (this.options.ranges) node.range[0] = start; - } - - resetEndLocation(node, end = this.state.lastTokEnd, endLoc = this.state.lastTokEndLoc) { - node.end = end; - node.loc.end = endLoc; - if (this.options.ranges) node.range[1] = end; - } - - resetStartLocationFromNode(node, locationNode) { - this.resetStartLocation(node, locationNode.start, locationNode.loc.start); - } - -} - -const unwrapParenthesizedExpression = node => { - return node.type === "ParenthesizedExpression" ? unwrapParenthesizedExpression(node.expression) : node; -}; - -class LValParser extends NodeUtils { - toAssignable(node) { - var _node$extra, _node$extra3; - - let parenthesized = undefined; - - if (node.type === "ParenthesizedExpression" || ((_node$extra = node.extra) == null ? void 0 : _node$extra.parenthesized)) { - parenthesized = unwrapParenthesizedExpression(node); - - if (parenthesized.type !== "Identifier" && parenthesized.type !== "MemberExpression") { - this.raise(node.start, Errors.InvalidParenthesizedAssignment); - } - } - - switch (node.type) { - case "Identifier": - case "ObjectPattern": - case "ArrayPattern": - case "AssignmentPattern": - break; - - case "ObjectExpression": - node.type = "ObjectPattern"; - - for (let i = 0, length = node.properties.length, last = length - 1; i < length; i++) { - var _node$extra2; - - const prop = node.properties[i]; - const isLast = i === last; - this.toAssignableObjectExpressionProp(prop, isLast); - - if (isLast && prop.type === "RestElement" && ((_node$extra2 = node.extra) == null ? void 0 : _node$extra2.trailingComma)) { - this.raiseRestNotLast(node.extra.trailingComma); - } - } - - break; - - case "ObjectProperty": - this.toAssignable(node.value); - break; - - case "SpreadElement": - { - this.checkToRestConversion(node); - node.type = "RestElement"; - const arg = node.argument; - this.toAssignable(arg); - break; - } - - case "ArrayExpression": - node.type = "ArrayPattern"; - this.toAssignableList(node.elements, (_node$extra3 = node.extra) == null ? void 0 : _node$extra3.trailingComma); - break; - - case "AssignmentExpression": - if (node.operator !== "=") { - this.raise(node.left.end, Errors.MissingEqInAssignment); - } - - node.type = "AssignmentPattern"; - delete node.operator; - this.toAssignable(node.left); - break; - - case "ParenthesizedExpression": - this.toAssignable(parenthesized); - break; - } - - return node; - } - - toAssignableObjectExpressionProp(prop, isLast) { - if (prop.type === "ObjectMethod") { - const error = prop.kind === "get" || prop.kind === "set" ? Errors.PatternHasAccessor : Errors.PatternHasMethod; - this.raise(prop.key.start, error); - } else if (prop.type === "SpreadElement" && !isLast) { - this.raiseRestNotLast(prop.start); - } else { - this.toAssignable(prop); - } - } - - toAssignableList(exprList, trailingCommaPos) { - let end = exprList.length; - - if (end) { - const last = exprList[end - 1]; - - if (last && last.type === "RestElement") { - --end; - } else if (last && last.type === "SpreadElement") { - last.type = "RestElement"; - const arg = last.argument; - this.toAssignable(arg); - - if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern" && arg.type !== "ObjectPattern") { - this.unexpected(arg.start); - } - - if (trailingCommaPos) { - this.raiseTrailingCommaAfterRest(trailingCommaPos); - } - - --end; - } - } - - for (let i = 0; i < end; i++) { - const elt = exprList[i]; - - if (elt) { - this.toAssignable(elt); - - if (elt.type === "RestElement") { - this.raiseRestNotLast(elt.start); - } - } - } - - return exprList; - } - - toReferencedList(exprList, isParenthesizedExpr) { - return exprList; - } - - toReferencedListDeep(exprList, isParenthesizedExpr) { - this.toReferencedList(exprList, isParenthesizedExpr); - - for (let _i = 0; _i < exprList.length; _i++) { - const expr = exprList[_i]; - - if (expr && expr.type === "ArrayExpression") { - this.toReferencedListDeep(expr.elements); - } - } - } - - parseSpread(refExpressionErrors, refNeedsArrowPos) { - const node = this.startNode(); - this.next(); - node.argument = this.parseMaybeAssign(false, refExpressionErrors, undefined, refNeedsArrowPos); - return this.finishNode(node, "SpreadElement"); - } - - parseRestBinding() { - const node = this.startNode(); - this.next(); - node.argument = this.parseBindingAtom(); - return this.finishNode(node, "RestElement"); - } - - parseBindingAtom() { - switch (this.state.type) { - case types.bracketL: - { - const node = this.startNode(); - this.next(); - node.elements = this.parseBindingList(types.bracketR, 93, true); - return this.finishNode(node, "ArrayPattern"); - } - - case types.braceL: - return this.parseObj(types.braceR, true); - } - - return this.parseIdentifier(); - } - - parseBindingList(close, closeCharCode, allowEmpty, allowModifiers) { - const elts = []; - let first = true; - - while (!this.eat(close)) { - if (first) { - first = false; - } else { - this.expect(types.comma); - } - - if (allowEmpty && this.match(types.comma)) { - elts.push(null); - } else if (this.eat(close)) { - break; - } else if (this.match(types.ellipsis)) { - elts.push(this.parseAssignableListItemTypes(this.parseRestBinding())); - this.checkCommaAfterRest(closeCharCode); - this.expect(close); - break; - } else { - const decorators = []; - - if (this.match(types.at) && this.hasPlugin("decorators")) { - this.raise(this.state.start, Errors.UnsupportedParameterDecorator); - } - - while (this.match(types.at)) { - decorators.push(this.parseDecorator()); - } - - elts.push(this.parseAssignableListItem(allowModifiers, decorators)); - } - } - - return elts; - } - - parseAssignableListItem(allowModifiers, decorators) { - const left = this.parseMaybeDefault(); - this.parseAssignableListItemTypes(left); - const elt = this.parseMaybeDefault(left.start, left.loc.start, left); - - if (decorators.length) { - left.decorators = decorators; - } - - return elt; - } - - parseAssignableListItemTypes(param) { - return param; - } - - parseMaybeDefault(startPos, startLoc, left) { - startLoc = startLoc || this.state.startLoc; - startPos = startPos || this.state.start; - left = left || this.parseBindingAtom(); - if (!this.eat(types.eq)) return left; - const node = this.startNodeAt(startPos, startLoc); - node.left = left; - node.right = this.parseMaybeAssign(); - return this.finishNode(node, "AssignmentPattern"); - } - - checkLVal(expr, bindingType = BIND_NONE, checkClashes, contextDescription, disallowLetBinding, strictModeChanged = false) { - switch (expr.type) { - case "Identifier": - if (this.state.strict && (strictModeChanged ? isStrictBindReservedWord(expr.name, this.inModule) : isStrictBindOnlyReservedWord(expr.name))) { - this.raise(expr.start, bindingType === BIND_NONE ? Errors.StrictEvalArguments : Errors.StrictEvalArgumentsBinding, expr.name); - } - - if (checkClashes) { - const key = `_${expr.name}`; - - if (checkClashes[key]) { - this.raise(expr.start, Errors.ParamDupe); - } else { - checkClashes[key] = true; - } - } - - if (disallowLetBinding && expr.name === "let") { - this.raise(expr.start, Errors.LetInLexicalBinding); - } - - if (!(bindingType & BIND_NONE)) { - this.scope.declareName(expr.name, bindingType, expr.start); - } - - break; - - case "MemberExpression": - if (bindingType !== BIND_NONE) { - this.raise(expr.start, Errors.InvalidPropertyBindingPattern); - } - - break; - - case "ObjectPattern": - for (let _i2 = 0, _expr$properties = expr.properties; _i2 < _expr$properties.length; _i2++) { - let prop = _expr$properties[_i2]; - if (prop.type === "ObjectProperty") prop = prop.value;else if (prop.type === "ObjectMethod") continue; - this.checkLVal(prop, bindingType, checkClashes, "object destructuring pattern", disallowLetBinding); - } - - break; - - case "ArrayPattern": - for (let _i3 = 0, _expr$elements = expr.elements; _i3 < _expr$elements.length; _i3++) { - const elem = _expr$elements[_i3]; - - if (elem) { - this.checkLVal(elem, bindingType, checkClashes, "array destructuring pattern", disallowLetBinding); - } - } - - break; - - case "AssignmentPattern": - this.checkLVal(expr.left, bindingType, checkClashes, "assignment pattern"); - break; - - case "RestElement": - this.checkLVal(expr.argument, bindingType, checkClashes, "rest element"); - break; - - case "ParenthesizedExpression": - this.checkLVal(expr.expression, bindingType, checkClashes, "parenthesized expression"); - break; - - default: - { - this.raise(expr.start, bindingType === BIND_NONE ? Errors.InvalidLhs : Errors.InvalidLhsBinding, contextDescription); - } - } - } - - checkToRestConversion(node) { - if (node.argument.type !== "Identifier" && node.argument.type !== "MemberExpression") { - this.raise(node.argument.start, Errors.InvalidRestAssignmentPattern); - } - } - - checkCommaAfterRest(close) { - if (this.match(types.comma)) { - if (this.lookaheadCharCode() === close) { - this.raiseTrailingCommaAfterRest(this.state.start); - } else { - this.raiseRestNotLast(this.state.start); - } - } - } - - raiseRestNotLast(pos) { - throw this.raise(pos, Errors.ElementAfterRest); - } - - raiseTrailingCommaAfterRest(pos) { - this.raise(pos, Errors.RestTrailingComma); - } - -} - -class ExpressionParser extends LValParser { - checkDuplicatedProto(prop, protoRef, refExpressionErrors) { - if (prop.type === "SpreadElement" || prop.computed || prop.kind || prop.shorthand) { - return; - } - - const key = prop.key; - const name = key.type === "Identifier" ? key.name : String(key.value); - - if (name === "__proto__") { - if (protoRef.used) { - if (refExpressionErrors) { - if (refExpressionErrors.doubleProto === -1) { - refExpressionErrors.doubleProto = key.start; - } - } else { - this.raise(key.start, Errors.DuplicateProto); - } - } - - protoRef.used = true; - } - } - - getExpression() { - let paramFlags = PARAM; - - if (this.hasPlugin("topLevelAwait") && this.inModule) { - paramFlags |= PARAM_AWAIT; - } - - this.scope.enter(SCOPE_PROGRAM); - this.prodParam.enter(paramFlags); - this.nextToken(); - const expr = this.parseExpression(); - - if (!this.match(types.eof)) { - this.unexpected(); - } - - expr.comments = this.state.comments; - expr.errors = this.state.errors; - return expr; - } - - parseExpression(noIn, refExpressionErrors) { - const startPos = this.state.start; - const startLoc = this.state.startLoc; - const expr = this.parseMaybeAssign(noIn, refExpressionErrors); - - if (this.match(types.comma)) { - const node = this.startNodeAt(startPos, startLoc); - node.expressions = [expr]; - - while (this.eat(types.comma)) { - node.expressions.push(this.parseMaybeAssign(noIn, refExpressionErrors)); - } - - this.toReferencedList(node.expressions); - return this.finishNode(node, "SequenceExpression"); - } - - return expr; - } - - parseMaybeAssign(noIn, refExpressionErrors, afterLeftParse, refNeedsArrowPos) { - const startPos = this.state.start; - const startLoc = this.state.startLoc; - - if (this.isContextual("yield")) { - if (this.prodParam.hasYield) { - let left = this.parseYield(noIn); - - if (afterLeftParse) { - left = afterLeftParse.call(this, left, startPos, startLoc); - } - - return left; - } else { - this.state.exprAllowed = false; - } - } - - let ownExpressionErrors; - - if (refExpressionErrors) { - ownExpressionErrors = false; - } else { - refExpressionErrors = new ExpressionErrors(); - ownExpressionErrors = true; - } - - if (this.match(types.parenL) || this.match(types.name)) { - this.state.potentialArrowAt = this.state.start; - } - - let left = this.parseMaybeConditional(noIn, refExpressionErrors, refNeedsArrowPos); - - if (afterLeftParse) { - left = afterLeftParse.call(this, left, startPos, startLoc); - } - - if (this.state.type.isAssign) { - const node = this.startNodeAt(startPos, startLoc); - const operator = this.state.value; - node.operator = operator; - - if (operator === "??=") { - this.expectPlugin("logicalAssignment"); - } - - if (operator === "||=" || operator === "&&=") { - this.expectPlugin("logicalAssignment"); - } - - if (this.match(types.eq)) { - node.left = this.toAssignable(left); - refExpressionErrors.doubleProto = -1; - } else { - node.left = left; - } - - if (refExpressionErrors.shorthandAssign >= node.left.start) { - refExpressionErrors.shorthandAssign = -1; - } - - this.checkLVal(left, undefined, undefined, "assignment expression"); - this.next(); - node.right = this.parseMaybeAssign(noIn); - return this.finishNode(node, "AssignmentExpression"); - } else if (ownExpressionErrors) { - this.checkExpressionErrors(refExpressionErrors, true); - } - - return left; - } - - parseMaybeConditional(noIn, refExpressionErrors, refNeedsArrowPos) { - const startPos = this.state.start; - const startLoc = this.state.startLoc; - const potentialArrowAt = this.state.potentialArrowAt; - const expr = this.parseExprOps(noIn, refExpressionErrors); - - if (expr.type === "ArrowFunctionExpression" && expr.start === potentialArrowAt) { - return expr; - } - - if (this.checkExpressionErrors(refExpressionErrors, false)) return expr; - return this.parseConditional(expr, noIn, startPos, startLoc, refNeedsArrowPos); - } - - parseConditional(expr, noIn, startPos, startLoc, refNeedsArrowPos) { - if (this.eat(types.question)) { - const node = this.startNodeAt(startPos, startLoc); - node.test = expr; - node.consequent = this.parseMaybeAssign(); - this.expect(types.colon); - node.alternate = this.parseMaybeAssign(noIn); - return this.finishNode(node, "ConditionalExpression"); - } - - return expr; - } - - parseExprOps(noIn, refExpressionErrors) { - const startPos = this.state.start; - const startLoc = this.state.startLoc; - const potentialArrowAt = this.state.potentialArrowAt; - const expr = this.parseMaybeUnary(refExpressionErrors); - - if (expr.type === "ArrowFunctionExpression" && expr.start === potentialArrowAt) { - return expr; - } - - if (this.checkExpressionErrors(refExpressionErrors, false)) { - return expr; - } - - return this.parseExprOp(expr, startPos, startLoc, -1, noIn); - } - - parseExprOp(left, leftStartPos, leftStartLoc, minPrec, noIn) { - let prec = this.state.type.binop; - - if (prec != null && (!noIn || !this.match(types._in))) { - if (prec > minPrec) { - const operator = this.state.value; - - if (operator === "|>" && this.state.inFSharpPipelineDirectBody) { - return left; - } - - const node = this.startNodeAt(leftStartPos, leftStartLoc); - node.left = left; - node.operator = operator; - - if (operator === "**" && left.type === "UnaryExpression" && (this.options.createParenthesizedExpressions || !(left.extra && left.extra.parenthesized))) { - this.raise(left.argument.start, Errors.UnexpectedTokenUnaryExponentiation); - } - - const op = this.state.type; - const logical = op === types.logicalOR || op === types.logicalAND; - const coalesce = op === types.nullishCoalescing; - - if (op === types.pipeline) { - this.expectPlugin("pipelineOperator"); - this.state.inPipeline = true; - this.checkPipelineAtInfixOperator(left, leftStartPos); - } else if (coalesce) { - prec = types.logicalAND.binop; - } - - this.next(); - - if (op === types.pipeline && this.getPluginOption("pipelineOperator", "proposal") === "minimal") { - if (this.match(types.name) && this.state.value === "await" && this.prodParam.hasAwait) { - throw this.raise(this.state.start, Errors.UnexpectedAwaitAfterPipelineBody); - } - } - - node.right = this.parseExprOpRightExpr(op, prec, noIn); - this.finishNode(node, logical || coalesce ? "LogicalExpression" : "BinaryExpression"); - const nextOp = this.state.type; - - if (coalesce && (nextOp === types.logicalOR || nextOp === types.logicalAND) || logical && nextOp === types.nullishCoalescing) { - throw this.raise(this.state.start, Errors.MixingCoalesceWithLogical); - } - - return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn); - } - } - - return left; - } - - parseExprOpRightExpr(op, prec, noIn) { - const startPos = this.state.start; - const startLoc = this.state.startLoc; - - switch (op) { - case types.pipeline: - switch (this.getPluginOption("pipelineOperator", "proposal")) { - case "smart": - return this.withTopicPermittingContext(() => { - return this.parseSmartPipelineBody(this.parseExprOpBaseRightExpr(op, prec, noIn), startPos, startLoc); - }); - - case "fsharp": - return this.withSoloAwaitPermittingContext(() => { - return this.parseFSharpPipelineBody(prec, noIn); - }); - } - - default: - return this.parseExprOpBaseRightExpr(op, prec, noIn); - } - } - - parseExprOpBaseRightExpr(op, prec, noIn) { - const startPos = this.state.start; - const startLoc = this.state.startLoc; - return this.parseExprOp(this.parseMaybeUnary(), startPos, startLoc, op.rightAssociative ? prec - 1 : prec, noIn); - } - - parseMaybeUnary(refExpressionErrors) { - if (this.isContextual("await") && this.isAwaitAllowed()) { - return this.parseAwait(); - } else if (this.state.type.prefix) { - const node = this.startNode(); - const update = this.match(types.incDec); - node.operator = this.state.value; - node.prefix = true; - - if (node.operator === "throw") { - this.expectPlugin("throwExpressions"); - } - - this.next(); - node.argument = this.parseMaybeUnary(); - this.checkExpressionErrors(refExpressionErrors, true); - - if (update) { - this.checkLVal(node.argument, undefined, undefined, "prefix operation"); - } else if (this.state.strict && node.operator === "delete") { - const arg = node.argument; - - if (arg.type === "Identifier") { - this.raise(node.start, Errors.StrictDelete); - } else if (arg.type === "MemberExpression" && arg.property.type === "PrivateName") { - this.raise(node.start, Errors.DeletePrivateField); - } - } - - return this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression"); - } - - const startPos = this.state.start; - const startLoc = this.state.startLoc; - let expr = this.parseExprSubscripts(refExpressionErrors); - if (this.checkExpressionErrors(refExpressionErrors, false)) return expr; - - while (this.state.type.postfix && !this.canInsertSemicolon()) { - const node = this.startNodeAt(startPos, startLoc); - node.operator = this.state.value; - node.prefix = false; - node.argument = expr; - this.checkLVal(expr, undefined, undefined, "postfix operation"); - this.next(); - expr = this.finishNode(node, "UpdateExpression"); - } - - return expr; - } - - parseExprSubscripts(refExpressionErrors) { - const startPos = this.state.start; - const startLoc = this.state.startLoc; - const potentialArrowAt = this.state.potentialArrowAt; - const expr = this.parseExprAtom(refExpressionErrors); - - if (expr.type === "ArrowFunctionExpression" && expr.start === potentialArrowAt) { - return expr; - } - - return this.parseSubscripts(expr, startPos, startLoc); - } - - parseSubscripts(base, startPos, startLoc, noCalls) { - const state = { - optionalChainMember: false, - maybeAsyncArrow: this.atPossibleAsyncArrow(base), - stop: false - }; - - do { - const oldMaybeInAsyncArrowHead = this.state.maybeInAsyncArrowHead; - - if (state.maybeAsyncArrow) { - this.state.maybeInAsyncArrowHead = true; - } - - base = this.parseSubscript(base, startPos, startLoc, noCalls, state); - state.maybeAsyncArrow = false; - this.state.maybeInAsyncArrowHead = oldMaybeInAsyncArrowHead; - } while (!state.stop); - - return base; - } - - parseSubscript(base, startPos, startLoc, noCalls, state) { - if (!noCalls && this.eat(types.doubleColon)) { - const node = this.startNodeAt(startPos, startLoc); - node.object = base; - node.callee = this.parseNoCallExpr(); - state.stop = true; - return this.parseSubscripts(this.finishNode(node, "BindExpression"), startPos, startLoc, noCalls); - } - - let optional = false; - - if (this.match(types.questionDot)) { - state.optionalChainMember = optional = true; - - if (noCalls && this.lookaheadCharCode() === 40) { - state.stop = true; - return base; - } - - this.next(); - } - - const computed = this.eat(types.bracketL); - - if (optional && !this.match(types.parenL) && !this.match(types.backQuote) || computed || this.eat(types.dot)) { - const node = this.startNodeAt(startPos, startLoc); - node.object = base; - node.property = computed ? this.parseExpression() : optional ? this.parseIdentifier(true) : this.parseMaybePrivateName(true); - node.computed = computed; - - if (node.property.type === "PrivateName") { - if (node.object.type === "Super") { - this.raise(startPos, Errors.SuperPrivateField); - } - - this.classScope.usePrivateName(node.property.id.name, node.property.start); - } - - if (computed) { - this.expect(types.bracketR); - } - - if (state.optionalChainMember) { - node.optional = optional; - return this.finishNode(node, "OptionalMemberExpression"); - } else { - return this.finishNode(node, "MemberExpression"); - } - } else if (!noCalls && this.match(types.parenL)) { - const oldMaybeInArrowParameters = this.state.maybeInArrowParameters; - const oldYieldPos = this.state.yieldPos; - const oldAwaitPos = this.state.awaitPos; - this.state.maybeInArrowParameters = true; - this.state.yieldPos = -1; - this.state.awaitPos = -1; - this.next(); - let node = this.startNodeAt(startPos, startLoc); - node.callee = base; - - if (optional) { - node.optional = true; - node.arguments = this.parseCallExpressionArguments(types.parenR, false); - } else { - node.arguments = this.parseCallExpressionArguments(types.parenR, state.maybeAsyncArrow, base.type === "Import", base.type !== "Super", node); - } - - this.finishCallExpression(node, state.optionalChainMember); - - if (state.maybeAsyncArrow && this.shouldParseAsyncArrow() && !optional) { - state.stop = true; - node = this.parseAsyncArrowFromCallExpression(this.startNodeAt(startPos, startLoc), node); - this.checkYieldAwaitInDefaultParams(); - this.state.yieldPos = oldYieldPos; - this.state.awaitPos = oldAwaitPos; - } else { - this.toReferencedListDeep(node.arguments); - if (oldYieldPos !== -1) this.state.yieldPos = oldYieldPos; - - if (!this.isAwaitAllowed() && !oldMaybeInArrowParameters || oldAwaitPos !== -1) { - this.state.awaitPos = oldAwaitPos; - } - } - - this.state.maybeInArrowParameters = oldMaybeInArrowParameters; - return node; - } else if (this.match(types.backQuote)) { - return this.parseTaggedTemplateExpression(startPos, startLoc, base, state); - } else { - state.stop = true; - return base; - } - } - - parseTaggedTemplateExpression(startPos, startLoc, base, state, typeArguments) { - const node = this.startNodeAt(startPos, startLoc); - node.tag = base; - node.quasi = this.parseTemplate(true); - if (typeArguments) node.typeParameters = typeArguments; - - if (state.optionalChainMember) { - this.raise(startPos, Errors.OptionalChainingNoTemplate); - } - - return this.finishNode(node, "TaggedTemplateExpression"); - } - - atPossibleAsyncArrow(base) { - return base.type === "Identifier" && base.name === "async" && this.state.lastTokEnd === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 && base.start === this.state.potentialArrowAt; - } - - finishCallExpression(node, optional) { - if (node.callee.type === "Import") { - if (node.arguments.length !== 1) { - this.raise(node.start, Errors.ImportCallArity); - } else { - const importArg = node.arguments[0]; - - if (importArg && importArg.type === "SpreadElement") { - this.raise(importArg.start, Errors.ImportCallSpreadArgument); - } - } - } - - return this.finishNode(node, optional ? "OptionalCallExpression" : "CallExpression"); - } - - parseCallExpressionArguments(close, possibleAsyncArrow, dynamicImport, allowPlaceholder, nodeForExtra) { - const elts = []; - let innerParenStart; - let first = true; - const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody; - this.state.inFSharpPipelineDirectBody = false; - - while (!this.eat(close)) { - if (first) { - first = false; - } else { - this.expect(types.comma); - - if (this.match(close)) { - if (dynamicImport) { - this.raise(this.state.lastTokStart, Errors.ImportCallArgumentTrailingComma); - } - - if (nodeForExtra) { - this.addExtra(nodeForExtra, "trailingComma", this.state.lastTokStart); - } - - this.next(); - break; - } - } - - if (this.match(types.parenL) && !innerParenStart) { - innerParenStart = this.state.start; - } - - elts.push(this.parseExprListItem(false, possibleAsyncArrow ? new ExpressionErrors() : undefined, possibleAsyncArrow ? { - start: 0 - } : undefined, allowPlaceholder)); - } - - if (possibleAsyncArrow && innerParenStart && this.shouldParseAsyncArrow()) { - this.unexpected(); - } - - this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody; - return elts; - } - - shouldParseAsyncArrow() { - return this.match(types.arrow) && !this.canInsertSemicolon(); - } - - parseAsyncArrowFromCallExpression(node, call) { - var _call$extra; - - this.expect(types.arrow); - this.parseArrowExpression(node, call.arguments, true, (_call$extra = call.extra) == null ? void 0 : _call$extra.trailingComma); - return node; - } - - parseNoCallExpr() { - const startPos = this.state.start; - const startLoc = this.state.startLoc; - return this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true); - } - - parseExprAtom(refExpressionErrors) { - if (this.state.type === types.slash) this.readRegexp(); - const canBeArrow = this.state.potentialArrowAt === this.state.start; - let node; - - switch (this.state.type) { - case types._super: - node = this.startNode(); - this.next(); - - if (this.match(types.parenL) && !this.scope.allowDirectSuper && !this.options.allowSuperOutsideMethod) { - this.raise(node.start, Errors.SuperNotAllowed); - } else if (!this.scope.allowSuper && !this.options.allowSuperOutsideMethod) { - this.raise(node.start, Errors.UnexpectedSuper); - } - - if (!this.match(types.parenL) && !this.match(types.bracketL) && !this.match(types.dot)) { - this.raise(node.start, Errors.UnsupportedSuper); - } - - return this.finishNode(node, "Super"); - - case types._import: - node = this.startNode(); - this.next(); - - if (this.match(types.dot)) { - return this.parseImportMetaProperty(node); - } - - if (!this.match(types.parenL)) { - this.raise(this.state.lastTokStart, Errors.UnsupportedImport); - } - - return this.finishNode(node, "Import"); - - case types._this: - node = this.startNode(); - this.next(); - return this.finishNode(node, "ThisExpression"); - - case types.name: - { - node = this.startNode(); - const containsEsc = this.state.containsEsc; - const id = this.parseIdentifier(); - - if (!containsEsc && id.name === "async" && this.match(types._function) && !this.canInsertSemicolon()) { - const last = this.state.context.length - 1; - - if (this.state.context[last] !== types$1.functionStatement) { - throw new Error("Internal error"); - } - - this.state.context[last] = types$1.functionExpression; - this.next(); - return this.parseFunction(node, undefined, true); - } else if (canBeArrow && !containsEsc && id.name === "async" && this.match(types.name) && !this.canInsertSemicolon()) { - const oldMaybeInArrowParameters = this.state.maybeInArrowParameters; - const oldMaybeInAsyncArrowHead = this.state.maybeInAsyncArrowHead; - const oldYieldPos = this.state.yieldPos; - const oldAwaitPos = this.state.awaitPos; - this.state.maybeInArrowParameters = true; - this.state.maybeInAsyncArrowHead = true; - this.state.yieldPos = -1; - this.state.awaitPos = -1; - const params = [this.parseIdentifier()]; - this.expect(types.arrow); - this.checkYieldAwaitInDefaultParams(); - this.state.maybeInArrowParameters = oldMaybeInArrowParameters; - this.state.maybeInAsyncArrowHead = oldMaybeInAsyncArrowHead; - this.state.yieldPos = oldYieldPos; - this.state.awaitPos = oldAwaitPos; - this.parseArrowExpression(node, params, true); - return node; - } - - if (canBeArrow && this.match(types.arrow) && !this.canInsertSemicolon()) { - this.next(); - this.parseArrowExpression(node, [id], false); - return node; - } - - return id; - } - - case types._do: - { - this.expectPlugin("doExpressions"); - const node = this.startNode(); - this.next(); - const oldLabels = this.state.labels; - this.state.labels = []; - node.body = this.parseBlock(); - this.state.labels = oldLabels; - return this.finishNode(node, "DoExpression"); - } - - case types.regexp: - { - const value = this.state.value; - node = this.parseLiteral(value.value, "RegExpLiteral"); - node.pattern = value.pattern; - node.flags = value.flags; - return node; - } - - case types.num: - return this.parseLiteral(this.state.value, "NumericLiteral"); - - case types.bigint: - return this.parseLiteral(this.state.value, "BigIntLiteral"); - - case types.string: - return this.parseLiteral(this.state.value, "StringLiteral"); - - case types._null: - node = this.startNode(); - this.next(); - return this.finishNode(node, "NullLiteral"); - - case types._true: - case types._false: - return this.parseBooleanLiteral(); - - case types.parenL: - return this.parseParenAndDistinguishExpression(canBeArrow); - - case types.bracketBarL: - case types.bracketHashL: - { - this.expectPlugin("recordAndTuple"); - const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody; - const close = this.state.type === types.bracketBarL ? types.bracketBarR : types.bracketR; - this.state.inFSharpPipelineDirectBody = false; - node = this.startNode(); - this.next(); - node.elements = this.parseExprList(close, true, refExpressionErrors, node); - this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody; - return this.finishNode(node, "TupleExpression"); - } - - case types.bracketL: - { - const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody; - this.state.inFSharpPipelineDirectBody = false; - node = this.startNode(); - this.next(); - node.elements = this.parseExprList(types.bracketR, true, refExpressionErrors, node); - - if (!this.state.maybeInArrowParameters) { - this.toReferencedList(node.elements); - } - - this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody; - return this.finishNode(node, "ArrayExpression"); - } - - case types.braceBarL: - case types.braceHashL: - { - this.expectPlugin("recordAndTuple"); - const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody; - const close = this.state.type === types.braceBarL ? types.braceBarR : types.braceR; - this.state.inFSharpPipelineDirectBody = false; - const ret = this.parseObj(close, false, true, refExpressionErrors); - this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody; - return ret; - } - - case types.braceL: - { - const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody; - this.state.inFSharpPipelineDirectBody = false; - const ret = this.parseObj(types.braceR, false, false, refExpressionErrors); - this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody; - return ret; - } - - case types._function: - return this.parseFunctionExpression(); - - case types.at: - this.parseDecorators(); - - case types._class: - node = this.startNode(); - this.takeDecorators(node); - return this.parseClass(node, false); - - case types._new: - return this.parseNew(); - - case types.backQuote: - return this.parseTemplate(false); - - case types.doubleColon: - { - node = this.startNode(); - this.next(); - node.object = null; - const callee = node.callee = this.parseNoCallExpr(); - - if (callee.type === "MemberExpression") { - return this.finishNode(node, "BindExpression"); - } else { - throw this.raise(callee.start, Errors.UnsupportedBind); - } - } - - case types.hash: - { - if (this.state.inPipeline) { - node = this.startNode(); - - if (this.getPluginOption("pipelineOperator", "proposal") !== "smart") { - this.raise(node.start, Errors.PrimaryTopicRequiresSmartPipeline); - } - - this.next(); - - if (!this.primaryTopicReferenceIsAllowedInCurrentTopicContext()) { - this.raise(node.start, Errors.PrimaryTopicNotAllowed); - } - - this.registerTopicReference(); - return this.finishNode(node, "PipelinePrimaryTopicReference"); - } - } - - default: - throw this.unexpected(); - } - } - - parseBooleanLiteral() { - const node = this.startNode(); - node.value = this.match(types._true); - this.next(); - return this.finishNode(node, "BooleanLiteral"); - } - - parseMaybePrivateName(isPrivateNameAllowed) { - const isPrivate = this.match(types.hash); - - if (isPrivate) { - this.expectOnePlugin(["classPrivateProperties", "classPrivateMethods"]); - - if (!isPrivateNameAllowed) { - this.raise(this.state.pos, Errors.UnexpectedPrivateField); - } - - const node = this.startNode(); - this.next(); - this.assertNoSpace("Unexpected space between # and identifier"); - node.id = this.parseIdentifier(true); - return this.finishNode(node, "PrivateName"); - } else { - return this.parseIdentifier(true); - } - } - - parseFunctionExpression() { - const node = this.startNode(); - let meta = this.startNode(); - this.next(); - meta = this.createIdentifier(meta, "function"); - - if (this.prodParam.hasYield && this.eat(types.dot)) { - return this.parseMetaProperty(node, meta, "sent"); - } - - return this.parseFunction(node); - } - - parseMetaProperty(node, meta, propertyName) { - node.meta = meta; - - if (meta.name === "function" && propertyName === "sent") { - if (this.isContextual(propertyName)) { - this.expectPlugin("functionSent"); - } else if (!this.hasPlugin("functionSent")) { - this.unexpected(); - } - } - - const containsEsc = this.state.containsEsc; - node.property = this.parseIdentifier(true); - - if (node.property.name !== propertyName || containsEsc) { - this.raise(node.property.start, Errors.UnsupportedMetaProperty, meta.name, propertyName); - } - - return this.finishNode(node, "MetaProperty"); - } - - parseImportMetaProperty(node) { - const id = this.createIdentifier(this.startNodeAtNode(node), "import"); - this.expect(types.dot); - - if (this.isContextual("meta")) { - this.expectPlugin("importMeta"); - - if (!this.inModule) { - this.raiseWithData(id.start, { - code: "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED" - }, Errors.ImportMetaOutsideModule); - } - - this.sawUnambiguousESM = true; - } else if (!this.hasPlugin("importMeta")) { - this.raise(id.start, Errors.ImportCallArityLtOne); - } - - return this.parseMetaProperty(node, id, "meta"); - } - - parseLiteral(value, type, startPos, startLoc) { - startPos = startPos || this.state.start; - startLoc = startLoc || this.state.startLoc; - const node = this.startNodeAt(startPos, startLoc); - this.addExtra(node, "rawValue", value); - this.addExtra(node, "raw", this.input.slice(startPos, this.state.end)); - node.value = value; - this.next(); - return this.finishNode(node, type); - } - - parseParenAndDistinguishExpression(canBeArrow) { - const startPos = this.state.start; - const startLoc = this.state.startLoc; - let val; - this.expect(types.parenL); - const oldMaybeInArrowParameters = this.state.maybeInArrowParameters; - const oldYieldPos = this.state.yieldPos; - const oldAwaitPos = this.state.awaitPos; - const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody; - this.state.maybeInArrowParameters = true; - this.state.yieldPos = -1; - this.state.awaitPos = -1; - this.state.inFSharpPipelineDirectBody = false; - const innerStartPos = this.state.start; - const innerStartLoc = this.state.startLoc; - const exprList = []; - const refExpressionErrors = new ExpressionErrors(); - const refNeedsArrowPos = { - start: 0 - }; - let first = true; - let spreadStart; - let optionalCommaStart; - - while (!this.match(types.parenR)) { - if (first) { - first = false; - } else { - this.expect(types.comma, refNeedsArrowPos.start || null); - - if (this.match(types.parenR)) { - optionalCommaStart = this.state.start; - break; - } - } - - if (this.match(types.ellipsis)) { - const spreadNodeStartPos = this.state.start; - const spreadNodeStartLoc = this.state.startLoc; - spreadStart = this.state.start; - exprList.push(this.parseParenItem(this.parseRestBinding(), spreadNodeStartPos, spreadNodeStartLoc)); - this.checkCommaAfterRest(41); - break; - } else { - exprList.push(this.parseMaybeAssign(false, refExpressionErrors, this.parseParenItem, refNeedsArrowPos)); - } - } - - const innerEndPos = this.state.start; - const innerEndLoc = this.state.startLoc; - this.expect(types.parenR); - this.state.maybeInArrowParameters = oldMaybeInArrowParameters; - this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody; - let arrowNode = this.startNodeAt(startPos, startLoc); - - if (canBeArrow && this.shouldParseArrow() && (arrowNode = this.parseArrow(arrowNode))) { - if (!this.isAwaitAllowed() && !this.state.maybeInAsyncArrowHead) { - this.state.awaitPos = oldAwaitPos; - } - - this.checkYieldAwaitInDefaultParams(); - this.state.yieldPos = oldYieldPos; - this.state.awaitPos = oldAwaitPos; - - for (let _i = 0; _i < exprList.length; _i++) { - const param = exprList[_i]; - - if (param.extra && param.extra.parenthesized) { - this.unexpected(param.extra.parenStart); - } - } - - this.parseArrowExpression(arrowNode, exprList, false); - return arrowNode; - } - - if (oldYieldPos !== -1) this.state.yieldPos = oldYieldPos; - if (oldAwaitPos !== -1) this.state.awaitPos = oldAwaitPos; - - if (!exprList.length) { - this.unexpected(this.state.lastTokStart); - } - - if (optionalCommaStart) this.unexpected(optionalCommaStart); - if (spreadStart) this.unexpected(spreadStart); - this.checkExpressionErrors(refExpressionErrors, true); - if (refNeedsArrowPos.start) this.unexpected(refNeedsArrowPos.start); - this.toReferencedListDeep(exprList, true); - - if (exprList.length > 1) { - val = this.startNodeAt(innerStartPos, innerStartLoc); - val.expressions = exprList; - this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc); - } else { - val = exprList[0]; - } - - if (!this.options.createParenthesizedExpressions) { - this.addExtra(val, "parenthesized", true); - this.addExtra(val, "parenStart", startPos); - return val; - } - - const parenExpression = this.startNodeAt(startPos, startLoc); - parenExpression.expression = val; - this.finishNode(parenExpression, "ParenthesizedExpression"); - return parenExpression; - } - - shouldParseArrow() { - return !this.canInsertSemicolon(); - } - - parseArrow(node) { - if (this.eat(types.arrow)) { - return node; - } - } - - parseParenItem(node, startPos, startLoc) { - return node; - } - - parseNew() { - const node = this.startNode(); - let meta = this.startNode(); - this.next(); - meta = this.createIdentifier(meta, "new"); - - if (this.eat(types.dot)) { - const metaProp = this.parseMetaProperty(node, meta, "target"); - - if (!this.scope.inNonArrowFunction && !this.scope.inClass) { - let error = Errors.UnexpectedNewTarget; - - if (this.hasPlugin("classProperties")) { - error += " or class properties"; - } - - this.raise(metaProp.start, error); - } - - return metaProp; - } - - node.callee = this.parseNoCallExpr(); - - if (node.callee.type === "Import") { - this.raise(node.callee.start, Errors.ImportCallNotNewExpression); - } else if (node.callee.type === "OptionalMemberExpression" || node.callee.type === "OptionalCallExpression") { - this.raise(this.state.lastTokEnd, Errors.OptionalChainingNoNew); - } else if (this.eat(types.questionDot)) { - this.raise(this.state.start, Errors.OptionalChainingNoNew); - } - - this.parseNewArguments(node); - return this.finishNode(node, "NewExpression"); - } - - parseNewArguments(node) { - if (this.eat(types.parenL)) { - const args = this.parseExprList(types.parenR); - this.toReferencedList(args); - node.arguments = args; - } else { - node.arguments = []; - } - } - - parseTemplateElement(isTagged) { - const elem = this.startNode(); - - if (this.state.value === null) { - if (!isTagged) { - this.raise(this.state.start + 1, Errors.InvalidEscapeSequenceTemplate); - } - } - - elem.value = { - raw: this.input.slice(this.state.start, this.state.end).replace(/\r\n?/g, "\n"), - cooked: this.state.value - }; - this.next(); - elem.tail = this.match(types.backQuote); - return this.finishNode(elem, "TemplateElement"); - } - - parseTemplate(isTagged) { - const node = this.startNode(); - this.next(); - node.expressions = []; - let curElt = this.parseTemplateElement(isTagged); - node.quasis = [curElt]; - - while (!curElt.tail) { - this.expect(types.dollarBraceL); - node.expressions.push(this.parseExpression()); - this.expect(types.braceR); - node.quasis.push(curElt = this.parseTemplateElement(isTagged)); - } - - this.next(); - return this.finishNode(node, "TemplateLiteral"); - } - - parseObj(close, isPattern, isRecord, refExpressionErrors) { - const propHash = Object.create(null); - let first = true; - const node = this.startNode(); - node.properties = []; - this.next(); - - while (!this.eat(close)) { - if (first) { - first = false; - } else { - this.expect(types.comma); - - if (this.match(close)) { - this.addExtra(node, "trailingComma", this.state.lastTokStart); - this.next(); - break; - } - } - - const prop = this.parseObjectMember(isPattern, refExpressionErrors); - - if (!isPattern) { - this.checkDuplicatedProto(prop, propHash, refExpressionErrors); - } - - if (prop.shorthand) { - this.addExtra(prop, "shorthand", true); - } - - node.properties.push(prop); - } - - let type = "ObjectExpression"; - - if (isPattern) { - type = "ObjectPattern"; - } else if (isRecord) { - type = "RecordExpression"; - } - - return this.finishNode(node, type); - } - - isAsyncProp(prop) { - return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" && (this.match(types.name) || this.match(types.num) || this.match(types.string) || this.match(types.bracketL) || this.state.type.keyword || this.match(types.star)) && !this.hasPrecedingLineBreak(); - } - - parseObjectMember(isPattern, refExpressionErrors) { - let decorators = []; - - if (this.match(types.at)) { - if (this.hasPlugin("decorators")) { - this.raise(this.state.start, Errors.UnsupportedPropertyDecorator); - } - - while (this.match(types.at)) { - decorators.push(this.parseDecorator()); - } - } - - const prop = this.startNode(); - let isGenerator = false; - let isAsync = false; - let startPos; - let startLoc; - - if (this.match(types.ellipsis)) { - if (decorators.length) this.unexpected(); - - if (isPattern) { - this.next(); - prop.argument = this.parseIdentifier(); - this.checkCommaAfterRest(125); - return this.finishNode(prop, "RestElement"); - } - - return this.parseSpread(); - } - - if (decorators.length) { - prop.decorators = decorators; - decorators = []; - } - - prop.method = false; - - if (isPattern || refExpressionErrors) { - startPos = this.state.start; - startLoc = this.state.startLoc; - } - - if (!isPattern) { - isGenerator = this.eat(types.star); - } - - const containsEsc = this.state.containsEsc; - this.parsePropertyName(prop, false); - - if (!isPattern && !containsEsc && !isGenerator && this.isAsyncProp(prop)) { - isAsync = true; - isGenerator = this.eat(types.star); - this.parsePropertyName(prop, false); - } else { - isAsync = false; - } - - this.parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, refExpressionErrors, containsEsc); - return prop; - } - - isGetterOrSetterMethod(prop, isPattern) { - return !isPattern && !prop.computed && prop.key.type === "Identifier" && (prop.key.name === "get" || prop.key.name === "set") && (this.match(types.string) || this.match(types.num) || this.match(types.bracketL) || this.match(types.name) || !!this.state.type.keyword); - } - - getGetterSetterExpectedParamCount(method) { - return method.kind === "get" ? 0 : 1; - } - - checkGetterSetterParams(method) { - const paramCount = this.getGetterSetterExpectedParamCount(method); - const start = method.start; - - if (method.params.length !== paramCount) { - if (method.kind === "get") { - this.raise(start, Errors.BadGetterArity); - } else { - this.raise(start, Errors.BadSetterArity); - } - } - - if (method.kind === "set" && method.params[method.params.length - 1].type === "RestElement") { - this.raise(start, Errors.BadSetterRestParameter); - } - } - - parseObjectMethod(prop, isGenerator, isAsync, isPattern, containsEsc) { - if (isAsync || isGenerator || this.match(types.parenL)) { - if (isPattern) this.unexpected(); - prop.kind = "method"; - prop.method = true; - return this.parseMethod(prop, isGenerator, isAsync, false, false, "ObjectMethod"); - } - - if (!containsEsc && this.isGetterOrSetterMethod(prop, isPattern)) { - if (isGenerator || isAsync) this.unexpected(); - prop.kind = prop.key.name; - this.parsePropertyName(prop, false); - this.parseMethod(prop, false, false, false, false, "ObjectMethod"); - this.checkGetterSetterParams(prop); - return prop; - } - } - - parseObjectProperty(prop, startPos, startLoc, isPattern, refExpressionErrors) { - prop.shorthand = false; - - if (this.eat(types.colon)) { - prop.value = isPattern ? this.parseMaybeDefault(this.state.start, this.state.startLoc) : this.parseMaybeAssign(false, refExpressionErrors); - return this.finishNode(prop, "ObjectProperty"); - } - - if (!prop.computed && prop.key.type === "Identifier") { - this.checkReservedWord(prop.key.name, prop.key.start, true, true); - - if (isPattern) { - prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key.__clone()); - } else if (this.match(types.eq) && refExpressionErrors) { - if (refExpressionErrors.shorthandAssign === -1) { - refExpressionErrors.shorthandAssign = this.state.start; - } - - prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key.__clone()); - } else { - prop.value = prop.key.__clone(); - } - - prop.shorthand = true; - return this.finishNode(prop, "ObjectProperty"); - } - } - - parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, refExpressionErrors, containsEsc) { - const node = this.parseObjectMethod(prop, isGenerator, isAsync, isPattern, containsEsc) || this.parseObjectProperty(prop, startPos, startLoc, isPattern, refExpressionErrors); - if (!node) this.unexpected(); - return node; - } - - parsePropertyName(prop, isPrivateNameAllowed) { - if (this.eat(types.bracketL)) { - prop.computed = true; - prop.key = this.parseMaybeAssign(); - this.expect(types.bracketR); - } else { - const oldInPropertyName = this.state.inPropertyName; - this.state.inPropertyName = true; - prop.key = this.match(types.num) || this.match(types.string) || this.match(types.bigint) ? this.parseExprAtom() : this.parseMaybePrivateName(isPrivateNameAllowed); - - if (prop.key.type !== "PrivateName") { - prop.computed = false; - } - - this.state.inPropertyName = oldInPropertyName; - } - - return prop.key; - } - - initFunction(node, isAsync) { - node.id = null; - node.generator = false; - node.async = !!isAsync; - } - - parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) { - const oldYieldPos = this.state.yieldPos; - const oldAwaitPos = this.state.awaitPos; - this.state.yieldPos = -1; - this.state.awaitPos = -1; - this.initFunction(node, isAsync); - node.generator = !!isGenerator; - const allowModifiers = isConstructor; - this.scope.enter(SCOPE_FUNCTION | SCOPE_SUPER | (inClassScope ? SCOPE_CLASS : 0) | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0)); - this.prodParam.enter(functionFlags(isAsync, node.generator)); - this.parseFunctionParams(node, allowModifiers); - this.parseFunctionBodyAndFinish(node, type, true); - this.prodParam.exit(); - this.scope.exit(); - this.state.yieldPos = oldYieldPos; - this.state.awaitPos = oldAwaitPos; - return node; - } - - parseArrowExpression(node, params, isAsync, trailingCommaPos) { - this.scope.enter(SCOPE_FUNCTION | SCOPE_ARROW); - this.prodParam.enter(functionFlags(isAsync, false)); - this.initFunction(node, isAsync); - const oldMaybeInArrowParameters = this.state.maybeInArrowParameters; - const oldYieldPos = this.state.yieldPos; - const oldAwaitPos = this.state.awaitPos; - - if (params) { - this.state.maybeInArrowParameters = true; - this.setArrowFunctionParameters(node, params, trailingCommaPos); - } - - this.state.maybeInArrowParameters = false; - this.state.yieldPos = -1; - this.state.awaitPos = -1; - this.parseFunctionBody(node, true); - this.prodParam.exit(); - this.scope.exit(); - this.state.maybeInArrowParameters = oldMaybeInArrowParameters; - this.state.yieldPos = oldYieldPos; - this.state.awaitPos = oldAwaitPos; - return this.finishNode(node, "ArrowFunctionExpression"); - } - - setArrowFunctionParameters(node, params, trailingCommaPos) { - node.params = this.toAssignableList(params, trailingCommaPos); - } - - parseFunctionBodyAndFinish(node, type, isMethod = false) { - this.parseFunctionBody(node, false, isMethod); - this.finishNode(node, type); - } - - parseFunctionBody(node, allowExpression, isMethod = false) { - const isExpression = allowExpression && !this.match(types.braceL); - const oldInParameters = this.state.inParameters; - this.state.inParameters = false; - - if (isExpression) { - node.body = this.parseMaybeAssign(); - this.checkParams(node, false, allowExpression, false); - } else { - const oldStrict = this.state.strict; - const oldLabels = this.state.labels; - this.state.labels = []; - this.prodParam.enter(this.prodParam.currentFlags() | PARAM_RETURN); - node.body = this.parseBlock(true, false, hasStrictModeDirective => { - const nonSimple = !this.isSimpleParamList(node.params); - - if (hasStrictModeDirective && nonSimple) { - const errorPos = (node.kind === "method" || node.kind === "constructor") && !!node.key ? node.key.end : node.start; - this.raise(errorPos, Errors.IllegalLanguageModeDirective); - } - - const strictModeChanged = !oldStrict && this.state.strict; - this.checkParams(node, !this.state.strict && !allowExpression && !isMethod && !nonSimple, allowExpression, strictModeChanged); - - if (this.state.strict && node.id) { - this.checkLVal(node.id, BIND_OUTSIDE, undefined, "function name", undefined, strictModeChanged); - } - }); - this.prodParam.exit(); - this.state.labels = oldLabels; - } - - this.state.inParameters = oldInParameters; - } - - isSimpleParamList(params) { - for (let i = 0, len = params.length; i < len; i++) { - if (params[i].type !== "Identifier") return false; - } - - return true; - } - - checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged = true) { - const nameHash = Object.create(null); - - for (let i = 0; i < node.params.length; i++) { - this.checkLVal(node.params[i], BIND_VAR, allowDuplicates ? null : nameHash, "function parameter list", undefined, strictModeChanged); - } - } - - parseExprList(close, allowEmpty, refExpressionErrors, nodeForExtra) { - const elts = []; - let first = true; - - while (!this.eat(close)) { - if (first) { - first = false; - } else { - this.expect(types.comma); - - if (this.match(close)) { - if (nodeForExtra) { - this.addExtra(nodeForExtra, "trailingComma", this.state.lastTokStart); - } - - this.next(); - break; - } - } - - elts.push(this.parseExprListItem(allowEmpty, refExpressionErrors)); - } - - return elts; - } - - parseExprListItem(allowEmpty, refExpressionErrors, refNeedsArrowPos, allowPlaceholder) { - let elt; - - if (allowEmpty && this.match(types.comma)) { - elt = null; - } else if (this.match(types.ellipsis)) { - const spreadNodeStartPos = this.state.start; - const spreadNodeStartLoc = this.state.startLoc; - elt = this.parseParenItem(this.parseSpread(refExpressionErrors, refNeedsArrowPos), spreadNodeStartPos, spreadNodeStartLoc); - } else if (this.match(types.question)) { - this.expectPlugin("partialApplication"); - - if (!allowPlaceholder) { - this.raise(this.state.start, Errors.UnexpectedArgumentPlaceholder); - } - - const node = this.startNode(); - this.next(); - elt = this.finishNode(node, "ArgumentPlaceholder"); - } else { - elt = this.parseMaybeAssign(false, refExpressionErrors, this.parseParenItem, refNeedsArrowPos); - } - - return elt; - } - - parseIdentifier(liberal) { - const node = this.startNode(); - const name = this.parseIdentifierName(node.start, liberal); - return this.createIdentifier(node, name); - } - - createIdentifier(node, name) { - node.name = name; - node.loc.identifierName = name; - return this.finishNode(node, "Identifier"); - } - - parseIdentifierName(pos, liberal) { - let name; - - if (this.match(types.name)) { - name = this.state.value; - } else if (this.state.type.keyword) { - name = this.state.type.keyword; - - if ((name === "class" || name === "function") && (this.state.lastTokEnd !== this.state.lastTokStart + 1 || this.input.charCodeAt(this.state.lastTokStart) !== 46)) { - this.state.context.pop(); - } - } else { - throw this.unexpected(); - } - - if (liberal) { - this.state.type = types.name; - } else { - this.checkReservedWord(name, this.state.start, !!this.state.type.keyword, false); - } - - this.next(); - return name; - } - - checkReservedWord(word, startLoc, checkKeywords, isBinding) { - if (this.prodParam.hasYield && word === "yield") { - this.raise(startLoc, Errors.YieldBindingIdentifier); - return; - } - - if (word === "await") { - if (this.prodParam.hasAwait) { - this.raise(startLoc, Errors.AwaitBindingIdentifier); - return; - } - - if (this.state.awaitPos === -1 && (this.state.maybeInAsyncArrowHead || this.isAwaitAllowed())) { - this.state.awaitPos = this.state.start; - } - } - - if (this.scope.inClass && !this.scope.inNonArrowFunction && word === "arguments") { - this.raise(startLoc, Errors.ArgumentsDisallowedInInitializer); - return; - } - - if (checkKeywords && isKeyword(word)) { - this.raise(startLoc, Errors.UnexpectedKeyword, word); - return; - } - - const reservedTest = !this.state.strict ? isReservedWord : isBinding ? isStrictBindReservedWord : isStrictReservedWord; - - if (reservedTest(word, this.inModule)) { - if (!this.prodParam.hasAwait && word === "await") { - this.raise(startLoc, Errors.AwaitNotInAsyncFunction); - } else { - this.raise(startLoc, Errors.UnexpectedReservedWord, word); - } - } - } - - isAwaitAllowed() { - if (this.scope.inFunction) return this.prodParam.hasAwait; - if (this.options.allowAwaitOutsideFunction) return true; - - if (this.hasPlugin("topLevelAwait")) { - return this.inModule && this.prodParam.hasAwait; - } - - return false; - } - - parseAwait() { - const node = this.startNode(); - this.next(); - - if (this.state.inParameters) { - this.raise(node.start, Errors.AwaitExpressionFormalParameter); - } else if (this.state.awaitPos === -1) { - this.state.awaitPos = node.start; - } - - if (this.eat(types.star)) { - this.raise(node.start, Errors.ObsoleteAwaitStar); - } - - if (!this.scope.inFunction && !this.options.allowAwaitOutsideFunction) { - if (this.hasPrecedingLineBreak() || this.match(types.plusMin) || this.match(types.parenL) || this.match(types.bracketL) || this.match(types.backQuote) || this.match(types.regexp) || this.match(types.slash) || this.hasPlugin("v8intrinsic") && this.match(types.modulo)) { - this.ambiguousScriptDifferentAst = true; - } else { - this.sawUnambiguousESM = true; - } - } - - if (!this.state.soloAwait) { - node.argument = this.parseMaybeUnary(); - } - - return this.finishNode(node, "AwaitExpression"); - } - - parseYield(noIn) { - const node = this.startNode(); - - if (this.state.inParameters) { - this.raise(node.start, Errors.YieldInParameter); - } else if (this.state.yieldPos === -1) { - this.state.yieldPos = node.start; - } - - this.next(); - - if (this.match(types.semi) || !this.match(types.star) && !this.state.type.startsExpr || this.hasPrecedingLineBreak()) { - node.delegate = false; - node.argument = null; - } else { - node.delegate = this.eat(types.star); - node.argument = this.parseMaybeAssign(noIn); - } - - return this.finishNode(node, "YieldExpression"); - } - - checkPipelineAtInfixOperator(left, leftStartPos) { - if (this.getPluginOption("pipelineOperator", "proposal") === "smart") { - if (left.type === "SequenceExpression") { - this.raise(leftStartPos, Errors.PipelineHeadSequenceExpression); - } - } - } - - parseSmartPipelineBody(childExpression, startPos, startLoc) { - const pipelineStyle = this.checkSmartPipelineBodyStyle(childExpression); - this.checkSmartPipelineBodyEarlyErrors(childExpression, pipelineStyle, startPos); - return this.parseSmartPipelineBodyInStyle(childExpression, pipelineStyle, startPos, startLoc); - } - - checkSmartPipelineBodyEarlyErrors(childExpression, pipelineStyle, startPos) { - if (this.match(types.arrow)) { - throw this.raise(this.state.start, Errors.PipelineBodyNoArrow); - } else if (pipelineStyle === "PipelineTopicExpression" && childExpression.type === "SequenceExpression") { - this.raise(startPos, Errors.PipelineBodySequenceExpression); - } - } - - parseSmartPipelineBodyInStyle(childExpression, pipelineStyle, startPos, startLoc) { - const bodyNode = this.startNodeAt(startPos, startLoc); - - switch (pipelineStyle) { - case "PipelineBareFunction": - bodyNode.callee = childExpression; - break; - - case "PipelineBareConstructor": - bodyNode.callee = childExpression.callee; - break; - - case "PipelineBareAwaitedFunction": - bodyNode.callee = childExpression.argument; - break; - - case "PipelineTopicExpression": - if (!this.topicReferenceWasUsedInCurrentTopicContext()) { - this.raise(startPos, Errors.PipelineTopicUnused); - } - - bodyNode.expression = childExpression; - break; - - default: - throw new Error(`Internal @babel/parser error: Unknown pipeline style (${pipelineStyle})`); - } - - return this.finishNode(bodyNode, pipelineStyle); - } - - checkSmartPipelineBodyStyle(expression) { - switch (expression.type) { - default: - return this.isSimpleReference(expression) ? "PipelineBareFunction" : "PipelineTopicExpression"; - } - } - - isSimpleReference(expression) { - switch (expression.type) { - case "MemberExpression": - return !expression.computed && this.isSimpleReference(expression.object); - - case "Identifier": - return true; - - default: - return false; - } - } - - withTopicPermittingContext(callback) { - const outerContextTopicState = this.state.topicContext; - this.state.topicContext = { - maxNumOfResolvableTopics: 1, - maxTopicIndex: null - }; - - try { - return callback(); - } finally { - this.state.topicContext = outerContextTopicState; - } - } - - withTopicForbiddingContext(callback) { - const outerContextTopicState = this.state.topicContext; - this.state.topicContext = { - maxNumOfResolvableTopics: 0, - maxTopicIndex: null - }; - - try { - return callback(); - } finally { - this.state.topicContext = outerContextTopicState; - } - } - - withSoloAwaitPermittingContext(callback) { - const outerContextSoloAwaitState = this.state.soloAwait; - this.state.soloAwait = true; - - try { - return callback(); - } finally { - this.state.soloAwait = outerContextSoloAwaitState; - } - } - - registerTopicReference() { - this.state.topicContext.maxTopicIndex = 0; - } - - primaryTopicReferenceIsAllowedInCurrentTopicContext() { - return this.state.topicContext.maxNumOfResolvableTopics >= 1; - } - - topicReferenceWasUsedInCurrentTopicContext() { - return this.state.topicContext.maxTopicIndex != null && this.state.topicContext.maxTopicIndex >= 0; - } - - parseFSharpPipelineBody(prec, noIn) { - const startPos = this.state.start; - const startLoc = this.state.startLoc; - this.state.potentialArrowAt = this.state.start; - const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody; - this.state.inFSharpPipelineDirectBody = true; - const ret = this.parseExprOp(this.parseMaybeUnary(), startPos, startLoc, prec, noIn); - this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody; - return ret; - } - -} - -const loopLabel = { - kind: "loop" -}, - switchLabel = { - kind: "switch" -}; -const FUNC_NO_FLAGS = 0b000, - FUNC_STATEMENT = 0b001, - FUNC_HANGING_STATEMENT = 0b010, - FUNC_NULLABLE_ID = 0b100; -class StatementParser extends ExpressionParser { - parseTopLevel(file, program) { - program.sourceType = this.options.sourceType; - program.interpreter = this.parseInterpreterDirective(); - this.parseBlockBody(program, true, true, types.eof); - - if (this.inModule && !this.options.allowUndeclaredExports && this.scope.undefinedExports.size > 0) { - for (let _i = 0, _Array$from = Array.from(this.scope.undefinedExports); _i < _Array$from.length; _i++) { - const [name] = _Array$from[_i]; - const pos = this.scope.undefinedExports.get(name); - this.raise(pos, Errors.ModuleExportUndefined, name); - } - } - - file.program = this.finishNode(program, "Program"); - file.comments = this.state.comments; - if (this.options.tokens) file.tokens = this.tokens; - return this.finishNode(file, "File"); - } - - stmtToDirective(stmt) { - const expr = stmt.expression; - const directiveLiteral = this.startNodeAt(expr.start, expr.loc.start); - const directive = this.startNodeAt(stmt.start, stmt.loc.start); - const raw = this.input.slice(expr.start, expr.end); - const val = directiveLiteral.value = raw.slice(1, -1); - this.addExtra(directiveLiteral, "raw", raw); - this.addExtra(directiveLiteral, "rawValue", val); - directive.value = this.finishNodeAt(directiveLiteral, "DirectiveLiteral", expr.end, expr.loc.end); - return this.finishNodeAt(directive, "Directive", stmt.end, stmt.loc.end); - } - - parseInterpreterDirective() { - if (!this.match(types.interpreterDirective)) { - return null; - } - - const node = this.startNode(); - node.value = this.state.value; - this.next(); - return this.finishNode(node, "InterpreterDirective"); - } - - isLet(context) { - if (!this.isContextual("let")) { - return false; - } - - const next = this.nextTokenStart(); - const nextCh = this.input.charCodeAt(next); - if (nextCh === 91) return true; - if (context) return false; - if (nextCh === 123) return true; - - if (isIdentifierStart(nextCh)) { - let pos = next + 1; - - while (isIdentifierChar(this.input.charCodeAt(pos))) { - ++pos; - } - - const ident = this.input.slice(next, pos); - if (!keywordRelationalOperator.test(ident)) return true; - } - - return false; - } - - parseStatement(context, topLevel) { - if (this.match(types.at)) { - this.parseDecorators(true); - } - - return this.parseStatementContent(context, topLevel); - } - - parseStatementContent(context, topLevel) { - let starttype = this.state.type; - const node = this.startNode(); - let kind; - - if (this.isLet(context)) { - starttype = types._var; - kind = "let"; - } - - switch (starttype) { - case types._break: - case types._continue: - return this.parseBreakContinueStatement(node, starttype.keyword); - - case types._debugger: - return this.parseDebuggerStatement(node); - - case types._do: - return this.parseDoStatement(node); - - case types._for: - return this.parseForStatement(node); - - case types._function: - if (this.lookaheadCharCode() === 46) break; - - if (context) { - if (this.state.strict) { - this.raise(this.state.start, Errors.StrictFunction); - } else if (context !== "if" && context !== "label") { - this.raise(this.state.start, Errors.SloppyFunction); - } - } - - return this.parseFunctionStatement(node, false, !context); - - case types._class: - if (context) this.unexpected(); - return this.parseClass(node, true); - - case types._if: - return this.parseIfStatement(node); - - case types._return: - return this.parseReturnStatement(node); - - case types._switch: - return this.parseSwitchStatement(node); - - case types._throw: - return this.parseThrowStatement(node); - - case types._try: - return this.parseTryStatement(node); - - case types._const: - case types._var: - kind = kind || this.state.value; - - if (context && kind !== "var") { - this.raise(this.state.start, Errors.UnexpectedLexicalDeclaration); - } - - return this.parseVarStatement(node, kind); - - case types._while: - return this.parseWhileStatement(node); - - case types._with: - return this.parseWithStatement(node); - - case types.braceL: - return this.parseBlock(); - - case types.semi: - return this.parseEmptyStatement(node); - - case types._export: - case types._import: - { - const nextTokenCharCode = this.lookaheadCharCode(); - - if (nextTokenCharCode === 40 || nextTokenCharCode === 46) { - break; - } - - if (!this.options.allowImportExportEverywhere && !topLevel) { - this.raise(this.state.start, Errors.UnexpectedImportExport); - } - - this.next(); - let result; - - if (starttype === types._import) { - result = this.parseImport(node); - - if (result.type === "ImportDeclaration" && (!result.importKind || result.importKind === "value")) { - this.sawUnambiguousESM = true; - } - } else { - result = this.parseExport(node); - - if (result.type === "ExportNamedDeclaration" && (!result.exportKind || result.exportKind === "value") || result.type === "ExportAllDeclaration" && (!result.exportKind || result.exportKind === "value") || result.type === "ExportDefaultDeclaration") { - this.sawUnambiguousESM = true; - } - } - - this.assertModuleNodeAllowed(node); - return result; - } - - default: - { - if (this.isAsyncFunction()) { - if (context) { - this.raise(this.state.start, Errors.AsyncFunctionInSingleStatementContext); - } - - this.next(); - return this.parseFunctionStatement(node, true, !context); - } - } - } - - const maybeName = this.state.value; - const expr = this.parseExpression(); - - if (starttype === types.name && expr.type === "Identifier" && this.eat(types.colon)) { - return this.parseLabeledStatement(node, maybeName, expr, context); - } else { - return this.parseExpressionStatement(node, expr); - } - } - - assertModuleNodeAllowed(node) { - if (!this.options.allowImportExportEverywhere && !this.inModule) { - this.raiseWithData(node.start, { - code: "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED" - }, Errors.ImportOutsideModule); - } - } - - takeDecorators(node) { - const decorators = this.state.decoratorStack[this.state.decoratorStack.length - 1]; - - if (decorators.length) { - node.decorators = decorators; - this.resetStartLocationFromNode(node, decorators[0]); - this.state.decoratorStack[this.state.decoratorStack.length - 1] = []; - } - } - - canHaveLeadingDecorator() { - return this.match(types._class); - } - - parseDecorators(allowExport) { - const currentContextDecorators = this.state.decoratorStack[this.state.decoratorStack.length - 1]; - - while (this.match(types.at)) { - const decorator = this.parseDecorator(); - currentContextDecorators.push(decorator); - } - - if (this.match(types._export)) { - if (!allowExport) { - this.unexpected(); - } - - if (this.hasPlugin("decorators") && !this.getPluginOption("decorators", "decoratorsBeforeExport")) { - this.raise(this.state.start, Errors.DecoratorExportClass); - } - } else if (!this.canHaveLeadingDecorator()) { - throw this.raise(this.state.start, Errors.UnexpectedLeadingDecorator); - } - } - - parseDecorator() { - this.expectOnePlugin(["decorators-legacy", "decorators"]); - const node = this.startNode(); - this.next(); - - if (this.hasPlugin("decorators")) { - this.state.decoratorStack.push([]); - const startPos = this.state.start; - const startLoc = this.state.startLoc; - let expr; - - if (this.eat(types.parenL)) { - expr = this.parseExpression(); - this.expect(types.parenR); - } else { - expr = this.parseIdentifier(false); - - while (this.eat(types.dot)) { - const node = this.startNodeAt(startPos, startLoc); - node.object = expr; - node.property = this.parseIdentifier(true); - node.computed = false; - expr = this.finishNode(node, "MemberExpression"); - } - } - - node.expression = this.parseMaybeDecoratorArguments(expr); - this.state.decoratorStack.pop(); - } else { - node.expression = this.parseExprSubscripts(); - } - - return this.finishNode(node, "Decorator"); - } - - parseMaybeDecoratorArguments(expr) { - if (this.eat(types.parenL)) { - const node = this.startNodeAtNode(expr); - node.callee = expr; - node.arguments = this.parseCallExpressionArguments(types.parenR, false); - this.toReferencedList(node.arguments); - return this.finishNode(node, "CallExpression"); - } - - return expr; - } - - parseBreakContinueStatement(node, keyword) { - const isBreak = keyword === "break"; - this.next(); - - if (this.isLineTerminator()) { - node.label = null; - } else { - node.label = this.parseIdentifier(); - this.semicolon(); - } - - this.verifyBreakContinue(node, keyword); - return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement"); - } - - verifyBreakContinue(node, keyword) { - const isBreak = keyword === "break"; - let i; - - for (i = 0; i < this.state.labels.length; ++i) { - const lab = this.state.labels[i]; - - if (node.label == null || lab.name === node.label.name) { - if (lab.kind != null && (isBreak || lab.kind === "loop")) break; - if (node.label && isBreak) break; - } - } - - if (i === this.state.labels.length) { - this.raise(node.start, Errors.IllegalBreakContinue, keyword); - } - } - - parseDebuggerStatement(node) { - this.next(); - this.semicolon(); - return this.finishNode(node, "DebuggerStatement"); - } - - parseHeaderExpression() { - this.expect(types.parenL); - const val = this.parseExpression(); - this.expect(types.parenR); - return val; - } - - parseDoStatement(node) { - this.next(); - this.state.labels.push(loopLabel); - node.body = this.withTopicForbiddingContext(() => this.parseStatement("do")); - this.state.labels.pop(); - this.expect(types._while); - node.test = this.parseHeaderExpression(); - this.eat(types.semi); - return this.finishNode(node, "DoWhileStatement"); - } - - parseForStatement(node) { - this.next(); - this.state.labels.push(loopLabel); - let awaitAt = -1; - - if (this.isAwaitAllowed() && this.eatContextual("await")) { - awaitAt = this.state.lastTokStart; - } - - this.scope.enter(SCOPE_OTHER); - this.expect(types.parenL); - - if (this.match(types.semi)) { - if (awaitAt > -1) { - this.unexpected(awaitAt); - } - - return this.parseFor(node, null); - } - - const isLet = this.isLet(); - - if (this.match(types._var) || this.match(types._const) || isLet) { - const init = this.startNode(); - const kind = isLet ? "let" : this.state.value; - this.next(); - this.parseVar(init, true, kind); - this.finishNode(init, "VariableDeclaration"); - - if ((this.match(types._in) || this.isContextual("of")) && init.declarations.length === 1) { - return this.parseForIn(node, init, awaitAt); - } - - if (awaitAt > -1) { - this.unexpected(awaitAt); - } - - return this.parseFor(node, init); - } - - const refExpressionErrors = new ExpressionErrors(); - const init = this.parseExpression(true, refExpressionErrors); - - if (this.match(types._in) || this.isContextual("of")) { - this.toAssignable(init); - const description = this.isContextual("of") ? "for-of statement" : "for-in statement"; - this.checkLVal(init, undefined, undefined, description); - return this.parseForIn(node, init, awaitAt); - } else { - this.checkExpressionErrors(refExpressionErrors, true); - } - - if (awaitAt > -1) { - this.unexpected(awaitAt); - } - - return this.parseFor(node, init); - } - - parseFunctionStatement(node, isAsync, declarationPosition) { - this.next(); - return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), isAsync); - } - - parseIfStatement(node) { - this.next(); - node.test = this.parseHeaderExpression(); - node.consequent = this.parseStatement("if"); - node.alternate = this.eat(types._else) ? this.parseStatement("if") : null; - return this.finishNode(node, "IfStatement"); - } - - parseReturnStatement(node) { - if (!this.prodParam.hasReturn && !this.options.allowReturnOutsideFunction) { - this.raise(this.state.start, Errors.IllegalReturn); - } - - this.next(); - - if (this.isLineTerminator()) { - node.argument = null; - } else { - node.argument = this.parseExpression(); - this.semicolon(); - } - - return this.finishNode(node, "ReturnStatement"); - } - - parseSwitchStatement(node) { - this.next(); - node.discriminant = this.parseHeaderExpression(); - const cases = node.cases = []; - this.expect(types.braceL); - this.state.labels.push(switchLabel); - this.scope.enter(SCOPE_OTHER); - let cur; - - for (let sawDefault; !this.match(types.braceR);) { - if (this.match(types._case) || this.match(types._default)) { - const isCase = this.match(types._case); - if (cur) this.finishNode(cur, "SwitchCase"); - cases.push(cur = this.startNode()); - cur.consequent = []; - this.next(); - - if (isCase) { - cur.test = this.parseExpression(); - } else { - if (sawDefault) { - this.raise(this.state.lastTokStart, Errors.MultipleDefaultsInSwitch); - } - - sawDefault = true; - cur.test = null; - } - - this.expect(types.colon); - } else { - if (cur) { - cur.consequent.push(this.parseStatement(null)); - } else { - this.unexpected(); - } - } - } - - this.scope.exit(); - if (cur) this.finishNode(cur, "SwitchCase"); - this.next(); - this.state.labels.pop(); - return this.finishNode(node, "SwitchStatement"); - } - - parseThrowStatement(node) { - this.next(); - - if (lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.start))) { - this.raise(this.state.lastTokEnd, Errors.NewlineAfterThrow); - } - - node.argument = this.parseExpression(); - this.semicolon(); - return this.finishNode(node, "ThrowStatement"); - } - - parseTryStatement(node) { - this.next(); - node.block = this.parseBlock(); - node.handler = null; - - if (this.match(types._catch)) { - const clause = this.startNode(); - this.next(); - - if (this.match(types.parenL)) { - this.expect(types.parenL); - clause.param = this.parseBindingAtom(); - const simple = clause.param.type === "Identifier"; - this.scope.enter(simple ? SCOPE_SIMPLE_CATCH : 0); - this.checkLVal(clause.param, BIND_LEXICAL, null, "catch clause"); - this.expect(types.parenR); - } else { - clause.param = null; - this.scope.enter(SCOPE_OTHER); - } - - clause.body = this.withTopicForbiddingContext(() => this.parseBlock(false, false)); - this.scope.exit(); - node.handler = this.finishNode(clause, "CatchClause"); - } - - node.finalizer = this.eat(types._finally) ? this.parseBlock() : null; - - if (!node.handler && !node.finalizer) { - this.raise(node.start, Errors.NoCatchOrFinally); - } - - return this.finishNode(node, "TryStatement"); - } - - parseVarStatement(node, kind) { - this.next(); - this.parseVar(node, false, kind); - this.semicolon(); - return this.finishNode(node, "VariableDeclaration"); - } - - parseWhileStatement(node) { - this.next(); - node.test = this.parseHeaderExpression(); - this.state.labels.push(loopLabel); - node.body = this.withTopicForbiddingContext(() => this.parseStatement("while")); - this.state.labels.pop(); - return this.finishNode(node, "WhileStatement"); - } - - parseWithStatement(node) { - if (this.state.strict) { - this.raise(this.state.start, Errors.StrictWith); - } - - this.next(); - node.object = this.parseHeaderExpression(); - node.body = this.withTopicForbiddingContext(() => this.parseStatement("with")); - return this.finishNode(node, "WithStatement"); - } - - parseEmptyStatement(node) { - this.next(); - return this.finishNode(node, "EmptyStatement"); - } - - parseLabeledStatement(node, maybeName, expr, context) { - for (let _i2 = 0, _this$state$labels = this.state.labels; _i2 < _this$state$labels.length; _i2++) { - const label = _this$state$labels[_i2]; - - if (label.name === maybeName) { - this.raise(expr.start, Errors.LabelRedeclaration, maybeName); - } - } - - const kind = this.state.type.isLoop ? "loop" : this.match(types._switch) ? "switch" : null; - - for (let i = this.state.labels.length - 1; i >= 0; i--) { - const label = this.state.labels[i]; - - if (label.statementStart === node.start) { - label.statementStart = this.state.start; - label.kind = kind; - } else { - break; - } - } - - this.state.labels.push({ - name: maybeName, - kind: kind, - statementStart: this.state.start - }); - node.body = this.parseStatement(context ? context.indexOf("label") === -1 ? context + "label" : context : "label"); - this.state.labels.pop(); - node.label = expr; - return this.finishNode(node, "LabeledStatement"); - } - - parseExpressionStatement(node, expr) { - node.expression = expr; - this.semicolon(); - return this.finishNode(node, "ExpressionStatement"); - } - - parseBlock(allowDirectives = false, createNewLexicalScope = true, afterBlockParse) { - const node = this.startNode(); - this.expect(types.braceL); - - if (createNewLexicalScope) { - this.scope.enter(SCOPE_OTHER); - } - - this.parseBlockBody(node, allowDirectives, false, types.braceR, afterBlockParse); - - if (createNewLexicalScope) { - this.scope.exit(); - } - - return this.finishNode(node, "BlockStatement"); - } - - isValidDirective(stmt) { - return stmt.type === "ExpressionStatement" && stmt.expression.type === "StringLiteral" && !stmt.expression.extra.parenthesized; - } - - parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse) { - const body = node.body = []; - const directives = node.directives = []; - this.parseBlockOrModuleBlockBody(body, allowDirectives ? directives : undefined, topLevel, end, afterBlockParse); - } - - parseBlockOrModuleBlockBody(body, directives, topLevel, end, afterBlockParse) { - const octalPositions = []; - const oldStrict = this.state.strict; - let hasStrictModeDirective = false; - let parsedNonDirective = false; - - while (!this.match(end)) { - if (!parsedNonDirective && this.state.octalPositions.length) { - octalPositions.push(...this.state.octalPositions); - } - - const stmt = this.parseStatement(null, topLevel); - - if (directives && !parsedNonDirective && this.isValidDirective(stmt)) { - const directive = this.stmtToDirective(stmt); - directives.push(directive); - - if (!hasStrictModeDirective && directive.value.value === "use strict") { - hasStrictModeDirective = true; - this.setStrict(true); - } - - continue; - } - - parsedNonDirective = true; - body.push(stmt); - } - - if (this.state.strict && octalPositions.length) { - for (let _i3 = 0; _i3 < octalPositions.length; _i3++) { - const pos = octalPositions[_i3]; - this.raise(pos, Errors.StrictOctalLiteral); - } - } - - if (afterBlockParse) { - afterBlockParse.call(this, hasStrictModeDirective); - } - - if (!oldStrict) { - this.setStrict(false); - } - - this.next(); - } - - parseFor(node, init) { - node.init = init; - this.expect(types.semi); - node.test = this.match(types.semi) ? null : this.parseExpression(); - this.expect(types.semi); - node.update = this.match(types.parenR) ? null : this.parseExpression(); - this.expect(types.parenR); - node.body = this.withTopicForbiddingContext(() => this.parseStatement("for")); - this.scope.exit(); - this.state.labels.pop(); - return this.finishNode(node, "ForStatement"); - } - - parseForIn(node, init, awaitAt) { - const isForIn = this.match(types._in); - this.next(); - - if (isForIn) { - if (awaitAt > -1) this.unexpected(awaitAt); - } else { - node.await = awaitAt > -1; - } - - if (init.type === "VariableDeclaration" && init.declarations[0].init != null && (!isForIn || this.state.strict || init.kind !== "var" || init.declarations[0].id.type !== "Identifier")) { - this.raise(init.start, Errors.ForInOfLoopInitializer, isForIn ? "for-in" : "for-of"); - } else if (init.type === "AssignmentPattern") { - this.raise(init.start, Errors.InvalidLhs, "for-loop"); - } - - node.left = init; - node.right = isForIn ? this.parseExpression() : this.parseMaybeAssign(); - this.expect(types.parenR); - node.body = this.withTopicForbiddingContext(() => this.parseStatement("for")); - this.scope.exit(); - this.state.labels.pop(); - return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement"); - } - - parseVar(node, isFor, kind) { - const declarations = node.declarations = []; - const isTypescript = this.hasPlugin("typescript"); - node.kind = kind; - - for (;;) { - const decl = this.startNode(); - this.parseVarId(decl, kind); - - if (this.eat(types.eq)) { - decl.init = this.parseMaybeAssign(isFor); - } else { - if (kind === "const" && !(this.match(types._in) || this.isContextual("of"))) { - if (!isTypescript) { - this.unexpected(); - } - } else if (decl.id.type !== "Identifier" && !(isFor && (this.match(types._in) || this.isContextual("of")))) { - this.raise(this.state.lastTokEnd, Errors.DeclarationMissingInitializer, "Complex binding patterns"); - } - - decl.init = null; - } - - declarations.push(this.finishNode(decl, "VariableDeclarator")); - if (!this.eat(types.comma)) break; - } - - return node; - } - - parseVarId(decl, kind) { - decl.id = this.parseBindingAtom(); - this.checkLVal(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, undefined, "variable declaration", kind !== "var"); - } - - parseFunction(node, statement = FUNC_NO_FLAGS, isAsync = false) { - const isStatement = statement & FUNC_STATEMENT; - const isHangingStatement = statement & FUNC_HANGING_STATEMENT; - const requireId = !!isStatement && !(statement & FUNC_NULLABLE_ID); - this.initFunction(node, isAsync); - - if (this.match(types.star) && isHangingStatement) { - this.raise(this.state.start, Errors.GeneratorInSingleStatementContext); - } - - node.generator = this.eat(types.star); - - if (isStatement) { - node.id = this.parseFunctionId(requireId); - } - - const oldMaybeInArrowParameters = this.state.maybeInArrowParameters; - const oldYieldPos = this.state.yieldPos; - const oldAwaitPos = this.state.awaitPos; - this.state.maybeInArrowParameters = false; - this.state.yieldPos = -1; - this.state.awaitPos = -1; - this.scope.enter(SCOPE_FUNCTION); - this.prodParam.enter(functionFlags(isAsync, node.generator)); - - if (!isStatement) { - node.id = this.parseFunctionId(); - } - - this.parseFunctionParams(node); - this.withTopicForbiddingContext(() => { - this.parseFunctionBodyAndFinish(node, isStatement ? "FunctionDeclaration" : "FunctionExpression"); - }); - this.prodParam.exit(); - this.scope.exit(); - - if (isStatement && !isHangingStatement) { - this.registerFunctionStatementId(node); - } - - this.state.maybeInArrowParameters = oldMaybeInArrowParameters; - this.state.yieldPos = oldYieldPos; - this.state.awaitPos = oldAwaitPos; - return node; - } - - parseFunctionId(requireId) { - return requireId || this.match(types.name) ? this.parseIdentifier() : null; - } - - parseFunctionParams(node, allowModifiers) { - const oldInParameters = this.state.inParameters; - this.state.inParameters = true; - this.expect(types.parenL); - node.params = this.parseBindingList(types.parenR, 41, false, allowModifiers); - this.state.inParameters = oldInParameters; - this.checkYieldAwaitInDefaultParams(); - } - - registerFunctionStatementId(node) { - if (!node.id) return; - this.scope.declareName(node.id.name, this.state.strict || node.generator || node.async ? this.scope.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION, node.id.start); - } - - parseClass(node, isStatement, optionalId) { - this.next(); - this.takeDecorators(node); - const oldStrict = this.state.strict; - this.state.strict = true; - this.parseClassId(node, isStatement, optionalId); - this.parseClassSuper(node); - node.body = this.parseClassBody(!!node.superClass, oldStrict); - this.state.strict = oldStrict; - return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression"); - } - - isClassProperty() { - return this.match(types.eq) || this.match(types.semi) || this.match(types.braceR); - } - - isClassMethod() { - return this.match(types.parenL); - } - - isNonstaticConstructor(method) { - return !method.computed && !method.static && (method.key.name === "constructor" || method.key.value === "constructor"); - } - - parseClassBody(constructorAllowsSuper, oldStrict) { - this.classScope.enter(); - const state = { - hadConstructor: false - }; - let decorators = []; - const classBody = this.startNode(); - classBody.body = []; - this.expect(types.braceL); - this.withTopicForbiddingContext(() => { - while (!this.match(types.braceR)) { - if (this.eat(types.semi)) { - if (decorators.length > 0) { - throw this.raise(this.state.lastTokEnd, Errors.DecoratorSemicolon); - } - - continue; - } - - if (this.match(types.at)) { - decorators.push(this.parseDecorator()); - continue; - } - - const member = this.startNode(); - - if (decorators.length) { - member.decorators = decorators; - this.resetStartLocationFromNode(member, decorators[0]); - decorators = []; - } - - this.parseClassMember(classBody, member, state, constructorAllowsSuper); - - if (member.kind === "constructor" && member.decorators && member.decorators.length > 0) { - this.raise(member.start, Errors.DecoratorConstructor); - } - } - }); - - if (!oldStrict) { - this.state.strict = false; - } - - this.next(); - - if (decorators.length) { - throw this.raise(this.state.start, Errors.TrailingDecorator); - } - - this.classScope.exit(); - return this.finishNode(classBody, "ClassBody"); - } - - parseClassMemberFromModifier(classBody, member) { - const containsEsc = this.state.containsEsc; - const key = this.parseIdentifier(true); - - if (this.isClassMethod()) { - const method = member; - method.kind = "method"; - method.computed = false; - method.key = key; - method.static = false; - this.pushClassMethod(classBody, method, false, false, false, false); - return true; - } else if (this.isClassProperty()) { - const prop = member; - prop.computed = false; - prop.key = key; - prop.static = false; - classBody.body.push(this.parseClassProperty(prop)); - return true; - } else if (containsEsc) { - throw this.unexpected(); - } - - return false; - } - - parseClassMember(classBody, member, state, constructorAllowsSuper) { - const isStatic = this.isContextual("static"); - - if (isStatic && this.parseClassMemberFromModifier(classBody, member)) { - return; - } - - this.parseClassMemberWithIsStatic(classBody, member, state, isStatic, constructorAllowsSuper); - } - - parseClassMemberWithIsStatic(classBody, member, state, isStatic, constructorAllowsSuper) { - const publicMethod = member; - const privateMethod = member; - const publicProp = member; - const privateProp = member; - const method = publicMethod; - const publicMember = publicMethod; - member.static = isStatic; - - if (this.eat(types.star)) { - method.kind = "method"; - this.parseClassPropertyName(method); - - if (method.key.type === "PrivateName") { - this.pushClassPrivateMethod(classBody, privateMethod, true, false); - return; - } - - if (this.isNonstaticConstructor(publicMethod)) { - this.raise(publicMethod.key.start, Errors.ConstructorIsGenerator); - } - - this.pushClassMethod(classBody, publicMethod, true, false, false, false); - return; - } - - const containsEsc = this.state.containsEsc; - const key = this.parseClassPropertyName(member); - const isPrivate = key.type === "PrivateName"; - const isSimple = key.type === "Identifier"; - const maybeQuestionTokenStart = this.state.start; - this.parsePostMemberNameModifiers(publicMember); - - if (this.isClassMethod()) { - method.kind = "method"; - - if (isPrivate) { - this.pushClassPrivateMethod(classBody, privateMethod, false, false); - return; - } - - const isConstructor = this.isNonstaticConstructor(publicMethod); - let allowsDirectSuper = false; - - if (isConstructor) { - publicMethod.kind = "constructor"; - - if (state.hadConstructor && !this.hasPlugin("typescript")) { - this.raise(key.start, Errors.DuplicateConstructor); - } - - state.hadConstructor = true; - allowsDirectSuper = constructorAllowsSuper; - } - - this.pushClassMethod(classBody, publicMethod, false, false, isConstructor, allowsDirectSuper); - } else if (this.isClassProperty()) { - if (isPrivate) { - this.pushClassPrivateProperty(classBody, privateProp); - } else { - this.pushClassProperty(classBody, publicProp); - } - } else if (isSimple && key.name === "async" && !containsEsc && !this.isLineTerminator()) { - const isGenerator = this.eat(types.star); - - if (publicMember.optional) { - this.unexpected(maybeQuestionTokenStart); - } - - method.kind = "method"; - this.parseClassPropertyName(method); - this.parsePostMemberNameModifiers(publicMember); - - if (method.key.type === "PrivateName") { - this.pushClassPrivateMethod(classBody, privateMethod, isGenerator, true); - } else { - if (this.isNonstaticConstructor(publicMethod)) { - this.raise(publicMethod.key.start, Errors.ConstructorIsAsync); - } - - this.pushClassMethod(classBody, publicMethod, isGenerator, true, false, false); - } - } else if (isSimple && (key.name === "get" || key.name === "set") && !containsEsc && !(this.match(types.star) && this.isLineTerminator())) { - method.kind = key.name; - this.parseClassPropertyName(publicMethod); - - if (method.key.type === "PrivateName") { - this.pushClassPrivateMethod(classBody, privateMethod, false, false); - } else { - if (this.isNonstaticConstructor(publicMethod)) { - this.raise(publicMethod.key.start, Errors.ConstructorIsAccessor); - } - - this.pushClassMethod(classBody, publicMethod, false, false, false, false); - } - - this.checkGetterSetterParams(publicMethod); - } else if (this.isLineTerminator()) { - if (isPrivate) { - this.pushClassPrivateProperty(classBody, privateProp); - } else { - this.pushClassProperty(classBody, publicProp); - } - } else { - this.unexpected(); - } - } - - parseClassPropertyName(member) { - const key = this.parsePropertyName(member, true); - - if (!member.computed && member.static && (key.name === "prototype" || key.value === "prototype")) { - this.raise(key.start, Errors.StaticPrototype); - } - - if (key.type === "PrivateName" && key.id.name === "constructor") { - this.raise(key.start, Errors.ConstructorClassPrivateField); - } - - return key; - } - - pushClassProperty(classBody, prop) { - if (!prop.computed && (prop.key.name === "constructor" || prop.key.value === "constructor")) { - this.raise(prop.key.start, Errors.ConstructorClassField); - } - - classBody.body.push(this.parseClassProperty(prop)); - } - - pushClassPrivateProperty(classBody, prop) { - this.expectPlugin("classPrivateProperties", prop.key.start); - const node = this.parseClassPrivateProperty(prop); - classBody.body.push(node); - this.classScope.declarePrivateName(node.key.id.name, CLASS_ELEMENT_OTHER, node.key.start); - } - - pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) { - classBody.body.push(this.parseMethod(method, isGenerator, isAsync, isConstructor, allowsDirectSuper, "ClassMethod", true)); - } - - pushClassPrivateMethod(classBody, method, isGenerator, isAsync) { - this.expectPlugin("classPrivateMethods", method.key.start); - const node = this.parseMethod(method, isGenerator, isAsync, false, false, "ClassPrivateMethod", true); - classBody.body.push(node); - const kind = node.kind === "get" ? node.static ? CLASS_ELEMENT_STATIC_GETTER : CLASS_ELEMENT_INSTANCE_GETTER : node.kind === "set" ? node.static ? CLASS_ELEMENT_STATIC_SETTER : CLASS_ELEMENT_INSTANCE_SETTER : CLASS_ELEMENT_OTHER; - this.classScope.declarePrivateName(node.key.id.name, kind, node.key.start); - } - - parsePostMemberNameModifiers(methodOrProp) {} - - parseAccessModifier() { - return undefined; - } - - parseClassPrivateProperty(node) { - this.scope.enter(SCOPE_CLASS | SCOPE_SUPER); - this.prodParam.enter(PARAM); - node.value = this.eat(types.eq) ? this.parseMaybeAssign() : null; - this.semicolon(); - this.prodParam.exit(); - this.scope.exit(); - return this.finishNode(node, "ClassPrivateProperty"); - } - - parseClassProperty(node) { - if (!node.typeAnnotation) { - this.expectPlugin("classProperties"); - } - - this.scope.enter(SCOPE_CLASS | SCOPE_SUPER); - this.prodParam.enter(PARAM); - - if (this.match(types.eq)) { - this.expectPlugin("classProperties"); - this.next(); - node.value = this.parseMaybeAssign(); - } else { - node.value = null; - } - - this.semicolon(); - this.prodParam.exit(); - this.scope.exit(); - return this.finishNode(node, "ClassProperty"); - } - - parseClassId(node, isStatement, optionalId, bindingType = BIND_CLASS) { - if (this.match(types.name)) { - node.id = this.parseIdentifier(); - - if (isStatement) { - this.checkLVal(node.id, bindingType, undefined, "class name"); - } - } else { - if (optionalId || !isStatement) { - node.id = null; - } else { - this.unexpected(null, Errors.MissingClassName); - } - } - } - - parseClassSuper(node) { - node.superClass = this.eat(types._extends) ? this.parseExprSubscripts() : null; - } - - parseExport(node) { - const hasDefault = this.maybeParseExportDefaultSpecifier(node); - const parseAfterDefault = !hasDefault || this.eat(types.comma); - const hasStar = parseAfterDefault && this.eatExportStar(node); - const hasNamespace = hasStar && this.maybeParseExportNamespaceSpecifier(node); - const parseAfterNamespace = parseAfterDefault && (!hasNamespace || this.eat(types.comma)); - const isFromRequired = hasDefault || hasStar; - - if (hasStar && !hasNamespace) { - if (hasDefault) this.unexpected(); - this.parseExportFrom(node, true); - return this.finishNode(node, "ExportAllDeclaration"); - } - - const hasSpecifiers = this.maybeParseExportNamedSpecifiers(node); - - if (hasDefault && parseAfterDefault && !hasStar && !hasSpecifiers || hasNamespace && parseAfterNamespace && !hasSpecifiers) { - throw this.unexpected(null, types.braceL); - } - - let hasDeclaration; - - if (isFromRequired || hasSpecifiers) { - hasDeclaration = false; - this.parseExportFrom(node, isFromRequired); - } else { - hasDeclaration = this.maybeParseExportDeclaration(node); - } - - if (isFromRequired || hasSpecifiers || hasDeclaration) { - this.checkExport(node, true, false, !!node.source); - return this.finishNode(node, "ExportNamedDeclaration"); - } - - if (this.eat(types._default)) { - node.declaration = this.parseExportDefaultExpression(); - this.checkExport(node, true, true); - return this.finishNode(node, "ExportDefaultDeclaration"); - } - - throw this.unexpected(null, types.braceL); - } - - eatExportStar(node) { - return this.eat(types.star); - } - - maybeParseExportDefaultSpecifier(node) { - if (this.isExportDefaultSpecifier()) { - this.expectPlugin("exportDefaultFrom"); - const specifier = this.startNode(); - specifier.exported = this.parseIdentifier(true); - node.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")]; - return true; - } - - return false; - } - - maybeParseExportNamespaceSpecifier(node) { - if (this.isContextual("as")) { - if (!node.specifiers) node.specifiers = []; - const specifier = this.startNodeAt(this.state.lastTokStart, this.state.lastTokStartLoc); - this.next(); - specifier.exported = this.parseIdentifier(true); - node.specifiers.push(this.finishNode(specifier, "ExportNamespaceSpecifier")); - return true; - } - - return false; - } - - maybeParseExportNamedSpecifiers(node) { - if (this.match(types.braceL)) { - if (!node.specifiers) node.specifiers = []; - node.specifiers.push(...this.parseExportSpecifiers()); - node.source = null; - node.declaration = null; - return true; - } - - return false; - } - - maybeParseExportDeclaration(node) { - if (this.shouldParseExportDeclaration()) { - if (this.isContextual("async")) { - const next = this.nextTokenStart(); - - if (!this.isUnparsedContextual(next, "function")) { - this.unexpected(next, types._function); - } - } - - node.specifiers = []; - node.source = null; - node.declaration = this.parseExportDeclaration(node); - return true; - } - - return false; - } - - isAsyncFunction() { - if (!this.isContextual("async")) return false; - const next = this.nextTokenStart(); - return !lineBreak.test(this.input.slice(this.state.pos, next)) && this.isUnparsedContextual(next, "function"); - } - - parseExportDefaultExpression() { - const expr = this.startNode(); - const isAsync = this.isAsyncFunction(); - - if (this.match(types._function) || isAsync) { - this.next(); - - if (isAsync) { - this.next(); - } - - return this.parseFunction(expr, FUNC_STATEMENT | FUNC_NULLABLE_ID, isAsync); - } else if (this.match(types._class)) { - return this.parseClass(expr, true, true); - } else if (this.match(types.at)) { - if (this.hasPlugin("decorators") && this.getPluginOption("decorators", "decoratorsBeforeExport")) { - this.raise(this.state.start, Errors.DecoratorBeforeExport); - } - - this.parseDecorators(false); - return this.parseClass(expr, true, true); - } else if (this.match(types._const) || this.match(types._var) || this.isLet()) { - throw this.raise(this.state.start, Errors.UnsupportedDefaultExport); - } else { - const res = this.parseMaybeAssign(); - this.semicolon(); - return res; - } - } - - parseExportDeclaration(node) { - return this.parseStatement(null); - } - - isExportDefaultSpecifier() { - if (this.match(types.name)) { - return this.state.value !== "async" && this.state.value !== "let"; - } - - if (!this.match(types._default)) { - return false; - } - - const next = this.nextTokenStart(); - return this.input.charCodeAt(next) === 44 || this.isUnparsedContextual(next, "from"); - } - - parseExportFrom(node, expect) { - if (this.eatContextual("from")) { - node.source = this.parseImportSource(); - this.checkExport(node); - } else { - if (expect) { - this.unexpected(); - } else { - node.source = null; - } - } - - this.semicolon(); - } - - shouldParseExportDeclaration() { - if (this.match(types.at)) { - this.expectOnePlugin(["decorators", "decorators-legacy"]); - - if (this.hasPlugin("decorators")) { - if (this.getPluginOption("decorators", "decoratorsBeforeExport")) { - this.unexpected(this.state.start, Errors.DecoratorBeforeExport); - } else { - return true; - } - } - } - - return this.state.type.keyword === "var" || this.state.type.keyword === "const" || this.state.type.keyword === "function" || this.state.type.keyword === "class" || this.isLet() || this.isAsyncFunction(); - } - - checkExport(node, checkNames, isDefault, isFrom) { - if (checkNames) { - if (isDefault) { - this.checkDuplicateExports(node, "default"); - } else if (node.specifiers && node.specifiers.length) { - for (let _i4 = 0, _node$specifiers = node.specifiers; _i4 < _node$specifiers.length; _i4++) { - const specifier = _node$specifiers[_i4]; - this.checkDuplicateExports(specifier, specifier.exported.name); - - if (!isFrom && specifier.local) { - this.checkReservedWord(specifier.local.name, specifier.local.start, true, false); - this.scope.checkLocalExport(specifier.local); - } - } - } else if (node.declaration) { - if (node.declaration.type === "FunctionDeclaration" || node.declaration.type === "ClassDeclaration") { - const id = node.declaration.id; - if (!id) throw new Error("Assertion failure"); - this.checkDuplicateExports(node, id.name); - } else if (node.declaration.type === "VariableDeclaration") { - for (let _i5 = 0, _node$declaration$dec = node.declaration.declarations; _i5 < _node$declaration$dec.length; _i5++) { - const declaration = _node$declaration$dec[_i5]; - this.checkDeclaration(declaration.id); - } - } - } - } - - const currentContextDecorators = this.state.decoratorStack[this.state.decoratorStack.length - 1]; - - if (currentContextDecorators.length) { - const isClass = node.declaration && (node.declaration.type === "ClassDeclaration" || node.declaration.type === "ClassExpression"); - - if (!node.declaration || !isClass) { - throw this.raise(node.start, Errors.UnsupportedDecoratorExport); - } - - this.takeDecorators(node.declaration); - } - } - - checkDeclaration(node) { - if (node.type === "Identifier") { - this.checkDuplicateExports(node, node.name); - } else if (node.type === "ObjectPattern") { - for (let _i6 = 0, _node$properties = node.properties; _i6 < _node$properties.length; _i6++) { - const prop = _node$properties[_i6]; - this.checkDeclaration(prop); - } - } else if (node.type === "ArrayPattern") { - for (let _i7 = 0, _node$elements = node.elements; _i7 < _node$elements.length; _i7++) { - const elem = _node$elements[_i7]; - - if (elem) { - this.checkDeclaration(elem); - } - } - } else if (node.type === "ObjectProperty") { - this.checkDeclaration(node.value); - } else if (node.type === "RestElement") { - this.checkDeclaration(node.argument); - } else if (node.type === "AssignmentPattern") { - this.checkDeclaration(node.left); - } - } - - checkDuplicateExports(node, name) { - if (this.state.exportedIdentifiers.indexOf(name) > -1) { - this.raise(node.start, name === "default" ? Errors.DuplicateDefaultExport : Errors.DuplicateExport, name); - } - - this.state.exportedIdentifiers.push(name); - } - - parseExportSpecifiers() { - const nodes = []; - let first = true; - this.expect(types.braceL); - - while (!this.eat(types.braceR)) { - if (first) { - first = false; - } else { - this.expect(types.comma); - if (this.eat(types.braceR)) break; - } - - const node = this.startNode(); - node.local = this.parseIdentifier(true); - node.exported = this.eatContextual("as") ? this.parseIdentifier(true) : node.local.__clone(); - nodes.push(this.finishNode(node, "ExportSpecifier")); - } - - return nodes; - } - - parseImport(node) { - node.specifiers = []; - - if (!this.match(types.string)) { - const hasDefault = this.maybeParseDefaultImportSpecifier(node); - const parseNext = !hasDefault || this.eat(types.comma); - const hasStar = parseNext && this.maybeParseStarImportSpecifier(node); - if (parseNext && !hasStar) this.parseNamedImportSpecifiers(node); - this.expectContextual("from"); - } - - node.source = this.parseImportSource(); - this.semicolon(); - return this.finishNode(node, "ImportDeclaration"); - } - - parseImportSource() { - if (!this.match(types.string)) this.unexpected(); - return this.parseExprAtom(); - } - - shouldParseDefaultImport(node) { - return this.match(types.name); - } - - parseImportSpecifierLocal(node, specifier, type, contextDescription) { - specifier.local = this.parseIdentifier(); - this.checkLVal(specifier.local, BIND_LEXICAL, undefined, contextDescription); - node.specifiers.push(this.finishNode(specifier, type)); - } - - maybeParseDefaultImportSpecifier(node) { - if (this.shouldParseDefaultImport(node)) { - this.parseImportSpecifierLocal(node, this.startNode(), "ImportDefaultSpecifier", "default import specifier"); - return true; - } - - return false; - } - - maybeParseStarImportSpecifier(node) { - if (this.match(types.star)) { - const specifier = this.startNode(); - this.next(); - this.expectContextual("as"); - this.parseImportSpecifierLocal(node, specifier, "ImportNamespaceSpecifier", "import namespace specifier"); - return true; - } - - return false; - } - - parseNamedImportSpecifiers(node) { - let first = true; - this.expect(types.braceL); - - while (!this.eat(types.braceR)) { - if (first) { - first = false; - } else { - if (this.eat(types.colon)) { - throw this.raise(this.state.start, Errors.DestructureNamedImport); - } - - this.expect(types.comma); - if (this.eat(types.braceR)) break; - } - - this.parseImportSpecifier(node); - } - } - - parseImportSpecifier(node) { - const specifier = this.startNode(); - specifier.imported = this.parseIdentifier(true); - - if (this.eatContextual("as")) { - specifier.local = this.parseIdentifier(); - } else { - this.checkReservedWord(specifier.imported.name, specifier.start, true, true); - specifier.local = specifier.imported.__clone(); - } - - this.checkLVal(specifier.local, BIND_LEXICAL, undefined, "import specifier"); - node.specifiers.push(this.finishNode(specifier, "ImportSpecifier")); - } - -} - -class ClassScope { - constructor() { - this.privateNames = new Set(); - this.loneAccessors = new Map(); - this.undefinedPrivateNames = new Map(); - } - -} -class ClassScopeHandler { - constructor(raise) { - this.stack = []; - this.undefinedPrivateNames = new Map(); - this.raise = raise; - } - - current() { - return this.stack[this.stack.length - 1]; - } - - enter() { - this.stack.push(new ClassScope()); - } - - exit() { - const oldClassScope = this.stack.pop(); - const current = this.current(); - - for (let _i = 0, _Array$from = Array.from(oldClassScope.undefinedPrivateNames); _i < _Array$from.length; _i++) { - const [name, pos] = _Array$from[_i]; - - if (current) { - if (!current.undefinedPrivateNames.has(name)) { - current.undefinedPrivateNames.set(name, pos); - } - } else { - this.raise(pos, Errors.InvalidPrivateFieldResolution, name); - } - } - } - - declarePrivateName(name, elementType, pos) { - const classScope = this.current(); - let redefined = classScope.privateNames.has(name); - - if (elementType & CLASS_ELEMENT_KIND_ACCESSOR) { - const accessor = redefined && classScope.loneAccessors.get(name); - - if (accessor) { - const oldStatic = accessor & CLASS_ELEMENT_FLAG_STATIC; - const newStatic = elementType & CLASS_ELEMENT_FLAG_STATIC; - const oldKind = accessor & CLASS_ELEMENT_KIND_ACCESSOR; - const newKind = elementType & CLASS_ELEMENT_KIND_ACCESSOR; - redefined = oldKind === newKind || oldStatic !== newStatic; - if (!redefined) classScope.loneAccessors.delete(name); - } else if (!redefined) { - classScope.loneAccessors.set(name, elementType); - } - } - - if (redefined) { - this.raise(pos, Errors.PrivateNameRedeclaration, name); - } - - classScope.privateNames.add(name); - classScope.undefinedPrivateNames.delete(name); - } - - usePrivateName(name, pos) { - let classScope; - - for (let _i2 = 0, _this$stack = this.stack; _i2 < _this$stack.length; _i2++) { - classScope = _this$stack[_i2]; - if (classScope.privateNames.has(name)) return; - } - - if (classScope) { - classScope.undefinedPrivateNames.set(name, pos); - } else { - this.raise(pos, Errors.InvalidPrivateFieldResolution, name); - } - } - -} - -class Parser extends StatementParser { - constructor(options, input) { - options = getOptions(options); - super(options, input); - const ScopeHandler = this.getScopeHandler(); - this.options = options; - this.inModule = this.options.sourceType === "module"; - this.scope = new ScopeHandler(this.raise.bind(this), this.inModule); - this.prodParam = new ProductionParameterHandler(); - this.classScope = new ClassScopeHandler(this.raise.bind(this)); - this.plugins = pluginsMap(this.options.plugins); - this.filename = options.sourceFilename; - } - - getScopeHandler() { - return ScopeHandler; - } - - parse() { - let paramFlags = PARAM; - - if (this.hasPlugin("topLevelAwait") && this.inModule) { - paramFlags |= PARAM_AWAIT; - } - - this.scope.enter(SCOPE_PROGRAM); - this.prodParam.enter(paramFlags); - const file = this.startNode(); - const program = this.startNode(); - this.nextToken(); - file.errors = null; - this.parseTopLevel(file, program); - file.errors = this.state.errors; - return file; - } - -} - -function pluginsMap(plugins) { - const pluginMap = new Map(); - - for (let _i = 0; _i < plugins.length; _i++) { - const plugin = plugins[_i]; - const [name, options] = Array.isArray(plugin) ? plugin : [plugin, {}]; - if (!pluginMap.has(name)) pluginMap.set(name, options || {}); - } - - return pluginMap; -} - -function parse(input, options) { - if (options && options.sourceType === "unambiguous") { - options = Object.assign({}, options); - - try { - options.sourceType = "module"; - const parser = getParser(options, input); - const ast = parser.parse(); - - if (parser.sawUnambiguousESM) { - return ast; - } - - if (parser.ambiguousScriptDifferentAst) { - try { - options.sourceType = "script"; - return getParser(options, input).parse(); - } catch (_unused) {} - } else { - ast.program.sourceType = "script"; - } - - return ast; - } catch (moduleError) { - try { - options.sourceType = "script"; - return getParser(options, input).parse(); - } catch (_unused2) {} - - throw moduleError; - } - } else { - return getParser(options, input).parse(); - } -} -function parseExpression(input, options) { - const parser = getParser(options, input); - - if (parser.options.strictMode) { - parser.state.strict = true; - } - - return parser.getExpression(); -} - -function getParser(options, input) { - let cls = Parser; - - if (options && options.plugins) { - validatePlugins(options.plugins); - cls = getParserClass(options.plugins); - } - - return new cls(options, input); -} - -const parserClassCache = {}; - -function getParserClass(pluginsFromOptions) { - const pluginList = mixinPluginNames.filter(name => hasPlugin(pluginsFromOptions, name)); - const key = pluginList.join("/"); - let cls = parserClassCache[key]; - - if (!cls) { - cls = Parser; - - for (let _i = 0; _i < pluginList.length; _i++) { - const plugin = pluginList[_i]; - cls = mixinPlugins[plugin](cls); - } - - parserClassCache[key] = cls; - } - - return cls; -} - -exports.parse = parse; -exports.parseExpression = parseExpression; -exports.tokTypes = types; -//# sourceMappingURL=index.js.map diff --git a/node_modules/@babel/parser/lib/index.js.map b/node_modules/@babel/parser/lib/index.js.map deleted file mode 100644 index 2f331d33..00000000 --- a/node_modules/@babel/parser/lib/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../src/tokenizer/types.js","../src/util/scopeflags.js","../src/util/whitespace.js","../src/util/location.js","../src/parser/base.js","../src/parser/comments.js","../src/parser/location.js","../src/plugins/estree.js","../src/tokenizer/context.js","../../babel-helper-validator-identifier/src/identifier.js","../../babel-helper-validator-identifier/src/keyword.js","../src/util/identifier.js","../src/plugins/flow.js","../src/plugins/jsx/xhtml.js","../src/plugins/jsx/index.js","../src/util/scope.js","../src/plugins/typescript/scope.js","../src/util/production-parameter.js","../src/plugins/typescript/index.js","../src/plugins/placeholders.js","../src/plugins/v8intrinsic.js","../src/plugin-utils.js","../src/options.js","../src/tokenizer/state.js","../src/tokenizer/index.js","../src/parser/util.js","../src/parser/node.js","../src/parser/lval.js","../src/parser/expression.js","../src/parser/statement.js","../src/util/class-scope.js","../src/parser/index.js","../src/index.js"],"sourcesContent":["// @flow\n\n// ## Token types\n\n// The assignment of fine-grained, information-carrying type objects\n// allows the tokenizer to store the information it has about a\n// token in a way that is very cheap for the parser to look up.\n\n// All token type variables start with an underscore, to make them\n// easy to recognize.\n\n// The `beforeExpr` property is used to disambiguate between regular\n// expressions and divisions. It is set on all token types that can\n// be followed by an expression (thus, a slash after them would be a\n// regular expression).\n\n// The `startsExpr` property is used to determine whether an expression\n// may be the β€œargument” subexpression of a `yield` expression or\n// `yield` statement. It is set on all token types that may be at the\n// start of a subexpression.\n\n// `isLoop` marks a keyword as starting a loop, which is important\n// to know when parsing a label, in order to allow or disallow\n// continue jumps to that label.\n\nconst beforeExpr = true;\nconst startsExpr = true;\nconst isLoop = true;\nconst isAssign = true;\nconst prefix = true;\nconst postfix = true;\n\ntype TokenOptions = {\n keyword?: string,\n beforeExpr?: boolean,\n startsExpr?: boolean,\n rightAssociative?: boolean,\n isLoop?: boolean,\n isAssign?: boolean,\n prefix?: boolean,\n postfix?: boolean,\n binop?: ?number,\n};\n\nexport class TokenType {\n label: string;\n keyword: ?string;\n beforeExpr: boolean;\n startsExpr: boolean;\n rightAssociative: boolean;\n isLoop: boolean;\n isAssign: boolean;\n prefix: boolean;\n postfix: boolean;\n binop: ?number;\n updateContext: ?(prevType: TokenType) => void;\n\n constructor(label: string, conf: TokenOptions = {}) {\n this.label = label;\n this.keyword = conf.keyword;\n this.beforeExpr = !!conf.beforeExpr;\n this.startsExpr = !!conf.startsExpr;\n this.rightAssociative = !!conf.rightAssociative;\n this.isLoop = !!conf.isLoop;\n this.isAssign = !!conf.isAssign;\n this.prefix = !!conf.prefix;\n this.postfix = !!conf.postfix;\n this.binop = conf.binop != null ? conf.binop : null;\n this.updateContext = null;\n }\n}\n\nexport const keywords = new Map();\n\nfunction createKeyword(name: string, options: TokenOptions = {}): TokenType {\n options.keyword = name;\n const token = new TokenType(name, options);\n keywords.set(name, token);\n return token;\n}\n\nfunction createBinop(name: string, binop: number) {\n return new TokenType(name, { beforeExpr, binop });\n}\n\nexport const types: { [name: string]: TokenType } = {\n num: new TokenType(\"num\", { startsExpr }),\n bigint: new TokenType(\"bigint\", { startsExpr }),\n regexp: new TokenType(\"regexp\", { startsExpr }),\n string: new TokenType(\"string\", { startsExpr }),\n name: new TokenType(\"name\", { startsExpr }),\n eof: new TokenType(\"eof\"),\n\n // Punctuation token types.\n bracketL: new TokenType(\"[\", { beforeExpr, startsExpr }),\n bracketHashL: new TokenType(\"#[\", { beforeExpr, startsExpr }),\n bracketBarL: new TokenType(\"[|\", { beforeExpr, startsExpr }),\n bracketR: new TokenType(\"]\"),\n bracketBarR: new TokenType(\"|]\"),\n braceL: new TokenType(\"{\", { beforeExpr, startsExpr }),\n braceBarL: new TokenType(\"{|\", { beforeExpr, startsExpr }),\n braceHashL: new TokenType(\"#{\", { beforeExpr, startsExpr }),\n braceR: new TokenType(\"}\"),\n braceBarR: new TokenType(\"|}\"),\n parenL: new TokenType(\"(\", { beforeExpr, startsExpr }),\n parenR: new TokenType(\")\"),\n comma: new TokenType(\",\", { beforeExpr }),\n semi: new TokenType(\";\", { beforeExpr }),\n colon: new TokenType(\":\", { beforeExpr }),\n doubleColon: new TokenType(\"::\", { beforeExpr }),\n dot: new TokenType(\".\"),\n question: new TokenType(\"?\", { beforeExpr }),\n questionDot: new TokenType(\"?.\"),\n arrow: new TokenType(\"=>\", { beforeExpr }),\n template: new TokenType(\"template\"),\n ellipsis: new TokenType(\"...\", { beforeExpr }),\n backQuote: new TokenType(\"`\", { startsExpr }),\n dollarBraceL: new TokenType(\"${\", { beforeExpr, startsExpr }),\n at: new TokenType(\"@\"),\n hash: new TokenType(\"#\", { startsExpr }),\n\n // Special hashbang token.\n interpreterDirective: new TokenType(\"#!...\"),\n\n // Operators. These carry several kinds of properties to help the\n // parser use them properly (the presence of these properties is\n // what categorizes them as operators).\n //\n // `binop`, when present, specifies that this operator is a binary\n // operator, and will refer to its precedence.\n //\n // `prefix` and `postfix` mark the operator as a prefix or postfix\n // unary operator.\n //\n // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as\n // binary operators with a very low precedence, that should result\n // in AssignmentExpression nodes.\n\n eq: new TokenType(\"=\", { beforeExpr, isAssign }),\n assign: new TokenType(\"_=\", { beforeExpr, isAssign }),\n incDec: new TokenType(\"++/--\", { prefix, postfix, startsExpr }),\n bang: new TokenType(\"!\", { beforeExpr, prefix, startsExpr }),\n tilde: new TokenType(\"~\", { beforeExpr, prefix, startsExpr }),\n pipeline: createBinop(\"|>\", 0),\n nullishCoalescing: createBinop(\"??\", 1),\n logicalOR: createBinop(\"||\", 1),\n logicalAND: createBinop(\"&&\", 2),\n bitwiseOR: createBinop(\"|\", 3),\n bitwiseXOR: createBinop(\"^\", 4),\n bitwiseAND: createBinop(\"&\", 5),\n equality: createBinop(\"==/!=/===/!==\", 6),\n relational: createBinop(\"/<=/>=\", 7),\n bitShift: createBinop(\"<>/>>>\", 8),\n plusMin: new TokenType(\"+/-\", { beforeExpr, binop: 9, prefix, startsExpr }),\n // startsExpr: required by v8intrinsic plugin\n modulo: new TokenType(\"%\", { beforeExpr, binop: 10, startsExpr }),\n star: createBinop(\"*\", 10),\n slash: createBinop(\"/\", 10),\n exponent: new TokenType(\"**\", {\n beforeExpr,\n binop: 11,\n rightAssociative: true,\n }),\n\n // Keywords\n // Don't forget to update packages/babel-helper-validator-identifier/src/keyword.js\n // when new keywords are added\n _break: createKeyword(\"break\"),\n _case: createKeyword(\"case\", { beforeExpr }),\n _catch: createKeyword(\"catch\"),\n _continue: createKeyword(\"continue\"),\n _debugger: createKeyword(\"debugger\"),\n _default: createKeyword(\"default\", { beforeExpr }),\n _do: createKeyword(\"do\", { isLoop, beforeExpr }),\n _else: createKeyword(\"else\", { beforeExpr }),\n _finally: createKeyword(\"finally\"),\n _for: createKeyword(\"for\", { isLoop }),\n _function: createKeyword(\"function\", { startsExpr }),\n _if: createKeyword(\"if\"),\n _return: createKeyword(\"return\", { beforeExpr }),\n _switch: createKeyword(\"switch\"),\n _throw: createKeyword(\"throw\", { beforeExpr, prefix, startsExpr }),\n _try: createKeyword(\"try\"),\n _var: createKeyword(\"var\"),\n _const: createKeyword(\"const\"),\n _while: createKeyword(\"while\", { isLoop }),\n _with: createKeyword(\"with\"),\n _new: createKeyword(\"new\", { beforeExpr, startsExpr }),\n _this: createKeyword(\"this\", { startsExpr }),\n _super: createKeyword(\"super\", { startsExpr }),\n _class: createKeyword(\"class\", { startsExpr }),\n _extends: createKeyword(\"extends\", { beforeExpr }),\n _export: createKeyword(\"export\"),\n _import: createKeyword(\"import\", { startsExpr }),\n _null: createKeyword(\"null\", { startsExpr }),\n _true: createKeyword(\"true\", { startsExpr }),\n _false: createKeyword(\"false\", { startsExpr }),\n _in: createKeyword(\"in\", { beforeExpr, binop: 7 }),\n _instanceof: createKeyword(\"instanceof\", { beforeExpr, binop: 7 }),\n _typeof: createKeyword(\"typeof\", { beforeExpr, prefix, startsExpr }),\n _void: createKeyword(\"void\", { beforeExpr, prefix, startsExpr }),\n _delete: createKeyword(\"delete\", { beforeExpr, prefix, startsExpr }),\n};\n","// @flow\n\n// Each scope gets a bitset that may contain these flags\n// prettier-ignore\nexport const SCOPE_OTHER = 0b00000000,\n SCOPE_PROGRAM = 0b00000001,\n SCOPE_FUNCTION = 0b00000010,\n SCOPE_ARROW = 0b00000100,\n SCOPE_SIMPLE_CATCH = 0b00001000,\n SCOPE_SUPER = 0b00010000,\n SCOPE_DIRECT_SUPER = 0b00100000,\n SCOPE_CLASS = 0b01000000,\n SCOPE_TS_MODULE = 0b10000000,\n SCOPE_VAR = SCOPE_PROGRAM | SCOPE_FUNCTION | SCOPE_TS_MODULE;\n\nexport type ScopeFlags =\n | typeof SCOPE_OTHER\n | typeof SCOPE_PROGRAM\n | typeof SCOPE_FUNCTION\n | typeof SCOPE_VAR\n | typeof SCOPE_ARROW\n | typeof SCOPE_SIMPLE_CATCH\n | typeof SCOPE_SUPER\n | typeof SCOPE_DIRECT_SUPER\n | typeof SCOPE_CLASS;\n\n// These flags are meant to be _only_ used inside the Scope class (or subclasses).\n// prettier-ignore\nexport const BIND_KIND_VALUE = 0b00000_0000_01,\n BIND_KIND_TYPE = 0b00000_0000_10,\n // Used in checkLVal and declareName to determine the type of a binding\n BIND_SCOPE_VAR = 0b00000_0001_00, // Var-style binding\n BIND_SCOPE_LEXICAL = 0b00000_0010_00, // Let- or const-style binding\n BIND_SCOPE_FUNCTION = 0b00000_0100_00, // Function declaration\n BIND_SCOPE_OUTSIDE = 0b00000_1000_00, // Special case for function names as\n // bound inside the function\n // Misc flags\n BIND_FLAGS_NONE = 0b00001_0000_00,\n BIND_FLAGS_CLASS = 0b00010_0000_00,\n BIND_FLAGS_TS_ENUM = 0b00100_0000_00,\n BIND_FLAGS_TS_CONST_ENUM = 0b01000_0000_00,\n BIND_FLAGS_TS_EXPORT_ONLY = 0b10000_0000_00;\n\n// These flags are meant to be _only_ used by Scope consumers\n// prettier-ignore\n/* = is value? | is type? | scope | misc flags */\nexport const BIND_CLASS = BIND_KIND_VALUE | BIND_KIND_TYPE | BIND_SCOPE_LEXICAL | BIND_FLAGS_CLASS ,\n BIND_LEXICAL = BIND_KIND_VALUE | 0 | BIND_SCOPE_LEXICAL | 0 ,\n BIND_VAR = BIND_KIND_VALUE | 0 | BIND_SCOPE_VAR | 0 ,\n BIND_FUNCTION = BIND_KIND_VALUE | 0 | BIND_SCOPE_FUNCTION | 0 ,\n BIND_TS_INTERFACE = 0 | BIND_KIND_TYPE | 0 | BIND_FLAGS_CLASS ,\n BIND_TS_TYPE = 0 | BIND_KIND_TYPE | 0 | 0 ,\n BIND_TS_ENUM = BIND_KIND_VALUE | BIND_KIND_TYPE | BIND_SCOPE_LEXICAL | BIND_FLAGS_TS_ENUM,\n BIND_TS_AMBIENT = 0 | 0 | 0 | BIND_FLAGS_TS_EXPORT_ONLY,\n // These bindings don't introduce anything in the scope. They are used for assignments and\n // function expressions IDs.\n BIND_NONE = 0 | 0 | 0 | BIND_FLAGS_NONE ,\n BIND_OUTSIDE = BIND_KIND_VALUE | 0 | 0 | BIND_FLAGS_NONE ,\n\n BIND_TS_CONST_ENUM = BIND_TS_ENUM | BIND_FLAGS_TS_CONST_ENUM,\n BIND_TS_NAMESPACE = 0 | 0 | 0 | BIND_FLAGS_TS_EXPORT_ONLY;\n\nexport type BindingTypes =\n | typeof BIND_NONE\n | typeof BIND_OUTSIDE\n | typeof BIND_VAR\n | typeof BIND_LEXICAL\n | typeof BIND_CLASS\n | typeof BIND_FUNCTION\n | typeof BIND_TS_INTERFACE\n | typeof BIND_TS_TYPE\n | typeof BIND_TS_ENUM\n | typeof BIND_TS_AMBIENT\n | typeof BIND_TS_NAMESPACE;\n\n// prettier-ignore\nexport const CLASS_ELEMENT_FLAG_STATIC = 0b1_00,\n CLASS_ELEMENT_KIND_GETTER = 0b0_10,\n CLASS_ELEMENT_KIND_SETTER = 0b0_01,\n CLASS_ELEMENT_KIND_ACCESSOR = CLASS_ELEMENT_KIND_GETTER | CLASS_ELEMENT_KIND_SETTER;\n\n// prettier-ignore\nexport const CLASS_ELEMENT_STATIC_GETTER = CLASS_ELEMENT_KIND_GETTER | CLASS_ELEMENT_FLAG_STATIC,\n CLASS_ELEMENT_STATIC_SETTER = CLASS_ELEMENT_KIND_SETTER | CLASS_ELEMENT_FLAG_STATIC,\n CLASS_ELEMENT_INSTANCE_GETTER = CLASS_ELEMENT_KIND_GETTER,\n CLASS_ELEMENT_INSTANCE_SETTER = CLASS_ELEMENT_KIND_SETTER,\n CLASS_ELEMENT_OTHER = 0;\n\nexport type ClassElementTypes =\n | typeof CLASS_ELEMENT_STATIC_GETTER\n | typeof CLASS_ELEMENT_STATIC_SETTER\n | typeof CLASS_ELEMENT_INSTANCE_GETTER\n | typeof CLASS_ELEMENT_INSTANCE_SETTER\n | typeof CLASS_ELEMENT_OTHER;\n","// @flow\n\nimport * as charCodes from \"charcodes\";\n\n// Matches a whole line break (where CRLF is considered a single\n// line break). Used to count lines.\nexport const lineBreak = /\\r\\n?|[\\n\\u2028\\u2029]/;\nexport const lineBreakG = new RegExp(lineBreak.source, \"g\");\n\n// https://tc39.github.io/ecma262/#sec-line-terminators\nexport function isNewLine(code: number): boolean {\n switch (code) {\n case charCodes.lineFeed:\n case charCodes.carriageReturn:\n case charCodes.lineSeparator:\n case charCodes.paragraphSeparator:\n return true;\n\n default:\n return false;\n }\n}\n\nexport const skipWhiteSpace = /(?:\\s|\\/\\/.*|\\/\\*[^]*?\\*\\/)*/g;\n\n// https://tc39.github.io/ecma262/#sec-white-space\nexport function isWhitespace(code: number): boolean {\n switch (code) {\n case 0x0009: // CHARACTER TABULATION\n case 0x000b: // LINE TABULATION\n case 0x000c: // FORM FEED\n case charCodes.space:\n case charCodes.nonBreakingSpace:\n case charCodes.oghamSpaceMark:\n case 0x2000: // EN QUAD\n case 0x2001: // EM QUAD\n case 0x2002: // EN SPACE\n case 0x2003: // EM SPACE\n case 0x2004: // THREE-PER-EM SPACE\n case 0x2005: // FOUR-PER-EM SPACE\n case 0x2006: // SIX-PER-EM SPACE\n case 0x2007: // FIGURE SPACE\n case 0x2008: // PUNCTUATION SPACE\n case 0x2009: // THIN SPACE\n case 0x200a: // HAIR SPACE\n case 0x202f: // NARROW NO-BREAK SPACE\n case 0x205f: // MEDIUM MATHEMATICAL SPACE\n case 0x3000: // IDEOGRAPHIC SPACE\n case 0xfeff: // ZERO WIDTH NO-BREAK SPACE\n return true;\n\n default:\n return false;\n }\n}\n","// @flow\n\nimport { lineBreakG } from \"./whitespace\";\n\nexport type Pos = {\n start: number,\n};\n\n// These are used when `options.locations` is on, for the\n// `startLoc` and `endLoc` properties.\n\nexport class Position {\n line: number;\n column: number;\n\n constructor(line: number, col: number) {\n this.line = line;\n this.column = col;\n }\n}\n\nexport class SourceLocation {\n start: Position;\n end: Position;\n filename: string;\n identifierName: ?string;\n\n constructor(start: Position, end?: Position) {\n this.start = start;\n // $FlowIgnore (may start as null, but initialized later)\n this.end = end;\n }\n}\n\n// The `getLineInfo` function is mostly useful when the\n// `locations` option is off (for performance reasons) and you\n// want to find the line/column position for a given character\n// offset. `input` should be the code string that the offset refers\n// into.\n\nexport function getLineInfo(input: string, offset: number): Position {\n let line = 1;\n let lineStart = 0;\n let match;\n lineBreakG.lastIndex = 0;\n while ((match = lineBreakG.exec(input)) && match.index < offset) {\n line++;\n lineStart = lineBreakG.lastIndex;\n }\n\n return new Position(line, offset - lineStart);\n}\n","// @flow\n\nimport type { Options } from \"../options\";\nimport type State from \"../tokenizer/state\";\nimport type { PluginsMap } from \"./index\";\nimport type ScopeHandler from \"../util/scope\";\nimport type ClassScopeHandler from \"../util/class-scope\";\nimport type ProductionParameterHandler from \"../util/production-parameter\";\n\nexport default class BaseParser {\n // Properties set by constructor in index.js\n options: Options;\n inModule: boolean;\n scope: ScopeHandler<*>;\n classScope: ClassScopeHandler;\n prodParam: ProductionParameterHandler;\n plugins: PluginsMap;\n filename: ?string;\n sawUnambiguousESM: boolean = false;\n ambiguousScriptDifferentAst: boolean = false;\n\n // Initialized by Tokenizer\n state: State;\n // input and length are not in state as they are constant and we do\n // not want to ever copy them, which happens if state gets cloned\n input: string;\n length: number;\n\n hasPlugin(name: string): boolean {\n return this.plugins.has(name);\n }\n\n getPluginOption(plugin: string, name: string) {\n // $FlowIssue\n if (this.hasPlugin(plugin)) return this.plugins.get(plugin)[name];\n }\n}\n","// @flow\n\n/**\n * Based on the comment attachment algorithm used in espree and estraverse.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * * Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY\n * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport BaseParser from \"./base\";\nimport type { Comment, Node } from \"../types\";\n\nfunction last(stack: $ReadOnlyArray): T {\n return stack[stack.length - 1];\n}\n\nexport default class CommentsParser extends BaseParser {\n addComment(comment: Comment): void {\n if (this.filename) comment.loc.filename = this.filename;\n this.state.trailingComments.push(comment);\n this.state.leadingComments.push(comment);\n }\n\n adjustCommentsAfterTrailingComma(\n node: Node,\n elements: (Node | null)[],\n // When the current node is followed by a token which hasn't a respective AST node, we\n // need to take all the trailing comments to prevent them from being attached to an\n // unrelated node. e.g. in\n // var { x } /* cmt */ = { y }\n // we don't want /* cmt */ to be attached to { y }.\n // On the other hand, in\n // fn(x) [new line] /* cmt */ [new line] y\n // /* cmt */ is both a trailing comment of fn(x) and a leading comment of y\n takeAllComments?: boolean,\n ) {\n if (this.state.leadingComments.length === 0) {\n return;\n }\n\n let lastElement = null;\n let i = elements.length;\n while (lastElement === null && i > 0) {\n lastElement = elements[--i];\n }\n if (lastElement === null) {\n return;\n }\n\n for (let j = 0; j < this.state.leadingComments.length; j++) {\n if (\n this.state.leadingComments[j].end < this.state.commentPreviousNode.end\n ) {\n this.state.leadingComments.splice(j, 1);\n j--;\n }\n }\n\n const newTrailingComments = [];\n for (let i = 0; i < this.state.leadingComments.length; i++) {\n const leadingComment = this.state.leadingComments[i];\n if (leadingComment.end < node.end) {\n newTrailingComments.push(leadingComment);\n\n // Perf: we don't need to splice if we are going to reset the array anyway\n if (!takeAllComments) {\n this.state.leadingComments.splice(i, 1);\n i--;\n }\n } else {\n if (node.trailingComments === undefined) {\n node.trailingComments = [];\n }\n node.trailingComments.push(leadingComment);\n }\n }\n if (takeAllComments) this.state.leadingComments = [];\n\n if (newTrailingComments.length > 0) {\n lastElement.trailingComments = newTrailingComments;\n } else if (lastElement.trailingComments !== undefined) {\n lastElement.trailingComments = [];\n }\n }\n\n processComment(node: Node): void {\n if (node.type === \"Program\" && node.body.length > 0) return;\n\n const stack = this.state.commentStack;\n\n let firstChild, lastChild, trailingComments, i, j;\n\n if (this.state.trailingComments.length > 0) {\n // If the first comment in trailingComments comes after the\n // current node, then we're good - all comments in the array will\n // come after the node and so it's safe to add them as official\n // trailingComments.\n if (this.state.trailingComments[0].start >= node.end) {\n trailingComments = this.state.trailingComments;\n this.state.trailingComments = [];\n } else {\n // Otherwise, if the first comment doesn't come after the\n // current node, that means we have a mix of leading and trailing\n // comments in the array and that leadingComments contains the\n // same items as trailingComments. Reset trailingComments to\n // zero items and we'll handle this by evaluating leadingComments\n // later.\n this.state.trailingComments.length = 0;\n }\n } else if (stack.length > 0) {\n const lastInStack = last(stack);\n if (\n lastInStack.trailingComments &&\n lastInStack.trailingComments[0].start >= node.end\n ) {\n trailingComments = lastInStack.trailingComments;\n delete lastInStack.trailingComments;\n }\n }\n\n // Eating the stack.\n if (stack.length > 0 && last(stack).start >= node.start) {\n firstChild = stack.pop();\n }\n\n while (stack.length > 0 && last(stack).start >= node.start) {\n lastChild = stack.pop();\n }\n\n if (!lastChild && firstChild) lastChild = firstChild;\n\n // Adjust comments that follow a trailing comma on the last element in a\n // comma separated list of nodes to be the trailing comments on the last\n // element\n if (firstChild) {\n switch (node.type) {\n case \"ObjectExpression\":\n this.adjustCommentsAfterTrailingComma(node, node.properties);\n break;\n case \"ObjectPattern\":\n this.adjustCommentsAfterTrailingComma(node, node.properties, true);\n break;\n case \"CallExpression\":\n this.adjustCommentsAfterTrailingComma(node, node.arguments);\n break;\n case \"ArrayExpression\":\n this.adjustCommentsAfterTrailingComma(node, node.elements);\n break;\n case \"ArrayPattern\":\n this.adjustCommentsAfterTrailingComma(node, node.elements, true);\n break;\n }\n } else if (\n this.state.commentPreviousNode &&\n ((this.state.commentPreviousNode.type === \"ImportSpecifier\" &&\n node.type !== \"ImportSpecifier\") ||\n (this.state.commentPreviousNode.type === \"ExportSpecifier\" &&\n node.type !== \"ExportSpecifier\"))\n ) {\n this.adjustCommentsAfterTrailingComma(node, [\n this.state.commentPreviousNode,\n ]);\n }\n\n if (lastChild) {\n if (lastChild.leadingComments) {\n if (\n lastChild !== node &&\n lastChild.leadingComments.length > 0 &&\n last(lastChild.leadingComments).end <= node.start\n ) {\n node.leadingComments = lastChild.leadingComments;\n delete lastChild.leadingComments;\n } else {\n // A leading comment for an anonymous class had been stolen by its first ClassMethod,\n // so this takes back the leading comment.\n // See also: https://github.com/eslint/espree/issues/158\n for (i = lastChild.leadingComments.length - 2; i >= 0; --i) {\n if (lastChild.leadingComments[i].end <= node.start) {\n node.leadingComments = lastChild.leadingComments.splice(0, i + 1);\n break;\n }\n }\n }\n }\n } else if (this.state.leadingComments.length > 0) {\n if (last(this.state.leadingComments).end <= node.start) {\n if (this.state.commentPreviousNode) {\n for (j = 0; j < this.state.leadingComments.length; j++) {\n if (\n this.state.leadingComments[j].end <\n this.state.commentPreviousNode.end\n ) {\n this.state.leadingComments.splice(j, 1);\n j--;\n }\n }\n }\n if (this.state.leadingComments.length > 0) {\n node.leadingComments = this.state.leadingComments;\n this.state.leadingComments = [];\n }\n } else {\n // https://github.com/eslint/espree/issues/2\n //\n // In special cases, such as return (without a value) and\n // debugger, all comments will end up as leadingComments and\n // will otherwise be eliminated. This step runs when the\n // commentStack is empty and there are comments left\n // in leadingComments.\n //\n // This loop figures out the stopping point between the actual\n // leading and trailing comments by finding the location of the\n // first comment that comes after the given node.\n for (i = 0; i < this.state.leadingComments.length; i++) {\n if (this.state.leadingComments[i].end > node.start) {\n break;\n }\n }\n\n // Split the array based on the location of the first comment\n // that comes after the node. Keep in mind that this could\n // result in an empty array, and if so, the array must be\n // deleted.\n const leadingComments = this.state.leadingComments.slice(0, i);\n\n if (leadingComments.length) {\n node.leadingComments = leadingComments;\n }\n\n // Similarly, trailing comments are attached later. The variable\n // must be reset to null if there are no trailing comments.\n trailingComments = this.state.leadingComments.slice(i);\n if (trailingComments.length === 0) {\n trailingComments = null;\n }\n }\n }\n\n this.state.commentPreviousNode = node;\n\n if (trailingComments) {\n if (\n trailingComments.length &&\n trailingComments[0].start >= node.start &&\n last(trailingComments).end <= node.end\n ) {\n node.innerComments = trailingComments;\n } else {\n node.trailingComments = trailingComments;\n }\n }\n\n stack.push(node);\n }\n}\n","// @flow\n/* eslint sort-keys: \"error\" */\nimport { getLineInfo, type Position } from \"../util/location\";\nimport CommentsParser from \"./comments\";\n\n// This function is used to raise exceptions on parse errors. It\n// takes an offset integer (into the current `input`) to indicate\n// the location of the error, attaches the position to the end\n// of the error message, and then raises a `SyntaxError` with that\n// message.\n\ntype ErrorContext = {\n pos: number,\n loc: Position,\n missingPlugin?: Array,\n code?: string,\n};\n\n// The Errors key follows https://cs.chromium.org/chromium/src/v8/src/common/message-template.h unless it does not exist\nexport const Errors = Object.freeze({\n ArgumentsDisallowedInInitializer:\n \"'arguments' is not allowed in class field initializer\",\n AsyncFunctionInSingleStatementContext:\n \"Async functions can only be declared at the top level or inside a block\",\n AwaitBindingIdentifier:\n \"Can not use 'await' as identifier inside an async function\",\n AwaitExpressionFormalParameter:\n \"await is not allowed in async function parameters\",\n AwaitNotInAsyncFunction:\n \"Can not use keyword 'await' outside an async function\",\n BadGetterArity: \"getter must not have any formal parameters\",\n BadSetterArity: \"setter must have exactly one formal parameter\",\n BadSetterRestParameter:\n \"setter function argument must not be a rest parameter\",\n ConstructorClassField: \"Classes may not have a field named 'constructor'\",\n ConstructorClassPrivateField:\n \"Classes may not have a private field named '#constructor'\",\n ConstructorIsAccessor: \"Class constructor may not be an accessor\",\n ConstructorIsAsync: \"Constructor can't be an async function\",\n ConstructorIsGenerator: \"Constructor can't be a generator\",\n DeclarationMissingInitializer: \"%0 require an initialization value\",\n DecoratorBeforeExport:\n \"Decorators must be placed *before* the 'export' keyword. You can set the 'decoratorsBeforeExport' option to false to use the 'export @decorator class {}' syntax\",\n DecoratorConstructor:\n \"Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?\",\n DecoratorExportClass:\n \"Using the export keyword between a decorator and a class is not allowed. Please use `export @dec class` instead.\",\n DecoratorSemicolon: \"Decorators must not be followed by a semicolon\",\n DeletePrivateField: \"Deleting a private field is not allowed\",\n DestructureNamedImport:\n \"ES2015 named imports do not destructure. Use another statement for destructuring after the import.\",\n DuplicateConstructor: \"Duplicate constructor in the same class\",\n DuplicateDefaultExport: \"Only one default export allowed per module.\",\n DuplicateExport:\n \"`%0` has already been exported. Exported identifiers must be unique.\",\n DuplicateProto: \"Redefinition of __proto__ property\",\n DuplicateRegExpFlags: \"Duplicate regular expression flag\",\n ElementAfterRest: \"Rest element must be last element\",\n EscapedCharNotAnIdentifier: \"Invalid Unicode escape\",\n ForInOfLoopInitializer:\n \"%0 loop variable declaration may not have an initializer\",\n GeneratorInSingleStatementContext:\n \"Generators can only be declared at the top level or inside a block\",\n IllegalBreakContinue: \"Unsyntactic %0\",\n IllegalLanguageModeDirective:\n \"Illegal 'use strict' directive in function with non-simple parameter list\",\n IllegalReturn: \"'return' outside of function\",\n ImportCallArgumentTrailingComma:\n \"Trailing comma is disallowed inside import(...) arguments\",\n ImportCallArity: \"import() requires exactly one argument\",\n ImportCallArityLtOne: \"Dynamic imports require a parameter: import('a.js')\",\n ImportCallNotNewExpression: \"Cannot use new with import(...)\",\n ImportCallSpreadArgument: \"... is not allowed in import()\",\n ImportMetaOutsideModule: `import.meta may appear only with 'sourceType: \"module\"'`,\n ImportOutsideModule: `'import' and 'export' may appear only with 'sourceType: \"module\"'`,\n InvalidCodePoint: \"Code point out of bounds\",\n InvalidDigit: \"Expected number in radix %0\",\n InvalidEscapeSequence: \"Bad character escape sequence\",\n InvalidEscapeSequenceTemplate: \"Invalid escape sequence in template\",\n InvalidEscapedReservedWord: \"Escape sequence in keyword %0\",\n InvalidIdentifier: \"Invalid identifier %0\",\n InvalidLhs: \"Invalid left-hand side in %0\",\n InvalidLhsBinding: \"Binding invalid left-hand side in %0\",\n InvalidNumber: \"Invalid number\",\n InvalidOrUnexpectedToken: \"Unexpected character '%0'\",\n InvalidParenthesizedAssignment: \"Invalid parenthesized assignment pattern\",\n InvalidPrivateFieldResolution: \"Private name #%0 is not defined\",\n InvalidPropertyBindingPattern: \"Binding member expression\",\n InvalidRestAssignmentPattern: \"Invalid rest operator's argument\",\n LabelRedeclaration: \"Label '%0' is already declared\",\n LetInLexicalBinding:\n \"'let' is not allowed to be used as a name in 'let' or 'const' declarations.\",\n MalformedRegExpFlags: \"Invalid regular expression flag\",\n MissingClassName: \"A class name is required\",\n MissingEqInAssignment:\n \"Only '=' operator can be used for specifying default value.\",\n MissingUnicodeEscape: \"Expecting Unicode escape sequence \\\\uXXXX\",\n MixingCoalesceWithLogical:\n \"Nullish coalescing operator(??) requires parens when mixing with logical operators\",\n ModuleExportUndefined: \"Export '%0' is not defined\",\n MultipleDefaultsInSwitch: \"Multiple default clauses\",\n NewlineAfterThrow: \"Illegal newline after throw\",\n NoCatchOrFinally: \"Missing catch or finally clause\",\n NumberIdentifier: \"Identifier directly after number\",\n NumericSeparatorInEscapeSequence:\n \"Numeric separators are not allowed inside unicode escape sequences or hex escape sequences\",\n ObsoleteAwaitStar:\n \"await* has been removed from the async functions proposal. Use Promise.all() instead.\",\n OptionalChainingNoNew:\n \"constructors in/after an Optional Chain are not allowed\",\n OptionalChainingNoTemplate:\n \"Tagged Template Literals are not allowed in optionalChain\",\n ParamDupe: \"Argument name clash\",\n PatternHasAccessor: \"Object pattern can't contain getter or setter\",\n PatternHasMethod: \"Object pattern can't contain methods\",\n PipelineBodyNoArrow:\n 'Unexpected arrow \"=>\" after pipeline body; arrow function in pipeline body must be parenthesized',\n PipelineBodySequenceExpression:\n \"Pipeline body may not be a comma-separated sequence expression\",\n PipelineHeadSequenceExpression:\n \"Pipeline head should not be a comma-separated sequence expression\",\n PipelineTopicUnused:\n \"Pipeline is in topic style but does not use topic reference\",\n PrimaryTopicNotAllowed:\n \"Topic reference was used in a lexical context without topic binding\",\n PrimaryTopicRequiresSmartPipeline:\n \"Primary Topic Reference found but pipelineOperator not passed 'smart' for 'proposal' option.\",\n PrivateNameRedeclaration: \"Duplicate private name #%0\",\n RecordExpressionBarIncorrectEndSyntaxType:\n \"Record expressions ending with '|}' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'\",\n RecordExpressionBarIncorrectStartSyntaxType:\n \"Record expressions starting with '{|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'\",\n RecordExpressionHashIncorrectStartSyntaxType:\n \"Record expressions starting with '#{' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'\",\n RestTrailingComma: \"Unexpected trailing comma after rest element\",\n SloppyFunction:\n \"In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement\",\n StaticPrototype: \"Classes may not have static property named prototype\",\n StrictDelete: \"Deleting local variable in strict mode\",\n StrictEvalArguments: \"Assigning to '%0' in strict mode\",\n StrictEvalArgumentsBinding: \"Binding '%0' in strict mode\",\n StrictFunction:\n \"In strict mode code, functions can only be declared at top level or inside a block\",\n StrictOctalLiteral: \"Legacy octal literals are not allowed in strict mode\",\n StrictWith: \"'with' in strict mode\",\n SuperNotAllowed:\n \"super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class?\",\n SuperPrivateField: \"Private fields can't be accessed on super\",\n TrailingDecorator: \"Decorators must be attached to a class element\",\n TupleExpressionBarIncorrectEndSyntaxType:\n \"Tuple expressions ending with '|]' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'\",\n TupleExpressionBarIncorrectStartSyntaxType:\n \"Tuple expressions starting with '[|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'\",\n TupleExpressionHashIncorrectStartSyntaxType:\n \"Tuple expressions starting with '#[' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'\",\n UnexpectedArgumentPlaceholder: \"Unexpected argument placeholder\",\n UnexpectedAwaitAfterPipelineBody:\n 'Unexpected \"await\" after pipeline body; await must have parentheses in minimal proposal',\n UnexpectedDigitAfterHash: \"Unexpected digit after hash token\",\n UnexpectedImportExport:\n \"'import' and 'export' may only appear at the top level\",\n UnexpectedKeyword: \"Unexpected keyword '%0'\",\n UnexpectedLeadingDecorator:\n \"Leading decorators must be attached to a class declaration\",\n UnexpectedLexicalDeclaration:\n \"Lexical declaration cannot appear in a single-statement context\",\n UnexpectedNewTarget: \"new.target can only be used in functions\",\n UnexpectedNumericSeparator:\n \"A numeric separator is only allowed between two digits\",\n UnexpectedPrivateField:\n \"Private names can only be used as the name of a class element (i.e. class C { #p = 42; #m() {} } )\\n or a property of member expression (i.e. this.#p).\",\n UnexpectedReservedWord: \"Unexpected reserved word '%0'\",\n UnexpectedSuper: \"super is only allowed in object methods and classes\",\n UnexpectedToken: \"Unexpected token '%'\",\n UnexpectedTokenUnaryExponentiation:\n \"Illegal expression. Wrap left hand side or entire exponentiation in parentheses.\",\n UnsupportedBind: \"Binding should be performed on object property.\",\n UnsupportedDecoratorExport:\n \"A decorated export must export a class declaration\",\n UnsupportedDefaultExport:\n \"Only expressions, functions or classes are allowed as the `default` export.\",\n UnsupportedImport: \"import can only be used in import() or import.meta\",\n UnsupportedMetaProperty: \"The only valid meta property for %0 is %0.%1\",\n UnsupportedParameterDecorator:\n \"Decorators cannot be used to decorate parameters\",\n UnsupportedPropertyDecorator:\n \"Decorators cannot be used to decorate object literal properties\",\n UnsupportedSuper:\n \"super can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop])\",\n UnterminatedComment: \"Unterminated comment\",\n UnterminatedRegExp: \"Unterminated regular expression\",\n UnterminatedString: \"Unterminated string constant\",\n UnterminatedTemplate: \"Unterminated template\",\n VarRedeclaration: \"Identifier '%0' has already been declared\",\n YieldBindingIdentifier:\n \"Can not use 'yield' as identifier inside a generator\",\n YieldInParameter: \"yield is not allowed in generator parameters\",\n ZeroDigitNumericSeparator:\n \"Numeric separator can not be used after leading 0\",\n});\n\nexport default class LocationParser extends CommentsParser {\n // Forward-declaration: defined in tokenizer/index.js\n /*::\n +isLookahead: boolean;\n */\n\n getLocationForPosition(pos: number): Position {\n let loc;\n if (pos === this.state.start) loc = this.state.startLoc;\n else if (pos === this.state.lastTokStart) loc = this.state.lastTokStartLoc;\n else if (pos === this.state.end) loc = this.state.endLoc;\n else if (pos === this.state.lastTokEnd) loc = this.state.lastTokEndLoc;\n else loc = getLineInfo(this.input, pos);\n\n return loc;\n }\n\n raise(pos: number, errorTemplate: string, ...params: any): Error | empty {\n return this.raiseWithData(pos, undefined, errorTemplate, ...params);\n }\n\n raiseWithData(\n pos: number,\n data?: {\n missingPlugin?: Array,\n code?: string,\n },\n errorTemplate: string,\n ...params: any\n ): Error | empty {\n const loc = this.getLocationForPosition(pos);\n const message =\n errorTemplate.replace(/%(\\d+)/g, (_, i: number) => params[i]) +\n ` (${loc.line}:${loc.column})`;\n return this._raise(Object.assign(({ loc, pos }: Object), data), message);\n }\n\n _raise(errorContext: ErrorContext, message: string): Error | empty {\n // $FlowIgnore\n const err: SyntaxError & ErrorContext = new SyntaxError(message);\n Object.assign(err, errorContext);\n if (this.options.errorRecovery) {\n if (!this.isLookahead) this.state.errors.push(err);\n return err;\n } else {\n throw err;\n }\n }\n}\n","// @flow\n\nimport { types as tt, TokenType } from \"../tokenizer/types\";\nimport type Parser from \"../parser\";\nimport type { ExpressionErrors } from \"../parser/util\";\nimport * as N from \"../types\";\nimport type { Position } from \"../util/location\";\nimport { type BindingTypes, BIND_NONE } from \"../util/scopeflags\";\nimport { Errors } from \"../parser/location\";\n\nfunction isSimpleProperty(node: N.Node): boolean {\n return (\n node != null &&\n node.type === \"Property\" &&\n node.kind === \"init\" &&\n node.method === false\n );\n}\n\nexport default (superClass: Class): Class =>\n class extends superClass {\n estreeParseRegExpLiteral({ pattern, flags }: N.RegExpLiteral): N.Node {\n let regex = null;\n try {\n regex = new RegExp(pattern, flags);\n } catch (e) {\n // In environments that don't support these flags value will\n // be null as the regex can't be represented natively.\n }\n const node = this.estreeParseLiteral(regex);\n node.regex = { pattern, flags };\n\n return node;\n }\n\n estreeParseBigIntLiteral(value: any): N.Node {\n // https://github.com/estree/estree/blob/master/es2020.md#bigintliteral\n // $FlowIgnore\n const bigInt = typeof BigInt !== \"undefined\" ? BigInt(value) : null;\n const node = this.estreeParseLiteral(bigInt);\n node.bigint = String(node.value || value);\n\n return node;\n }\n\n estreeParseLiteral(value: any): N.Node {\n return this.parseLiteral(value, \"Literal\");\n }\n\n directiveToStmt(directive: N.Directive): N.ExpressionStatement {\n const directiveLiteral = directive.value;\n\n const stmt = this.startNodeAt(directive.start, directive.loc.start);\n const expression = this.startNodeAt(\n directiveLiteral.start,\n directiveLiteral.loc.start,\n );\n\n expression.value = directiveLiteral.value;\n expression.raw = directiveLiteral.extra.raw;\n\n stmt.expression = this.finishNodeAt(\n expression,\n \"Literal\",\n directiveLiteral.end,\n directiveLiteral.loc.end,\n );\n stmt.directive = directiveLiteral.extra.raw.slice(1, -1);\n\n return this.finishNodeAt(\n stmt,\n \"ExpressionStatement\",\n directive.end,\n directive.loc.end,\n );\n }\n\n // ==================================\n // Overrides\n // ==================================\n\n initFunction(\n node: N.BodilessFunctionOrMethodBase,\n isAsync: ?boolean,\n ): void {\n super.initFunction(node, isAsync);\n node.expression = false;\n }\n\n checkDeclaration(node: N.Pattern | N.ObjectProperty): void {\n if (isSimpleProperty(node)) {\n this.checkDeclaration(((node: any): N.EstreeProperty).value);\n } else {\n super.checkDeclaration(node);\n }\n }\n\n checkGetterSetterParams(method: N.ObjectMethod | N.ClassMethod): void {\n const prop = ((method: any): N.EstreeProperty | N.EstreeMethodDefinition);\n const paramCount = prop.kind === \"get\" ? 0 : 1;\n const start = prop.start;\n if (prop.value.params.length !== paramCount) {\n if (method.kind === \"get\") {\n this.raise(start, Errors.BadGetterArity);\n } else {\n this.raise(start, Errors.BadSetterArity);\n }\n } else if (\n prop.kind === \"set\" &&\n prop.value.params[0].type === \"RestElement\"\n ) {\n this.raise(start, Errors.BadSetterRestParameter);\n }\n }\n\n checkLVal(\n expr: N.Expression,\n bindingType: BindingTypes = BIND_NONE,\n checkClashes: ?{ [key: string]: boolean },\n contextDescription: string,\n disallowLetBinding?: boolean,\n ): void {\n switch (expr.type) {\n case \"ObjectPattern\":\n expr.properties.forEach(prop => {\n this.checkLVal(\n prop.type === \"Property\" ? prop.value : prop,\n bindingType,\n checkClashes,\n \"object destructuring pattern\",\n disallowLetBinding,\n );\n });\n break;\n default:\n super.checkLVal(\n expr,\n bindingType,\n checkClashes,\n contextDescription,\n disallowLetBinding,\n );\n }\n }\n\n checkDuplicatedProto(\n prop: N.ObjectMember | N.SpreadElement,\n protoRef: { used: boolean },\n refExpressionErrors: ?ExpressionErrors,\n ): void {\n if (\n prop.type === \"SpreadElement\" ||\n prop.computed ||\n prop.method ||\n // $FlowIgnore\n prop.shorthand\n ) {\n return;\n }\n\n const key = prop.key;\n // It is either an Identifier or a String/NumericLiteral\n const name = key.type === \"Identifier\" ? key.name : String(key.value);\n\n if (name === \"__proto__\" && prop.kind === \"init\") {\n // Store the first redefinition's position\n if (protoRef.used) {\n if (refExpressionErrors && refExpressionErrors.doubleProto === -1) {\n refExpressionErrors.doubleProto = key.start;\n } else {\n this.raise(key.start, Errors.DuplicateProto);\n }\n }\n\n protoRef.used = true;\n }\n }\n\n isValidDirective(stmt: N.Statement): boolean {\n return (\n stmt.type === \"ExpressionStatement\" &&\n stmt.expression.type === \"Literal\" &&\n typeof stmt.expression.value === \"string\" &&\n (!stmt.expression.extra || !stmt.expression.extra.parenthesized)\n );\n }\n\n stmtToDirective(stmt: N.Statement): N.Directive {\n const directive = super.stmtToDirective(stmt);\n const value = stmt.expression.value;\n\n // Reset value to the actual value as in estree mode we want\n // the stmt to have the real value and not the raw value\n directive.value.value = value;\n\n return directive;\n }\n\n parseBlockBody(\n node: N.BlockStatementLike,\n allowDirectives: ?boolean,\n topLevel: boolean,\n end: TokenType,\n ): void {\n super.parseBlockBody(node, allowDirectives, topLevel, end);\n\n const directiveStatements = node.directives.map(d =>\n this.directiveToStmt(d),\n );\n node.body = directiveStatements.concat(node.body);\n delete node.directives;\n }\n\n pushClassMethod(\n classBody: N.ClassBody,\n method: N.ClassMethod,\n isGenerator: boolean,\n isAsync: boolean,\n isConstructor: boolean,\n allowsDirectSuper: boolean,\n ): void {\n this.parseMethod(\n method,\n isGenerator,\n isAsync,\n isConstructor,\n allowsDirectSuper,\n \"ClassMethod\",\n true,\n );\n if (method.typeParameters) {\n // $FlowIgnore\n method.value.typeParameters = method.typeParameters;\n delete method.typeParameters;\n }\n classBody.body.push(method);\n }\n\n parseExprAtom(refExpressionErrors?: ?ExpressionErrors): N.Expression {\n switch (this.state.type) {\n case tt.num:\n case tt.string:\n return this.estreeParseLiteral(this.state.value);\n\n case tt.regexp:\n return this.estreeParseRegExpLiteral(this.state.value);\n\n case tt.bigint:\n return this.estreeParseBigIntLiteral(this.state.value);\n\n case tt._null:\n return this.estreeParseLiteral(null);\n\n case tt._true:\n return this.estreeParseLiteral(true);\n\n case tt._false:\n return this.estreeParseLiteral(false);\n\n default:\n return super.parseExprAtom(refExpressionErrors);\n }\n }\n\n parseLiteral(\n value: any,\n type: /*T[\"kind\"]*/ string,\n startPos?: number,\n startLoc?: Position,\n ): T {\n const node = super.parseLiteral(value, type, startPos, startLoc);\n node.raw = node.extra.raw;\n delete node.extra;\n\n return node;\n }\n\n parseFunctionBody(\n node: N.Function,\n allowExpression: ?boolean,\n isMethod?: boolean = false,\n ): void {\n super.parseFunctionBody(node, allowExpression, isMethod);\n node.expression = node.body.type !== \"BlockStatement\";\n }\n\n parseMethod(\n node: T,\n isGenerator: boolean,\n isAsync: boolean,\n isConstructor: boolean,\n allowDirectSuper: boolean,\n type: string,\n inClassScope: boolean = false,\n ): T {\n let funcNode = this.startNode();\n funcNode.kind = node.kind; // provide kind, so super method correctly sets state\n funcNode = super.parseMethod(\n funcNode,\n isGenerator,\n isAsync,\n isConstructor,\n allowDirectSuper,\n type,\n inClassScope,\n );\n funcNode.type = \"FunctionExpression\";\n delete funcNode.kind;\n // $FlowIgnore\n node.value = funcNode;\n\n type = type === \"ClassMethod\" ? \"MethodDefinition\" : type;\n return this.finishNode(node, type);\n }\n\n parseObjectMethod(\n prop: N.ObjectMethod,\n isGenerator: boolean,\n isAsync: boolean,\n isPattern: boolean,\n containsEsc: boolean,\n ): ?N.ObjectMethod {\n const node: N.EstreeProperty = (super.parseObjectMethod(\n prop,\n isGenerator,\n isAsync,\n isPattern,\n containsEsc,\n ): any);\n\n if (node) {\n node.type = \"Property\";\n if (((node: any): N.ClassMethod).kind === \"method\") node.kind = \"init\";\n node.shorthand = false;\n }\n\n return (node: any);\n }\n\n parseObjectProperty(\n prop: N.ObjectProperty,\n startPos: ?number,\n startLoc: ?Position,\n isPattern: boolean,\n refExpressionErrors: ?ExpressionErrors,\n ): ?N.ObjectProperty {\n const node: N.EstreeProperty = (super.parseObjectProperty(\n prop,\n startPos,\n startLoc,\n isPattern,\n refExpressionErrors,\n ): any);\n\n if (node) {\n node.kind = \"init\";\n node.type = \"Property\";\n }\n\n return (node: any);\n }\n\n toAssignable(node: N.Node): N.Node {\n if (isSimpleProperty(node)) {\n this.toAssignable(node.value);\n\n return node;\n }\n\n return super.toAssignable(node);\n }\n\n toAssignableObjectExpressionProp(prop: N.Node, isLast: boolean) {\n if (prop.kind === \"get\" || prop.kind === \"set\") {\n throw this.raise(prop.key.start, Errors.PatternHasAccessor);\n } else if (prop.method) {\n throw this.raise(prop.key.start, Errors.PatternHasMethod);\n } else {\n super.toAssignableObjectExpressionProp(prop, isLast);\n }\n }\n\n finishCallExpression(\n node: T,\n optional: boolean,\n ): N.Expression {\n super.finishCallExpression(node, optional);\n\n if (node.callee.type === \"Import\") {\n ((node: N.Node): N.EstreeImportExpression).type = \"ImportExpression\";\n ((node: N.Node): N.EstreeImportExpression).source = node.arguments[0];\n delete node.arguments;\n delete node.callee;\n }\n\n return node;\n }\n\n toReferencedListDeep(\n exprList: $ReadOnlyArray,\n isParenthesizedExpr?: boolean,\n ): void {\n // ImportExpressions do not have an arguments array.\n if (!exprList) {\n return;\n }\n\n super.toReferencedListDeep(exprList, isParenthesizedExpr);\n }\n\n parseExport(node: N.Node) {\n super.parseExport(node);\n\n switch (node.type) {\n case \"ExportAllDeclaration\":\n node.exported = null;\n break;\n\n case \"ExportNamedDeclaration\":\n if (\n node.specifiers.length === 1 &&\n node.specifiers[0].type === \"ExportNamespaceSpecifier\"\n ) {\n node.type = \"ExportAllDeclaration\";\n node.exported = node.specifiers[0].exported;\n delete node.specifiers;\n }\n\n break;\n }\n\n return node;\n }\n };\n","// @flow\n\n// The algorithm used to determine whether a regexp can appear at a\n// given point in the program is loosely based on sweet.js' approach.\n// See https://github.com/mozilla/sweet.js/wiki/design\n\nimport { types as tt } from \"./types\";\nimport { lineBreak } from \"../util/whitespace\";\n\nexport class TokContext {\n constructor(\n token: string,\n isExpr?: boolean,\n preserveSpace?: boolean,\n override?: ?Function, // Takes a Tokenizer as a this-parameter, and returns void.\n ) {\n this.token = token;\n this.isExpr = !!isExpr;\n this.preserveSpace = !!preserveSpace;\n this.override = override;\n }\n\n token: string;\n isExpr: boolean;\n preserveSpace: boolean;\n override: ?Function;\n}\n\nexport const types: {\n [key: string]: TokContext,\n} = {\n braceStatement: new TokContext(\"{\", false),\n braceExpression: new TokContext(\"{\", true),\n templateQuasi: new TokContext(\"${\", false),\n parenStatement: new TokContext(\"(\", false),\n parenExpression: new TokContext(\"(\", true),\n template: new TokContext(\"`\", true, true, p => p.readTmplToken()),\n functionExpression: new TokContext(\"function\", true),\n functionStatement: new TokContext(\"function\", false),\n};\n\n// Token-specific context update code\n\ntt.parenR.updateContext = tt.braceR.updateContext = function() {\n if (this.state.context.length === 1) {\n this.state.exprAllowed = true;\n return;\n }\n\n let out = this.state.context.pop();\n if (out === types.braceStatement && this.curContext().token === \"function\") {\n out = this.state.context.pop();\n }\n\n this.state.exprAllowed = !out.isExpr;\n};\n\ntt.name.updateContext = function(prevType) {\n let allowed = false;\n if (prevType !== tt.dot) {\n if (\n (this.state.value === \"of\" && !this.state.exprAllowed) ||\n (this.state.value === \"yield\" && this.prodParam.hasYield)\n ) {\n allowed = true;\n }\n }\n this.state.exprAllowed = allowed;\n\n if (this.state.isIterator) {\n this.state.isIterator = false;\n }\n};\n\ntt.braceL.updateContext = function(prevType) {\n this.state.context.push(\n this.braceIsBlock(prevType) ? types.braceStatement : types.braceExpression,\n );\n this.state.exprAllowed = true;\n};\n\ntt.dollarBraceL.updateContext = function() {\n this.state.context.push(types.templateQuasi);\n this.state.exprAllowed = true;\n};\n\ntt.parenL.updateContext = function(prevType) {\n const statementParens =\n prevType === tt._if ||\n prevType === tt._for ||\n prevType === tt._with ||\n prevType === tt._while;\n this.state.context.push(\n statementParens ? types.parenStatement : types.parenExpression,\n );\n this.state.exprAllowed = true;\n};\n\ntt.incDec.updateContext = function() {\n // tokExprAllowed stays unchanged\n};\n\ntt._function.updateContext = tt._class.updateContext = function(prevType) {\n if (\n prevType.beforeExpr &&\n prevType !== tt.semi &&\n prevType !== tt._else &&\n !(\n prevType === tt._return &&\n lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.start))\n ) &&\n !(\n (prevType === tt.colon || prevType === tt.braceL) &&\n this.curContext() === types.b_stat\n )\n ) {\n this.state.context.push(types.functionExpression);\n } else {\n this.state.context.push(types.functionStatement);\n }\n\n this.state.exprAllowed = false;\n};\n\ntt.backQuote.updateContext = function() {\n if (this.curContext() === types.template) {\n this.state.context.pop();\n } else {\n this.state.context.push(types.template);\n }\n this.state.exprAllowed = false;\n};\n","// @flow\n\nimport * as charCodes from \"charcodes\";\n\n// ## Character categories\n\n// Big ugly regular expressions that match characters in the\n// whitespace, identifier, and identifier-start categories. These\n// are only applied when a character is found to actually have a\n// code point between 0x80 and 0xffff.\n// Generated by `scripts/generate-identifier-regex.js`.\n\n/* prettier-ignore */\nlet 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\\u08a0-\\u08b4\\u08b6-\\u08c7\\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\\u0c60\\u0c61\\u0c80\\u0c85-\\u0c8c\\u0c8e-\\u0c90\\u0c92-\\u0ca8\\u0caa-\\u0cb3\\u0cb5-\\u0cb9\\u0cbd\\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-\\u170c\\u170e-\\u1711\\u1720-\\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-\\u1b4b\\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-\\u2c2e\\u2c30-\\u2c5e\\u2c60-\\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-\\u9ffc\\ua000-\\ua48c\\ua4d0-\\ua4fd\\ua500-\\ua60c\\ua610-\\ua61f\\ua62a\\ua62b\\ua640-\\ua66e\\ua67f-\\ua69d\\ua6a0-\\ua6ef\\ua717-\\ua71f\\ua722-\\ua788\\ua78b-\\ua7bf\\ua7c2-\\ua7ca\\ua7f5-\\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\";\n/* prettier-ignore */\nlet 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\\u08d3-\\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\\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\\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-\\u0ecd\\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-\\u1714\\u1732-\\u1734\\u1752\\u1753\\u1772\\u1773\\u17b4-\\u17d3\\u17dd\\u17e0-\\u17e9\\u180b-\\u180d\\u1810-\\u1819\\u18a9\\u1920-\\u192b\\u1930-\\u193b\\u1946-\\u194f\\u19d0-\\u19da\\u1a17-\\u1a1b\\u1a55-\\u1a5e\\u1a60-\\u1a7c\\u1a7f-\\u1a89\\u1a90-\\u1a99\\u1ab0-\\u1abd\\u1abf\\u1ac0\\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-\\u1df9\\u1dfb-\\u1dff\\u203f\\u2040\\u2054\\u20d0-\\u20dc\\u20e1\\u20e5-\\u20f0\\u2cef-\\u2cf1\\u2d7f\\u2de0-\\u2dff\\u302a-\\u302f\\u3099\\u309a\\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\";\n\nconst nonASCIIidentifierStart = new RegExp(\n \"[\" + nonASCIIidentifierStartChars + \"]\",\n);\nconst nonASCIIidentifier = new RegExp(\n \"[\" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + \"]\",\n);\n\nnonASCIIidentifierStartChars = nonASCIIidentifierChars = null;\n\n// These are a run-length and offset-encoded representation of the\n// >0xffff code points that are a valid part of identifiers. The\n// offset starts at 0x10000, and each pair of numbers represents an\n// offset to the next range, and then a size of the range. They were\n// generated by `scripts/generate-identifier-regex.js`.\n/* prettier-ignore */\n/* prettier-ignore */\nconst 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,157,310,10,21,11,7,153,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,107,20,28,22,13,52,76,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,85,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,230,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,35,56,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,190,0,80,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,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,8952,286,50,2,18,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,2357,44,11,6,17,0,370,43,1301,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,42717,35,4148,12,221,3,5761,15,7472,3104,541,1507,4938];\n/* prettier-ignore */\nconst 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,154,10,176,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,161,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,19306,9,135,4,60,6,26,9,1014,0,2,54,8,3,82,0,12,1,19628,1,5319,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,262,6,10,9,419,13,1495,6,110,6,6,9,4759,9,787719,239];\n\n// This has a complexity linear to the value of the code. The\n// assumption is that looking up astral identifier characters is\n// rare.\nfunction isInAstralSet(code: number, set: $ReadOnlyArray): boolean {\n let pos = 0x10000;\n for (let i = 0, length = set.length; i < length; i += 2) {\n pos += set[i];\n if (pos > code) return false;\n\n pos += set[i + 1];\n if (pos >= code) return true;\n }\n return false;\n}\n\n// Test whether a given character code starts an identifier.\n\nexport function isIdentifierStart(code: number): boolean {\n if (code < charCodes.uppercaseA) return code === charCodes.dollarSign;\n if (code <= charCodes.uppercaseZ) return true;\n if (code < charCodes.lowercaseA) return code === charCodes.underscore;\n if (code <= charCodes.lowercaseZ) return true;\n if (code <= 0xffff) {\n return (\n code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code))\n );\n }\n return isInAstralSet(code, astralIdentifierStartCodes);\n}\n\n// Test whether a given character is part of an identifier.\n\nexport function isIdentifierChar(code: number): boolean {\n if (code < charCodes.digit0) return code === charCodes.dollarSign;\n if (code < charCodes.colon) return true;\n if (code < charCodes.uppercaseA) return false;\n if (code <= charCodes.uppercaseZ) return true;\n if (code < charCodes.lowercaseA) return code === charCodes.underscore;\n if (code <= charCodes.lowercaseZ) return true;\n if (code <= 0xffff) {\n return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));\n }\n return (\n isInAstralSet(code, astralIdentifierStartCodes) ||\n isInAstralSet(code, astralIdentifierCodes)\n );\n}\n\n// Test whether a given string is a valid identifier name\n\nexport function isIdentifierName(name: string): boolean {\n let isFirst = true;\n for (const char of Array.from(name)) {\n const cp = char.codePointAt(0);\n if (isFirst) {\n if (!isIdentifierStart(cp)) {\n return false;\n }\n isFirst = false;\n } else if (!isIdentifierChar(cp)) {\n return false;\n }\n }\n return true;\n}\n","// @flow\n\nconst 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","/* eslint max-len: 0 */\n\n// @flow\n\nimport * as charCodes from \"charcodes\";\n\nexport {\n isIdentifierStart,\n isIdentifierChar,\n isReservedWord,\n isStrictBindOnlyReservedWord,\n isStrictBindReservedWord,\n isStrictReservedWord,\n isKeyword,\n} from \"@babel/helper-validator-identifier\";\n\nexport const keywordRelationalOperator = /^in(stanceof)?$/;\n\n// Test whether a current state character code and next character code is @\n\nexport function isIteratorStart(current: number, next: number): boolean {\n return current === charCodes.atSign && next === charCodes.atSign;\n}\n","// @flow\n\n/*:: declare var invariant; */\n\nimport type Parser from \"../parser\";\nimport { types as tt, type TokenType } from \"../tokenizer/types\";\nimport * as N from \"../types\";\nimport type { Options } from \"../options\";\nimport type { Pos, Position } from \"../util/location\";\nimport type State from \"../tokenizer/state\";\nimport { types as tc } from \"../tokenizer/context\";\nimport * as charCodes from \"charcodes\";\nimport { isIteratorStart } from \"../util/identifier\";\nimport {\n type BindingTypes,\n BIND_NONE,\n BIND_LEXICAL,\n BIND_VAR,\n BIND_FUNCTION,\n SCOPE_ARROW,\n SCOPE_FUNCTION,\n SCOPE_OTHER,\n} from \"../util/scopeflags\";\nimport type { ExpressionErrors } from \"../parser/util\";\nimport { Errors } from \"../parser/location\";\n\nconst reservedTypes = new Set([\n \"_\",\n \"any\",\n \"bool\",\n \"boolean\",\n \"empty\",\n \"extends\",\n \"false\",\n \"interface\",\n \"mixed\",\n \"null\",\n \"number\",\n \"static\",\n \"string\",\n \"true\",\n \"typeof\",\n \"void\",\n]);\n\n/* eslint sort-keys: \"error\" */\n// The Errors key follows https://github.com/facebook/flow/blob/master/src/parser/parse_error.ml unless it does not exist\nconst FlowErrors = Object.freeze({\n AmbiguousConditionalArrow:\n \"Ambiguous expression: wrap the arrow functions in parentheses to disambiguate.\",\n AmbiguousDeclareModuleKind:\n \"Found both `declare module.exports` and `declare export` in the same module. Modules can only have 1 since they are either an ES module or they are a CommonJS module\",\n AssignReservedType: \"Cannot overwrite reserved type %0\",\n DeclareClassElement:\n \"The `declare` modifier can only appear on class fields.\",\n DeclareClassFieldInitializer:\n \"Initializers are not allowed in fields with the `declare` modifier.\",\n DuplicateDeclareModuleExports: \"Duplicate `declare module.exports` statement\",\n EnumBooleanMemberNotInitialized:\n \"Boolean enum members need to be initialized. Use either `%0 = true,` or `%0 = false,` in enum `%1`.\",\n EnumDuplicateMemberName:\n \"Enum member names need to be unique, but the name `%0` has already been used before in enum `%1`.\",\n EnumInconsistentMemberValues:\n \"Enum `%0` has inconsistent member initializers. Either use no initializers, or consistently use literals (either booleans, numbers, or strings) for all member initializers.\",\n EnumInvalidExplicitType:\n \"Enum type `%1` is not valid. Use one of `boolean`, `number`, `string`, or `symbol` in enum `%0`.\",\n EnumInvalidExplicitTypeUnknownSupplied:\n \"Supplied enum type is not valid. Use one of `boolean`, `number`, `string`, or `symbol` in enum `%0`.\",\n EnumInvalidMemberInitializerPrimaryType:\n \"Enum `%0` has type `%2`, so the initializer of `%1` needs to be a %2 literal.\",\n EnumInvalidMemberInitializerSymbolType:\n \"Symbol enum members cannot be initialized. Use `%1,` in enum `%0`.\",\n EnumInvalidMemberInitializerUnknownType:\n \"The enum member initializer for `%1` needs to be a literal (either a boolean, number, or string) in enum `%0`.\",\n EnumInvalidMemberName:\n \"Enum member names cannot start with lowercase 'a' through 'z'. Instead of using `%0`, consider using `%1`, in enum `%2`.\",\n EnumNumberMemberNotInitialized:\n \"Number enum members need to be initialized, e.g. `%1 = 1` in enum `%0`.\",\n EnumStringMemberInconsistentlyInitailized:\n \"String enum members need to consistently either all use initializers, or use no initializers, in enum `%0`.\",\n ImportTypeShorthandOnlyInPureImport:\n \"The `type` and `typeof` keywords on named imports can only be used on regular `import` statements. It cannot be used with `import type` or `import typeof` statements\",\n InexactInsideExact:\n \"Explicit inexact syntax cannot appear inside an explicit exact object type\",\n InexactInsideNonObject:\n \"Explicit inexact syntax cannot appear in class or interface definitions\",\n InexactVariance: \"Explicit inexact syntax cannot have variance\",\n InvalidNonTypeImportInDeclareModule:\n \"Imports within a `declare module` body must always be `import type` or `import typeof`\",\n MissingTypeParamDefault:\n \"Type parameter declaration needs a default, since a preceding type parameter declaration has a default.\",\n NestedDeclareModule:\n \"`declare module` cannot be used inside another `declare module`\",\n NestedFlowComment: \"Cannot have a flow comment inside another flow comment\",\n OptionalBindingPattern:\n \"A binding pattern parameter cannot be optional in an implementation signature.\",\n SpreadVariance: \"Spread properties cannot have variance\",\n TypeBeforeInitializer:\n \"Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`\",\n TypeCastInPattern:\n \"The type cast expression is expected to be wrapped with parenthesis\",\n UnexpectedExplicitInexactInObject:\n \"Explicit inexact syntax must appear at the end of an inexact object\",\n UnexpectedReservedType: \"Unexpected reserved type %0\",\n UnexpectedReservedUnderscore:\n \"`_` is only allowed as a type argument to call or new\",\n UnexpectedSpaceBetweenModuloChecks:\n \"Spaces between `%` and `checks` are not allowed here.\",\n UnexpectedSpreadType:\n \"Spread operator cannot appear in class or interface definitions\",\n UnexpectedSubtractionOperand:\n 'Unexpected token, expected \"number\" or \"bigint\"',\n UnexpectedTokenAfterTypeParameter:\n \"Expected an arrow function after this type parameter declaration\",\n UnsupportedDeclareExportKind:\n \"`declare export %0` is not supported. Use `%1` instead\",\n UnsupportedStatementInDeclareModule:\n \"Only declares and type imports are allowed inside declare module\",\n UnterminatedFlowComment: \"Unterminated flow-comment\",\n});\n/* eslint-disable sort-keys */\n\nfunction isEsModuleType(bodyElement: N.Node): boolean {\n return (\n bodyElement.type === \"DeclareExportAllDeclaration\" ||\n (bodyElement.type === \"DeclareExportDeclaration\" &&\n (!bodyElement.declaration ||\n (bodyElement.declaration.type !== \"TypeAlias\" &&\n bodyElement.declaration.type !== \"InterfaceDeclaration\")))\n );\n}\n\nfunction hasTypeImportKind(node: N.Node): boolean {\n return node.importKind === \"type\" || node.importKind === \"typeof\";\n}\n\nfunction isMaybeDefaultImport(state: State): boolean {\n return (\n (state.type === tt.name || !!state.type.keyword) && state.value !== \"from\"\n );\n}\n\nconst exportSuggestions = {\n const: \"declare export var\",\n let: \"declare export var\",\n type: \"export type\",\n interface: \"export interface\",\n};\n\n// Like Array#filter, but returns a tuple [ acceptedElements, discardedElements ]\nfunction partition(\n list: T[],\n test: (T, number, T[]) => ?boolean,\n): [T[], T[]] {\n const list1 = [];\n const list2 = [];\n for (let i = 0; i < list.length; i++) {\n (test(list[i], i, list) ? list1 : list2).push(list[i]);\n }\n return [list1, list2];\n}\n\nconst FLOW_PRAGMA_REGEX = /\\*?\\s*@((?:no)?flow)\\b/;\n\n// Flow enums types\ntype EnumExplicitType = null | \"boolean\" | \"number\" | \"string\" | \"symbol\";\ntype EnumContext = {|\n enumName: string,\n explicitType: EnumExplicitType,\n memberName: string,\n|};\ntype EnumMemberInit =\n | {| type: \"number\", pos: number, value: N.Node |}\n | {| type: \"string\", pos: number, value: N.Node |}\n | {| type: \"boolean\", pos: number, value: N.Node |}\n | {| type: \"invalid\", pos: number |}\n | {| type: \"none\", pos: number |};\n\nexport default (superClass: Class): Class =>\n class extends superClass {\n // The value of the @flow/@noflow pragma. Initially undefined, transitions\n // to \"@flow\" or \"@noflow\" if we see a pragma. Transitions to null if we are\n // past the initial comment.\n flowPragma: void | null | \"flow\" | \"noflow\";\n\n constructor(options: ?Options, input: string) {\n super(options, input);\n this.flowPragma = undefined;\n }\n\n shouldParseTypes(): boolean {\n return this.getPluginOption(\"flow\", \"all\") || this.flowPragma === \"flow\";\n }\n\n shouldParseEnums(): boolean {\n return !!this.getPluginOption(\"flow\", \"enums\");\n }\n\n finishToken(type: TokenType, val: any): void {\n if (\n type !== tt.string &&\n type !== tt.semi &&\n type !== tt.interpreterDirective\n ) {\n if (this.flowPragma === undefined) {\n this.flowPragma = null;\n }\n }\n return super.finishToken(type, val);\n }\n\n addComment(comment: N.Comment): void {\n if (this.flowPragma === undefined) {\n // Try to parse a flow pragma.\n const matches = FLOW_PRAGMA_REGEX.exec(comment.value);\n if (!matches) {\n // do nothing\n } else if (matches[1] === \"flow\") {\n this.flowPragma = \"flow\";\n } else if (matches[1] === \"noflow\") {\n this.flowPragma = \"noflow\";\n } else {\n throw new Error(\"Unexpected flow pragma\");\n }\n }\n return super.addComment(comment);\n }\n\n flowParseTypeInitialiser(tok?: TokenType): N.FlowType {\n const oldInType = this.state.inType;\n this.state.inType = true;\n this.expect(tok || tt.colon);\n\n const type = this.flowParseType();\n this.state.inType = oldInType;\n return type;\n }\n\n flowParsePredicate(): N.FlowType {\n const node = this.startNode();\n const moduloLoc = this.state.startLoc;\n const moduloPos = this.state.start;\n this.expect(tt.modulo);\n const checksLoc = this.state.startLoc;\n this.expectContextual(\"checks\");\n // Force '%' and 'checks' to be adjacent\n if (\n moduloLoc.line !== checksLoc.line ||\n moduloLoc.column !== checksLoc.column - 1\n ) {\n this.raise(moduloPos, FlowErrors.UnexpectedSpaceBetweenModuloChecks);\n }\n if (this.eat(tt.parenL)) {\n node.value = this.parseExpression();\n this.expect(tt.parenR);\n return this.finishNode(node, \"DeclaredPredicate\");\n } else {\n return this.finishNode(node, \"InferredPredicate\");\n }\n }\n\n flowParseTypeAndPredicateInitialiser(): [?N.FlowType, ?N.FlowPredicate] {\n const oldInType = this.state.inType;\n this.state.inType = true;\n this.expect(tt.colon);\n let type = null;\n let predicate = null;\n if (this.match(tt.modulo)) {\n this.state.inType = oldInType;\n predicate = this.flowParsePredicate();\n } else {\n type = this.flowParseType();\n this.state.inType = oldInType;\n if (this.match(tt.modulo)) {\n predicate = this.flowParsePredicate();\n }\n }\n return [type, predicate];\n }\n\n flowParseDeclareClass(node: N.FlowDeclareClass): N.FlowDeclareClass {\n this.next();\n this.flowParseInterfaceish(node, /*isClass*/ true);\n return this.finishNode(node, \"DeclareClass\");\n }\n\n flowParseDeclareFunction(\n node: N.FlowDeclareFunction,\n ): N.FlowDeclareFunction {\n this.next();\n\n const id = (node.id = this.parseIdentifier());\n\n const typeNode = this.startNode();\n const typeContainer = this.startNode();\n\n if (this.isRelational(\"<\")) {\n typeNode.typeParameters = this.flowParseTypeParameterDeclaration();\n } else {\n typeNode.typeParameters = null;\n }\n\n this.expect(tt.parenL);\n const tmp = this.flowParseFunctionTypeParams();\n typeNode.params = tmp.params;\n typeNode.rest = tmp.rest;\n this.expect(tt.parenR);\n\n [\n // $FlowFixMe (destructuring not supported yet)\n typeNode.returnType,\n // $FlowFixMe (destructuring not supported yet)\n node.predicate,\n ] = this.flowParseTypeAndPredicateInitialiser();\n\n typeContainer.typeAnnotation = this.finishNode(\n typeNode,\n \"FunctionTypeAnnotation\",\n );\n\n id.typeAnnotation = this.finishNode(typeContainer, \"TypeAnnotation\");\n\n this.resetEndLocation(id);\n this.semicolon();\n\n return this.finishNode(node, \"DeclareFunction\");\n }\n\n flowParseDeclare(\n node: N.FlowDeclare,\n insideModule?: boolean,\n ): N.FlowDeclare {\n if (this.match(tt._class)) {\n return this.flowParseDeclareClass(node);\n } else if (this.match(tt._function)) {\n return this.flowParseDeclareFunction(node);\n } else if (this.match(tt._var)) {\n return this.flowParseDeclareVariable(node);\n } else if (this.eatContextual(\"module\")) {\n if (this.match(tt.dot)) {\n return this.flowParseDeclareModuleExports(node);\n } else {\n if (insideModule) {\n this.raise(this.state.lastTokStart, FlowErrors.NestedDeclareModule);\n }\n return this.flowParseDeclareModule(node);\n }\n } else if (this.isContextual(\"type\")) {\n return this.flowParseDeclareTypeAlias(node);\n } else if (this.isContextual(\"opaque\")) {\n return this.flowParseDeclareOpaqueType(node);\n } else if (this.isContextual(\"interface\")) {\n return this.flowParseDeclareInterface(node);\n } else if (this.match(tt._export)) {\n return this.flowParseDeclareExportDeclaration(node, insideModule);\n } else {\n throw this.unexpected();\n }\n }\n\n flowParseDeclareVariable(\n node: N.FlowDeclareVariable,\n ): N.FlowDeclareVariable {\n this.next();\n node.id = this.flowParseTypeAnnotatableIdentifier(\n /*allowPrimitiveOverride*/ true,\n );\n this.scope.declareName(node.id.name, BIND_VAR, node.id.start);\n this.semicolon();\n return this.finishNode(node, \"DeclareVariable\");\n }\n\n flowParseDeclareModule(node: N.FlowDeclareModule): N.FlowDeclareModule {\n this.scope.enter(SCOPE_OTHER);\n\n if (this.match(tt.string)) {\n node.id = this.parseExprAtom();\n } else {\n node.id = this.parseIdentifier();\n }\n\n const bodyNode = (node.body = this.startNode());\n const body = (bodyNode.body = []);\n this.expect(tt.braceL);\n while (!this.match(tt.braceR)) {\n let bodyNode = this.startNode();\n\n if (this.match(tt._import)) {\n this.next();\n if (!this.isContextual(\"type\") && !this.match(tt._typeof)) {\n this.raise(\n this.state.lastTokStart,\n FlowErrors.InvalidNonTypeImportInDeclareModule,\n );\n }\n this.parseImport(bodyNode);\n } else {\n this.expectContextual(\n \"declare\",\n FlowErrors.UnsupportedStatementInDeclareModule,\n );\n\n bodyNode = this.flowParseDeclare(bodyNode, true);\n }\n\n body.push(bodyNode);\n }\n\n this.scope.exit();\n\n this.expect(tt.braceR);\n\n this.finishNode(bodyNode, \"BlockStatement\");\n\n let kind = null;\n let hasModuleExport = false;\n body.forEach(bodyElement => {\n if (isEsModuleType(bodyElement)) {\n if (kind === \"CommonJS\") {\n this.raise(\n bodyElement.start,\n FlowErrors.AmbiguousDeclareModuleKind,\n );\n }\n kind = \"ES\";\n } else if (bodyElement.type === \"DeclareModuleExports\") {\n if (hasModuleExport) {\n this.raise(\n bodyElement.start,\n FlowErrors.DuplicateDeclareModuleExports,\n );\n }\n if (kind === \"ES\") {\n this.raise(\n bodyElement.start,\n FlowErrors.AmbiguousDeclareModuleKind,\n );\n }\n kind = \"CommonJS\";\n hasModuleExport = true;\n }\n });\n\n node.kind = kind || \"CommonJS\";\n return this.finishNode(node, \"DeclareModule\");\n }\n\n flowParseDeclareExportDeclaration(\n node: N.FlowDeclareExportDeclaration,\n insideModule: ?boolean,\n ): N.FlowDeclareExportDeclaration {\n this.expect(tt._export);\n\n if (this.eat(tt._default)) {\n if (this.match(tt._function) || this.match(tt._class)) {\n // declare export default class ...\n // declare export default function ...\n node.declaration = this.flowParseDeclare(this.startNode());\n } else {\n // declare export default [type];\n node.declaration = this.flowParseType();\n this.semicolon();\n }\n node.default = true;\n\n return this.finishNode(node, \"DeclareExportDeclaration\");\n } else {\n if (\n this.match(tt._const) ||\n this.isLet() ||\n ((this.isContextual(\"type\") || this.isContextual(\"interface\")) &&\n !insideModule)\n ) {\n const label = this.state.value;\n const suggestion = exportSuggestions[label];\n throw this.raise(\n this.state.start,\n FlowErrors.UnsupportedDeclareExportKind,\n label,\n suggestion,\n );\n }\n\n if (\n this.match(tt._var) || // declare export var ...\n this.match(tt._function) || // declare export function ...\n this.match(tt._class) || // declare export class ...\n this.isContextual(\"opaque\") // declare export opaque ..\n ) {\n node.declaration = this.flowParseDeclare(this.startNode());\n node.default = false;\n\n return this.finishNode(node, \"DeclareExportDeclaration\");\n } else if (\n this.match(tt.star) || // declare export * from ''\n this.match(tt.braceL) || // declare export {} ...\n this.isContextual(\"interface\") || // declare export interface ...\n this.isContextual(\"type\") || // declare export type ...\n this.isContextual(\"opaque\") // declare export opaque type ...\n ) {\n node = this.parseExport(node);\n if (node.type === \"ExportNamedDeclaration\") {\n // flow does not support the ExportNamedDeclaration\n // $FlowIgnore\n node.type = \"ExportDeclaration\";\n // $FlowFixMe\n node.default = false;\n delete node.exportKind;\n }\n\n // $FlowIgnore\n node.type = \"Declare\" + node.type;\n\n return node;\n }\n }\n\n throw this.unexpected();\n }\n\n flowParseDeclareModuleExports(\n node: N.FlowDeclareModuleExports,\n ): N.FlowDeclareModuleExports {\n this.next();\n this.expectContextual(\"exports\");\n node.typeAnnotation = this.flowParseTypeAnnotation();\n this.semicolon();\n\n return this.finishNode(node, \"DeclareModuleExports\");\n }\n\n flowParseDeclareTypeAlias(\n node: N.FlowDeclareTypeAlias,\n ): N.FlowDeclareTypeAlias {\n this.next();\n this.flowParseTypeAlias(node);\n // Don't do finishNode as we don't want to process comments twice\n node.type = \"DeclareTypeAlias\";\n return node;\n }\n\n flowParseDeclareOpaqueType(\n node: N.FlowDeclareOpaqueType,\n ): N.FlowDeclareOpaqueType {\n this.next();\n this.flowParseOpaqueType(node, true);\n // Don't do finishNode as we don't want to process comments twice\n node.type = \"DeclareOpaqueType\";\n return node;\n }\n\n flowParseDeclareInterface(\n node: N.FlowDeclareInterface,\n ): N.FlowDeclareInterface {\n this.next();\n this.flowParseInterfaceish(node);\n return this.finishNode(node, \"DeclareInterface\");\n }\n\n // Interfaces\n\n flowParseInterfaceish(\n node: N.FlowDeclare,\n isClass?: boolean = false,\n ): void {\n node.id = this.flowParseRestrictedIdentifier(\n /* liberal */ !isClass,\n /* declaration */ true,\n );\n\n this.scope.declareName(\n node.id.name,\n isClass ? BIND_FUNCTION : BIND_LEXICAL,\n node.id.start,\n );\n\n if (this.isRelational(\"<\")) {\n node.typeParameters = this.flowParseTypeParameterDeclaration();\n } else {\n node.typeParameters = null;\n }\n\n node.extends = [];\n node.implements = [];\n node.mixins = [];\n\n if (this.eat(tt._extends)) {\n do {\n node.extends.push(this.flowParseInterfaceExtends());\n } while (!isClass && this.eat(tt.comma));\n }\n\n if (this.isContextual(\"mixins\")) {\n this.next();\n do {\n node.mixins.push(this.flowParseInterfaceExtends());\n } while (this.eat(tt.comma));\n }\n\n if (this.isContextual(\"implements\")) {\n this.next();\n do {\n node.implements.push(this.flowParseInterfaceExtends());\n } while (this.eat(tt.comma));\n }\n\n node.body = this.flowParseObjectType({\n allowStatic: isClass,\n allowExact: false,\n allowSpread: false,\n allowProto: isClass,\n allowInexact: false,\n });\n }\n\n flowParseInterfaceExtends(): N.FlowInterfaceExtends {\n const node = this.startNode();\n\n node.id = this.flowParseQualifiedTypeIdentifier();\n if (this.isRelational(\"<\")) {\n node.typeParameters = this.flowParseTypeParameterInstantiation();\n } else {\n node.typeParameters = null;\n }\n\n return this.finishNode(node, \"InterfaceExtends\");\n }\n\n flowParseInterface(node: N.FlowInterface): N.FlowInterface {\n this.flowParseInterfaceish(node);\n return this.finishNode(node, \"InterfaceDeclaration\");\n }\n\n checkNotUnderscore(word: string) {\n if (word === \"_\") {\n this.raise(this.state.start, FlowErrors.UnexpectedReservedUnderscore);\n }\n }\n\n checkReservedType(word: string, startLoc: number, declaration?: boolean) {\n if (!reservedTypes.has(word)) return;\n\n this.raise(\n startLoc,\n declaration\n ? FlowErrors.AssignReservedType\n : FlowErrors.UnexpectedReservedType,\n word,\n );\n }\n\n flowParseRestrictedIdentifier(\n liberal?: boolean,\n declaration?: boolean,\n ): N.Identifier {\n this.checkReservedType(this.state.value, this.state.start, declaration);\n return this.parseIdentifier(liberal);\n }\n\n // Type aliases\n\n flowParseTypeAlias(node: N.FlowTypeAlias): N.FlowTypeAlias {\n node.id = this.flowParseRestrictedIdentifier(\n /* liberal */ false,\n /* declaration */ true,\n );\n this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start);\n\n if (this.isRelational(\"<\")) {\n node.typeParameters = this.flowParseTypeParameterDeclaration();\n } else {\n node.typeParameters = null;\n }\n\n node.right = this.flowParseTypeInitialiser(tt.eq);\n this.semicolon();\n\n return this.finishNode(node, \"TypeAlias\");\n }\n\n flowParseOpaqueType(\n node: N.FlowOpaqueType,\n declare: boolean,\n ): N.FlowOpaqueType {\n this.expectContextual(\"type\");\n node.id = this.flowParseRestrictedIdentifier(\n /* liberal */ true,\n /* declaration */ true,\n );\n this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start);\n\n if (this.isRelational(\"<\")) {\n node.typeParameters = this.flowParseTypeParameterDeclaration();\n } else {\n node.typeParameters = null;\n }\n\n // Parse the supertype\n node.supertype = null;\n if (this.match(tt.colon)) {\n node.supertype = this.flowParseTypeInitialiser(tt.colon);\n }\n\n node.impltype = null;\n if (!declare) {\n node.impltype = this.flowParseTypeInitialiser(tt.eq);\n }\n this.semicolon();\n\n return this.finishNode(node, \"OpaqueType\");\n }\n\n // Type annotations\n\n flowParseTypeParameter(requireDefault?: boolean = false): N.TypeParameter {\n const nodeStart = this.state.start;\n\n const node = this.startNode();\n\n const variance = this.flowParseVariance();\n\n const ident = this.flowParseTypeAnnotatableIdentifier();\n node.name = ident.name;\n node.variance = variance;\n node.bound = ident.typeAnnotation;\n\n if (this.match(tt.eq)) {\n this.eat(tt.eq);\n node.default = this.flowParseType();\n } else {\n if (requireDefault) {\n this.raise(nodeStart, FlowErrors.MissingTypeParamDefault);\n }\n }\n\n return this.finishNode(node, \"TypeParameter\");\n }\n\n flowParseTypeParameterDeclaration(): N.TypeParameterDeclaration {\n const oldInType = this.state.inType;\n const node = this.startNode();\n node.params = [];\n\n this.state.inType = true;\n\n // istanbul ignore else: this condition is already checked at all call sites\n if (this.isRelational(\"<\") || this.match(tt.jsxTagStart)) {\n this.next();\n } else {\n this.unexpected();\n }\n\n let defaultRequired = false;\n\n do {\n const typeParameter = this.flowParseTypeParameter(defaultRequired);\n\n node.params.push(typeParameter);\n\n if (typeParameter.default) {\n defaultRequired = true;\n }\n\n if (!this.isRelational(\">\")) {\n this.expect(tt.comma);\n }\n } while (!this.isRelational(\">\"));\n this.expectRelational(\">\");\n\n this.state.inType = oldInType;\n\n return this.finishNode(node, \"TypeParameterDeclaration\");\n }\n\n flowParseTypeParameterInstantiation(): N.TypeParameterInstantiation {\n const node = this.startNode();\n const oldInType = this.state.inType;\n node.params = [];\n\n this.state.inType = true;\n\n this.expectRelational(\"<\");\n const oldNoAnonFunctionType = this.state.noAnonFunctionType;\n this.state.noAnonFunctionType = false;\n while (!this.isRelational(\">\")) {\n node.params.push(this.flowParseType());\n if (!this.isRelational(\">\")) {\n this.expect(tt.comma);\n }\n }\n this.state.noAnonFunctionType = oldNoAnonFunctionType;\n this.expectRelational(\">\");\n\n this.state.inType = oldInType;\n\n return this.finishNode(node, \"TypeParameterInstantiation\");\n }\n\n flowParseTypeParameterInstantiationCallOrNew(): N.TypeParameterInstantiation {\n const node = this.startNode();\n const oldInType = this.state.inType;\n node.params = [];\n\n this.state.inType = true;\n\n this.expectRelational(\"<\");\n while (!this.isRelational(\">\")) {\n node.params.push(this.flowParseTypeOrImplicitInstantiation());\n if (!this.isRelational(\">\")) {\n this.expect(tt.comma);\n }\n }\n this.expectRelational(\">\");\n\n this.state.inType = oldInType;\n\n return this.finishNode(node, \"TypeParameterInstantiation\");\n }\n\n flowParseInterfaceType(): N.FlowInterfaceType {\n const node = this.startNode();\n this.expectContextual(\"interface\");\n\n node.extends = [];\n if (this.eat(tt._extends)) {\n do {\n node.extends.push(this.flowParseInterfaceExtends());\n } while (this.eat(tt.comma));\n }\n\n node.body = this.flowParseObjectType({\n allowStatic: false,\n allowExact: false,\n allowSpread: false,\n allowProto: false,\n allowInexact: false,\n });\n\n return this.finishNode(node, \"InterfaceTypeAnnotation\");\n }\n\n flowParseObjectPropertyKey(): N.Expression {\n return this.match(tt.num) || this.match(tt.string)\n ? this.parseExprAtom()\n : this.parseIdentifier(true);\n }\n\n flowParseObjectTypeIndexer(\n node: N.FlowObjectTypeIndexer,\n isStatic: boolean,\n variance: ?N.FlowVariance,\n ): N.FlowObjectTypeIndexer {\n node.static = isStatic;\n\n // Note: bracketL has already been consumed\n if (this.lookahead().type === tt.colon) {\n node.id = this.flowParseObjectPropertyKey();\n node.key = this.flowParseTypeInitialiser();\n } else {\n node.id = null;\n node.key = this.flowParseType();\n }\n this.expect(tt.bracketR);\n node.value = this.flowParseTypeInitialiser();\n node.variance = variance;\n\n return this.finishNode(node, \"ObjectTypeIndexer\");\n }\n\n flowParseObjectTypeInternalSlot(\n node: N.FlowObjectTypeInternalSlot,\n isStatic: boolean,\n ): N.FlowObjectTypeInternalSlot {\n node.static = isStatic;\n // Note: both bracketL have already been consumed\n node.id = this.flowParseObjectPropertyKey();\n this.expect(tt.bracketR);\n this.expect(tt.bracketR);\n if (this.isRelational(\"<\") || this.match(tt.parenL)) {\n node.method = true;\n node.optional = false;\n node.value = this.flowParseObjectTypeMethodish(\n this.startNodeAt(node.start, node.loc.start),\n );\n } else {\n node.method = false;\n if (this.eat(tt.question)) {\n node.optional = true;\n }\n node.value = this.flowParseTypeInitialiser();\n }\n return this.finishNode(node, \"ObjectTypeInternalSlot\");\n }\n\n flowParseObjectTypeMethodish(\n node: N.FlowFunctionTypeAnnotation,\n ): N.FlowFunctionTypeAnnotation {\n node.params = [];\n node.rest = null;\n node.typeParameters = null;\n\n if (this.isRelational(\"<\")) {\n node.typeParameters = this.flowParseTypeParameterDeclaration();\n }\n\n this.expect(tt.parenL);\n while (!this.match(tt.parenR) && !this.match(tt.ellipsis)) {\n node.params.push(this.flowParseFunctionTypeParam());\n if (!this.match(tt.parenR)) {\n this.expect(tt.comma);\n }\n }\n\n if (this.eat(tt.ellipsis)) {\n node.rest = this.flowParseFunctionTypeParam();\n }\n this.expect(tt.parenR);\n node.returnType = this.flowParseTypeInitialiser();\n\n return this.finishNode(node, \"FunctionTypeAnnotation\");\n }\n\n flowParseObjectTypeCallProperty(\n node: N.FlowObjectTypeCallProperty,\n isStatic: boolean,\n ): N.FlowObjectTypeCallProperty {\n const valueNode = this.startNode();\n node.static = isStatic;\n node.value = this.flowParseObjectTypeMethodish(valueNode);\n return this.finishNode(node, \"ObjectTypeCallProperty\");\n }\n\n flowParseObjectType({\n allowStatic,\n allowExact,\n allowSpread,\n allowProto,\n allowInexact,\n }: {\n allowStatic: boolean,\n allowExact: boolean,\n allowSpread: boolean,\n allowProto: boolean,\n allowInexact: boolean,\n }): N.FlowObjectTypeAnnotation {\n const oldInType = this.state.inType;\n this.state.inType = true;\n\n const nodeStart = this.startNode();\n\n nodeStart.callProperties = [];\n nodeStart.properties = [];\n nodeStart.indexers = [];\n nodeStart.internalSlots = [];\n\n let endDelim;\n let exact;\n let inexact = false;\n if (allowExact && this.match(tt.braceBarL)) {\n this.expect(tt.braceBarL);\n endDelim = tt.braceBarR;\n exact = true;\n } else {\n this.expect(tt.braceL);\n endDelim = tt.braceR;\n exact = false;\n }\n\n nodeStart.exact = exact;\n\n while (!this.match(endDelim)) {\n let isStatic = false;\n let protoStart: ?number = null;\n let inexactStart: ?number = null;\n const node = this.startNode();\n\n if (allowProto && this.isContextual(\"proto\")) {\n const lookahead = this.lookahead();\n\n if (lookahead.type !== tt.colon && lookahead.type !== tt.question) {\n this.next();\n protoStart = this.state.start;\n allowStatic = false;\n }\n }\n\n if (allowStatic && this.isContextual(\"static\")) {\n const lookahead = this.lookahead();\n\n // static is a valid identifier name\n if (lookahead.type !== tt.colon && lookahead.type !== tt.question) {\n this.next();\n isStatic = true;\n }\n }\n\n const variance = this.flowParseVariance();\n\n if (this.eat(tt.bracketL)) {\n if (protoStart != null) {\n this.unexpected(protoStart);\n }\n if (this.eat(tt.bracketL)) {\n if (variance) {\n this.unexpected(variance.start);\n }\n nodeStart.internalSlots.push(\n this.flowParseObjectTypeInternalSlot(node, isStatic),\n );\n } else {\n nodeStart.indexers.push(\n this.flowParseObjectTypeIndexer(node, isStatic, variance),\n );\n }\n } else if (this.match(tt.parenL) || this.isRelational(\"<\")) {\n if (protoStart != null) {\n this.unexpected(protoStart);\n }\n if (variance) {\n this.unexpected(variance.start);\n }\n nodeStart.callProperties.push(\n this.flowParseObjectTypeCallProperty(node, isStatic),\n );\n } else {\n let kind = \"init\";\n\n if (this.isContextual(\"get\") || this.isContextual(\"set\")) {\n const lookahead = this.lookahead();\n if (\n lookahead.type === tt.name ||\n lookahead.type === tt.string ||\n lookahead.type === tt.num\n ) {\n kind = this.state.value;\n this.next();\n }\n }\n\n const propOrInexact = this.flowParseObjectTypeProperty(\n node,\n isStatic,\n protoStart,\n variance,\n kind,\n allowSpread,\n allowInexact ?? !exact,\n );\n\n if (propOrInexact === null) {\n inexact = true;\n inexactStart = this.state.lastTokStart;\n } else {\n nodeStart.properties.push(propOrInexact);\n }\n }\n\n this.flowObjectTypeSemicolon();\n\n if (\n inexactStart &&\n !this.match(tt.braceR) &&\n !this.match(tt.braceBarR)\n ) {\n this.raise(\n inexactStart,\n FlowErrors.UnexpectedExplicitInexactInObject,\n );\n }\n }\n\n this.expect(endDelim);\n\n /* The inexact flag should only be added on ObjectTypeAnnotations that\n * are not the body of an interface, declare interface, or declare class.\n * Since spreads are only allowed in objec types, checking that is\n * sufficient here.\n */\n if (allowSpread) {\n nodeStart.inexact = inexact;\n }\n\n const out = this.finishNode(nodeStart, \"ObjectTypeAnnotation\");\n\n this.state.inType = oldInType;\n\n return out;\n }\n\n flowParseObjectTypeProperty(\n node: N.FlowObjectTypeProperty | N.FlowObjectTypeSpreadProperty,\n isStatic: boolean,\n protoStart: ?number,\n variance: ?N.FlowVariance,\n kind: string,\n allowSpread: boolean,\n allowInexact: boolean,\n ): (N.FlowObjectTypeProperty | N.FlowObjectTypeSpreadProperty) | null {\n if (this.eat(tt.ellipsis)) {\n const isInexactToken =\n this.match(tt.comma) ||\n this.match(tt.semi) ||\n this.match(tt.braceR) ||\n this.match(tt.braceBarR);\n\n if (isInexactToken) {\n if (!allowSpread) {\n this.raise(\n this.state.lastTokStart,\n FlowErrors.InexactInsideNonObject,\n );\n } else if (!allowInexact) {\n this.raise(this.state.lastTokStart, FlowErrors.InexactInsideExact);\n }\n if (variance) {\n this.raise(variance.start, FlowErrors.InexactVariance);\n }\n\n return null;\n }\n\n if (!allowSpread) {\n this.raise(this.state.lastTokStart, FlowErrors.UnexpectedSpreadType);\n }\n if (protoStart != null) {\n this.unexpected(protoStart);\n }\n if (variance) {\n this.raise(variance.start, FlowErrors.SpreadVariance);\n }\n\n node.argument = this.flowParseType();\n return this.finishNode(node, \"ObjectTypeSpreadProperty\");\n } else {\n node.key = this.flowParseObjectPropertyKey();\n node.static = isStatic;\n node.proto = protoStart != null;\n node.kind = kind;\n\n let optional = false;\n if (this.isRelational(\"<\") || this.match(tt.parenL)) {\n // This is a method property\n node.method = true;\n\n if (protoStart != null) {\n this.unexpected(protoStart);\n }\n if (variance) {\n this.unexpected(variance.start);\n }\n\n node.value = this.flowParseObjectTypeMethodish(\n this.startNodeAt(node.start, node.loc.start),\n );\n if (kind === \"get\" || kind === \"set\") {\n this.flowCheckGetterSetterParams(node);\n }\n } else {\n if (kind !== \"init\") this.unexpected();\n\n node.method = false;\n\n if (this.eat(tt.question)) {\n optional = true;\n }\n node.value = this.flowParseTypeInitialiser();\n node.variance = variance;\n }\n\n node.optional = optional;\n\n return this.finishNode(node, \"ObjectTypeProperty\");\n }\n }\n\n // This is similar to checkGetterSetterParams, but as\n // @babel/parser uses non estree properties we cannot reuse it here\n flowCheckGetterSetterParams(\n property: N.FlowObjectTypeProperty | N.FlowObjectTypeSpreadProperty,\n ): void {\n const paramCount = property.kind === \"get\" ? 0 : 1;\n const start = property.start;\n const length =\n property.value.params.length + (property.value.rest ? 1 : 0);\n if (length !== paramCount) {\n if (property.kind === \"get\") {\n this.raise(start, Errors.BadGetterArity);\n } else {\n this.raise(start, Errors.BadSetterArity);\n }\n }\n\n if (property.kind === \"set\" && property.value.rest) {\n this.raise(start, Errors.BadSetterRestParameter);\n }\n }\n\n flowObjectTypeSemicolon(): void {\n if (\n !this.eat(tt.semi) &&\n !this.eat(tt.comma) &&\n !this.match(tt.braceR) &&\n !this.match(tt.braceBarR)\n ) {\n this.unexpected();\n }\n }\n\n flowParseQualifiedTypeIdentifier(\n startPos?: number,\n startLoc?: Position,\n id?: N.Identifier,\n ): N.FlowQualifiedTypeIdentifier {\n startPos = startPos || this.state.start;\n startLoc = startLoc || this.state.startLoc;\n let node = id || this.flowParseRestrictedIdentifier(true);\n\n while (this.eat(tt.dot)) {\n const node2 = this.startNodeAt(startPos, startLoc);\n node2.qualification = node;\n node2.id = this.flowParseRestrictedIdentifier(true);\n node = this.finishNode(node2, \"QualifiedTypeIdentifier\");\n }\n\n return node;\n }\n\n flowParseGenericType(\n startPos: number,\n startLoc: Position,\n id: N.Identifier,\n ): N.FlowGenericTypeAnnotation {\n const node = this.startNodeAt(startPos, startLoc);\n\n node.typeParameters = null;\n node.id = this.flowParseQualifiedTypeIdentifier(startPos, startLoc, id);\n\n if (this.isRelational(\"<\")) {\n node.typeParameters = this.flowParseTypeParameterInstantiation();\n }\n\n return this.finishNode(node, \"GenericTypeAnnotation\");\n }\n\n flowParseTypeofType(): N.FlowTypeofTypeAnnotation {\n const node = this.startNode();\n this.expect(tt._typeof);\n node.argument = this.flowParsePrimaryType();\n return this.finishNode(node, \"TypeofTypeAnnotation\");\n }\n\n flowParseTupleType(): N.FlowTupleTypeAnnotation {\n const node = this.startNode();\n node.types = [];\n this.expect(tt.bracketL);\n // We allow trailing commas\n while (this.state.pos < this.length && !this.match(tt.bracketR)) {\n node.types.push(this.flowParseType());\n if (this.match(tt.bracketR)) break;\n this.expect(tt.comma);\n }\n this.expect(tt.bracketR);\n return this.finishNode(node, \"TupleTypeAnnotation\");\n }\n\n flowParseFunctionTypeParam(): N.FlowFunctionTypeParam {\n let name = null;\n let optional = false;\n let typeAnnotation = null;\n const node = this.startNode();\n const lh = this.lookahead();\n if (lh.type === tt.colon || lh.type === tt.question) {\n name = this.parseIdentifier();\n if (this.eat(tt.question)) {\n optional = true;\n }\n typeAnnotation = this.flowParseTypeInitialiser();\n } else {\n typeAnnotation = this.flowParseType();\n }\n node.name = name;\n node.optional = optional;\n node.typeAnnotation = typeAnnotation;\n return this.finishNode(node, \"FunctionTypeParam\");\n }\n\n reinterpretTypeAsFunctionTypeParam(\n type: N.FlowType,\n ): N.FlowFunctionTypeParam {\n const node = this.startNodeAt(type.start, type.loc.start);\n node.name = null;\n node.optional = false;\n node.typeAnnotation = type;\n return this.finishNode(node, \"FunctionTypeParam\");\n }\n\n flowParseFunctionTypeParams(\n params: N.FlowFunctionTypeParam[] = [],\n ): { params: N.FlowFunctionTypeParam[], rest: ?N.FlowFunctionTypeParam } {\n let rest: ?N.FlowFunctionTypeParam = null;\n while (!this.match(tt.parenR) && !this.match(tt.ellipsis)) {\n params.push(this.flowParseFunctionTypeParam());\n if (!this.match(tt.parenR)) {\n this.expect(tt.comma);\n }\n }\n if (this.eat(tt.ellipsis)) {\n rest = this.flowParseFunctionTypeParam();\n }\n return { params, rest };\n }\n\n flowIdentToTypeAnnotation(\n startPos: number,\n startLoc: Position,\n node: N.FlowTypeAnnotation,\n id: N.Identifier,\n ): N.FlowTypeAnnotation {\n switch (id.name) {\n case \"any\":\n return this.finishNode(node, \"AnyTypeAnnotation\");\n\n case \"bool\":\n case \"boolean\":\n return this.finishNode(node, \"BooleanTypeAnnotation\");\n\n case \"mixed\":\n return this.finishNode(node, \"MixedTypeAnnotation\");\n\n case \"empty\":\n return this.finishNode(node, \"EmptyTypeAnnotation\");\n\n case \"number\":\n return this.finishNode(node, \"NumberTypeAnnotation\");\n\n case \"string\":\n return this.finishNode(node, \"StringTypeAnnotation\");\n\n case \"symbol\":\n return this.finishNode(node, \"SymbolTypeAnnotation\");\n\n default:\n this.checkNotUnderscore(id.name);\n return this.flowParseGenericType(startPos, startLoc, id);\n }\n }\n\n // The parsing of types roughly parallels the parsing of expressions, and\n // primary types are kind of like primary expressions...they're the\n // primitives with which other types are constructed.\n flowParsePrimaryType(): N.FlowTypeAnnotation {\n const startPos = this.state.start;\n const startLoc = this.state.startLoc;\n const node = this.startNode();\n let tmp;\n let type;\n let isGroupedType = false;\n const oldNoAnonFunctionType = this.state.noAnonFunctionType;\n\n switch (this.state.type) {\n case tt.name:\n if (this.isContextual(\"interface\")) {\n return this.flowParseInterfaceType();\n }\n\n return this.flowIdentToTypeAnnotation(\n startPos,\n startLoc,\n node,\n this.parseIdentifier(),\n );\n\n case tt.braceL:\n return this.flowParseObjectType({\n allowStatic: false,\n allowExact: false,\n allowSpread: true,\n allowProto: false,\n allowInexact: true,\n });\n\n case tt.braceBarL:\n return this.flowParseObjectType({\n allowStatic: false,\n allowExact: true,\n allowSpread: true,\n allowProto: false,\n allowInexact: false,\n });\n\n case tt.bracketL:\n this.state.noAnonFunctionType = false;\n type = this.flowParseTupleType();\n this.state.noAnonFunctionType = oldNoAnonFunctionType;\n return type;\n\n case tt.relational:\n if (this.state.value === \"<\") {\n node.typeParameters = this.flowParseTypeParameterDeclaration();\n this.expect(tt.parenL);\n tmp = this.flowParseFunctionTypeParams();\n node.params = tmp.params;\n node.rest = tmp.rest;\n this.expect(tt.parenR);\n\n this.expect(tt.arrow);\n\n node.returnType = this.flowParseType();\n\n return this.finishNode(node, \"FunctionTypeAnnotation\");\n }\n break;\n\n case tt.parenL:\n this.next();\n\n // Check to see if this is actually a grouped type\n if (!this.match(tt.parenR) && !this.match(tt.ellipsis)) {\n if (this.match(tt.name)) {\n const token = this.lookahead().type;\n isGroupedType = token !== tt.question && token !== tt.colon;\n } else {\n isGroupedType = true;\n }\n }\n\n if (isGroupedType) {\n this.state.noAnonFunctionType = false;\n type = this.flowParseType();\n this.state.noAnonFunctionType = oldNoAnonFunctionType;\n\n // A `,` or a `) =>` means this is an anonymous function type\n if (\n this.state.noAnonFunctionType ||\n !(\n this.match(tt.comma) ||\n (this.match(tt.parenR) && this.lookahead().type === tt.arrow)\n )\n ) {\n this.expect(tt.parenR);\n return type;\n } else {\n // Eat a comma if there is one\n this.eat(tt.comma);\n }\n }\n\n if (type) {\n tmp = this.flowParseFunctionTypeParams([\n this.reinterpretTypeAsFunctionTypeParam(type),\n ]);\n } else {\n tmp = this.flowParseFunctionTypeParams();\n }\n\n node.params = tmp.params;\n node.rest = tmp.rest;\n\n this.expect(tt.parenR);\n\n this.expect(tt.arrow);\n\n node.returnType = this.flowParseType();\n\n node.typeParameters = null;\n\n return this.finishNode(node, \"FunctionTypeAnnotation\");\n\n case tt.string:\n return this.parseLiteral(\n this.state.value,\n \"StringLiteralTypeAnnotation\",\n );\n\n case tt._true:\n case tt._false:\n node.value = this.match(tt._true);\n this.next();\n return this.finishNode(node, \"BooleanLiteralTypeAnnotation\");\n\n case tt.plusMin:\n if (this.state.value === \"-\") {\n this.next();\n if (this.match(tt.num)) {\n return this.parseLiteral(\n -this.state.value,\n \"NumberLiteralTypeAnnotation\",\n node.start,\n node.loc.start,\n );\n }\n\n if (this.match(tt.bigint)) {\n return this.parseLiteral(\n -this.state.value,\n \"BigIntLiteralTypeAnnotation\",\n node.start,\n node.loc.start,\n );\n }\n\n throw this.raise(\n this.state.start,\n FlowErrors.UnexpectedSubtractionOperand,\n );\n }\n\n throw this.unexpected();\n case tt.num:\n return this.parseLiteral(\n this.state.value,\n \"NumberLiteralTypeAnnotation\",\n );\n\n case tt.bigint:\n return this.parseLiteral(\n this.state.value,\n \"BigIntLiteralTypeAnnotation\",\n );\n\n case tt._void:\n this.next();\n return this.finishNode(node, \"VoidTypeAnnotation\");\n\n case tt._null:\n this.next();\n return this.finishNode(node, \"NullLiteralTypeAnnotation\");\n\n case tt._this:\n this.next();\n return this.finishNode(node, \"ThisTypeAnnotation\");\n\n case tt.star:\n this.next();\n return this.finishNode(node, \"ExistsTypeAnnotation\");\n\n default:\n if (this.state.type.keyword === \"typeof\") {\n return this.flowParseTypeofType();\n } else if (this.state.type.keyword) {\n const label = this.state.type.label;\n this.next();\n return super.createIdentifier(node, label);\n }\n }\n\n throw this.unexpected();\n }\n\n flowParsePostfixType(): N.FlowTypeAnnotation {\n const startPos = this.state.start,\n startLoc = this.state.startLoc;\n let type = this.flowParsePrimaryType();\n while (this.match(tt.bracketL) && !this.canInsertSemicolon()) {\n const node = this.startNodeAt(startPos, startLoc);\n node.elementType = type;\n this.expect(tt.bracketL);\n this.expect(tt.bracketR);\n type = this.finishNode(node, \"ArrayTypeAnnotation\");\n }\n return type;\n }\n\n flowParsePrefixType(): N.FlowTypeAnnotation {\n const node = this.startNode();\n if (this.eat(tt.question)) {\n node.typeAnnotation = this.flowParsePrefixType();\n return this.finishNode(node, \"NullableTypeAnnotation\");\n } else {\n return this.flowParsePostfixType();\n }\n }\n\n flowParseAnonFunctionWithoutParens(): N.FlowTypeAnnotation {\n const param = this.flowParsePrefixType();\n if (!this.state.noAnonFunctionType && this.eat(tt.arrow)) {\n // TODO: This should be a type error. Passing in a SourceLocation, and it expects a Position.\n const node = this.startNodeAt(param.start, param.loc.start);\n node.params = [this.reinterpretTypeAsFunctionTypeParam(param)];\n node.rest = null;\n node.returnType = this.flowParseType();\n node.typeParameters = null;\n return this.finishNode(node, \"FunctionTypeAnnotation\");\n }\n return param;\n }\n\n flowParseIntersectionType(): N.FlowTypeAnnotation {\n const node = this.startNode();\n this.eat(tt.bitwiseAND);\n const type = this.flowParseAnonFunctionWithoutParens();\n node.types = [type];\n while (this.eat(tt.bitwiseAND)) {\n node.types.push(this.flowParseAnonFunctionWithoutParens());\n }\n return node.types.length === 1\n ? type\n : this.finishNode(node, \"IntersectionTypeAnnotation\");\n }\n\n flowParseUnionType(): N.FlowTypeAnnotation {\n const node = this.startNode();\n this.eat(tt.bitwiseOR);\n const type = this.flowParseIntersectionType();\n node.types = [type];\n while (this.eat(tt.bitwiseOR)) {\n node.types.push(this.flowParseIntersectionType());\n }\n return node.types.length === 1\n ? type\n : this.finishNode(node, \"UnionTypeAnnotation\");\n }\n\n flowParseType(): N.FlowTypeAnnotation {\n const oldInType = this.state.inType;\n this.state.inType = true;\n const type = this.flowParseUnionType();\n this.state.inType = oldInType;\n // Ensure that a brace after a function generic type annotation is a\n // statement, except in arrow functions (noAnonFunctionType)\n this.state.exprAllowed =\n this.state.exprAllowed || this.state.noAnonFunctionType;\n return type;\n }\n\n flowParseTypeOrImplicitInstantiation(): N.FlowTypeAnnotation {\n if (this.state.type === tt.name && this.state.value === \"_\") {\n const startPos = this.state.start;\n const startLoc = this.state.startLoc;\n const node = this.parseIdentifier();\n return this.flowParseGenericType(startPos, startLoc, node);\n } else {\n return this.flowParseType();\n }\n }\n\n flowParseTypeAnnotation(): N.FlowTypeAnnotation {\n const node = this.startNode();\n node.typeAnnotation = this.flowParseTypeInitialiser();\n return this.finishNode(node, \"TypeAnnotation\");\n }\n\n flowParseTypeAnnotatableIdentifier(\n allowPrimitiveOverride?: boolean,\n ): N.Identifier {\n const ident = allowPrimitiveOverride\n ? this.parseIdentifier()\n : this.flowParseRestrictedIdentifier();\n if (this.match(tt.colon)) {\n ident.typeAnnotation = this.flowParseTypeAnnotation();\n this.resetEndLocation(ident);\n }\n return ident;\n }\n\n typeCastToParameter(node: N.Node): N.Node {\n node.expression.typeAnnotation = node.typeAnnotation;\n\n this.resetEndLocation(\n node.expression,\n node.typeAnnotation.end,\n node.typeAnnotation.loc.end,\n );\n\n return node.expression;\n }\n\n flowParseVariance(): ?N.FlowVariance {\n let variance = null;\n if (this.match(tt.plusMin)) {\n variance = this.startNode();\n if (this.state.value === \"+\") {\n variance.kind = \"plus\";\n } else {\n variance.kind = \"minus\";\n }\n this.next();\n this.finishNode(variance, \"Variance\");\n }\n return variance;\n }\n\n // ==================================\n // Overrides\n // ==================================\n\n parseFunctionBody(\n node: N.Function,\n allowExpressionBody: ?boolean,\n isMethod?: boolean = false,\n ): void {\n if (allowExpressionBody) {\n return this.forwardNoArrowParamsConversionAt(node, () =>\n super.parseFunctionBody(node, true, isMethod),\n );\n }\n\n return super.parseFunctionBody(node, false, isMethod);\n }\n\n parseFunctionBodyAndFinish(\n node: N.BodilessFunctionOrMethodBase,\n type: string,\n isMethod?: boolean = false,\n ): void {\n if (this.match(tt.colon)) {\n const typeNode = this.startNode();\n\n [\n // $FlowFixMe (destructuring not supported yet)\n typeNode.typeAnnotation,\n // $FlowFixMe (destructuring not supported yet)\n node.predicate,\n ] = this.flowParseTypeAndPredicateInitialiser();\n\n node.returnType = typeNode.typeAnnotation\n ? this.finishNode(typeNode, \"TypeAnnotation\")\n : null;\n }\n\n super.parseFunctionBodyAndFinish(node, type, isMethod);\n }\n\n // interfaces and enums\n parseStatement(context: ?string, topLevel?: boolean): N.Statement {\n // strict mode handling of `interface` since it's a reserved word\n if (\n this.state.strict &&\n this.match(tt.name) &&\n this.state.value === \"interface\"\n ) {\n const node = this.startNode();\n this.next();\n return this.flowParseInterface(node);\n } else if (this.shouldParseEnums() && this.isContextual(\"enum\")) {\n const node = this.startNode();\n this.next();\n return this.flowParseEnumDeclaration(node);\n } else {\n const stmt = super.parseStatement(context, topLevel);\n // We will parse a flow pragma in any comment before the first statement.\n if (this.flowPragma === undefined && !this.isValidDirective(stmt)) {\n this.flowPragma = null;\n }\n return stmt;\n }\n }\n\n // declares, interfaces and type aliases\n parseExpressionStatement(\n node: N.ExpressionStatement,\n expr: N.Expression,\n ): N.ExpressionStatement {\n if (expr.type === \"Identifier\") {\n if (expr.name === \"declare\") {\n if (\n this.match(tt._class) ||\n this.match(tt.name) ||\n this.match(tt._function) ||\n this.match(tt._var) ||\n this.match(tt._export)\n ) {\n return this.flowParseDeclare(node);\n }\n } else if (this.match(tt.name)) {\n if (expr.name === \"interface\") {\n return this.flowParseInterface(node);\n } else if (expr.name === \"type\") {\n return this.flowParseTypeAlias(node);\n } else if (expr.name === \"opaque\") {\n return this.flowParseOpaqueType(node, false);\n }\n }\n }\n\n return super.parseExpressionStatement(node, expr);\n }\n\n // export type\n shouldParseExportDeclaration(): boolean {\n return (\n this.isContextual(\"type\") ||\n this.isContextual(\"interface\") ||\n this.isContextual(\"opaque\") ||\n (this.shouldParseEnums() && this.isContextual(\"enum\")) ||\n super.shouldParseExportDeclaration()\n );\n }\n\n isExportDefaultSpecifier(): boolean {\n if (\n this.match(tt.name) &&\n (this.state.value === \"type\" ||\n this.state.value === \"interface\" ||\n this.state.value === \"opaque\" ||\n (this.shouldParseEnums() && this.state.value === \"enum\"))\n ) {\n return false;\n }\n\n return super.isExportDefaultSpecifier();\n }\n\n parseExportDefaultExpression(): N.Expression | N.Declaration {\n if (this.shouldParseEnums() && this.isContextual(\"enum\")) {\n const node = this.startNode();\n this.next();\n return this.flowParseEnumDeclaration(node);\n }\n return super.parseExportDefaultExpression();\n }\n\n parseConditional(\n expr: N.Expression,\n noIn: ?boolean,\n startPos: number,\n startLoc: Position,\n refNeedsArrowPos?: ?Pos,\n ): N.Expression {\n if (!this.match(tt.question)) return expr;\n\n // only use the expensive \"tryParse\" method if there is a question mark\n // and if we come from inside parens\n if (refNeedsArrowPos) {\n const result = this.tryParse(() =>\n super.parseConditional(expr, noIn, startPos, startLoc),\n );\n\n if (!result.node) {\n // $FlowIgnore\n refNeedsArrowPos.start = result.error.pos || this.state.start;\n return expr;\n }\n\n if (result.error) this.state = result.failState;\n return result.node;\n }\n\n this.expect(tt.question);\n const state = this.state.clone();\n const originalNoArrowAt = this.state.noArrowAt;\n const node = this.startNodeAt(startPos, startLoc);\n let { consequent, failed } = this.tryParseConditionalConsequent();\n let [valid, invalid] = this.getArrowLikeExpressions(consequent);\n\n if (failed || invalid.length > 0) {\n const noArrowAt = [...originalNoArrowAt];\n\n if (invalid.length > 0) {\n this.state = state;\n this.state.noArrowAt = noArrowAt;\n\n for (let i = 0; i < invalid.length; i++) {\n noArrowAt.push(invalid[i].start);\n }\n\n ({ consequent, failed } = this.tryParseConditionalConsequent());\n [valid, invalid] = this.getArrowLikeExpressions(consequent);\n }\n\n if (failed && valid.length > 1) {\n // if there are two or more possible correct ways of parsing, throw an\n // error.\n // e.g. Source: a ? (b): c => (d): e => f\n // Result 1: a ? b : (c => ((d): e => f))\n // Result 2: a ? ((b): c => d) : (e => f)\n this.raise(state.start, FlowErrors.AmbiguousConditionalArrow);\n }\n\n if (failed && valid.length === 1) {\n this.state = state;\n this.state.noArrowAt = noArrowAt.concat(valid[0].start);\n ({ consequent, failed } = this.tryParseConditionalConsequent());\n }\n }\n\n this.getArrowLikeExpressions(consequent, true);\n\n this.state.noArrowAt = originalNoArrowAt;\n this.expect(tt.colon);\n\n node.test = expr;\n node.consequent = consequent;\n node.alternate = this.forwardNoArrowParamsConversionAt(node, () =>\n this.parseMaybeAssign(noIn, undefined, undefined, undefined),\n );\n\n return this.finishNode(node, \"ConditionalExpression\");\n }\n\n tryParseConditionalConsequent(): {\n consequent: N.Expression,\n failed: boolean,\n } {\n this.state.noArrowParamsConversionAt.push(this.state.start);\n\n const consequent = this.parseMaybeAssign();\n const failed = !this.match(tt.colon);\n\n this.state.noArrowParamsConversionAt.pop();\n\n return { consequent, failed };\n }\n\n // Given an expression, walks through out its arrow functions whose body is\n // an expression and through out conditional expressions. It returns every\n // function which has been parsed with a return type but could have been\n // parenthesized expressions.\n // These functions are separated into two arrays: one containing the ones\n // whose parameters can be converted to assignable lists, one containing the\n // others.\n getArrowLikeExpressions(\n node: N.Expression,\n disallowInvalid?: boolean,\n ): [N.ArrowFunctionExpression[], N.ArrowFunctionExpression[]] {\n const stack = [node];\n const arrows: N.ArrowFunctionExpression[] = [];\n\n while (stack.length !== 0) {\n const node = stack.pop();\n if (node.type === \"ArrowFunctionExpression\") {\n if (node.typeParameters || !node.returnType) {\n // This is an arrow expression without ambiguity, so check its parameters\n this.finishArrowValidation(node);\n } else {\n arrows.push(node);\n }\n stack.push(node.body);\n } else if (node.type === \"ConditionalExpression\") {\n stack.push(node.consequent);\n stack.push(node.alternate);\n }\n }\n\n if (disallowInvalid) {\n arrows.forEach(node => this.finishArrowValidation(node));\n return [arrows, []];\n }\n\n return partition(arrows, node =>\n node.params.every(param => this.isAssignable(param, true)),\n );\n }\n\n finishArrowValidation(node: N.ArrowFunctionExpression) {\n this.toAssignableList(\n // node.params is Expression[] instead of $ReadOnlyArray because it\n // has not been converted yet.\n ((node.params: any): N.Expression[]),\n node.extra?.trailingComma,\n );\n // Enter scope, as checkParams defines bindings\n this.scope.enter(SCOPE_FUNCTION | SCOPE_ARROW);\n // Use super's method to force the parameters to be checked\n super.checkParams(node, false, true);\n this.scope.exit();\n }\n\n forwardNoArrowParamsConversionAt(node: N.Node, parse: () => T): T {\n let result: T;\n if (this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {\n this.state.noArrowParamsConversionAt.push(this.state.start);\n result = parse();\n this.state.noArrowParamsConversionAt.pop();\n } else {\n result = parse();\n }\n\n return result;\n }\n\n parseParenItem(\n node: N.Expression,\n startPos: number,\n startLoc: Position,\n ): N.Expression {\n node = super.parseParenItem(node, startPos, startLoc);\n if (this.eat(tt.question)) {\n node.optional = true;\n // Include questionmark in location of node\n // Don't use this.finishNode() as otherwise we might process comments twice and\n // include already consumed parens\n this.resetEndLocation(node);\n }\n\n if (this.match(tt.colon)) {\n const typeCastNode = this.startNodeAt(startPos, startLoc);\n typeCastNode.expression = node;\n typeCastNode.typeAnnotation = this.flowParseTypeAnnotation();\n\n return this.finishNode(typeCastNode, \"TypeCastExpression\");\n }\n\n return node;\n }\n\n assertModuleNodeAllowed(node: N.Node) {\n if (\n (node.type === \"ImportDeclaration\" &&\n (node.importKind === \"type\" || node.importKind === \"typeof\")) ||\n (node.type === \"ExportNamedDeclaration\" &&\n node.exportKind === \"type\") ||\n (node.type === \"ExportAllDeclaration\" && node.exportKind === \"type\")\n ) {\n // Allow Flowtype imports and exports in all conditions because\n // Flow itself does not care about 'sourceType'.\n return;\n }\n\n super.assertModuleNodeAllowed(node);\n }\n\n parseExport(node: N.Node): N.AnyExport {\n const decl = super.parseExport(node);\n if (\n decl.type === \"ExportNamedDeclaration\" ||\n decl.type === \"ExportAllDeclaration\"\n ) {\n decl.exportKind = decl.exportKind || \"value\";\n }\n return decl;\n }\n\n parseExportDeclaration(node: N.ExportNamedDeclaration): ?N.Declaration {\n if (this.isContextual(\"type\")) {\n node.exportKind = \"type\";\n\n const declarationNode = this.startNode();\n this.next();\n\n if (this.match(tt.braceL)) {\n // export type { foo, bar };\n node.specifiers = this.parseExportSpecifiers();\n this.parseExportFrom(node);\n return null;\n } else {\n // export type Foo = Bar;\n return this.flowParseTypeAlias(declarationNode);\n }\n } else if (this.isContextual(\"opaque\")) {\n node.exportKind = \"type\";\n\n const declarationNode = this.startNode();\n this.next();\n // export opaque type Foo = Bar;\n return this.flowParseOpaqueType(declarationNode, false);\n } else if (this.isContextual(\"interface\")) {\n node.exportKind = \"type\";\n const declarationNode = this.startNode();\n this.next();\n return this.flowParseInterface(declarationNode);\n } else if (this.shouldParseEnums() && this.isContextual(\"enum\")) {\n node.exportKind = \"value\";\n const declarationNode = this.startNode();\n this.next();\n return this.flowParseEnumDeclaration(declarationNode);\n } else {\n return super.parseExportDeclaration(node);\n }\n }\n\n eatExportStar(node: N.Node): boolean {\n if (super.eatExportStar(...arguments)) return true;\n\n if (this.isContextual(\"type\") && this.lookahead().type === tt.star) {\n node.exportKind = \"type\";\n this.next();\n this.next();\n return true;\n }\n\n return false;\n }\n\n maybeParseExportNamespaceSpecifier(node: N.Node): boolean {\n const pos = this.state.start;\n const hasNamespace = super.maybeParseExportNamespaceSpecifier(node);\n if (hasNamespace && node.exportKind === \"type\") {\n this.unexpected(pos);\n }\n return hasNamespace;\n }\n\n parseClassId(node: N.Class, isStatement: boolean, optionalId: ?boolean) {\n super.parseClassId(node, isStatement, optionalId);\n if (this.isRelational(\"<\")) {\n node.typeParameters = this.flowParseTypeParameterDeclaration();\n }\n }\n\n parseClassMember(\n classBody: N.ClassBody,\n member: any,\n state: { hadConstructor: boolean },\n constructorAllowsSuper: boolean,\n ): void {\n const pos = this.state.start;\n if (this.isContextual(\"declare\")) {\n if (this.parseClassMemberFromModifier(classBody, member)) {\n // 'declare' is a class element name\n return;\n }\n\n member.declare = true;\n }\n\n super.parseClassMember(classBody, member, state, constructorAllowsSuper);\n\n if (member.declare) {\n if (\n member.type !== \"ClassProperty\" &&\n member.type !== \"ClassPrivateProperty\"\n ) {\n this.raise(pos, FlowErrors.DeclareClassElement);\n } else if (member.value) {\n this.raise(\n member.value.start,\n FlowErrors.DeclareClassFieldInitializer,\n );\n }\n }\n }\n\n // ensure that inside flow types, we bypass the jsx parser plugin\n getTokenFromCode(code: number): void {\n const next = this.input.charCodeAt(this.state.pos + 1);\n if (code === charCodes.leftCurlyBrace && next === charCodes.verticalBar) {\n return this.finishOp(tt.braceBarL, 2);\n } else if (\n this.state.inType &&\n (code === charCodes.greaterThan || code === charCodes.lessThan)\n ) {\n return this.finishOp(tt.relational, 1);\n } else if (isIteratorStart(code, next)) {\n this.state.isIterator = true;\n return super.readWord();\n } else {\n return super.getTokenFromCode(code);\n }\n }\n\n isAssignable(node: N.Node, isBinding?: boolean): boolean {\n switch (node.type) {\n case \"Identifier\":\n case \"ObjectPattern\":\n case \"ArrayPattern\":\n case \"AssignmentPattern\":\n return true;\n\n case \"ObjectExpression\": {\n const last = node.properties.length - 1;\n return node.properties.every((prop, i) => {\n return (\n prop.type !== \"ObjectMethod\" &&\n (i === last || prop.type === \"SpreadElement\") &&\n this.isAssignable(prop)\n );\n });\n }\n\n case \"ObjectProperty\":\n return this.isAssignable(node.value);\n\n case \"SpreadElement\":\n return this.isAssignable(node.argument);\n\n case \"ArrayExpression\":\n return node.elements.every(element => this.isAssignable(element));\n\n case \"AssignmentExpression\":\n return node.operator === \"=\";\n\n case \"ParenthesizedExpression\":\n case \"TypeCastExpression\":\n return this.isAssignable(node.expression);\n\n case \"MemberExpression\":\n case \"OptionalMemberExpression\":\n return !isBinding;\n\n default:\n return false;\n }\n }\n\n toAssignable(node: N.Node): N.Node {\n if (node.type === \"TypeCastExpression\") {\n return super.toAssignable(this.typeCastToParameter(node));\n } else {\n return super.toAssignable(node);\n }\n }\n\n // turn type casts that we found in function parameter head into type annotated params\n toAssignableList(\n exprList: N.Expression[],\n trailingCommaPos?: ?number,\n ): $ReadOnlyArray {\n for (let i = 0; i < exprList.length; i++) {\n const expr = exprList[i];\n if (expr && expr.type === \"TypeCastExpression\") {\n exprList[i] = this.typeCastToParameter(expr);\n }\n }\n return super.toAssignableList(exprList, trailingCommaPos);\n }\n\n // this is a list of nodes, from something like a call expression, we need to filter the\n // type casts that we've found that are illegal in this context\n toReferencedList(\n exprList: $ReadOnlyArray,\n isParenthesizedExpr?: boolean,\n ): $ReadOnlyArray {\n for (let i = 0; i < exprList.length; i++) {\n const expr = exprList[i];\n if (\n expr &&\n expr.type === \"TypeCastExpression\" &&\n (!expr.extra || !expr.extra.parenthesized) &&\n (exprList.length > 1 || !isParenthesizedExpr)\n ) {\n this.raise(expr.typeAnnotation.start, FlowErrors.TypeCastInPattern);\n }\n }\n\n return exprList;\n }\n\n checkLVal(\n expr: N.Expression,\n bindingType: BindingTypes = BIND_NONE,\n checkClashes: ?{ [key: string]: boolean },\n contextDescription: string,\n ): void {\n if (expr.type !== \"TypeCastExpression\") {\n return super.checkLVal(\n expr,\n bindingType,\n checkClashes,\n contextDescription,\n );\n }\n }\n\n // parse class property type annotations\n parseClassProperty(node: N.ClassProperty): N.ClassProperty {\n if (this.match(tt.colon)) {\n node.typeAnnotation = this.flowParseTypeAnnotation();\n }\n return super.parseClassProperty(node);\n }\n\n parseClassPrivateProperty(\n node: N.ClassPrivateProperty,\n ): N.ClassPrivateProperty {\n if (this.match(tt.colon)) {\n node.typeAnnotation = this.flowParseTypeAnnotation();\n }\n return super.parseClassPrivateProperty(node);\n }\n\n // determine whether or not we're currently in the position where a class method would appear\n isClassMethod(): boolean {\n return this.isRelational(\"<\") || super.isClassMethod();\n }\n\n // determine whether or not we're currently in the position where a class property would appear\n isClassProperty(): boolean {\n return this.match(tt.colon) || super.isClassProperty();\n }\n\n isNonstaticConstructor(method: N.ClassMethod | N.ClassProperty): boolean {\n return !this.match(tt.colon) && super.isNonstaticConstructor(method);\n }\n\n // parse type parameters for class methods\n pushClassMethod(\n classBody: N.ClassBody,\n method: N.ClassMethod,\n isGenerator: boolean,\n isAsync: boolean,\n isConstructor: boolean,\n allowsDirectSuper: boolean,\n ): void {\n if ((method: $FlowFixMe).variance) {\n this.unexpected((method: $FlowFixMe).variance.start);\n }\n delete (method: $FlowFixMe).variance;\n if (this.isRelational(\"<\")) {\n method.typeParameters = this.flowParseTypeParameterDeclaration();\n }\n\n super.pushClassMethod(\n classBody,\n method,\n isGenerator,\n isAsync,\n isConstructor,\n allowsDirectSuper,\n );\n }\n\n pushClassPrivateMethod(\n classBody: N.ClassBody,\n method: N.ClassPrivateMethod,\n isGenerator: boolean,\n isAsync: boolean,\n ): void {\n if ((method: $FlowFixMe).variance) {\n this.unexpected((method: $FlowFixMe).variance.start);\n }\n delete (method: $FlowFixMe).variance;\n if (this.isRelational(\"<\")) {\n method.typeParameters = this.flowParseTypeParameterDeclaration();\n }\n\n super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync);\n }\n\n // parse a the super class type parameters and implements\n parseClassSuper(node: N.Class): void {\n super.parseClassSuper(node);\n if (node.superClass && this.isRelational(\"<\")) {\n node.superTypeParameters = this.flowParseTypeParameterInstantiation();\n }\n if (this.isContextual(\"implements\")) {\n this.next();\n const implemented: N.FlowClassImplements[] = (node.implements = []);\n do {\n const node = this.startNode();\n node.id = this.flowParseRestrictedIdentifier(/*liberal*/ true);\n if (this.isRelational(\"<\")) {\n node.typeParameters = this.flowParseTypeParameterInstantiation();\n } else {\n node.typeParameters = null;\n }\n implemented.push(this.finishNode(node, \"ClassImplements\"));\n } while (this.eat(tt.comma));\n }\n }\n\n parsePropertyName(\n node: N.ObjectOrClassMember | N.ClassMember | N.TsNamedTypeElementBase,\n isPrivateNameAllowed: boolean,\n ): N.Identifier {\n const variance = this.flowParseVariance();\n const key = super.parsePropertyName(node, isPrivateNameAllowed);\n // $FlowIgnore (\"variance\" not defined on TsNamedTypeElementBase)\n node.variance = variance;\n return key;\n }\n\n // parse type parameters for object method shorthand\n parseObjPropValue(\n prop: N.ObjectMember,\n startPos: ?number,\n startLoc: ?Position,\n isGenerator: boolean,\n isAsync: boolean,\n isPattern: boolean,\n refExpressionErrors: ?ExpressionErrors,\n containsEsc: boolean,\n ): void {\n if ((prop: $FlowFixMe).variance) {\n this.unexpected((prop: $FlowFixMe).variance.start);\n }\n delete (prop: $FlowFixMe).variance;\n\n let typeParameters;\n\n // method shorthand\n if (this.isRelational(\"<\")) {\n typeParameters = this.flowParseTypeParameterDeclaration();\n if (!this.match(tt.parenL)) this.unexpected();\n }\n\n super.parseObjPropValue(\n prop,\n startPos,\n startLoc,\n isGenerator,\n isAsync,\n isPattern,\n refExpressionErrors,\n containsEsc,\n );\n\n // add typeParameters if we found them\n if (typeParameters) {\n (prop.value || prop).typeParameters = typeParameters;\n }\n }\n\n parseAssignableListItemTypes(param: N.Pattern): N.Pattern {\n if (this.eat(tt.question)) {\n if (param.type !== \"Identifier\") {\n this.raise(param.start, FlowErrors.OptionalBindingPattern);\n }\n\n ((param: any): N.Identifier).optional = true;\n }\n if (this.match(tt.colon)) {\n param.typeAnnotation = this.flowParseTypeAnnotation();\n }\n this.resetEndLocation(param);\n return param;\n }\n\n parseMaybeDefault(\n startPos?: ?number,\n startLoc?: ?Position,\n left?: ?N.Pattern,\n ): N.Pattern {\n const node = super.parseMaybeDefault(startPos, startLoc, left);\n\n if (\n node.type === \"AssignmentPattern\" &&\n node.typeAnnotation &&\n node.right.start < node.typeAnnotation.start\n ) {\n this.raise(node.typeAnnotation.start, FlowErrors.TypeBeforeInitializer);\n }\n\n return node;\n }\n\n shouldParseDefaultImport(node: N.ImportDeclaration): boolean {\n if (!hasTypeImportKind(node)) {\n return super.shouldParseDefaultImport(node);\n }\n\n return isMaybeDefaultImport(this.state);\n }\n\n parseImportSpecifierLocal(\n node: N.ImportDeclaration,\n specifier: N.Node,\n type: string,\n contextDescription: string,\n ): void {\n specifier.local = hasTypeImportKind(node)\n ? this.flowParseRestrictedIdentifier(\n /* liberal */ true,\n /* declaration */ true,\n )\n : this.parseIdentifier();\n\n this.checkLVal(\n specifier.local,\n BIND_LEXICAL,\n undefined,\n contextDescription,\n );\n node.specifiers.push(this.finishNode(specifier, type));\n }\n\n // parse typeof and type imports\n maybeParseDefaultImportSpecifier(node: N.ImportDeclaration): boolean {\n node.importKind = \"value\";\n\n let kind = null;\n if (this.match(tt._typeof)) {\n kind = \"typeof\";\n } else if (this.isContextual(\"type\")) {\n kind = \"type\";\n }\n if (kind) {\n const lh = this.lookahead();\n\n // import type * is not allowed\n if (kind === \"type\" && lh.type === tt.star) {\n this.unexpected(lh.start);\n }\n\n if (\n isMaybeDefaultImport(lh) ||\n lh.type === tt.braceL ||\n lh.type === tt.star\n ) {\n this.next();\n node.importKind = kind;\n }\n }\n\n return super.maybeParseDefaultImportSpecifier(node);\n }\n\n // parse import-type/typeof shorthand\n parseImportSpecifier(node: N.ImportDeclaration): void {\n const specifier = this.startNode();\n const firstIdentLoc = this.state.start;\n const firstIdent = this.parseIdentifier(true);\n\n let specifierTypeKind = null;\n if (firstIdent.name === \"type\") {\n specifierTypeKind = \"type\";\n } else if (firstIdent.name === \"typeof\") {\n specifierTypeKind = \"typeof\";\n }\n\n let isBinding = false;\n if (this.isContextual(\"as\") && !this.isLookaheadContextual(\"as\")) {\n const as_ident = this.parseIdentifier(true);\n if (\n specifierTypeKind !== null &&\n !this.match(tt.name) &&\n !this.state.type.keyword\n ) {\n // `import {type as ,` or `import {type as }`\n specifier.imported = as_ident;\n specifier.importKind = specifierTypeKind;\n specifier.local = as_ident.__clone();\n } else {\n // `import {type as foo`\n specifier.imported = firstIdent;\n specifier.importKind = null;\n specifier.local = this.parseIdentifier();\n }\n } else if (\n specifierTypeKind !== null &&\n (this.match(tt.name) || this.state.type.keyword)\n ) {\n // `import {type foo`\n specifier.imported = this.parseIdentifier(true);\n specifier.importKind = specifierTypeKind;\n if (this.eatContextual(\"as\")) {\n specifier.local = this.parseIdentifier();\n } else {\n isBinding = true;\n specifier.local = specifier.imported.__clone();\n }\n } else {\n isBinding = true;\n specifier.imported = firstIdent;\n specifier.importKind = null;\n specifier.local = specifier.imported.__clone();\n }\n\n const nodeIsTypeImport = hasTypeImportKind(node);\n const specifierIsTypeImport = hasTypeImportKind(specifier);\n\n if (nodeIsTypeImport && specifierIsTypeImport) {\n this.raise(\n firstIdentLoc,\n FlowErrors.ImportTypeShorthandOnlyInPureImport,\n );\n }\n\n if (nodeIsTypeImport || specifierIsTypeImport) {\n this.checkReservedType(\n specifier.local.name,\n specifier.local.start,\n /* declaration */ true,\n );\n }\n\n if (isBinding && !nodeIsTypeImport && !specifierIsTypeImport) {\n this.checkReservedWord(\n specifier.local.name,\n specifier.start,\n true,\n true,\n );\n }\n\n this.checkLVal(\n specifier.local,\n BIND_LEXICAL,\n undefined,\n \"import specifier\",\n );\n node.specifiers.push(this.finishNode(specifier, \"ImportSpecifier\"));\n }\n\n // parse function type parameters - function foo() {}\n parseFunctionParams(node: N.Function, allowModifiers?: boolean): void {\n // $FlowFixMe\n const kind = node.kind;\n if (kind !== \"get\" && kind !== \"set\" && this.isRelational(\"<\")) {\n node.typeParameters = this.flowParseTypeParameterDeclaration();\n }\n super.parseFunctionParams(node, allowModifiers);\n }\n\n // parse flow type annotations on variable declarator heads - let foo: string = bar\n parseVarId(\n decl: N.VariableDeclarator,\n kind: \"var\" | \"let\" | \"const\",\n ): void {\n super.parseVarId(decl, kind);\n if (this.match(tt.colon)) {\n decl.id.typeAnnotation = this.flowParseTypeAnnotation();\n this.resetEndLocation(decl.id); // set end position to end of type\n }\n }\n\n // parse the return type of an async arrow function - let foo = (async (): number => {});\n parseAsyncArrowFromCallExpression(\n node: N.ArrowFunctionExpression,\n call: N.CallExpression,\n ): N.ArrowFunctionExpression {\n if (this.match(tt.colon)) {\n const oldNoAnonFunctionType = this.state.noAnonFunctionType;\n this.state.noAnonFunctionType = true;\n node.returnType = this.flowParseTypeAnnotation();\n this.state.noAnonFunctionType = oldNoAnonFunctionType;\n }\n\n return super.parseAsyncArrowFromCallExpression(node, call);\n }\n\n // todo description\n shouldParseAsyncArrow(): boolean {\n return this.match(tt.colon) || super.shouldParseAsyncArrow();\n }\n\n // We need to support type parameter declarations for arrow functions. This\n // is tricky. There are three situations we need to handle\n //\n // 1. This is either JSX or an arrow function. We'll try JSX first. If that\n // fails, we'll try an arrow function. If that fails, we'll throw the JSX\n // error.\n // 2. This is an arrow function. We'll parse the type parameter declaration,\n // parse the rest, make sure the rest is an arrow function, and go from\n // there\n // 3. This is neither. Just call the super method\n parseMaybeAssign(\n noIn?: ?boolean,\n refExpressionErrors?: ?ExpressionErrors,\n afterLeftParse?: Function,\n refNeedsArrowPos?: ?Pos,\n ): N.Expression {\n let state = null;\n\n let jsx;\n\n if (\n this.hasPlugin(\"jsx\") &&\n (this.match(tt.jsxTagStart) || this.isRelational(\"<\"))\n ) {\n state = this.state.clone();\n\n jsx = this.tryParse(\n () =>\n super.parseMaybeAssign(\n noIn,\n refExpressionErrors,\n afterLeftParse,\n refNeedsArrowPos,\n ),\n state,\n );\n /*:: invariant(!jsx.aborted) */\n\n if (!jsx.error) return jsx.node;\n\n // Remove `tc.j_expr` and `tc.j_oTag` from context added\n // by parsing `jsxTagStart` to stop the JSX plugin from\n // messing with the tokens\n const { context } = this.state;\n if (context[context.length - 1] === tc.j_oTag) {\n context.length -= 2;\n } else if (context[context.length - 1] === tc.j_expr) {\n context.length -= 1;\n }\n }\n\n if ((jsx && jsx.error) || this.isRelational(\"<\")) {\n state = state || this.state.clone();\n\n let typeParameters;\n\n const arrow = this.tryParse(() => {\n typeParameters = this.flowParseTypeParameterDeclaration();\n\n const arrowExpression = this.forwardNoArrowParamsConversionAt(\n typeParameters,\n () =>\n super.parseMaybeAssign(\n noIn,\n refExpressionErrors,\n afterLeftParse,\n refNeedsArrowPos,\n ),\n );\n arrowExpression.typeParameters = typeParameters;\n this.resetStartLocationFromNode(arrowExpression, typeParameters);\n\n return arrowExpression;\n }, state);\n\n const arrowExpression: ?N.ArrowFunctionExpression =\n arrow.node && arrow.node.type === \"ArrowFunctionExpression\"\n ? arrow.node\n : null;\n\n if (!arrow.error && arrowExpression) return arrowExpression;\n\n // If we are here, both JSX and Flow parsing attemps failed.\n // Give the precedence to the JSX error, except if JSX had an\n // unrecoverable error while Flow didn't.\n // If the error is recoverable, we can only re-report it if there is\n // a node we can return.\n\n if (jsx && jsx.node) {\n /*:: invariant(jsx.failState) */\n this.state = jsx.failState;\n return jsx.node;\n }\n\n if (arrowExpression) {\n /*:: invariant(arrow.failState) */\n this.state = arrow.failState;\n return arrowExpression;\n }\n\n if (jsx && jsx.thrown) throw jsx.error;\n if (arrow.thrown) throw arrow.error;\n\n /*:: invariant(typeParameters) */\n throw this.raise(\n typeParameters.start,\n FlowErrors.UnexpectedTokenAfterTypeParameter,\n );\n }\n\n return super.parseMaybeAssign(\n noIn,\n refExpressionErrors,\n afterLeftParse,\n refNeedsArrowPos,\n );\n }\n\n // handle return types for arrow functions\n parseArrow(node: N.ArrowFunctionExpression): ?N.ArrowFunctionExpression {\n if (this.match(tt.colon)) {\n const result = this.tryParse(() => {\n const oldNoAnonFunctionType = this.state.noAnonFunctionType;\n this.state.noAnonFunctionType = true;\n\n const typeNode = this.startNode();\n\n [\n // $FlowFixMe (destructuring not supported yet)\n typeNode.typeAnnotation,\n // $FlowFixMe (destructuring not supported yet)\n node.predicate,\n ] = this.flowParseTypeAndPredicateInitialiser();\n\n this.state.noAnonFunctionType = oldNoAnonFunctionType;\n\n if (this.canInsertSemicolon()) this.unexpected();\n if (!this.match(tt.arrow)) this.unexpected();\n\n return typeNode;\n });\n\n if (result.thrown) return null;\n /*:: invariant(result.node) */\n\n if (result.error) this.state = result.failState;\n\n // assign after it is clear it is an arrow\n node.returnType = result.node.typeAnnotation\n ? this.finishNode(result.node, \"TypeAnnotation\")\n : null;\n }\n\n return super.parseArrow(node);\n }\n\n shouldParseArrow(): boolean {\n return this.match(tt.colon) || super.shouldParseArrow();\n }\n\n setArrowFunctionParameters(\n node: N.ArrowFunctionExpression,\n params: N.Expression[],\n ): void {\n if (this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {\n node.params = params;\n } else {\n super.setArrowFunctionParameters(node, params);\n }\n }\n\n checkParams(\n node: N.Function,\n allowDuplicates: boolean,\n isArrowFunction: ?boolean,\n ): void {\n if (\n isArrowFunction &&\n this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1\n ) {\n return;\n }\n\n return super.checkParams(...arguments);\n }\n\n parseParenAndDistinguishExpression(canBeArrow: boolean): N.Expression {\n return super.parseParenAndDistinguishExpression(\n canBeArrow && this.state.noArrowAt.indexOf(this.state.start) === -1,\n );\n }\n\n parseSubscripts(\n base: N.Expression,\n startPos: number,\n startLoc: Position,\n noCalls?: ?boolean,\n ): N.Expression {\n if (\n base.type === \"Identifier\" &&\n base.name === \"async\" &&\n this.state.noArrowAt.indexOf(startPos) !== -1\n ) {\n this.next();\n\n const node = this.startNodeAt(startPos, startLoc);\n node.callee = base;\n node.arguments = this.parseCallExpressionArguments(tt.parenR, false);\n base = this.finishNode(node, \"CallExpression\");\n } else if (\n base.type === \"Identifier\" &&\n base.name === \"async\" &&\n this.isRelational(\"<\")\n ) {\n const state = this.state.clone();\n const arrow = this.tryParse(\n abort =>\n this.parseAsyncArrowWithTypeParameters(startPos, startLoc) ||\n abort(),\n state,\n );\n\n if (!arrow.error && !arrow.aborted) return arrow.node;\n\n const result = this.tryParse(\n () => super.parseSubscripts(base, startPos, startLoc, noCalls),\n state,\n );\n\n if (result.node && !result.error) return result.node;\n\n if (arrow.node) {\n this.state = arrow.failState;\n return arrow.node;\n }\n\n if (result.node) {\n this.state = result.failState;\n return result.node;\n }\n\n throw arrow.error || result.error;\n }\n\n return super.parseSubscripts(base, startPos, startLoc, noCalls);\n }\n\n parseSubscript(\n base: N.Expression,\n startPos: number,\n startLoc: Position,\n noCalls: ?boolean,\n subscriptState: N.ParseSubscriptState,\n ): N.Expression {\n if (this.match(tt.questionDot) && this.isLookaheadRelational(\"<\")) {\n subscriptState.optionalChainMember = true;\n if (noCalls) {\n subscriptState.stop = true;\n return base;\n }\n this.next();\n const node: N.OptionalCallExpression = this.startNodeAt(\n startPos,\n startLoc,\n );\n node.callee = base;\n node.typeArguments = this.flowParseTypeParameterInstantiation();\n this.expect(tt.parenL);\n // $FlowFixMe\n node.arguments = this.parseCallExpressionArguments(tt.parenR, false);\n node.optional = true;\n return this.finishCallExpression(node, /* optional */ true);\n } else if (\n !noCalls &&\n this.shouldParseTypes() &&\n this.isRelational(\"<\")\n ) {\n const node = this.startNodeAt(startPos, startLoc);\n node.callee = base;\n\n const result = this.tryParse(() => {\n node.typeArguments = this.flowParseTypeParameterInstantiationCallOrNew();\n this.expect(tt.parenL);\n node.arguments = this.parseCallExpressionArguments(tt.parenR, false);\n if (subscriptState.optionalChainMember) node.optional = false;\n return this.finishCallExpression(\n node,\n subscriptState.optionalChainMember,\n );\n });\n\n if (result.node) {\n if (result.error) this.state = result.failState;\n return result.node;\n }\n }\n\n return super.parseSubscript(\n base,\n startPos,\n startLoc,\n noCalls,\n subscriptState,\n );\n }\n\n parseNewArguments(node: N.NewExpression): void {\n let targs = null;\n if (this.shouldParseTypes() && this.isRelational(\"<\")) {\n targs = this.tryParse(() =>\n this.flowParseTypeParameterInstantiationCallOrNew(),\n ).node;\n }\n node.typeArguments = targs;\n\n super.parseNewArguments(node);\n }\n\n parseAsyncArrowWithTypeParameters(\n startPos: number,\n startLoc: Position,\n ): ?N.ArrowFunctionExpression {\n const node = this.startNodeAt(startPos, startLoc);\n this.parseFunctionParams(node);\n if (!this.parseArrow(node)) return;\n return this.parseArrowExpression(\n node,\n /* params */ undefined,\n /* isAsync */ true,\n );\n }\n\n readToken_mult_modulo(code: number): void {\n const next = this.input.charCodeAt(this.state.pos + 1);\n if (\n code === charCodes.asterisk &&\n next === charCodes.slash &&\n this.state.hasFlowComment\n ) {\n this.state.hasFlowComment = false;\n this.state.pos += 2;\n this.nextToken();\n return;\n }\n\n super.readToken_mult_modulo(code);\n }\n\n readToken_pipe_amp(code: number): void {\n const next = this.input.charCodeAt(this.state.pos + 1);\n if (\n code === charCodes.verticalBar &&\n next === charCodes.rightCurlyBrace\n ) {\n // '|}'\n this.finishOp(tt.braceBarR, 2);\n return;\n }\n\n super.readToken_pipe_amp(code);\n }\n\n parseTopLevel(file: N.File, program: N.Program): N.File {\n const fileNode = super.parseTopLevel(file, program);\n if (this.state.hasFlowComment) {\n this.raise(this.state.pos, FlowErrors.UnterminatedFlowComment);\n }\n return fileNode;\n }\n\n skipBlockComment(): void {\n if (this.hasPlugin(\"flowComments\") && this.skipFlowComment()) {\n if (this.state.hasFlowComment) {\n this.unexpected(null, FlowErrors.NestedFlowComment);\n }\n this.hasFlowCommentCompletion();\n this.state.pos += this.skipFlowComment();\n this.state.hasFlowComment = true;\n return;\n }\n\n if (this.state.hasFlowComment) {\n const end = this.input.indexOf(\"*-/\", (this.state.pos += 2));\n if (end === -1) {\n throw this.raise(this.state.pos - 2, Errors.UnterminatedComment);\n }\n this.state.pos = end + 3;\n return;\n }\n\n super.skipBlockComment();\n }\n\n skipFlowComment(): number | boolean {\n const { pos } = this.state;\n let shiftToFirstNonWhiteSpace = 2;\n while (\n [charCodes.space, charCodes.tab].includes(\n this.input.charCodeAt(pos + shiftToFirstNonWhiteSpace),\n )\n ) {\n shiftToFirstNonWhiteSpace++;\n }\n\n const ch2 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos);\n const ch3 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos + 1);\n\n if (ch2 === charCodes.colon && ch3 === charCodes.colon) {\n return shiftToFirstNonWhiteSpace + 2; // check for /*::\n }\n if (\n this.input.slice(\n shiftToFirstNonWhiteSpace + pos,\n shiftToFirstNonWhiteSpace + pos + 12,\n ) === \"flow-include\"\n ) {\n return shiftToFirstNonWhiteSpace + 12; // check for /*flow-include\n }\n if (ch2 === charCodes.colon && ch3 !== charCodes.colon) {\n return shiftToFirstNonWhiteSpace; // check for /*:, advance up to :\n }\n return false;\n }\n\n hasFlowCommentCompletion(): void {\n const end = this.input.indexOf(\"*/\", this.state.pos);\n if (end === -1) {\n throw this.raise(this.state.pos, Errors.UnterminatedComment);\n }\n }\n\n // Flow enum parsing\n\n flowEnumErrorBooleanMemberNotInitialized(\n pos: number,\n { enumName, memberName }: { enumName: string, memberName: string },\n ): void {\n this.raise(\n pos,\n FlowErrors.EnumBooleanMemberNotInitialized,\n memberName,\n enumName,\n );\n }\n\n flowEnumErrorInvalidMemberName(\n pos: number,\n { enumName, memberName }: { enumName: string, memberName: string },\n ): void {\n const suggestion = memberName[0].toUpperCase() + memberName.slice(1);\n this.raise(\n pos,\n FlowErrors.EnumInvalidMemberName,\n memberName,\n suggestion,\n enumName,\n );\n }\n\n flowEnumErrorDuplicateMemberName(\n pos: number,\n { enumName, memberName }: { enumName: string, memberName: string },\n ): void {\n this.raise(pos, FlowErrors.EnumDuplicateMemberName, memberName, enumName);\n }\n\n flowEnumErrorInconsistentMemberValues(\n pos: number,\n { enumName }: { enumName: string },\n ): void {\n this.raise(pos, FlowErrors.EnumInconsistentMemberValues, enumName);\n }\n\n flowEnumErrorInvalidExplicitType(\n pos: number,\n {\n enumName,\n suppliedType,\n }: { enumName: string, suppliedType: null | string },\n ) {\n return this.raise(\n pos,\n suppliedType === null\n ? FlowErrors.EnumInvalidExplicitTypeUnknownSupplied\n : FlowErrors.EnumInvalidExplicitType,\n enumName,\n suppliedType,\n );\n }\n\n flowEnumErrorInvalidMemberInitializer(\n pos: number,\n { enumName, explicitType, memberName }: EnumContext,\n ) {\n let message = null;\n switch (explicitType) {\n case \"boolean\":\n case \"number\":\n case \"string\":\n message = FlowErrors.EnumInvalidMemberInitializerPrimaryType;\n break;\n case \"symbol\":\n message = FlowErrors.EnumInvalidMemberInitializerSymbolType;\n break;\n default:\n // null\n message = FlowErrors.EnumInvalidMemberInitializerUnknownType;\n }\n return this.raise(pos, message, enumName, memberName, explicitType);\n }\n\n flowEnumErrorNumberMemberNotInitialized(\n pos: number,\n { enumName, memberName }: { enumName: string, memberName: string },\n ): void {\n this.raise(\n pos,\n FlowErrors.EnumNumberMemberNotInitialized,\n enumName,\n memberName,\n );\n }\n\n flowEnumErrorStringMemberInconsistentlyInitailized(\n pos: number,\n { enumName }: { enumName: string },\n ): void {\n this.raise(\n pos,\n FlowErrors.EnumStringMemberInconsistentlyInitailized,\n enumName,\n );\n }\n\n flowEnumMemberInit(): EnumMemberInit {\n const startPos = this.state.start;\n const endOfInit = () => this.match(tt.comma) || this.match(tt.braceR);\n switch (this.state.type) {\n case tt.num: {\n const literal = this.parseLiteral(this.state.value, \"NumericLiteral\");\n if (endOfInit()) {\n return { type: \"number\", pos: literal.start, value: literal };\n }\n return { type: \"invalid\", pos: startPos };\n }\n case tt.string: {\n const literal = this.parseLiteral(this.state.value, \"StringLiteral\");\n if (endOfInit()) {\n return { type: \"string\", pos: literal.start, value: literal };\n }\n return { type: \"invalid\", pos: startPos };\n }\n case tt._true:\n case tt._false: {\n const literal = this.parseBooleanLiteral();\n if (endOfInit()) {\n return {\n type: \"boolean\",\n pos: literal.start,\n value: literal,\n };\n }\n return { type: \"invalid\", pos: startPos };\n }\n default:\n return { type: \"invalid\", pos: startPos };\n }\n }\n\n flowEnumMemberRaw(): { id: N.Node, init: EnumMemberInit } {\n const pos = this.state.start;\n const id = this.parseIdentifier(true);\n const init = this.eat(tt.eq)\n ? this.flowEnumMemberInit()\n : { type: \"none\", pos };\n return { id, init };\n }\n\n flowEnumCheckExplicitTypeMismatch(\n pos: number,\n context: EnumContext,\n expectedType: EnumExplicitType,\n ): void {\n const { explicitType } = context;\n if (explicitType === null) {\n return;\n }\n if (explicitType !== expectedType) {\n this.flowEnumErrorInvalidMemberInitializer(pos, context);\n }\n }\n\n flowEnumMembers({\n enumName,\n explicitType,\n }: {\n enumName: string,\n explicitType: EnumExplicitType,\n }): {|\n booleanMembers: Array,\n numberMembers: Array,\n stringMembers: Array,\n defaultedMembers: Array,\n |} {\n const seenNames = new Set();\n const members = {\n booleanMembers: [],\n numberMembers: [],\n stringMembers: [],\n defaultedMembers: [],\n };\n while (!this.match(tt.braceR)) {\n const memberNode = this.startNode();\n const { id, init } = this.flowEnumMemberRaw();\n const memberName = id.name;\n if (memberName === \"\") {\n continue;\n }\n if (/^[a-z]/.test(memberName)) {\n this.flowEnumErrorInvalidMemberName(id.start, {\n enumName,\n memberName,\n });\n }\n if (seenNames.has(memberName)) {\n this.flowEnumErrorDuplicateMemberName(id.start, {\n enumName,\n memberName,\n });\n }\n seenNames.add(memberName);\n const context = { enumName, explicitType, memberName };\n memberNode.id = id;\n switch (init.type) {\n case \"boolean\": {\n this.flowEnumCheckExplicitTypeMismatch(\n init.pos,\n context,\n \"boolean\",\n );\n memberNode.init = init.value;\n members.booleanMembers.push(\n this.finishNode(memberNode, \"EnumBooleanMember\"),\n );\n break;\n }\n case \"number\": {\n this.flowEnumCheckExplicitTypeMismatch(init.pos, context, \"number\");\n memberNode.init = init.value;\n members.numberMembers.push(\n this.finishNode(memberNode, \"EnumNumberMember\"),\n );\n break;\n }\n case \"string\": {\n this.flowEnumCheckExplicitTypeMismatch(init.pos, context, \"string\");\n memberNode.init = init.value;\n members.stringMembers.push(\n this.finishNode(memberNode, \"EnumStringMember\"),\n );\n break;\n }\n case \"invalid\": {\n throw this.flowEnumErrorInvalidMemberInitializer(init.pos, context);\n }\n case \"none\": {\n switch (explicitType) {\n case \"boolean\":\n this.flowEnumErrorBooleanMemberNotInitialized(\n init.pos,\n context,\n );\n break;\n case \"number\":\n this.flowEnumErrorNumberMemberNotInitialized(init.pos, context);\n break;\n default:\n members.defaultedMembers.push(\n this.finishNode(memberNode, \"EnumDefaultedMember\"),\n );\n }\n }\n }\n\n if (!this.match(tt.braceR)) {\n this.expect(tt.comma);\n }\n }\n return members;\n }\n\n flowEnumStringMembers(\n initializedMembers: Array,\n defaultedMembers: Array,\n { enumName }: { enumName: string },\n ): Array {\n if (initializedMembers.length === 0) {\n return defaultedMembers;\n } else if (defaultedMembers.length === 0) {\n return initializedMembers;\n } else if (defaultedMembers.length > initializedMembers.length) {\n for (const member of initializedMembers) {\n this.flowEnumErrorStringMemberInconsistentlyInitailized(\n member.start,\n { enumName },\n );\n }\n return defaultedMembers;\n } else {\n for (const member of defaultedMembers) {\n this.flowEnumErrorStringMemberInconsistentlyInitailized(\n member.start,\n { enumName },\n );\n }\n return initializedMembers;\n }\n }\n\n flowEnumParseExplicitType({\n enumName,\n }: {\n enumName: string,\n }): EnumExplicitType {\n if (this.eatContextual(\"of\")) {\n if (!this.match(tt.name)) {\n throw this.flowEnumErrorInvalidExplicitType(this.state.start, {\n enumName,\n suppliedType: null,\n });\n }\n\n const { value } = this.state;\n this.next();\n\n if (\n value !== \"boolean\" &&\n value !== \"number\" &&\n value !== \"string\" &&\n value !== \"symbol\"\n ) {\n this.flowEnumErrorInvalidExplicitType(this.state.start, {\n enumName,\n suppliedType: value,\n });\n }\n\n return value;\n }\n return null;\n }\n\n flowEnumBody(node: N.Node, { enumName, nameLoc }): N.Node {\n const explicitType = this.flowEnumParseExplicitType({ enumName });\n this.expect(tt.braceL);\n const members = this.flowEnumMembers({ enumName, explicitType });\n\n switch (explicitType) {\n case \"boolean\":\n node.explicitType = true;\n node.members = members.booleanMembers;\n this.expect(tt.braceR);\n return this.finishNode(node, \"EnumBooleanBody\");\n case \"number\":\n node.explicitType = true;\n node.members = members.numberMembers;\n this.expect(tt.braceR);\n return this.finishNode(node, \"EnumNumberBody\");\n case \"string\":\n node.explicitType = true;\n node.members = this.flowEnumStringMembers(\n members.stringMembers,\n members.defaultedMembers,\n { enumName },\n );\n this.expect(tt.braceR);\n return this.finishNode(node, \"EnumStringBody\");\n case \"symbol\":\n node.members = members.defaultedMembers;\n this.expect(tt.braceR);\n return this.finishNode(node, \"EnumSymbolBody\");\n default: {\n // `explicitType` is `null`\n const empty = () => {\n node.members = [];\n this.expect(tt.braceR);\n return this.finishNode(node, \"EnumStringBody\");\n };\n node.explicitType = false;\n\n const boolsLen = members.booleanMembers.length;\n const numsLen = members.numberMembers.length;\n const strsLen = members.stringMembers.length;\n const defaultedLen = members.defaultedMembers.length;\n\n if (!boolsLen && !numsLen && !strsLen && !defaultedLen) {\n return empty();\n } else if (!boolsLen && !numsLen) {\n node.members = this.flowEnumStringMembers(\n members.stringMembers,\n members.defaultedMembers,\n { enumName },\n );\n this.expect(tt.braceR);\n return this.finishNode(node, \"EnumStringBody\");\n } else if (!numsLen && !strsLen && boolsLen >= defaultedLen) {\n for (const member of members.defaultedMembers) {\n this.flowEnumErrorBooleanMemberNotInitialized(member.start, {\n enumName,\n memberName: member.id.name,\n });\n }\n node.members = members.booleanMembers;\n this.expect(tt.braceR);\n return this.finishNode(node, \"EnumBooleanBody\");\n } else if (!boolsLen && !strsLen && numsLen >= defaultedLen) {\n for (const member of members.defaultedMembers) {\n this.flowEnumErrorNumberMemberNotInitialized(member.start, {\n enumName,\n memberName: member.id.name,\n });\n }\n node.members = members.numberMembers;\n this.expect(tt.braceR);\n return this.finishNode(node, \"EnumNumberBody\");\n } else {\n this.flowEnumErrorInconsistentMemberValues(nameLoc, { enumName });\n return empty();\n }\n }\n }\n }\n\n flowParseEnumDeclaration(node: N.Node): N.Node {\n const id = this.parseIdentifier();\n node.id = id;\n node.body = this.flowEnumBody(this.startNode(), {\n enumName: id.name,\n nameLoc: id.start,\n });\n return this.finishNode(node, \"EnumDeclaration\");\n }\n };\n","// @flow\n\nconst entities: { [name: string]: string } = {\n quot: \"\\u0022\",\n amp: \"&\",\n apos: \"\\u0027\",\n lt: \"<\",\n gt: \">\",\n nbsp: \"\\u00A0\",\n iexcl: \"\\u00A1\",\n cent: \"\\u00A2\",\n pound: \"\\u00A3\",\n curren: \"\\u00A4\",\n yen: \"\\u00A5\",\n brvbar: \"\\u00A6\",\n sect: \"\\u00A7\",\n uml: \"\\u00A8\",\n copy: \"\\u00A9\",\n ordf: \"\\u00AA\",\n laquo: \"\\u00AB\",\n not: \"\\u00AC\",\n shy: \"\\u00AD\",\n reg: \"\\u00AE\",\n macr: \"\\u00AF\",\n deg: \"\\u00B0\",\n plusmn: \"\\u00B1\",\n sup2: \"\\u00B2\",\n sup3: \"\\u00B3\",\n acute: \"\\u00B4\",\n micro: \"\\u00B5\",\n para: \"\\u00B6\",\n middot: \"\\u00B7\",\n cedil: \"\\u00B8\",\n sup1: \"\\u00B9\",\n ordm: \"\\u00BA\",\n raquo: \"\\u00BB\",\n frac14: \"\\u00BC\",\n frac12: \"\\u00BD\",\n frac34: \"\\u00BE\",\n iquest: \"\\u00BF\",\n Agrave: \"\\u00C0\",\n Aacute: \"\\u00C1\",\n Acirc: \"\\u00C2\",\n Atilde: \"\\u00C3\",\n Auml: \"\\u00C4\",\n Aring: \"\\u00C5\",\n AElig: \"\\u00C6\",\n Ccedil: \"\\u00C7\",\n Egrave: \"\\u00C8\",\n Eacute: \"\\u00C9\",\n Ecirc: \"\\u00CA\",\n Euml: \"\\u00CB\",\n Igrave: \"\\u00CC\",\n Iacute: \"\\u00CD\",\n Icirc: \"\\u00CE\",\n Iuml: \"\\u00CF\",\n ETH: \"\\u00D0\",\n Ntilde: \"\\u00D1\",\n Ograve: \"\\u00D2\",\n Oacute: \"\\u00D3\",\n Ocirc: \"\\u00D4\",\n Otilde: \"\\u00D5\",\n Ouml: \"\\u00D6\",\n times: \"\\u00D7\",\n Oslash: \"\\u00D8\",\n Ugrave: \"\\u00D9\",\n Uacute: \"\\u00DA\",\n Ucirc: \"\\u00DB\",\n Uuml: \"\\u00DC\",\n Yacute: \"\\u00DD\",\n THORN: \"\\u00DE\",\n szlig: \"\\u00DF\",\n agrave: \"\\u00E0\",\n aacute: \"\\u00E1\",\n acirc: \"\\u00E2\",\n atilde: \"\\u00E3\",\n auml: \"\\u00E4\",\n aring: \"\\u00E5\",\n aelig: \"\\u00E6\",\n ccedil: \"\\u00E7\",\n egrave: \"\\u00E8\",\n eacute: \"\\u00E9\",\n ecirc: \"\\u00EA\",\n euml: \"\\u00EB\",\n igrave: \"\\u00EC\",\n iacute: \"\\u00ED\",\n icirc: \"\\u00EE\",\n iuml: \"\\u00EF\",\n eth: \"\\u00F0\",\n ntilde: \"\\u00F1\",\n ograve: \"\\u00F2\",\n oacute: \"\\u00F3\",\n ocirc: \"\\u00F4\",\n otilde: \"\\u00F5\",\n ouml: \"\\u00F6\",\n divide: \"\\u00F7\",\n oslash: \"\\u00F8\",\n ugrave: \"\\u00F9\",\n uacute: \"\\u00FA\",\n ucirc: \"\\u00FB\",\n uuml: \"\\u00FC\",\n yacute: \"\\u00FD\",\n thorn: \"\\u00FE\",\n yuml: \"\\u00FF\",\n OElig: \"\\u0152\",\n oelig: \"\\u0153\",\n Scaron: \"\\u0160\",\n scaron: \"\\u0161\",\n Yuml: \"\\u0178\",\n fnof: \"\\u0192\",\n circ: \"\\u02C6\",\n tilde: \"\\u02DC\",\n Alpha: \"\\u0391\",\n Beta: \"\\u0392\",\n Gamma: \"\\u0393\",\n Delta: \"\\u0394\",\n Epsilon: \"\\u0395\",\n Zeta: \"\\u0396\",\n Eta: \"\\u0397\",\n Theta: \"\\u0398\",\n Iota: \"\\u0399\",\n Kappa: \"\\u039A\",\n Lambda: \"\\u039B\",\n Mu: \"\\u039C\",\n Nu: \"\\u039D\",\n Xi: \"\\u039E\",\n Omicron: \"\\u039F\",\n Pi: \"\\u03A0\",\n Rho: \"\\u03A1\",\n Sigma: \"\\u03A3\",\n Tau: \"\\u03A4\",\n Upsilon: \"\\u03A5\",\n Phi: \"\\u03A6\",\n Chi: \"\\u03A7\",\n Psi: \"\\u03A8\",\n Omega: \"\\u03A9\",\n alpha: \"\\u03B1\",\n beta: \"\\u03B2\",\n gamma: \"\\u03B3\",\n delta: \"\\u03B4\",\n epsilon: \"\\u03B5\",\n zeta: \"\\u03B6\",\n eta: \"\\u03B7\",\n theta: \"\\u03B8\",\n iota: \"\\u03B9\",\n kappa: \"\\u03BA\",\n lambda: \"\\u03BB\",\n mu: \"\\u03BC\",\n nu: \"\\u03BD\",\n xi: \"\\u03BE\",\n omicron: \"\\u03BF\",\n pi: \"\\u03C0\",\n rho: \"\\u03C1\",\n sigmaf: \"\\u03C2\",\n sigma: \"\\u03C3\",\n tau: \"\\u03C4\",\n upsilon: \"\\u03C5\",\n phi: \"\\u03C6\",\n chi: \"\\u03C7\",\n psi: \"\\u03C8\",\n omega: \"\\u03C9\",\n thetasym: \"\\u03D1\",\n upsih: \"\\u03D2\",\n piv: \"\\u03D6\",\n ensp: \"\\u2002\",\n emsp: \"\\u2003\",\n thinsp: \"\\u2009\",\n zwnj: \"\\u200C\",\n zwj: \"\\u200D\",\n lrm: \"\\u200E\",\n rlm: \"\\u200F\",\n ndash: \"\\u2013\",\n mdash: \"\\u2014\",\n lsquo: \"\\u2018\",\n rsquo: \"\\u2019\",\n sbquo: \"\\u201A\",\n ldquo: \"\\u201C\",\n rdquo: \"\\u201D\",\n bdquo: \"\\u201E\",\n dagger: \"\\u2020\",\n Dagger: \"\\u2021\",\n bull: \"\\u2022\",\n hellip: \"\\u2026\",\n permil: \"\\u2030\",\n prime: \"\\u2032\",\n Prime: \"\\u2033\",\n lsaquo: \"\\u2039\",\n rsaquo: \"\\u203A\",\n oline: \"\\u203E\",\n frasl: \"\\u2044\",\n euro: \"\\u20AC\",\n image: \"\\u2111\",\n weierp: \"\\u2118\",\n real: \"\\u211C\",\n trade: \"\\u2122\",\n alefsym: \"\\u2135\",\n larr: \"\\u2190\",\n uarr: \"\\u2191\",\n rarr: \"\\u2192\",\n darr: \"\\u2193\",\n harr: \"\\u2194\",\n crarr: \"\\u21B5\",\n lArr: \"\\u21D0\",\n uArr: \"\\u21D1\",\n rArr: \"\\u21D2\",\n dArr: \"\\u21D3\",\n hArr: \"\\u21D4\",\n forall: \"\\u2200\",\n part: \"\\u2202\",\n exist: \"\\u2203\",\n empty: \"\\u2205\",\n nabla: \"\\u2207\",\n isin: \"\\u2208\",\n notin: \"\\u2209\",\n ni: \"\\u220B\",\n prod: \"\\u220F\",\n sum: \"\\u2211\",\n minus: \"\\u2212\",\n lowast: \"\\u2217\",\n radic: \"\\u221A\",\n prop: \"\\u221D\",\n infin: \"\\u221E\",\n ang: \"\\u2220\",\n and: \"\\u2227\",\n or: \"\\u2228\",\n cap: \"\\u2229\",\n cup: \"\\u222A\",\n int: \"\\u222B\",\n there4: \"\\u2234\",\n sim: \"\\u223C\",\n cong: \"\\u2245\",\n asymp: \"\\u2248\",\n ne: \"\\u2260\",\n equiv: \"\\u2261\",\n le: \"\\u2264\",\n ge: \"\\u2265\",\n sub: \"\\u2282\",\n sup: \"\\u2283\",\n nsub: \"\\u2284\",\n sube: \"\\u2286\",\n supe: \"\\u2287\",\n oplus: \"\\u2295\",\n otimes: \"\\u2297\",\n perp: \"\\u22A5\",\n sdot: \"\\u22C5\",\n lceil: \"\\u2308\",\n rceil: \"\\u2309\",\n lfloor: \"\\u230A\",\n rfloor: \"\\u230B\",\n lang: \"\\u2329\",\n rang: \"\\u232A\",\n loz: \"\\u25CA\",\n spades: \"\\u2660\",\n clubs: \"\\u2663\",\n hearts: \"\\u2665\",\n diams: \"\\u2666\",\n};\nexport default entities;\n","// @flow\n\nimport * as charCodes from \"charcodes\";\n\nimport XHTMLEntities from \"./xhtml\";\nimport type Parser from \"../../parser\";\nimport type { ExpressionErrors } from \"../../parser/util\";\nimport { TokenType, types as tt } from \"../../tokenizer/types\";\nimport { TokContext, types as tc } from \"../../tokenizer/context\";\nimport * as N from \"../../types\";\nimport { isIdentifierChar, isIdentifierStart } from \"../../util/identifier\";\nimport type { Position } from \"../../util/location\";\nimport { isNewLine } from \"../../util/whitespace\";\nimport { Errors } from \"../../parser/location\";\n\nconst HEX_NUMBER = /^[\\da-fA-F]+$/;\nconst DECIMAL_NUMBER = /^\\d+$/;\n\nconst JsxErrors = Object.freeze({\n AttributeIsEmpty:\n \"JSX attributes must only be assigned a non-empty expression\",\n MissingClosingTagFragment: \"Expected corresponding JSX closing tag for <>\",\n MissingClosingTagElement: \"Expected corresponding JSX closing tag for <%0>\",\n UnsupportedJsxValue:\n \"JSX value should be either an expression or a quoted JSX text\",\n UnterminatedJsxContent: \"Unterminated JSX contents\",\n UnwrappedAdjacentJSXElements:\n \"Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...?\",\n});\n\n// Be aware that this file is always executed and not only when the plugin is enabled.\n// Therefore this contexts and tokens do always exist.\ntc.j_oTag = new TokContext(\"...\", true, true);\n\ntt.jsxName = new TokenType(\"jsxName\");\ntt.jsxText = new TokenType(\"jsxText\", { beforeExpr: true });\ntt.jsxTagStart = new TokenType(\"jsxTagStart\", { startsExpr: true });\ntt.jsxTagEnd = new TokenType(\"jsxTagEnd\");\n\ntt.jsxTagStart.updateContext = function() {\n this.state.context.push(tc.j_expr); // treat as beginning of JSX expression\n this.state.context.push(tc.j_oTag); // start opening tag context\n this.state.exprAllowed = false;\n};\n\ntt.jsxTagEnd.updateContext = function(prevType) {\n const out = this.state.context.pop();\n if ((out === tc.j_oTag && prevType === tt.slash) || out === tc.j_cTag) {\n this.state.context.pop();\n this.state.exprAllowed = this.curContext() === tc.j_expr;\n } else {\n this.state.exprAllowed = true;\n }\n};\n\nfunction isFragment(object: ?N.JSXElement): boolean {\n return object\n ? object.type === \"JSXOpeningFragment\" ||\n object.type === \"JSXClosingFragment\"\n : false;\n}\n\n// Transforms JSX element name to string.\n\nfunction getQualifiedJSXName(\n object: N.JSXIdentifier | N.JSXNamespacedName | N.JSXMemberExpression,\n): string {\n if (object.type === \"JSXIdentifier\") {\n return object.name;\n }\n\n if (object.type === \"JSXNamespacedName\") {\n return object.namespace.name + \":\" + object.name.name;\n }\n\n if (object.type === \"JSXMemberExpression\") {\n return (\n getQualifiedJSXName(object.object) +\n \".\" +\n getQualifiedJSXName(object.property)\n );\n }\n\n // istanbul ignore next\n throw new Error(\"Node had unexpected type: \" + object.type);\n}\n\nexport default (superClass: Class): Class =>\n class extends superClass {\n // Reads inline JSX contents token.\n\n jsxReadToken(): void {\n let out = \"\";\n let chunkStart = this.state.pos;\n for (;;) {\n if (this.state.pos >= this.length) {\n throw this.raise(this.state.start, JsxErrors.UnterminatedJsxContent);\n }\n\n const ch = this.input.charCodeAt(this.state.pos);\n\n switch (ch) {\n case charCodes.lessThan:\n case charCodes.leftCurlyBrace:\n if (this.state.pos === this.state.start) {\n if (ch === charCodes.lessThan && this.state.exprAllowed) {\n ++this.state.pos;\n return this.finishToken(tt.jsxTagStart);\n }\n return super.getTokenFromCode(ch);\n }\n out += this.input.slice(chunkStart, this.state.pos);\n return this.finishToken(tt.jsxText, out);\n\n case charCodes.ampersand:\n out += this.input.slice(chunkStart, this.state.pos);\n out += this.jsxReadEntity();\n chunkStart = this.state.pos;\n break;\n\n default:\n if (isNewLine(ch)) {\n out += this.input.slice(chunkStart, this.state.pos);\n out += this.jsxReadNewLine(true);\n chunkStart = this.state.pos;\n } else {\n ++this.state.pos;\n }\n }\n }\n }\n\n jsxReadNewLine(normalizeCRLF: boolean): string {\n const ch = this.input.charCodeAt(this.state.pos);\n let out;\n ++this.state.pos;\n if (\n ch === charCodes.carriageReturn &&\n this.input.charCodeAt(this.state.pos) === charCodes.lineFeed\n ) {\n ++this.state.pos;\n out = normalizeCRLF ? \"\\n\" : \"\\r\\n\";\n } else {\n out = String.fromCharCode(ch);\n }\n ++this.state.curLine;\n this.state.lineStart = this.state.pos;\n\n return out;\n }\n\n jsxReadString(quote: number): void {\n let out = \"\";\n let chunkStart = ++this.state.pos;\n for (;;) {\n if (this.state.pos >= this.length) {\n throw this.raise(this.state.start, Errors.UnterminatedString);\n }\n\n const ch = this.input.charCodeAt(this.state.pos);\n if (ch === quote) break;\n if (ch === charCodes.ampersand) {\n out += this.input.slice(chunkStart, this.state.pos);\n out += this.jsxReadEntity();\n chunkStart = this.state.pos;\n } else if (isNewLine(ch)) {\n out += this.input.slice(chunkStart, this.state.pos);\n out += this.jsxReadNewLine(false);\n chunkStart = this.state.pos;\n } else {\n ++this.state.pos;\n }\n }\n out += this.input.slice(chunkStart, this.state.pos++);\n return this.finishToken(tt.string, out);\n }\n\n jsxReadEntity(): string {\n let str = \"\";\n let count = 0;\n let entity;\n let ch = this.input[this.state.pos];\n\n const startPos = ++this.state.pos;\n while (this.state.pos < this.length && count++ < 10) {\n ch = this.input[this.state.pos++];\n if (ch === \";\") {\n if (str[0] === \"#\") {\n if (str[1] === \"x\") {\n str = str.substr(2);\n if (HEX_NUMBER.test(str)) {\n entity = String.fromCodePoint(parseInt(str, 16));\n }\n } else {\n str = str.substr(1);\n if (DECIMAL_NUMBER.test(str)) {\n entity = String.fromCodePoint(parseInt(str, 10));\n }\n }\n } else {\n entity = XHTMLEntities[str];\n }\n break;\n }\n str += ch;\n }\n if (!entity) {\n this.state.pos = startPos;\n return \"&\";\n }\n return entity;\n }\n\n // Read a JSX identifier (valid tag or attribute name).\n //\n // Optimized version since JSX identifiers can\"t contain\n // escape characters and so can be read as single slice.\n // Also assumes that first character was already checked\n // by isIdentifierStart in readToken.\n\n jsxReadWord(): void {\n let ch;\n const start = this.state.pos;\n do {\n ch = this.input.charCodeAt(++this.state.pos);\n } while (isIdentifierChar(ch) || ch === charCodes.dash);\n return this.finishToken(\n tt.jsxName,\n this.input.slice(start, this.state.pos),\n );\n }\n\n // Parse next token as JSX identifier\n\n jsxParseIdentifier(): N.JSXIdentifier {\n const node = this.startNode();\n if (this.match(tt.jsxName)) {\n node.name = this.state.value;\n } else if (this.state.type.keyword) {\n node.name = this.state.type.keyword;\n } else {\n this.unexpected();\n }\n this.next();\n return this.finishNode(node, \"JSXIdentifier\");\n }\n\n // Parse namespaced identifier.\n\n jsxParseNamespacedName(): N.JSXNamespacedName {\n const startPos = this.state.start;\n const startLoc = this.state.startLoc;\n const name = this.jsxParseIdentifier();\n if (!this.eat(tt.colon)) return name;\n\n const node = this.startNodeAt(startPos, startLoc);\n node.namespace = name;\n node.name = this.jsxParseIdentifier();\n return this.finishNode(node, \"JSXNamespacedName\");\n }\n\n // Parses element name in any form - namespaced, member\n // or single identifier.\n\n jsxParseElementName():\n | N.JSXIdentifier\n | N.JSXNamespacedName\n | N.JSXMemberExpression {\n const startPos = this.state.start;\n const startLoc = this.state.startLoc;\n let node = this.jsxParseNamespacedName();\n if (node.type === \"JSXNamespacedName\") {\n return node;\n }\n while (this.eat(tt.dot)) {\n const newNode = this.startNodeAt(startPos, startLoc);\n newNode.object = node;\n newNode.property = this.jsxParseIdentifier();\n node = this.finishNode(newNode, \"JSXMemberExpression\");\n }\n return node;\n }\n\n // Parses any type of JSX attribute value.\n\n jsxParseAttributeValue(): N.Expression {\n let node;\n switch (this.state.type) {\n case tt.braceL:\n node = this.startNode();\n this.next();\n node = this.jsxParseExpressionContainer(node);\n if (node.expression.type === \"JSXEmptyExpression\") {\n this.raise(node.start, JsxErrors.AttributeIsEmpty);\n }\n return node;\n\n case tt.jsxTagStart:\n case tt.string:\n return this.parseExprAtom();\n\n default:\n throw this.raise(this.state.start, JsxErrors.UnsupportedJsxValue);\n }\n }\n\n // JSXEmptyExpression is unique type since it doesn't actually parse anything,\n // and so it should start at the end of last read token (left brace) and finish\n // at the beginning of the next one (right brace).\n\n jsxParseEmptyExpression(): N.JSXEmptyExpression {\n const node = this.startNodeAt(\n this.state.lastTokEnd,\n this.state.lastTokEndLoc,\n );\n return this.finishNodeAt(\n node,\n \"JSXEmptyExpression\",\n this.state.start,\n this.state.startLoc,\n );\n }\n\n // Parse JSX spread child\n\n jsxParseSpreadChild(node: N.JSXSpreadChild): N.JSXSpreadChild {\n this.next(); // ellipsis\n node.expression = this.parseExpression();\n this.expect(tt.braceR);\n\n return this.finishNode(node, \"JSXSpreadChild\");\n }\n\n // Parses JSX expression enclosed into curly brackets.\n\n jsxParseExpressionContainer(\n node: N.JSXExpressionContainer,\n ): N.JSXExpressionContainer {\n if (this.match(tt.braceR)) {\n node.expression = this.jsxParseEmptyExpression();\n } else {\n node.expression = this.parseExpression();\n }\n this.expect(tt.braceR);\n return this.finishNode(node, \"JSXExpressionContainer\");\n }\n\n // Parses following JSX attribute name-value pair.\n\n jsxParseAttribute(): N.JSXAttribute {\n const node = this.startNode();\n if (this.eat(tt.braceL)) {\n this.expect(tt.ellipsis);\n node.argument = this.parseMaybeAssign();\n this.expect(tt.braceR);\n return this.finishNode(node, \"JSXSpreadAttribute\");\n }\n node.name = this.jsxParseNamespacedName();\n node.value = this.eat(tt.eq) ? this.jsxParseAttributeValue() : null;\n return this.finishNode(node, \"JSXAttribute\");\n }\n\n // Parses JSX opening tag starting after \"<\".\n\n jsxParseOpeningElementAt(\n startPos: number,\n startLoc: Position,\n ): N.JSXOpeningElement {\n const node = this.startNodeAt(startPos, startLoc);\n if (this.match(tt.jsxTagEnd)) {\n this.expect(tt.jsxTagEnd);\n return this.finishNode(node, \"JSXOpeningFragment\");\n }\n node.name = this.jsxParseElementName();\n return this.jsxParseOpeningElementAfterName(node);\n }\n\n jsxParseOpeningElementAfterName(\n node: N.JSXOpeningElement,\n ): N.JSXOpeningElement {\n const attributes: N.JSXAttribute[] = [];\n while (!this.match(tt.slash) && !this.match(tt.jsxTagEnd)) {\n attributes.push(this.jsxParseAttribute());\n }\n node.attributes = attributes;\n node.selfClosing = this.eat(tt.slash);\n this.expect(tt.jsxTagEnd);\n return this.finishNode(node, \"JSXOpeningElement\");\n }\n\n // Parses JSX closing tag starting after \" JSX open tag -> ... anymore\n this.state.context.push(tc.j_cTag); // reconsider as closing tag context\n this.state.exprAllowed = false;\n } else {\n return super.updateContext(prevType);\n }\n }\n };\n","// @flow\nimport {\n SCOPE_ARROW,\n SCOPE_DIRECT_SUPER,\n SCOPE_FUNCTION,\n SCOPE_SIMPLE_CATCH,\n SCOPE_SUPER,\n SCOPE_PROGRAM,\n SCOPE_VAR,\n SCOPE_CLASS,\n BIND_SCOPE_FUNCTION,\n BIND_SCOPE_VAR,\n BIND_SCOPE_LEXICAL,\n BIND_KIND_VALUE,\n type ScopeFlags,\n type BindingTypes,\n} from \"./scopeflags\";\nimport * as N from \"../types\";\nimport { Errors } from \"../parser/location\";\n\n// Start an AST node, attaching a start offset.\nexport class Scope {\n flags: ScopeFlags;\n // A list of var-declared names in the current lexical scope\n var: string[] = [];\n // A list of lexically-declared names in the current lexical scope\n lexical: string[] = [];\n // A list of lexically-declared FunctionDeclaration names in the current lexical scope\n functions: string[] = [];\n\n constructor(flags: ScopeFlags) {\n this.flags = flags;\n }\n}\n\ntype raiseFunction = (number, string, ...any) => void;\n\n// The functions in this module keep track of declared variables in the\n// current scope in order to detect duplicate variable names.\nexport default class ScopeHandler {\n scopeStack: Array = [];\n raise: raiseFunction;\n inModule: boolean;\n undefinedExports: Map = new Map();\n undefinedPrivateNames: Map = new Map();\n\n constructor(raise: raiseFunction, inModule: boolean) {\n this.raise = raise;\n this.inModule = inModule;\n }\n\n get inFunction() {\n return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0;\n }\n get allowSuper() {\n return (this.currentThisScope().flags & SCOPE_SUPER) > 0;\n }\n get allowDirectSuper() {\n return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0;\n }\n get inClass() {\n return (this.currentThisScope().flags & SCOPE_CLASS) > 0;\n }\n get inNonArrowFunction() {\n return (this.currentThisScope().flags & SCOPE_FUNCTION) > 0;\n }\n get treatFunctionsAsVar() {\n return this.treatFunctionsAsVarInScope(this.currentScope());\n }\n\n createScope(flags: ScopeFlags): Scope {\n return new Scope(flags);\n }\n // This method will be overwritten by subclasses\n /*:: +createScope: (flags: ScopeFlags) => IScope; */\n\n enter(flags: ScopeFlags) {\n this.scopeStack.push(this.createScope(flags));\n }\n\n exit() {\n this.scopeStack.pop();\n }\n\n // The spec says:\n // > At the top level of a function, or script, function declarations are\n // > treated like var declarations rather than like lexical declarations.\n treatFunctionsAsVarInScope(scope: IScope): boolean {\n return !!(\n scope.flags & SCOPE_FUNCTION ||\n (!this.inModule && scope.flags & SCOPE_PROGRAM)\n );\n }\n\n declareName(name: string, bindingType: BindingTypes, pos: number) {\n let scope = this.currentScope();\n if (bindingType & BIND_SCOPE_LEXICAL || bindingType & BIND_SCOPE_FUNCTION) {\n this.checkRedeclarationInScope(scope, name, bindingType, pos);\n\n if (bindingType & BIND_SCOPE_FUNCTION) {\n scope.functions.push(name);\n } else {\n scope.lexical.push(name);\n }\n\n if (bindingType & BIND_SCOPE_LEXICAL) {\n this.maybeExportDefined(scope, name);\n }\n } else if (bindingType & BIND_SCOPE_VAR) {\n for (let i = this.scopeStack.length - 1; i >= 0; --i) {\n scope = this.scopeStack[i];\n this.checkRedeclarationInScope(scope, name, bindingType, pos);\n scope.var.push(name);\n this.maybeExportDefined(scope, name);\n\n if (scope.flags & SCOPE_VAR) break;\n }\n }\n if (this.inModule && scope.flags & SCOPE_PROGRAM) {\n this.undefinedExports.delete(name);\n }\n }\n\n maybeExportDefined(scope: IScope, name: string) {\n if (this.inModule && scope.flags & SCOPE_PROGRAM) {\n this.undefinedExports.delete(name);\n }\n }\n\n checkRedeclarationInScope(\n scope: IScope,\n name: string,\n bindingType: BindingTypes,\n pos: number,\n ) {\n if (this.isRedeclaredInScope(scope, name, bindingType)) {\n this.raise(pos, Errors.VarRedeclaration, name);\n }\n }\n\n isRedeclaredInScope(\n scope: IScope,\n name: string,\n bindingType: BindingTypes,\n ): boolean {\n if (!(bindingType & BIND_KIND_VALUE)) return false;\n\n if (bindingType & BIND_SCOPE_LEXICAL) {\n return (\n scope.lexical.indexOf(name) > -1 ||\n scope.functions.indexOf(name) > -1 ||\n scope.var.indexOf(name) > -1\n );\n }\n\n if (bindingType & BIND_SCOPE_FUNCTION) {\n return (\n scope.lexical.indexOf(name) > -1 ||\n (!this.treatFunctionsAsVarInScope(scope) &&\n scope.var.indexOf(name) > -1)\n );\n }\n\n return (\n (scope.lexical.indexOf(name) > -1 &&\n !(scope.flags & SCOPE_SIMPLE_CATCH && scope.lexical[0] === name)) ||\n (!this.treatFunctionsAsVarInScope(scope) &&\n scope.functions.indexOf(name) > -1)\n );\n }\n\n checkLocalExport(id: N.Identifier) {\n if (\n this.scopeStack[0].lexical.indexOf(id.name) === -1 &&\n this.scopeStack[0].var.indexOf(id.name) === -1 &&\n // In strict mode, scope.functions will always be empty.\n // Modules are strict by default, but the `scriptMode` option\n // can overwrite this behavior.\n this.scopeStack[0].functions.indexOf(id.name) === -1\n ) {\n this.undefinedExports.set(id.name, id.start);\n }\n }\n\n currentScope(): IScope {\n return this.scopeStack[this.scopeStack.length - 1];\n }\n\n // $FlowIgnore\n currentVarScope(): IScope {\n for (let i = this.scopeStack.length - 1; ; i--) {\n const scope = this.scopeStack[i];\n if (scope.flags & SCOPE_VAR) {\n return scope;\n }\n }\n }\n\n // Could be useful for `arguments`, `this`, `new.target`, `super()`, `super.property`, and `super[property]`.\n // $FlowIgnore\n currentThisScope(): IScope {\n for (let i = this.scopeStack.length - 1; ; i--) {\n const scope = this.scopeStack[i];\n if (\n (scope.flags & SCOPE_VAR || scope.flags & SCOPE_CLASS) &&\n !(scope.flags & SCOPE_ARROW)\n ) {\n return scope;\n }\n }\n }\n}\n","// @flow\n\nimport ScopeHandler, { Scope } from \"../../util/scope\";\nimport {\n BIND_KIND_TYPE,\n BIND_FLAGS_TS_ENUM,\n BIND_FLAGS_TS_CONST_ENUM,\n BIND_FLAGS_TS_EXPORT_ONLY,\n BIND_KIND_VALUE,\n BIND_FLAGS_CLASS,\n type ScopeFlags,\n type BindingTypes,\n} from \"../../util/scopeflags\";\nimport * as N from \"../../types\";\n\nclass TypeScriptScope extends Scope {\n types: string[] = [];\n\n // enums (which are also in .types)\n enums: string[] = [];\n\n // const enums (which are also in .enums and .types)\n constEnums: string[] = [];\n\n // classes (which are also in .lexical) and interface (which are also in .types)\n classes: string[] = [];\n\n // namespaces and ambient functions (or classes) are too difficult to track,\n // especially without type analysis.\n // We need to track them anyway, to avoid \"X is not defined\" errors\n // when exporting them.\n exportOnlyBindings: string[] = [];\n}\n\n// See https://github.com/babel/babel/pull/9766#discussion_r268920730 for an\n// explanation of how typescript handles scope.\n\nexport default class TypeScriptScopeHandler extends ScopeHandler {\n createScope(flags: ScopeFlags): TypeScriptScope {\n return new TypeScriptScope(flags);\n }\n\n declareName(name: string, bindingType: BindingTypes, pos: number) {\n const scope = this.currentScope();\n if (bindingType & BIND_FLAGS_TS_EXPORT_ONLY) {\n this.maybeExportDefined(scope, name);\n scope.exportOnlyBindings.push(name);\n return;\n }\n\n super.declareName(...arguments);\n\n if (bindingType & BIND_KIND_TYPE) {\n if (!(bindingType & BIND_KIND_VALUE)) {\n // \"Value\" bindings have already been registered by the superclass.\n this.checkRedeclarationInScope(scope, name, bindingType, pos);\n this.maybeExportDefined(scope, name);\n }\n scope.types.push(name);\n }\n if (bindingType & BIND_FLAGS_TS_ENUM) scope.enums.push(name);\n if (bindingType & BIND_FLAGS_TS_CONST_ENUM) scope.constEnums.push(name);\n if (bindingType & BIND_FLAGS_CLASS) scope.classes.push(name);\n }\n\n isRedeclaredInScope(\n scope: TypeScriptScope,\n name: string,\n bindingType: BindingTypes,\n ): boolean {\n if (scope.enums.indexOf(name) > -1) {\n if (bindingType & BIND_FLAGS_TS_ENUM) {\n // Enums can be merged with other enums if they are both\n // const or both non-const.\n const isConst = !!(bindingType & BIND_FLAGS_TS_CONST_ENUM);\n const wasConst = scope.constEnums.indexOf(name) > -1;\n return isConst !== wasConst;\n }\n return true;\n }\n if (bindingType & BIND_FLAGS_CLASS && scope.classes.indexOf(name) > -1) {\n if (scope.lexical.indexOf(name) > -1) {\n // Classes can be merged with interfaces\n return !!(bindingType & BIND_KIND_VALUE);\n } else {\n // Interface can be merged with other classes or interfaces\n return false;\n }\n }\n if (bindingType & BIND_KIND_TYPE && scope.types.indexOf(name) > -1) {\n return true;\n }\n\n return super.isRedeclaredInScope(...arguments);\n }\n\n checkLocalExport(id: N.Identifier) {\n if (\n this.scopeStack[0].types.indexOf(id.name) === -1 &&\n this.scopeStack[0].exportOnlyBindings.indexOf(id.name) === -1\n ) {\n super.checkLocalExport(id);\n }\n }\n}\n","// @flow\nexport const PARAM = 0b000, // Initial Parameter flags\n PARAM_YIELD = 0b001, // track [Yield] production parameter\n PARAM_AWAIT = 0b010, // track [Await] production parameter\n PARAM_RETURN = 0b100; // track [Return] production parameter\n\n// ProductionParameterHandler is a stack fashioned production parameter tracker\n// https://tc39.es/ecma262/#sec-grammar-notation\n// The tracked parameters are defined above. Note that the [In] parameter is\n// tracked in `noIn` argument of `parseExpression`.\n//\n// Whenever [+Await]/[+Yield] appears in the right-hand sides of a production,\n// we must enter a new tracking stack. For example when parsing\n//\n// AsyncFunctionDeclaration [Yield, Await]:\n// async [no LineTerminator here] function BindingIdentifier[?Yield, ?Await]\n// ( FormalParameters[~Yield, +Await] ) { AsyncFunctionBody }\n//\n// we must follow such process:\n//\n// 1. parse async keyword\n// 2. parse function keyword\n// 3. parse bindingIdentifier <= inherit current parameters: [?Await]\n// 4. enter new stack with (PARAM_AWAIT)\n// 5. parse formal parameters <= must have [Await] parameter [+Await]\n// 6. parse function body\n// 7. exit current stack\n\nexport type ParamKind = typeof PARAM | typeof PARAM_AWAIT | typeof PARAM_YIELD;\n\nexport default class ProductionParameterHandler {\n stacks: Array = [];\n enter(flags: ParamKind) {\n this.stacks.push(flags);\n }\n\n exit() {\n this.stacks.pop();\n }\n\n currentFlags(): ParamKind {\n return this.stacks[this.stacks.length - 1];\n }\n\n get hasAwait(): boolean {\n return (this.currentFlags() & PARAM_AWAIT) > 0;\n }\n\n get hasYield(): boolean {\n return (this.currentFlags() & PARAM_YIELD) > 0;\n }\n\n get hasReturn(): boolean {\n return (this.currentFlags() & PARAM_RETURN) > 0;\n }\n}\n\nexport function functionFlags(\n isAsync: boolean,\n isGenerator: boolean,\n): ParamKind {\n return (isAsync ? PARAM_AWAIT : 0) | (isGenerator ? PARAM_YIELD : 0);\n}\n","// @flow\n\n/*:: declare var invariant; */\n\nimport type { TokenType } from \"../../tokenizer/types\";\nimport type State from \"../../tokenizer/state\";\nimport { types as tt } from \"../../tokenizer/types\";\nimport { types as ct } from \"../../tokenizer/context\";\nimport * as N from \"../../types\";\nimport type { Pos, Position } from \"../../util/location\";\nimport type Parser from \"../../parser\";\nimport {\n type BindingTypes,\n BIND_NONE,\n SCOPE_TS_MODULE,\n SCOPE_OTHER,\n BIND_TS_ENUM,\n BIND_TS_CONST_ENUM,\n BIND_TS_TYPE,\n BIND_TS_INTERFACE,\n BIND_TS_AMBIENT,\n BIND_TS_NAMESPACE,\n BIND_CLASS,\n BIND_LEXICAL,\n} from \"../../util/scopeflags\";\nimport TypeScriptScopeHandler from \"./scope\";\nimport * as charCodes from \"charcodes\";\nimport type { ExpressionErrors } from \"../../parser/util\";\nimport { PARAM } from \"../../util/production-parameter\";\nimport { Errors } from \"../../parser/location\";\n\ntype TsModifier =\n | \"readonly\"\n | \"abstract\"\n | \"declare\"\n | \"static\"\n | \"public\"\n | \"private\"\n | \"protected\";\n\nfunction nonNull(x: ?T): T {\n if (x == null) {\n // $FlowIgnore\n throw new Error(`Unexpected ${x} value.`);\n }\n return x;\n}\n\nfunction assert(x: boolean): void {\n if (!x) {\n throw new Error(\"Assert fail\");\n }\n}\n\ntype ParsingContext =\n | \"EnumMembers\"\n | \"HeritageClauseElement\"\n | \"TupleElementTypes\"\n | \"TypeMembers\"\n | \"TypeParametersOrArguments\";\n\nconst TSErrors = Object.freeze({\n ClassMethodHasDeclare: \"Class methods cannot have the 'declare' modifier\",\n ClassMethodHasReadonly: \"Class methods cannot have the 'readonly' modifier\",\n DeclareClassFieldHasInitializer:\n \"'declare' class fields cannot have an initializer\",\n DuplicateModifier: \"Duplicate modifier: '%0'\",\n EmptyHeritageClauseType: \"'%0' list cannot be empty.\",\n IndexSignatureHasAbstract:\n \"Index signatures cannot have the 'abstract' modifier\",\n IndexSignatureHasAccessibility:\n \"Index signatures cannot have an accessibility modifier ('%0')\",\n IndexSignatureHasStatic: \"Index signatures cannot have the 'static' modifier\",\n OptionalTypeBeforeRequired:\n \"A required element cannot follow an optional element.\",\n PatternIsOptional:\n \"A binding pattern parameter cannot be optional in an implementation signature.\",\n PrivateElementHasAbstract:\n \"Private elements cannot have the 'abstract' modifier.\",\n PrivateElementHasAccessibility:\n \"Private elements cannot have an accessibility modifier ('%0')\",\n TemplateTypeHasSubstitution:\n \"Template literal types cannot have any substitution\",\n TypeAnnotationAfterAssign:\n \"Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`\",\n UnexpectedReadonly:\n \"'readonly' type modifier is only permitted on array and tuple literal types.\",\n UnexpectedTypeAnnotation: \"Did not expect a type annotation here.\",\n UnexpectedTypeCastInParameter: \"Unexpected type cast in parameter position.\",\n UnsupportedImportTypeArgument:\n \"Argument in a type import must be a string literal\",\n UnsupportedParameterPropertyKind:\n \"A parameter property may not be declared using a binding pattern.\",\n UnsupportedSignatureParameterKind:\n \"Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got %0\",\n});\n\n// Doesn't handle \"void\" or \"null\" because those are keywords, not identifiers.\nfunction keywordTypeFromName(\n value: string,\n): N.TsKeywordTypeType | typeof undefined {\n switch (value) {\n case \"any\":\n return \"TSAnyKeyword\";\n case \"boolean\":\n return \"TSBooleanKeyword\";\n case \"bigint\":\n return \"TSBigIntKeyword\";\n case \"never\":\n return \"TSNeverKeyword\";\n case \"number\":\n return \"TSNumberKeyword\";\n case \"object\":\n return \"TSObjectKeyword\";\n case \"string\":\n return \"TSStringKeyword\";\n case \"symbol\":\n return \"TSSymbolKeyword\";\n case \"undefined\":\n return \"TSUndefinedKeyword\";\n case \"unknown\":\n return \"TSUnknownKeyword\";\n default:\n return undefined;\n }\n}\n\nexport default (superClass: Class): Class =>\n class extends superClass {\n getScopeHandler(): Class {\n return TypeScriptScopeHandler;\n }\n\n tsIsIdentifier(): boolean {\n // TODO: actually a bit more complex in TypeScript, but shouldn't matter.\n // See https://github.com/Microsoft/TypeScript/issues/15008\n return this.match(tt.name);\n }\n\n tsNextTokenCanFollowModifier() {\n // Note: TypeScript's implementation is much more complicated because\n // more things are considered modifiers there.\n // This implementation only handles modifiers not handled by @babel/parser itself. And \"static\".\n // TODO: Would be nice to avoid lookahead. Want a hasLineBreakUpNext() method...\n this.next();\n return (\n !this.hasPrecedingLineBreak() &&\n !this.match(tt.parenL) &&\n !this.match(tt.parenR) &&\n !this.match(tt.colon) &&\n !this.match(tt.eq) &&\n !this.match(tt.question) &&\n !this.match(tt.bang)\n );\n }\n\n /** Parses a modifier matching one the given modifier names. */\n tsParseModifier(allowedModifiers: T[]): ?T {\n if (!this.match(tt.name)) {\n return undefined;\n }\n\n const modifier = this.state.value;\n if (\n allowedModifiers.indexOf(modifier) !== -1 &&\n this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this))\n ) {\n return modifier;\n }\n return undefined;\n }\n\n /** Parses a list of modifiers, in any order.\n * If you need a specific order, you must call this function multiple times:\n * this.tsParseModifiers(node, [\"public\"]);\n * this.tsParseModifiers(node, [\"abstract\", \"readonly\"]);\n */\n tsParseModifiers(\n modified: { [key: TsModifier]: ?true },\n allowedModifiers: T[],\n ): void {\n for (;;) {\n const startPos = this.state.start;\n const modifier: ?T = this.tsParseModifier(allowedModifiers);\n\n if (!modifier) break;\n\n if (Object.hasOwnProperty.call(modified, modifier)) {\n this.raise(startPos, TSErrors.DuplicateModifier, modifier);\n }\n modified[modifier] = true;\n }\n }\n\n tsIsListTerminator(kind: ParsingContext): boolean {\n switch (kind) {\n case \"EnumMembers\":\n case \"TypeMembers\":\n return this.match(tt.braceR);\n case \"HeritageClauseElement\":\n return this.match(tt.braceL);\n case \"TupleElementTypes\":\n return this.match(tt.bracketR);\n case \"TypeParametersOrArguments\":\n return this.isRelational(\">\");\n }\n\n throw new Error(\"Unreachable\");\n }\n\n tsParseList(kind: ParsingContext, parseElement: () => T): T[] {\n const result: T[] = [];\n while (!this.tsIsListTerminator(kind)) {\n // Skipping \"parseListElement\" from the TS source since that's just for error handling.\n result.push(parseElement());\n }\n return result;\n }\n\n tsParseDelimitedList(\n kind: ParsingContext,\n parseElement: () => T,\n ): T[] {\n return nonNull(\n this.tsParseDelimitedListWorker(\n kind,\n parseElement,\n /* expectSuccess */ true,\n ),\n );\n }\n\n /**\n * If !expectSuccess, returns undefined instead of failing to parse.\n * If expectSuccess, parseElement should always return a defined value.\n */\n tsParseDelimitedListWorker(\n kind: ParsingContext,\n parseElement: () => ?T,\n expectSuccess: boolean,\n ): ?(T[]) {\n const result = [];\n\n for (;;) {\n if (this.tsIsListTerminator(kind)) {\n break;\n }\n\n const element = parseElement();\n if (element == null) {\n return undefined;\n }\n result.push(element);\n\n if (this.eat(tt.comma)) {\n continue;\n }\n\n if (this.tsIsListTerminator(kind)) {\n break;\n }\n\n if (expectSuccess) {\n // This will fail with an error about a missing comma\n this.expect(tt.comma);\n }\n return undefined;\n }\n\n return result;\n }\n\n tsParseBracketedList(\n kind: ParsingContext,\n parseElement: () => T,\n bracket: boolean,\n skipFirstToken: boolean,\n ): T[] {\n if (!skipFirstToken) {\n if (bracket) {\n this.expect(tt.bracketL);\n } else {\n this.expectRelational(\"<\");\n }\n }\n\n const result = this.tsParseDelimitedList(kind, parseElement);\n\n if (bracket) {\n this.expect(tt.bracketR);\n } else {\n this.expectRelational(\">\");\n }\n\n return result;\n }\n\n tsParseImportType(): N.TsImportType {\n const node: N.TsImportType = this.startNode();\n this.expect(tt._import);\n this.expect(tt.parenL);\n if (!this.match(tt.string)) {\n this.raise(this.state.start, TSErrors.UnsupportedImportTypeArgument);\n }\n\n // For compatibility to estree we cannot call parseLiteral directly here\n node.argument = this.parseExprAtom();\n this.expect(tt.parenR);\n\n if (this.eat(tt.dot)) {\n node.qualifier = this.tsParseEntityName(/* allowReservedWords */ true);\n }\n if (this.isRelational(\"<\")) {\n node.typeParameters = this.tsParseTypeArguments();\n }\n return this.finishNode(node, \"TSImportType\");\n }\n\n tsParseEntityName(allowReservedWords: boolean): N.TsEntityName {\n let entity: N.TsEntityName = this.parseIdentifier();\n while (this.eat(tt.dot)) {\n const node: N.TsQualifiedName = this.startNodeAtNode(entity);\n node.left = entity;\n node.right = this.parseIdentifier(allowReservedWords);\n entity = this.finishNode(node, \"TSQualifiedName\");\n }\n return entity;\n }\n\n tsParseTypeReference(): N.TsTypeReference {\n const node: N.TsTypeReference = this.startNode();\n node.typeName = this.tsParseEntityName(/* allowReservedWords */ false);\n if (!this.hasPrecedingLineBreak() && this.isRelational(\"<\")) {\n node.typeParameters = this.tsParseTypeArguments();\n }\n return this.finishNode(node, \"TSTypeReference\");\n }\n\n tsParseThisTypePredicate(lhs: N.TsThisType): N.TsTypePredicate {\n this.next();\n const node: N.TsTypePredicate = this.startNodeAtNode(lhs);\n node.parameterName = lhs;\n node.typeAnnotation = this.tsParseTypeAnnotation(/* eatColon */ false);\n return this.finishNode(node, \"TSTypePredicate\");\n }\n\n tsParseThisTypeNode(): N.TsThisType {\n const node: N.TsThisType = this.startNode();\n this.next();\n return this.finishNode(node, \"TSThisType\");\n }\n\n tsParseTypeQuery(): N.TsTypeQuery {\n const node: N.TsTypeQuery = this.startNode();\n this.expect(tt._typeof);\n if (this.match(tt._import)) {\n node.exprName = this.tsParseImportType();\n } else {\n node.exprName = this.tsParseEntityName(/* allowReservedWords */ true);\n }\n return this.finishNode(node, \"TSTypeQuery\");\n }\n\n tsParseTypeParameter(): N.TsTypeParameter {\n const node: N.TsTypeParameter = this.startNode();\n node.name = this.parseIdentifierName(node.start);\n node.constraint = this.tsEatThenParseType(tt._extends);\n node.default = this.tsEatThenParseType(tt.eq);\n return this.finishNode(node, \"TSTypeParameter\");\n }\n\n tsTryParseTypeParameters(): ?N.TsTypeParameterDeclaration {\n if (this.isRelational(\"<\")) {\n return this.tsParseTypeParameters();\n }\n }\n\n tsParseTypeParameters() {\n const node: N.TsTypeParameterDeclaration = this.startNode();\n\n if (this.isRelational(\"<\") || this.match(tt.jsxTagStart)) {\n this.next();\n } else {\n this.unexpected();\n }\n\n node.params = this.tsParseBracketedList(\n \"TypeParametersOrArguments\",\n this.tsParseTypeParameter.bind(this),\n /* bracket */ false,\n /* skipFirstToken */ true,\n );\n return this.finishNode(node, \"TSTypeParameterDeclaration\");\n }\n\n tsTryNextParseConstantContext(): ?N.TsTypeReference {\n if (this.lookahead().type === tt._const) {\n this.next();\n return this.tsParseTypeReference();\n }\n return null;\n }\n\n // Note: In TypeScript implementation we must provide `yieldContext` and `awaitContext`,\n // but here it's always false, because this is only used for types.\n tsFillSignature(\n returnToken: TokenType,\n signature: N.TsSignatureDeclaration,\n ): void {\n // Arrow fns *must* have return token (`=>`). Normal functions can omit it.\n const returnTokenRequired = returnToken === tt.arrow;\n signature.typeParameters = this.tsTryParseTypeParameters();\n this.expect(tt.parenL);\n signature.parameters = this.tsParseBindingListForSignature();\n if (returnTokenRequired) {\n signature.typeAnnotation = this.tsParseTypeOrTypePredicateAnnotation(\n returnToken,\n );\n } else if (this.match(returnToken)) {\n signature.typeAnnotation = this.tsParseTypeOrTypePredicateAnnotation(\n returnToken,\n );\n }\n }\n\n tsParseBindingListForSignature(): $ReadOnlyArray<\n N.Identifier | N.RestElement | N.ObjectPattern | N.ArrayPattern,\n > {\n return this.parseBindingList(tt.parenR, charCodes.rightParenthesis).map(\n pattern => {\n if (\n pattern.type !== \"Identifier\" &&\n pattern.type !== \"RestElement\" &&\n pattern.type !== \"ObjectPattern\" &&\n pattern.type !== \"ArrayPattern\"\n ) {\n this.raise(\n pattern.start,\n TSErrors.UnsupportedSignatureParameterKind,\n pattern.type,\n );\n }\n return (pattern: any);\n },\n );\n }\n\n tsParseTypeMemberSemicolon(): void {\n if (!this.eat(tt.comma)) {\n this.semicolon();\n }\n }\n\n tsParseSignatureMember(\n kind: \"TSCallSignatureDeclaration\" | \"TSConstructSignatureDeclaration\",\n node: N.TsCallSignatureDeclaration | N.TsConstructSignatureDeclaration,\n ): N.TsCallSignatureDeclaration | N.TsConstructSignatureDeclaration {\n this.tsFillSignature(tt.colon, node);\n this.tsParseTypeMemberSemicolon();\n return this.finishNode(node, kind);\n }\n\n tsIsUnambiguouslyIndexSignature() {\n this.next(); // Skip '{'\n return this.eat(tt.name) && this.match(tt.colon);\n }\n\n tsTryParseIndexSignature(node: N.Node): ?N.TsIndexSignature {\n if (\n !(\n this.match(tt.bracketL) &&\n this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this))\n )\n ) {\n return undefined;\n }\n\n this.expect(tt.bracketL);\n const id = this.parseIdentifier();\n id.typeAnnotation = this.tsParseTypeAnnotation();\n this.resetEndLocation(id); // set end position to end of type\n\n this.expect(tt.bracketR);\n node.parameters = [id];\n\n const type = this.tsTryParseTypeAnnotation();\n if (type) node.typeAnnotation = type;\n this.tsParseTypeMemberSemicolon();\n return this.finishNode(node, \"TSIndexSignature\");\n }\n\n tsParsePropertyOrMethodSignature(\n node: N.TsPropertySignature | N.TsMethodSignature,\n readonly: boolean,\n ): N.TsPropertySignature | N.TsMethodSignature {\n if (this.eat(tt.question)) node.optional = true;\n const nodeAny: any = node;\n\n if (!readonly && (this.match(tt.parenL) || this.isRelational(\"<\"))) {\n const method: N.TsMethodSignature = nodeAny;\n this.tsFillSignature(tt.colon, method);\n this.tsParseTypeMemberSemicolon();\n return this.finishNode(method, \"TSMethodSignature\");\n } else {\n const property: N.TsPropertySignature = nodeAny;\n if (readonly) property.readonly = true;\n const type = this.tsTryParseTypeAnnotation();\n if (type) property.typeAnnotation = type;\n this.tsParseTypeMemberSemicolon();\n return this.finishNode(property, \"TSPropertySignature\");\n }\n }\n\n tsParseTypeMember(): N.TsTypeElement {\n const node: any = this.startNode();\n\n if (this.match(tt.parenL) || this.isRelational(\"<\")) {\n return this.tsParseSignatureMember(\"TSCallSignatureDeclaration\", node);\n }\n\n if (this.match(tt._new)) {\n const id: N.Identifier = this.startNode();\n this.next();\n if (this.match(tt.parenL) || this.isRelational(\"<\")) {\n return this.tsParseSignatureMember(\n \"TSConstructSignatureDeclaration\",\n node,\n );\n } else {\n node.key = this.createIdentifier(id, \"new\");\n return this.tsParsePropertyOrMethodSignature(node, false);\n }\n }\n\n const readonly = !!this.tsParseModifier([\"readonly\"]);\n\n const idx = this.tsTryParseIndexSignature(node);\n if (idx) {\n if (readonly) node.readonly = true;\n return idx;\n }\n\n this.parsePropertyName(node, /* isPrivateNameAllowed */ false);\n return this.tsParsePropertyOrMethodSignature(node, readonly);\n }\n\n tsParseTypeLiteral(): N.TsTypeLiteral {\n const node: N.TsTypeLiteral = this.startNode();\n node.members = this.tsParseObjectTypeMembers();\n return this.finishNode(node, \"TSTypeLiteral\");\n }\n\n tsParseObjectTypeMembers(): $ReadOnlyArray {\n this.expect(tt.braceL);\n const members = this.tsParseList(\n \"TypeMembers\",\n this.tsParseTypeMember.bind(this),\n );\n this.expect(tt.braceR);\n return members;\n }\n\n tsIsStartOfMappedType(): boolean {\n this.next();\n if (this.eat(tt.plusMin)) {\n return this.isContextual(\"readonly\");\n }\n if (this.isContextual(\"readonly\")) {\n this.next();\n }\n if (!this.match(tt.bracketL)) {\n return false;\n }\n this.next();\n if (!this.tsIsIdentifier()) {\n return false;\n }\n this.next();\n return this.match(tt._in);\n }\n\n tsParseMappedTypeParameter(): N.TsTypeParameter {\n const node: N.TsTypeParameter = this.startNode();\n node.name = this.parseIdentifierName(node.start);\n node.constraint = this.tsExpectThenParseType(tt._in);\n return this.finishNode(node, \"TSTypeParameter\");\n }\n\n tsParseMappedType(): N.TsMappedType {\n const node: N.TsMappedType = this.startNode();\n\n this.expect(tt.braceL);\n\n if (this.match(tt.plusMin)) {\n node.readonly = this.state.value;\n this.next();\n this.expectContextual(\"readonly\");\n } else if (this.eatContextual(\"readonly\")) {\n node.readonly = true;\n }\n\n this.expect(tt.bracketL);\n node.typeParameter = this.tsParseMappedTypeParameter();\n this.expect(tt.bracketR);\n\n if (this.match(tt.plusMin)) {\n node.optional = this.state.value;\n this.next();\n this.expect(tt.question);\n } else if (this.eat(tt.question)) {\n node.optional = true;\n }\n\n node.typeAnnotation = this.tsTryParseType();\n this.semicolon();\n this.expect(tt.braceR);\n\n return this.finishNode(node, \"TSMappedType\");\n }\n\n tsParseTupleType(): N.TsTupleType {\n const node: N.TsTupleType = this.startNode();\n node.elementTypes = this.tsParseBracketedList(\n \"TupleElementTypes\",\n this.tsParseTupleElementType.bind(this),\n /* bracket */ true,\n /* skipFirstToken */ false,\n );\n\n // Validate the elementTypes to ensure:\n // No mandatory elements may follow optional elements\n // If there's a rest element, it must be at the end of the tuple\n let seenOptionalElement = false;\n node.elementTypes.forEach(elementNode => {\n if (elementNode.type === \"TSOptionalType\") {\n seenOptionalElement = true;\n } else if (seenOptionalElement && elementNode.type !== \"TSRestType\") {\n this.raise(elementNode.start, TSErrors.OptionalTypeBeforeRequired);\n }\n });\n\n return this.finishNode(node, \"TSTupleType\");\n }\n\n tsParseTupleElementType(): N.TsType {\n // parses `...TsType[]`\n if (this.match(tt.ellipsis)) {\n const restNode: N.TsRestType = this.startNode();\n this.next(); // skips ellipsis\n restNode.typeAnnotation = this.tsParseType();\n if (\n this.match(tt.comma) &&\n this.lookaheadCharCode() !== charCodes.rightSquareBracket\n ) {\n this.raiseRestNotLast(this.state.start);\n }\n return this.finishNode(restNode, \"TSRestType\");\n }\n\n const type = this.tsParseType();\n // parses `TsType?`\n if (this.eat(tt.question)) {\n const optionalTypeNode: N.TsOptionalType = this.startNodeAtNode(type);\n optionalTypeNode.typeAnnotation = type;\n return this.finishNode(optionalTypeNode, \"TSOptionalType\");\n }\n return type;\n }\n\n tsParseParenthesizedType(): N.TsParenthesizedType {\n const node = this.startNode();\n this.expect(tt.parenL);\n node.typeAnnotation = this.tsParseType();\n this.expect(tt.parenR);\n return this.finishNode(node, \"TSParenthesizedType\");\n }\n\n tsParseFunctionOrConstructorType(\n type: \"TSFunctionType\" | \"TSConstructorType\",\n ): N.TsFunctionOrConstructorType {\n const node: N.TsFunctionOrConstructorType = this.startNode();\n if (type === \"TSConstructorType\") {\n this.expect(tt._new);\n }\n this.tsFillSignature(tt.arrow, node);\n return this.finishNode(node, type);\n }\n\n tsParseLiteralTypeNode(): N.TsLiteralType {\n const node: N.TsLiteralType = this.startNode();\n node.literal = (() => {\n switch (this.state.type) {\n case tt.num:\n case tt.string:\n case tt._true:\n case tt._false:\n // For compatibility to estree we cannot call parseLiteral directly here\n return this.parseExprAtom();\n default:\n throw this.unexpected();\n }\n })();\n return this.finishNode(node, \"TSLiteralType\");\n }\n\n tsParseTemplateLiteralType(): N.TsType {\n const node: N.TsLiteralType = this.startNode();\n const templateNode = this.parseTemplate(false);\n if (templateNode.expressions.length > 0) {\n this.raise(\n templateNode.expressions[0].start,\n TSErrors.TemplateTypeHasSubstitution,\n );\n }\n node.literal = templateNode;\n return this.finishNode(node, \"TSLiteralType\");\n }\n\n tsParseThisTypeOrThisTypePredicate(): N.TsThisType | N.TsTypePredicate {\n const thisKeyword = this.tsParseThisTypeNode();\n if (this.isContextual(\"is\") && !this.hasPrecedingLineBreak()) {\n return this.tsParseThisTypePredicate(thisKeyword);\n } else {\n return thisKeyword;\n }\n }\n\n tsParseNonArrayType(): N.TsType {\n switch (this.state.type) {\n case tt.name:\n case tt._void:\n case tt._null: {\n const type = this.match(tt._void)\n ? \"TSVoidKeyword\"\n : this.match(tt._null)\n ? \"TSNullKeyword\"\n : keywordTypeFromName(this.state.value);\n if (\n type !== undefined &&\n this.lookaheadCharCode() !== charCodes.dot\n ) {\n const node: N.TsKeywordType = this.startNode();\n this.next();\n return this.finishNode(node, type);\n }\n return this.tsParseTypeReference();\n }\n case tt.string:\n case tt.num:\n case tt._true:\n case tt._false:\n return this.tsParseLiteralTypeNode();\n case tt.plusMin:\n if (this.state.value === \"-\") {\n const node: N.TsLiteralType = this.startNode();\n if (this.lookahead().type !== tt.num) {\n throw this.unexpected();\n }\n node.literal = this.parseMaybeUnary();\n return this.finishNode(node, \"TSLiteralType\");\n }\n break;\n case tt._this:\n return this.tsParseThisTypeOrThisTypePredicate();\n case tt._typeof:\n return this.tsParseTypeQuery();\n case tt._import:\n return this.tsParseImportType();\n case tt.braceL:\n return this.tsLookAhead(this.tsIsStartOfMappedType.bind(this))\n ? this.tsParseMappedType()\n : this.tsParseTypeLiteral();\n case tt.bracketL:\n return this.tsParseTupleType();\n case tt.parenL:\n return this.tsParseParenthesizedType();\n case tt.backQuote:\n return this.tsParseTemplateLiteralType();\n }\n\n throw this.unexpected();\n }\n\n tsParseArrayTypeOrHigher(): N.TsType {\n let type = this.tsParseNonArrayType();\n while (!this.hasPrecedingLineBreak() && this.eat(tt.bracketL)) {\n if (this.match(tt.bracketR)) {\n const node: N.TsArrayType = this.startNodeAtNode(type);\n node.elementType = type;\n this.expect(tt.bracketR);\n type = this.finishNode(node, \"TSArrayType\");\n } else {\n const node: N.TsIndexedAccessType = this.startNodeAtNode(type);\n node.objectType = type;\n node.indexType = this.tsParseType();\n this.expect(tt.bracketR);\n type = this.finishNode(node, \"TSIndexedAccessType\");\n }\n }\n return type;\n }\n\n tsParseTypeOperator(\n operator: \"keyof\" | \"unique\" | \"readonly\",\n ): N.TsTypeOperator {\n const node: N.TsTypeOperator = this.startNode();\n this.expectContextual(operator);\n node.operator = operator;\n node.typeAnnotation = this.tsParseTypeOperatorOrHigher();\n\n if (operator === \"readonly\") {\n this.tsCheckTypeAnnotationForReadOnly(node);\n }\n\n return this.finishNode(node, \"TSTypeOperator\");\n }\n\n tsCheckTypeAnnotationForReadOnly(node: N.Node) {\n switch (node.typeAnnotation.type) {\n case \"TSTupleType\":\n case \"TSArrayType\":\n return;\n default:\n this.raise(node.start, TSErrors.UnexpectedReadonly);\n }\n }\n\n tsParseInferType(): N.TsInferType {\n const node = this.startNode();\n this.expectContextual(\"infer\");\n const typeParameter = this.startNode();\n typeParameter.name = this.parseIdentifierName(typeParameter.start);\n node.typeParameter = this.finishNode(typeParameter, \"TSTypeParameter\");\n return this.finishNode(node, \"TSInferType\");\n }\n\n tsParseTypeOperatorOrHigher(): N.TsType {\n const operator = [\"keyof\", \"unique\", \"readonly\"].find(kw =>\n this.isContextual(kw),\n );\n return operator\n ? this.tsParseTypeOperator(operator)\n : this.isContextual(\"infer\")\n ? this.tsParseInferType()\n : this.tsParseArrayTypeOrHigher();\n }\n\n tsParseUnionOrIntersectionType(\n kind: \"TSUnionType\" | \"TSIntersectionType\",\n parseConstituentType: () => N.TsType,\n operator: TokenType,\n ): N.TsType {\n this.eat(operator);\n let type = parseConstituentType();\n if (this.match(operator)) {\n const types = [type];\n while (this.eat(operator)) {\n types.push(parseConstituentType());\n }\n const node: N.TsUnionType | N.TsIntersectionType = this.startNodeAtNode(\n type,\n );\n node.types = types;\n type = this.finishNode(node, kind);\n }\n return type;\n }\n\n tsParseIntersectionTypeOrHigher(): N.TsType {\n return this.tsParseUnionOrIntersectionType(\n \"TSIntersectionType\",\n this.tsParseTypeOperatorOrHigher.bind(this),\n tt.bitwiseAND,\n );\n }\n\n tsParseUnionTypeOrHigher() {\n return this.tsParseUnionOrIntersectionType(\n \"TSUnionType\",\n this.tsParseIntersectionTypeOrHigher.bind(this),\n tt.bitwiseOR,\n );\n }\n\n tsIsStartOfFunctionType() {\n if (this.isRelational(\"<\")) {\n return true;\n }\n return (\n this.match(tt.parenL) &&\n this.tsLookAhead(this.tsIsUnambiguouslyStartOfFunctionType.bind(this))\n );\n }\n\n tsSkipParameterStart(): boolean {\n if (this.match(tt.name) || this.match(tt._this)) {\n this.next();\n return true;\n }\n\n if (this.match(tt.braceL)) {\n let braceStackCounter = 1;\n this.next();\n\n while (braceStackCounter > 0) {\n if (this.match(tt.braceL)) {\n ++braceStackCounter;\n } else if (this.match(tt.braceR)) {\n --braceStackCounter;\n }\n this.next();\n }\n return true;\n }\n\n if (this.match(tt.bracketL)) {\n let braceStackCounter = 1;\n this.next();\n\n while (braceStackCounter > 0) {\n if (this.match(tt.bracketL)) {\n ++braceStackCounter;\n } else if (this.match(tt.bracketR)) {\n --braceStackCounter;\n }\n this.next();\n }\n return true;\n }\n\n return false;\n }\n\n tsIsUnambiguouslyStartOfFunctionType(): boolean {\n this.next();\n if (this.match(tt.parenR) || this.match(tt.ellipsis)) {\n // ( )\n // ( ...\n return true;\n }\n if (this.tsSkipParameterStart()) {\n if (\n this.match(tt.colon) ||\n this.match(tt.comma) ||\n this.match(tt.question) ||\n this.match(tt.eq)\n ) {\n // ( xxx :\n // ( xxx ,\n // ( xxx ?\n // ( xxx =\n return true;\n }\n if (this.match(tt.parenR)) {\n this.next();\n if (this.match(tt.arrow)) {\n // ( xxx ) =>\n return true;\n }\n }\n }\n return false;\n }\n\n tsParseTypeOrTypePredicateAnnotation(\n returnToken: TokenType,\n ): N.TsTypeAnnotation {\n return this.tsInType(() => {\n const t: N.TsTypeAnnotation = this.startNode();\n this.expect(returnToken);\n\n const asserts = this.tsTryParse(\n this.tsParseTypePredicateAsserts.bind(this),\n );\n\n if (asserts && this.match(tt._this)) {\n // When asserts is false, thisKeyword is handled by tsParseNonArrayType\n // : asserts this is type\n let thisTypePredicate = this.tsParseThisTypeOrThisTypePredicate();\n // if it turns out to be a `TSThisType`, wrap it with `TSTypePredicate`\n // : asserts this\n if (thisTypePredicate.type === \"TSThisType\") {\n const node: N.TsTypePredicate = this.startNodeAtNode(t);\n node.parameterName = (thisTypePredicate: N.TsThisType);\n node.asserts = true;\n thisTypePredicate = this.finishNode(node, \"TSTypePredicate\");\n } else {\n (thisTypePredicate: N.TsTypePredicate).asserts = true;\n }\n t.typeAnnotation = thisTypePredicate;\n return this.finishNode(t, \"TSTypeAnnotation\");\n }\n\n const typePredicateVariable =\n this.tsIsIdentifier() &&\n this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this));\n\n if (!typePredicateVariable) {\n if (!asserts) {\n // : type\n return this.tsParseTypeAnnotation(/* eatColon */ false, t);\n }\n\n const node: N.TsTypePredicate = this.startNodeAtNode(t);\n // : asserts foo\n node.parameterName = this.parseIdentifier();\n node.asserts = asserts;\n t.typeAnnotation = this.finishNode(node, \"TSTypePredicate\");\n return this.finishNode(t, \"TSTypeAnnotation\");\n }\n\n // : asserts foo is type\n const type = this.tsParseTypeAnnotation(/* eatColon */ false);\n const node = this.startNodeAtNode(t);\n node.parameterName = typePredicateVariable;\n node.typeAnnotation = type;\n node.asserts = asserts;\n t.typeAnnotation = this.finishNode(node, \"TSTypePredicate\");\n return this.finishNode(t, \"TSTypeAnnotation\");\n });\n }\n\n tsTryParseTypeOrTypePredicateAnnotation(): ?N.TsTypeAnnotation {\n return this.match(tt.colon)\n ? this.tsParseTypeOrTypePredicateAnnotation(tt.colon)\n : undefined;\n }\n\n tsTryParseTypeAnnotation(): ?N.TsTypeAnnotation {\n return this.match(tt.colon) ? this.tsParseTypeAnnotation() : undefined;\n }\n\n tsTryParseType(): ?N.TsType {\n return this.tsEatThenParseType(tt.colon);\n }\n\n tsParseTypePredicatePrefix(): ?N.Identifier {\n const id = this.parseIdentifier();\n if (this.isContextual(\"is\") && !this.hasPrecedingLineBreak()) {\n this.next();\n return id;\n }\n }\n\n tsParseTypePredicateAsserts(): boolean {\n if (\n !this.match(tt.name) ||\n this.state.value !== \"asserts\" ||\n this.hasPrecedingLineBreak()\n ) {\n return false;\n }\n const containsEsc = this.state.containsEsc;\n this.next();\n if (!this.match(tt.name) && !this.match(tt._this)) {\n return false;\n }\n\n if (containsEsc) {\n this.raise(\n this.state.lastTokStart,\n Errors.InvalidEscapedReservedWord,\n \"asserts\",\n );\n }\n\n return true;\n }\n\n tsParseTypeAnnotation(\n eatColon = true,\n t: N.TsTypeAnnotation = this.startNode(),\n ): N.TsTypeAnnotation {\n this.tsInType(() => {\n if (eatColon) this.expect(tt.colon);\n t.typeAnnotation = this.tsParseType();\n });\n return this.finishNode(t, \"TSTypeAnnotation\");\n }\n\n /** Be sure to be in a type context before calling this, using `tsInType`. */\n tsParseType(): N.TsType {\n // Need to set `state.inType` so that we don't parse JSX in a type context.\n assert(this.state.inType);\n const type = this.tsParseNonConditionalType();\n if (this.hasPrecedingLineBreak() || !this.eat(tt._extends)) {\n return type;\n }\n const node: N.TsConditionalType = this.startNodeAtNode(type);\n node.checkType = type;\n node.extendsType = this.tsParseNonConditionalType();\n this.expect(tt.question);\n node.trueType = this.tsParseType();\n this.expect(tt.colon);\n node.falseType = this.tsParseType();\n return this.finishNode(node, \"TSConditionalType\");\n }\n\n tsParseNonConditionalType(): N.TsType {\n if (this.tsIsStartOfFunctionType()) {\n return this.tsParseFunctionOrConstructorType(\"TSFunctionType\");\n }\n if (this.match(tt._new)) {\n // As in `new () => Date`\n return this.tsParseFunctionOrConstructorType(\"TSConstructorType\");\n }\n return this.tsParseUnionTypeOrHigher();\n }\n\n tsParseTypeAssertion(): N.TsTypeAssertion {\n const node: N.TsTypeAssertion = this.startNode();\n const _const = this.tsTryNextParseConstantContext();\n node.typeAnnotation = _const || this.tsNextThenParseType();\n this.expectRelational(\">\");\n node.expression = this.parseMaybeUnary();\n return this.finishNode(node, \"TSTypeAssertion\");\n }\n\n tsParseHeritageClause(\n descriptor: string,\n ): $ReadOnlyArray {\n const originalStart = this.state.start;\n\n const delimitedList = this.tsParseDelimitedList(\n \"HeritageClauseElement\",\n this.tsParseExpressionWithTypeArguments.bind(this),\n );\n\n if (!delimitedList.length) {\n this.raise(originalStart, TSErrors.EmptyHeritageClauseType, descriptor);\n }\n\n return delimitedList;\n }\n\n tsParseExpressionWithTypeArguments(): N.TsExpressionWithTypeArguments {\n const node: N.TsExpressionWithTypeArguments = this.startNode();\n // Note: TS uses parseLeftHandSideExpressionOrHigher,\n // then has grammar errors later if it's not an EntityName.\n node.expression = this.tsParseEntityName(/* allowReservedWords */ false);\n if (this.isRelational(\"<\")) {\n node.typeParameters = this.tsParseTypeArguments();\n }\n\n return this.finishNode(node, \"TSExpressionWithTypeArguments\");\n }\n\n tsParseInterfaceDeclaration(\n node: N.TsInterfaceDeclaration,\n ): N.TsInterfaceDeclaration {\n node.id = this.parseIdentifier();\n this.checkLVal(\n node.id,\n BIND_TS_INTERFACE,\n undefined,\n \"typescript interface declaration\",\n );\n node.typeParameters = this.tsTryParseTypeParameters();\n if (this.eat(tt._extends)) {\n node.extends = this.tsParseHeritageClause(\"extends\");\n }\n const body: N.TSInterfaceBody = this.startNode();\n body.body = this.tsInType(this.tsParseObjectTypeMembers.bind(this));\n node.body = this.finishNode(body, \"TSInterfaceBody\");\n return this.finishNode(node, \"TSInterfaceDeclaration\");\n }\n\n tsParseTypeAliasDeclaration(\n node: N.TsTypeAliasDeclaration,\n ): N.TsTypeAliasDeclaration {\n node.id = this.parseIdentifier();\n this.checkLVal(node.id, BIND_TS_TYPE, undefined, \"typescript type alias\");\n\n node.typeParameters = this.tsTryParseTypeParameters();\n node.typeAnnotation = this.tsExpectThenParseType(tt.eq);\n this.semicolon();\n return this.finishNode(node, \"TSTypeAliasDeclaration\");\n }\n\n tsInNoContext(cb: () => T): T {\n const oldContext = this.state.context;\n this.state.context = [oldContext[0]];\n try {\n return cb();\n } finally {\n this.state.context = oldContext;\n }\n }\n\n /**\n * Runs `cb` in a type context.\n * This should be called one token *before* the first type token,\n * so that the call to `next()` is run in type context.\n */\n tsInType(cb: () => T): T {\n const oldInType = this.state.inType;\n this.state.inType = true;\n try {\n return cb();\n } finally {\n this.state.inType = oldInType;\n }\n }\n\n tsEatThenParseType(token: TokenType): N.TsType | typeof undefined {\n return !this.match(token) ? undefined : this.tsNextThenParseType();\n }\n\n tsExpectThenParseType(token: TokenType): N.TsType {\n return this.tsDoThenParseType(() => this.expect(token));\n }\n\n tsNextThenParseType(): N.TsType {\n return this.tsDoThenParseType(() => this.next());\n }\n\n tsDoThenParseType(cb: () => void): N.TsType {\n return this.tsInType(() => {\n cb();\n return this.tsParseType();\n });\n }\n\n tsParseEnumMember(): N.TsEnumMember {\n const node: N.TsEnumMember = this.startNode();\n // Computed property names are grammar errors in an enum, so accept just string literal or identifier.\n node.id = this.match(tt.string)\n ? this.parseExprAtom()\n : this.parseIdentifier(/* liberal */ true);\n if (this.eat(tt.eq)) {\n node.initializer = this.parseMaybeAssign();\n }\n return this.finishNode(node, \"TSEnumMember\");\n }\n\n tsParseEnumDeclaration(\n node: N.TsEnumDeclaration,\n isConst: boolean,\n ): N.TsEnumDeclaration {\n if (isConst) node.const = true;\n node.id = this.parseIdentifier();\n this.checkLVal(\n node.id,\n isConst ? BIND_TS_CONST_ENUM : BIND_TS_ENUM,\n undefined,\n \"typescript enum declaration\",\n );\n\n this.expect(tt.braceL);\n node.members = this.tsParseDelimitedList(\n \"EnumMembers\",\n this.tsParseEnumMember.bind(this),\n );\n this.expect(tt.braceR);\n return this.finishNode(node, \"TSEnumDeclaration\");\n }\n\n tsParseModuleBlock(): N.TsModuleBlock {\n const node: N.TsModuleBlock = this.startNode();\n this.scope.enter(SCOPE_OTHER);\n\n this.expect(tt.braceL);\n // Inside of a module block is considered \"top-level\", meaning it can have imports and exports.\n this.parseBlockOrModuleBlockBody(\n (node.body = []),\n /* directives */ undefined,\n /* topLevel */ true,\n /* end */ tt.braceR,\n );\n this.scope.exit();\n return this.finishNode(node, \"TSModuleBlock\");\n }\n\n tsParseModuleOrNamespaceDeclaration(\n node: N.TsModuleDeclaration,\n nested?: boolean = false,\n ): N.TsModuleDeclaration {\n node.id = this.parseIdentifier();\n\n if (!nested) {\n this.checkLVal(\n node.id,\n BIND_TS_NAMESPACE,\n null,\n \"module or namespace declaration\",\n );\n }\n\n if (this.eat(tt.dot)) {\n const inner = this.startNode();\n this.tsParseModuleOrNamespaceDeclaration(inner, true);\n node.body = inner;\n } else {\n this.scope.enter(SCOPE_TS_MODULE);\n this.prodParam.enter(PARAM);\n node.body = this.tsParseModuleBlock();\n this.prodParam.exit();\n this.scope.exit();\n }\n return this.finishNode(node, \"TSModuleDeclaration\");\n }\n\n tsParseAmbientExternalModuleDeclaration(\n node: N.TsModuleDeclaration,\n ): N.TsModuleDeclaration {\n if (this.isContextual(\"global\")) {\n node.global = true;\n node.id = this.parseIdentifier();\n } else if (this.match(tt.string)) {\n node.id = this.parseExprAtom();\n } else {\n this.unexpected();\n }\n if (this.match(tt.braceL)) {\n this.scope.enter(SCOPE_TS_MODULE);\n this.prodParam.enter(PARAM);\n node.body = this.tsParseModuleBlock();\n this.prodParam.exit();\n this.scope.exit();\n } else {\n this.semicolon();\n }\n\n return this.finishNode(node, \"TSModuleDeclaration\");\n }\n\n tsParseImportEqualsDeclaration(\n node: N.TsImportEqualsDeclaration,\n isExport?: boolean,\n ): N.TsImportEqualsDeclaration {\n node.isExport = isExport || false;\n node.id = this.parseIdentifier();\n this.checkLVal(\n node.id,\n BIND_LEXICAL,\n undefined,\n \"import equals declaration\",\n );\n this.expect(tt.eq);\n node.moduleReference = this.tsParseModuleReference();\n this.semicolon();\n return this.finishNode(node, \"TSImportEqualsDeclaration\");\n }\n\n tsIsExternalModuleReference(): boolean {\n return (\n this.isContextual(\"require\") &&\n this.lookaheadCharCode() === charCodes.leftParenthesis\n );\n }\n\n tsParseModuleReference(): N.TsModuleReference {\n return this.tsIsExternalModuleReference()\n ? this.tsParseExternalModuleReference()\n : this.tsParseEntityName(/* allowReservedWords */ false);\n }\n\n tsParseExternalModuleReference(): N.TsExternalModuleReference {\n const node: N.TsExternalModuleReference = this.startNode();\n this.expectContextual(\"require\");\n this.expect(tt.parenL);\n if (!this.match(tt.string)) {\n throw this.unexpected();\n }\n // For compatibility to estree we cannot call parseLiteral directly here\n node.expression = this.parseExprAtom();\n this.expect(tt.parenR);\n return this.finishNode(node, \"TSExternalModuleReference\");\n }\n\n // Utilities\n\n tsLookAhead(f: () => T): T {\n const state = this.state.clone();\n const res = f();\n this.state = state;\n return res;\n }\n\n tsTryParseAndCatch(f: () => T): ?T {\n const result = this.tryParse(abort => f() || abort());\n\n if (result.aborted || !result.node) return undefined;\n if (result.error) this.state = result.failState;\n return result.node;\n }\n\n tsTryParse(f: () => ?T): ?T {\n const state = this.state.clone();\n const result = f();\n if (result !== undefined && result !== false) {\n return result;\n } else {\n this.state = state;\n return undefined;\n }\n }\n\n tsTryParseDeclare(nany: any): ?N.Declaration {\n if (this.isLineTerminator()) {\n return;\n }\n let starttype = this.state.type;\n let kind;\n\n if (this.isContextual(\"let\")) {\n starttype = tt._var;\n kind = \"let\";\n }\n\n switch (starttype) {\n case tt._function:\n return this.parseFunctionStatement(\n nany,\n /* async */ false,\n /* declarationPosition */ true,\n );\n case tt._class:\n // While this is also set by tsParseExpressionStatement, we need to set it\n // before parsing the class declaration to now how to register it in the scope.\n nany.declare = true;\n return this.parseClass(\n nany,\n /* isStatement */ true,\n /* optionalId */ false,\n );\n case tt._const:\n if (this.match(tt._const) && this.isLookaheadContextual(\"enum\")) {\n // `const enum = 0;` not allowed because \"enum\" is a strict mode reserved word.\n this.expect(tt._const);\n this.expectContextual(\"enum\");\n return this.tsParseEnumDeclaration(nany, /* isConst */ true);\n }\n // falls through\n case tt._var:\n kind = kind || this.state.value;\n return this.parseVarStatement(nany, kind);\n case tt.name: {\n const value = this.state.value;\n if (value === \"global\") {\n return this.tsParseAmbientExternalModuleDeclaration(nany);\n } else {\n return this.tsParseDeclaration(nany, value, /* next */ true);\n }\n }\n }\n }\n\n // Note: this won't be called unless the keyword is allowed in `shouldParseExportDeclaration`.\n tsTryParseExportDeclaration(): ?N.Declaration {\n return this.tsParseDeclaration(\n this.startNode(),\n this.state.value,\n /* next */ true,\n );\n }\n\n tsParseExpressionStatement(node: any, expr: N.Identifier): ?N.Declaration {\n switch (expr.name) {\n case \"declare\": {\n const declaration = this.tsTryParseDeclare(node);\n if (declaration) {\n declaration.declare = true;\n return declaration;\n }\n break;\n }\n case \"global\":\n // `global { }` (with no `declare`) may appear inside an ambient module declaration.\n // Would like to use tsParseAmbientExternalModuleDeclaration here, but already ran past \"global\".\n if (this.match(tt.braceL)) {\n this.scope.enter(SCOPE_TS_MODULE);\n this.prodParam.enter(PARAM);\n const mod: N.TsModuleDeclaration = node;\n mod.global = true;\n mod.id = expr;\n mod.body = this.tsParseModuleBlock();\n this.scope.exit();\n this.prodParam.exit();\n return this.finishNode(mod, \"TSModuleDeclaration\");\n }\n break;\n\n default:\n return this.tsParseDeclaration(node, expr.name, /* next */ false);\n }\n }\n\n // Common to tsTryParseDeclare, tsTryParseExportDeclaration, and tsParseExpressionStatement.\n tsParseDeclaration(\n node: any,\n value: string,\n next: boolean,\n ): ?N.Declaration {\n switch (value) {\n case \"abstract\":\n if (this.tsCheckLineTerminatorAndMatch(tt._class, next)) {\n const cls: N.ClassDeclaration = node;\n cls.abstract = true;\n if (next) {\n this.next();\n if (!this.match(tt._class)) {\n this.unexpected(null, tt._class);\n }\n }\n return this.parseClass(\n cls,\n /* isStatement */ true,\n /* optionalId */ false,\n );\n }\n break;\n\n case \"enum\":\n if (next || this.match(tt.name)) {\n if (next) this.next();\n return this.tsParseEnumDeclaration(node, /* isConst */ false);\n }\n break;\n\n case \"interface\":\n if (this.tsCheckLineTerminatorAndMatch(tt.name, next)) {\n if (next) this.next();\n return this.tsParseInterfaceDeclaration(node);\n }\n break;\n\n case \"module\":\n if (next) this.next();\n if (this.match(tt.string)) {\n return this.tsParseAmbientExternalModuleDeclaration(node);\n } else if (this.tsCheckLineTerminatorAndMatch(tt.name, next)) {\n return this.tsParseModuleOrNamespaceDeclaration(node);\n }\n break;\n\n case \"namespace\":\n if (this.tsCheckLineTerminatorAndMatch(tt.name, next)) {\n if (next) this.next();\n return this.tsParseModuleOrNamespaceDeclaration(node);\n }\n break;\n\n case \"type\":\n if (this.tsCheckLineTerminatorAndMatch(tt.name, next)) {\n if (next) this.next();\n return this.tsParseTypeAliasDeclaration(node);\n }\n break;\n }\n }\n\n tsCheckLineTerminatorAndMatch(tokenType: TokenType, next: boolean) {\n return (next || this.match(tokenType)) && !this.isLineTerminator();\n }\n\n tsTryParseGenericAsyncArrowFunction(\n startPos: number,\n startLoc: Position,\n ): ?N.ArrowFunctionExpression {\n if (!this.isRelational(\"<\")) {\n return undefined;\n }\n\n const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;\n const oldYieldPos = this.state.yieldPos;\n const oldAwaitPos = this.state.awaitPos;\n this.state.maybeInArrowParameters = true;\n this.state.yieldPos = -1;\n this.state.awaitPos = -1;\n\n const res: ?N.ArrowFunctionExpression = this.tsTryParseAndCatch(() => {\n const node: N.ArrowFunctionExpression = this.startNodeAt(\n startPos,\n startLoc,\n );\n node.typeParameters = this.tsParseTypeParameters();\n // Don't use overloaded parseFunctionParams which would look for \"<\" again.\n super.parseFunctionParams(node);\n node.returnType = this.tsTryParseTypeOrTypePredicateAnnotation();\n this.expect(tt.arrow);\n return node;\n });\n\n this.state.maybeInArrowParameters = oldMaybeInArrowParameters;\n this.state.yieldPos = oldYieldPos;\n this.state.awaitPos = oldAwaitPos;\n\n if (!res) {\n return undefined;\n }\n\n return this.parseArrowExpression(\n res,\n /* params are already set */ null,\n /* async */ true,\n );\n }\n\n tsParseTypeArguments(): N.TsTypeParameterInstantiation {\n const node = this.startNode();\n node.params = this.tsInType(() =>\n // Temporarily remove a JSX parsing context, which makes us scan different tokens.\n this.tsInNoContext(() => {\n this.expectRelational(\"<\");\n return this.tsParseDelimitedList(\n \"TypeParametersOrArguments\",\n this.tsParseType.bind(this),\n );\n }),\n );\n // This reads the next token after the `>` too, so do this in the enclosing context.\n // But be sure not to parse a regex in the jsx expression ` />`, so set exprAllowed = false\n this.state.exprAllowed = false;\n this.expectRelational(\">\");\n return this.finishNode(node, \"TSTypeParameterInstantiation\");\n }\n\n tsIsDeclarationStart(): boolean {\n if (this.match(tt.name)) {\n switch (this.state.value) {\n case \"abstract\":\n case \"declare\":\n case \"enum\":\n case \"interface\":\n case \"module\":\n case \"namespace\":\n case \"type\":\n return true;\n }\n }\n\n return false;\n }\n\n // ======================================================\n // OVERRIDES\n // ======================================================\n\n isExportDefaultSpecifier(): boolean {\n if (this.tsIsDeclarationStart()) return false;\n return super.isExportDefaultSpecifier();\n }\n\n parseAssignableListItem(\n allowModifiers: ?boolean,\n decorators: N.Decorator[],\n ): N.Pattern | N.TSParameterProperty {\n // Store original location/position to include modifiers in range\n const startPos = this.state.start;\n const startLoc = this.state.startLoc;\n\n let accessibility: ?N.Accessibility;\n let readonly = false;\n if (allowModifiers) {\n accessibility = this.parseAccessModifier();\n readonly = !!this.tsParseModifier([\"readonly\"]);\n }\n\n const left = this.parseMaybeDefault();\n this.parseAssignableListItemTypes(left);\n const elt = this.parseMaybeDefault(left.start, left.loc.start, left);\n if (accessibility || readonly) {\n const pp: N.TSParameterProperty = this.startNodeAt(startPos, startLoc);\n if (decorators.length) {\n pp.decorators = decorators;\n }\n if (accessibility) pp.accessibility = accessibility;\n if (readonly) pp.readonly = readonly;\n if (elt.type !== \"Identifier\" && elt.type !== \"AssignmentPattern\") {\n this.raise(pp.start, TSErrors.UnsupportedParameterPropertyKind);\n }\n pp.parameter = ((elt: any): N.Identifier | N.AssignmentPattern);\n return this.finishNode(pp, \"TSParameterProperty\");\n }\n\n if (decorators.length) {\n left.decorators = decorators;\n }\n\n return elt;\n }\n\n parseFunctionBodyAndFinish(\n node: N.BodilessFunctionOrMethodBase,\n type: string,\n isMethod?: boolean = false,\n ): void {\n if (this.match(tt.colon)) {\n node.returnType = this.tsParseTypeOrTypePredicateAnnotation(tt.colon);\n }\n\n const bodilessType =\n type === \"FunctionDeclaration\"\n ? \"TSDeclareFunction\"\n : type === \"ClassMethod\"\n ? \"TSDeclareMethod\"\n : undefined;\n if (bodilessType && !this.match(tt.braceL) && this.isLineTerminator()) {\n this.finishNode(node, bodilessType);\n return;\n }\n\n super.parseFunctionBodyAndFinish(node, type, isMethod);\n }\n\n registerFunctionStatementId(node: N.Function): void {\n if (!node.body && node.id) {\n // Function ids are validated after parsing their body.\n // For bodyless function, we need to do it here.\n this.checkLVal(node.id, BIND_TS_AMBIENT, null, \"function name\");\n } else {\n super.registerFunctionStatementId(...arguments);\n }\n }\n\n parseSubscript(\n base: N.Expression,\n startPos: number,\n startLoc: Position,\n noCalls: ?boolean,\n state: N.ParseSubscriptState,\n ): N.Expression {\n if (!this.hasPrecedingLineBreak() && this.match(tt.bang)) {\n this.state.exprAllowed = false;\n this.next();\n\n const nonNullExpression: N.TsNonNullExpression = this.startNodeAt(\n startPos,\n startLoc,\n );\n nonNullExpression.expression = base;\n return this.finishNode(nonNullExpression, \"TSNonNullExpression\");\n }\n\n if (this.isRelational(\"<\")) {\n // tsTryParseAndCatch is expensive, so avoid if not necessary.\n // There are number of things we are going to \"maybe\" parse, like type arguments on\n // tagged template expressions. If any of them fail, walk it back and continue.\n const result = this.tsTryParseAndCatch(() => {\n if (!noCalls && this.atPossibleAsyncArrow(base)) {\n // Almost certainly this is a generic async function `async () => ...\n // But it might be a call with a type argument `async();`\n const asyncArrowFn = this.tsTryParseGenericAsyncArrowFunction(\n startPos,\n startLoc,\n );\n if (asyncArrowFn) {\n return asyncArrowFn;\n }\n }\n\n const node: N.CallExpression = this.startNodeAt(startPos, startLoc);\n node.callee = base;\n\n const typeArguments = this.tsParseTypeArguments();\n\n if (typeArguments) {\n if (!noCalls && this.eat(tt.parenL)) {\n // possibleAsync always false here, because we would have handled it above.\n // $FlowIgnore (won't be any undefined arguments)\n node.arguments = this.parseCallExpressionArguments(\n tt.parenR,\n /* possibleAsync */ false,\n );\n node.typeParameters = typeArguments;\n return this.finishCallExpression(node, state.optionalChainMember);\n } else if (this.match(tt.backQuote)) {\n return this.parseTaggedTemplateExpression(\n startPos,\n startLoc,\n base,\n state,\n typeArguments,\n );\n }\n }\n\n this.unexpected();\n });\n\n if (result) return result;\n }\n\n return super.parseSubscript(base, startPos, startLoc, noCalls, state);\n }\n\n parseNewArguments(node: N.NewExpression): void {\n if (this.isRelational(\"<\")) {\n // tsTryParseAndCatch is expensive, so avoid if not necessary.\n // 99% certain this is `new C();`. But may be `new C < T;`, which is also legal.\n const typeParameters = this.tsTryParseAndCatch(() => {\n const args = this.tsParseTypeArguments();\n if (!this.match(tt.parenL)) this.unexpected();\n return args;\n });\n if (typeParameters) {\n node.typeParameters = typeParameters;\n }\n }\n\n super.parseNewArguments(node);\n }\n\n parseExprOp(\n left: N.Expression,\n leftStartPos: number,\n leftStartLoc: Position,\n minPrec: number,\n noIn: ?boolean,\n ) {\n if (\n nonNull(tt._in.binop) > minPrec &&\n !this.hasPrecedingLineBreak() &&\n this.isContextual(\"as\")\n ) {\n const node: N.TsAsExpression = this.startNodeAt(\n leftStartPos,\n leftStartLoc,\n );\n node.expression = left;\n const _const = this.tsTryNextParseConstantContext();\n if (_const) {\n node.typeAnnotation = _const;\n } else {\n node.typeAnnotation = this.tsNextThenParseType();\n }\n this.finishNode(node, \"TSAsExpression\");\n return this.parseExprOp(\n node,\n leftStartPos,\n leftStartLoc,\n minPrec,\n noIn,\n );\n }\n\n return super.parseExprOp(left, leftStartPos, leftStartLoc, minPrec, noIn);\n }\n\n checkReservedWord(\n word: string, // eslint-disable-line no-unused-vars\n startLoc: number, // eslint-disable-line no-unused-vars\n checkKeywords: boolean, // eslint-disable-line no-unused-vars\n // eslint-disable-next-line no-unused-vars\n isBinding: boolean,\n ): void {\n // Don't bother checking for TypeScript code.\n // Strict mode words may be allowed as in `declare namespace N { const static: number; }`.\n // And we have a type checker anyway, so don't bother having the parser do it.\n }\n\n /*\n Don't bother doing this check in TypeScript code because:\n 1. We may have a nested export statement with the same name:\n export const x = 0;\n export namespace N {\n export const x = 1;\n }\n 2. We have a type checker to warn us about this sort of thing.\n */\n checkDuplicateExports() {}\n\n parseImport(node: N.Node): N.AnyImport {\n if (this.match(tt.name) || this.match(tt.star) || this.match(tt.braceL)) {\n const ahead = this.lookahead();\n\n if (this.match(tt.name) && ahead.type === tt.eq) {\n return this.tsParseImportEqualsDeclaration(node);\n }\n\n if (\n this.isContextual(\"type\") &&\n // import type, { a } from \"b\";\n ahead.type !== tt.comma &&\n // import type from \"a\";\n !(ahead.type === tt.name && ahead.value === \"from\")\n ) {\n node.importKind = \"type\";\n this.next();\n } else {\n node.importKind = \"value\";\n }\n }\n\n const importNode = super.parseImport(node);\n /*:: invariant(importNode.type !== \"TSImportEqualsDeclaration\") */\n\n // `import type` can only be used on imports with named imports or with a\n // default import - but not both\n if (\n importNode.importKind === \"type\" &&\n importNode.specifiers.length > 1 &&\n importNode.specifiers[0].type === \"ImportDefaultSpecifier\"\n ) {\n this.raise(\n importNode.start,\n \"A type-only import can specify a default import or named bindings, but not both.\",\n );\n }\n\n return importNode;\n }\n\n parseExport(node: N.Node): N.AnyExport {\n if (this.match(tt._import)) {\n // `export import A = B;`\n this.expect(tt._import);\n return this.tsParseImportEqualsDeclaration(node, /* isExport */ true);\n } else if (this.eat(tt.eq)) {\n // `export = x;`\n const assign: N.TsExportAssignment = node;\n assign.expression = this.parseExpression();\n this.semicolon();\n return this.finishNode(assign, \"TSExportAssignment\");\n } else if (this.eatContextual(\"as\")) {\n // `export as namespace A;`\n const decl: N.TsNamespaceExportDeclaration = node;\n // See `parseNamespaceExportDeclaration` in TypeScript's own parser\n this.expectContextual(\"namespace\");\n decl.id = this.parseIdentifier();\n this.semicolon();\n return this.finishNode(decl, \"TSNamespaceExportDeclaration\");\n } else {\n if (this.isContextual(\"type\") && this.lookahead().type === tt.braceL) {\n this.next();\n node.exportKind = \"type\";\n } else {\n node.exportKind = \"value\";\n }\n\n return super.parseExport(node);\n }\n }\n\n isAbstractClass(): boolean {\n return (\n this.isContextual(\"abstract\") && this.lookahead().type === tt._class\n );\n }\n\n parseExportDefaultExpression(): N.Expression | N.Declaration {\n if (this.isAbstractClass()) {\n const cls = this.startNode();\n this.next(); // Skip \"abstract\"\n this.parseClass(cls, true, true);\n cls.abstract = true;\n return cls;\n }\n\n // export default interface allowed in:\n // https://github.com/Microsoft/TypeScript/pull/16040\n if (this.state.value === \"interface\") {\n const result = this.tsParseDeclaration(\n this.startNode(),\n this.state.value,\n true,\n );\n\n if (result) return result;\n }\n\n return super.parseExportDefaultExpression();\n }\n\n parseStatementContent(context: ?string, topLevel: ?boolean): N.Statement {\n if (this.state.type === tt._const) {\n const ahead = this.lookahead();\n if (ahead.type === tt.name && ahead.value === \"enum\") {\n const node: N.TsEnumDeclaration = this.startNode();\n this.expect(tt._const);\n this.expectContextual(\"enum\");\n return this.tsParseEnumDeclaration(node, /* isConst */ true);\n }\n }\n return super.parseStatementContent(context, topLevel);\n }\n\n parseAccessModifier(): ?N.Accessibility {\n return this.tsParseModifier([\"public\", \"protected\", \"private\"]);\n }\n\n parseClassMember(\n classBody: N.ClassBody,\n member: any,\n state: { hadConstructor: boolean },\n constructorAllowsSuper: boolean,\n ): void {\n this.tsParseModifiers(member, [\"declare\"]);\n const accessibility = this.parseAccessModifier();\n if (accessibility) member.accessibility = accessibility;\n this.tsParseModifiers(member, [\"declare\"]);\n\n super.parseClassMember(classBody, member, state, constructorAllowsSuper);\n }\n\n parseClassMemberWithIsStatic(\n classBody: N.ClassBody,\n member: N.ClassMember | N.TsIndexSignature,\n state: { hadConstructor: boolean },\n isStatic: boolean,\n constructorAllowsSuper: boolean,\n ): void {\n this.tsParseModifiers(member, [\"abstract\", \"readonly\", \"declare\"]);\n\n const idx = this.tsTryParseIndexSignature(member);\n if (idx) {\n classBody.body.push(idx);\n\n if ((member: any).abstract) {\n this.raise(member.start, TSErrors.IndexSignatureHasAbstract);\n }\n if (isStatic) {\n this.raise(member.start, TSErrors.IndexSignatureHasStatic);\n }\n if ((member: any).accessibility) {\n this.raise(\n member.start,\n TSErrors.IndexSignatureHasAccessibility,\n (member: any).accessibility,\n );\n }\n\n return;\n }\n\n /*:: invariant(member.type !== \"TSIndexSignature\") */\n\n super.parseClassMemberWithIsStatic(\n classBody,\n member,\n state,\n isStatic,\n constructorAllowsSuper,\n );\n }\n\n parsePostMemberNameModifiers(\n methodOrProp: N.ClassMethod | N.ClassProperty | N.ClassPrivateProperty,\n ): void {\n const optional = this.eat(tt.question);\n if (optional) methodOrProp.optional = true;\n\n if ((methodOrProp: any).readonly && this.match(tt.parenL)) {\n this.raise(methodOrProp.start, TSErrors.ClassMethodHasReadonly);\n }\n\n if ((methodOrProp: any).declare && this.match(tt.parenL)) {\n this.raise(methodOrProp.start, TSErrors.ClassMethodHasDeclare);\n }\n }\n\n // Note: The reason we do this in `parseExpressionStatement` and not `parseStatement`\n // is that e.g. `type()` is valid JS, so we must try parsing that first.\n // If it's really a type, we will parse `type` as the statement, and can correct it here\n // by parsing the rest.\n parseExpressionStatement(\n node: N.ExpressionStatement,\n expr: N.Expression,\n ): N.Statement {\n const decl =\n expr.type === \"Identifier\"\n ? this.tsParseExpressionStatement(node, expr)\n : undefined;\n return decl || super.parseExpressionStatement(node, expr);\n }\n\n // export type\n // Should be true for anything parsed by `tsTryParseExportDeclaration`.\n shouldParseExportDeclaration(): boolean {\n if (this.tsIsDeclarationStart()) return true;\n return super.shouldParseExportDeclaration();\n }\n\n // An apparent conditional expression could actually be an optional parameter in an arrow function.\n parseConditional(\n expr: N.Expression,\n noIn: ?boolean,\n startPos: number,\n startLoc: Position,\n refNeedsArrowPos?: ?Pos,\n ): N.Expression {\n // only do the expensive clone if there is a question mark\n // and if we come from inside parens\n if (!refNeedsArrowPos || !this.match(tt.question)) {\n return super.parseConditional(\n expr,\n noIn,\n startPos,\n startLoc,\n refNeedsArrowPos,\n );\n }\n\n const result = this.tryParse(() =>\n super.parseConditional(expr, noIn, startPos, startLoc),\n );\n\n if (!result.node) {\n // $FlowIgnore\n refNeedsArrowPos.start = result.error.pos || this.state.start;\n return expr;\n }\n if (result.error) this.state = result.failState;\n return result.node;\n }\n\n // Note: These \"type casts\" are *not* valid TS expressions.\n // But we parse them here and change them when completing the arrow function.\n parseParenItem(\n node: N.Expression,\n startPos: number,\n startLoc: Position,\n ): N.Expression {\n node = super.parseParenItem(node, startPos, startLoc);\n if (this.eat(tt.question)) {\n node.optional = true;\n // Include questionmark in location of node\n // Don't use this.finishNode() as otherwise we might process comments twice and\n // include already consumed parens\n this.resetEndLocation(node);\n }\n\n if (this.match(tt.colon)) {\n const typeCastNode: N.TsTypeCastExpression = this.startNodeAt(\n startPos,\n startLoc,\n );\n typeCastNode.expression = node;\n typeCastNode.typeAnnotation = this.tsParseTypeAnnotation();\n\n return this.finishNode(typeCastNode, \"TSTypeCastExpression\");\n }\n\n return node;\n }\n\n parseExportDeclaration(node: N.ExportNamedDeclaration): ?N.Declaration {\n // Store original location/position\n const startPos = this.state.start;\n const startLoc = this.state.startLoc;\n\n // \"export declare\" is equivalent to just \"export\".\n const isDeclare = this.eatContextual(\"declare\");\n\n let declaration: ?N.Declaration;\n\n if (this.match(tt.name)) {\n declaration = this.tsTryParseExportDeclaration();\n }\n if (!declaration) {\n declaration = super.parseExportDeclaration(node);\n }\n if (\n declaration &&\n (declaration.type === \"TSInterfaceDeclaration\" ||\n declaration.type === \"TSTypeAliasDeclaration\" ||\n isDeclare)\n ) {\n node.exportKind = \"type\";\n }\n\n if (declaration && isDeclare) {\n // Reset location to include `declare` in range\n this.resetStartLocation(declaration, startPos, startLoc);\n\n declaration.declare = true;\n }\n\n return declaration;\n }\n\n parseClassId(\n node: N.Class,\n isStatement: boolean,\n optionalId: ?boolean,\n ): void {\n if ((!isStatement || optionalId) && this.isContextual(\"implements\")) {\n return;\n }\n\n super.parseClassId(\n node,\n isStatement,\n optionalId,\n (node: any).declare ? BIND_TS_AMBIENT : BIND_CLASS,\n );\n const typeParameters = this.tsTryParseTypeParameters();\n if (typeParameters) node.typeParameters = typeParameters;\n }\n\n parseClassPropertyAnnotation(\n node: N.ClassProperty | N.ClassPrivateProperty,\n ): void {\n if (!node.optional && this.eat(tt.bang)) {\n node.definite = true;\n }\n\n const type = this.tsTryParseTypeAnnotation();\n if (type) node.typeAnnotation = type;\n }\n\n parseClassProperty(node: N.ClassProperty): N.ClassProperty {\n this.parseClassPropertyAnnotation(node);\n\n if (node.declare && this.match(tt.equal)) {\n this.raise(this.state.start, TSErrors.DeclareClassFieldHasInitializer);\n }\n\n return super.parseClassProperty(node);\n }\n\n parseClassPrivateProperty(\n node: N.ClassPrivateProperty,\n ): N.ClassPrivateProperty {\n // $FlowIgnore\n if (node.abstract) {\n this.raise(node.start, TSErrors.PrivateElementHasAbstract);\n }\n\n // $FlowIgnore\n if (node.accessibility) {\n this.raise(\n node.start,\n TSErrors.PrivateElementHasAccessibility,\n node.accessibility,\n );\n }\n\n this.parseClassPropertyAnnotation(node);\n return super.parseClassPrivateProperty(node);\n }\n\n pushClassMethod(\n classBody: N.ClassBody,\n method: N.ClassMethod,\n isGenerator: boolean,\n isAsync: boolean,\n isConstructor: boolean,\n allowsDirectSuper: boolean,\n ): void {\n const typeParameters = this.tsTryParseTypeParameters();\n if (typeParameters) method.typeParameters = typeParameters;\n super.pushClassMethod(\n classBody,\n method,\n isGenerator,\n isAsync,\n isConstructor,\n allowsDirectSuper,\n );\n }\n\n pushClassPrivateMethod(\n classBody: N.ClassBody,\n method: N.ClassPrivateMethod,\n isGenerator: boolean,\n isAsync: boolean,\n ): void {\n const typeParameters = this.tsTryParseTypeParameters();\n if (typeParameters) method.typeParameters = typeParameters;\n super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync);\n }\n\n parseClassSuper(node: N.Class): void {\n super.parseClassSuper(node);\n if (node.superClass && this.isRelational(\"<\")) {\n node.superTypeParameters = this.tsParseTypeArguments();\n }\n if (this.eatContextual(\"implements\")) {\n node.implements = this.tsParseHeritageClause(\"implements\");\n }\n }\n\n parseObjPropValue(prop: N.ObjectMember, ...args): void {\n const typeParameters = this.tsTryParseTypeParameters();\n if (typeParameters) prop.typeParameters = typeParameters;\n\n super.parseObjPropValue(prop, ...args);\n }\n\n parseFunctionParams(node: N.Function, allowModifiers?: boolean): void {\n const typeParameters = this.tsTryParseTypeParameters();\n if (typeParameters) node.typeParameters = typeParameters;\n super.parseFunctionParams(node, allowModifiers);\n }\n\n // `let x: number;`\n parseVarId(\n decl: N.VariableDeclarator,\n kind: \"var\" | \"let\" | \"const\",\n ): void {\n super.parseVarId(decl, kind);\n if (decl.id.type === \"Identifier\" && this.eat(tt.bang)) {\n decl.definite = true;\n }\n\n const type = this.tsTryParseTypeAnnotation();\n if (type) {\n decl.id.typeAnnotation = type;\n this.resetEndLocation(decl.id); // set end position to end of type\n }\n }\n\n // parse the return type of an async arrow function - let foo = (async (): number => {});\n parseAsyncArrowFromCallExpression(\n node: N.ArrowFunctionExpression,\n call: N.CallExpression,\n ): N.ArrowFunctionExpression {\n if (this.match(tt.colon)) {\n node.returnType = this.tsParseTypeAnnotation();\n }\n return super.parseAsyncArrowFromCallExpression(node, call);\n }\n\n parseMaybeAssign(...args): N.Expression {\n // Note: When the JSX plugin is on, type assertions (` x`) aren't valid syntax.\n\n let state: ?State;\n let jsx;\n let typeCast;\n\n if (this.match(tt.jsxTagStart)) {\n // Prefer to parse JSX if possible. But may be an arrow fn.\n state = this.state.clone();\n\n jsx = this.tryParse(() => super.parseMaybeAssign(...args), state);\n /*:: invariant(!jsx.aborted) */\n\n if (!jsx.error) return jsx.node;\n\n // Remove `tc.j_expr` and `tc.j_oTag` from context added\n // by parsing `jsxTagStart` to stop the JSX plugin from\n // messing with the tokens\n const { context } = this.state;\n if (context[context.length - 1] === ct.j_oTag) {\n context.length -= 2;\n } else if (context[context.length - 1] === ct.j_expr) {\n context.length -= 1;\n }\n }\n\n if (!(jsx && jsx.error) && !this.isRelational(\"<\")) {\n return super.parseMaybeAssign(...args);\n }\n\n // Either way, we're looking at a '<': tt.jsxTagStart or relational.\n\n let typeParameters: N.TsTypeParameterDeclaration;\n state = state || this.state.clone();\n\n const arrow = this.tryParse(abort => {\n // This is similar to TypeScript's `tryParseParenthesizedArrowFunctionExpression`.\n typeParameters = this.tsParseTypeParameters();\n const expr = super.parseMaybeAssign(...args);\n\n if (\n expr.type !== \"ArrowFunctionExpression\" ||\n (expr.extra && expr.extra.parenthesized)\n ) {\n abort();\n }\n\n // Correct TypeScript code should have at least 1 type parameter, but don't crash on bad code.\n if (typeParameters && typeParameters.params.length !== 0) {\n this.resetStartLocationFromNode(expr, typeParameters);\n }\n expr.typeParameters = typeParameters;\n return expr;\n }, state);\n\n if (!arrow.error && !arrow.aborted) return arrow.node;\n\n if (!jsx) {\n // Try parsing a type cast instead of an arrow function.\n // This will never happen outside of JSX.\n // (Because in JSX the '<' should be a jsxTagStart and not a relational.\n assert(!this.hasPlugin(\"jsx\"));\n\n // This will start with a type assertion (via parseMaybeUnary).\n // But don't directly call `this.tsParseTypeAssertion` because we want to handle any binary after it.\n typeCast = this.tryParse(() => super.parseMaybeAssign(...args), state);\n /*:: invariant(!typeCast.aborted) */\n if (!typeCast.error) return typeCast.node;\n }\n\n if (jsx && jsx.node) {\n /*:: invariant(jsx.failState) */\n this.state = jsx.failState;\n return jsx.node;\n }\n\n if (arrow.node) {\n /*:: invariant(arrow.failState) */\n this.state = arrow.failState;\n return arrow.node;\n }\n\n if (typeCast && typeCast.node) {\n /*:: invariant(typeCast.failState) */\n this.state = typeCast.failState;\n return typeCast.node;\n }\n\n if (jsx && jsx.thrown) throw jsx.error;\n if (arrow.thrown) throw arrow.error;\n if (typeCast && typeCast.thrown) throw typeCast.error;\n\n throw (jsx && jsx.error) || arrow.error || (typeCast && typeCast.error);\n }\n\n // Handle type assertions\n parseMaybeUnary(refExpressionErrors?: ?ExpressionErrors): N.Expression {\n if (!this.hasPlugin(\"jsx\") && this.isRelational(\"<\")) {\n return this.tsParseTypeAssertion();\n } else {\n return super.parseMaybeUnary(refExpressionErrors);\n }\n }\n\n parseArrow(node: N.ArrowFunctionExpression): ?N.ArrowFunctionExpression {\n if (this.match(tt.colon)) {\n // This is different from how the TS parser does it.\n // TS uses lookahead. The Babel Parser parses it as a parenthesized expression and converts.\n\n const result = this.tryParse(abort => {\n const returnType = this.tsParseTypeOrTypePredicateAnnotation(\n tt.colon,\n );\n if (this.canInsertSemicolon() || !this.match(tt.arrow)) abort();\n return returnType;\n });\n\n if (result.aborted) return;\n\n if (!result.thrown) {\n if (result.error) this.state = result.failState;\n node.returnType = result.node;\n }\n }\n\n return super.parseArrow(node);\n }\n\n // Allow type annotations inside of a parameter list.\n parseAssignableListItemTypes(param: N.Pattern) {\n if (this.eat(tt.question)) {\n if (param.type !== \"Identifier\") {\n this.raise(param.start, TSErrors.PatternIsOptional);\n }\n\n ((param: any): N.Identifier).optional = true;\n }\n const type = this.tsTryParseTypeAnnotation();\n if (type) param.typeAnnotation = type;\n this.resetEndLocation(param);\n\n return param;\n }\n\n toAssignable(node: N.Node): N.Node {\n switch (node.type) {\n case \"TSTypeCastExpression\":\n return super.toAssignable(this.typeCastToParameter(node));\n case \"TSParameterProperty\":\n return super.toAssignable(node);\n case \"TSAsExpression\":\n case \"TSNonNullExpression\":\n case \"TSTypeAssertion\":\n node.expression = this.toAssignable(node.expression);\n return node;\n default:\n return super.toAssignable(node);\n }\n }\n\n checkLVal(\n expr: N.Expression,\n bindingType: BindingTypes = BIND_NONE,\n checkClashes: ?{ [key: string]: boolean },\n contextDescription: string,\n ): void {\n switch (expr.type) {\n case \"TSTypeCastExpression\":\n // Allow \"typecasts\" to appear on the left of assignment expressions,\n // because it may be in an arrow function.\n // e.g. `const f = (foo: number = 0) => foo;`\n return;\n case \"TSParameterProperty\":\n this.checkLVal(\n expr.parameter,\n bindingType,\n checkClashes,\n \"parameter property\",\n );\n return;\n case \"TSAsExpression\":\n case \"TSNonNullExpression\":\n case \"TSTypeAssertion\":\n this.checkLVal(\n expr.expression,\n bindingType,\n checkClashes,\n contextDescription,\n );\n return;\n default:\n super.checkLVal(expr, bindingType, checkClashes, contextDescription);\n return;\n }\n }\n\n parseBindingAtom(): N.Pattern {\n switch (this.state.type) {\n case tt._this:\n // \"this\" may be the name of a parameter, so allow it.\n return this.parseIdentifier(/* liberal */ true);\n default:\n return super.parseBindingAtom();\n }\n }\n\n parseMaybeDecoratorArguments(expr: N.Expression): N.Expression {\n if (this.isRelational(\"<\")) {\n const typeArguments = this.tsParseTypeArguments();\n\n if (this.match(tt.parenL)) {\n const call = super.parseMaybeDecoratorArguments(expr);\n call.typeParameters = typeArguments;\n return call;\n }\n\n this.unexpected(this.state.start, tt.parenL);\n }\n\n return super.parseMaybeDecoratorArguments(expr);\n }\n\n // === === === === === === === === === === === === === === === ===\n // Note: All below methods are duplicates of something in flow.js.\n // Not sure what the best way to combine these is.\n // === === === === === === === === === === === === === === === ===\n\n isClassMethod(): boolean {\n return this.isRelational(\"<\") || super.isClassMethod();\n }\n\n isClassProperty(): boolean {\n return (\n this.match(tt.bang) || this.match(tt.colon) || super.isClassProperty()\n );\n }\n\n parseMaybeDefault(...args): N.Pattern {\n const node = super.parseMaybeDefault(...args);\n\n if (\n node.type === \"AssignmentPattern\" &&\n node.typeAnnotation &&\n node.right.start < node.typeAnnotation.start\n ) {\n this.raise(\n node.typeAnnotation.start,\n TSErrors.TypeAnnotationAfterAssign,\n );\n }\n\n return node;\n }\n\n // ensure that inside types, we bypass the jsx parser plugin\n getTokenFromCode(code: number): void {\n if (this.state.inType && (code === 62 || code === 60)) {\n return this.finishOp(tt.relational, 1);\n } else {\n return super.getTokenFromCode(code);\n }\n }\n\n toAssignableList(exprList: N.Expression[]): $ReadOnlyArray {\n for (let i = 0; i < exprList.length; i++) {\n const expr = exprList[i];\n if (!expr) continue;\n switch (expr.type) {\n case \"TSTypeCastExpression\":\n exprList[i] = this.typeCastToParameter(expr);\n break;\n case \"TSAsExpression\":\n case \"TSTypeAssertion\":\n if (!this.state.maybeInArrowParameters) {\n exprList[i] = this.typeCastToParameter(expr);\n } else {\n this.raise(expr.start, TSErrors.UnexpectedTypeCastInParameter);\n }\n break;\n }\n }\n return super.toAssignableList(...arguments);\n }\n\n typeCastToParameter(node: N.TsTypeCastExpression): N.Node {\n node.expression.typeAnnotation = node.typeAnnotation;\n\n this.resetEndLocation(\n node.expression,\n node.typeAnnotation.end,\n node.typeAnnotation.loc.end,\n );\n\n return node.expression;\n }\n\n toReferencedList(\n exprList: $ReadOnlyArray,\n isInParens?: boolean, // eslint-disable-line no-unused-vars\n ): $ReadOnlyArray {\n for (let i = 0; i < exprList.length; i++) {\n const expr = exprList[i];\n if (expr && expr.type === \"TSTypeCastExpression\") {\n this.raise(expr.start, TSErrors.UnexpectedTypeAnnotation);\n }\n }\n\n return exprList;\n }\n\n shouldParseArrow() {\n return this.match(tt.colon) || super.shouldParseArrow();\n }\n\n shouldParseAsyncArrow(): boolean {\n return this.match(tt.colon) || super.shouldParseAsyncArrow();\n }\n\n canHaveLeadingDecorator() {\n // Avoid unnecessary lookahead in checking for abstract class unless needed!\n return super.canHaveLeadingDecorator() || this.isAbstractClass();\n }\n\n jsxParseOpeningElementAfterName(\n node: N.JSXOpeningElement,\n ): N.JSXOpeningElement {\n if (this.isRelational(\"<\")) {\n const typeArguments = this.tsTryParseAndCatch(() =>\n this.tsParseTypeArguments(),\n );\n if (typeArguments) node.typeParameters = typeArguments;\n }\n return super.jsxParseOpeningElementAfterName(node);\n }\n\n getGetterSetterExpectedParamCount(\n method: N.ObjectMethod | N.ClassMethod,\n ): number {\n const baseCount = super.getGetterSetterExpectedParamCount(method);\n const firstParam = method.params[0];\n const hasContextParam =\n firstParam &&\n firstParam.type === \"Identifier\" &&\n firstParam.name === \"this\";\n\n return hasContextParam ? baseCount + 1 : baseCount;\n }\n };\n","// @flow\n\nimport * as charCodes from \"charcodes\";\n\nimport { types as tt, TokenType } from \"../tokenizer/types\";\nimport type Parser from \"../parser\";\nimport * as N from \"../types\";\n\ntt.placeholder = new TokenType(\"%%\", { startsExpr: true });\n\nexport type PlaceholderTypes =\n | \"Identifier\"\n | \"StringLiteral\"\n | \"Expression\"\n | \"Statement\"\n | \"Declaration\"\n | \"BlockStatement\"\n | \"ClassBody\"\n | \"Pattern\";\n\n// $PropertyType doesn't support enums. Use a fake \"switch\" (GetPlaceholderNode)\n//type MaybePlaceholder = $PropertyType | N.Placeholder;\n\ntype _Switch = $Call<\n (\n $ElementType<$ElementType, 0>,\n ) => $ElementType<$ElementType, 1>,\n Value,\n>;\ntype $Switch = _Switch;\n\ntype NodeOf = $Switch<\n T,\n [\n [\"Identifier\", N.Identifier],\n [\"StringLiteral\", N.StringLiteral],\n [\"Expression\", N.Expression],\n [\"Statement\", N.Statement],\n [\"Declaration\", N.Declaration],\n [\"BlockStatement\", N.BlockStatement],\n [\"ClassBody\", N.ClassBody],\n [\"Pattern\", N.Pattern],\n ],\n>;\n\n// Placeholder breaks everything, because its type is incompatible with\n// the substituted nodes.\ntype MaybePlaceholder = NodeOf; // | Placeholder\n\nexport default (superClass: Class): Class =>\n class extends superClass {\n parsePlaceholder(\n expectedNode: T,\n ): /*?N.Placeholder*/ ?MaybePlaceholder {\n if (this.match(tt.placeholder)) {\n const node = this.startNode();\n this.next();\n this.assertNoSpace(\"Unexpected space in placeholder.\");\n\n // We can't use this.parseIdentifier because\n // we don't want nested placeholders.\n node.name = super.parseIdentifier(/* liberal */ true);\n\n this.assertNoSpace(\"Unexpected space in placeholder.\");\n this.expect(tt.placeholder);\n return this.finishPlaceholder(node, expectedNode);\n }\n }\n\n finishPlaceholder(\n node: N.Node,\n expectedNode: T,\n ): /*N.Placeholder*/ MaybePlaceholder {\n const isFinished = !!(node.expectedNode && node.type === \"Placeholder\");\n node.expectedNode = expectedNode;\n\n return isFinished ? node : this.finishNode(node, \"Placeholder\");\n }\n\n /* ============================================================ *\n * tokenizer/index.js *\n * ============================================================ */\n\n getTokenFromCode(code: number) {\n if (\n code === charCodes.percentSign &&\n this.input.charCodeAt(this.state.pos + 1) === charCodes.percentSign\n ) {\n return this.finishOp(tt.placeholder, 2);\n }\n\n return super.getTokenFromCode(...arguments);\n }\n\n /* ============================================================ *\n * parser/expression.js *\n * ============================================================ */\n\n parseExprAtom(): MaybePlaceholder<\"Expression\"> {\n return (\n this.parsePlaceholder(\"Expression\") || super.parseExprAtom(...arguments)\n );\n }\n\n parseIdentifier(): MaybePlaceholder<\"Identifier\"> {\n // NOTE: This function only handles identifiers outside of\n // expressions and binding patterns, since they are already\n // handled by the parseExprAtom and parseBindingAtom functions.\n // This is needed, for example, to parse \"class %%NAME%% {}\".\n return (\n this.parsePlaceholder(\"Identifier\") ||\n super.parseIdentifier(...arguments)\n );\n }\n\n checkReservedWord(word: string): void {\n // Sometimes we call #checkReservedWord(node.name), expecting\n // that node is an Identifier. If it is a Placeholder, name\n // will be undefined.\n if (word !== undefined) super.checkReservedWord(...arguments);\n }\n\n /* ============================================================ *\n * parser/lval.js *\n * ============================================================ */\n\n parseBindingAtom(): MaybePlaceholder<\"Pattern\"> {\n return (\n this.parsePlaceholder(\"Pattern\") || super.parseBindingAtom(...arguments)\n );\n }\n\n checkLVal(expr: N.Expression): void {\n if (expr.type !== \"Placeholder\") super.checkLVal(...arguments);\n }\n\n toAssignable(node: N.Node): N.Node {\n if (\n node &&\n node.type === \"Placeholder\" &&\n node.expectedNode === \"Expression\"\n ) {\n node.expectedNode = \"Pattern\";\n return node;\n }\n return super.toAssignable(...arguments);\n }\n\n /* ============================================================ *\n * parser/statement.js *\n * ============================================================ */\n\n verifyBreakContinue(node: N.BreakStatement | N.ContinueStatement) {\n if (node.label && node.label.type === \"Placeholder\") return;\n super.verifyBreakContinue(...arguments);\n }\n\n parseExpressionStatement(\n node: MaybePlaceholder<\"Statement\">,\n expr: N.Expression,\n ): MaybePlaceholder<\"Statement\"> {\n if (\n expr.type !== \"Placeholder\" ||\n (expr.extra && expr.extra.parenthesized)\n ) {\n return super.parseExpressionStatement(...arguments);\n }\n\n if (this.match(tt.colon)) {\n const stmt: N.LabeledStatement = node;\n stmt.label = this.finishPlaceholder(expr, \"Identifier\");\n this.next();\n stmt.body = this.parseStatement(\"label\");\n return this.finishNode(stmt, \"LabeledStatement\");\n }\n\n this.semicolon();\n\n node.name = expr.name;\n return this.finishPlaceholder(node, \"Statement\");\n }\n\n parseBlock(): MaybePlaceholder<\"BlockStatement\"> {\n return (\n this.parsePlaceholder(\"BlockStatement\") ||\n super.parseBlock(...arguments)\n );\n }\n\n parseFunctionId(): ?MaybePlaceholder<\"Identifier\"> {\n return (\n this.parsePlaceholder(\"Identifier\") ||\n super.parseFunctionId(...arguments)\n );\n }\n\n parseClass(\n node: T,\n isStatement: /* T === ClassDeclaration */ boolean,\n optionalId?: boolean,\n ): T {\n const type = isStatement ? \"ClassDeclaration\" : \"ClassExpression\";\n\n this.next();\n this.takeDecorators(node);\n\n const placeholder = this.parsePlaceholder(\"Identifier\");\n if (placeholder) {\n if (\n this.match(tt._extends) ||\n this.match(tt.placeholder) ||\n this.match(tt.braceL)\n ) {\n node.id = placeholder;\n } else if (optionalId || !isStatement) {\n node.id = null;\n node.body = this.finishPlaceholder(placeholder, \"ClassBody\");\n return this.finishNode(node, type);\n } else {\n this.unexpected(null, \"A class name is required\");\n }\n } else {\n this.parseClassId(node, isStatement, optionalId);\n }\n\n this.parseClassSuper(node);\n node.body =\n this.parsePlaceholder(\"ClassBody\") ||\n this.parseClassBody(!!node.superClass);\n return this.finishNode(node, type);\n }\n\n parseExport(node: N.Node): N.Node {\n const placeholder = this.parsePlaceholder(\"Identifier\");\n if (!placeholder) return super.parseExport(...arguments);\n\n if (!this.isContextual(\"from\") && !this.match(tt.comma)) {\n // export %%DECL%%;\n node.specifiers = [];\n node.source = null;\n node.declaration = this.finishPlaceholder(placeholder, \"Declaration\");\n return this.finishNode(node, \"ExportNamedDeclaration\");\n }\n\n // export %%NAME%% from \"foo\";\n this.expectPlugin(\"exportDefaultFrom\");\n const specifier = this.startNode();\n specifier.exported = placeholder;\n node.specifiers = [this.finishNode(specifier, \"ExportDefaultSpecifier\")];\n\n return super.parseExport(node);\n }\n\n maybeParseExportDefaultSpecifier(node: N.Node): boolean {\n if (node.specifiers && node.specifiers.length > 0) {\n // \"export %%NAME%%\" has already been parsed by #parseExport.\n return true;\n }\n return super.maybeParseExportDefaultSpecifier(...arguments);\n }\n\n checkExport(node: N.ExportNamedDeclaration): void {\n const { specifiers } = node;\n if (specifiers && specifiers.length) {\n node.specifiers = specifiers.filter(\n node => node.exported.type === \"Placeholder\",\n );\n }\n super.checkExport(node);\n node.specifiers = specifiers;\n }\n\n parseImport(\n node: N.Node,\n ): N.ImportDeclaration | N.TsImportEqualsDeclaration {\n const placeholder = this.parsePlaceholder(\"Identifier\");\n if (!placeholder) return super.parseImport(...arguments);\n\n node.specifiers = [];\n\n if (!this.isContextual(\"from\") && !this.match(tt.comma)) {\n // import %%STRING%%;\n node.source = this.finishPlaceholder(placeholder, \"StringLiteral\");\n this.semicolon();\n return this.finishNode(node, \"ImportDeclaration\");\n }\n\n // import %%DEFAULT%% ...\n const specifier = this.startNodeAtNode(placeholder);\n specifier.local = placeholder;\n this.finishNode(specifier, \"ImportDefaultSpecifier\");\n node.specifiers.push(specifier);\n\n if (this.eat(tt.comma)) {\n // import %%DEFAULT%%, * as ...\n const hasStarImport = this.maybeParseStarImportSpecifier(node);\n\n // import %%DEFAULT%%, { ...\n if (!hasStarImport) this.parseNamedImportSpecifiers(node);\n }\n\n this.expectContextual(\"from\");\n node.source = this.parseImportSource();\n this.semicolon();\n return this.finishNode(node, \"ImportDeclaration\");\n }\n\n parseImportSource(): MaybePlaceholder<\"StringLiteral\"> {\n // import ... from %%STRING%%;\n\n return (\n this.parsePlaceholder(\"StringLiteral\") ||\n super.parseImportSource(...arguments)\n );\n }\n };\n","import type Parser from \"../parser\";\nimport { types as tt } from \"../tokenizer/types\";\nimport * as N from \"../types\";\n\nexport default (superClass: Class): Class =>\n class extends superClass {\n parseV8Intrinsic(): N.Expression {\n if (this.match(tt.modulo)) {\n const v8IntrinsicStart = this.state.start;\n // let the `loc` of Identifier starts from `%`\n const node = this.startNode();\n this.eat(tt.modulo);\n if (this.match(tt.name)) {\n const name = this.parseIdentifierName(this.state.start);\n const identifier = this.createIdentifier(node, name);\n identifier.type = \"V8IntrinsicIdentifier\";\n if (this.match(tt.parenL)) {\n return identifier;\n }\n }\n this.unexpected(v8IntrinsicStart);\n }\n }\n\n /* ============================================================ *\n * parser/expression.js *\n * ============================================================ */\n\n parseExprAtom(): N.Expression {\n return this.parseV8Intrinsic() || super.parseExprAtom(...arguments);\n }\n };\n","// @flow\n\nimport type Parser from \"./parser\";\n\nexport type Plugin = string | [string, Object];\n\nexport type PluginList = $ReadOnlyArray;\n\nexport type MixinPlugin = (superClass: Class) => Class;\n\nexport function hasPlugin(plugins: PluginList, name: string): boolean {\n return plugins.some(plugin => {\n if (Array.isArray(plugin)) {\n return plugin[0] === name;\n } else {\n return plugin === name;\n }\n });\n}\n\nexport function getPluginOption(\n plugins: PluginList,\n name: string,\n option: string,\n) {\n const plugin = plugins.find(plugin => {\n if (Array.isArray(plugin)) {\n return plugin[0] === name;\n } else {\n return plugin === name;\n }\n });\n\n if (plugin && Array.isArray(plugin)) {\n return plugin[1][option];\n }\n\n return null;\n}\n\nconst PIPELINE_PROPOSALS = [\"minimal\", \"smart\", \"fsharp\"];\nconst RECORD_AND_TUPLE_SYNTAX_TYPES = [\"hash\", \"bar\"];\n\nexport function validatePlugins(plugins: PluginList) {\n if (hasPlugin(plugins, \"decorators\")) {\n if (hasPlugin(plugins, \"decorators-legacy\")) {\n throw new Error(\n \"Cannot use the decorators and decorators-legacy plugin together\",\n );\n }\n\n const decoratorsBeforeExport = getPluginOption(\n plugins,\n \"decorators\",\n \"decoratorsBeforeExport\",\n );\n if (decoratorsBeforeExport == null) {\n throw new Error(\n \"The 'decorators' plugin requires a 'decoratorsBeforeExport' option,\" +\n \" whose value must be a boolean. If you are migrating from\" +\n \" Babylon/Babel 6 or want to use the old decorators proposal, you\" +\n \" should use the 'decorators-legacy' plugin instead of 'decorators'.\",\n );\n } else if (typeof decoratorsBeforeExport !== \"boolean\") {\n throw new Error(\"'decoratorsBeforeExport' must be a boolean.\");\n }\n }\n\n if (hasPlugin(plugins, \"flow\") && hasPlugin(plugins, \"typescript\")) {\n throw new Error(\"Cannot combine flow and typescript plugins.\");\n }\n\n if (hasPlugin(plugins, \"placeholders\") && hasPlugin(plugins, \"v8intrinsic\")) {\n throw new Error(\"Cannot combine placeholders and v8intrinsic plugins.\");\n }\n\n if (\n hasPlugin(plugins, \"pipelineOperator\") &&\n !PIPELINE_PROPOSALS.includes(\n getPluginOption(plugins, \"pipelineOperator\", \"proposal\"),\n )\n ) {\n throw new Error(\n \"'pipelineOperator' requires 'proposal' option whose value should be one of: \" +\n PIPELINE_PROPOSALS.map(p => `'${p}'`).join(\", \"),\n );\n }\n\n if (\n hasPlugin(plugins, \"recordAndTuple\") &&\n !RECORD_AND_TUPLE_SYNTAX_TYPES.includes(\n getPluginOption(plugins, \"recordAndTuple\", \"syntaxType\"),\n )\n ) {\n throw new Error(\n \"'recordAndTuple' requires 'syntaxType' option whose value should be one of: \" +\n RECORD_AND_TUPLE_SYNTAX_TYPES.map(p => `'${p}'`).join(\", \"),\n );\n }\n}\n\n// These plugins are defined using a mixin which extends the parser class.\n\nimport estree from \"./plugins/estree\";\nimport flow from \"./plugins/flow\";\nimport jsx from \"./plugins/jsx\";\nimport typescript from \"./plugins/typescript\";\nimport placeholders from \"./plugins/placeholders\";\nimport v8intrinsic from \"./plugins/v8intrinsic\";\n\n// NOTE: order is important. estree must come first; placeholders must come last.\nexport const mixinPlugins: { [name: string]: MixinPlugin } = {\n estree,\n jsx,\n flow,\n typescript,\n v8intrinsic,\n placeholders,\n};\n\nexport const mixinPluginNames: $ReadOnlyArray = Object.keys(\n mixinPlugins,\n);\n","// @flow\n\nimport type { PluginList } from \"./plugin-utils\";\n\n// A second optional argument can be given to further configure\n// the parser process. These options are recognized:\n\nexport type SourceType = \"script\" | \"module\" | \"unambiguous\";\n\nexport type Options = {\n sourceType: SourceType,\n sourceFilename?: string,\n startLine: number,\n allowAwaitOutsideFunction: boolean,\n allowReturnOutsideFunction: boolean,\n allowImportExportEverywhere: boolean,\n allowSuperOutsideMethod: boolean,\n allowUndeclaredExports: boolean,\n plugins: PluginList,\n strictMode: ?boolean,\n ranges: boolean,\n tokens: boolean,\n createParenthesizedExpressions: boolean,\n errorRecovery: boolean,\n};\n\nexport const defaultOptions: Options = {\n // Source type (\"script\" or \"module\") for different semantics\n sourceType: \"script\",\n // Source filename.\n sourceFilename: undefined,\n // Line from which to start counting source. Useful for\n // integration with other tools.\n startLine: 1,\n // When enabled, await at the top level is not considered an\n // error.\n allowAwaitOutsideFunction: false,\n // When enabled, a return at the top level is not considered an\n // error.\n allowReturnOutsideFunction: false,\n // When enabled, import/export statements are not constrained to\n // appearing at the top of the program.\n allowImportExportEverywhere: false,\n // TODO\n allowSuperOutsideMethod: false,\n // When enabled, export statements can reference undeclared variables.\n allowUndeclaredExports: false,\n // An array of plugins to enable\n plugins: [],\n // TODO\n strictMode: null,\n // Nodes have their start and end characters offsets recorded in\n // `start` and `end` properties (directly on the node, rather than\n // the `loc` object, which holds line/column data. To also add a\n // [semi-standardized][range] `range` property holding a `[start,\n // end]` array with the same numbers, set the `ranges` option to\n // `true`.\n //\n // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678\n ranges: false,\n // Adds all parsed tokens to a `tokens` property on the `File` node\n tokens: false,\n // Whether to create ParenthesizedExpression AST nodes (if false\n // the parser sets extra.parenthesized on the expression nodes instead).\n createParenthesizedExpressions: false,\n // When enabled, errors are attached to the AST instead of being directly thrown.\n // Some errors will still throw, because @babel/parser can't always recover.\n errorRecovery: false,\n};\n\n// Interpret and default an options object\n\nexport function getOptions(opts: ?Options): Options {\n const options: any = {};\n for (const key of Object.keys(defaultOptions)) {\n options[key] = opts && opts[key] != null ? opts[key] : defaultOptions[key];\n }\n return options;\n}\n","// @flow\n\nimport type { Options } from \"../options\";\nimport * as N from \"../types\";\nimport { Position } from \"../util/location\";\n\nimport { types as ct, type TokContext } from \"./context\";\nimport { types as tt, type TokenType } from \"./types\";\n\ntype TopicContextState = {\n // When a topic binding has been currently established,\n // then this is 1. Otherwise, it is 0. This is forwards compatible\n // with a future plugin for multiple lexical topics.\n maxNumOfResolvableTopics: number,\n\n // When a topic binding has been currently established, and if that binding\n // has been used as a topic reference `#`, then this is 0. Otherwise, it is\n // `null`. This is forwards compatible with a future plugin for multiple\n // lexical topics.\n maxTopicIndex: null | 0,\n};\n\nexport default class State {\n strict: boolean;\n curLine: number;\n\n // And, if locations are used, the {line, column} object\n // corresponding to those offsets\n startLoc: Position;\n endLoc: Position;\n\n init(options: Options): void {\n this.strict =\n options.strictMode === false ? false : options.sourceType === \"module\";\n\n this.curLine = options.startLine;\n this.startLoc = this.endLoc = this.curPosition();\n }\n\n errors: SyntaxError[] = [];\n\n // Used to signify the start of a potential arrow function\n potentialArrowAt: number = -1;\n\n // Used to signify the start of an expression which looks like a\n // typed arrow function, but it isn't\n // e.g. a ? (b) : c => d\n // ^\n noArrowAt: number[] = [];\n\n // Used to signify the start of an expression whose params, if it looks like\n // an arrow function, shouldn't be converted to assignable nodes.\n // This is used to defer the validation of typed arrow functions inside\n // conditional expressions.\n // e.g. a ? (b) : c => d\n // ^\n noArrowParamsConversionAt: number[] = [];\n\n // Flags to track\n inParameters: boolean = false;\n maybeInArrowParameters: boolean = false;\n // This flag is used to track async arrow head across function declarations.\n // e.g. async (foo = function (await) {}) => {}\n // When parsing `await` in this expression, `maybeInAsyncArrowHead` is true\n // but `maybeInArrowParameters` is false\n maybeInAsyncArrowHead: boolean = false;\n inPipeline: boolean = false;\n inType: boolean = false;\n noAnonFunctionType: boolean = false;\n inPropertyName: boolean = false;\n hasFlowComment: boolean = false;\n isIterator: boolean = false;\n\n // For the smartPipelines plugin:\n topicContext: TopicContextState = {\n maxNumOfResolvableTopics: 0,\n maxTopicIndex: null,\n };\n\n // For the F# plugin\n soloAwait: boolean = false;\n inFSharpPipelineDirectBody: boolean = false;\n\n // Labels in scope.\n labels: Array<{\n kind: ?(\"loop\" | \"switch\"),\n name?: ?string,\n statementStart?: number,\n }> = [];\n\n // Leading decorators. Last element of the stack represents the decorators in current context.\n // Supports nesting of decorators, e.g. @foo(@bar class inner {}) class outer {}\n // where @foo belongs to the outer class and @bar to the inner\n decoratorStack: Array> = [[]];\n\n // Positions to delayed-check that yield/await does not exist in default parameters.\n yieldPos: number = -1;\n awaitPos: number = -1;\n\n // Comment store.\n comments: Array = [];\n\n // Comment attachment store\n trailingComments: Array = [];\n leadingComments: Array = [];\n commentStack: Array<{\n start: number,\n leadingComments: ?Array,\n trailingComments: ?Array,\n type: string,\n }> = [];\n // $FlowIgnore this is initialized when the parser starts.\n commentPreviousNode: N.Node = null;\n\n // The current position of the tokenizer in the input.\n pos: number = 0;\n lineStart: number = 0;\n\n // Properties of the current token:\n // Its type\n type: TokenType = tt.eof;\n\n // For tokens that include more information than their type, the value\n value: any = null;\n\n // Its start and end offset\n start: number = 0;\n end: number = 0;\n\n // Position information for the previous token\n // $FlowIgnore this is initialized when generating the second token.\n lastTokEndLoc: Position = null;\n // $FlowIgnore this is initialized when generating the second token.\n lastTokStartLoc: Position = null;\n lastTokStart: number = 0;\n lastTokEnd: number = 0;\n\n // The context stack is used to superficially track syntactic\n // context to predict whether a regular expression is allowed in a\n // given position.\n context: Array = [ct.braceStatement];\n exprAllowed: boolean = true;\n\n // Used to signal to callers of `readWord1` whether the word\n // contained any escape sequences. This is needed because words with\n // escape sequences must not be interpreted as keywords.\n containsEsc: boolean = false;\n\n // This property is used to throw an error for\n // an octal literal in a directive that occurs prior\n // to a \"use strict\" directive.\n octalPositions: number[] = [];\n\n // Names of exports store. `default` is stored as a name for both\n // `export default foo;` and `export { foo as default };`.\n exportedIdentifiers: Array = [];\n\n // Tokens length in token store\n tokensLength: number = 0;\n\n curPosition(): Position {\n return new Position(this.curLine, this.pos - this.lineStart);\n }\n\n clone(skipArrays?: boolean): State {\n const state = new State();\n const keys = Object.keys(this);\n for (let i = 0, length = keys.length; i < length; i++) {\n const key = keys[i];\n // $FlowIgnore\n let val = this[key];\n\n if (!skipArrays && Array.isArray(val)) {\n val = val.slice();\n }\n\n // $FlowIgnore\n state[key] = val;\n }\n\n return state;\n }\n}\n","// @flow\n\nimport type { Options } from \"../options\";\nimport * as N from \"../types\";\nimport type { Position } from \"../util/location\";\nimport * as charCodes from \"charcodes\";\nimport { isIdentifierStart, isIdentifierChar } from \"../util/identifier\";\nimport { types as tt, keywords as keywordTypes, type TokenType } from \"./types\";\nimport { type TokContext, types as ct } from \"./context\";\nimport LocationParser, { Errors } from \"../parser/location\";\nimport { SourceLocation } from \"../util/location\";\nimport {\n lineBreak,\n lineBreakG,\n isNewLine,\n isWhitespace,\n skipWhiteSpace,\n} from \"../util/whitespace\";\nimport State from \"./state\";\n\nconst VALID_REGEX_FLAGS = new Set([\"g\", \"m\", \"s\", \"i\", \"y\", \"u\"]);\n\n// The following character codes are forbidden from being\n// an immediate sibling of NumericLiteralSeparator _\n\nconst forbiddenNumericSeparatorSiblings = {\n decBinOct: [\n charCodes.dot,\n charCodes.uppercaseB,\n charCodes.uppercaseE,\n charCodes.uppercaseO,\n charCodes.underscore, // multiple separators are not allowed\n charCodes.lowercaseB,\n charCodes.lowercaseE,\n charCodes.lowercaseO,\n ],\n hex: [\n charCodes.dot,\n charCodes.uppercaseX,\n charCodes.underscore, // multiple separators are not allowed\n charCodes.lowercaseX,\n ],\n};\n\nconst allowedNumericSeparatorSiblings = {};\nallowedNumericSeparatorSiblings.bin = [\n // 0 - 1\n charCodes.digit0,\n charCodes.digit1,\n];\nallowedNumericSeparatorSiblings.oct = [\n // 0 - 7\n ...allowedNumericSeparatorSiblings.bin,\n\n charCodes.digit2,\n charCodes.digit3,\n charCodes.digit4,\n charCodes.digit5,\n charCodes.digit6,\n charCodes.digit7,\n];\nallowedNumericSeparatorSiblings.dec = [\n // 0 - 9\n ...allowedNumericSeparatorSiblings.oct,\n\n charCodes.digit8,\n charCodes.digit9,\n];\n\nallowedNumericSeparatorSiblings.hex = [\n // 0 - 9, A - F, a - f,\n ...allowedNumericSeparatorSiblings.dec,\n\n charCodes.uppercaseA,\n charCodes.uppercaseB,\n charCodes.uppercaseC,\n charCodes.uppercaseD,\n charCodes.uppercaseE,\n charCodes.uppercaseF,\n\n charCodes.lowercaseA,\n charCodes.lowercaseB,\n charCodes.lowercaseC,\n charCodes.lowercaseD,\n charCodes.lowercaseE,\n charCodes.lowercaseF,\n];\n\n// Object type used to represent tokens. Note that normally, tokens\n// simply exist as properties on the parser object. This is only\n// used for the onToken callback and the external tokenizer.\n\nexport class Token {\n constructor(state: State) {\n this.type = state.type;\n this.value = state.value;\n this.start = state.start;\n this.end = state.end;\n this.loc = new SourceLocation(state.startLoc, state.endLoc);\n }\n\n type: TokenType;\n value: any;\n start: number;\n end: number;\n loc: SourceLocation;\n}\n\n// ## Tokenizer\n\nexport default class Tokenizer extends LocationParser {\n // Forward-declarations\n // parser/util.js\n /*::\n +unexpected: (pos?: ?number, messageOrType?: string | TokenType) => empty;\n */\n\n isLookahead: boolean;\n\n // Token store.\n tokens: Array = [];\n\n constructor(options: Options, input: string) {\n super();\n this.state = new State();\n this.state.init(options);\n this.input = input;\n this.length = input.length;\n this.isLookahead = false;\n }\n\n pushToken(token: Token | N.Comment) {\n // Pop out invalid tokens trapped by try-catch parsing.\n // Those parsing branches are mainly created by typescript and flow plugins.\n this.tokens.length = this.state.tokensLength;\n this.tokens.push(token);\n ++this.state.tokensLength;\n }\n\n // Move to the next token\n\n next(): void {\n if (!this.isLookahead) {\n this.checkKeywordEscapes();\n if (this.options.tokens) {\n this.pushToken(new Token(this.state));\n }\n }\n\n this.state.lastTokEnd = this.state.end;\n this.state.lastTokStart = this.state.start;\n this.state.lastTokEndLoc = this.state.endLoc;\n this.state.lastTokStartLoc = this.state.startLoc;\n this.nextToken();\n }\n\n // TODO\n\n eat(type: TokenType): boolean {\n if (this.match(type)) {\n this.next();\n return true;\n } else {\n return false;\n }\n }\n\n // TODO\n\n match(type: TokenType): boolean {\n return this.state.type === type;\n }\n\n // TODO\n\n lookahead(): State {\n const old = this.state;\n this.state = old.clone(true);\n\n this.isLookahead = true;\n this.next();\n this.isLookahead = false;\n\n const curr = this.state;\n this.state = old;\n return curr;\n }\n\n nextTokenStart(): number {\n const thisTokEnd = this.state.pos;\n skipWhiteSpace.lastIndex = thisTokEnd;\n const skip = skipWhiteSpace.exec(this.input);\n // $FlowIgnore: The skipWhiteSpace ensures to match any string\n return thisTokEnd + skip[0].length;\n }\n\n lookaheadCharCode(): number {\n return this.input.charCodeAt(this.nextTokenStart());\n }\n\n // Toggle strict mode. Re-reads the next number or string to please\n // pedantic tests (`\"use strict\"; 010;` should fail).\n\n setStrict(strict: boolean): void {\n this.state.strict = strict;\n if (!this.match(tt.num) && !this.match(tt.string)) return;\n this.state.pos = this.state.start;\n while (this.state.pos < this.state.lineStart) {\n this.state.lineStart =\n this.input.lastIndexOf(\"\\n\", this.state.lineStart - 2) + 1;\n --this.state.curLine;\n }\n this.nextToken();\n }\n\n curContext(): TokContext {\n return this.state.context[this.state.context.length - 1];\n }\n\n // Read a single token, updating the parser object's token-related\n // properties.\n\n nextToken(): void {\n const curContext = this.curContext();\n if (!curContext || !curContext.preserveSpace) this.skipSpace();\n\n this.state.octalPositions = [];\n this.state.start = this.state.pos;\n this.state.startLoc = this.state.curPosition();\n if (this.state.pos >= this.length) {\n this.finishToken(tt.eof);\n return;\n }\n\n const override = curContext?.override;\n if (override) {\n override(this);\n } else {\n this.getTokenFromCode(this.input.codePointAt(this.state.pos));\n }\n }\n\n pushComment(\n block: boolean,\n text: string,\n start: number,\n end: number,\n startLoc: Position,\n endLoc: Position,\n ): void {\n const comment = {\n type: block ? \"CommentBlock\" : \"CommentLine\",\n value: text,\n start: start,\n end: end,\n loc: new SourceLocation(startLoc, endLoc),\n };\n\n if (this.options.tokens) this.pushToken(comment);\n this.state.comments.push(comment);\n this.addComment(comment);\n }\n\n skipBlockComment(): void {\n const startLoc = this.state.curPosition();\n const start = this.state.pos;\n const end = this.input.indexOf(\"*/\", this.state.pos + 2);\n if (end === -1) throw this.raise(start, Errors.UnterminatedComment);\n\n this.state.pos = end + 2;\n lineBreakG.lastIndex = start;\n let match;\n while (\n (match = lineBreakG.exec(this.input)) &&\n match.index < this.state.pos\n ) {\n ++this.state.curLine;\n this.state.lineStart = match.index + match[0].length;\n }\n\n // If we are doing a lookahead right now we need to advance the position (above code)\n // but we do not want to push the comment to the state.\n if (this.isLookahead) return;\n\n this.pushComment(\n true,\n this.input.slice(start + 2, end),\n start,\n this.state.pos,\n startLoc,\n this.state.curPosition(),\n );\n }\n\n skipLineComment(startSkip: number): void {\n const start = this.state.pos;\n const startLoc = this.state.curPosition();\n let ch = this.input.charCodeAt((this.state.pos += startSkip));\n if (this.state.pos < this.length) {\n while (!isNewLine(ch) && ++this.state.pos < this.length) {\n ch = this.input.charCodeAt(this.state.pos);\n }\n }\n\n // If we are doing a lookahead right now we need to advance the position (above code)\n // but we do not want to push the comment to the state.\n if (this.isLookahead) return;\n\n this.pushComment(\n false,\n this.input.slice(start + startSkip, this.state.pos),\n start,\n this.state.pos,\n startLoc,\n this.state.curPosition(),\n );\n }\n\n // Called at the start of the parse and after every token. Skips\n // whitespace and comments, and.\n\n skipSpace(): void {\n loop: while (this.state.pos < this.length) {\n const ch = this.input.charCodeAt(this.state.pos);\n switch (ch) {\n case charCodes.space:\n case charCodes.nonBreakingSpace:\n case charCodes.tab:\n ++this.state.pos;\n break;\n case charCodes.carriageReturn:\n if (\n this.input.charCodeAt(this.state.pos + 1) === charCodes.lineFeed\n ) {\n ++this.state.pos;\n }\n // fall through\n case charCodes.lineFeed:\n case charCodes.lineSeparator:\n case charCodes.paragraphSeparator:\n ++this.state.pos;\n ++this.state.curLine;\n this.state.lineStart = this.state.pos;\n break;\n\n case charCodes.slash:\n switch (this.input.charCodeAt(this.state.pos + 1)) {\n case charCodes.asterisk:\n this.skipBlockComment();\n break;\n\n case charCodes.slash:\n this.skipLineComment(2);\n break;\n\n default:\n break loop;\n }\n break;\n\n default:\n if (isWhitespace(ch)) {\n ++this.state.pos;\n } else {\n break loop;\n }\n }\n }\n }\n\n // Called at the end of every token. Sets `end`, `val`, and\n // maintains `context` and `exprAllowed`, and skips the space after\n // the token, so that the next one's `start` will point at the\n // right position.\n\n finishToken(type: TokenType, val: any): void {\n this.state.end = this.state.pos;\n this.state.endLoc = this.state.curPosition();\n const prevType = this.state.type;\n this.state.type = type;\n this.state.value = val;\n\n if (!this.isLookahead) this.updateContext(prevType);\n }\n\n // ### Token reading\n\n // This is the function that is called to fetch the next token. It\n // is somewhat obscure, because it works in character codes rather\n // than characters, and because operator parsing has been inlined\n // into it.\n //\n // All in the name of speed.\n\n // number sign is \"#\"\n readToken_numberSign(): void {\n if (this.state.pos === 0 && this.readToken_interpreter()) {\n return;\n }\n\n const nextPos = this.state.pos + 1;\n const next = this.input.charCodeAt(nextPos);\n if (next >= charCodes.digit0 && next <= charCodes.digit9) {\n throw this.raise(this.state.pos, Errors.UnexpectedDigitAfterHash);\n }\n\n if (\n this.hasPlugin(\"recordAndTuple\") &&\n (next === charCodes.leftCurlyBrace ||\n next === charCodes.leftSquareBracket)\n ) {\n if (this.getPluginOption(\"recordAndTuple\", \"syntaxType\") !== \"hash\") {\n throw this.raise(\n this.state.pos,\n next === charCodes.leftCurlyBrace\n ? Errors.RecordExpressionHashIncorrectStartSyntaxType\n : Errors.TupleExpressionHashIncorrectStartSyntaxType,\n );\n }\n\n if (next === charCodes.leftCurlyBrace) {\n // #{\n this.finishToken(tt.braceHashL);\n } else {\n // #[\n this.finishToken(tt.bracketHashL);\n }\n this.state.pos += 2;\n } else if (\n this.hasPlugin(\"classPrivateProperties\") ||\n this.hasPlugin(\"classPrivateMethods\") ||\n this.getPluginOption(\"pipelineOperator\", \"proposal\") === \"smart\"\n ) {\n this.finishOp(tt.hash, 1);\n } else {\n throw this.raise(this.state.pos, Errors.InvalidOrUnexpectedToken, \"#\");\n }\n }\n\n readToken_dot(): void {\n const next = this.input.charCodeAt(this.state.pos + 1);\n if (next >= charCodes.digit0 && next <= charCodes.digit9) {\n this.readNumber(true);\n return;\n }\n\n if (\n next === charCodes.dot &&\n this.input.charCodeAt(this.state.pos + 2) === charCodes.dot\n ) {\n this.state.pos += 3;\n this.finishToken(tt.ellipsis);\n } else {\n ++this.state.pos;\n this.finishToken(tt.dot);\n }\n }\n\n readToken_slash(): void {\n // '/'\n if (this.state.exprAllowed && !this.state.inType) {\n ++this.state.pos;\n this.readRegexp();\n return;\n }\n\n const next = this.input.charCodeAt(this.state.pos + 1);\n if (next === charCodes.equalsTo) {\n this.finishOp(tt.assign, 2);\n } else {\n this.finishOp(tt.slash, 1);\n }\n }\n\n readToken_interpreter(): boolean {\n if (this.state.pos !== 0 || this.length < 2) return false;\n\n let ch = this.input.charCodeAt(this.state.pos + 1);\n if (ch !== charCodes.exclamationMark) return false;\n\n const start = this.state.pos;\n this.state.pos += 1;\n\n while (!isNewLine(ch) && ++this.state.pos < this.length) {\n ch = this.input.charCodeAt(this.state.pos);\n }\n\n const value = this.input.slice(start + 2, this.state.pos);\n\n this.finishToken(tt.interpreterDirective, value);\n\n return true;\n }\n\n readToken_mult_modulo(code: number): void {\n // '%*'\n let type = code === charCodes.asterisk ? tt.star : tt.modulo;\n let width = 1;\n let next = this.input.charCodeAt(this.state.pos + 1);\n const exprAllowed = this.state.exprAllowed;\n\n // Exponentiation operator **\n if (code === charCodes.asterisk && next === charCodes.asterisk) {\n width++;\n next = this.input.charCodeAt(this.state.pos + 2);\n type = tt.exponent;\n }\n\n if (next === charCodes.equalsTo && !exprAllowed) {\n width++;\n type = tt.assign;\n }\n\n this.finishOp(type, width);\n }\n\n readToken_pipe_amp(code: number): void {\n // '||' '&&' '||=' '&&='\n const next = this.input.charCodeAt(this.state.pos + 1);\n\n if (next === code) {\n if (this.input.charCodeAt(this.state.pos + 2) === charCodes.equalsTo) {\n this.finishOp(tt.assign, 3);\n } else {\n this.finishOp(\n code === charCodes.verticalBar ? tt.logicalOR : tt.logicalAND,\n 2,\n );\n }\n return;\n }\n\n if (code === charCodes.verticalBar) {\n // '|>'\n if (next === charCodes.greaterThan) {\n this.finishOp(tt.pipeline, 2);\n return;\n }\n // '|}'\n if (\n this.hasPlugin(\"recordAndTuple\") &&\n next === charCodes.rightCurlyBrace\n ) {\n if (this.getPluginOption(\"recordAndTuple\", \"syntaxType\") !== \"bar\") {\n throw this.raise(\n this.state.pos,\n Errors.RecordExpressionBarIncorrectEndSyntaxType,\n );\n }\n\n this.finishOp(tt.braceBarR, 2);\n return;\n }\n\n // '|]'\n if (\n this.hasPlugin(\"recordAndTuple\") &&\n next === charCodes.rightSquareBracket\n ) {\n if (this.getPluginOption(\"recordAndTuple\", \"syntaxType\") !== \"bar\") {\n throw this.raise(\n this.state.pos,\n Errors.TupleExpressionBarIncorrectEndSyntaxType,\n );\n }\n\n this.finishOp(tt.bracketBarR, 2);\n return;\n }\n }\n\n if (next === charCodes.equalsTo) {\n this.finishOp(tt.assign, 2);\n return;\n }\n\n this.finishOp(\n code === charCodes.verticalBar ? tt.bitwiseOR : tt.bitwiseAND,\n 1,\n );\n }\n\n readToken_caret(): void {\n // '^'\n const next = this.input.charCodeAt(this.state.pos + 1);\n if (next === charCodes.equalsTo) {\n this.finishOp(tt.assign, 2);\n } else {\n this.finishOp(tt.bitwiseXOR, 1);\n }\n }\n\n readToken_plus_min(code: number): void {\n // '+-'\n const next = this.input.charCodeAt(this.state.pos + 1);\n\n if (next === code) {\n if (\n next === charCodes.dash &&\n !this.inModule &&\n this.input.charCodeAt(this.state.pos + 2) === charCodes.greaterThan &&\n (this.state.lastTokEnd === 0 ||\n lineBreak.test(\n this.input.slice(this.state.lastTokEnd, this.state.pos),\n ))\n ) {\n // A `-->` line comment\n this.skipLineComment(3);\n this.skipSpace();\n this.nextToken();\n return;\n }\n this.finishOp(tt.incDec, 2);\n return;\n }\n\n if (next === charCodes.equalsTo) {\n this.finishOp(tt.assign, 2);\n } else {\n this.finishOp(tt.plusMin, 1);\n }\n }\n\n readToken_lt_gt(code: number): void {\n // '<>'\n const next = this.input.charCodeAt(this.state.pos + 1);\n let size = 1;\n\n if (next === code) {\n size =\n code === charCodes.greaterThan &&\n this.input.charCodeAt(this.state.pos + 2) === charCodes.greaterThan\n ? 3\n : 2;\n if (this.input.charCodeAt(this.state.pos + size) === charCodes.equalsTo) {\n this.finishOp(tt.assign, size + 1);\n return;\n }\n this.finishOp(tt.bitShift, size);\n return;\n }\n\n if (\n next === charCodes.exclamationMark &&\n code === charCodes.lessThan &&\n !this.inModule &&\n this.input.charCodeAt(this.state.pos + 2) === charCodes.dash &&\n this.input.charCodeAt(this.state.pos + 3) === charCodes.dash\n ) {\n // ` * (any, kinda silly) -// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0 -// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0 -// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0 -// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0 -// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0 -function replaceTildes (comp, options) { - return comp.trim().split(/\s+/).map(function (comp) { - return replaceTilde(comp, options) - }).join(' ') -} - -function replaceTilde (comp, options) { - var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE] - return comp.replace(r, function (_, M, m, p, pr) { - debug('tilde', comp, _, M, m, p, pr) - var ret - - if (isX(M)) { - ret = '' - } else if (isX(m)) { - ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0' - } else if (isX(p)) { - // ~1.2 == >=1.2.0 <1.3.0 - ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0' - } else if (pr) { - debug('replaceTilde pr', pr) - ret = '>=' + M + '.' + m + '.' + p + '-' + pr + - ' <' + M + '.' + (+m + 1) + '.0' - } else { - // ~1.2.3 == >=1.2.3 <1.3.0 - ret = '>=' + M + '.' + m + '.' + p + - ' <' + M + '.' + (+m + 1) + '.0' - } - - debug('tilde return', ret) - return ret - }) -} - -// ^ --> * (any, kinda silly) -// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0 -// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0 -// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0 -// ^1.2.3 --> >=1.2.3 <2.0.0 -// ^1.2.0 --> >=1.2.0 <2.0.0 -function replaceCarets (comp, options) { - return comp.trim().split(/\s+/).map(function (comp) { - return replaceCaret(comp, options) - }).join(' ') -} - -function replaceCaret (comp, options) { - debug('caret', comp, options) - var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET] - return comp.replace(r, function (_, M, m, p, pr) { - debug('caret', comp, _, M, m, p, pr) - var ret - - if (isX(M)) { - ret = '' - } else if (isX(m)) { - ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0' - } else if (isX(p)) { - if (M === '0') { - ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0' - } else { - ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0' - } - } else if (pr) { - debug('replaceCaret pr', pr) - if (M === '0') { - if (m === '0') { - ret = '>=' + M + '.' + m + '.' + p + '-' + pr + - ' <' + M + '.' + m + '.' + (+p + 1) - } else { - ret = '>=' + M + '.' + m + '.' + p + '-' + pr + - ' <' + M + '.' + (+m + 1) + '.0' - } - } else { - ret = '>=' + M + '.' + m + '.' + p + '-' + pr + - ' <' + (+M + 1) + '.0.0' - } - } else { - debug('no pr') - if (M === '0') { - if (m === '0') { - ret = '>=' + M + '.' + m + '.' + p + - ' <' + M + '.' + m + '.' + (+p + 1) - } else { - ret = '>=' + M + '.' + m + '.' + p + - ' <' + M + '.' + (+m + 1) + '.0' - } - } else { - ret = '>=' + M + '.' + m + '.' + p + - ' <' + (+M + 1) + '.0.0' - } - } - - debug('caret return', ret) - return ret - }) -} - -function replaceXRanges (comp, options) { - debug('replaceXRanges', comp, options) - return comp.split(/\s+/).map(function (comp) { - return replaceXRange(comp, options) - }).join(' ') -} - -function replaceXRange (comp, options) { - comp = comp.trim() - var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE] - return comp.replace(r, function (ret, gtlt, M, m, p, pr) { - debug('xRange', comp, ret, gtlt, M, m, p, pr) - var xM = isX(M) - var xm = xM || isX(m) - var xp = xm || isX(p) - var anyX = xp - - if (gtlt === '=' && anyX) { - gtlt = '' - } - - // if we're including prereleases in the match, then we need - // to fix this to -0, the lowest possible prerelease value - pr = options.includePrerelease ? '-0' : '' - - if (xM) { - if (gtlt === '>' || gtlt === '<') { - // nothing is allowed - ret = '<0.0.0-0' - } else { - // nothing is forbidden - ret = '*' - } - } else if (gtlt && anyX) { - // we know patch is an x, because we have any x at all. - // replace X with 0 - if (xm) { - m = 0 - } - p = 0 - - if (gtlt === '>') { - // >1 => >=2.0.0 - // >1.2 => >=1.3.0 - // >1.2.3 => >= 1.2.4 - gtlt = '>=' - if (xm) { - M = +M + 1 - m = 0 - p = 0 - } else { - m = +m + 1 - p = 0 - } - } else if (gtlt === '<=') { - // <=0.7.x is actually <0.8.0, since any 0.7.x should - // pass. Similarly, <=7.x is actually <8.0.0, etc. - gtlt = '<' - if (xm) { - M = +M + 1 - } else { - m = +m + 1 - } - } - - ret = gtlt + M + '.' + m + '.' + p + pr - } else if (xm) { - ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr - } else if (xp) { - ret = '>=' + M + '.' + m + '.0' + pr + - ' <' + M + '.' + (+m + 1) + '.0' + pr - } - - debug('xRange return', ret) - - return ret - }) -} - -// Because * is AND-ed with everything else in the comparator, -// and '' means "any version", just remove the *s entirely. -function replaceStars (comp, options) { - debug('replaceStars', comp, options) - // Looseness is ignored here. star is always as loose as it gets! - return comp.trim().replace(re[t.STAR], '') -} - -// This function is passed to string.replace(re[t.HYPHENRANGE]) -// M, m, patch, prerelease, build -// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5 -// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do -// 1.2 - 3.4 => >=1.2.0 <3.5.0 -function hyphenReplace ($0, - from, fM, fm, fp, fpr, fb, - to, tM, tm, tp, tpr, tb) { - if (isX(fM)) { - from = '' - } else if (isX(fm)) { - from = '>=' + fM + '.0.0' - } else if (isX(fp)) { - from = '>=' + fM + '.' + fm + '.0' - } else { - from = '>=' + from - } - - if (isX(tM)) { - to = '' - } else if (isX(tm)) { - to = '<' + (+tM + 1) + '.0.0' - } else if (isX(tp)) { - to = '<' + tM + '.' + (+tm + 1) + '.0' - } else if (tpr) { - to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr - } else { - to = '<=' + to - } - - return (from + ' ' + to).trim() -} - -// if ANY of the sets match ALL of its comparators, then pass -Range.prototype.test = function (version) { - if (!version) { - return false - } - - if (typeof version === 'string') { - try { - version = new SemVer(version, this.options) - } catch (er) { - return false - } - } - - for (var i = 0; i < this.set.length; i++) { - if (testSet(this.set[i], version, this.options)) { - return true - } - } - return false -} - -function testSet (set, version, options) { - for (var i = 0; i < set.length; i++) { - if (!set[i].test(version)) { - return false - } - } - - if (version.prerelease.length && !options.includePrerelease) { - // Find the set of versions that are allowed to have prereleases - // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0 - // That should allow `1.2.3-pr.2` to pass. - // However, `1.2.4-alpha.notready` should NOT be allowed, - // even though it's within the range set by the comparators. - for (i = 0; i < set.length; i++) { - debug(set[i].semver) - if (set[i].semver === ANY) { - continue - } - - if (set[i].semver.prerelease.length > 0) { - var allowed = set[i].semver - if (allowed.major === version.major && - allowed.minor === version.minor && - allowed.patch === version.patch) { - return true - } - } - } - - // Version has a -pre, but it's not one of the ones we like. - return false - } - - return true -} - -exports.satisfies = satisfies -function satisfies (version, range, options) { - try { - range = new Range(range, options) - } catch (er) { - return false - } - return range.test(version) -} - -exports.maxSatisfying = maxSatisfying -function maxSatisfying (versions, range, options) { - var max = null - var maxSV = null - try { - var rangeObj = new Range(range, options) - } catch (er) { - return null - } - versions.forEach(function (v) { - if (rangeObj.test(v)) { - // satisfies(v, range, options) - if (!max || maxSV.compare(v) === -1) { - // compare(max, v, true) - max = v - maxSV = new SemVer(max, options) - } - } - }) - return max -} - -exports.minSatisfying = minSatisfying -function minSatisfying (versions, range, options) { - var min = null - var minSV = null - try { - var rangeObj = new Range(range, options) - } catch (er) { - return null - } - versions.forEach(function (v) { - if (rangeObj.test(v)) { - // satisfies(v, range, options) - if (!min || minSV.compare(v) === 1) { - // compare(min, v, true) - min = v - minSV = new SemVer(min, options) - } - } - }) - return min -} - -exports.minVersion = minVersion -function minVersion (range, loose) { - range = new Range(range, loose) - - var minver = new SemVer('0.0.0') - if (range.test(minver)) { - return minver - } - - minver = new SemVer('0.0.0-0') - if (range.test(minver)) { - return minver - } - - minver = null - for (var i = 0; i < range.set.length; ++i) { - var comparators = range.set[i] - - comparators.forEach(function (comparator) { - // Clone to avoid manipulating the comparator's semver object. - var compver = new SemVer(comparator.semver.version) - switch (comparator.operator) { - case '>': - if (compver.prerelease.length === 0) { - compver.patch++ - } else { - compver.prerelease.push(0) - } - compver.raw = compver.format() - /* fallthrough */ - case '': - case '>=': - if (!minver || gt(minver, compver)) { - minver = compver - } - break - case '<': - case '<=': - /* Ignore maximum versions */ - break - /* istanbul ignore next */ - default: - throw new Error('Unexpected operation: ' + comparator.operator) - } - }) - } - - if (minver && range.test(minver)) { - return minver - } - - return null -} - -exports.validRange = validRange -function validRange (range, options) { - try { - // Return '*' instead of '' so that truthiness works. - // This will throw if it's invalid anyway - return new Range(range, options).range || '*' - } catch (er) { - return null - } -} - -// Determine if version is less than all the versions possible in the range -exports.ltr = ltr -function ltr (version, range, options) { - return outside(version, range, '<', options) -} - -// Determine if version is greater than all the versions possible in the range. -exports.gtr = gtr -function gtr (version, range, options) { - return outside(version, range, '>', options) -} - -exports.outside = outside -function outside (version, range, hilo, options) { - version = new SemVer(version, options) - range = new Range(range, options) - - var gtfn, ltefn, ltfn, comp, ecomp - switch (hilo) { - case '>': - gtfn = gt - ltefn = lte - ltfn = lt - comp = '>' - ecomp = '>=' - break - case '<': - gtfn = lt - ltefn = gte - ltfn = gt - comp = '<' - ecomp = '<=' - break - default: - throw new TypeError('Must provide a hilo val of "<" or ">"') - } - - // If it satisifes the range it is not outside - if (satisfies(version, range, options)) { - return false - } - - // From now on, variable terms are as if we're in "gtr" mode. - // but note that everything is flipped for the "ltr" function. - - for (var i = 0; i < range.set.length; ++i) { - var comparators = range.set[i] - - var high = null - var low = null - - comparators.forEach(function (comparator) { - if (comparator.semver === ANY) { - comparator = new Comparator('>=0.0.0') - } - high = high || comparator - low = low || comparator - if (gtfn(comparator.semver, high.semver, options)) { - high = comparator - } else if (ltfn(comparator.semver, low.semver, options)) { - low = comparator - } - }) - - // If the edge version comparator has a operator then our version - // isn't outside it - if (high.operator === comp || high.operator === ecomp) { - return false - } - - // If the lowest version comparator has an operator and our version - // is less than it then it isn't higher than the range - if ((!low.operator || low.operator === comp) && - ltefn(version, low.semver)) { - return false - } else if (low.operator === ecomp && ltfn(version, low.semver)) { - return false - } - } - return true -} - -exports.prerelease = prerelease -function prerelease (version, options) { - var parsed = parse(version, options) - return (parsed && parsed.prerelease.length) ? parsed.prerelease : null -} - -exports.intersects = intersects -function intersects (r1, r2, options) { - r1 = new Range(r1, options) - r2 = new Range(r2, options) - return r1.intersects(r2) -} - -exports.coerce = coerce -function coerce (version, options) { - if (version instanceof SemVer) { - return version - } - - if (typeof version === 'number') { - version = String(version) - } - - if (typeof version !== 'string') { - return null - } - - options = options || {} - - var match = null - if (!options.rtl) { - match = version.match(re[t.COERCE]) - } else { - // Find the right-most coercible string that does not share - // a terminus with a more left-ward coercible string. - // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4' - // - // Walk through the string checking with a /g regexp - // Manually set the index so as to pick up overlapping matches. - // Stop when we get a match that ends at the string end, since no - // coercible string can be more right-ward without the same terminus. - var next - while ((next = re[t.COERCERTL].exec(version)) && - (!match || match.index + match[0].length !== version.length) - ) { - if (!match || - next.index + next[0].length !== match.index + match[0].length) { - match = next - } - re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length - } - // leave it in a clean state - re[t.COERCERTL].lastIndex = -1 - } - - if (match === null) { - return null - } - - return parse(match[2] + - '.' + (match[3] || '0') + - '.' + (match[4] || '0'), options) -} diff --git a/node_modules/jest-config/LICENSE b/node_modules/jest-config/LICENSE deleted file mode 100644 index b96dcb04..00000000 --- a/node_modules/jest-config/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) Facebook, Inc. and its affiliates. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/jest-config/build/Defaults.d.ts b/node_modules/jest-config/build/Defaults.d.ts deleted file mode 100644 index 3d460872..00000000 --- a/node_modules/jest-config/build/Defaults.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import type { Config } from '@jest/types'; -declare const defaultOptions: Config.DefaultOptions; -export default defaultOptions; -//# sourceMappingURL=Defaults.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-config/build/Defaults.d.ts.map b/node_modules/jest-config/build/Defaults.d.ts.map deleted file mode 100644 index cb2e7ff4..00000000 --- a/node_modules/jest-config/build/Defaults.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Defaults.d.ts","sourceRoot":"","sources":["../src/Defaults.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAOxC,QAAA,MAAM,cAAc,EAAE,MAAM,CAAC,cAyD5B,CAAC;AAEF,eAAe,cAAc,CAAC"} \ No newline at end of file diff --git a/node_modules/jest-config/build/Defaults.js b/node_modules/jest-config/build/Defaults.js deleted file mode 100644 index c3e1a44c..00000000 --- a/node_modules/jest-config/build/Defaults.js +++ /dev/null @@ -1,94 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.default = void 0; - -function _jestRegexUtil() { - const data = require('jest-regex-util'); - - _jestRegexUtil = function () { - return data; - }; - - return data; -} - -var _constants = require('./constants'); - -var _getCacheDirectory = _interopRequireDefault(require('./getCacheDirectory')); - -function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : {default: obj}; -} - -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -const NODE_MODULES_REGEXP = (0, _jestRegexUtil().replacePathSepForRegex)( - _constants.NODE_MODULES -); -const defaultOptions = { - automock: false, - bail: 0, - browser: false, - cache: true, - cacheDirectory: (0, _getCacheDirectory.default)(), - changedFilesWithAncestor: false, - clearMocks: false, - collectCoverage: false, - coveragePathIgnorePatterns: [NODE_MODULES_REGEXP], - coverageProvider: 'babel', - coverageReporters: ['json', 'text', 'lcov', 'clover'], - errorOnDeprecated: false, - expand: false, - forceCoverageMatch: [], - globals: {}, - haste: { - computeSha1: false, - providesModuleNodeModules: [], - throwOnModuleCollision: false - }, - maxConcurrency: 5, - maxWorkers: '50%', - moduleDirectories: ['node_modules'], - moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node'], - moduleNameMapper: {}, - modulePathIgnorePatterns: [], - noStackTrace: false, - notify: false, - notifyMode: 'failure-change', - prettierPath: 'prettier', - resetMocks: false, - resetModules: false, - restoreMocks: false, - roots: [''], - runTestsByPath: false, - runner: 'jest-runner', - setupFiles: [], - setupFilesAfterEnv: [], - skipFilter: false, - snapshotSerializers: [], - testEnvironment: 'jest-environment-jsdom', - testEnvironmentOptions: {}, - testFailureExitCode: 1, - testLocationInResults: false, - testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[tj]s?(x)'], - testPathIgnorePatterns: [NODE_MODULES_REGEXP], - testRegex: [], - testRunner: 'jasmine2', - testSequencer: '@jest/test-sequencer', - testURL: 'http://localhost', - timers: 'real', - transformIgnorePatterns: [NODE_MODULES_REGEXP], - useStderr: false, - watch: false, - watchPathIgnorePatterns: [], - watchman: true -}; -var _default = defaultOptions; -exports.default = _default; diff --git a/node_modules/jest-config/build/Deprecated.d.ts b/node_modules/jest-config/build/Deprecated.d.ts deleted file mode 100644 index 37d97d3b..00000000 --- a/node_modules/jest-config/build/Deprecated.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -declare const _default: Record; -export default _default; -//# sourceMappingURL=Deprecated.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-config/build/Deprecated.d.ts.map b/node_modules/jest-config/build/Deprecated.d.ts.map deleted file mode 100644 index bd1ed207..00000000 --- a/node_modules/jest-config/build/Deprecated.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Deprecated.d.ts","sourceRoot":"","sources":["../src/Deprecated.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAOH,wBAgE8B"} \ No newline at end of file diff --git a/node_modules/jest-config/build/Deprecated.js b/node_modules/jest-config/build/Deprecated.js deleted file mode 100644 index 44031b12..00000000 --- a/node_modules/jest-config/build/Deprecated.js +++ /dev/null @@ -1,98 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.default = void 0; - -function _chalk() { - const data = _interopRequireDefault(require('chalk')); - - _chalk = function () { - return data; - }; - - return data; -} - -function _prettyFormat() { - const data = _interopRequireDefault(require('pretty-format')); - - _prettyFormat = function () { - return data; - }; - - return data; -} - -function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : {default: obj}; -} - -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -const format = value => - (0, _prettyFormat().default)(value, { - min: true - }); - -var _default = { - mapCoverage: () => ` Option ${_chalk().default.bold( - '"mapCoverage"' - )} has been removed, as it's no longer necessary. - - Please update your configuration.`, - preprocessorIgnorePatterns: options => ` Option ${_chalk().default.bold( - '"preprocessorIgnorePatterns"' - )} was replaced by ${_chalk().default.bold( - '"transformIgnorePatterns"' - )}, which support multiple preprocessors. - - Jest now treats your current configuration as: - { - ${_chalk().default.bold( - '"transformIgnorePatterns"' - )}: ${_chalk().default.bold(format(options.preprocessorIgnorePatterns))} - } - - Please update your configuration.`, - scriptPreprocessor: options => ` Option ${_chalk().default.bold( - '"scriptPreprocessor"' - )} was replaced by ${_chalk().default.bold( - '"transform"' - )}, which support multiple preprocessors. - - Jest now treats your current configuration as: - { - ${_chalk().default.bold('"transform"')}: ${_chalk().default.bold( - `{".*": ${format(options.scriptPreprocessor)}}` - )} - } - - Please update your configuration.`, - setupTestFrameworkScriptFile: _options => ` Option ${_chalk().default.bold( - '"setupTestFrameworkScriptFile"' - )} was replaced by configuration ${_chalk().default.bold( - '"setupFilesAfterEnv"' - )}, which supports multiple paths. - - Please update your configuration.`, - testPathDirs: options => ` Option ${_chalk().default.bold( - '"testPathDirs"' - )} was replaced by ${_chalk().default.bold('"roots"')}. - - Jest now treats your current configuration as: - { - ${_chalk().default.bold('"roots"')}: ${_chalk().default.bold( - format(options.testPathDirs) - )} - } - - Please update your configuration. - ` -}; -exports.default = _default; diff --git a/node_modules/jest-config/build/Descriptions.d.ts b/node_modules/jest-config/build/Descriptions.d.ts deleted file mode 100644 index 33bafb8b..00000000 --- a/node_modules/jest-config/build/Descriptions.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import type { Config } from '@jest/types'; -declare const descriptions: { - [key in keyof Config.InitialOptions]: string; -}; -export default descriptions; -//# sourceMappingURL=Descriptions.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-config/build/Descriptions.d.ts.map b/node_modules/jest-config/build/Descriptions.d.ts.map deleted file mode 100644 index a41698c8..00000000 --- a/node_modules/jest-config/build/Descriptions.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Descriptions.d.ts","sourceRoot":"","sources":["../src/Descriptions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAExC,QAAA,MAAM,YAAY,EAAE;KAAE,GAAG,IAAI,MAAM,MAAM,CAAC,cAAc,GAAG,MAAM;CAsFhE,CAAC;AAEF,eAAe,YAAY,CAAC"} \ No newline at end of file diff --git a/node_modules/jest-config/build/Descriptions.js b/node_modules/jest-config/build/Descriptions.js deleted file mode 100644 index bcdf116f..00000000 --- a/node_modules/jest-config/build/Descriptions.js +++ /dev/null @@ -1,102 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.default = void 0; - -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -const descriptions = { - automock: 'All imported modules in your tests should be mocked automatically', - bail: 'Stop running tests after `n` failures', - browser: 'Respect "browser" field in package.json when resolving modules', - cacheDirectory: - 'The directory where Jest should store its cached dependency information', - clearMocks: 'Automatically clear mock calls and instances between every test', - collectCoverage: - 'Indicates whether the coverage information should be collected while executing the test', - collectCoverageFrom: - 'An array of glob patterns indicating a set of files for which coverage information should be collected', - coverageDirectory: - 'The directory where Jest should output its coverage files', - coveragePathIgnorePatterns: - 'An array of regexp pattern strings used to skip coverage collection', - coverageReporters: - 'A list of reporter names that Jest uses when writing coverage reports', - coverageThreshold: - 'An object that configures minimum threshold enforcement for coverage results', - dependencyExtractor: 'A path to a custom dependency extractor', - errorOnDeprecated: - 'Make calling deprecated APIs throw helpful error messages', - forceCoverageMatch: - 'Force coverage collection from ignored files using an array of glob patterns', - globalSetup: - 'A path to a module which exports an async function that is triggered once before all test suites', - globalTeardown: - 'A path to a module which exports an async function that is triggered once after all test suites', - globals: - 'A set of global variables that need to be available in all test environments', - maxWorkers: - 'The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.', - moduleDirectories: - "An array of directory names to be searched recursively up from the requiring module's location", - moduleFileExtensions: 'An array of file extensions your modules use', - moduleNameMapper: - 'A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module', - modulePathIgnorePatterns: - "An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader", - notify: 'Activates notifications for test results', - notifyMode: - 'An enum that specifies notification mode. Requires { notify: true }', - preset: "A preset that is used as a base for Jest's configuration", - projects: 'Run tests from one or more projects', - reporters: 'Use this configuration option to add custom reporters to Jest', - resetMocks: 'Automatically reset mock state between every test', - resetModules: 'Reset the module registry before running each individual test', - resolver: 'A path to a custom resolver', - restoreMocks: 'Automatically restore mock state between every test', - rootDir: - 'The root directory that Jest should scan for tests and modules within', - roots: - 'A list of paths to directories that Jest should use to search for files in', - runner: - "Allows you to use a custom runner instead of Jest's default test runner", - setupFiles: - 'The paths to modules that run some code to configure or set up the testing environment before each test', - setupFilesAfterEnv: - 'A list of paths to modules that run some code to configure or set up the testing framework before each test', - snapshotSerializers: - 'A list of paths to snapshot serializer modules Jest should use for snapshot testing', - testEnvironment: 'The test environment that will be used for testing', - testEnvironmentOptions: 'Options that will be passed to the testEnvironment', - testLocationInResults: 'Adds a location field to test results', - testMatch: 'The glob patterns Jest uses to detect test files', - testPathIgnorePatterns: - 'An array of regexp pattern strings that are matched against all test paths, matched tests are skipped', - testRegex: - 'The regexp pattern or array of patterns that Jest uses to detect test files', - testResultsProcessor: - 'This option allows the use of a custom results processor', - testRunner: 'This option allows use of a custom test runner', - testURL: - 'This option sets the URL for the jsdom environment. It is reflected in properties such as location.href', - timers: - 'Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"', - transform: 'A map from regular expressions to paths to transformers', - transformIgnorePatterns: - 'An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation', - unmockedModulePathPatterns: - 'An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them', - verbose: - 'Indicates whether each individual test should be reported during the run', - watchPathIgnorePatterns: - 'An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode', - watchman: 'Whether to use watchman for file crawling' -}; -var _default = descriptions; -exports.default = _default; diff --git a/node_modules/jest-config/build/ReporterValidationErrors.d.ts b/node_modules/jest-config/build/ReporterValidationErrors.d.ts deleted file mode 100644 index a2294c3e..00000000 --- a/node_modules/jest-config/build/ReporterValidationErrors.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import type { Config } from '@jest/types'; -import { ValidationError } from 'jest-validate'; -/** - * Reporter Validation Error is thrown if the given arguments - * within the reporter are not valid. - * - * This is a highly specific reporter error and in the future will be - * merged with jest-validate. Till then, we can make use of it. It works - * and that's what counts most at this time. - */ -export declare function createReporterError(reporterIndex: number, reporterValue: Array | string): ValidationError; -export declare function createArrayReporterError(arrayReporter: Config.ReporterConfig, reporterIndex: number, valueIndex: number, value: string | Record, expectedType: string, valueName: string): ValidationError; -export declare function validateReporters(reporterConfig: Array): boolean; -//# sourceMappingURL=ReporterValidationErrors.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-config/build/ReporterValidationErrors.d.ts.map b/node_modules/jest-config/build/ReporterValidationErrors.d.ts.map deleted file mode 100644 index 415d4b8d..00000000 --- a/node_modules/jest-config/build/ReporterValidationErrors.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"ReporterValidationErrors.d.ts","sourceRoot":"","sources":["../src/ReporterValidationErrors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAQ9C;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,MAAM,GACnD,eAAe,CAQjB;AAED,wBAAgB,wBAAwB,CACtC,aAAa,EAAE,MAAM,CAAC,cAAc,EACpC,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACnC,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,GAChB,eAAe,CAcjB;AAED,wBAAgB,iBAAiB,CAC/B,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,cAAc,GAAG,MAAM,CAAC,GACpD,OAAO,CAUT"} \ No newline at end of file diff --git a/node_modules/jest-config/build/ReporterValidationErrors.js b/node_modules/jest-config/build/ReporterValidationErrors.js deleted file mode 100644 index 53e1b822..00000000 --- a/node_modules/jest-config/build/ReporterValidationErrors.js +++ /dev/null @@ -1,138 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.createReporterError = createReporterError; -exports.createArrayReporterError = createArrayReporterError; -exports.validateReporters = validateReporters; - -function _jestValidate() { - const data = require('jest-validate'); - - _jestValidate = function () { - return data; - }; - - return data; -} - -function _chalk() { - const data = _interopRequireDefault(require('chalk')); - - _chalk = function () { - return data; - }; - - return data; -} - -function _jestGetType() { - const data = _interopRequireDefault(require('jest-get-type')); - - _jestGetType = function () { - return data; - }; - - return data; -} - -var _utils = require('./utils'); - -function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : {default: obj}; -} - -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -const validReporterTypes = ['array', 'string']; -const ERROR = `${_utils.BULLET}Reporter Validation Error`; -/** - * Reporter Validation Error is thrown if the given arguments - * within the reporter are not valid. - * - * This is a highly specific reporter error and in the future will be - * merged with jest-validate. Till then, we can make use of it. It works - * and that's what counts most at this time. - */ - -function createReporterError(reporterIndex, reporterValue) { - const errorMessage = - ` Reporter at index ${reporterIndex} must be of type:\n` + - ` ${_chalk().default.bold.green(validReporterTypes.join(' or '))}\n` + - ` but instead received:\n` + - ` ${_chalk().default.bold.red( - (0, _jestGetType().default)(reporterValue) - )}`; - return new (_jestValidate().ValidationError)( - ERROR, - errorMessage, - _utils.DOCUMENTATION_NOTE - ); -} - -function createArrayReporterError( - arrayReporter, - reporterIndex, - valueIndex, - value, - expectedType, - valueName -) { - const errorMessage = - ` Unexpected value for ${valueName} ` + - `at index ${valueIndex} of reporter at index ${reporterIndex}\n` + - ' Expected:\n' + - ` ${_chalk().default.bold.red(expectedType)}\n` + - ' Got:\n' + - ` ${_chalk().default.bold.green((0, _jestGetType().default)(value))}\n` + - ` Reporter configuration:\n` + - ` ${_chalk().default.bold.green( - JSON.stringify(arrayReporter, null, 2).split('\n').join('\n ') - )}`; - return new (_jestValidate().ValidationError)( - ERROR, - errorMessage, - _utils.DOCUMENTATION_NOTE - ); -} - -function validateReporters(reporterConfig) { - return reporterConfig.every((reporter, index) => { - if (Array.isArray(reporter)) { - validateArrayReporter(reporter, index); - } else if (typeof reporter !== 'string') { - throw createReporterError(index, reporter); - } - - return true; - }); -} - -function validateArrayReporter(arrayReporter, reporterIndex) { - const [path, options] = arrayReporter; - - if (typeof path !== 'string') { - throw createArrayReporterError( - arrayReporter, - reporterIndex, - 0, - path, - 'string', - 'Path' - ); - } else if (typeof options !== 'object') { - throw createArrayReporterError( - arrayReporter, - reporterIndex, - 1, - options, - 'object', - 'Reporter Configuration' - ); - } -} diff --git a/node_modules/jest-config/build/ValidConfig.d.ts b/node_modules/jest-config/build/ValidConfig.d.ts deleted file mode 100644 index 009a4182..00000000 --- a/node_modules/jest-config/build/ValidConfig.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import type { Config } from '@jest/types'; -declare const initialOptions: Config.InitialOptions; -export default initialOptions; -//# sourceMappingURL=ValidConfig.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-config/build/ValidConfig.d.ts.map b/node_modules/jest-config/build/ValidConfig.d.ts.map deleted file mode 100644 index fab7cacc..00000000 --- a/node_modules/jest-config/build/ValidConfig.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"ValidConfig.d.ts","sourceRoot":"","sources":["../src/ValidConfig.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAOxC,QAAA,MAAM,cAAc,EAAE,MAAM,CAAC,cA+H5B,CAAC;AAEF,eAAe,cAAc,CAAC"} \ No newline at end of file diff --git a/node_modules/jest-config/build/ValidConfig.js b/node_modules/jest-config/build/ValidConfig.js deleted file mode 100644 index 5a67c6c6..00000000 --- a/node_modules/jest-config/build/ValidConfig.js +++ /dev/null @@ -1,179 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.default = void 0; - -function _jestRegexUtil() { - const data = require('jest-regex-util'); - - _jestRegexUtil = function () { - return data; - }; - - return data; -} - -function _jestValidate() { - const data = require('jest-validate'); - - _jestValidate = function () { - return data; - }; - - return data; -} - -var _constants = require('./constants'); - -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -const NODE_MODULES_REGEXP = (0, _jestRegexUtil().replacePathSepForRegex)( - _constants.NODE_MODULES -); -const initialOptions = { - automock: false, - bail: (0, _jestValidate().multipleValidOptions)(false, 0), - browser: false, - cache: true, - cacheDirectory: '/tmp/user/jest', - changedFilesWithAncestor: false, - changedSince: 'master', - clearMocks: false, - collectCoverage: true, - collectCoverageFrom: ['src', '!public'], - collectCoverageOnlyFrom: { - '/this-directory-is-covered/Covered.js': true - }, - coverageDirectory: 'coverage', - coveragePathIgnorePatterns: [NODE_MODULES_REGEXP], - coverageProvider: 'v8', - coverageReporters: ['json', 'text', 'lcov', 'clover'], - coverageThreshold: { - global: { - branches: 50, - functions: 100, - lines: 100, - statements: 100 - } - }, - dependencyExtractor: '/dependencyExtractor.js', - displayName: (0, _jestValidate().multipleValidOptions)('test-config', { - color: 'blue', - name: 'test-config' - }), - errorOnDeprecated: false, - expand: false, - extraGlobals: [], - filter: '/filter.js', - forceCoverageMatch: ['**/*.t.js'], - forceExit: false, - globalSetup: 'setup.js', - globalTeardown: 'teardown.js', - globals: { - __DEV__: true - }, - haste: { - computeSha1: true, - defaultPlatform: 'ios', - hasteImplModulePath: '/haste_impl.js', - platforms: ['ios', 'android'], - providesModuleNodeModules: ['react', 'react-native'], - throwOnModuleCollision: false - }, - json: false, - lastCommit: false, - logHeapUsage: true, - maxConcurrency: 5, - maxWorkers: '50%', - moduleDirectories: ['node_modules'], - moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node'], - moduleLoader: '', - moduleNameMapper: { - '^React$': '/node_modules/react' - }, - modulePathIgnorePatterns: ['/build/'], - modulePaths: ['/shared/vendor/modules'], - name: 'string', - noStackTrace: false, - notify: false, - notifyMode: 'failure-change', - onlyChanged: false, - preset: 'react-native', - prettierPath: '/node_modules/prettier', - projects: ['project-a', 'project-b/'], - reporters: [ - 'default', - 'custom-reporter-1', - [ - 'custom-reporter-2', - { - configValue: true - } - ] - ], - resetMocks: false, - resetModules: false, - resolver: '/resolver.js', - restoreMocks: false, - rootDir: '/', - roots: [''], - runTestsByPath: false, - runner: 'jest-runner', - setupFiles: ['/setup.js'], - setupFilesAfterEnv: ['/testSetupFile.js'], - silent: true, - skipFilter: false, - skipNodeResolution: false, - snapshotResolver: '/snapshotResolver.js', - snapshotSerializers: ['my-serializer-module'], - testEnvironment: 'jest-environment-jsdom', - testEnvironmentOptions: { - userAgent: 'Agent/007' - }, - testFailureExitCode: 1, - testLocationInResults: false, - testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'], - testNamePattern: 'test signature', - testPathIgnorePatterns: [NODE_MODULES_REGEXP], - testRegex: (0, - _jestValidate() - .multipleValidOptions)('(/__tests__/.*|(\\.|/)(test|spec))\\.[jt]sx?$', [ - '/__tests__/\\.test\\.[jt]sx?$', - '/__tests__/\\.spec\\.[jt]sx?$' - ]), - testResultsProcessor: 'processor-node-module', - testRunner: 'jasmine2', - testSequencer: '@jest/test-sequencer', - testTimeout: 5000, - testURL: 'http://localhost', - timers: 'real', - transform: { - '^.+\\.js$': '/preprocessor.js' - }, - transformIgnorePatterns: [NODE_MODULES_REGEXP], - unmockedModulePathPatterns: ['mock'], - updateSnapshot: true, - useStderr: false, - verbose: false, - watch: false, - watchPathIgnorePatterns: ['/e2e/'], - watchPlugins: [ - 'path/to/yourWatchPlugin', - [ - 'jest-watch-typeahead/filename', - { - key: 'k', - prompt: 'do something with my custom prompt' - } - ] - ], - watchman: true -}; -var _default = initialOptions; -exports.default = _default; diff --git a/node_modules/jest-config/build/color.d.ts b/node_modules/jest-config/build/color.d.ts deleted file mode 100644 index 2d7e1ff8..00000000 --- a/node_modules/jest-config/build/color.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -export declare const getDisplayNameColor: (seed?: string | undefined) => "hex" | "bold" | "reset" | "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "grey" | "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright" | "bgBlack" | "bgRed" | "bgGreen" | "bgYellow" | "bgBlue" | "bgMagenta" | "bgCyan" | "bgWhite" | "bgGray" | "bgGrey" | "bgBlackBright" | "bgRedBright" | "bgGreenBright" | "bgYellowBright" | "bgBlueBright" | "bgMagentaBright" | "bgCyanBright" | "bgWhiteBright" | "dim" | "italic" | "underline" | "inverse" | "hidden" | "strikethrough" | "visible" | "Instance" | "level" | "keyword" | "rgb" | "hsl" | "hsv" | "hwb" | "ansi" | "ansi256" | "bgHex" | "bgKeyword" | "bgRgb" | "bgHsl" | "bgHsv" | "bgHwb" | "bgAnsi" | "bgAnsi256" | "supportsColor" | "Level" | "Color" | "ForegroundColor" | "BackgroundColor" | "Modifiers" | "stderr"; -//# sourceMappingURL=color.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-config/build/color.d.ts.map b/node_modules/jest-config/build/color.d.ts.map deleted file mode 100644 index e9371245..00000000 --- a/node_modules/jest-config/build/color.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../src/color.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAeH,eAAO,MAAM,mBAAmB,24BAS/B,CAAC"} \ No newline at end of file diff --git a/node_modules/jest-config/build/color.js b/node_modules/jest-config/build/color.js deleted file mode 100644 index 378d41f9..00000000 --- a/node_modules/jest-config/build/color.js +++ /dev/null @@ -1,51 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.getDisplayNameColor = void 0; - -function _crypto() { - const data = require('crypto'); - - _crypto = function () { - return data; - }; - - return data; -} - -function _chalk() { - const data = _interopRequireDefault(require('chalk')); - - _chalk = function () { - return data; - }; - - return data; -} - -function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : {default: obj}; -} - -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -const colors = ['red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white']; - -const getDisplayNameColor = seed => { - if (seed === undefined) { - return 'white'; - } - - const hash = (0, _crypto().createHash)('sha256'); - hash.update(seed); - const num = hash.digest().readUInt32LE(0); - return colors[num % colors.length]; -}; - -exports.getDisplayNameColor = getDisplayNameColor; diff --git a/node_modules/jest-config/build/constants.d.ts b/node_modules/jest-config/build/constants.d.ts deleted file mode 100644 index 7b4af327..00000000 --- a/node_modules/jest-config/build/constants.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -export declare const NODE_MODULES: string; -export declare const DEFAULT_JS_PATTERN = "^.+\\.[jt]sx?$"; -export declare const DEFAULT_REPORTER_LABEL = "default"; -export declare const PACKAGE_JSON = "package.json"; -export declare const JEST_CONFIG_BASE_NAME = "jest.config"; -export declare const JEST_CONFIG_EXT_CJS = ".cjs"; -export declare const JEST_CONFIG_EXT_MJS = ".mjs"; -export declare const JEST_CONFIG_EXT_JS = ".js"; -export declare const JEST_CONFIG_EXT_JSON = ".json"; -export declare const JEST_CONFIG_EXT_ORDER: readonly string[]; -//# sourceMappingURL=constants.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-config/build/constants.d.ts.map b/node_modules/jest-config/build/constants.d.ts.map deleted file mode 100644 index 68a94f3c..00000000 --- a/node_modules/jest-config/build/constants.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,eAAO,MAAM,YAAY,QAAuC,CAAC;AACjE,eAAO,MAAM,kBAAkB,mBAAmB,CAAC;AACnD,eAAO,MAAM,sBAAsB,YAAY,CAAC;AAChD,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAC3C,eAAO,MAAM,qBAAqB,gBAAgB,CAAC;AACnD,eAAO,MAAM,mBAAmB,SAAS,CAAC;AAC1C,eAAO,MAAM,mBAAmB,SAAS,CAAC;AAC1C,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AACxC,eAAO,MAAM,oBAAoB,UAAU,CAAC;AAC5C,eAAO,MAAM,qBAAqB,mBAKhC,CAAC"} \ No newline at end of file diff --git a/node_modules/jest-config/build/constants.js b/node_modules/jest-config/build/constants.js deleted file mode 100644 index b6735b89..00000000 --- a/node_modules/jest-config/build/constants.js +++ /dev/null @@ -1,90 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.JEST_CONFIG_EXT_ORDER = exports.JEST_CONFIG_EXT_JSON = exports.JEST_CONFIG_EXT_JS = exports.JEST_CONFIG_EXT_MJS = exports.JEST_CONFIG_EXT_CJS = exports.JEST_CONFIG_BASE_NAME = exports.PACKAGE_JSON = exports.DEFAULT_REPORTER_LABEL = exports.DEFAULT_JS_PATTERN = exports.NODE_MODULES = void 0; - -function path() { - const data = _interopRequireWildcard(require('path')); - - path = function () { - return data; - }; - - return data; -} - -function _getRequireWildcardCache() { - if (typeof WeakMap !== 'function') return null; - var cache = new WeakMap(); - _getRequireWildcardCache = function () { - return cache; - }; - return cache; -} - -function _interopRequireWildcard(obj) { - if (obj && obj.__esModule) { - return obj; - } - if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { - return {default: obj}; - } - var cache = _getRequireWildcardCache(); - if (cache && cache.has(obj)) { - return cache.get(obj); - } - var newObj = {}; - var hasPropertyDescriptor = - Object.defineProperty && Object.getOwnPropertyDescriptor; - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) { - var desc = hasPropertyDescriptor - ? Object.getOwnPropertyDescriptor(obj, key) - : null; - if (desc && (desc.get || desc.set)) { - Object.defineProperty(newObj, key, desc); - } else { - newObj[key] = obj[key]; - } - } - } - newObj.default = obj; - if (cache) { - cache.set(obj, newObj); - } - return newObj; -} - -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -const NODE_MODULES = path().sep + 'node_modules' + path().sep; -exports.NODE_MODULES = NODE_MODULES; -const DEFAULT_JS_PATTERN = '^.+\\.[jt]sx?$'; -exports.DEFAULT_JS_PATTERN = DEFAULT_JS_PATTERN; -const DEFAULT_REPORTER_LABEL = 'default'; -exports.DEFAULT_REPORTER_LABEL = DEFAULT_REPORTER_LABEL; -const PACKAGE_JSON = 'package.json'; -exports.PACKAGE_JSON = PACKAGE_JSON; -const JEST_CONFIG_BASE_NAME = 'jest.config'; -exports.JEST_CONFIG_BASE_NAME = JEST_CONFIG_BASE_NAME; -const JEST_CONFIG_EXT_CJS = '.cjs'; -exports.JEST_CONFIG_EXT_CJS = JEST_CONFIG_EXT_CJS; -const JEST_CONFIG_EXT_MJS = '.mjs'; -exports.JEST_CONFIG_EXT_MJS = JEST_CONFIG_EXT_MJS; -const JEST_CONFIG_EXT_JS = '.js'; -exports.JEST_CONFIG_EXT_JS = JEST_CONFIG_EXT_JS; -const JEST_CONFIG_EXT_JSON = '.json'; -exports.JEST_CONFIG_EXT_JSON = JEST_CONFIG_EXT_JSON; -const JEST_CONFIG_EXT_ORDER = Object.freeze([ - JEST_CONFIG_EXT_JS, - JEST_CONFIG_EXT_MJS, - JEST_CONFIG_EXT_CJS, - JEST_CONFIG_EXT_JSON -]); -exports.JEST_CONFIG_EXT_ORDER = JEST_CONFIG_EXT_ORDER; diff --git a/node_modules/jest-config/build/getCacheDirectory.d.ts b/node_modules/jest-config/build/getCacheDirectory.d.ts deleted file mode 100644 index bd7f7222..00000000 --- a/node_modules/jest-config/build/getCacheDirectory.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -declare const getCacheDirectory: () => string; -export default getCacheDirectory; -//# sourceMappingURL=getCacheDirectory.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-config/build/getCacheDirectory.d.ts.map b/node_modules/jest-config/build/getCacheDirectory.d.ts.map deleted file mode 100644 index 3efd3f1e..00000000 --- a/node_modules/jest-config/build/getCacheDirectory.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"getCacheDirectory.d.ts","sourceRoot":"","sources":["../src/getCacheDirectory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,QAAA,MAAM,iBAAiB,cAWtB,CAAC;AAEF,eAAe,iBAAiB,CAAC"} \ No newline at end of file diff --git a/node_modules/jest-config/build/getCacheDirectory.js b/node_modules/jest-config/build/getCacheDirectory.js deleted file mode 100644 index 409def63..00000000 --- a/node_modules/jest-config/build/getCacheDirectory.js +++ /dev/null @@ -1,104 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.default = void 0; - -function path() { - const data = _interopRequireWildcard(require('path')); - - path = function () { - return data; - }; - - return data; -} - -function _os() { - const data = require('os'); - - _os = function () { - return data; - }; - - return data; -} - -function _realpathNative() { - const data = require('realpath-native'); - - _realpathNative = function () { - return data; - }; - - return data; -} - -function _getRequireWildcardCache() { - if (typeof WeakMap !== 'function') return null; - var cache = new WeakMap(); - _getRequireWildcardCache = function () { - return cache; - }; - return cache; -} - -function _interopRequireWildcard(obj) { - if (obj && obj.__esModule) { - return obj; - } - if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { - return {default: obj}; - } - var cache = _getRequireWildcardCache(); - if (cache && cache.has(obj)) { - return cache.get(obj); - } - var newObj = {}; - var hasPropertyDescriptor = - Object.defineProperty && Object.getOwnPropertyDescriptor; - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) { - var desc = hasPropertyDescriptor - ? Object.getOwnPropertyDescriptor(obj, key) - : null; - if (desc && (desc.get || desc.set)) { - Object.defineProperty(newObj, key, desc); - } else { - newObj[key] = obj[key]; - } - } - } - newObj.default = obj; - if (cache) { - cache.set(obj, newObj); - } - return newObj; -} - -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -const getCacheDirectory = () => { - const {getuid} = process; - const tmpdirPath = path().join( - (0, _realpathNative().sync)((0, _os().tmpdir)()), - 'jest' - ); - - if (getuid == null) { - return tmpdirPath; - } else { - // On some platforms tmpdir() is `/tmp`, causing conflicts between different - // users and permission issues. Adding an additional subdivision by UID can - // help. - return `${tmpdirPath}_${getuid.call(process).toString(36)}`; - } -}; - -var _default = getCacheDirectory; -exports.default = _default; diff --git a/node_modules/jest-config/build/getMaxWorkers.d.ts b/node_modules/jest-config/build/getMaxWorkers.d.ts deleted file mode 100644 index 9527cc28..00000000 --- a/node_modules/jest-config/build/getMaxWorkers.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import type { Config } from '@jest/types'; -export default function getMaxWorkers(argv: Partial>, defaultOptions?: Partial>): number; -//# sourceMappingURL=getMaxWorkers.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-config/build/getMaxWorkers.d.ts.map b/node_modules/jest-config/build/getMaxWorkers.d.ts.map deleted file mode 100644 index f3f48098..00000000 --- a/node_modules/jest-config/build/getMaxWorkers.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"getMaxWorkers.d.ts","sourceRoot":"","sources":["../src/getMaxWorkers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAExC,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,IAAI,EAAE,OAAO,CACX,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,GAAG,WAAW,GAAG,OAAO,GAAG,UAAU,CAAC,CACrE,EACD,cAAc,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,GACxD,MAAM,CAgBR"} \ No newline at end of file diff --git a/node_modules/jest-config/build/getMaxWorkers.js b/node_modules/jest-config/build/getMaxWorkers.js deleted file mode 100644 index 7f97165c..00000000 --- a/node_modules/jest-config/build/getMaxWorkers.js +++ /dev/null @@ -1,57 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.default = getMaxWorkers; - -function _os() { - const data = require('os'); - - _os = function () { - return data; - }; - - return data; -} - -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -function getMaxWorkers(argv, defaultOptions) { - if (argv.runInBand) { - return 1; - } else if (argv.maxWorkers) { - return parseWorkers(argv.maxWorkers); - } else if (defaultOptions && defaultOptions.maxWorkers) { - return parseWorkers(defaultOptions.maxWorkers); - } else { - // In watch mode, Jest should be unobtrusive and not use all available CPUs. - const numCpus = (0, _os().cpus)() ? (0, _os().cpus)().length : 1; - const isWatchModeEnabled = argv.watch || argv.watchAll; - return Math.max( - isWatchModeEnabled ? Math.floor(numCpus / 2) : numCpus - 1, - 1 - ); - } -} - -const parseWorkers = maxWorkers => { - const parsed = parseInt(maxWorkers.toString(), 10); - - if ( - typeof maxWorkers === 'string' && - maxWorkers.trim().endsWith('%') && - parsed > 0 && - parsed <= 100 - ) { - const numCpus = (0, _os().cpus)().length; - const workers = Math.floor((parsed / 100) * numCpus); - return workers >= 1 ? workers : 1; - } - - return parsed > 0 ? parsed : 1; -}; diff --git a/node_modules/jest-config/build/importEsm.d.ts b/node_modules/jest-config/build/importEsm.d.ts deleted file mode 100644 index e8982d5e..00000000 --- a/node_modules/jest-config/build/importEsm.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -declare const _default: (specifier: string) => Promise<{ - default: unknown; -}>; -export default _default; -//# sourceMappingURL=importEsm.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-config/build/importEsm.d.ts.map b/node_modules/jest-config/build/importEsm.d.ts.map deleted file mode 100644 index b9ac3503..00000000 --- a/node_modules/jest-config/build/importEsm.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"importEsm.d.ts","sourceRoot":"","sources":["../src/importEsm.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;;;AAMH,wBAEwC"} \ No newline at end of file diff --git a/node_modules/jest-config/build/importEsm.js b/node_modules/jest-config/build/importEsm.js deleted file mode 100644 index bfe47f15..00000000 --- a/node_modules/jest-config/build/importEsm.js +++ /dev/null @@ -1,30 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.default = void 0; - -function _url() { - const data = require('url'); - - _url = function () { - return data; - }; - - return data; -} - -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -// this is in a separate file so that node 8 don't explode with a syntax error. -// Remove this file when we drop support for Node 8 -var _default = ( - specifier // node `import()` supports URL, but TypeScript doesn't know that -) => import((0, _url().pathToFileURL)(specifier).href); - -exports.default = _default; diff --git a/node_modules/jest-config/build/index.d.ts b/node_modules/jest-config/build/index.d.ts deleted file mode 100644 index 7594e43e..00000000 --- a/node_modules/jest-config/build/index.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import type { Config } from '@jest/types'; -export { getTestEnvironment, isJSONString } from './utils'; -export { default as normalize } from './normalize'; -export { default as deprecationEntries } from './Deprecated'; -export { replaceRootDirInPath } from './utils'; -export { default as defaults } from './Defaults'; -export { default as descriptions } from './Descriptions'; -import * as constants from './constants'; -export { constants }; -declare type ReadConfig = { - configPath: Config.Path | null | undefined; - globalConfig: Config.GlobalConfig; - hasDeprecationWarnings: boolean; - projectConfig: Config.ProjectConfig; -}; -export declare function readConfig(argv: Config.Argv, packageRootOrConfig: Config.Path | Config.InitialOptions, skipArgvConfigOption?: boolean, parentConfigPath?: Config.Path | null, projectIndex?: number): Promise; -export declare function readConfigs(argv: Config.Argv, projectPaths: Array): Promise<{ - globalConfig: Config.GlobalConfig; - configs: Array; - hasDeprecationWarnings: boolean; -}>; -//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-config/build/index.d.ts.map b/node_modules/jest-config/build/index.d.ts.map deleted file mode 100644 index 0823b999..00000000 --- a/node_modules/jest-config/build/index.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAOxC,OAAO,EAAC,kBAAkB,EAAE,YAAY,EAAC,MAAM,SAAS,CAAC;AACzD,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,EAAC,OAAO,IAAI,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAC,oBAAoB,EAAC,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,EAAC,SAAS,EAAC,CAAC;AAEnB,aAAK,UAAU,GAAG;IAChB,UAAU,EAAE,MAAM,CAAC,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC;IAC3C,YAAY,EAAE,MAAM,CAAC,YAAY,CAAC;IAClC,sBAAsB,EAAE,OAAO,CAAC;IAChC,aAAa,EAAE,MAAM,CAAC,aAAa,CAAC;CACrC,CAAC;AAEF,wBAAsB,UAAU,CAC9B,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,mBAAmB,EAAE,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,cAAc,EAKxD,oBAAoB,CAAC,EAAE,OAAO,EAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC,IAAI,GAAG,IAAI,EACrC,YAAY,GAAE,MAAiB,GAC9B,OAAO,CAAC,UAAU,CAAC,CAwDrB;AAuKD,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAC/B,OAAO,CAAC;IACT,YAAY,EAAE,MAAM,CAAC,YAAY,CAAC;IAClC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IACrC,sBAAsB,EAAE,OAAO,CAAC;CACjC,CAAC,CAmFD"} \ No newline at end of file diff --git a/node_modules/jest-config/build/index.js b/node_modules/jest-config/build/index.js deleted file mode 100644 index e6189abf..00000000 --- a/node_modules/jest-config/build/index.js +++ /dev/null @@ -1,474 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.readConfig = readConfig; -exports.readConfigs = readConfigs; -Object.defineProperty(exports, 'getTestEnvironment', { - enumerable: true, - get: function () { - return _utils.getTestEnvironment; - } -}); -Object.defineProperty(exports, 'isJSONString', { - enumerable: true, - get: function () { - return _utils.isJSONString; - } -}); -Object.defineProperty(exports, 'replaceRootDirInPath', { - enumerable: true, - get: function () { - return _utils.replaceRootDirInPath; - } -}); -Object.defineProperty(exports, 'normalize', { - enumerable: true, - get: function () { - return _normalize.default; - } -}); -Object.defineProperty(exports, 'deprecationEntries', { - enumerable: true, - get: function () { - return _Deprecated.default; - } -}); -Object.defineProperty(exports, 'defaults', { - enumerable: true, - get: function () { - return _Defaults.default; - } -}); -Object.defineProperty(exports, 'descriptions', { - enumerable: true, - get: function () { - return _Descriptions.default; - } -}); -exports.constants = void 0; - -function fs() { - const data = _interopRequireWildcard(require('fs')); - - fs = function () { - return data; - }; - - return data; -} - -function path() { - const data = _interopRequireWildcard(require('path')); - - path = function () { - return data; - }; - - return data; -} - -function _chalk() { - const data = _interopRequireDefault(require('chalk')); - - _chalk = function () { - return data; - }; - - return data; -} - -function _realpathNative() { - const data = require('realpath-native'); - - _realpathNative = function () { - return data; - }; - - return data; -} - -var _utils = require('./utils'); - -var _normalize = _interopRequireDefault(require('./normalize')); - -var _resolveConfigPath = _interopRequireDefault(require('./resolveConfigPath')); - -var _readConfigFileAndSetRootDir = _interopRequireDefault( - require('./readConfigFileAndSetRootDir') -); - -var _Deprecated = _interopRequireDefault(require('./Deprecated')); - -var _Defaults = _interopRequireDefault(require('./Defaults')); - -var _Descriptions = _interopRequireDefault(require('./Descriptions')); - -var constants = _interopRequireWildcard(require('./constants')); - -exports.constants = constants; - -function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : {default: obj}; -} - -function _getRequireWildcardCache() { - if (typeof WeakMap !== 'function') return null; - var cache = new WeakMap(); - _getRequireWildcardCache = function () { - return cache; - }; - return cache; -} - -function _interopRequireWildcard(obj) { - if (obj && obj.__esModule) { - return obj; - } - if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { - return {default: obj}; - } - var cache = _getRequireWildcardCache(); - if (cache && cache.has(obj)) { - return cache.get(obj); - } - var newObj = {}; - var hasPropertyDescriptor = - Object.defineProperty && Object.getOwnPropertyDescriptor; - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) { - var desc = hasPropertyDescriptor - ? Object.getOwnPropertyDescriptor(obj, key) - : null; - if (desc && (desc.get || desc.set)) { - Object.defineProperty(newObj, key, desc); - } else { - newObj[key] = obj[key]; - } - } - } - newObj.default = obj; - if (cache) { - cache.set(obj, newObj); - } - return newObj; -} - -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -async function readConfig( - argv, - packageRootOrConfig, // Whether it needs to look into `--config` arg passed to CLI. - // It only used to read initial config. If the initial config contains - // `project` property, we don't want to read `--config` value and rather - // read individual configs for every project. - skipArgvConfigOption, - parentConfigPath, - projectIndex = Infinity -) { - let rawOptions; - let configPath = null; - - if (typeof packageRootOrConfig !== 'string') { - if (parentConfigPath) { - const parentConfigDirname = path().dirname(parentConfigPath); - rawOptions = packageRootOrConfig; - rawOptions.rootDir = rawOptions.rootDir - ? (0, _utils.replaceRootDirInPath)( - parentConfigDirname, - rawOptions.rootDir - ) - : parentConfigDirname; - } else { - throw new Error( - 'Jest: Cannot use configuration as an object without a file path.' - ); - } - } else if ((0, _utils.isJSONString)(argv.config)) { - // A JSON string was passed to `--config` argument and we can parse it - // and use as is. - let config; - - try { - config = JSON.parse(argv.config); - } catch (e) { - throw new Error( - 'There was an error while parsing the `--config` argument as a JSON string.' - ); - } // NOTE: we might need to resolve this dir to an absolute path in the future - - config.rootDir = config.rootDir || packageRootOrConfig; - rawOptions = config; // A string passed to `--config`, which is either a direct path to the config - // or a path to directory containing `package.json` or `jest.config.js` - } else if (!skipArgvConfigOption && typeof argv.config == 'string') { - configPath = (0, _resolveConfigPath.default)(argv.config, process.cwd()); - rawOptions = await (0, _readConfigFileAndSetRootDir.default)(configPath); - } else { - // Otherwise just try to find config in the current rootDir. - configPath = (0, _resolveConfigPath.default)( - packageRootOrConfig, - process.cwd() - ); - rawOptions = await (0, _readConfigFileAndSetRootDir.default)(configPath); - } - - const {options, hasDeprecationWarnings} = (0, _normalize.default)( - rawOptions, - argv, - configPath, - projectIndex - ); - const {globalConfig, projectConfig} = groupOptions(options); - return { - configPath, - globalConfig, - hasDeprecationWarnings, - projectConfig - }; -} - -const groupOptions = options => ({ - globalConfig: Object.freeze({ - bail: options.bail, - changedFilesWithAncestor: options.changedFilesWithAncestor, - changedSince: options.changedSince, - collectCoverage: options.collectCoverage, - collectCoverageFrom: options.collectCoverageFrom, - collectCoverageOnlyFrom: options.collectCoverageOnlyFrom, - coverageDirectory: options.coverageDirectory, - coverageProvider: options.coverageProvider, - coverageReporters: options.coverageReporters, - coverageThreshold: options.coverageThreshold, - detectLeaks: options.detectLeaks, - detectOpenHandles: options.detectOpenHandles, - enabledTestsMap: options.enabledTestsMap, - errorOnDeprecated: options.errorOnDeprecated, - expand: options.expand, - filter: options.filter, - findRelatedTests: options.findRelatedTests, - forceExit: options.forceExit, - globalSetup: options.globalSetup, - globalTeardown: options.globalTeardown, - json: options.json, - lastCommit: options.lastCommit, - listTests: options.listTests, - logHeapUsage: options.logHeapUsage, - maxConcurrency: options.maxConcurrency, - maxWorkers: options.maxWorkers, - noSCM: undefined, - noStackTrace: options.noStackTrace, - nonFlagArgs: options.nonFlagArgs, - notify: options.notify, - notifyMode: options.notifyMode, - onlyChanged: options.onlyChanged, - onlyFailures: options.onlyFailures, - outputFile: options.outputFile, - passWithNoTests: options.passWithNoTests, - projects: options.projects, - replname: options.replname, - reporters: options.reporters, - rootDir: options.rootDir, - runTestsByPath: options.runTestsByPath, - silent: options.silent, - skipFilter: options.skipFilter, - testFailureExitCode: options.testFailureExitCode, - testNamePattern: options.testNamePattern, - testPathPattern: options.testPathPattern, - testResultsProcessor: options.testResultsProcessor, - testSequencer: options.testSequencer, - testTimeout: options.testTimeout, - updateSnapshot: options.updateSnapshot, - useStderr: options.useStderr, - verbose: options.verbose, - watch: options.watch, - watchAll: options.watchAll, - watchPlugins: options.watchPlugins, - watchman: options.watchman - }), - projectConfig: Object.freeze({ - automock: options.automock, - browser: options.browser, - cache: options.cache, - cacheDirectory: options.cacheDirectory, - clearMocks: options.clearMocks, - coveragePathIgnorePatterns: options.coveragePathIgnorePatterns, - cwd: options.cwd, - dependencyExtractor: options.dependencyExtractor, - detectLeaks: options.detectLeaks, - detectOpenHandles: options.detectOpenHandles, - displayName: options.displayName, - errorOnDeprecated: options.errorOnDeprecated, - extraGlobals: options.extraGlobals, - filter: options.filter, - forceCoverageMatch: options.forceCoverageMatch, - globalSetup: options.globalSetup, - globalTeardown: options.globalTeardown, - globals: options.globals, - haste: options.haste, - moduleDirectories: options.moduleDirectories, - moduleFileExtensions: options.moduleFileExtensions, - moduleLoader: options.moduleLoader, - moduleNameMapper: options.moduleNameMapper, - modulePathIgnorePatterns: options.modulePathIgnorePatterns, - modulePaths: options.modulePaths, - name: options.name, - prettierPath: options.prettierPath, - resetMocks: options.resetMocks, - resetModules: options.resetModules, - resolver: options.resolver, - restoreMocks: options.restoreMocks, - rootDir: options.rootDir, - roots: options.roots, - runner: options.runner, - setupFiles: options.setupFiles, - setupFilesAfterEnv: options.setupFilesAfterEnv, - skipFilter: options.skipFilter, - skipNodeResolution: options.skipNodeResolution, - snapshotResolver: options.snapshotResolver, - snapshotSerializers: options.snapshotSerializers, - testEnvironment: options.testEnvironment, - testEnvironmentOptions: options.testEnvironmentOptions, - testLocationInResults: options.testLocationInResults, - testMatch: options.testMatch, - testPathIgnorePatterns: options.testPathIgnorePatterns, - testRegex: options.testRegex, - testRunner: options.testRunner, - testURL: options.testURL, - timers: options.timers, - transform: options.transform, - transformIgnorePatterns: options.transformIgnorePatterns, - unmockedModulePathPatterns: options.unmockedModulePathPatterns, - watchPathIgnorePatterns: options.watchPathIgnorePatterns - }) -}); - -const ensureNoDuplicateConfigs = (parsedConfigs, projects) => { - if (projects.length <= 1) { - return; - } - - const configPathMap = new Map(); - - for (const config of parsedConfigs) { - const {configPath} = config; - - if (configPathMap.has(configPath)) { - const message = `Whoops! Two projects resolved to the same config path: ${_chalk().default.bold( - String(configPath) - )}: - - Project 1: ${_chalk().default.bold( - projects[parsedConfigs.findIndex(x => x === config)] - )} - Project 2: ${_chalk().default.bold( - projects[parsedConfigs.findIndex(x => x === configPathMap.get(configPath))] - )} - -This usually means that your ${_chalk().default.bold( - '"projects"' - )} config includes a directory that doesn't have any configuration recognizable by Jest. Please fix it. -`; - throw new Error(message); - } - - if (configPath !== null) { - configPathMap.set(configPath, config); - } - } -}; // Possible scenarios: -// 1. jest --config config.json -// 2. jest --projects p1 p2 -// 3. jest --projects p1 p2 --config config.json -// 4. jest --projects p1 -// 5. jest -// -// If no projects are specified, process.cwd() will be used as the default -// (and only) project. - -async function readConfigs(argv, projectPaths) { - let globalConfig; - let hasDeprecationWarnings; - let configs = []; - let projects = projectPaths; - let configPath; - - if (projectPaths.length === 1) { - const parsedConfig = await readConfig(argv, projects[0]); - configPath = parsedConfig.configPath; - hasDeprecationWarnings = parsedConfig.hasDeprecationWarnings; - globalConfig = parsedConfig.globalConfig; - configs = [parsedConfig.projectConfig]; - - if (globalConfig.projects && globalConfig.projects.length) { - // Even though we had one project in CLI args, there might be more - // projects defined in the config. - // In other words, if this was a single project, - // and its config has `projects` settings, use that value instead. - projects = globalConfig.projects; - } - } - - if (projects.length > 0) { - const projectIsCwd = - process.platform === 'win32' - ? projects[0] === (0, _realpathNative().sync)(process.cwd()) - : projects[0] === process.cwd(); - const parsedConfigs = await Promise.all( - projects - .filter(root => { - // Ignore globbed files that cannot be `require`d. - if ( - typeof root === 'string' && - fs().existsSync(root) && - !fs().lstatSync(root).isDirectory() && - !constants.JEST_CONFIG_EXT_ORDER.some(ext => root.endsWith(ext)) - ) { - return false; - } - - return true; - }) - .map((root, projectIndex) => { - const projectIsTheOnlyProject = - projectIndex === 0 && projects.length === 1; - const skipArgvConfigOption = !( - projectIsTheOnlyProject && projectIsCwd - ); - return readConfig( - argv, - root, - skipArgvConfigOption, - configPath, - projectIndex - ); - }) - ); - ensureNoDuplicateConfigs(parsedConfigs, projects); - configs = parsedConfigs.map(({projectConfig}) => projectConfig); - - if (!hasDeprecationWarnings) { - hasDeprecationWarnings = parsedConfigs.some( - ({hasDeprecationWarnings}) => !!hasDeprecationWarnings - ); - } // If no config was passed initially, use the one from the first project - - if (!globalConfig) { - globalConfig = parsedConfigs[0].globalConfig; - } - } - - if (!globalConfig || !configs.length) { - throw new Error('jest: No configuration found for any project.'); - } - - return { - configs, - globalConfig, - hasDeprecationWarnings: !!hasDeprecationWarnings - }; -} diff --git a/node_modules/jest-config/build/normalize.d.ts b/node_modules/jest-config/build/normalize.d.ts deleted file mode 100644 index 3c9f589e..00000000 --- a/node_modules/jest-config/build/normalize.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import type { Config } from '@jest/types'; -declare type AllOptions = Config.ProjectConfig & Config.GlobalConfig; -export default function normalize(initialOptions: Config.InitialOptions, argv: Config.Argv, configPath?: Config.Path | null, projectIndex?: number): { - hasDeprecationWarnings: boolean; - options: AllOptions; -}; -export {}; -//# sourceMappingURL=normalize.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-config/build/normalize.d.ts.map b/node_modules/jest-config/build/normalize.d.ts.map deleted file mode 100644 index c21e2c41..00000000 --- a/node_modules/jest-config/build/normalize.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../src/normalize.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAkCxC,aAAK,UAAU,GAAG,MAAM,CAAC,aAAa,GAAG,MAAM,CAAC,YAAY,CAAC;AAub7D,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,cAAc,EAAE,MAAM,CAAC,cAAc,EACrC,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,UAAU,CAAC,EAAE,MAAM,CAAC,IAAI,GAAG,IAAI,EAC/B,YAAY,GAAE,MAAiB,GAC9B;IACD,sBAAsB,EAAE,OAAO,CAAC;IAChC,OAAO,EAAE,UAAU,CAAC;CACrB,CAumBA"} \ No newline at end of file diff --git a/node_modules/jest-config/build/normalize.js b/node_modules/jest-config/build/normalize.js deleted file mode 100644 index d03aa0f6..00000000 --- a/node_modules/jest-config/build/normalize.js +++ /dev/null @@ -1,1311 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.default = normalize; - -function _crypto() { - const data = require('crypto'); - - _crypto = function () { - return data; - }; - - return data; -} - -function _fs() { - const data = require('fs'); - - _fs = function () { - return data; - }; - - return data; -} - -function path() { - const data = _interopRequireWildcard(require('path')); - - path = function () { - return data; - }; - - return data; -} - -function _glob() { - const data = require('glob'); - - _glob = function () { - return data; - }; - - return data; -} - -function _jestValidate() { - const data = require('jest-validate'); - - _jestValidate = function () { - return data; - }; - - return data; -} - -function _jestUtil() { - const data = require('jest-util'); - - _jestUtil = function () { - return data; - }; - - return data; -} - -function _chalk() { - const data = _interopRequireDefault(require('chalk')); - - _chalk = function () { - return data; - }; - - return data; -} - -function _micromatch() { - const data = _interopRequireDefault(require('micromatch')); - - _micromatch = function () { - return data; - }; - - return data; -} - -function _realpathNative() { - const data = require('realpath-native'); - - _realpathNative = function () { - return data; - }; - - return data; -} - -function _jestResolve() { - const data = _interopRequireDefault(require('jest-resolve')); - - _jestResolve = function () { - return data; - }; - - return data; -} - -function _jestRegexUtil() { - const data = require('jest-regex-util'); - - _jestRegexUtil = function () { - return data; - }; - - return data; -} - -function _deepmerge() { - const data = _interopRequireDefault(require('deepmerge')); - - _deepmerge = function () { - return data; - }; - - return data; -} - -var _validatePattern = _interopRequireDefault(require('./validatePattern')); - -var _getMaxWorkers = _interopRequireDefault(require('./getMaxWorkers')); - -var _utils = require('./utils'); - -var _constants = require('./constants'); - -var _ReporterValidationErrors = require('./ReporterValidationErrors'); - -var _Defaults = _interopRequireDefault(require('./Defaults')); - -var _Deprecated = _interopRequireDefault(require('./Deprecated')); - -var _setFromArgv = _interopRequireDefault(require('./setFromArgv')); - -var _ValidConfig = _interopRequireDefault(require('./ValidConfig')); - -var _color = require('./color'); - -function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : {default: obj}; -} - -function _getRequireWildcardCache() { - if (typeof WeakMap !== 'function') return null; - var cache = new WeakMap(); - _getRequireWildcardCache = function () { - return cache; - }; - return cache; -} - -function _interopRequireWildcard(obj) { - if (obj && obj.__esModule) { - return obj; - } - if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { - return {default: obj}; - } - var cache = _getRequireWildcardCache(); - if (cache && cache.has(obj)) { - return cache.get(obj); - } - var newObj = {}; - var hasPropertyDescriptor = - Object.defineProperty && Object.getOwnPropertyDescriptor; - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) { - var desc = hasPropertyDescriptor - ? Object.getOwnPropertyDescriptor(obj, key) - : null; - if (desc && (desc.get || desc.set)) { - Object.defineProperty(newObj, key, desc); - } else { - newObj[key] = obj[key]; - } - } - } - newObj.default = obj; - if (cache) { - cache.set(obj, newObj); - } - return newObj; -} - -function ownKeys(object, enumerableOnly) { - var keys = Object.keys(object); - if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(object); - if (enumerableOnly) - symbols = symbols.filter(function (sym) { - return Object.getOwnPropertyDescriptor(object, sym).enumerable; - }); - keys.push.apply(keys, symbols); - } - return keys; -} - -function _objectSpread(target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i] != null ? arguments[i] : {}; - if (i % 2) { - ownKeys(Object(source), true).forEach(function (key) { - _defineProperty(target, key, source[key]); - }); - } else if (Object.getOwnPropertyDescriptors) { - Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); - } else { - ownKeys(Object(source)).forEach(function (key) { - Object.defineProperty( - target, - key, - Object.getOwnPropertyDescriptor(source, key) - ); - }); - } - } - return target; -} - -function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - return obj; -} - -const ERROR = `${_utils.BULLET}Validation Error`; -const PRESET_EXTENSIONS = ['.json', '.js']; -const PRESET_NAME = 'jest-preset'; - -const createConfigError = message => - new (_jestValidate().ValidationError)( - ERROR, - message, - _utils.DOCUMENTATION_NOTE - ); - -function verifyDirectoryExists(path, key) { - try { - const rootStat = (0, _fs().statSync)(path); - - if (!rootStat.isDirectory()) { - throw createConfigError( - ` ${_chalk().default.bold(path)} in the ${_chalk().default.bold( - key - )} option is not a directory.` - ); - } - } catch (err) { - if (err instanceof _jestValidate().ValidationError) { - throw err; - } - - if (err.code === 'ENOENT') { - throw createConfigError( - ` Directory ${_chalk().default.bold( - path - )} in the ${_chalk().default.bold(key)} option was not found.` - ); - } // Not sure in which cases `statSync` can throw, so let's just show the underlying error to the user - - throw createConfigError( - ` Got an error trying to find ${_chalk().default.bold( - path - )} in the ${_chalk().default.bold(key)} option.\n\n Error was: ${ - err.message - }` - ); - } -} // TS 3.5 forces us to split these into 2 - -const mergeModuleNameMapperWithPreset = (options, preset) => { - if (options['moduleNameMapper'] && preset['moduleNameMapper']) { - options['moduleNameMapper'] = _objectSpread( - {}, - options['moduleNameMapper'], - {}, - preset['moduleNameMapper'], - {}, - options['moduleNameMapper'] - ); - } -}; - -const mergeTransformWithPreset = (options, preset) => { - if (options['transform'] && preset['transform']) { - options['transform'] = _objectSpread( - {}, - options['transform'], - {}, - preset['transform'], - {}, - options['transform'] - ); - } -}; - -const mergeGlobalsWithPreset = (options, preset) => { - if (options['globals'] && preset['globals']) { - options['globals'] = (0, _deepmerge().default)( - preset['globals'], - options['globals'] - ); - } -}; - -const setupPreset = (options, optionsPreset) => { - let preset; - const presetPath = (0, _utils.replaceRootDirInPath)( - options.rootDir, - optionsPreset - ); - - const presetModule = _jestResolve().default.findNodeModule( - presetPath.startsWith('.') - ? presetPath - : path().join(presetPath, PRESET_NAME), - { - basedir: options.rootDir, - extensions: PRESET_EXTENSIONS - } - ); - - try { - // Force re-evaluation to support multiple projects - try { - if (presetModule) { - delete require.cache[require.resolve(presetModule)]; - } - } catch (e) {} // @ts-ignore: `presetModule` can be null? - - preset = require(presetModule); - } catch (error) { - if (error instanceof SyntaxError || error instanceof TypeError) { - throw createConfigError( - ` Preset ${_chalk().default.bold(presetPath)} is invalid:\n\n ${ - error.message - }\n ${error.stack}` - ); - } - - if (error.message.includes('Cannot find module')) { - if (error.message.includes(presetPath)) { - const preset = _jestResolve().default.findNodeModule(presetPath, { - basedir: options.rootDir - }); - - if (preset) { - throw createConfigError( - ` Module ${_chalk().default.bold( - presetPath - )} should have "jest-preset.js" or "jest-preset.json" file at the root.` - ); - } - - throw createConfigError( - ` Preset ${_chalk().default.bold(presetPath)} not found.` - ); - } - - throw createConfigError( - ` Missing dependency in ${_chalk().default.bold(presetPath)}:\n\n ${ - error.message - }\n ${error.stack}` - ); - } - - throw createConfigError( - ` An unknown error occurred in ${_chalk().default.bold( - presetPath - )}:\n\n ${error.message}\n ${error.stack}` - ); - } - - if (options.setupFiles) { - options.setupFiles = (preset.setupFiles || []).concat(options.setupFiles); - } - - if (options.setupFilesAfterEnv) { - options.setupFilesAfterEnv = (preset.setupFilesAfterEnv || []).concat( - options.setupFilesAfterEnv - ); - } - - if (options.modulePathIgnorePatterns && preset.modulePathIgnorePatterns) { - options.modulePathIgnorePatterns = preset.modulePathIgnorePatterns.concat( - options.modulePathIgnorePatterns - ); - } - - mergeModuleNameMapperWithPreset(options, preset); - mergeTransformWithPreset(options, preset); - mergeGlobalsWithPreset(options, preset); - return _objectSpread({}, preset, {}, options); -}; - -const setupBabelJest = options => { - const transform = options.transform; - let babelJest; - - if (transform) { - const customJSPattern = Object.keys(transform).find(pattern => { - const regex = new RegExp(pattern); - return regex.test('a.js') || regex.test('a.jsx'); - }); - const customTSPattern = Object.keys(transform).find(pattern => { - const regex = new RegExp(pattern); - return regex.test('a.ts') || regex.test('a.tsx'); - }); - [customJSPattern, customTSPattern].forEach(pattern => { - if (pattern) { - const customTransformer = transform[pattern]; - - if (Array.isArray(customTransformer)) { - if (customTransformer[0] === 'babel-jest') { - babelJest = require.resolve('babel-jest'); - customTransformer[0] = babelJest; - } else if (customTransformer[0].includes('babel-jest')) { - babelJest = customTransformer[0]; - } - } else { - if (customTransformer === 'babel-jest') { - babelJest = require.resolve('babel-jest'); - transform[pattern] = babelJest; - } else if (customTransformer.includes('babel-jest')) { - babelJest = customTransformer; - } - } - } - }); - } else { - babelJest = require.resolve('babel-jest'); - options.transform = { - [_constants.DEFAULT_JS_PATTERN]: babelJest - }; - } -}; - -const normalizeCollectCoverageOnlyFrom = (options, key) => { - const initialCollectCoverageFrom = options[key]; - const collectCoverageOnlyFrom = Array.isArray(initialCollectCoverageFrom) - ? initialCollectCoverageFrom // passed from argv - : Object.keys(initialCollectCoverageFrom); // passed from options - - return collectCoverageOnlyFrom.reduce((map, filePath) => { - filePath = path().resolve( - options.rootDir, - (0, _utils.replaceRootDirInPath)(options.rootDir, filePath) - ); - map[filePath] = true; - return map; - }, Object.create(null)); -}; - -const normalizeCollectCoverageFrom = (options, key) => { - const initialCollectCoverageFrom = options[key]; - let value; - - if (!initialCollectCoverageFrom) { - value = []; - } - - if (!Array.isArray(initialCollectCoverageFrom)) { - try { - value = JSON.parse(initialCollectCoverageFrom); - } catch (e) {} - - if (options[key] && !Array.isArray(value)) { - value = [initialCollectCoverageFrom]; - } - } else { - value = initialCollectCoverageFrom; - } - - if (value) { - value = value.map(filePath => - filePath.replace(/^(!?)(\/)(.*)/, '$1$3') - ); - } - - return value; -}; - -const normalizeUnmockedModulePathPatterns = ( - options, - key // _replaceRootDirTags is specifically well-suited for substituting -) => - // in paths (it deals with properly interpreting relative path - // separators, etc). - // - // For patterns, direct global substitution is far more ideal, so we - // special case substitutions for patterns here. - options[key].map(pattern => - (0, _jestRegexUtil().replacePathSepForRegex)( - pattern.replace(//g, options.rootDir) - ) - ); - -const normalizePreprocessor = options => { - if (options.scriptPreprocessor && options.transform) { - throw createConfigError(` Options: ${_chalk().default.bold( - 'scriptPreprocessor' - )} and ${_chalk().default.bold('transform')} cannot be used together. - Please change your configuration to only use ${_chalk().default.bold( - 'transform' - )}.`); - } - - if (options.preprocessorIgnorePatterns && options.transformIgnorePatterns) { - throw createConfigError(` Options ${_chalk().default.bold( - 'preprocessorIgnorePatterns' - )} and ${_chalk().default.bold( - 'transformIgnorePatterns' - )} cannot be used together. - Please change your configuration to only use ${_chalk().default.bold( - 'transformIgnorePatterns' - )}.`); - } - - if (options.scriptPreprocessor) { - options.transform = { - '.*': options.scriptPreprocessor - }; - } - - if (options.preprocessorIgnorePatterns) { - options.transformIgnorePatterns = options.preprocessorIgnorePatterns; - } - - delete options.scriptPreprocessor; - delete options.preprocessorIgnorePatterns; - return options; -}; - -const normalizeMissingOptions = (options, configPath, projectIndex) => { - if (!options.name) { - options.name = (0, _crypto().createHash)('md5') - .update(options.rootDir) // In case we load config from some path that has the same root dir - .update(configPath || '') - .update(String(projectIndex)) - .digest('hex'); - } - - if (!options.setupFiles) { - options.setupFiles = []; - } - - return options; -}; - -const normalizeRootDir = options => { - // Assert that there *is* a rootDir - if (!options.rootDir) { - throw createConfigError( - ` Configuration option ${_chalk().default.bold( - 'rootDir' - )} must be specified.` - ); - } - - options.rootDir = path().normalize(options.rootDir); - - try { - // try to resolve windows short paths, ignoring errors (permission errors, mostly) - options.rootDir = (0, _realpathNative().sync)(options.rootDir); - } catch (e) { - // ignored - } - - verifyDirectoryExists(options.rootDir, 'rootDir'); - return _objectSpread({}, options, { - rootDir: options.rootDir - }); -}; - -const normalizeReporters = options => { - const reporters = options.reporters; - - if (!reporters || !Array.isArray(reporters)) { - return options; - } - - (0, _ReporterValidationErrors.validateReporters)(reporters); - options.reporters = reporters.map(reporterConfig => { - const normalizedReporterConfig = - typeof reporterConfig === 'string' // if reporter config is a string, we wrap it in an array - ? // and pass an empty object for options argument, to normalize - // the shape. - [reporterConfig, {}] - : reporterConfig; - const reporterPath = (0, _utils.replaceRootDirInPath)( - options.rootDir, - normalizedReporterConfig[0] - ); - - if (reporterPath !== _constants.DEFAULT_REPORTER_LABEL) { - const reporter = _jestResolve().default.findNodeModule(reporterPath, { - basedir: options.rootDir - }); - - if (!reporter) { - throw new (_jestResolve().default.ModuleNotFoundError)( - `Could not resolve a module for a custom reporter.\n` + - ` Module name: ${reporterPath}` - ); - } - - normalizedReporterConfig[0] = reporter; - } - - return normalizedReporterConfig; - }); - return options; -}; - -const buildTestPathPattern = argv => { - const patterns = []; - - if (argv._) { - patterns.push(...argv._); - } - - if (argv.testPathPattern) { - patterns.push(...argv.testPathPattern); - } - - const replacePosixSep = pattern => { - // yargs coerces positional args into numbers - const patternAsString = pattern.toString(); - - if (path().sep === '/') { - return patternAsString; - } - - return patternAsString.replace(/\//g, '\\\\'); - }; - - const testPathPattern = patterns.map(replacePosixSep).join('|'); - - if ((0, _validatePattern.default)(testPathPattern)) { - return testPathPattern; - } else { - showTestPathPatternError(testPathPattern); - return ''; - } -}; - -const showTestPathPatternError = testPathPattern => { - (0, _jestUtil().clearLine)(process.stdout); - console.log( - _chalk().default.red( - ` Invalid testPattern ${testPathPattern} supplied. ` + - `Running all tests instead.` - ) - ); -}; - -function normalize(initialOptions, argv, configPath, projectIndex = Infinity) { - const {hasDeprecationWarnings} = (0, _jestValidate().validate)( - initialOptions, - { - comment: _utils.DOCUMENTATION_NOTE, - deprecatedConfig: _Deprecated.default, - exampleConfig: _ValidConfig.default, - recursiveBlacklist: [ - 'collectCoverageOnlyFrom', // 'coverageThreshold' allows to use 'global' and glob strings on the same - // level, there's currently no way we can deal with such config - 'coverageThreshold', - 'globals', - 'moduleNameMapper', - 'testEnvironmentOptions', - 'transform' - ] - } - ); - let options = normalizePreprocessor( - normalizeReporters( - normalizeMissingOptions( - normalizeRootDir((0, _setFromArgv.default)(initialOptions, argv)), - configPath, - projectIndex - ) - ) - ); - - if (options.preset) { - options = setupPreset(options, options.preset); - } - - if (!options.setupFilesAfterEnv) { - options.setupFilesAfterEnv = []; - } - - if ( - options.setupTestFrameworkScriptFile && - options.setupFilesAfterEnv.length > 0 - ) { - throw createConfigError(` Options: ${_chalk().default.bold( - 'setupTestFrameworkScriptFile' - )} and ${_chalk().default.bold( - 'setupFilesAfterEnv' - )} cannot be used together. - Please change your configuration to only use ${_chalk().default.bold( - 'setupFilesAfterEnv' - )}.`); - } - - if (options.setupTestFrameworkScriptFile) { - options.setupFilesAfterEnv.push(options.setupTestFrameworkScriptFile); - } - - options.testEnvironment = (0, _utils.getTestEnvironment)({ - rootDir: options.rootDir, - testEnvironment: - options.testEnvironment || _Defaults.default.testEnvironment - }); - - if (!options.roots && options.testPathDirs) { - options.roots = options.testPathDirs; - delete options.testPathDirs; - } - - if (!options.roots) { - options.roots = [options.rootDir]; - } - - if (!options.testRunner || options.testRunner === 'jasmine2') { - options.testRunner = require.resolve('jest-jasmine2'); - } - - if (!options.coverageDirectory) { - options.coverageDirectory = path().resolve(options.rootDir, 'coverage'); - } - - setupBabelJest(options); // TODO: Type this properly - - const newOptions = _objectSpread({}, _Defaults.default); - - if (options.resolver) { - newOptions.resolver = (0, _utils.resolve)(null, { - filePath: options.resolver, - key: 'resolver', - rootDir: options.rootDir - }); - } - - const optionKeys = Object.keys(options); - optionKeys.reduce((newOptions, key) => { - // The resolver has been resolved separately; skip it - if (key === 'resolver') { - return newOptions; - } // This is cheating, because it claims that all keys of InitialOptions are Required. - // We only really know it's Required for oldOptions[key], not for oldOptions.someOtherKey, - // so oldOptions[key] is the only way it should be used. - - const oldOptions = options; - let value; - - switch (key) { - case 'collectCoverageOnlyFrom': - value = normalizeCollectCoverageOnlyFrom(oldOptions, key); - break; - - case 'setupFiles': - case 'setupFilesAfterEnv': - case 'snapshotSerializers': - { - const option = oldOptions[key]; - value = - option && - option.map(filePath => - (0, _utils.resolve)(newOptions.resolver, { - filePath, - key, - rootDir: options.rootDir - }) - ); - } - break; - - case 'modulePaths': - case 'roots': - { - const option = oldOptions[key]; - value = - option && - option.map(filePath => - path().resolve( - options.rootDir, - (0, _utils.replaceRootDirInPath)(options.rootDir, filePath) - ) - ); - } - break; - - case 'collectCoverageFrom': - value = normalizeCollectCoverageFrom(oldOptions, key); - break; - - case 'cacheDirectory': - case 'coverageDirectory': - { - const option = oldOptions[key]; - value = - option && - path().resolve( - options.rootDir, - (0, _utils.replaceRootDirInPath)(options.rootDir, option) - ); - } - break; - - case 'dependencyExtractor': - case 'globalSetup': - case 'globalTeardown': - case 'moduleLoader': - case 'snapshotResolver': - case 'testResultsProcessor': - case 'testRunner': - case 'filter': - { - const option = oldOptions[key]; - value = - option && - (0, _utils.resolve)(newOptions.resolver, { - filePath: option, - key, - rootDir: options.rootDir - }); - } - break; - - case 'runner': - { - const option = oldOptions[key]; - value = - option && - (0, _utils.getRunner)(newOptions.resolver, { - filePath: option, - rootDir: options.rootDir - }); - } - break; - - case 'prettierPath': - { - // We only want this to throw if "prettierPath" is explicitly passed - // from config or CLI, and the requested path isn't found. Otherwise we - // set it to null and throw an error lazily when it is used. - const option = oldOptions[key]; - value = - option && - (0, _utils.resolve)(newOptions.resolver, { - filePath: option, - key, - optional: option === _Defaults.default[key], - rootDir: options.rootDir - }); - } - break; - - case 'moduleNameMapper': - const moduleNameMapper = oldOptions[key]; - value = - moduleNameMapper && - Object.keys(moduleNameMapper).map(regex => { - const item = moduleNameMapper && moduleNameMapper[regex]; - return ( - item && [ - regex, - (0, _utils._replaceRootDirTags)(options.rootDir, item) - ] - ); - }); - break; - - case 'transform': - const transform = oldOptions[key]; - value = - transform && - Object.keys(transform).map(regex => { - const transformElement = transform[regex]; - return [ - regex, - (0, _utils.resolve)(newOptions.resolver, { - filePath: Array.isArray(transformElement) - ? transformElement[0] - : transformElement, - key, - rootDir: options.rootDir - }), - Array.isArray(transformElement) ? transformElement[1] : {} - ]; - }); - break; - - case 'coveragePathIgnorePatterns': - case 'modulePathIgnorePatterns': - case 'testPathIgnorePatterns': - case 'transformIgnorePatterns': - case 'watchPathIgnorePatterns': - case 'unmockedModulePathPatterns': - value = normalizeUnmockedModulePathPatterns(oldOptions, key); - break; - - case 'haste': - value = _objectSpread({}, oldOptions[key]); - - if (value.hasteImplModulePath != null) { - const resolvedHasteImpl = (0, _utils.resolve)(newOptions.resolver, { - filePath: (0, _utils.replaceRootDirInPath)( - options.rootDir, - value.hasteImplModulePath - ), - key: 'haste.hasteImplModulePath', - rootDir: options.rootDir - }); - value.hasteImplModulePath = resolvedHasteImpl || undefined; - } - - break; - - case 'projects': - value = (oldOptions[key] || []) - .map(project => - typeof project === 'string' - ? (0, _utils._replaceRootDirTags)(options.rootDir, project) - : project - ) - .reduce((projects, project) => { - // Project can be specified as globs. If a glob matches any files, - // We expand it to these paths. If not, we keep the original path - // for the future resolution. - const globMatches = - typeof project === 'string' ? (0, _glob().sync)(project) : []; - return projects.concat(globMatches.length ? globMatches : project); - }, []); - break; - - case 'moduleDirectories': - case 'testMatch': - { - const replacedRootDirTags = (0, _utils._replaceRootDirTags)( - (0, _utils.escapeGlobCharacters)(options.rootDir), - oldOptions[key] - ); - - if (replacedRootDirTags) { - value = Array.isArray(replacedRootDirTags) - ? replacedRootDirTags.map(_jestUtil().replacePathSepForGlob) - : (0, _jestUtil().replacePathSepForGlob)(replacedRootDirTags); - } else { - value = replacedRootDirTags; - } - } - break; - - case 'testRegex': - { - const option = oldOptions[key]; - value = option - ? (Array.isArray(option) ? option : [option]).map( - _jestRegexUtil().replacePathSepForRegex - ) - : []; - } - break; - - case 'moduleFileExtensions': { - value = oldOptions[key]; - - if ( - Array.isArray(value) && // If it's the wrong type, it can throw at a later time - (options.runner === undefined || - options.runner === _Defaults.default.runner) && // Only require 'js' for the default jest-runner - !value.includes('js') - ) { - const errorMessage = - ` moduleFileExtensions must include 'js':\n` + - ` but instead received:\n` + - ` ${_chalk().default.bold.red(JSON.stringify(value))}`; // If `js` is not included, any dependency Jest itself injects into - // the environment, like jasmine or sourcemap-support, will need to - // `require` its modules with a file extension. This is not plausible - // in the long run, so it's way easier to just fail hard early. - // We might consider throwing if `json` is missing as well, as it's a - // fair assumption from modules that they can do - // `require('some-package/package') without the trailing `.json` as it - // works in Node normally. - - throw createConfigError( - errorMessage + - "\n Please change your configuration to include 'js'." - ); - } - - break; - } - - case 'bail': { - const bail = oldOptions[key]; - - if (typeof bail === 'boolean') { - value = bail ? 1 : 0; - } else if (typeof bail === 'string') { - value = 1; // If Jest is invoked as `jest --bail someTestPattern` then need to - // move the pattern from the `bail` configuration and into `argv._` - // to be processed as an extra parameter - - argv._.push(bail); - } else { - value = oldOptions[key]; - } - - break; - } - - case 'displayName': { - const displayName = oldOptions[key]; - /** - * Ensuring that displayName shape is correct here so that the - * reporters can trust the shape of the data - */ - - if (typeof displayName === 'object') { - const {name, color} = displayName; - - if ( - !name || - !color || - typeof name !== 'string' || - typeof color !== 'string' - ) { - const errorMessage = - ` Option "${_chalk().default.bold( - 'displayName' - )}" must be of type:\n\n` + - ' {\n' + - ' name: string;\n' + - ' color: string;\n' + - ' }\n'; - throw createConfigError(errorMessage); - } - - value = oldOptions[key]; - } else { - value = { - color: (0, _color.getDisplayNameColor)(options.runner), - name: displayName - }; - } - - break; - } - - case 'testTimeout': { - if (oldOptions[key] < 0) { - throw createConfigError( - ` Option "${_chalk().default.bold( - 'testTimeout' - )}" must be a natural number.` - ); - } - - value = oldOptions[key]; - break; - } - - case 'automock': - case 'browser': - case 'cache': - case 'changedSince': - case 'changedFilesWithAncestor': - case 'clearMocks': - case 'collectCoverage': - case 'coverageProvider': - case 'coverageReporters': - case 'coverageThreshold': - case 'detectLeaks': - case 'detectOpenHandles': - case 'errorOnDeprecated': - case 'expand': - case 'extraGlobals': - case 'globals': - case 'findRelatedTests': - case 'forceCoverageMatch': - case 'forceExit': - case 'lastCommit': - case 'listTests': - case 'logHeapUsage': - case 'maxConcurrency': - case 'mapCoverage': - case 'name': - case 'noStackTrace': - case 'notify': - case 'notifyMode': - case 'onlyChanged': - case 'outputFile': - case 'passWithNoTests': - case 'replname': - case 'reporters': - case 'resetMocks': - case 'resetModules': - case 'restoreMocks': - case 'rootDir': - case 'runTestsByPath': - case 'silent': - case 'skipFilter': - case 'skipNodeResolution': - case 'testEnvironment': - case 'testEnvironmentOptions': - case 'testFailureExitCode': - case 'testLocationInResults': - case 'testNamePattern': - case 'testURL': - case 'timers': - case 'useStderr': - case 'verbose': - case 'watch': - case 'watchAll': - case 'watchman': - value = oldOptions[key]; - break; - - case 'watchPlugins': - value = (oldOptions[key] || []).map(watchPlugin => { - if (typeof watchPlugin === 'string') { - return { - config: {}, - path: (0, _utils.getWatchPlugin)(newOptions.resolver, { - filePath: watchPlugin, - rootDir: options.rootDir - }) - }; - } else { - return { - config: watchPlugin[1] || {}, - path: (0, _utils.getWatchPlugin)(newOptions.resolver, { - filePath: watchPlugin[0], - rootDir: options.rootDir - }) - }; - } - }); - break; - } // @ts-ignore: automock is missing in GlobalConfig, so what - - newOptions[key] = value; - return newOptions; - }, newOptions); - newOptions.roots.forEach((root, i) => { - verifyDirectoryExists(root, `roots[${i}]`); - }); - - try { - // try to resolve windows short paths, ignoring errors (permission errors, mostly) - newOptions.cwd = (0, _realpathNative().sync)(process.cwd()); - } catch (e) { - // ignored - } - - newOptions.testSequencer = (0, _utils.getSequencer)(newOptions.resolver, { - filePath: options.testSequencer || _Defaults.default.testSequencer, - rootDir: options.rootDir - }); - newOptions.nonFlagArgs = argv._; - newOptions.testPathPattern = buildTestPathPattern(argv); - newOptions.json = !!argv.json; - newOptions.testFailureExitCode = parseInt(newOptions.testFailureExitCode, 10); - - if ( - newOptions.lastCommit || - newOptions.changedFilesWithAncestor || - newOptions.changedSince - ) { - newOptions.onlyChanged = true; - } - - if (argv.all) { - newOptions.onlyChanged = false; - } else if (newOptions.testPathPattern) { - // When passing a test path pattern we don't want to only monitor changed - // files unless `--watch` is also passed. - newOptions.onlyChanged = newOptions.watch; - } - - if (!newOptions.onlyChanged) { - newOptions.onlyChanged = false; - } - - if (!newOptions.lastCommit) { - newOptions.lastCommit = false; - } - - if (!newOptions.onlyFailures) { - newOptions.onlyFailures = false; - } - - if (!newOptions.watchAll) { - newOptions.watchAll = false; - } // as any since it can happen. We really need to fix the types here - - if (newOptions.moduleNameMapper === _Defaults.default.moduleNameMapper) { - newOptions.moduleNameMapper = []; - } - - newOptions.updateSnapshot = - argv.ci && !argv.updateSnapshot - ? 'none' - : argv.updateSnapshot - ? 'all' - : 'new'; - newOptions.maxConcurrency = parseInt(newOptions.maxConcurrency, 10); - newOptions.maxWorkers = (0, _getMaxWorkers.default)(argv, options); - - if (newOptions.testRegex.length && options.testMatch) { - throw createConfigError( - ` Configuration options ${_chalk().default.bold('testMatch')} and` + - ` ${_chalk().default.bold('testRegex')} cannot be used together.` - ); - } - - if (newOptions.testRegex.length && !options.testMatch) { - // Prevent the default testMatch conflicting with any explicitly - // configured `testRegex` value - newOptions.testMatch = []; - } // If argv.json is set, coverageReporters shouldn't print a text report. - - if (argv.json) { - newOptions.coverageReporters = (newOptions.coverageReporters || []).filter( - reporter => reporter !== 'text' - ); - } // If collectCoverage is enabled while using --findRelatedTests we need to - // avoid having false negatives in the generated coverage report. - // The following: `--findRelatedTests '/rootDir/file1.js' --coverage` - // Is transformed to: `--findRelatedTests '/rootDir/file1.js' --coverage --collectCoverageFrom 'file1.js'` - // where arguments to `--collectCoverageFrom` should be globs (or relative - // paths to the rootDir) - - if (newOptions.collectCoverage && argv.findRelatedTests) { - let collectCoverageFrom = argv._.map(filename => { - filename = (0, _utils.replaceRootDirInPath)(options.rootDir, filename); - return path().isAbsolute(filename) - ? path().relative(options.rootDir, filename) - : filename; - }); // Don't override existing collectCoverageFrom options - - if (newOptions.collectCoverageFrom) { - collectCoverageFrom = collectCoverageFrom.reduce((patterns, filename) => { - if ( - (0, _micromatch().default)( - [ - (0, _jestUtil().replacePathSepForGlob)( - path().relative(options.rootDir, filename) - ) - ], - newOptions.collectCoverageFrom - ).length === 0 - ) { - return patterns; - } - - return [...patterns, filename]; - }, newOptions.collectCoverageFrom); - } - - newOptions.collectCoverageFrom = collectCoverageFrom; - } else if (!newOptions.collectCoverageFrom) { - newOptions.collectCoverageFrom = []; - } - - if (!newOptions.findRelatedTests) { - newOptions.findRelatedTests = false; - } - - if (!newOptions.projects) { - newOptions.projects = []; - } - - if (!newOptions.extraGlobals) { - newOptions.extraGlobals = []; - } - - if (!newOptions.forceExit) { - newOptions.forceExit = false; - } - - if (!newOptions.logHeapUsage) { - newOptions.logHeapUsage = false; - } - - return { - hasDeprecationWarnings, - options: newOptions - }; -} diff --git a/node_modules/jest-config/build/readConfigFileAndSetRootDir.d.ts b/node_modules/jest-config/build/readConfigFileAndSetRootDir.d.ts deleted file mode 100644 index 63894f31..00000000 --- a/node_modules/jest-config/build/readConfigFileAndSetRootDir.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import type { Config } from '@jest/types'; -export default function readConfigFileAndSetRootDir(configPath: Config.Path): Promise; -//# sourceMappingURL=readConfigFileAndSetRootDir.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-config/build/readConfigFileAndSetRootDir.d.ts.map b/node_modules/jest-config/build/readConfigFileAndSetRootDir.d.ts.map deleted file mode 100644 index 13c4c4ae..00000000 --- a/node_modules/jest-config/build/readConfigFileAndSetRootDir.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"readConfigFileAndSetRootDir.d.ts","sourceRoot":"","sources":["../src/readConfigFileAndSetRootDir.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAUxC,wBAA8B,2BAA2B,CACvD,UAAU,EAAE,MAAM,CAAC,IAAI,GACtB,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CA0DhC"} \ No newline at end of file diff --git a/node_modules/jest-config/build/readConfigFileAndSetRootDir.js b/node_modules/jest-config/build/readConfigFileAndSetRootDir.js deleted file mode 100644 index f53e1d27..00000000 --- a/node_modules/jest-config/build/readConfigFileAndSetRootDir.js +++ /dev/null @@ -1,157 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.default = readConfigFileAndSetRootDir; - -function path() { - const data = _interopRequireWildcard(require('path')); - - path = function () { - return data; - }; - - return data; -} - -function fs() { - const data = _interopRequireWildcard(require('fs')); - - fs = function () { - return data; - }; - - return data; -} - -var _jsonlint = _interopRequireDefault(require('./vendor/jsonlint')); - -var _constants = require('./constants'); - -function _importEsm() { - const data = _interopRequireDefault(require('./importEsm')); - - _importEsm = function () { - return data; - }; - - return data; -} - -function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : {default: obj}; -} - -function _getRequireWildcardCache() { - if (typeof WeakMap !== 'function') return null; - var cache = new WeakMap(); - _getRequireWildcardCache = function () { - return cache; - }; - return cache; -} - -function _interopRequireWildcard(obj) { - if (obj && obj.__esModule) { - return obj; - } - if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { - return {default: obj}; - } - var cache = _getRequireWildcardCache(); - if (cache && cache.has(obj)) { - return cache.get(obj); - } - var newObj = {}; - var hasPropertyDescriptor = - Object.defineProperty && Object.getOwnPropertyDescriptor; - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) { - var desc = hasPropertyDescriptor - ? Object.getOwnPropertyDescriptor(obj, key) - : null; - if (desc && (desc.get || desc.set)) { - Object.defineProperty(newObj, key, desc); - } else { - newObj[key] = obj[key]; - } - } - } - newObj.default = obj; - if (cache) { - cache.set(obj, newObj); - } - return newObj; -} - -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -// @ts-ignore: vendored -// Read the configuration and set its `rootDir` -// 1. If it's a `package.json` file, we look into its "jest" property -// 2. For any other file, we just require it. If we receive an 'ERR_REQUIRE_ESM' -// from node, perform a dynamic import instead. -async function readConfigFileAndSetRootDir(configPath) { - const isJSON = configPath.endsWith(_constants.JEST_CONFIG_EXT_JSON); - let configObject; - - try { - configObject = require(configPath); - } catch (error) { - if (error.code === 'ERR_REQUIRE_ESM') { - try { - const importedConfig = await (0, _importEsm().default)(configPath); - - if (!importedConfig.default) { - throw new Error( - `Jest: Failed to load mjs config file ${configPath} - did you use a default export?` - ); - } - - configObject = importedConfig.default; - } catch (innerError) { - if (innerError.message === 'Not supported') { - throw new Error( - `Jest: Your version of Node does not support dynamic import - please enable it or use a .cjs file extension for file ${configPath}` - ); - } - - throw innerError; - } - } else if (isJSON) { - throw new Error( - `Jest: Failed to parse config file ${configPath}\n` + - ` ${_jsonlint.default.errors(fs().readFileSync(configPath, 'utf8'))}` - ); - } else { - throw error; - } - } - - if (configPath.endsWith(_constants.PACKAGE_JSON)) { - // Event if there's no "jest" property in package.json we will still use - // an empty object. - configObject = configObject.jest || {}; - } - - if (configObject.rootDir) { - // We don't touch it if it has an absolute path specified - if (!path().isAbsolute(configObject.rootDir)) { - // otherwise, we'll resolve it relative to the file's __dirname - configObject.rootDir = path().resolve( - path().dirname(configPath), - configObject.rootDir - ); - } - } else { - // If rootDir is not there, we'll set it to this file's __dirname - configObject.rootDir = path().dirname(configPath); - } - - return configObject; -} diff --git a/node_modules/jest-config/build/resolveConfigPath.d.ts b/node_modules/jest-config/build/resolveConfigPath.d.ts deleted file mode 100644 index 8fae01c1..00000000 --- a/node_modules/jest-config/build/resolveConfigPath.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -declare const _default: (pathToResolve: string, cwd: string) => string; -export default _default; -//# sourceMappingURL=resolveConfigPath.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-config/build/resolveConfigPath.d.ts.map b/node_modules/jest-config/build/resolveConfigPath.d.ts.map deleted file mode 100644 index 201df955..00000000 --- a/node_modules/jest-config/build/resolveConfigPath.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"resolveConfigPath.d.ts","sourceRoot":"","sources":["../src/resolveConfigPath.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAgBH,wBA+BE"} \ No newline at end of file diff --git a/node_modules/jest-config/build/resolveConfigPath.js b/node_modules/jest-config/build/resolveConfigPath.js deleted file mode 100644 index c54bdf7b..00000000 --- a/node_modules/jest-config/build/resolveConfigPath.js +++ /dev/null @@ -1,153 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.default = void 0; - -function path() { - const data = _interopRequireWildcard(require('path')); - - path = function () { - return data; - }; - - return data; -} - -function fs() { - const data = _interopRequireWildcard(require('fs')); - - fs = function () { - return data; - }; - - return data; -} - -var _constants = require('./constants'); - -function _getRequireWildcardCache() { - if (typeof WeakMap !== 'function') return null; - var cache = new WeakMap(); - _getRequireWildcardCache = function () { - return cache; - }; - return cache; -} - -function _interopRequireWildcard(obj) { - if (obj && obj.__esModule) { - return obj; - } - if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { - return {default: obj}; - } - var cache = _getRequireWildcardCache(); - if (cache && cache.has(obj)) { - return cache.get(obj); - } - var newObj = {}; - var hasPropertyDescriptor = - Object.defineProperty && Object.getOwnPropertyDescriptor; - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) { - var desc = hasPropertyDescriptor - ? Object.getOwnPropertyDescriptor(obj, key) - : null; - if (desc && (desc.get || desc.set)) { - Object.defineProperty(newObj, key, desc); - } else { - newObj[key] = obj[key]; - } - } - } - newObj.default = obj; - if (cache) { - cache.set(obj, newObj); - } - return newObj; -} - -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -const isFile = filePath => - fs().existsSync(filePath) && !fs().lstatSync(filePath).isDirectory(); - -const getConfigFilename = ext => _constants.JEST_CONFIG_BASE_NAME + ext; - -var _default = (pathToResolve, cwd) => { - if (!path().isAbsolute(cwd)) { - throw new Error(`"cwd" must be an absolute path. cwd: ${cwd}`); - } - - const absolutePath = path().isAbsolute(pathToResolve) - ? pathToResolve - : path().resolve(cwd, pathToResolve); - - if (isFile(absolutePath)) { - return absolutePath; - } // This is a guard against passing non existing path as a project/config, - // that will otherwise result in a very confusing situation. - // e.g. - // With a directory structure like this: - // my_project/ - // packcage.json - // - // Passing a `my_project/some_directory_that_doesnt_exist` as a project - // name will resolve into a (possibly empty) `my_project/package.json` and - // try to run all tests it finds under `my_project` directory. - - if (!fs().existsSync(absolutePath)) { - throw new Error( - `Can't find a root directory while resolving a config file path.\n` + - `Provided path to resolve: ${pathToResolve}\n` + - `cwd: ${cwd}` - ); - } - - return resolveConfigPathByTraversing(absolutePath, pathToResolve, cwd); -}; - -exports.default = _default; - -const resolveConfigPathByTraversing = (pathToResolve, initialPath, cwd) => { - const jestConfig = _constants.JEST_CONFIG_EXT_ORDER.map(ext => - path().resolve(pathToResolve, getConfigFilename(ext)) - ).find(isFile); - - if (jestConfig) { - return jestConfig; - } - - const packageJson = path().resolve(pathToResolve, _constants.PACKAGE_JSON); - - if (isFile(packageJson)) { - return packageJson; - } // This is the system root. - // We tried everything, config is nowhere to be found Β―\_(ツ)_/Β― - - if (pathToResolve === path().dirname(pathToResolve)) { - throw new Error(makeResolutionErrorMessage(initialPath, cwd)); - } // go up a level and try it again - - return resolveConfigPathByTraversing( - path().dirname(pathToResolve), - initialPath, - cwd - ); -}; - -const makeResolutionErrorMessage = (initialPath, cwd) => - 'Could not find a config file based on provided values:\n' + - `path: "${initialPath}"\n` + - `cwd: "${cwd}"\n` + - 'Config paths must be specified by either a direct path to a config\n' + - 'file, or a path to a directory. If directory is given, Jest will try to\n' + - `traverse directory tree up, until it finds one of those files in exact order: ${_constants.JEST_CONFIG_EXT_ORDER.map( - ext => `"${getConfigFilename(ext)}"` - ).join(' or ')}.`; diff --git a/node_modules/jest-config/build/setFromArgv.d.ts b/node_modules/jest-config/build/setFromArgv.d.ts deleted file mode 100644 index 771bace1..00000000 --- a/node_modules/jest-config/build/setFromArgv.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import type { Config } from '@jest/types'; -export default function setFromArgv(options: Config.InitialOptions, argv: Config.Argv): Config.InitialOptions; -//# sourceMappingURL=setFromArgv.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-config/build/setFromArgv.d.ts.map b/node_modules/jest-config/build/setFromArgv.d.ts.map deleted file mode 100644 index 1bf3d7cc..00000000 --- a/node_modules/jest-config/build/setFromArgv.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"setFromArgv.d.ts","sourceRoot":"","sources":["../src/setFromArgv.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAKxC,MAAM,CAAC,OAAO,UAAU,WAAW,CACjC,OAAO,EAAE,MAAM,CAAC,cAAc,EAC9B,IAAI,EAAE,MAAM,CAAC,IAAI,GAChB,MAAM,CAAC,cAAc,CAyCvB"} \ No newline at end of file diff --git a/node_modules/jest-config/build/setFromArgv.js b/node_modules/jest-config/build/setFromArgv.js deleted file mode 100644 index b56749e9..00000000 --- a/node_modules/jest-config/build/setFromArgv.js +++ /dev/null @@ -1,119 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.default = setFromArgv; - -var _utils = require('./utils'); - -function ownKeys(object, enumerableOnly) { - var keys = Object.keys(object); - if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(object); - if (enumerableOnly) - symbols = symbols.filter(function (sym) { - return Object.getOwnPropertyDescriptor(object, sym).enumerable; - }); - keys.push.apply(keys, symbols); - } - return keys; -} - -function _objectSpread(target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i] != null ? arguments[i] : {}; - if (i % 2) { - ownKeys(Object(source), true).forEach(function (key) { - _defineProperty(target, key, source[key]); - }); - } else if (Object.getOwnPropertyDescriptors) { - Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); - } else { - ownKeys(Object(source)).forEach(function (key) { - Object.defineProperty( - target, - key, - Object.getOwnPropertyDescriptor(source, key) - ); - }); - } - } - return target; -} - -function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - return obj; -} - -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -const specialArgs = ['_', '$0', 'h', 'help', 'config']; - -function setFromArgv(options, argv) { - const argvToOptions = Object.keys(argv) - .filter(key => argv[key] !== undefined && specialArgs.indexOf(key) === -1) - .reduce((options, key) => { - switch (key) { - case 'coverage': - options.collectCoverage = argv[key]; - break; - - case 'json': - options.useStderr = argv[key]; - break; - - case 'watchAll': - options.watch = false; - options.watchAll = argv[key]; - break; - - case 'env': - options.testEnvironment = argv[key]; - break; - - case 'config': - break; - - case 'coverageThreshold': - case 'globals': - case 'moduleNameMapper': - case 'transform': - case 'haste': - const str = argv[key]; - - if ((0, _utils.isJSONString)(str)) { - options[key] = JSON.parse(str); - } - - break; - - default: - options[key] = argv[key]; - } - - return options; - }, {}); - return _objectSpread( - {}, - options, - {}, - (0, _utils.isJSONString)(argv.config) ? JSON.parse(argv.config) : null, - {}, - argvToOptions - ); -} diff --git a/node_modules/jest-config/build/ts3.4/Defaults.d.ts b/node_modules/jest-config/build/ts3.4/Defaults.d.ts deleted file mode 100644 index 10f2c5bd..00000000 --- a/node_modules/jest-config/build/ts3.4/Defaults.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import { Config } from '@jest/types'; -declare const defaultOptions: Config.DefaultOptions; -export default defaultOptions; -//# sourceMappingURL=Defaults.d.ts.map diff --git a/node_modules/jest-config/build/ts3.4/Deprecated.d.ts b/node_modules/jest-config/build/ts3.4/Deprecated.d.ts deleted file mode 100644 index dbbe690e..00000000 --- a/node_modules/jest-config/build/ts3.4/Deprecated.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -declare const _default: Record; -export default _default; -//# sourceMappingURL=Deprecated.d.ts.map diff --git a/node_modules/jest-config/build/ts3.4/Descriptions.d.ts b/node_modules/jest-config/build/ts3.4/Descriptions.d.ts deleted file mode 100644 index eb6305e4..00000000 --- a/node_modules/jest-config/build/ts3.4/Descriptions.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import { Config } from '@jest/types'; -declare const descriptions: { - [key in keyof Config.InitialOptions]: string; -}; -export default descriptions; -//# sourceMappingURL=Descriptions.d.ts.map diff --git a/node_modules/jest-config/build/ts3.4/ReporterValidationErrors.d.ts b/node_modules/jest-config/build/ts3.4/ReporterValidationErrors.d.ts deleted file mode 100644 index a640431a..00000000 --- a/node_modules/jest-config/build/ts3.4/ReporterValidationErrors.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import { Config } from '@jest/types'; -import { ValidationError } from 'jest-validate'; -/** - * Reporter Validation Error is thrown if the given arguments - * within the reporter are not valid. - * - * This is a highly specific reporter error and in the future will be - * merged with jest-validate. Till then, we can make use of it. It works - * and that's what counts most at this time. - */ -export declare function createReporterError(reporterIndex: number, reporterValue: Array | string): ValidationError; -export declare function createArrayReporterError(arrayReporter: Config.ReporterConfig, reporterIndex: number, valueIndex: number, value: string | Record, expectedType: string, valueName: string): ValidationError; -export declare function validateReporters(reporterConfig: Array): boolean; -//# sourceMappingURL=ReporterValidationErrors.d.ts.map diff --git a/node_modules/jest-config/build/ts3.4/ValidConfig.d.ts b/node_modules/jest-config/build/ts3.4/ValidConfig.d.ts deleted file mode 100644 index bdbaec7e..00000000 --- a/node_modules/jest-config/build/ts3.4/ValidConfig.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import { Config } from '@jest/types'; -declare const initialOptions: Config.InitialOptions; -export default initialOptions; -//# sourceMappingURL=ValidConfig.d.ts.map diff --git a/node_modules/jest-config/build/ts3.4/color.d.ts b/node_modules/jest-config/build/ts3.4/color.d.ts deleted file mode 100644 index 34dda4f6..00000000 --- a/node_modules/jest-config/build/ts3.4/color.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -export declare const getDisplayNameColor: (seed?: string | undefined) => "hex" | "bold" | "reset" | "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "grey" | "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright" | "bgBlack" | "bgRed" | "bgGreen" | "bgYellow" | "bgBlue" | "bgMagenta" | "bgCyan" | "bgWhite" | "bgGray" | "bgGrey" | "bgBlackBright" | "bgRedBright" | "bgGreenBright" | "bgYellowBright" | "bgBlueBright" | "bgMagentaBright" | "bgCyanBright" | "bgWhiteBright" | "dim" | "italic" | "underline" | "inverse" | "hidden" | "strikethrough" | "visible" | "Instance" | "level" | "keyword" | "rgb" | "hsl" | "hsv" | "hwb" | "ansi" | "ansi256" | "bgHex" | "bgKeyword" | "bgRgb" | "bgHsl" | "bgHsv" | "bgHwb" | "bgAnsi" | "bgAnsi256" | "supportsColor" | "Level" | "Color" | "ForegroundColor" | "BackgroundColor" | "Modifiers" | "stderr"; -//# sourceMappingURL=color.d.ts.map diff --git a/node_modules/jest-config/build/ts3.4/constants.d.ts b/node_modules/jest-config/build/ts3.4/constants.d.ts deleted file mode 100644 index b91db2a0..00000000 --- a/node_modules/jest-config/build/ts3.4/constants.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -export declare const NODE_MODULES: string; -export declare const DEFAULT_JS_PATTERN = "^.+\\.[jt]sx?$"; -export declare const DEFAULT_REPORTER_LABEL = "default"; -export declare const PACKAGE_JSON = "package.json"; -export declare const JEST_CONFIG_BASE_NAME = "jest.config"; -export declare const JEST_CONFIG_EXT_CJS = ".cjs"; -export declare const JEST_CONFIG_EXT_MJS = ".mjs"; -export declare const JEST_CONFIG_EXT_JS = ".js"; -export declare const JEST_CONFIG_EXT_JSON = ".json"; -export declare const JEST_CONFIG_EXT_ORDER: readonly string[]; -//# sourceMappingURL=constants.d.ts.map diff --git a/node_modules/jest-config/build/ts3.4/getCacheDirectory.d.ts b/node_modules/jest-config/build/ts3.4/getCacheDirectory.d.ts deleted file mode 100644 index 64c14cbf..00000000 --- a/node_modules/jest-config/build/ts3.4/getCacheDirectory.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -declare const getCacheDirectory: () => string; -export default getCacheDirectory; -//# sourceMappingURL=getCacheDirectory.d.ts.map diff --git a/node_modules/jest-config/build/ts3.4/getMaxWorkers.d.ts b/node_modules/jest-config/build/ts3.4/getMaxWorkers.d.ts deleted file mode 100644 index 9f767213..00000000 --- a/node_modules/jest-config/build/ts3.4/getMaxWorkers.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import { Config } from '@jest/types'; -export default function getMaxWorkers(argv: Partial>, defaultOptions?: Partial>): number; -//# sourceMappingURL=getMaxWorkers.d.ts.map diff --git a/node_modules/jest-config/build/ts3.4/importEsm.d.ts b/node_modules/jest-config/build/ts3.4/importEsm.d.ts deleted file mode 100644 index 353f5d2f..00000000 --- a/node_modules/jest-config/build/ts3.4/importEsm.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -declare const _default: (specifier: string) => Promise<{ - default: unknown; -}>; -export default _default; -//# sourceMappingURL=importEsm.d.ts.map diff --git a/node_modules/jest-config/build/ts3.4/index.d.ts b/node_modules/jest-config/build/ts3.4/index.d.ts deleted file mode 100644 index cbf8c947..00000000 --- a/node_modules/jest-config/build/ts3.4/index.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import { Config } from '@jest/types'; -export { getTestEnvironment, isJSONString } from './utils'; -export { default as normalize } from './normalize'; -export { default as deprecationEntries } from './Deprecated'; -export { replaceRootDirInPath } from './utils'; -export { default as defaults } from './Defaults'; -export { default as descriptions } from './Descriptions'; -import * as constants from './constants'; -export { constants }; -declare type ReadConfig = { - configPath: Config.Path | null | undefined; - globalConfig: Config.GlobalConfig; - hasDeprecationWarnings: boolean; - projectConfig: Config.ProjectConfig; -}; -export declare function readConfig(argv: Config.Argv, packageRootOrConfig: Config.Path | Config.InitialOptions, skipArgvConfigOption?: boolean, parentConfigPath?: Config.Path | null, projectIndex?: number): Promise; -export declare function readConfigs(argv: Config.Argv, projectPaths: Array): Promise<{ - globalConfig: Config.GlobalConfig; - configs: Array; - hasDeprecationWarnings: boolean; -}>; -//# sourceMappingURL=index.d.ts.map diff --git a/node_modules/jest-config/build/ts3.4/normalize.d.ts b/node_modules/jest-config/build/ts3.4/normalize.d.ts deleted file mode 100644 index 9dc65e81..00000000 --- a/node_modules/jest-config/build/ts3.4/normalize.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import { Config } from '@jest/types'; -declare type AllOptions = Config.ProjectConfig & Config.GlobalConfig; -export default function normalize(initialOptions: Config.InitialOptions, argv: Config.Argv, configPath?: Config.Path | null, projectIndex?: number): { - hasDeprecationWarnings: boolean; - options: AllOptions; -}; -export {}; -//# sourceMappingURL=normalize.d.ts.map diff --git a/node_modules/jest-config/build/ts3.4/readConfigFileAndSetRootDir.d.ts b/node_modules/jest-config/build/ts3.4/readConfigFileAndSetRootDir.d.ts deleted file mode 100644 index cd8bf733..00000000 --- a/node_modules/jest-config/build/ts3.4/readConfigFileAndSetRootDir.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import { Config } from '@jest/types'; -export default function readConfigFileAndSetRootDir(configPath: Config.Path): Promise; -//# sourceMappingURL=readConfigFileAndSetRootDir.d.ts.map diff --git a/node_modules/jest-config/build/ts3.4/resolveConfigPath.d.ts b/node_modules/jest-config/build/ts3.4/resolveConfigPath.d.ts deleted file mode 100644 index ae835471..00000000 --- a/node_modules/jest-config/build/ts3.4/resolveConfigPath.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -declare const _default: (pathToResolve: string, cwd: string) => string; -export default _default; -//# sourceMappingURL=resolveConfigPath.d.ts.map diff --git a/node_modules/jest-config/build/ts3.4/setFromArgv.d.ts b/node_modules/jest-config/build/ts3.4/setFromArgv.d.ts deleted file mode 100644 index 9c2e952f..00000000 --- a/node_modules/jest-config/build/ts3.4/setFromArgv.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import { Config } from '@jest/types'; -export default function setFromArgv(options: Config.InitialOptions, argv: Config.Argv): Config.InitialOptions; -//# sourceMappingURL=setFromArgv.d.ts.map diff --git a/node_modules/jest-config/build/ts3.4/utils.d.ts b/node_modules/jest-config/build/ts3.4/utils.d.ts deleted file mode 100644 index 955ac2f8..00000000 --- a/node_modules/jest-config/build/ts3.4/utils.d.ts +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import { Config } from '@jest/types'; -declare type ResolveOptions = { - rootDir: Config.Path; - key: string; - filePath: Config.Path; - optional?: boolean; -}; -export declare const BULLET: string; -export declare const DOCUMENTATION_NOTE: string; -export declare const resolve: (resolver: string | null | undefined, { key, filePath, rootDir, optional }: ResolveOptions) => string; -export declare const escapeGlobCharacters: (path: string) => string; -export declare const replaceRootDirInPath: (rootDir: string, filePath: string) => string; -declare type OrArray = T | Array; -declare type ReplaceRootDirConfigObj = Record; -declare type ReplaceRootDirConfigValues = OrArray | OrArray | OrArray; -export declare const _replaceRootDirTags: (rootDir: string, config: T) => T; -export declare const resolveWithPrefix: (resolver: string | null | undefined, { filePath, humanOptionName, optionName, prefix, rootDir, }: { - filePath: string; - humanOptionName: string; - optionName: string; - prefix: string; - rootDir: string; -}) => string; -/** - * Finds the test environment to use: - * - * 1. looks for jest-environment- relative to project. - * 1. looks for jest-environment- relative to Jest. - * 1. looks for relative to project. - * 1. looks for relative to Jest. - */ -export declare const getTestEnvironment: ({ rootDir, testEnvironment: filePath, }: { - rootDir: string; - testEnvironment: string; -}) => string; -/** - * Finds the watch plugins to use: - * - * 1. looks for jest-watch- relative to project. - * 1. looks for jest-watch- relative to Jest. - * 1. looks for relative to project. - * 1. looks for relative to Jest. - */ -export declare const getWatchPlugin: (resolver: string | null | undefined, { filePath, rootDir }: { - filePath: string; - rootDir: string; -}) => string; -/** - * Finds the runner to use: - * - * 1. looks for jest-runner- relative to project. - * 1. looks for jest-runner- relative to Jest. - * 1. looks for relative to project. - * 1. looks for relative to Jest. - */ -export declare const getRunner: (resolver: string | null | undefined, { filePath, rootDir }: { - filePath: string; - rootDir: string; -}) => string; -declare type JSONString = string & { - readonly $$type: never; -}; -export declare const isJSONString: (text?: string | JSONString | undefined) => text is JSONString; -export declare const getSequencer: (resolver: string | null | undefined, { filePath, rootDir }: { - filePath: string; - rootDir: string; -}) => string; -export {}; -//# sourceMappingURL=utils.d.ts.map diff --git a/node_modules/jest-config/build/ts3.4/validatePattern.d.ts b/node_modules/jest-config/build/ts3.4/validatePattern.d.ts deleted file mode 100644 index 5d38b434..00000000 --- a/node_modules/jest-config/build/ts3.4/validatePattern.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -export default function validatePattern(pattern?: string): boolean; -//# sourceMappingURL=validatePattern.d.ts.map diff --git a/node_modules/jest-config/build/utils.d.ts b/node_modules/jest-config/build/utils.d.ts deleted file mode 100644 index a48c9e05..00000000 --- a/node_modules/jest-config/build/utils.d.ts +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import type { Config } from '@jest/types'; -declare type ResolveOptions = { - rootDir: Config.Path; - key: string; - filePath: Config.Path; - optional?: boolean; -}; -export declare const BULLET: string; -export declare const DOCUMENTATION_NOTE: string; -export declare const resolve: (resolver: string | null | undefined, { key, filePath, rootDir, optional }: ResolveOptions) => string; -export declare const escapeGlobCharacters: (path: string) => string; -export declare const replaceRootDirInPath: (rootDir: string, filePath: string) => string; -declare type OrArray = T | Array; -declare type ReplaceRootDirConfigObj = Record; -declare type ReplaceRootDirConfigValues = OrArray | OrArray | OrArray; -export declare const _replaceRootDirTags: (rootDir: string, config: T) => T; -export declare const resolveWithPrefix: (resolver: string | null | undefined, { filePath, humanOptionName, optionName, prefix, rootDir, }: { - filePath: string; - humanOptionName: string; - optionName: string; - prefix: string; - rootDir: string; -}) => string; -/** - * Finds the test environment to use: - * - * 1. looks for jest-environment- relative to project. - * 1. looks for jest-environment- relative to Jest. - * 1. looks for relative to project. - * 1. looks for relative to Jest. - */ -export declare const getTestEnvironment: ({ rootDir, testEnvironment: filePath, }: { - rootDir: string; - testEnvironment: string; -}) => string; -/** - * Finds the watch plugins to use: - * - * 1. looks for jest-watch- relative to project. - * 1. looks for jest-watch- relative to Jest. - * 1. looks for relative to project. - * 1. looks for relative to Jest. - */ -export declare const getWatchPlugin: (resolver: string | null | undefined, { filePath, rootDir }: { - filePath: string; - rootDir: string; -}) => string; -/** - * Finds the runner to use: - * - * 1. looks for jest-runner- relative to project. - * 1. looks for jest-runner- relative to Jest. - * 1. looks for relative to project. - * 1. looks for relative to Jest. - */ -export declare const getRunner: (resolver: string | null | undefined, { filePath, rootDir }: { - filePath: string; - rootDir: string; -}) => string; -declare type JSONString = string & { - readonly $$type: never; -}; -export declare const isJSONString: (text?: string | JSONString | undefined) => text is JSONString; -export declare const getSequencer: (resolver: string | null | undefined, { filePath, rootDir }: { - filePath: string; - rootDir: string; -}) => string; -export {}; -//# sourceMappingURL=utils.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-config/build/utils.d.ts.map b/node_modules/jest-config/build/utils.d.ts.map deleted file mode 100644 index a5aacbf6..00000000 --- a/node_modules/jest-config/build/utils.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAKxC,aAAK,cAAc,GAAG;IACpB,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,MAA8B,CAAC;AACpD,eAAO,MAAM,kBAAkB,QAI9B,CAAC;AAKF,eAAO,MAAM,OAAO,uGAsBnB,CAAC;AAEF,eAAO,MAAM,oBAAoB,0BACW,CAAC;AAE7C,eAAO,MAAM,oBAAoB,+CAYhC,CAAC;AAgBF,aAAK,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;AAC/B,aAAK,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;AAC3D,aAAK,0BAA0B,GAC3B,OAAO,CAAC,uBAAuB,CAAC,GAChC,OAAO,CAAC,MAAM,CAAC,GACf,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAEzB,eAAO,MAAM,mBAAmB,yEAyB/B,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;YAgD7B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB;;;YAa3B,CAAC;AAEL;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc;;;YAUvB,CAAC;AAEL;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS;;;YAUlB,CAAC;AAEL,aAAK,UAAU,GAAG,MAAM,GAAG;IAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAA;CAAC,CAAC;AACpD,eAAO,MAAM,YAAY,gEAIL,CAAC;AAErB,eAAO,MAAM,YAAY;;;YAUrB,CAAC"} \ No newline at end of file diff --git a/node_modules/jest-config/build/utils.js b/node_modules/jest-config/build/utils.js deleted file mode 100644 index 0be254a3..00000000 --- a/node_modules/jest-config/build/utils.js +++ /dev/null @@ -1,313 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.getSequencer = exports.isJSONString = exports.getRunner = exports.getWatchPlugin = exports.getTestEnvironment = exports.resolveWithPrefix = exports._replaceRootDirTags = exports.replaceRootDirInPath = exports.escapeGlobCharacters = exports.resolve = exports.DOCUMENTATION_NOTE = exports.BULLET = void 0; - -function path() { - const data = _interopRequireWildcard(require('path')); - - path = function () { - return data; - }; - - return data; -} - -function _jestValidate() { - const data = require('jest-validate'); - - _jestValidate = function () { - return data; - }; - - return data; -} - -function _jestResolve() { - const data = _interopRequireDefault(require('jest-resolve')); - - _jestResolve = function () { - return data; - }; - - return data; -} - -function _chalk() { - const data = _interopRequireDefault(require('chalk')); - - _chalk = function () { - return data; - }; - - return data; -} - -function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : {default: obj}; -} - -function _getRequireWildcardCache() { - if (typeof WeakMap !== 'function') return null; - var cache = new WeakMap(); - _getRequireWildcardCache = function () { - return cache; - }; - return cache; -} - -function _interopRequireWildcard(obj) { - if (obj && obj.__esModule) { - return obj; - } - if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { - return {default: obj}; - } - var cache = _getRequireWildcardCache(); - if (cache && cache.has(obj)) { - return cache.get(obj); - } - var newObj = {}; - var hasPropertyDescriptor = - Object.defineProperty && Object.getOwnPropertyDescriptor; - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) { - var desc = hasPropertyDescriptor - ? Object.getOwnPropertyDescriptor(obj, key) - : null; - if (desc && (desc.get || desc.set)) { - Object.defineProperty(newObj, key, desc); - } else { - newObj[key] = obj[key]; - } - } - } - newObj.default = obj; - if (cache) { - cache.set(obj, newObj); - } - return newObj; -} - -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -const BULLET = _chalk().default.bold('\u25cf '); - -exports.BULLET = BULLET; -const DOCUMENTATION_NOTE = ` ${_chalk().default.bold( - 'Configuration Documentation:' -)} - https://jestjs.io/docs/configuration.html -`; -exports.DOCUMENTATION_NOTE = DOCUMENTATION_NOTE; - -const createValidationError = message => - new (_jestValidate().ValidationError)( - `${BULLET}Validation Error`, - message, - DOCUMENTATION_NOTE - ); - -const resolve = (resolver, {key, filePath, rootDir, optional}) => { - const module = _jestResolve().default.findNodeModule( - replaceRootDirInPath(rootDir, filePath), - { - basedir: rootDir, - resolver: resolver || undefined - } - ); - - if (!module && !optional) { - throw createValidationError(` Module ${_chalk().default.bold( - filePath - )} in the ${_chalk().default.bold(key)} option was not found. - ${_chalk().default.bold('')} is: ${rootDir}`); - } /// can cast as string since nulls will be thrown - - return module; -}; - -exports.resolve = resolve; - -const escapeGlobCharacters = path => path.replace(/([()*{}\[\]!?\\])/g, '\\$1'); - -exports.escapeGlobCharacters = escapeGlobCharacters; - -const replaceRootDirInPath = (rootDir, filePath) => { - if (!/^/.test(filePath)) { - return filePath; - } - - return path().resolve( - rootDir, - path().normalize('./' + filePath.substr(''.length)) - ); -}; - -exports.replaceRootDirInPath = replaceRootDirInPath; - -const _replaceRootDirInObject = (rootDir, config) => { - const newConfig = {}; - - for (const configKey in config) { - newConfig[configKey] = - configKey === 'rootDir' - ? config[configKey] - : _replaceRootDirTags(rootDir, config[configKey]); - } - - return newConfig; -}; - -const _replaceRootDirTags = (rootDir, config) => { - if (config == null) { - return config; - } - - switch (typeof config) { - case 'object': - if (Array.isArray(config)) { - /// can be string[] or {}[] - return config.map(item => _replaceRootDirTags(rootDir, item)); - } - - if (config instanceof RegExp) { - return config; - } - - return _replaceRootDirInObject(rootDir, config); - - case 'string': - return replaceRootDirInPath(rootDir, config); - } - - return config; -}; - -exports._replaceRootDirTags = _replaceRootDirTags; - -const resolveWithPrefix = ( - resolver, - {filePath, humanOptionName, optionName, prefix, rootDir} -) => { - const fileName = replaceRootDirInPath(rootDir, filePath); - - let module = _jestResolve().default.findNodeModule(`${prefix}${fileName}`, { - basedir: rootDir, - resolver: resolver || undefined - }); - - if (module) { - return module; - } - - try { - return require.resolve(`${prefix}${fileName}`); - } catch (e) {} - - module = _jestResolve().default.findNodeModule(fileName, { - basedir: rootDir, - resolver: resolver || undefined - }); - - if (module) { - return module; - } - - try { - return require.resolve(fileName); - } catch (e) {} - - throw createValidationError( - ` ${humanOptionName} ${_chalk().default.bold( - fileName - )} cannot be found. Make sure the ${_chalk().default.bold( - optionName - )} configuration option points to an existing node module.` - ); -}; -/** - * Finds the test environment to use: - * - * 1. looks for jest-environment- relative to project. - * 1. looks for jest-environment- relative to Jest. - * 1. looks for relative to project. - * 1. looks for relative to Jest. - */ - -exports.resolveWithPrefix = resolveWithPrefix; - -const getTestEnvironment = ({rootDir, testEnvironment: filePath}) => - resolveWithPrefix(undefined, { - filePath, - humanOptionName: 'Test environment', - optionName: 'testEnvironment', - prefix: 'jest-environment-', - rootDir - }); -/** - * Finds the watch plugins to use: - * - * 1. looks for jest-watch- relative to project. - * 1. looks for jest-watch- relative to Jest. - * 1. looks for relative to project. - * 1. looks for relative to Jest. - */ - -exports.getTestEnvironment = getTestEnvironment; - -const getWatchPlugin = (resolver, {filePath, rootDir}) => - resolveWithPrefix(resolver, { - filePath, - humanOptionName: 'Watch plugin', - optionName: 'watchPlugins', - prefix: 'jest-watch-', - rootDir - }); -/** - * Finds the runner to use: - * - * 1. looks for jest-runner- relative to project. - * 1. looks for jest-runner- relative to Jest. - * 1. looks for relative to project. - * 1. looks for relative to Jest. - */ - -exports.getWatchPlugin = getWatchPlugin; - -const getRunner = (resolver, {filePath, rootDir}) => - resolveWithPrefix(resolver, { - filePath, - humanOptionName: 'Jest Runner', - optionName: 'runner', - prefix: 'jest-runner-', - rootDir - }); - -exports.getRunner = getRunner; - -// newtype -const isJSONString = text => - text != null && - typeof text === 'string' && - text.startsWith('{') && - text.endsWith('}'); - -exports.isJSONString = isJSONString; - -const getSequencer = (resolver, {filePath, rootDir}) => - resolveWithPrefix(resolver, { - filePath, - humanOptionName: 'Jest Sequencer', - optionName: 'testSequencer', - prefix: 'jest-sequencer-', - rootDir - }); - -exports.getSequencer = getSequencer; diff --git a/node_modules/jest-config/build/validatePattern.d.ts b/node_modules/jest-config/build/validatePattern.d.ts deleted file mode 100644 index 92bc7f13..00000000 --- a/node_modules/jest-config/build/validatePattern.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -export default function validatePattern(pattern?: string): boolean; -//# sourceMappingURL=validatePattern.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-config/build/validatePattern.d.ts.map b/node_modules/jest-config/build/validatePattern.d.ts.map deleted file mode 100644 index eb1de382..00000000 --- a/node_modules/jest-config/build/validatePattern.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"validatePattern.d.ts","sourceRoot":"","sources":["../src/validatePattern.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAWjE"} \ No newline at end of file diff --git a/node_modules/jest-config/build/validatePattern.js b/node_modules/jest-config/build/validatePattern.js deleted file mode 100644 index 36ef2a0c..00000000 --- a/node_modules/jest-config/build/validatePattern.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.default = validatePattern; - -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -function validatePattern(pattern) { - if (pattern) { - try { - // eslint-disable-next-line no-new - new RegExp(pattern, 'i'); - } catch (e) { - return false; - } - } - - return true; -} diff --git a/node_modules/jest-config/build/vendor/jsonlint.js b/node_modules/jest-config/build/vendor/jsonlint.js deleted file mode 100644 index 93399c56..00000000 --- a/node_modules/jest-config/build/vendor/jsonlint.js +++ /dev/null @@ -1,917 +0,0 @@ -'use strict'; - -// From: https://github.com/zaach/jsonlint -// Vendored in Jest to avoid jsonlint's transitive dependencies. - -/* eslint-disable */ -var jsonlint = (function () { - var parser = { - trace: function trace() {}, - yy: {}, - symbols_: { - error: 2, - JSONString: 3, - STRING: 4, - JSONNumber: 5, - NUMBER: 6, - JSONNullLiteral: 7, - NULL: 8, - JSONBooleanLiteral: 9, - TRUE: 10, - FALSE: 11, - JSONText: 12, - JSONValue: 13, - EOF: 14, - JSONObject: 15, - JSONArray: 16, - '{': 17, - '}': 18, - JSONMemberList: 19, - JSONMember: 20, - ':': 21, - ',': 22, - '[': 23, - ']': 24, - JSONElementList: 25, - $accept: 0, - $end: 1 - }, - terminals_: { - 2: 'error', - 4: 'STRING', - 6: 'NUMBER', - 8: 'NULL', - 10: 'TRUE', - 11: 'FALSE', - 14: 'EOF', - 17: '{', - 18: '}', - 21: ':', - 22: ',', - 23: '[', - 24: ']' - }, - productions_: [ - 0, - [3, 1], - [5, 1], - [7, 1], - [9, 1], - [9, 1], - [12, 2], - [13, 1], - [13, 1], - [13, 1], - [13, 1], - [13, 1], - [13, 1], - [15, 2], - [15, 3], - [20, 3], - [19, 1], - [19, 3], - [16, 2], - [16, 3], - [25, 1], - [25, 3] - ], - performAction: function anonymous( - yytext, - yyleng, - yylineno, - yy, - yystate, - $$, - _$ - ) { - var $0 = $$.length - 1; - - switch (yystate) { - case 1: - // replace escaped characters with actual character - this.$ = yytext - .replace(/\\(\\|")/g, '$' + '1') - .replace(/\\n/g, '\n') - .replace(/\\r/g, '\r') - .replace(/\\t/g, '\t') - .replace(/\\v/g, '\v') - .replace(/\\f/g, '\f') - .replace(/\\b/g, '\b'); - break; - - case 2: - this.$ = Number(yytext); - break; - - case 3: - this.$ = null; - break; - - case 4: - this.$ = true; - break; - - case 5: - this.$ = false; - break; - - case 6: - return (this.$ = $$[$0 - 1]); - break; - - case 13: - this.$ = {}; - break; - - case 14: - this.$ = $$[$0 - 1]; - break; - - case 15: - this.$ = [$$[$0 - 2], $$[$0]]; - break; - - case 16: - this.$ = {}; - this.$[$$[$0][0]] = $$[$0][1]; - break; - - case 17: - this.$ = $$[$0 - 2]; - $$[$0 - 2][$$[$0][0]] = $$[$0][1]; - break; - - case 18: - this.$ = []; - break; - - case 19: - this.$ = $$[$0 - 1]; - break; - - case 20: - this.$ = [$$[$0]]; - break; - - case 21: - this.$ = $$[$0 - 2]; - $$[$0 - 2].push($$[$0]); - break; - } - }, - table: [ - { - 3: 5, - 4: [1, 12], - 5: 6, - 6: [1, 13], - 7: 3, - 8: [1, 9], - 9: 4, - 10: [1, 10], - 11: [1, 11], - 12: 1, - 13: 2, - 15: 7, - 16: 8, - 17: [1, 14], - 23: [1, 15] - }, - { - 1: [3] - }, - { - 14: [1, 16] - }, - { - 14: [2, 7], - 18: [2, 7], - 22: [2, 7], - 24: [2, 7] - }, - { - 14: [2, 8], - 18: [2, 8], - 22: [2, 8], - 24: [2, 8] - }, - { - 14: [2, 9], - 18: [2, 9], - 22: [2, 9], - 24: [2, 9] - }, - { - 14: [2, 10], - 18: [2, 10], - 22: [2, 10], - 24: [2, 10] - }, - { - 14: [2, 11], - 18: [2, 11], - 22: [2, 11], - 24: [2, 11] - }, - { - 14: [2, 12], - 18: [2, 12], - 22: [2, 12], - 24: [2, 12] - }, - { - 14: [2, 3], - 18: [2, 3], - 22: [2, 3], - 24: [2, 3] - }, - { - 14: [2, 4], - 18: [2, 4], - 22: [2, 4], - 24: [2, 4] - }, - { - 14: [2, 5], - 18: [2, 5], - 22: [2, 5], - 24: [2, 5] - }, - { - 14: [2, 1], - 18: [2, 1], - 21: [2, 1], - 22: [2, 1], - 24: [2, 1] - }, - { - 14: [2, 2], - 18: [2, 2], - 22: [2, 2], - 24: [2, 2] - }, - { - 3: 20, - 4: [1, 12], - 18: [1, 17], - 19: 18, - 20: 19 - }, - { - 3: 5, - 4: [1, 12], - 5: 6, - 6: [1, 13], - 7: 3, - 8: [1, 9], - 9: 4, - 10: [1, 10], - 11: [1, 11], - 13: 23, - 15: 7, - 16: 8, - 17: [1, 14], - 23: [1, 15], - 24: [1, 21], - 25: 22 - }, - { - 1: [2, 6] - }, - { - 14: [2, 13], - 18: [2, 13], - 22: [2, 13], - 24: [2, 13] - }, - { - 18: [1, 24], - 22: [1, 25] - }, - { - 18: [2, 16], - 22: [2, 16] - }, - { - 21: [1, 26] - }, - { - 14: [2, 18], - 18: [2, 18], - 22: [2, 18], - 24: [2, 18] - }, - { - 22: [1, 28], - 24: [1, 27] - }, - { - 22: [2, 20], - 24: [2, 20] - }, - { - 14: [2, 14], - 18: [2, 14], - 22: [2, 14], - 24: [2, 14] - }, - { - 3: 20, - 4: [1, 12], - 20: 29 - }, - { - 3: 5, - 4: [1, 12], - 5: 6, - 6: [1, 13], - 7: 3, - 8: [1, 9], - 9: 4, - 10: [1, 10], - 11: [1, 11], - 13: 30, - 15: 7, - 16: 8, - 17: [1, 14], - 23: [1, 15] - }, - { - 14: [2, 19], - 18: [2, 19], - 22: [2, 19], - 24: [2, 19] - }, - { - 3: 5, - 4: [1, 12], - 5: 6, - 6: [1, 13], - 7: 3, - 8: [1, 9], - 9: 4, - 10: [1, 10], - 11: [1, 11], - 13: 31, - 15: 7, - 16: 8, - 17: [1, 14], - 23: [1, 15] - }, - { - 18: [2, 17], - 22: [2, 17] - }, - { - 18: [2, 15], - 22: [2, 15] - }, - { - 22: [2, 21], - 24: [2, 21] - } - ], - defaultActions: { - 16: [2, 6] - }, - parseError: function parseError(str, hash) { - throw new Error(str); - }, - parse: function parse(input) { - var self = this, - stack = [0], - vstack = [null], - // semantic value stack - lstack = [], - // location stack - table = this.table, - yytext = '', - yylineno = 0, - yyleng = 0, - recovering = 0, - TERROR = 2, - EOF = 1; //this.reductionCount = this.shiftCount = 0; - - this.lexer.setInput(input); - this.lexer.yy = this.yy; - this.yy.lexer = this.lexer; - if (typeof this.lexer.yylloc == 'undefined') this.lexer.yylloc = {}; - var yyloc = this.lexer.yylloc; - lstack.push(yyloc); - if (typeof this.yy.parseError === 'function') - this.parseError = this.yy.parseError; - - function popStack(n) { - stack.length = stack.length - 2 * n; - vstack.length = vstack.length - n; - lstack.length = lstack.length - n; - } - - function lex() { - var token; - token = self.lexer.lex() || 1; // $end = 1 - // if token isn't its numeric value, convert - - if (typeof token !== 'number') { - token = self.symbols_[token] || token; - } - - return token; - } - - var symbol, - preErrorSymbol, - state, - action, - a, - r, - yyval = {}, - p, - len, - newState, - expected; - - while (true) { - // retrieve state number from top of stack - state = stack[stack.length - 1]; // use default actions if available - - if (this.defaultActions[state]) { - action = this.defaultActions[state]; - } else { - if (symbol == null) symbol = lex(); // read action for current state and first input - - action = table[state] && table[state][symbol]; - } // handle parse error - - _handle_error: if ( - typeof action === 'undefined' || - !action.length || - !action[0] - ) { - if (!recovering) { - // Report error - expected = []; - - for (p in table[state]) - if (this.terminals_[p] && p > 2) { - expected.push("'" + this.terminals_[p] + "'"); - } - - var errStr = ''; - - if (this.lexer.showPosition) { - errStr = - 'Parse error on line ' + - (yylineno + 1) + - ':\n' + - this.lexer.showPosition() + - '\nExpecting ' + - expected.join(', ') + - ", got '" + - this.terminals_[symbol] + - "'"; - } else { - errStr = - 'Parse error on line ' + - (yylineno + 1) + - ': Unexpected ' + - (symbol == 1 - ? /*EOF*/ - 'end of input' - : "'" + (this.terminals_[symbol] || symbol) + "'"); - } - - this.parseError(errStr, { - text: this.lexer.match, - token: this.terminals_[symbol] || symbol, - line: this.lexer.yylineno, - loc: yyloc, - expected: expected - }); - } // just recovered from another error - - if (recovering == 3) { - if (symbol == EOF) { - throw new Error(errStr || 'Parsing halted.'); - } // discard current lookahead and grab another - - yyleng = this.lexer.yyleng; - yytext = this.lexer.yytext; - yylineno = this.lexer.yylineno; - yyloc = this.lexer.yylloc; - symbol = lex(); - } // try to recover from error - - while (1) { - // check for error recovery rule in this state - if (TERROR.toString() in table[state]) { - break; - } - - if (state == 0) { - throw new Error(errStr || 'Parsing halted.'); - } - - popStack(1); - state = stack[stack.length - 1]; - } - - preErrorSymbol = symbol; // save the lookahead token - - symbol = TERROR; // insert generic error symbol as new lookahead - - state = stack[stack.length - 1]; - action = table[state] && table[state][TERROR]; - recovering = 3; // allow 3 real symbols to be shifted before reporting a new error - } // this shouldn't happen, unless resolve defaults are off - - if (action[0] instanceof Array && action.length > 1) { - throw new Error( - 'Parse Error: multiple actions possible at state: ' + - state + - ', token: ' + - symbol - ); - } - - switch (action[0]) { - case 1: - // shift - //this.shiftCount++; - stack.push(symbol); - vstack.push(this.lexer.yytext); - lstack.push(this.lexer.yylloc); - stack.push(action[1]); // push state - - symbol = null; - - if (!preErrorSymbol) { - // normal execution/no error - yyleng = this.lexer.yyleng; - yytext = this.lexer.yytext; - yylineno = this.lexer.yylineno; - yyloc = this.lexer.yylloc; - if (recovering > 0) recovering--; - } else { - // error just occurred, resume old lookahead f/ before error - symbol = preErrorSymbol; - preErrorSymbol = null; - } - - break; - - case 2: - // reduce - //this.reductionCount++; - len = this.productions_[action[1]][1]; // perform semantic action - - yyval.$ = vstack[vstack.length - len]; // default to $$ = $1 - // default location, uses first token for firsts, last for lasts - - yyval._$ = { - first_line: lstack[lstack.length - (len || 1)].first_line, - last_line: lstack[lstack.length - 1].last_line, - first_column: lstack[lstack.length - (len || 1)].first_column, - last_column: lstack[lstack.length - 1].last_column - }; - r = this.performAction.call( - yyval, - yytext, - yyleng, - yylineno, - this.yy, - action[1], - vstack, - lstack - ); - - if (typeof r !== 'undefined') { - return r; - } // pop off stack - - if (len) { - stack = stack.slice(0, -1 * len * 2); - vstack = vstack.slice(0, -1 * len); - lstack = lstack.slice(0, -1 * len); - } - - stack.push(this.productions_[action[1]][0]); // push nonterminal (reduce) - - vstack.push(yyval.$); - lstack.push(yyval._$); // goto new state = table[STATE][NONTERMINAL] - - newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; - stack.push(newState); - break; - - case 3: - // accept - return true; - } - } - - return true; - } - }; - /* Jison generated lexer */ - - var lexer = (function () { - var lexer = { - EOF: 1, - parseError: function parseError(str, hash) { - if (this.yy.parseError) { - this.yy.parseError(str, hash); - } else { - throw new Error(str); - } - }, - setInput: function (input) { - this._input = input; - this._more = this._less = this.done = false; - this.yylineno = this.yyleng = 0; - this.yytext = this.matched = this.match = ''; - this.conditionStack = ['INITIAL']; - this.yylloc = { - first_line: 1, - first_column: 0, - last_line: 1, - last_column: 0 - }; - return this; - }, - input: function () { - var ch = this._input[0]; - this.yytext += ch; - this.yyleng++; - this.match += ch; - this.matched += ch; - var lines = ch.match(/\n/); - if (lines) this.yylineno++; - this._input = this._input.slice(1); - return ch; - }, - unput: function (ch) { - this._input = ch + this._input; - return this; - }, - more: function () { - this._more = true; - return this; - }, - less: function (n) { - this._input = this.match.slice(n) + this._input; - }, - pastInput: function () { - var past = this.matched.substr( - 0, - this.matched.length - this.match.length - ); - return ( - (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\n/g, '') - ); - }, - upcomingInput: function () { - var next = this.match; - - if (next.length < 20) { - next += this._input.substr(0, 20 - next.length); - } - - return (next.substr(0, 20) + (next.length > 20 ? '...' : '')).replace( - /\n/g, - '' - ); - }, - showPosition: function () { - var pre = this.pastInput(); - var c = new Array(pre.length + 1).join('-'); - return pre + this.upcomingInput() + '\n' + c + '^'; - }, - next: function () { - if (this.done) { - return this.EOF; - } - - if (!this._input) this.done = true; - var token, match, tempMatch, index, col, lines; - - if (!this._more) { - this.yytext = ''; - this.match = ''; - } - - var rules = this._currentRules(); - - for (var i = 0; i < rules.length; i++) { - tempMatch = this._input.match(this.rules[rules[i]]); - - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (!this.options.flex) break; - } - } - - if (match) { - lines = match[0].match(/\n.*/g); - if (lines) this.yylineno += lines.length; - this.yylloc = { - first_line: this.yylloc.last_line, - last_line: this.yylineno + 1, - first_column: this.yylloc.last_column, - last_column: lines - ? lines[lines.length - 1].length - 1 - : this.yylloc.last_column + match[0].length - }; - this.yytext += match[0]; - this.match += match[0]; - this.yyleng = this.yytext.length; - this._more = false; - this._input = this._input.slice(match[0].length); - this.matched += match[0]; - token = this.performAction.call( - this, - this.yy, - this, - rules[index], - this.conditionStack[this.conditionStack.length - 1] - ); - if (this.done && this._input) this.done = false; - if (token) return token; - else return; - } - - if (this._input === '') { - return this.EOF; - } else { - this.parseError( - 'Lexical error on line ' + - (this.yylineno + 1) + - '. Unrecognized text.\n' + - this.showPosition(), - { - text: '', - token: null, - line: this.yylineno - } - ); - } - }, - lex: function lex() { - var r = this.next(); - - if (typeof r !== 'undefined') { - return r; - } else { - return this.lex(); - } - }, - begin: function begin(condition) { - this.conditionStack.push(condition); - }, - popState: function popState() { - return this.conditionStack.pop(); - }, - _currentRules: function _currentRules() { - return this.conditions[ - this.conditionStack[this.conditionStack.length - 1] - ].rules; - }, - topState: function () { - return this.conditionStack[this.conditionStack.length - 2]; - }, - pushState: function begin(condition) { - this.begin(condition); - } - }; - lexer.options = {}; - - lexer.performAction = function anonymous( - yy, - yy_, - $avoiding_name_collisions, - YY_START - ) { - var YYSTATE = YY_START; - - switch ($avoiding_name_collisions) { - case 0: - /* skip whitespace */ - break; - - case 1: - return 6; - break; - - case 2: - yy_.yytext = yy_.yytext.substr(1, yy_.yyleng - 2); - return 4; - break; - - case 3: - return 17; - break; - - case 4: - return 18; - break; - - case 5: - return 23; - break; - - case 6: - return 24; - break; - - case 7: - return 22; - break; - - case 8: - return 21; - break; - - case 9: - return 10; - break; - - case 10: - return 11; - break; - - case 11: - return 8; - break; - - case 12: - return 14; - break; - - case 13: - return 'INVALID'; - break; - } - }; - - lexer.rules = [ - /^(?:\s+)/, - /^(?:(-?([0-9]|[1-9][0-9]+))(\.[0-9]+)?([eE][-+]?[0-9]+)?\b)/, - /^(?:"(?:\\[\\"bfnrt/]|\\u[a-fA-F0-9]{4}|[^\\\0-\x09\x0a-\x1f"])*")/, - /^(?:\{)/, - /^(?:\})/, - /^(?:\[)/, - /^(?:\])/, - /^(?:,)/, - /^(?::)/, - /^(?:true\b)/, - /^(?:false\b)/, - /^(?:null\b)/, - /^(?:$)/, - /^(?:.)/ - ]; - lexer.conditions = { - INITIAL: { - rules: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], - inclusive: true - } - }; - return lexer; - })(); - - parser.lexer = lexer; - return parser; -})(); - -exports.parser = jsonlint; - -exports.errors = function (input) { - try { - this.parse(input); - } catch (e) { - return e.stack; - } -}; - -exports.parse = function () { - return jsonlint.parse.apply(jsonlint, arguments); -}; - -exports.main = function commonjsMain(args) { - if (!args[1]) throw new Error('Usage: ' + args[0] + ' FILE'); - - if (typeof process !== 'undefined') { - var source = require('fs').readFileSync( - require('path').join(process.cwd(), args[1]), - 'utf8' - ); - } else { - var cwd = require('file').path(require('file').cwd()); - - var source = cwd.join(args[1]).read({ - charset: 'utf-8' - }); - } - - return exports.parser.parse(source); -}; diff --git a/node_modules/jest-runner/LICENSE b/node_modules/jest-runner/LICENSE deleted file mode 100644 index b96dcb04..00000000 --- a/node_modules/jest-runner/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) Facebook, Inc. and its affiliates. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/jest-runner/build/index.d.ts b/node_modules/jest-runner/build/index.d.ts deleted file mode 100644 index 05590c50..00000000 --- a/node_modules/jest-runner/build/index.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import type { Config } from '@jest/types'; -import type { OnTestFailure as JestOnTestFailure, OnTestStart as JestOnTestStart, OnTestSuccess as JestOnTestSuccess, Test as JestTest, TestRunnerContext as JestTestRunnerContext, TestRunnerOptions as JestTestRunnerOptions, TestWatcher as JestTestWatcher } from './types'; -declare namespace TestRunner { - type Test = JestTest; - type OnTestFailure = JestOnTestFailure; - type OnTestStart = JestOnTestStart; - type OnTestSuccess = JestOnTestSuccess; - type TestWatcher = JestTestWatcher; - type TestRunnerContext = JestTestRunnerContext; - type TestRunnerOptions = JestTestRunnerOptions; -} -declare class TestRunner { - private _globalConfig; - private _context; - constructor(globalConfig: Config.GlobalConfig, context?: JestTestRunnerContext); - runTests(tests: Array, watcher: JestTestWatcher, onStart: JestOnTestStart, onResult: JestOnTestSuccess, onFailure: JestOnTestFailure, options: JestTestRunnerOptions): Promise; - private _createInBandTestRun; - private _createParallelTestRun; -} -export = TestRunner; -//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-runner/build/index.d.ts.map b/node_modules/jest-runner/build/index.d.ts.map deleted file mode 100644 index bcd8d071..00000000 --- a/node_modules/jest-runner/build/index.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAQxC,OAAO,KAAK,EACV,aAAa,IAAI,iBAAiB,EAClC,WAAW,IAAI,eAAe,EAC9B,aAAa,IAAI,iBAAiB,EAClC,IAAI,IAAI,QAAQ,EAChB,iBAAiB,IAAI,qBAAqB,EAC1C,iBAAiB,IAAI,qBAAqB,EAC1C,WAAW,IAAI,eAAe,EAE/B,MAAM,SAAS,CAAC;AAQjB,kBAAU,UAAU,CAAC;IACnB,KAAY,IAAI,GAAG,QAAQ,CAAC;IAC5B,KAAY,aAAa,GAAG,iBAAiB,CAAC;IAC9C,KAAY,WAAW,GAAG,eAAe,CAAC;IAC1C,KAAY,aAAa,GAAG,iBAAiB,CAAC;IAC9C,KAAY,WAAW,GAAG,eAAe,CAAC;IAC1C,KAAY,iBAAiB,GAAG,qBAAqB,CAAC;IACtD,KAAY,iBAAiB,GAAG,qBAAqB,CAAC;CACvD;AAGD,cAAM,UAAU;IACd,OAAO,CAAC,aAAa,CAAsB;IAC3C,OAAO,CAAC,QAAQ,CAAwB;gBAGtC,YAAY,EAAE,MAAM,CAAC,YAAY,EACjC,OAAO,CAAC,EAAE,qBAAqB;IAM3B,QAAQ,CACZ,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,EACtB,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,iBAAiB,EAC3B,SAAS,EAAE,iBAAiB,EAC5B,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC;YAYF,oBAAoB;YAkCpB,sBAAsB;CAkGrC;AASD,SAAS,UAAU,CAAC"} \ No newline at end of file diff --git a/node_modules/jest-runner/build/index.js b/node_modules/jest-runner/build/index.js deleted file mode 100644 index 71fcc4c6..00000000 --- a/node_modules/jest-runner/build/index.js +++ /dev/null @@ -1,252 +0,0 @@ -'use strict'; - -function _exit() { - const data = _interopRequireDefault(require('exit')); - - _exit = function () { - return data; - }; - - return data; -} - -function _chalk() { - const data = _interopRequireDefault(require('chalk')); - - _chalk = function () { - return data; - }; - - return data; -} - -function _throat() { - const data = _interopRequireDefault(require('throat')); - - _throat = function () { - return data; - }; - - return data; -} - -function _jestWorker() { - const data = _interopRequireDefault(require('jest-worker')); - - _jestWorker = function () { - return data; - }; - - return data; -} - -var _runTest = _interopRequireDefault(require('./runTest')); - -function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : {default: obj}; -} - -function ownKeys(object, enumerableOnly) { - var keys = Object.keys(object); - if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(object); - if (enumerableOnly) - symbols = symbols.filter(function (sym) { - return Object.getOwnPropertyDescriptor(object, sym).enumerable; - }); - keys.push.apply(keys, symbols); - } - return keys; -} - -function _objectSpread(target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i] != null ? arguments[i] : {}; - if (i % 2) { - ownKeys(Object(source), true).forEach(function (key) { - _defineProperty(target, key, source[key]); - }); - } else if (Object.getOwnPropertyDescriptors) { - Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); - } else { - ownKeys(Object(source)).forEach(function (key) { - Object.defineProperty( - target, - key, - Object.getOwnPropertyDescriptor(source, key) - ); - }); - } - } - return target; -} - -function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - return obj; -} - -const TEST_WORKER_PATH = require.resolve('./testWorker'); - -/* eslint-disable-next-line no-redeclare */ -class TestRunner { - constructor(globalConfig, context) { - _defineProperty(this, '_globalConfig', void 0); - - _defineProperty(this, '_context', void 0); - - this._globalConfig = globalConfig; - this._context = context || {}; - } - - async runTests(tests, watcher, onStart, onResult, onFailure, options) { - return await (options.serial - ? this._createInBandTestRun(tests, watcher, onStart, onResult, onFailure) - : this._createParallelTestRun( - tests, - watcher, - onStart, - onResult, - onFailure - )); - } - - async _createInBandTestRun(tests, watcher, onStart, onResult, onFailure) { - process.env.JEST_WORKER_ID = '1'; - const mutex = (0, _throat().default)(1); - return tests.reduce( - (promise, test) => - mutex(() => - promise - .then(async () => { - if (watcher.isInterrupted()) { - throw new CancelRun(); - } - - await onStart(test); - return (0, _runTest.default)( - test.path, - this._globalConfig, - test.context.config, - test.context.resolver, - this._context - ); - }) - .then(result => onResult(test, result)) - .catch(err => onFailure(test, err)) - ), - Promise.resolve() - ); - } - - async _createParallelTestRun(tests, watcher, onStart, onResult, onFailure) { - const resolvers = new Map(); - - for (const test of tests) { - if (!resolvers.has(test.context.config.name)) { - resolvers.set(test.context.config.name, { - config: test.context.config, - serializableModuleMap: test.context.moduleMap.toJSON() - }); - } - } - - const worker = new (_jestWorker().default)(TEST_WORKER_PATH, { - exposedMethods: ['worker'], - forkOptions: { - stdio: 'pipe' - }, - maxRetries: 3, - numWorkers: this._globalConfig.maxWorkers, - setupArgs: [ - { - serializableResolvers: Array.from(resolvers.values()) - } - ] - }); - if (worker.getStdout()) worker.getStdout().pipe(process.stdout); - if (worker.getStderr()) worker.getStderr().pipe(process.stderr); - const mutex = (0, _throat().default)(this._globalConfig.maxWorkers); // Send test suites to workers continuously instead of all at once to track - // the start time of individual tests. - - const runTestInWorker = test => - mutex(async () => { - if (watcher.isInterrupted()) { - return Promise.reject(); - } - - await onStart(test); - return worker.worker({ - config: test.context.config, - context: _objectSpread({}, this._context, { - changedFiles: - this._context.changedFiles && - Array.from(this._context.changedFiles) - }), - globalConfig: this._globalConfig, - path: test.path - }); - }); - - const onError = async (err, test) => { - await onFailure(test, err); - - if (err.type === 'ProcessTerminatedError') { - console.error( - 'A worker process has quit unexpectedly! ' + - 'Most likely this is an initialization error.' - ); - (0, _exit().default)(1); - } - }; - - const onInterrupt = new Promise((_, reject) => { - watcher.on('change', state => { - if (state.interrupted) { - reject(new CancelRun()); - } - }); - }); - const runAllTests = Promise.all( - tests.map(test => - runTestInWorker(test) - .then(testResult => onResult(test, testResult)) - .catch(error => onError(error, test)) - ) - ); - - const cleanup = async () => { - const {forceExited} = await worker.end(); - - if (forceExited) { - console.log( - _chalk().default.yellow( - 'A worker process has failed to exit gracefully and has been force exited. ' + - 'This is likely caused by tests leaking due to improper teardown. ' + - 'Try running with --runInBand --detectOpenHandles to find leaks.' - ) - ); - } - }; - - return Promise.race([runAllTests, onInterrupt]).then(cleanup, cleanup); - } -} - -class CancelRun extends Error { - constructor(message) { - super(message); - this.name = 'CancelRun'; - } -} - -module.exports = TestRunner; diff --git a/node_modules/jest-runner/build/runTest.d.ts b/node_modules/jest-runner/build/runTest.d.ts deleted file mode 100644 index 787e6d84..00000000 --- a/node_modules/jest-runner/build/runTest.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ -import type { Config } from '@jest/types'; -import type { TestResult } from '@jest/test-result'; -import Resolver = require('jest-resolve'); -import type { TestRunnerContext } from './types'; -export default function runTest(path: Config.Path, globalConfig: Config.GlobalConfig, config: Config.ProjectConfig, resolver: Resolver, context?: TestRunnerContext): Promise; -//# sourceMappingURL=runTest.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-runner/build/runTest.d.ts.map b/node_modules/jest-runner/build/runTest.d.ts.map deleted file mode 100644 index 00ee6f92..00000000 --- a/node_modules/jest-runner/build/runTest.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"runTest.d.ts","sourceRoot":"","sources":["../src/runTest.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAclD,OAAO,QAAQ,GAAG,QAAQ,cAAc,CAAC,CAAC;AAM1C,OAAO,KAAK,EAAgB,iBAAiB,EAAC,MAAM,SAAS,CAAC;AAmR9D,wBAA8B,OAAO,CACnC,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,YAAY,EAAE,MAAM,CAAC,YAAY,EACjC,MAAM,EAAE,MAAM,CAAC,aAAa,EAC5B,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,UAAU,CAAC,CAoBrB"} \ No newline at end of file diff --git a/node_modules/jest-runner/build/runTest.js b/node_modules/jest-runner/build/runTest.js deleted file mode 100644 index e3e62220..00000000 --- a/node_modules/jest-runner/build/runTest.js +++ /dev/null @@ -1,506 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.default = runTest; - -function _vm() { - const data = require('vm'); - - _vm = function () { - return data; - }; - - return data; -} - -function _console() { - const data = require('@jest/console'); - - _console = function () { - return data; - }; - - return data; -} - -function _jestRuntime() { - const data = _interopRequireDefault(require('jest-runtime')); - - _jestRuntime = function () { - return data; - }; - - return data; -} - -function fs() { - const data = _interopRequireWildcard(require('graceful-fs')); - - fs = function () { - return data; - }; - - return data; -} - -function _jestUtil() { - const data = require('jest-util'); - - _jestUtil = function () { - return data; - }; - - return data; -} - -function _jestLeakDetector() { - const data = _interopRequireDefault(require('jest-leak-detector')); - - _jestLeakDetector = function () { - return data; - }; - - return data; -} - -function _jestResolve() { - const data = _interopRequireDefault(require('jest-resolve')); - - _jestResolve = function () { - return data; - }; - - return data; -} - -function _jestConfig() { - const data = require('jest-config'); - - _jestConfig = function () { - return data; - }; - - return data; -} - -function docblock() { - const data = _interopRequireWildcard(require('jest-docblock')); - - docblock = function () { - return data; - }; - - return data; -} - -function _jestMessageUtil() { - const data = require('jest-message-util'); - - _jestMessageUtil = function () { - return data; - }; - - return data; -} - -function _sourceMapSupport() { - const data = _interopRequireDefault(require('source-map-support')); - - _sourceMapSupport = function () { - return data; - }; - - return data; -} - -function _chalk() { - const data = _interopRequireDefault(require('chalk')); - - _chalk = function () { - return data; - }; - - return data; -} - -function _getRequireWildcardCache() { - if (typeof WeakMap !== 'function') return null; - var cache = new WeakMap(); - _getRequireWildcardCache = function () { - return cache; - }; - return cache; -} - -function _interopRequireWildcard(obj) { - if (obj && obj.__esModule) { - return obj; - } - if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { - return {default: obj}; - } - var cache = _getRequireWildcardCache(); - if (cache && cache.has(obj)) { - return cache.get(obj); - } - var newObj = {}; - var hasPropertyDescriptor = - Object.defineProperty && Object.getOwnPropertyDescriptor; - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) { - var desc = hasPropertyDescriptor - ? Object.getOwnPropertyDescriptor(obj, key) - : null; - if (desc && (desc.get || desc.set)) { - Object.defineProperty(newObj, key, desc); - } else { - newObj[key] = obj[key]; - } - } - } - newObj.default = obj; - if (cache) { - cache.set(obj, newObj); - } - return newObj; -} - -function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : {default: obj}; -} - -function ownKeys(object, enumerableOnly) { - var keys = Object.keys(object); - if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(object); - if (enumerableOnly) - symbols = symbols.filter(function (sym) { - return Object.getOwnPropertyDescriptor(object, sym).enumerable; - }); - keys.push.apply(keys, symbols); - } - return keys; -} - -function _objectSpread(target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i] != null ? arguments[i] : {}; - if (i % 2) { - ownKeys(Object(source), true).forEach(function (key) { - _defineProperty(target, key, source[key]); - }); - } else if (Object.getOwnPropertyDescriptors) { - Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); - } else { - ownKeys(Object(source)).forEach(function (key) { - Object.defineProperty( - target, - key, - Object.getOwnPropertyDescriptor(source, key) - ); - }); - } - } - return target; -} - -function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - return obj; -} - -function freezeConsole(testConsole, config) { - // @ts-ignore: `_log` is `private` - we should figure out some proper API here - testConsole._log = function fakeConsolePush(_type, message) { - const error = new (_jestUtil().ErrorWithStack)( - `${_chalk().default.red( - `${_chalk().default.bold( - 'Cannot log after tests are done.' - )} Did you forget to wait for something async in your test?` - )}\nAttempted to log "${message}".`, - fakeConsolePush - ); - const formattedError = (0, _jestMessageUtil().formatExecError)( - error, - config, - { - noStackTrace: false - }, - undefined, - true - ); - process.stderr.write('\n' + formattedError + '\n'); // TODO: set exit code in Jest 25 - // process.exitCode = 1; - }; -} // Keeping the core of "runTest" as a separate function (as "runTestInternal") -// is key to be able to detect memory leaks. Since all variables are local to -// the function, when "runTestInternal" finishes its execution, they can all be -// freed, UNLESS something else is leaking them (and that's why we can detect -// the leak!). -// -// If we had all the code in a single function, we should manually nullify all -// references to verify if there is a leak, which is not maintainable and error -// prone. That's why "runTestInternal" CANNOT be inlined inside "runTest". - -async function runTestInternal(path, globalConfig, config, resolver, context) { - const testSource = fs().readFileSync(path, 'utf8'); - const docblockPragmas = docblock().parse(docblock().extract(testSource)); - const customEnvironment = docblockPragmas['jest-environment']; - let testEnvironment = config.testEnvironment; - - if (customEnvironment) { - if (Array.isArray(customEnvironment)) { - throw new Error( - `You can only define a single test environment through docblocks, got "${customEnvironment.join( - ', ' - )}"` - ); - } - - testEnvironment = (0, _jestConfig().getTestEnvironment)( - _objectSpread({}, config, { - testEnvironment: customEnvironment - }) - ); - } - - const TestEnvironment = (0, _jestUtil().interopRequireDefault)( - require(testEnvironment) - ).default; - const testFramework = - process.env.JEST_CIRCUS === '1' - ? require('jest-circus/runner') // eslint-disable-line import/no-extraneous-dependencies - : require(config.testRunner); - const Runtime = config.moduleLoader - ? require(config.moduleLoader) - : require('jest-runtime'); - let runtime = undefined; - const consoleOut = globalConfig.useStderr ? process.stderr : process.stdout; - - const consoleFormatter = (type, message) => - (0, _console().getConsoleOutput)( - config.cwd, - !!globalConfig.verbose, // 4 = the console call is buried 4 stack frames deep - _console().BufferedConsole.write( - [], - type, - message, - 4, - runtime && runtime.getSourceMaps() - ) - ); - - let testConsole; - - if (globalConfig.silent) { - testConsole = new (_console().NullConsole)( - consoleOut, - consoleOut, - consoleFormatter - ); - } else if (globalConfig.verbose) { - testConsole = new (_console().CustomConsole)( - consoleOut, - consoleOut, - consoleFormatter - ); - } else { - testConsole = new (_console().BufferedConsole)( - () => runtime && runtime.getSourceMaps() - ); - } - - const environment = new TestEnvironment(config, { - console: testConsole, - docblockPragmas, - testPath: path - }); - const leakDetector = config.detectLeaks - ? new (_jestLeakDetector().default)(environment) - : null; - const cacheFS = { - [path]: testSource - }; - (0, _jestUtil().setGlobal)(environment.global, 'console', testConsole); - runtime = new Runtime(config, environment, resolver, cacheFS, { - changedFiles: context && context.changedFiles, - collectCoverage: globalConfig.collectCoverage, - collectCoverageFrom: globalConfig.collectCoverageFrom, - collectCoverageOnlyFrom: globalConfig.collectCoverageOnlyFrom, - coverageProvider: globalConfig.coverageProvider - }); - const start = Date.now(); - config.setupFiles.forEach(path => runtime.requireModule(path)); - const sourcemapOptions = { - environment: 'node', - handleUncaughtExceptions: false, - retrieveSourceMap: source => { - const sourceMaps = runtime && runtime.getSourceMaps(); - const sourceMapSource = sourceMaps && sourceMaps[source]; - - if (sourceMapSource) { - try { - return { - map: JSON.parse(fs().readFileSync(sourceMapSource, 'utf8')), - url: source - }; - } catch (e) {} - } - - return null; - } - }; // For tests - - runtime - .requireInternalModule( - require.resolve('source-map-support'), - 'source-map-support' - ) - .install(sourcemapOptions); // For runtime errors - - _sourceMapSupport().default.install(sourcemapOptions); - - if ( - environment.global && - environment.global.process && - environment.global.process.exit - ) { - const realExit = environment.global.process.exit; - - environment.global.process.exit = function exit(...args) { - const error = new (_jestUtil().ErrorWithStack)( - `process.exit called with "${args.join(', ')}"`, - exit - ); - const formattedError = (0, _jestMessageUtil().formatExecError)( - error, - config, - { - noStackTrace: false - }, - undefined, - true - ); - process.stderr.write(formattedError); - return realExit(...args); - }; - } // if we don't have `getVmContext` on the env,or `compileFunction` available skip coverage - - const collectV8Coverage = - globalConfig.coverageProvider === 'v8' && - typeof environment.getVmContext === 'function' && - typeof _vm().compileFunction === 'function'; - - try { - await environment.setup(); - let result; - - try { - if (collectV8Coverage) { - await runtime.collectV8Coverage(); - } - - result = await testFramework( - globalConfig, - config, - environment, - runtime, - path - ); - } catch (err) { - // Access stack before uninstalling sourcemaps - err.stack; - throw err; - } finally { - if (collectV8Coverage) { - await runtime.stopCollectingV8Coverage(); - } - } - - freezeConsole(testConsole, config); - const testCount = - result.numPassingTests + - result.numFailingTests + - result.numPendingTests + - result.numTodoTests; - result.perfStats = { - end: Date.now(), - start - }; - result.testFilePath = path; - result.console = testConsole.getBuffer(); - result.skipped = testCount === result.numPendingTests; - result.displayName = config.displayName; - const coverage = runtime.getAllCoverageInfoCopy(); - - if (coverage) { - const coverageKeys = Object.keys(coverage); - - if (coverageKeys.length) { - result.coverage = coverage; - result.sourceMaps = runtime.getSourceMapInfo(new Set(coverageKeys)); - } - } - - if (collectV8Coverage) { - const v8Coverage = runtime.getAllV8CoverageInfoCopy(); - - if (v8Coverage && v8Coverage.length > 0) { - result.v8Coverage = v8Coverage; - } - } - - if (globalConfig.logHeapUsage) { - if (global.gc) { - global.gc(); - } - - result.memoryUsage = process.memoryUsage().heapUsed; - } // Delay the resolution to allow log messages to be output. - - return new Promise(resolve => { - setImmediate(() => - resolve({ - leakDetector, - result - }) - ); - }); - } finally { - await environment.teardown(); - - _sourceMapSupport().default.resetRetrieveHandlers(); - } -} - -async function runTest(path, globalConfig, config, resolver, context) { - const {leakDetector, result} = await runTestInternal( - path, - globalConfig, - config, - resolver, - context - ); - - if (leakDetector) { - // We wanna allow a tiny but time to pass to allow last-minute cleanup - await new Promise(resolve => setTimeout(resolve, 100)); // Resolve leak detector, outside the "runTestInternal" closure. - - result.leaks = await leakDetector.isLeaking(); - } else { - result.leaks = false; - } - - return result; -} diff --git a/node_modules/jest-runner/build/testWorker.d.ts b/node_modules/jest-runner/build/testWorker.d.ts deleted file mode 100644 index fa7e8905..00000000 --- a/node_modules/jest-runner/build/testWorker.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ -import type { Config } from '@jest/types'; -import type { TestResult } from '@jest/test-result'; -import HasteMap = require('jest-haste-map'); -import type { TestRunnerSerializedContext } from './types'; -export declare type SerializableResolver = { - config: Config.ProjectConfig; - serializableModuleMap: HasteMap.SerializableModuleMap; -}; -declare type WorkerData = { - config: Config.ProjectConfig; - globalConfig: Config.GlobalConfig; - path: Config.Path; - context?: TestRunnerSerializedContext; -}; -export declare function setup(setupData: { - serializableResolvers: Array; -}): void; -export declare function worker({ config, globalConfig, path, context, }: WorkerData): Promise; -export {}; -//# sourceMappingURL=testWorker.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-runner/build/testWorker.d.ts.map b/node_modules/jest-runner/build/testWorker.d.ts.map deleted file mode 100644 index 1db6dde0..00000000 --- a/node_modules/jest-runner/build/testWorker.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"testWorker.d.ts","sourceRoot":"","sources":["../src/testWorker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAoB,UAAU,EAAC,MAAM,mBAAmB,CAAC;AACrE,OAAO,QAAQ,GAAG,QAAQ,gBAAgB,CAAC,CAAC;AAK5C,OAAO,KAAK,EAAgB,2BAA2B,EAAC,MAAM,SAAS,CAAC;AAGxE,oBAAY,oBAAoB,GAAG;IACjC,MAAM,EAAE,MAAM,CAAC,aAAa,CAAC;IAC7B,qBAAqB,EAAE,QAAQ,CAAC,qBAAqB,CAAC;CACvD,CAAC;AAEF,aAAK,UAAU,GAAG;IAChB,MAAM,EAAE,MAAM,CAAC,aAAa,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC,YAAY,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC;IAClB,OAAO,CAAC,EAAE,2BAA2B,CAAC;CACvC,CAAC;AAmCF,wBAAgB,KAAK,CAAC,SAAS,EAAE;IAC/B,qBAAqB,EAAE,KAAK,CAAC,oBAAoB,CAAC,CAAC;CACpD,GAAG,IAAI,CASP;AAED,wBAAsB,MAAM,CAAC,EAC3B,MAAM,EACN,YAAY,EACZ,IAAI,EACJ,OAAO,GACR,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAelC"} \ No newline at end of file diff --git a/node_modules/jest-runner/build/testWorker.js b/node_modules/jest-runner/build/testWorker.js deleted file mode 100644 index 97c61b8e..00000000 --- a/node_modules/jest-runner/build/testWorker.js +++ /dev/null @@ -1,184 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.setup = setup; -exports.worker = worker; - -function _jestHasteMap() { - const data = _interopRequireDefault(require('jest-haste-map')); - - _jestHasteMap = function () { - return data; - }; - - return data; -} - -function _exit() { - const data = _interopRequireDefault(require('exit')); - - _exit = function () { - return data; - }; - - return data; -} - -function _jestMessageUtil() { - const data = require('jest-message-util'); - - _jestMessageUtil = function () { - return data; - }; - - return data; -} - -function _jestRuntime() { - const data = _interopRequireDefault(require('jest-runtime')); - - _jestRuntime = function () { - return data; - }; - - return data; -} - -function _jestResolve() { - const data = _interopRequireDefault(require('jest-resolve')); - - _jestResolve = function () { - return data; - }; - - return data; -} - -var _runTest = _interopRequireDefault(require('./runTest')); - -function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : {default: obj}; -} - -function ownKeys(object, enumerableOnly) { - var keys = Object.keys(object); - if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(object); - if (enumerableOnly) - symbols = symbols.filter(function (sym) { - return Object.getOwnPropertyDescriptor(object, sym).enumerable; - }); - keys.push.apply(keys, symbols); - } - return keys; -} - -function _objectSpread(target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i] != null ? arguments[i] : {}; - if (i % 2) { - ownKeys(Object(source), true).forEach(function (key) { - _defineProperty(target, key, source[key]); - }); - } else if (Object.getOwnPropertyDescriptors) { - Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); - } else { - ownKeys(Object(source)).forEach(function (key) { - Object.defineProperty( - target, - key, - Object.getOwnPropertyDescriptor(source, key) - ); - }); - } - } - return target; -} - -function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - return obj; -} - -// Make sure uncaught errors are logged before we exit. -process.on('uncaughtException', err => { - console.error(err.stack); - (0, _exit().default)(1); -}); - -const formatError = error => { - if (typeof error === 'string') { - const {message, stack} = (0, _jestMessageUtil().separateMessageFromStack)( - error - ); - return { - message, - stack, - type: 'Error' - }; - } - - return { - code: error.code || undefined, - message: error.message, - stack: error.stack, - type: 'Error' - }; -}; - -const resolvers = new Map(); - -const getResolver = config => { - const resolver = resolvers.get(config.name); - - if (!resolver) { - throw new Error('Cannot find resolver for: ' + config.name); - } - - return resolver; -}; - -function setup(setupData) { - // Module maps that will be needed for the test runs are passed. - for (const { - config, - serializableModuleMap - } of setupData.serializableResolvers) { - const moduleMap = _jestHasteMap().default.ModuleMap.fromJSON( - serializableModuleMap - ); - - resolvers.set( - config.name, - _jestRuntime().default.createResolver(config, moduleMap) - ); - } -} - -async function worker({config, globalConfig, path, context}) { - try { - return await (0, _runTest.default)( - path, - globalConfig, - config, - getResolver(config), - context && - _objectSpread({}, context, { - changedFiles: context.changedFiles && new Set(context.changedFiles) - }) - ); - } catch (error) { - throw formatError(error); - } -} diff --git a/node_modules/jest-runner/build/ts3.4/index.d.ts b/node_modules/jest-runner/build/ts3.4/index.d.ts deleted file mode 100644 index ff4b4a7e..00000000 --- a/node_modules/jest-runner/build/ts3.4/index.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import { Config } from '@jest/types'; -import { OnTestFailure as JestOnTestFailure, OnTestStart as JestOnTestStart, OnTestSuccess as JestOnTestSuccess, Test as JestTest, TestRunnerContext as JestTestRunnerContext, TestRunnerOptions as JestTestRunnerOptions, TestWatcher as JestTestWatcher } from './types'; -declare namespace TestRunner { - type Test = JestTest; - type OnTestFailure = JestOnTestFailure; - type OnTestStart = JestOnTestStart; - type OnTestSuccess = JestOnTestSuccess; - type TestWatcher = JestTestWatcher; - type TestRunnerContext = JestTestRunnerContext; - type TestRunnerOptions = JestTestRunnerOptions; -} -declare class TestRunner { - private _globalConfig; - private _context; - constructor(globalConfig: Config.GlobalConfig, context?: JestTestRunnerContext); - runTests(tests: Array, watcher: JestTestWatcher, onStart: JestOnTestStart, onResult: JestOnTestSuccess, onFailure: JestOnTestFailure, options: JestTestRunnerOptions): Promise; - private _createInBandTestRun; - private _createParallelTestRun; -} -export = TestRunner; -//# sourceMappingURL=index.d.ts.map diff --git a/node_modules/jest-runner/build/ts3.4/runTest.d.ts b/node_modules/jest-runner/build/ts3.4/runTest.d.ts deleted file mode 100644 index c477f894..00000000 --- a/node_modules/jest-runner/build/ts3.4/runTest.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ -import { Config } from '@jest/types'; -import { TestResult } from '@jest/test-result'; -import Resolver = require('jest-resolve'); -import { TestRunnerContext } from './types'; -export default function runTest(path: Config.Path, globalConfig: Config.GlobalConfig, config: Config.ProjectConfig, resolver: Resolver, context?: TestRunnerContext): Promise; -//# sourceMappingURL=runTest.d.ts.map diff --git a/node_modules/jest-runner/build/ts3.4/testWorker.d.ts b/node_modules/jest-runner/build/ts3.4/testWorker.d.ts deleted file mode 100644 index 021c4484..00000000 --- a/node_modules/jest-runner/build/ts3.4/testWorker.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - */ -import { Config } from '@jest/types'; -import { TestResult } from '@jest/test-result'; -import HasteMap = require('jest-haste-map'); -import { TestRunnerSerializedContext } from './types'; -export declare type SerializableResolver = { - config: Config.ProjectConfig; - serializableModuleMap: HasteMap.SerializableModuleMap; -}; -declare type WorkerData = { - config: Config.ProjectConfig; - globalConfig: Config.GlobalConfig; - path: Config.Path; - context?: TestRunnerSerializedContext; -}; -export declare function setup(setupData: { - serializableResolvers: Array; -}): void; -export declare function worker({ config, globalConfig, path, context, }: WorkerData): Promise; -export {}; -//# sourceMappingURL=testWorker.d.ts.map diff --git a/node_modules/jest-runner/build/ts3.4/types.d.ts b/node_modules/jest-runner/build/ts3.4/types.d.ts deleted file mode 100644 index d68a0031..00000000 --- a/node_modules/jest-runner/build/ts3.4/types.d.ts +++ /dev/null @@ -1,55 +0,0 @@ -/// -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -/// -import { EventEmitter } from 'events'; -import { Config } from '@jest/types'; -import { SerializableError, TestResult } from '@jest/test-result'; -import { JestEnvironment } from '@jest/environment'; -import { FS as HasteFS, ModuleMap } from 'jest-haste-map'; -import HasteResolver = require('jest-resolve'); -import Runtime = require('jest-runtime'); -export declare type ErrorWithCode = Error & { - code?: string; -}; -export declare type Test = { - context: Context; - duration?: number; - path: Config.Path; -}; -export declare type Context = { - config: Config.ProjectConfig; - hasteFS: HasteFS; - moduleMap: ModuleMap; - resolver: HasteResolver; -}; -export declare type OnTestStart = (test: Test) => Promise; -export declare type OnTestFailure = (test: Test, serializableError: SerializableError) => Promise; -export declare type OnTestSuccess = (test: Test, testResult: TestResult) => Promise; -export declare type TestFramework = (globalConfig: Config.GlobalConfig, config: Config.ProjectConfig, environment: JestEnvironment, runtime: Runtime, testPath: string) => Promise; -export declare type TestRunnerOptions = { - serial: boolean; -}; -export declare type TestRunnerContext = { - changedFiles?: Set; -}; -export declare type TestRunnerSerializedContext = { - changedFiles?: Array; -}; -export declare type WatcherState = { - interrupted: boolean; -}; -export interface TestWatcher extends EventEmitter { - state: WatcherState; - new ({ isWatchMode }: { - isWatchMode: boolean; - }): TestWatcher; - setState(state: WatcherState): void; - isInterrupted(): boolean; - isWatchMode(): boolean; -} -//# sourceMappingURL=types.d.ts.map diff --git a/node_modules/jest-runner/build/types.d.ts b/node_modules/jest-runner/build/types.d.ts deleted file mode 100644 index 463b2145..00000000 --- a/node_modules/jest-runner/build/types.d.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -/// -import type { EventEmitter } from 'events'; -import type { Config } from '@jest/types'; -import type { SerializableError, TestResult } from '@jest/test-result'; -import type { JestEnvironment } from '@jest/environment'; -import type { FS as HasteFS, ModuleMap } from 'jest-haste-map'; -import HasteResolver = require('jest-resolve'); -import Runtime = require('jest-runtime'); -export declare type ErrorWithCode = Error & { - code?: string; -}; -export declare type Test = { - context: Context; - duration?: number; - path: Config.Path; -}; -export declare type Context = { - config: Config.ProjectConfig; - hasteFS: HasteFS; - moduleMap: ModuleMap; - resolver: HasteResolver; -}; -export declare type OnTestStart = (test: Test) => Promise; -export declare type OnTestFailure = (test: Test, serializableError: SerializableError) => Promise; -export declare type OnTestSuccess = (test: Test, testResult: TestResult) => Promise; -export declare type TestFramework = (globalConfig: Config.GlobalConfig, config: Config.ProjectConfig, environment: JestEnvironment, runtime: Runtime, testPath: string) => Promise; -export declare type TestRunnerOptions = { - serial: boolean; -}; -export declare type TestRunnerContext = { - changedFiles?: Set; -}; -export declare type TestRunnerSerializedContext = { - changedFiles?: Array; -}; -export declare type WatcherState = { - interrupted: boolean; -}; -export interface TestWatcher extends EventEmitter { - state: WatcherState; - new ({ isWatchMode }: { - isWatchMode: boolean; - }): TestWatcher; - setState(state: WatcherState): void; - isInterrupted(): boolean; - isWatchMode(): boolean; -} -//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-runner/build/types.d.ts.map b/node_modules/jest-runner/build/types.d.ts.map deleted file mode 100644 index 5f88cf64..00000000 --- a/node_modules/jest-runner/build/types.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAC,iBAAiB,EAAE,UAAU,EAAC,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAC,EAAE,IAAI,OAAO,EAAE,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAC7D,OAAO,aAAa,GAAG,QAAQ,cAAc,CAAC,CAAC;AAC/C,OAAO,OAAO,GAAG,QAAQ,cAAc,CAAC,CAAC;AAEzC,oBAAY,aAAa,GAAG,KAAK,GAAG;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC;AACpD,oBAAY,IAAI,GAAG;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC;CACnB,CAAC;AAEF,oBAAY,OAAO,GAAG;IACpB,MAAM,EAAE,MAAM,CAAC,aAAa,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,aAAa,CAAC;CACzB,CAAC;AAEF,oBAAY,WAAW,GAAG,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AACxD,oBAAY,aAAa,GAAG,CAC1B,IAAI,EAAE,IAAI,EACV,iBAAiB,EAAE,iBAAiB,KACjC,OAAO,CAAC,IAAI,CAAC,CAAC;AACnB,oBAAY,aAAa,GAAG,CAC1B,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,KACnB,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB,oBAAY,aAAa,GAAG,CAC1B,YAAY,EAAE,MAAM,CAAC,YAAY,EACjC,MAAM,EAAE,MAAM,CAAC,aAAa,EAC5B,WAAW,EAAE,eAAe,EAC5B,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,KACb,OAAO,CAAC,UAAU,CAAC,CAAC;AAEzB,oBAAY,iBAAiB,GAAG;IAC9B,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,oBAAY,iBAAiB,GAAG;IAC9B,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;CACjC,CAAC;AAEF,oBAAY,2BAA2B,GAAG;IACxC,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;CACnC,CAAC;AAGF,oBAAY,YAAY,GAAG;IACzB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AACF,MAAM,WAAW,WAAY,SAAQ,YAAY;IAC/C,KAAK,EAAE,YAAY,CAAC;IACpB,KAAK,EAAC,WAAW,EAAC,EAAE;QAAC,WAAW,EAAE,OAAO,CAAA;KAAC,GAAG,WAAW,CAAC;IACzD,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IACpC,aAAa,IAAI,OAAO,CAAC;IACzB,WAAW,IAAI,OAAO,CAAC;CACxB"} \ No newline at end of file diff --git a/node_modules/jest-runner/build/types.js b/node_modules/jest-runner/build/types.js deleted file mode 100644 index a5deb51a..00000000 --- a/node_modules/jest-runner/build/types.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; - -function _jestResolve() { - const data = _interopRequireDefault(require('jest-resolve')); - - _jestResolve = function () { - return data; - }; - - return data; -} - -function _jestRuntime() { - const data = _interopRequireDefault(require('jest-runtime')); - - _jestRuntime = function () { - return data; - }; - - return data; -} - -function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : {default: obj}; -} diff --git a/node_modules/jest-runner/node_modules/.bin/jest-runtime b/node_modules/jest-runner/node_modules/.bin/jest-runtime deleted file mode 120000 index 340a27dd..00000000 --- a/node_modules/jest-runner/node_modules/.bin/jest-runtime +++ /dev/null @@ -1 +0,0 @@ -../../../jest-runtime/bin/jest-runtime.js \ No newline at end of file diff --git a/node_modules/jest-runtime/LICENSE b/node_modules/jest-runtime/LICENSE deleted file mode 100644 index b96dcb04..00000000 --- a/node_modules/jest-runtime/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) Facebook, Inc. and its affiliates. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/jest-runtime/bin/jest-runtime.js b/node_modules/jest-runtime/bin/jest-runtime.js deleted file mode 100755 index 6a510e72..00000000 --- a/node_modules/jest-runtime/bin/jest-runtime.js +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env node -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -if (process.env.NODE_ENV == null) { - process.env.NODE_ENV = 'test'; -} - -require('../build/cli').run(); diff --git a/node_modules/jest-runtime/build/cli/args.d.ts b/node_modules/jest-runtime/build/cli/args.d.ts deleted file mode 100644 index fc7eff5d..00000000 --- a/node_modules/jest-runtime/build/cli/args.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import type { Options } from 'yargs'; -export declare const usage = "Usage: $0 [--config=] "; -export declare const options: Record<'cache' | 'config' | 'debug' | 'version' | 'watchman', Options>; -//# sourceMappingURL=args.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-runtime/build/cli/args.d.ts.map b/node_modules/jest-runtime/build/cli/args.d.ts.map deleted file mode 100644 index 2b45d2c1..00000000 --- a/node_modules/jest-runtime/build/cli/args.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/cli/args.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAEnC,eAAO,MAAM,KAAK,mDAAmD,CAAC;AAEtE,eAAO,MAAM,OAAO,EAAE,MAAM,CAC1B,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,EACrD,OAAO,CA8BR,CAAC"} \ No newline at end of file diff --git a/node_modules/jest-runtime/build/cli/args.js b/node_modules/jest-runtime/build/cli/args.js deleted file mode 100644 index 9419c609..00000000 --- a/node_modules/jest-runtime/build/cli/args.js +++ /dev/null @@ -1,46 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.options = exports.usage = void 0; - -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -const usage = 'Usage: $0 [--config=] '; -exports.usage = usage; -const options = { - cache: { - default: true, - description: - 'Whether to use the preprocessor cache. Disable ' + - 'the cache using --no-cache.', - type: 'boolean' - }, - config: { - alias: 'c', - description: 'The path to a Jest config file.', - type: 'string' - }, - debug: { - description: 'Print debugging info about your jest config.', - type: 'boolean' - }, - version: { - alias: 'v', - description: 'Print the version and exit', - type: 'boolean' - }, - watchman: { - default: true, - description: - 'Whether to use watchman for file crawling. Disable using ' + - '--no-watchman.', - type: 'boolean' - } -}; -exports.options = options; diff --git a/node_modules/jest-runtime/build/cli/index.d.ts b/node_modules/jest-runtime/build/cli/index.d.ts deleted file mode 100644 index a3a38263..00000000 --- a/node_modules/jest-runtime/build/cli/index.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import type { Config } from '@jest/types'; -export declare function run(cliArgv?: Config.Argv, cliInfo?: Array): Promise; -//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-runtime/build/cli/index.d.ts.map b/node_modules/jest-runtime/build/cli/index.d.ts.map deleted file mode 100644 index ce439b51..00000000 --- a/node_modules/jest-runtime/build/cli/index.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAUxC,wBAAsB,GAAG,CACvB,OAAO,CAAC,EAAE,MAAM,CAAC,IAAI,EACrB,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GACtB,OAAO,CAAC,IAAI,CAAC,CA6Ef"} \ No newline at end of file diff --git a/node_modules/jest-runtime/build/cli/index.js b/node_modules/jest-runtime/build/cli/index.js deleted file mode 100644 index 38e53172..00000000 --- a/node_modules/jest-runtime/build/cli/index.js +++ /dev/null @@ -1,291 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.run = run; - -function _os() { - const data = require('os'); - - _os = function () { - return data; - }; - - return data; -} - -function path() { - const data = _interopRequireWildcard(require('path')); - - path = function () { - return data; - }; - - return data; -} - -function _chalk() { - const data = _interopRequireDefault(require('chalk')); - - _chalk = function () { - return data; - }; - - return data; -} - -function _realpathNative() { - const data = require('realpath-native'); - - _realpathNative = function () { - return data; - }; - - return data; -} - -function _yargs() { - const data = _interopRequireDefault(require('yargs')); - - _yargs = function () { - return data; - }; - - return data; -} - -function _console() { - const data = require('@jest/console'); - - _console = function () { - return data; - }; - - return data; -} - -function _jestUtil() { - const data = require('jest-util'); - - _jestUtil = function () { - return data; - }; - - return data; -} - -function _jestValidate() { - const data = require('jest-validate'); - - _jestValidate = function () { - return data; - }; - - return data; -} - -function _jestConfig() { - const data = require('jest-config'); - - _jestConfig = function () { - return data; - }; - - return data; -} - -function _version() { - const data = require('../version'); - - _version = function () { - return data; - }; - - return data; -} - -var args = _interopRequireWildcard(require('./args')); - -function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : {default: obj}; -} - -function _getRequireWildcardCache() { - if (typeof WeakMap !== 'function') return null; - var cache = new WeakMap(); - _getRequireWildcardCache = function () { - return cache; - }; - return cache; -} - -function _interopRequireWildcard(obj) { - if (obj && obj.__esModule) { - return obj; - } - if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { - return {default: obj}; - } - var cache = _getRequireWildcardCache(); - if (cache && cache.has(obj)) { - return cache.get(obj); - } - var newObj = {}; - var hasPropertyDescriptor = - Object.defineProperty && Object.getOwnPropertyDescriptor; - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) { - var desc = hasPropertyDescriptor - ? Object.getOwnPropertyDescriptor(obj, key) - : null; - if (desc && (desc.get || desc.set)) { - Object.defineProperty(newObj, key, desc); - } else { - newObj[key] = obj[key]; - } - } - } - newObj.default = obj; - if (cache) { - cache.set(obj, newObj); - } - return newObj; -} - -function ownKeys(object, enumerableOnly) { - var keys = Object.keys(object); - if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(object); - if (enumerableOnly) - symbols = symbols.filter(function (sym) { - return Object.getOwnPropertyDescriptor(object, sym).enumerable; - }); - keys.push.apply(keys, symbols); - } - return keys; -} - -function _objectSpread(target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i] != null ? arguments[i] : {}; - if (i % 2) { - ownKeys(Object(source), true).forEach(function (key) { - _defineProperty(target, key, source[key]); - }); - } else if (Object.getOwnPropertyDescriptors) { - Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); - } else { - ownKeys(Object(source)).forEach(function (key) { - Object.defineProperty( - target, - key, - Object.getOwnPropertyDescriptor(source, key) - ); - }); - } - } - return target; -} - -function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - return obj; -} - -async function run(cliArgv, cliInfo) { - const realFs = require('fs'); - - const fs = require('graceful-fs'); - - fs.gracefulify(realFs); - let argv; - - if (cliArgv) { - argv = cliArgv; - } else { - argv = _yargs() - .default.usage(args.usage) - .help(false) - .version(false) - .options(args.options).argv; - (0, _jestValidate().validateCLIOptions)( - argv, - _objectSpread({}, args.options, { - deprecationEntries: _jestConfig().deprecationEntries - }) - ); - } - - if (argv.help) { - _yargs().default.showHelp(); - - process.on('exit', () => (process.exitCode = 1)); - return; - } - - if (argv.version) { - console.log(`v${_version().VERSION}\n`); - return; - } - - if (!argv._.length) { - console.log('Please provide a path to a script. (See --help for details)'); - process.on('exit', () => (process.exitCode = 1)); - return; - } - - const root = (0, _realpathNative().sync)(process.cwd()); - const filePath = path().resolve(root, argv._[0]); - - if (argv.debug) { - const info = cliInfo ? ', ' + cliInfo.join(', ') : ''; - console.log(`Using Jest Runtime v${_version().VERSION}${info}`); - } - - const options = await (0, _jestConfig().readConfig)(argv, root); - const globalConfig = options.globalConfig; // Always disable automocking in scripts. - - const config = _objectSpread({}, options.projectConfig, { - automock: false - }); // Break circular dependency - - const Runtime = require('..'); - - try { - const hasteMap = await Runtime.createContext(config, { - maxWorkers: Math.max((0, _os().cpus)().length - 1, 1), - watchman: globalConfig.watchman - }); - - const Environment = require(config.testEnvironment); - - const environment = new Environment(config); - (0, _jestUtil().setGlobal)( - environment.global, - 'console', - new (_console().CustomConsole)(process.stdout, process.stderr) - ); - (0, _jestUtil().setGlobal)(environment.global, 'jestProjectConfig', config); - (0, _jestUtil().setGlobal)( - environment.global, - 'jestGlobalConfig', - globalConfig - ); - const runtime = new Runtime(config, environment, hasteMap.resolver); - config.setupFiles.forEach(path => runtime.requireModule(path)); - runtime.requireModule(filePath); - } catch (e) { - console.error(_chalk().default.red(e.stack || e)); - process.on('exit', () => (process.exitCode = 1)); - } -} diff --git a/node_modules/jest-runtime/build/helpers.d.ts b/node_modules/jest-runtime/build/helpers.d.ts deleted file mode 100644 index 76dc0ec2..00000000 --- a/node_modules/jest-runtime/build/helpers.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -export declare const findSiblingsWithFileExtension: (moduleFileExtensions: string[], from: string, moduleName: string) => string; -//# sourceMappingURL=helpers.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-runtime/build/helpers.d.ts.map b/node_modules/jest-runtime/build/helpers.d.ts.map deleted file mode 100644 index 52b744e8..00000000 --- a/node_modules/jest-runtime/build/helpers.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,eAAO,MAAM,6BAA6B,8EA0CzC,CAAC"} \ No newline at end of file diff --git a/node_modules/jest-runtime/build/helpers.js b/node_modules/jest-runtime/build/helpers.js deleted file mode 100644 index d29ed1dc..00000000 --- a/node_modules/jest-runtime/build/helpers.js +++ /dev/null @@ -1,131 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.findSiblingsWithFileExtension = void 0; - -function path() { - const data = _interopRequireWildcard(require('path')); - - path = function () { - return data; - }; - - return data; -} - -function _slash() { - const data = _interopRequireDefault(require('slash')); - - _slash = function () { - return data; - }; - - return data; -} - -function _glob() { - const data = _interopRequireDefault(require('glob')); - - _glob = function () { - return data; - }; - - return data; -} - -function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : {default: obj}; -} - -function _getRequireWildcardCache() { - if (typeof WeakMap !== 'function') return null; - var cache = new WeakMap(); - _getRequireWildcardCache = function () { - return cache; - }; - return cache; -} - -function _interopRequireWildcard(obj) { - if (obj && obj.__esModule) { - return obj; - } - if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { - return {default: obj}; - } - var cache = _getRequireWildcardCache(); - if (cache && cache.has(obj)) { - return cache.get(obj); - } - var newObj = {}; - var hasPropertyDescriptor = - Object.defineProperty && Object.getOwnPropertyDescriptor; - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) { - var desc = hasPropertyDescriptor - ? Object.getOwnPropertyDescriptor(obj, key) - : null; - if (desc && (desc.get || desc.set)) { - Object.defineProperty(newObj, key, desc); - } else { - newObj[key] = obj[key]; - } - } - } - newObj.default = obj; - if (cache) { - cache.set(obj, newObj); - } - return newObj; -} - -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -const findSiblingsWithFileExtension = ( - moduleFileExtensions, - from, - moduleName -) => { - if (!path().isAbsolute(moduleName) && path().extname(moduleName) === '') { - const dirname = path().dirname(from); - const pathToModule = path().resolve(dirname, moduleName); - - try { - const slashedDirname = (0, _slash().default)(dirname); - - const matches = _glob() - .default.sync(`${pathToModule}.*`) - .map(match => (0, _slash().default)(match)) - .map(match => { - const relativePath = path().posix.relative(slashedDirname, match); - return path().posix.dirname(match) === slashedDirname - ? `./${relativePath}` - : relativePath; - }) - .map(match => `\t'${match}'`) - .join('\n'); - - if (matches) { - const foundMessage = `\n\nHowever, Jest was able to find:\n${matches}`; - const mappedModuleFileExtensions = moduleFileExtensions - .map(ext => `'${ext}'`) - .join(', '); - return ( - foundMessage + - "\n\nYou might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently " + - `[${mappedModuleFileExtensions}].\n\nSee https://jestjs.io/docs/en/configuration#modulefileextensions-arraystring` - ); - } - } catch (ignored) {} - } - - return ''; -}; - -exports.findSiblingsWithFileExtension = findSiblingsWithFileExtension; diff --git a/node_modules/jest-runtime/build/index.d.ts b/node_modules/jest-runtime/build/index.d.ts deleted file mode 100644 index d4ca7f59..00000000 --- a/node_modules/jest-runtime/build/index.d.ts +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import type { Config } from '@jest/types'; -import type { JestEnvironment } from '@jest/environment'; -import type { SourceMapRegistry } from '@jest/source-map'; -import { ShouldInstrumentOptions, shouldInstrument } from '@jest/transform'; -import type { V8CoverageResult } from '@jest/test-result'; -import { options as cliOptions } from './cli/args'; -import type { Context as JestContext } from './types'; -import HasteMap = require('jest-haste-map'); -import Resolver = require('jest-resolve'); -declare type HasteMapOptions = { - console?: Console; - maxWorkers: number; - resetCache: boolean; - watch?: boolean; - watchman: boolean; -}; -declare type InternalModuleOptions = { - isInternalModule: boolean; -}; -declare type CacheFS = { - [path: string]: string; -}; -declare namespace Runtime { - type Context = JestContext; - type RuntimeType = Runtime; -} -declare class Runtime { - private _cacheFS; - private _config; - private _coverageOptions; - private _currentlyExecutingModulePath; - private _environment; - private _explicitShouldMock; - private _internalModuleRegistry; - private _isCurrentlyExecutingManualMock; - private _mockFactories; - private _mockMetaDataCache; - private _mockRegistry; - private _isolatedMockRegistry; - private _moduleMocker; - private _isolatedModuleRegistry; - private _moduleRegistry; - private _needsCoverageMapped; - private _resolver; - private _shouldAutoMock; - private _shouldMockModuleCache; - private _shouldUnmockTransitiveDependenciesCache; - private _sourceMapRegistry; - private _scriptTransformer; - private _fileTransforms; - private _v8CoverageInstrumenter; - private _v8CoverageResult; - private _transitiveShouldMock; - private _unmockList; - private _virtualMocks; - private _moduleImplementation?; - constructor(config: Config.ProjectConfig, environment: JestEnvironment, resolver: Resolver, cacheFS?: CacheFS, coverageOptions?: ShouldInstrumentOptions); - static shouldInstrument: typeof shouldInstrument; - static createContext(config: Config.ProjectConfig, options: { - console?: Console; - maxWorkers: number; - watch?: boolean; - watchman: boolean; - }): Promise; - static createHasteMap(config: Config.ProjectConfig, options?: HasteMapOptions): HasteMap; - static createResolver(config: Config.ProjectConfig, moduleMap: HasteMap.ModuleMap): Resolver; - static runCLI(args?: Config.Argv, info?: Array): Promise; - static getCLIOptions(): typeof cliOptions; - requireModule(from: Config.Path, moduleName?: string, options?: InternalModuleOptions, isRequireActual?: boolean | null): T; - requireInternalModule(from: Config.Path, to?: string): T; - requireActual(from: Config.Path, moduleName: string): T; - requireMock(from: Config.Path, moduleName: string): T; - private _loadModule; - private _getFullTransformationOptions; - requireModuleOrMock(from: Config.Path, moduleName: string): unknown; - isolateModules(fn: () => void): void; - resetModules(): void; - collectV8Coverage(): Promise; - stopCollectingV8Coverage(): Promise; - getAllCoverageInfoCopy(): JestEnvironment['global']['__coverage__']; - getAllV8CoverageInfoCopy(): V8CoverageResult; - getSourceMapInfo(coveredFiles: Set): Record; - getSourceMaps(): SourceMapRegistry; - setMock(from: string, moduleName: string, mockFactory: () => unknown, options?: { - virtual?: boolean; - }): void; - restoreAllMocks(): void; - resetAllMocks(): void; - clearAllMocks(): void; - private _resolveModule; - private _requireResolve; - private _requireResolvePaths; - private _execModule; - private createScriptFromCode; - private _requireCoreModule; - private _getMockedNativeModule; - private _generateMock; - private _shouldMock; - private _createRequireImplementation; - private _createJestObjectFor; - private _logFormattedReferenceError; - private wrapCodeInModuleWrapper; - private constructInjectedModuleParameters; - private handleExecutionError; -} -export = Runtime; -//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-runtime/build/index.d.ts.map b/node_modules/jest-runtime/build/index.d.ts.map deleted file mode 100644 index 85228ee6..00000000 --- a/node_modules/jest-runtime/build/index.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAEV,eAAe,EAIhB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAIxD,OAAO,EAEL,uBAAuB,EAIvB,gBAAgB,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAIxD,OAAO,EAAC,OAAO,IAAI,UAAU,EAAC,MAAM,YAAY,CAAC;AAEjD,OAAO,KAAK,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,SAAS,CAAC;AAEpD,OAAO,QAAQ,GAAG,QAAQ,gBAAgB,CAAC,CAAC;AAC5C,OAAO,QAAQ,GAAG,QAAQ,cAAc,CAAC,CAAC;AAI1C,aAAK,eAAe,GAAG;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,aAAK,qBAAqB,GAAG;IAC3B,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAQF,aAAK,OAAO,GAAG;IAAC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CAAC,CAAC;AAExC,kBAAU,OAAO,CAAC;IAChB,KAAY,OAAO,GAAG,WAAW,CAAC;IAElC,KAAY,WAAW,GAAG,OAAO,CAAC;CACnC;AA2BD,cAAM,OAAO;IACX,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,gBAAgB,CAA0B;IAClD,OAAO,CAAC,6BAA6B,CAAS;IAC9C,OAAO,CAAC,YAAY,CAAkB;IACtC,OAAO,CAAC,mBAAmB,CAAgB;IAC3C,OAAO,CAAC,uBAAuB,CAAiB;IAChD,OAAO,CAAC,+BAA+B,CAAgB;IACvD,OAAO,CAAC,cAAc,CAAgC;IACtD,OAAO,CAAC,kBAAkB,CAExB;IACF,OAAO,CAAC,aAAa,CAAmB;IACxC,OAAO,CAAC,qBAAqB,CAA0B;IACvD,OAAO,CAAC,aAAa,CAAkB;IACvC,OAAO,CAAC,uBAAuB,CAAwB;IACvD,OAAO,CAAC,eAAe,CAAiB;IACxC,OAAO,CAAC,oBAAoB,CAAc;IAC1C,OAAO,CAAC,SAAS,CAAW;IAC5B,OAAO,CAAC,eAAe,CAAU;IACjC,OAAO,CAAC,sBAAsB,CAAgB;IAC9C,OAAO,CAAC,wCAAwC,CAAgB;IAChE,OAAO,CAAC,kBAAkB,CAAoB;IAC9C,OAAO,CAAC,kBAAkB,CAAoB;IAC9C,OAAO,CAAC,eAAe,CAA+B;IACtD,OAAO,CAAC,uBAAuB,CAAmC;IAClE,OAAO,CAAC,iBAAiB,CAAyB;IAClD,OAAO,CAAC,qBAAqB,CAAgB;IAC7C,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,qBAAqB,CAAC,CAA6B;gBAGzD,MAAM,EAAE,MAAM,CAAC,aAAa,EAC5B,WAAW,EAAE,eAAe,EAC5B,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,OAAO,EACjB,eAAe,CAAC,EAAE,uBAAuB;IA2D3C,MAAM,CAAC,gBAAgB,0BAAoB;IAE3C,MAAM,CAAC,aAAa,CAClB,MAAM,EAAE,MAAM,CAAC,aAAa,EAC5B,OAAO,EAAE;QACP,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,QAAQ,EAAE,OAAO,CAAC;KACnB,GACA,OAAO,CAAC,WAAW,CAAC;IAsBvB,MAAM,CAAC,cAAc,CACnB,MAAM,EAAE,MAAM,CAAC,aAAa,EAC5B,OAAO,CAAC,EAAE,eAAe,GACxB,QAAQ;IAmCX,MAAM,CAAC,cAAc,CACnB,MAAM,EAAE,MAAM,CAAC,aAAa,EAC5B,SAAS,EAAE,QAAQ,CAAC,SAAS,GAC5B,QAAQ;IAeX,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAItE,MAAM,CAAC,aAAa,IAAI,OAAO,UAAU;IAIzC,aAAa,CAAC,CAAC,GAAG,OAAO,EACvB,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,qBAAqB,EAC/B,eAAe,CAAC,EAAE,OAAO,GAAG,IAAI,GAC/B,CAAC;IA4EJ,qBAAqB,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC;IAIrE,aAAa,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC;IAIpE,WAAW,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC;IAuFlE,OAAO,CAAC,WAAW;IA8BnB,OAAO,CAAC,6BAA6B;IAarC,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO;IA8BnE,cAAc,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI;IAgBpC,YAAY,IAAI,IAAI;IA2Bd,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAMlC,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC;IAO/C,sBAAsB,IAAI,eAAe,CAAC,QAAQ,CAAC,CAAC,cAAc,CAAC;IAInE,wBAAwB,IAAI,gBAAgB;IAyB5C,gBAAgB,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAgBnE,aAAa,IAAI,iBAAiB;IAIlC,OAAO,CACL,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,OAAO,EAC1B,OAAO,CAAC,EAAE;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAC,GAC5B,IAAI;IAcP,eAAe,IAAI,IAAI;IAIvB,aAAa,IAAI,IAAI;IAIrB,aAAa,IAAI,IAAI;IAIrB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,eAAe;IA8CvB,OAAO,CAAC,oBAAoB;IAqB5B,OAAO,CAAC,WAAW;IA4InB,OAAO,CAAC,oBAAoB;IAa5B,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,sBAAsB;IAiE9B,OAAO,CAAC,aAAa;IAwCrB,OAAO,CAAC,WAAW;IA8DnB,OAAO,CAAC,4BAA4B;IAwCpC,OAAO,CAAC,oBAAoB;IA8J5B,OAAO,CAAC,2BAA2B;IAenC,OAAO,CAAC,uBAAuB;IAY/B,OAAO,CAAC,iCAAiC;IAazC,OAAO,CAAC,oBAAoB;CAiB7B;AAED,SAAS,OAAO,CAAC"} \ No newline at end of file diff --git a/node_modules/jest-runtime/build/index.js b/node_modules/jest-runtime/build/index.js deleted file mode 100644 index 9fd9eedb..00000000 --- a/node_modules/jest-runtime/build/index.js +++ /dev/null @@ -1,1551 +0,0 @@ -'use strict'; - -function _url() { - const data = require('url'); - - _url = function () { - return data; - }; - - return data; -} - -function path() { - const data = _interopRequireWildcard(require('path')); - - path = function () { - return data; - }; - - return data; -} - -function _vm() { - const data = require('vm'); - - _vm = function () { - return data; - }; - - return data; -} - -function nativeModule() { - const data = _interopRequireWildcard(require('module')); - - nativeModule = function () { - return data; - }; - - return data; -} - -function _jestMessageUtil() { - const data = require('jest-message-util'); - - _jestMessageUtil = function () { - return data; - }; - - return data; -} - -function _jestUtil() { - const data = require('jest-util'); - - _jestUtil = function () { - return data; - }; - - return data; -} - -function _jestRegexUtil() { - const data = require('jest-regex-util'); - - _jestRegexUtil = function () { - return data; - }; - - return data; -} - -function _transform() { - const data = require('@jest/transform'); - - _transform = function () { - return data; - }; - - return data; -} - -function _collectV8Coverage() { - const data = require('collect-v8-coverage'); - - _collectV8Coverage = function () { - return data; - }; - - return data; -} - -function fs() { - const data = _interopRequireWildcard(require('graceful-fs')); - - fs = function () { - return data; - }; - - return data; -} - -var _cli = require('./cli'); - -var _args = require('./cli/args'); - -var _helpers = require('./helpers'); - -function _jestMock() { - const data = _interopRequireDefault(require('jest-mock')); - - _jestMock = function () { - return data; - }; - - return data; -} - -function _jestHasteMap() { - const data = _interopRequireDefault(require('jest-haste-map')); - - _jestHasteMap = function () { - return data; - }; - - return data; -} - -function _jestResolve() { - const data = _interopRequireDefault(require('jest-resolve')); - - _jestResolve = function () { - return data; - }; - - return data; -} - -function _jestSnapshot() { - const data = _interopRequireDefault(require('jest-snapshot')); - - _jestSnapshot = function () { - return data; - }; - - return data; -} - -function _stripBom() { - const data = _interopRequireDefault(require('strip-bom')); - - _stripBom = function () { - return data; - }; - - return data; -} - -function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : {default: obj}; -} - -function _getRequireWildcardCache() { - if (typeof WeakMap !== 'function') return null; - var cache = new WeakMap(); - _getRequireWildcardCache = function () { - return cache; - }; - return cache; -} - -function _interopRequireWildcard(obj) { - if (obj && obj.__esModule) { - return obj; - } - if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { - return {default: obj}; - } - var cache = _getRequireWildcardCache(); - if (cache && cache.has(obj)) { - return cache.get(obj); - } - var newObj = {}; - var hasPropertyDescriptor = - Object.defineProperty && Object.getOwnPropertyDescriptor; - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) { - var desc = hasPropertyDescriptor - ? Object.getOwnPropertyDescriptor(obj, key) - : null; - if (desc && (desc.get || desc.set)) { - Object.defineProperty(newObj, key, desc); - } else { - newObj[key] = obj[key]; - } - } - } - newObj.default = obj; - if (cache) { - cache.set(obj, newObj); - } - return newObj; -} - -function ownKeys(object, enumerableOnly) { - var keys = Object.keys(object); - if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(object); - if (enumerableOnly) - symbols = symbols.filter(function (sym) { - return Object.getOwnPropertyDescriptor(object, sym).enumerable; - }); - keys.push.apply(keys, symbols); - } - return keys; -} - -function _objectSpread(target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i] != null ? arguments[i] : {}; - if (i % 2) { - ownKeys(Object(source), true).forEach(function (key) { - _defineProperty(target, key, source[key]); - }); - } else if (Object.getOwnPropertyDescriptors) { - Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); - } else { - ownKeys(Object(source)).forEach(function (key) { - Object.defineProperty( - target, - key, - Object.getOwnPropertyDescriptor(source, key) - ); - }); - } - } - return target; -} - -function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - return obj; -} - -const testTimeoutSymbol = Symbol.for('TEST_TIMEOUT_SYMBOL'); -const retryTimesSymbol = Symbol.for('RETRY_TIMES'); -const NODE_MODULES = path().sep + 'node_modules' + path().sep; - -const getModuleNameMapper = config => { - if ( - Array.isArray(config.moduleNameMapper) && - config.moduleNameMapper.length - ) { - return config.moduleNameMapper.map(([regex, moduleName]) => ({ - moduleName, - regex: new RegExp(regex) - })); - } - - return null; -}; - -const unmockRegExpCache = new WeakMap(); -const EVAL_RESULT_VARIABLE = 'Object.'; - -/* eslint-disable-next-line no-redeclare */ -class Runtime { - constructor(config, environment, resolver, cacheFS, coverageOptions) { - _defineProperty(this, '_cacheFS', void 0); - - _defineProperty(this, '_config', void 0); - - _defineProperty(this, '_coverageOptions', void 0); - - _defineProperty(this, '_currentlyExecutingModulePath', void 0); - - _defineProperty(this, '_environment', void 0); - - _defineProperty(this, '_explicitShouldMock', void 0); - - _defineProperty(this, '_internalModuleRegistry', void 0); - - _defineProperty(this, '_isCurrentlyExecutingManualMock', void 0); - - _defineProperty(this, '_mockFactories', void 0); - - _defineProperty(this, '_mockMetaDataCache', void 0); - - _defineProperty(this, '_mockRegistry', void 0); - - _defineProperty(this, '_isolatedMockRegistry', void 0); - - _defineProperty(this, '_moduleMocker', void 0); - - _defineProperty(this, '_isolatedModuleRegistry', void 0); - - _defineProperty(this, '_moduleRegistry', void 0); - - _defineProperty(this, '_needsCoverageMapped', void 0); - - _defineProperty(this, '_resolver', void 0); - - _defineProperty(this, '_shouldAutoMock', void 0); - - _defineProperty(this, '_shouldMockModuleCache', void 0); - - _defineProperty(this, '_shouldUnmockTransitiveDependenciesCache', void 0); - - _defineProperty(this, '_sourceMapRegistry', void 0); - - _defineProperty(this, '_scriptTransformer', void 0); - - _defineProperty(this, '_fileTransforms', void 0); - - _defineProperty(this, '_v8CoverageInstrumenter', void 0); - - _defineProperty(this, '_v8CoverageResult', void 0); - - _defineProperty(this, '_transitiveShouldMock', void 0); - - _defineProperty(this, '_unmockList', void 0); - - _defineProperty(this, '_virtualMocks', void 0); - - _defineProperty(this, '_moduleImplementation', void 0); - - this._cacheFS = cacheFS || Object.create(null); - this._config = config; - this._coverageOptions = coverageOptions || { - changedFiles: undefined, - collectCoverage: false, - collectCoverageFrom: [], - collectCoverageOnlyFrom: undefined, - coverageProvider: 'babel' - }; - this._currentlyExecutingModulePath = ''; - this._environment = environment; - this._explicitShouldMock = Object.create(null); - this._internalModuleRegistry = new Map(); - this._isCurrentlyExecutingManualMock = null; - this._mockFactories = Object.create(null); - this._mockRegistry = new Map(); // during setup, this cannot be null (and it's fine to explode if it is) - - this._moduleMocker = this._environment.moduleMocker; - this._isolatedModuleRegistry = null; - this._isolatedMockRegistry = null; - this._moduleRegistry = new Map(); - this._needsCoverageMapped = new Set(); - this._resolver = resolver; - this._scriptTransformer = new (_transform().ScriptTransformer)(config); - this._shouldAutoMock = config.automock; - this._sourceMapRegistry = Object.create(null); - this._fileTransforms = new Map(); - this._virtualMocks = Object.create(null); - this._mockMetaDataCache = Object.create(null); - this._shouldMockModuleCache = Object.create(null); - this._shouldUnmockTransitiveDependenciesCache = Object.create(null); - this._transitiveShouldMock = Object.create(null); - this._unmockList = unmockRegExpCache.get(config); - - if (!this._unmockList && config.unmockedModulePathPatterns) { - this._unmockList = new RegExp( - config.unmockedModulePathPatterns.join('|') - ); - unmockRegExpCache.set(config, this._unmockList); - } - - if (config.automock) { - config.setupFiles.forEach(filePath => { - if (filePath && filePath.includes(NODE_MODULES)) { - const moduleID = this._resolver.getModuleID( - this._virtualMocks, - filePath - ); - - this._transitiveShouldMock[moduleID] = false; - } - }); - } - - this.resetModules(); - } - - static createContext(config, options) { - (0, _jestUtil().createDirectory)(config.cacheDirectory); - const instance = Runtime.createHasteMap(config, { - console: options.console, - maxWorkers: options.maxWorkers, - resetCache: !config.cache, - watch: options.watch, - watchman: options.watchman - }); - return instance.build().then( - hasteMap => ({ - config, - hasteFS: hasteMap.hasteFS, - moduleMap: hasteMap.moduleMap, - resolver: Runtime.createResolver(config, hasteMap.moduleMap) - }), - error => { - throw error; - } - ); - } - - static createHasteMap(config, options) { - const ignorePatternParts = [ - ...config.modulePathIgnorePatterns, - ...(options && options.watch ? config.watchPathIgnorePatterns : []), - config.cacheDirectory.startsWith(config.rootDir + path().sep) && - config.cacheDirectory - ].filter(Boolean); - const ignorePattern = - ignorePatternParts.length > 0 - ? new RegExp(ignorePatternParts.join('|')) - : undefined; - return new (_jestHasteMap().default)({ - cacheDirectory: config.cacheDirectory, - computeSha1: config.haste.computeSha1, - console: options && options.console, - dependencyExtractor: config.dependencyExtractor, - extensions: [_jestSnapshot().default.EXTENSION].concat( - config.moduleFileExtensions - ), - hasteImplModulePath: config.haste.hasteImplModulePath, - ignorePattern, - maxWorkers: (options && options.maxWorkers) || 1, - mocksPattern: (0, _jestRegexUtil().escapePathForRegex)( - path().sep + '__mocks__' + path().sep - ), - name: config.name, - platforms: config.haste.platforms || ['ios', 'android'], - providesModuleNodeModules: config.haste.providesModuleNodeModules, - resetCache: options && options.resetCache, - retainAllFiles: false, - rootDir: config.rootDir, - roots: config.roots, - throwOnModuleCollision: config.haste.throwOnModuleCollision, - useWatchman: options && options.watchman, - watch: options && options.watch - }); - } - - static createResolver(config, moduleMap) { - return new (_jestResolve().default)(moduleMap, { - browser: config.browser, - defaultPlatform: config.haste.defaultPlatform, - extensions: config.moduleFileExtensions.map(extension => '.' + extension), - hasCoreModules: true, - moduleDirectories: config.moduleDirectories, - moduleNameMapper: getModuleNameMapper(config), - modulePaths: config.modulePaths, - platforms: config.haste.platforms, - resolver: config.resolver, - rootDir: config.rootDir - }); - } - - static runCLI(args, info) { - return (0, _cli.run)(args, info); - } - - static getCLIOptions() { - return _args.options; - } - - requireModule(from, moduleName, options, isRequireActual) { - const moduleID = this._resolver.getModuleID( - this._virtualMocks, - from, - moduleName - ); - - let modulePath; // Some old tests rely on this mocking behavior. Ideally we'll change this - // to be more explicit. - - const moduleResource = moduleName && this._resolver.getModule(moduleName); - - const manualMock = - moduleName && this._resolver.getMockModule(from, moduleName); - - if ( - (!options || !options.isInternalModule) && - !isRequireActual && - !moduleResource && - manualMock && - manualMock !== this._isCurrentlyExecutingManualMock && - this._explicitShouldMock[moduleID] !== false - ) { - modulePath = manualMock; - } - - if (moduleName && this._resolver.isCoreModule(moduleName)) { - return this._requireCoreModule(moduleName); - } - - if (!modulePath) { - modulePath = this._resolveModule(from, moduleName); - } - - let moduleRegistry; - - if (!options || !options.isInternalModule) { - if ( - this._moduleRegistry.get(modulePath) || - !this._isolatedModuleRegistry - ) { - moduleRegistry = this._moduleRegistry; - } else { - moduleRegistry = this._isolatedModuleRegistry; - } - } else { - moduleRegistry = this._internalModuleRegistry; - } - - const module = moduleRegistry.get(modulePath); - - if (module) { - return module.exports; - } // We must register the pre-allocated module object first so that any - // circular dependencies that may arise while evaluating the module can - // be satisfied. - - const localModule = { - children: [], - exports: {}, - filename: modulePath, - id: modulePath, - loaded: false - }; - moduleRegistry.set(modulePath, localModule); - - this._loadModule( - localModule, - from, - moduleName, - modulePath, - options, - moduleRegistry - ); - - return localModule.exports; - } - - requireInternalModule(from, to) { - return this.requireModule(from, to, { - isInternalModule: true - }); - } - - requireActual(from, moduleName) { - return this.requireModule(from, moduleName, undefined, true); - } - - requireMock(from, moduleName) { - const moduleID = this._resolver.getModuleID( - this._virtualMocks, - from, - moduleName - ); - - if ( - this._isolatedMockRegistry && - this._isolatedMockRegistry.get(moduleID) - ) { - return this._isolatedMockRegistry.get(moduleID); - } else if (this._mockRegistry.get(moduleID)) { - return this._mockRegistry.get(moduleID); - } - - const mockRegistry = this._isolatedMockRegistry || this._mockRegistry; - - if (moduleID in this._mockFactories) { - const module = this._mockFactories[moduleID](); - - mockRegistry.set(moduleID, module); - return module; - } - - const manualMockOrStub = this._resolver.getMockModule(from, moduleName); - - let modulePath; - - if (manualMockOrStub) { - modulePath = this._resolveModule(from, manualMockOrStub); - } else { - modulePath = this._resolveModule(from, moduleName); - } - - let isManualMock = - manualMockOrStub && - !this._resolver.resolveStubModuleName(from, moduleName); - - if (!isManualMock) { - // If the actual module file has a __mocks__ dir sitting immediately next - // to it, look to see if there is a manual mock for this file. - // - // subDir1/my_module.js - // subDir1/__mocks__/my_module.js - // subDir2/my_module.js - // subDir2/__mocks__/my_module.js - // - // Where some other module does a relative require into each of the - // respective subDir{1,2} directories and expects a manual mock - // corresponding to that particular my_module.js file. - const moduleDir = path().dirname(modulePath); - const moduleFileName = path().basename(modulePath); - const potentialManualMock = path().join( - moduleDir, - '__mocks__', - moduleFileName - ); - - if (fs().existsSync(potentialManualMock)) { - isManualMock = true; - modulePath = potentialManualMock; - } - } - - if (isManualMock) { - const localModule = { - children: [], - exports: {}, - filename: modulePath, - id: modulePath, - loaded: false - }; - - this._loadModule( - localModule, - from, - moduleName, - modulePath, - undefined, - mockRegistry - ); - - mockRegistry.set(moduleID, localModule.exports); - } else { - // Look for a real module to generate an automock from - mockRegistry.set(moduleID, this._generateMock(from, moduleName)); - } - - return mockRegistry.get(moduleID); - } - - _loadModule( - localModule, - from, - moduleName, - modulePath, - options, - moduleRegistry - ) { - if (path().extname(modulePath) === '.json') { - const text = (0, _stripBom().default)( - fs().readFileSync(modulePath, 'utf8') - ); - - const transformedFile = this._scriptTransformer.transformJson( - modulePath, - this._getFullTransformationOptions(options), - text - ); - - localModule.exports = this._environment.global.JSON.parse( - transformedFile - ); - } else if (path().extname(modulePath) === '.node') { - localModule.exports = require(modulePath); - } else { - // Only include the fromPath if a moduleName is given. Else treat as root. - const fromPath = moduleName ? from : null; - - this._execModule(localModule, options, moduleRegistry, fromPath); - } - - localModule.loaded = true; - } - - _getFullTransformationOptions(options) { - return _objectSpread({}, options, { - changedFiles: this._coverageOptions.changedFiles, - collectCoverage: this._coverageOptions.collectCoverage, - collectCoverageFrom: this._coverageOptions.collectCoverageFrom, - collectCoverageOnlyFrom: this._coverageOptions.collectCoverageOnlyFrom, - coverageProvider: this._coverageOptions.coverageProvider - }); - } - - requireModuleOrMock(from, moduleName) { - try { - if (this._shouldMock(from, moduleName)) { - return this.requireMock(from, moduleName); - } else { - return this.requireModule(from, moduleName); - } - } catch (e) { - const moduleNotFound = _jestResolve().default.tryCastModuleNotFoundError( - e - ); - - if (moduleNotFound) { - if ( - moduleNotFound.siblingWithSimilarExtensionFound === null || - moduleNotFound.siblingWithSimilarExtensionFound === undefined - ) { - moduleNotFound.hint = (0, _helpers.findSiblingsWithFileExtension)( - this._config.moduleFileExtensions, - from, - moduleNotFound.moduleName || moduleName - ); - moduleNotFound.siblingWithSimilarExtensionFound = Boolean( - moduleNotFound.hint - ); - } - - moduleNotFound.buildMessage(this._config.rootDir); - throw moduleNotFound; - } - - throw e; - } - } - - isolateModules(fn) { - if (this._isolatedModuleRegistry || this._isolatedMockRegistry) { - throw new Error( - 'isolateModules cannot be nested inside another isolateModules.' - ); - } - - this._isolatedModuleRegistry = new Map(); - this._isolatedMockRegistry = new Map(); - - try { - fn(); - } finally { - this._isolatedModuleRegistry = null; - this._isolatedMockRegistry = null; - } - } - - resetModules() { - this._isolatedModuleRegistry = null; - this._isolatedMockRegistry = null; - - this._mockRegistry.clear(); - - this._moduleRegistry.clear(); - - if (this._environment) { - if (this._environment.global) { - const envGlobal = this._environment.global; - Object.keys(envGlobal).forEach(key => { - const globalMock = envGlobal[key]; - - if ( - ((typeof globalMock === 'object' && globalMock !== null) || - typeof globalMock === 'function') && - globalMock._isMockFunction === true - ) { - globalMock.mockClear(); - } - }); - } - - if (this._environment.fakeTimers) { - this._environment.fakeTimers.clearAllTimers(); - } - } - } - - async collectV8Coverage() { - this._v8CoverageInstrumenter = new (_collectV8Coverage().CoverageInstrumenter)(); - await this._v8CoverageInstrumenter.startInstrumenting(); - } - - async stopCollectingV8Coverage() { - if (!this._v8CoverageInstrumenter) { - throw new Error('You need to call `collectV8Coverage` first.'); - } - - this._v8CoverageResult = await this._v8CoverageInstrumenter.stopInstrumenting(); - } - - getAllCoverageInfoCopy() { - return (0, _jestUtil().deepCyclicCopy)( - this._environment.global.__coverage__ - ); - } - - getAllV8CoverageInfoCopy() { - if (!this._v8CoverageResult) { - throw new Error('You need to `stopCollectingV8Coverage` first'); - } - - return this._v8CoverageResult - .filter(res => res.url.startsWith('file://')) - .map(res => - _objectSpread({}, res, { - url: (0, _url().fileURLToPath)(res.url) - }) - ) - .filter( - ( - res // TODO: will this work on windows? It might be better if `shouldInstrument` deals with it anyways - ) => - res.url.startsWith(this._config.rootDir) && - this._fileTransforms.has(res.url) && - (0, _transform().shouldInstrument)( - res.url, - this._coverageOptions, - this._config - ) - ) - .map(result => { - const transformedFile = this._fileTransforms.get(result.url); - - return { - codeTransformResult: transformedFile, - result - }; - }); - } - - getSourceMapInfo(coveredFiles) { - return Object.keys(this._sourceMapRegistry).reduce((result, sourcePath) => { - if ( - coveredFiles.has(sourcePath) && - this._needsCoverageMapped.has(sourcePath) && - fs().existsSync(this._sourceMapRegistry[sourcePath]) - ) { - result[sourcePath] = this._sourceMapRegistry[sourcePath]; - } - - return result; - }, {}); - } - - getSourceMaps() { - return this._sourceMapRegistry; - } - - setMock(from, moduleName, mockFactory, options) { - if (options && options.virtual) { - const mockPath = this._resolver.getModulePath(from, moduleName); - - this._virtualMocks[mockPath] = true; - } - - const moduleID = this._resolver.getModuleID( - this._virtualMocks, - from, - moduleName - ); - - this._explicitShouldMock[moduleID] = true; - this._mockFactories[moduleID] = mockFactory; - } - - restoreAllMocks() { - this._moduleMocker.restoreAllMocks(); - } - - resetAllMocks() { - this._moduleMocker.resetAllMocks(); - } - - clearAllMocks() { - this._moduleMocker.clearAllMocks(); - } - - _resolveModule(from, to) { - return to ? this._resolver.resolveModule(from, to) : from; - } - - _requireResolve(from, moduleName, options = {}) { - if (moduleName == null) { - throw new Error( - 'The first argument to require.resolve must be a string. Received null or undefined.' - ); - } - - const {paths} = options; - - if (paths) { - for (const p of paths) { - const absolutePath = path().resolve(from, '..', p); - - const module = this._resolver.resolveModuleFromDirIfExists( - absolutePath, - moduleName, // required to also resolve files without leading './' directly in the path - { - paths: [absolutePath] - } - ); - - if (module) { - return module; - } - } - - throw new (_jestResolve().default.ModuleNotFoundError)( - `Cannot resolve module '${moduleName}' from paths ['${paths.join( - "', '" - )}'] from ${from}` - ); - } - - try { - return this._resolveModule(from, moduleName); - } catch (err) { - const module = this._resolver.getMockModule(from, moduleName); - - if (module) { - return module; - } else { - throw err; - } - } - } - - _requireResolvePaths(from, moduleName) { - if (moduleName == null) { - throw new Error( - 'The first argument to require.resolve.paths must be a string. Received null or undefined.' - ); - } - - if (!moduleName.length) { - throw new Error( - 'The first argument to require.resolve.paths must not be the empty string.' - ); - } - - if (moduleName[0] === '.') { - return [path().resolve(from, '..')]; - } - - if (this._resolver.isCoreModule(moduleName)) { - return null; - } - - return this._resolver.getModulePaths(path().resolve(from, '..')); - } - - _execModule(localModule, options, moduleRegistry, from) { - // If the environment was disposed, prevent this module from being executed. - if (!this._environment.global) { - return; - } - - const filename = localModule.filename; - const lastExecutingModulePath = this._currentlyExecutingModulePath; - this._currentlyExecutingModulePath = filename; - const origCurrExecutingManualMock = this._isCurrentlyExecutingManualMock; - this._isCurrentlyExecutingManualMock = filename; - const dirname = path().dirname(filename); - localModule.children = []; - Object.defineProperty(localModule, 'parent', { - enumerable: true, - - get() { - const key = from || ''; - return moduleRegistry.get(key) || null; - } - }); - localModule.paths = this._resolver.getModulePaths(dirname); - Object.defineProperty(localModule, 'require', { - value: this._createRequireImplementation(localModule, options) - }); - - const transformedFile = this._scriptTransformer.transform( - filename, - this._getFullTransformationOptions(options), - this._cacheFS[filename] - ); // we only care about non-internal modules - - if (!options || !options.isInternalModule) { - this._fileTransforms.set(filename, transformedFile); - } - - if (transformedFile.sourceMapPath) { - this._sourceMapRegistry[filename] = transformedFile.sourceMapPath; - - if (transformedFile.mapCoverage) { - this._needsCoverageMapped.add(filename); - } - } - - let compiledFunction = null; // Use this if available instead of deprecated `JestEnvironment.runScript` - - if (typeof this._environment.getVmContext === 'function') { - const vmContext = this._environment.getVmContext(); - - if (vmContext) { - if (typeof _vm().compileFunction === 'function') { - try { - compiledFunction = (0, _vm().compileFunction)( - transformedFile.code, - this.constructInjectedModuleParameters(), - { - filename, - parsingContext: vmContext - } - ); - } catch (e) { - throw (0, _transform().handlePotentialSyntaxError)(e); - } - } else { - const script = this.createScriptFromCode( - transformedFile.code, - filename - ); - const runScript = script.runInContext(vmContext); - - if (runScript === null) { - compiledFunction = null; - } else { - compiledFunction = runScript[EVAL_RESULT_VARIABLE]; - } - } - } - } else { - const script = this.createScriptFromCode(transformedFile.code, filename); - - const runScript = this._environment.runScript(script); - - if (runScript === null) { - compiledFunction = null; - } else { - compiledFunction = runScript[EVAL_RESULT_VARIABLE]; - } - } - - if (compiledFunction === null) { - this._logFormattedReferenceError( - 'You are trying to `import` a file after the Jest environment has been torn down.' - ); - - process.exitCode = 1; - return; - } - - try { - compiledFunction.call( - localModule.exports, - localModule, // module object - localModule.exports, // module exports - localModule.require, // require implementation - dirname, // __dirname - filename, // __filename - this._environment.global, // global object - this._createJestObjectFor(filename, localModule.require), // jest object - ...this._config.extraGlobals.map(globalVariable => { - if (this._environment.global[globalVariable]) { - return this._environment.global[globalVariable]; - } - - throw new Error( - `You have requested '${globalVariable}' as a global variable, but it was not present. Please check your config or your global environment.` - ); - }) - ); - } catch (error) { - this.handleExecutionError(error, localModule); - } - - this._isCurrentlyExecutingManualMock = origCurrExecutingManualMock; - this._currentlyExecutingModulePath = lastExecutingModulePath; - } - - createScriptFromCode(scriptSource, filename) { - try { - return new (_vm().Script)(this.wrapCodeInModuleWrapper(scriptSource), { - displayErrors: true, - filename: this._resolver.isCoreModule(filename) - ? `jest-nodejs-core-${filename}` - : filename - }); - } catch (e) { - throw (0, _transform().handlePotentialSyntaxError)(e); - } - } - - _requireCoreModule(moduleName) { - if (moduleName === 'process') { - return this._environment.global.process; - } - - if (moduleName === 'module') { - return this._getMockedNativeModule(); - } - - return require(moduleName); - } - - _getMockedNativeModule() { - if (this._moduleImplementation) { - return this._moduleImplementation; - } - - const createRequire = modulePath => { - const filename = - typeof modulePath === 'string' - ? modulePath.startsWith('file:///') - ? (0, _url().fileURLToPath)(new (_url().URL)(modulePath)) - : modulePath - : (0, _url().fileURLToPath)(modulePath); - - if (!path().isAbsolute(filename)) { - const error = new TypeError( - `The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received '${filename}'` - ); // @ts-ignore - - error.code = 'ERR_INVALID_ARG_TYPE'; - throw error; - } - - return this._createRequireImplementation({ - children: [], - exports: {}, - filename, - id: filename, - loaded: false - }); - }; // should we implement the class ourselves? - - class Module extends nativeModule().Module {} - - Module.Module = Module; - - if ('createRequire' in nativeModule()) { - Module.createRequire = createRequire; - } - - if ('createRequireFromPath' in nativeModule()) { - Module.createRequireFromPath = filename => { - if (typeof filename !== 'string') { - const error = new TypeError( - `The argument 'filename' must be string. Received '${filename}'.${ - filename instanceof _url().URL - ? ' Use createRequire for URL filename.' - : '' - }` - ); // @ts-ignore - - error.code = 'ERR_INVALID_ARG_TYPE'; - throw error; - } - - return createRequire(filename); - }; - } - - if ('syncBuiltinESMExports' in nativeModule()) { - Module.syncBuiltinESMExports = () => {}; - } - - this._moduleImplementation = Module; - return Module; - } - - _generateMock(from, moduleName) { - const modulePath = - this._resolver.resolveStubModuleName(from, moduleName) || - this._resolveModule(from, moduleName); - - if (!(modulePath in this._mockMetaDataCache)) { - // This allows us to handle circular dependencies while generating an - // automock - this._mockMetaDataCache[modulePath] = - this._moduleMocker.getMetadata({}) || {}; // In order to avoid it being possible for automocking to potentially - // cause side-effects within the module environment, we need to execute - // the module in isolation. This could cause issues if the module being - // mocked has calls into side-effectful APIs on another module. - - const origMockRegistry = this._mockRegistry; - const origModuleRegistry = this._moduleRegistry; - this._mockRegistry = new Map(); - this._moduleRegistry = new Map(); - const moduleExports = this.requireModule(from, moduleName); // Restore the "real" module/mock registries - - this._mockRegistry = origMockRegistry; - this._moduleRegistry = origModuleRegistry; - - const mockMetadata = this._moduleMocker.getMetadata(moduleExports); - - if (mockMetadata == null) { - throw new Error( - `Failed to get mock metadata: ${modulePath}\n\n` + - `See: https://jestjs.io/docs/manual-mocks.html#content` - ); - } - - this._mockMetaDataCache[modulePath] = mockMetadata; - } - - return this._moduleMocker.generateFromMetadata( - this._mockMetaDataCache[modulePath] - ); - } - - _shouldMock(from, moduleName) { - const explicitShouldMock = this._explicitShouldMock; - - const moduleID = this._resolver.getModuleID( - this._virtualMocks, - from, - moduleName - ); - - const key = from + path().delimiter + moduleID; - - if (moduleID in explicitShouldMock) { - return explicitShouldMock[moduleID]; - } - - if ( - !this._shouldAutoMock || - this._resolver.isCoreModule(moduleName) || - this._shouldUnmockTransitiveDependenciesCache[key] - ) { - return false; - } - - if (moduleID in this._shouldMockModuleCache) { - return this._shouldMockModuleCache[moduleID]; - } - - let modulePath; - - try { - modulePath = this._resolveModule(from, moduleName); - } catch (e) { - const manualMock = this._resolver.getMockModule(from, moduleName); - - if (manualMock) { - this._shouldMockModuleCache[moduleID] = true; - return true; - } - - throw e; - } - - if (this._unmockList && this._unmockList.test(modulePath)) { - this._shouldMockModuleCache[moduleID] = false; - return false; - } // transitive unmocking for package managers that store flat packages (npm3) - - const currentModuleID = this._resolver.getModuleID( - this._virtualMocks, - from - ); - - if ( - this._transitiveShouldMock[currentModuleID] === false || - (from.includes(NODE_MODULES) && - modulePath.includes(NODE_MODULES) && - ((this._unmockList && this._unmockList.test(from)) || - explicitShouldMock[currentModuleID] === false)) - ) { - this._transitiveShouldMock[moduleID] = false; - this._shouldUnmockTransitiveDependenciesCache[key] = true; - return false; - } - - return (this._shouldMockModuleCache[moduleID] = true); - } - - _createRequireImplementation(from, options) { - // TODO: somehow avoid having to type the arguments - they should come from `NodeRequire/LocalModuleRequire.resolve` - const resolve = (moduleName, options) => - this._requireResolve(from.filename, moduleName, options); - - resolve.paths = moduleName => - this._requireResolvePaths(from.filename, moduleName); - - const moduleRequire = - options && options.isInternalModule - ? moduleName => this.requireInternalModule(from.filename, moduleName) - : this.requireModuleOrMock.bind(this, from.filename); - moduleRequire.cache = Object.create(null); - moduleRequire.extensions = Object.create(null); - moduleRequire.requireActual = this.requireActual.bind(this, from.filename); - moduleRequire.requireMock = this.requireMock.bind(this, from.filename); - moduleRequire.resolve = resolve; - Object.defineProperty(moduleRequire, 'main', { - enumerable: true, - - get() { - let mainModule = from.parent; - - while ( - mainModule && - mainModule.parent && - mainModule.id !== mainModule.parent.id - ) { - mainModule = mainModule.parent; - } - - return mainModule; - } - }); - return moduleRequire; - } - - _createJestObjectFor(from, localRequire) { - const disableAutomock = () => { - this._shouldAutoMock = false; - return jestObject; - }; - - const enableAutomock = () => { - this._shouldAutoMock = true; - return jestObject; - }; - - const unmock = moduleName => { - const moduleID = this._resolver.getModuleID( - this._virtualMocks, - from, - moduleName - ); - - this._explicitShouldMock[moduleID] = false; - return jestObject; - }; - - const deepUnmock = moduleName => { - const moduleID = this._resolver.getModuleID( - this._virtualMocks, - from, - moduleName - ); - - this._explicitShouldMock[moduleID] = false; - this._transitiveShouldMock[moduleID] = false; - return jestObject; - }; - - const mock = (moduleName, mockFactory, options) => { - if (mockFactory !== undefined) { - return setMockFactory(moduleName, mockFactory, options); - } - - const moduleID = this._resolver.getModuleID( - this._virtualMocks, - from, - moduleName - ); - - this._explicitShouldMock[moduleID] = true; - return jestObject; - }; - - const setMockFactory = (moduleName, mockFactory, options) => { - this.setMock(from, moduleName, mockFactory, options); - return jestObject; - }; - - const clearAllMocks = () => { - this.clearAllMocks(); - return jestObject; - }; - - const resetAllMocks = () => { - this.resetAllMocks(); - return jestObject; - }; - - const restoreAllMocks = () => { - this.restoreAllMocks(); - return jestObject; - }; - - const useFakeTimers = () => { - _getFakeTimers().useFakeTimers(); - - return jestObject; - }; - - const useRealTimers = () => { - _getFakeTimers().useRealTimers(); - - return jestObject; - }; - - const resetModules = () => { - this.resetModules(); - return jestObject; - }; - - const isolateModules = fn => { - this.isolateModules(fn); - return jestObject; - }; - - const fn = this._moduleMocker.fn.bind(this._moduleMocker); - - const spyOn = this._moduleMocker.spyOn.bind(this._moduleMocker); - - const setTimeout = timeout => { - if (this._environment.global.jasmine) { - this._environment.global.jasmine._DEFAULT_TIMEOUT_INTERVAL = timeout; - } else { - // @ts-ignore: https://github.com/Microsoft/TypeScript/issues/24587 - this._environment.global[testTimeoutSymbol] = timeout; - } - - return jestObject; - }; - - const retryTimes = numTestRetries => { - // @ts-ignore: https://github.com/Microsoft/TypeScript/issues/24587 - this._environment.global[retryTimesSymbol] = numTestRetries; - return jestObject; - }; - - const _getFakeTimers = () => { - if (!this._environment.fakeTimers) { - this._logFormattedReferenceError( - 'You are trying to access a property or method of the Jest environment after it has been torn down.' - ); - - process.exitCode = 1; - } // We've logged a user message above, so it doesn't matter if we return `null` here - - return this._environment.fakeTimers; - }; - - const jestObject = { - addMatchers: matchers => - this._environment.global.jasmine.addMatchers(matchers), - advanceTimersByTime: msToRun => - _getFakeTimers().advanceTimersByTime(msToRun), - advanceTimersToNextTimer: steps => - _getFakeTimers().advanceTimersToNextTimer(steps), - autoMockOff: disableAutomock, - autoMockOn: enableAutomock, - clearAllMocks, - clearAllTimers: () => _getFakeTimers().clearAllTimers(), - deepUnmock, - disableAutomock, - doMock: mock, - dontMock: unmock, - enableAutomock, - fn, - genMockFromModule: moduleName => this._generateMock(from, moduleName), - getTimerCount: () => _getFakeTimers().getTimerCount(), - isMockFunction: this._moduleMocker.isMockFunction, - isolateModules, - mock, - requireActual: localRequire.requireActual, - requireMock: localRequire.requireMock, - resetAllMocks, - resetModuleRegistry: resetModules, - resetModules, - restoreAllMocks, - retryTimes, - runAllImmediates: () => _getFakeTimers().runAllImmediates(), - runAllTicks: () => _getFakeTimers().runAllTicks(), - runAllTimers: () => _getFakeTimers().runAllTimers(), - runOnlyPendingTimers: () => _getFakeTimers().runOnlyPendingTimers(), - runTimersToTime: msToRun => _getFakeTimers().advanceTimersByTime(msToRun), - setMock: (moduleName, mock) => setMockFactory(moduleName, () => mock), - setTimeout, - spyOn, - unmock, - useFakeTimers, - useRealTimers - }; - return jestObject; - } - - _logFormattedReferenceError(errorMessage) { - const originalStack = new ReferenceError(errorMessage).stack - .split('\n') // Remove this file from the stack (jest-message-utils will keep one line) - .filter(line => line.indexOf(__filename) === -1) - .join('\n'); - const {message, stack} = (0, _jestMessageUtil().separateMessageFromStack)( - originalStack - ); - console.error( - `\n${message}\n` + - (0, _jestMessageUtil().formatStackTrace)(stack, this._config, { - noStackTrace: false - }) - ); - } - - wrapCodeInModuleWrapper(content) { - const args = this.constructInjectedModuleParameters(); - return ( - '({"' + - EVAL_RESULT_VARIABLE + - `":function(${args.join(',')}){` + - content + - '\n}});' - ); - } - - constructInjectedModuleParameters() { - return [ - 'module', - 'exports', - 'require', - '__dirname', - '__filename', - 'global', - 'jest', - ...this._config.extraGlobals - ]; - } - - handleExecutionError(e, module) { - const moduleNotFoundError = _jestResolve().default.tryCastModuleNotFoundError( - e - ); - - if (moduleNotFoundError) { - if (!moduleNotFoundError.requireStack) { - moduleNotFoundError.requireStack = [module.filename || module.id]; - - for (let cursor = module.parent; cursor; cursor = cursor.parent) { - moduleNotFoundError.requireStack.push(cursor.filename || cursor.id); - } - - moduleNotFoundError.buildMessage(this._config.rootDir); - } - - throw moduleNotFoundError; - } - - throw e; - } -} - -_defineProperty(Runtime, 'shouldInstrument', _transform().shouldInstrument); - -module.exports = Runtime; diff --git a/node_modules/jest-runtime/build/ts3.4/cli/args.d.ts b/node_modules/jest-runtime/build/ts3.4/cli/args.d.ts deleted file mode 100644 index 8b3ff4a8..00000000 --- a/node_modules/jest-runtime/build/ts3.4/cli/args.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import { Options } from 'yargs'; -export declare const usage = "Usage: $0 [--config=] "; -export declare const options: Record<'cache' | 'config' | 'debug' | 'version' | 'watchman', Options>; -//# sourceMappingURL=args.d.ts.map diff --git a/node_modules/jest-runtime/build/ts3.4/cli/index.d.ts b/node_modules/jest-runtime/build/ts3.4/cli/index.d.ts deleted file mode 100644 index 2eb499b3..00000000 --- a/node_modules/jest-runtime/build/ts3.4/cli/index.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import { Config } from '@jest/types'; -export declare function run(cliArgv?: Config.Argv, cliInfo?: Array): Promise; -//# sourceMappingURL=index.d.ts.map diff --git a/node_modules/jest-runtime/build/ts3.4/helpers.d.ts b/node_modules/jest-runtime/build/ts3.4/helpers.d.ts deleted file mode 100644 index b60638ec..00000000 --- a/node_modules/jest-runtime/build/ts3.4/helpers.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -export declare const findSiblingsWithFileExtension: (moduleFileExtensions: string[], from: string, moduleName: string) => string; -//# sourceMappingURL=helpers.d.ts.map diff --git a/node_modules/jest-runtime/build/ts3.4/index.d.ts b/node_modules/jest-runtime/build/ts3.4/index.d.ts deleted file mode 100644 index 4e519654..00000000 --- a/node_modules/jest-runtime/build/ts3.4/index.d.ts +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import { Config } from '@jest/types'; -import { JestEnvironment } from '@jest/environment'; -import { SourceMapRegistry } from '@jest/source-map'; -import { ShouldInstrumentOptions, shouldInstrument } from '@jest/transform'; -import { V8CoverageResult } from '@jest/test-result'; -import { options as cliOptions } from './cli/args'; -import { Context as JestContext } from './types'; -import HasteMap = require('jest-haste-map'); -import Resolver = require('jest-resolve'); -declare type HasteMapOptions = { - console?: Console; - maxWorkers: number; - resetCache: boolean; - watch?: boolean; - watchman: boolean; -}; -declare type InternalModuleOptions = { - isInternalModule: boolean; -}; -declare type CacheFS = { - [path: string]: string; -}; -declare namespace Runtime { - type Context = JestContext; - type RuntimeType = Runtime; -} -declare class Runtime { - private _cacheFS; - private _config; - private _coverageOptions; - private _currentlyExecutingModulePath; - private _environment; - private _explicitShouldMock; - private _internalModuleRegistry; - private _isCurrentlyExecutingManualMock; - private _mockFactories; - private _mockMetaDataCache; - private _mockRegistry; - private _isolatedMockRegistry; - private _moduleMocker; - private _isolatedModuleRegistry; - private _moduleRegistry; - private _needsCoverageMapped; - private _resolver; - private _shouldAutoMock; - private _shouldMockModuleCache; - private _shouldUnmockTransitiveDependenciesCache; - private _sourceMapRegistry; - private _scriptTransformer; - private _fileTransforms; - private _v8CoverageInstrumenter; - private _v8CoverageResult; - private _transitiveShouldMock; - private _unmockList; - private _virtualMocks; - private _moduleImplementation?; - constructor(config: Config.ProjectConfig, environment: JestEnvironment, resolver: Resolver, cacheFS?: CacheFS, coverageOptions?: ShouldInstrumentOptions); - static shouldInstrument: typeof shouldInstrument; - static createContext(config: Config.ProjectConfig, options: { - console?: Console; - maxWorkers: number; - watch?: boolean; - watchman: boolean; - }): Promise; - static createHasteMap(config: Config.ProjectConfig, options?: HasteMapOptions): HasteMap; - static createResolver(config: Config.ProjectConfig, moduleMap: HasteMap.ModuleMap): Resolver; - static runCLI(args?: Config.Argv, info?: Array): Promise; - static getCLIOptions(): typeof cliOptions; - requireModule(from: Config.Path, moduleName?: string, options?: InternalModuleOptions, isRequireActual?: boolean | null): T; - requireInternalModule(from: Config.Path, to?: string): T; - requireActual(from: Config.Path, moduleName: string): T; - requireMock(from: Config.Path, moduleName: string): T; - private _loadModule; - private _getFullTransformationOptions; - requireModuleOrMock(from: Config.Path, moduleName: string): unknown; - isolateModules(fn: () => void): void; - resetModules(): void; - collectV8Coverage(): Promise; - stopCollectingV8Coverage(): Promise; - getAllCoverageInfoCopy(): JestEnvironment['global']['__coverage__']; - getAllV8CoverageInfoCopy(): V8CoverageResult; - getSourceMapInfo(coveredFiles: Set): Record; - getSourceMaps(): SourceMapRegistry; - setMock(from: string, moduleName: string, mockFactory: () => unknown, options?: { - virtual?: boolean; - }): void; - restoreAllMocks(): void; - resetAllMocks(): void; - clearAllMocks(): void; - private _resolveModule; - private _requireResolve; - private _requireResolvePaths; - private _execModule; - private createScriptFromCode; - private _requireCoreModule; - private _getMockedNativeModule; - private _generateMock; - private _shouldMock; - private _createRequireImplementation; - private _createJestObjectFor; - private _logFormattedReferenceError; - private wrapCodeInModuleWrapper; - private constructInjectedModuleParameters; - private handleExecutionError; -} -export = Runtime; -//# sourceMappingURL=index.d.ts.map diff --git a/node_modules/jest-runtime/build/ts3.4/types.d.ts b/node_modules/jest-runtime/build/ts3.4/types.d.ts deleted file mode 100644 index 25b277c5..00000000 --- a/node_modules/jest-runtime/build/ts3.4/types.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import { Config } from '@jest/types'; -import HasteResolver = require('jest-resolve'); -import { FS as HasteFS, ModuleMap } from 'jest-haste-map'; -export declare type Context = { - config: Config.ProjectConfig; - hasteFS: HasteFS; - moduleMap: ModuleMap; - resolver: HasteResolver; -}; -//# sourceMappingURL=types.d.ts.map diff --git a/node_modules/jest-runtime/build/ts3.4/version.d.ts b/node_modules/jest-runtime/build/ts3.4/version.d.ts deleted file mode 100644 index c2b09a2a..00000000 --- a/node_modules/jest-runtime/build/ts3.4/version.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -export declare const VERSION: string; -//# sourceMappingURL=version.d.ts.map diff --git a/node_modules/jest-runtime/build/types.d.ts b/node_modules/jest-runtime/build/types.d.ts deleted file mode 100644 index 8bf83997..00000000 --- a/node_modules/jest-runtime/build/types.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import type { Config } from '@jest/types'; -import HasteResolver = require('jest-resolve'); -import type { FS as HasteFS, ModuleMap } from 'jest-haste-map'; -export declare type Context = { - config: Config.ProjectConfig; - hasteFS: HasteFS; - moduleMap: ModuleMap; - resolver: HasteResolver; -}; -//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-runtime/build/types.d.ts.map b/node_modules/jest-runtime/build/types.d.ts.map deleted file mode 100644 index aa8239ab..00000000 --- a/node_modules/jest-runtime/build/types.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,aAAa,GAAG,QAAQ,cAAc,CAAC,CAAC;AAC/C,OAAO,KAAK,EAAC,EAAE,IAAI,OAAO,EAAE,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAE7D,oBAAY,OAAO,GAAG;IACpB,MAAM,EAAE,MAAM,CAAC,aAAa,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,aAAa,CAAC;CACzB,CAAC"} \ No newline at end of file diff --git a/node_modules/jest-runtime/build/types.js b/node_modules/jest-runtime/build/types.js deleted file mode 100644 index 56441c8d..00000000 --- a/node_modules/jest-runtime/build/types.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -function _jestResolve() { - const data = _interopRequireDefault(require('jest-resolve')); - - _jestResolve = function () { - return data; - }; - - return data; -} - -function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : {default: obj}; -} diff --git a/node_modules/jest-runtime/build/version.d.ts b/node_modules/jest-runtime/build/version.d.ts deleted file mode 100644 index 33ef02eb..00000000 --- a/node_modules/jest-runtime/build/version.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -export declare const VERSION: string; -//# sourceMappingURL=version.d.ts.map \ No newline at end of file diff --git a/node_modules/jest-runtime/build/version.d.ts.map b/node_modules/jest-runtime/build/version.d.ts.map deleted file mode 100644 index 60880b83..00000000 --- a/node_modules/jest-runtime/build/version.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,eAAO,MAAM,OAAO,EAAE,MAA2C,CAAC"} \ No newline at end of file diff --git a/node_modules/jest-runtime/build/version.js b/node_modules/jest-runtime/build/version.js deleted file mode 100644 index 5ca58b3e..00000000 --- a/node_modules/jest-runtime/build/version.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.VERSION = void 0; - -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -// For some reason, doing `require`ing here works, while inside `cli` fails -const VERSION = require('../package.json').version; - -exports.VERSION = VERSION; diff --git a/node_modules/jest-runtime/node_modules/strip-bom/index.d.ts b/node_modules/jest-runtime/node_modules/strip-bom/index.d.ts deleted file mode 100644 index 8f2a5248..00000000 --- a/node_modules/jest-runtime/node_modules/strip-bom/index.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** -Strip UTF-8 [byte order mark](https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8) (BOM) from a string. - -@example -``` -import stripBom = require('strip-bom'); - -stripBom('\uFEFFunicorn'); -//=> 'unicorn' -``` -*/ -declare function stripBom(string: string): string; - -export = stripBom; diff --git a/node_modules/jest-runtime/node_modules/strip-bom/index.js b/node_modules/jest-runtime/node_modules/strip-bom/index.js deleted file mode 100644 index 82f91754..00000000 --- a/node_modules/jest-runtime/node_modules/strip-bom/index.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -module.exports = string => { - if (typeof string !== 'string') { - throw new TypeError(`Expected a string, got ${typeof string}`); - } - - // Catches EFBBBF (UTF-8 BOM) because the buffer-to-string - // conversion translates it to FEFF (UTF-16 BOM) - if (string.charCodeAt(0) === 0xFEFF) { - return string.slice(1); - } - - return string; -}; diff --git a/node_modules/jest-runtime/node_modules/strip-bom/license b/node_modules/jest-runtime/node_modules/strip-bom/license deleted file mode 100644 index e7af2f77..00000000 --- a/node_modules/jest-runtime/node_modules/strip-bom/license +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) Sindre Sorhus (sindresorhus.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/jest-runtime/node_modules/strip-bom/readme.md b/node_modules/jest-runtime/node_modules/strip-bom/readme.md deleted file mode 100644 index e826851f..00000000 --- a/node_modules/jest-runtime/node_modules/strip-bom/readme.md +++ /dev/null @@ -1,54 +0,0 @@ -# strip-bom [![Build Status](https://travis-ci.org/sindresorhus/strip-bom.svg?branch=master)](https://travis-ci.org/sindresorhus/strip-bom) - -> Strip UTF-8 [byte order mark](https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8) (BOM) from a string - -From Wikipedia: - -> The Unicode Standard permits the BOM in UTF-8, but does not require nor recommend its use. Byte order has no meaning in UTF-8. - ---- - -
- - Get professional support for 'strip-bom' with a Tidelift subscription - -
- - Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies. -
-
- ---- - -## Install - -``` -$ npm install strip-bom -``` - - -## Usage - -```js -const stripBom = require('strip-bom'); - -stripBom('\uFEFFunicorn'); -//=> 'unicorn' -``` - - -## Security - -To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. - - -## Related - -- [strip-bom-cli](https://github.com/sindresorhus/strip-bom-cli) - CLI for this module -- [strip-bom-buf](https://github.com/sindresorhus/strip-bom-buf) - Buffer version of this module -- [strip-bom-stream](https://github.com/sindresorhus/strip-bom-stream) - Stream version of this module - - -## License - -MIT Β© [Sindre Sorhus](https://sindresorhus.com) diff --git a/node_modules/jest/LICENSE b/node_modules/jest/LICENSE deleted file mode 100644 index b96dcb04..00000000 --- a/node_modules/jest/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) Facebook, Inc. and its affiliates. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/jest/README.md b/node_modules/jest/README.md deleted file mode 100644 index 4e02089b..00000000 --- a/node_modules/jest/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Jest - -πŸƒ Delightful JavaScript Testing - -- **πŸ‘©πŸ»β€πŸ’» Developer Ready**: Complete and ready to set-up JavaScript testing solution. Works out of the box for any React project. - -- **πŸƒπŸ½ Instant Feedback**: Failed tests run first. Fast interactive mode can switch between running all tests or only test files related to changed files. - -- **πŸ“Έ Snapshot Testing**: Jest can [capture snapshots](https://jestjs.io/docs/snapshot-testing.html) of React trees or other serializable values to simplify UI testing. - -Read More: https://jestjs.io/ diff --git a/node_modules/jest/bin/jest.js b/node_modules/jest/bin/jest.js deleted file mode 100755 index 4a828880..00000000 --- a/node_modules/jest/bin/jest.js +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env node -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -const importLocal = require('import-local'); - -if (!importLocal(__filename)) { - require('jest-cli/bin/jest'); -} diff --git a/node_modules/jest/build/jest.d.ts b/node_modules/jest/build/jest.d.ts deleted file mode 100644 index 562c4f8a..00000000 --- a/node_modules/jest/build/jest.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -export { SearchSource, TestScheduler, TestWatcher, getVersion, runCLI, } from '@jest/core'; -export { run } from 'jest-cli'; -//# sourceMappingURL=jest.d.ts.map \ No newline at end of file diff --git a/node_modules/jest/build/jest.d.ts.map b/node_modules/jest/build/jest.d.ts.map deleted file mode 100644 index 941e727f..00000000 --- a/node_modules/jest/build/jest.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"jest.d.ts","sourceRoot":"","sources":["../src/jest.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,YAAY,EACZ,aAAa,EACb,WAAW,EACX,UAAU,EACV,MAAM,GACP,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAC,GAAG,EAAC,MAAM,UAAU,CAAC"} \ No newline at end of file diff --git a/node_modules/jest/build/jest.js b/node_modules/jest/build/jest.js deleted file mode 100644 index 997d6229..00000000 --- a/node_modules/jest/build/jest.js +++ /dev/null @@ -1,61 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -Object.defineProperty(exports, 'SearchSource', { - enumerable: true, - get: function () { - return _core().SearchSource; - } -}); -Object.defineProperty(exports, 'TestScheduler', { - enumerable: true, - get: function () { - return _core().TestScheduler; - } -}); -Object.defineProperty(exports, 'TestWatcher', { - enumerable: true, - get: function () { - return _core().TestWatcher; - } -}); -Object.defineProperty(exports, 'getVersion', { - enumerable: true, - get: function () { - return _core().getVersion; - } -}); -Object.defineProperty(exports, 'runCLI', { - enumerable: true, - get: function () { - return _core().runCLI; - } -}); -Object.defineProperty(exports, 'run', { - enumerable: true, - get: function () { - return _jestCli().run; - } -}); - -function _core() { - const data = require('@jest/core'); - - _core = function () { - return data; - }; - - return data; -} - -function _jestCli() { - const data = require('jest-cli'); - - _jestCli = function () { - return data; - }; - - return data; -} diff --git a/node_modules/jest/build/ts3.4/jest.d.ts b/node_modules/jest/build/ts3.4/jest.d.ts deleted file mode 100644 index dbce6515..00000000 --- a/node_modules/jest/build/ts3.4/jest.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -export { SearchSource, TestScheduler, TestWatcher, getVersion, runCLI, } from '@jest/core'; -export { run } from 'jest-cli'; -//# sourceMappingURL=jest.d.ts.map diff --git a/node_modules/jest/node_modules/.bin/import-local-fixture b/node_modules/jest/node_modules/.bin/import-local-fixture deleted file mode 120000 index 653f8d95..00000000 --- a/node_modules/jest/node_modules/.bin/import-local-fixture +++ /dev/null @@ -1 +0,0 @@ -../../../import-local/fixtures/cli.js \ No newline at end of file diff --git a/node_modules/jest/node_modules/jest-cli/LICENSE b/node_modules/jest/node_modules/jest-cli/LICENSE deleted file mode 100644 index b96dcb04..00000000 --- a/node_modules/jest/node_modules/jest-cli/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) Facebook, Inc. and its affiliates. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/jest/node_modules/jest-cli/README.md b/node_modules/jest/node_modules/jest-cli/README.md deleted file mode 100644 index 4e02089b..00000000 --- a/node_modules/jest/node_modules/jest-cli/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Jest - -πŸƒ Delightful JavaScript Testing - -- **πŸ‘©πŸ»β€πŸ’» Developer Ready**: Complete and ready to set-up JavaScript testing solution. Works out of the box for any React project. - -- **πŸƒπŸ½ Instant Feedback**: Failed tests run first. Fast interactive mode can switch between running all tests or only test files related to changed files. - -- **πŸ“Έ Snapshot Testing**: Jest can [capture snapshots](https://jestjs.io/docs/snapshot-testing.html) of React trees or other serializable values to simplify UI testing. - -Read More: https://jestjs.io/ diff --git a/node_modules/jest/node_modules/jest-cli/bin/jest.js b/node_modules/jest/node_modules/jest-cli/bin/jest.js deleted file mode 100755 index fc6308c8..00000000 --- a/node_modules/jest/node_modules/jest-cli/bin/jest.js +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env node -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -const importLocal = require('import-local'); - -if (!importLocal(__filename)) { - if (process.env.NODE_ENV == null) { - process.env.NODE_ENV = 'test'; - } - - require('../build/cli').run(); -} diff --git a/node_modules/jest/node_modules/jest-cli/build/cli/args.d.ts b/node_modules/jest/node_modules/jest-cli/build/cli/args.d.ts deleted file mode 100644 index 63fdd0b2..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/cli/args.d.ts +++ /dev/null @@ -1,498 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import type { Config } from '@jest/types'; -export declare function check(argv: Config.Argv): true; -export declare const usage = "Usage: $0 [--config=] [TestPathPattern]"; -export declare const docs = "Documentation: https://jestjs.io/"; -export declare const options: { - readonly all: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly automock: { - readonly default: undefined; - readonly description: "Automock all files by default."; - readonly type: "boolean"; - }; - readonly bail: { - readonly alias: "b"; - readonly default: undefined; - readonly description: "Exit the test suite immediately after `n` number of failing tests."; - readonly type: "boolean"; - }; - readonly browser: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly cache: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly cacheDirectory: { - readonly description: string; - readonly type: "string"; - }; - readonly changedFilesWithAncestor: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly changedSince: { - readonly description: string; - readonly nargs: 1; - readonly type: "string"; - }; - readonly ci: { - readonly default: boolean; - readonly description: string; - readonly type: "boolean"; - }; - readonly clearCache: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly clearMocks: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly collectCoverage: { - readonly default: undefined; - readonly description: "Alias for --coverage."; - readonly type: "boolean"; - }; - readonly collectCoverageFrom: { - readonly description: string; - readonly type: "string"; - }; - readonly collectCoverageOnlyFrom: { - readonly description: "Explicit list of paths coverage will be restricted to."; - readonly string: true; - readonly type: "array"; - }; - readonly color: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly colors: { - readonly default: undefined; - readonly description: "Alias for `--color`."; - readonly type: "boolean"; - }; - readonly config: { - readonly alias: "c"; - readonly description: string; - readonly type: "string"; - }; - readonly coverage: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly coverageDirectory: { - readonly description: "The directory where Jest should output its coverage files."; - readonly type: "string"; - }; - readonly coveragePathIgnorePatterns: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly coverageProvider: { - readonly choices: readonly ["babel", "v8"]; - readonly description: "Select between Babel and V8 to collect coverage"; - }; - readonly coverageReporters: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly coverageThreshold: { - readonly description: string; - readonly type: "string"; - }; - readonly debug: { - readonly default: undefined; - readonly description: "Print debugging info about your jest config."; - readonly type: "boolean"; - }; - readonly detectLeaks: { - readonly default: false; - readonly description: string; - readonly type: "boolean"; - }; - readonly detectOpenHandles: { - readonly default: false; - readonly description: string; - readonly type: "boolean"; - }; - readonly env: { - readonly description: string; - readonly type: "string"; - }; - readonly errorOnDeprecated: { - readonly default: false; - readonly description: "Make calling deprecated APIs throw helpful error messages."; - readonly type: "boolean"; - }; - readonly expand: { - readonly alias: "e"; - readonly default: undefined; - readonly description: "Use this flag to show full diffs instead of a patch."; - readonly type: "boolean"; - }; - readonly filter: { - readonly default: undefined; - readonly description: string; - readonly type: "string"; - }; - readonly findRelatedTests: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly forceExit: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly globalSetup: { - readonly description: "The path to a module that runs before All Tests."; - readonly type: "string"; - }; - readonly globalTeardown: { - readonly description: "The path to a module that runs after All Tests."; - readonly type: "string"; - }; - readonly globals: { - readonly description: string; - readonly type: "string"; - }; - readonly haste: { - readonly description: "A JSON string with map of variables for the haste module system"; - readonly type: "string"; - }; - readonly init: { - readonly description: "Generate a basic configuration file"; - readonly type: "boolean"; - }; - readonly json: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly lastCommit: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly listTests: { - readonly default: false; - readonly description: string; - readonly type: "boolean"; - }; - readonly logHeapUsage: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly mapCoverage: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly maxConcurrency: { - readonly default: 5; - readonly description: string; - readonly type: "number"; - }; - readonly maxWorkers: { - readonly alias: "w"; - readonly description: string; - readonly type: "string"; - }; - readonly moduleDirectories: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly moduleFileExtensions: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly moduleNameMapper: { - readonly description: string; - readonly type: "string"; - }; - readonly modulePathIgnorePatterns: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly modulePaths: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly noStackTrace: { - readonly default: undefined; - readonly description: "Disables stack trace in test results output"; - readonly type: "boolean"; - }; - readonly notify: { - readonly default: undefined; - readonly description: "Activates notifications for test results."; - readonly type: "boolean"; - }; - readonly notifyMode: { - readonly default: "failure-change"; - readonly description: "Specifies when notifications will appear for test results."; - readonly type: "string"; - }; - readonly onlyChanged: { - readonly alias: "o"; - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly onlyFailures: { - readonly alias: "f"; - readonly default: undefined; - readonly description: "Run tests that failed in the previous execution."; - readonly type: "boolean"; - }; - readonly outputFile: { - readonly description: string; - readonly type: "string"; - }; - readonly passWithNoTests: { - readonly default: false; - readonly description: "Will not fail if no tests are found (for example while using `--testPathPattern`.)"; - readonly type: "boolean"; - }; - readonly preset: { - readonly description: "A preset that is used as a base for Jest's configuration."; - readonly type: "string"; - }; - readonly prettierPath: { - readonly default: undefined; - readonly description: "The path to the \"prettier\" module used for inline snapshots."; - readonly type: "string"; - }; - readonly projects: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly reporters: { - readonly description: "A list of custom reporters for the test suite."; - readonly string: true; - readonly type: "array"; - }; - readonly resetMocks: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly resetModules: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly resolver: { - readonly description: "A JSON string which allows the use of a custom resolver."; - readonly type: "string"; - }; - readonly restoreMocks: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly rootDir: { - readonly description: string; - readonly type: "string"; - }; - readonly roots: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly runInBand: { - readonly alias: "i"; - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly runTestsByPath: { - readonly default: false; - readonly description: string; - readonly type: "boolean"; - }; - readonly runner: { - readonly description: "Allows to use a custom runner instead of Jest's default test runner."; - readonly type: "string"; - }; - readonly setupFiles: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly setupFilesAfterEnv: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly showConfig: { - readonly default: undefined; - readonly description: "Print your jest config and then exits."; - readonly type: "boolean"; - }; - readonly silent: { - readonly default: undefined; - readonly description: "Prevent tests from printing messages through the console."; - readonly type: "boolean"; - }; - readonly skipFilter: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly snapshotSerializers: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly testEnvironment: { - readonly description: "Alias for --env"; - readonly type: "string"; - }; - readonly testEnvironmentOptions: { - readonly description: string; - readonly type: "string"; - }; - readonly testFailureExitCode: { - readonly description: "Exit code of `jest` command if the test run failed"; - readonly type: "string"; - }; - readonly testLocationInResults: { - readonly default: false; - readonly description: "Add `location` information to the test results"; - readonly type: "boolean"; - }; - readonly testMatch: { - readonly description: "The glob patterns Jest uses to detect test files."; - readonly string: true; - readonly type: "array"; - }; - readonly testNamePattern: { - readonly alias: "t"; - readonly description: "Run only tests with a name that matches the regex pattern."; - readonly type: "string"; - }; - readonly testPathIgnorePatterns: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly testPathPattern: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly testRegex: { - readonly description: "A string or array of string regexp patterns that Jest uses to detect test files."; - readonly string: true; - readonly type: "array"; - }; - readonly testResultsProcessor: { - readonly description: string; - readonly type: "string"; - }; - readonly testRunner: { - readonly description: string; - readonly type: "string"; - }; - readonly testSequencer: { - readonly description: string; - readonly type: "string"; - }; - readonly testTimeout: { - readonly description: "This option sets the default timeouts of test cases."; - readonly type: "number"; - }; - readonly testURL: { - readonly description: "This option sets the URL for the jsdom environment."; - readonly type: "string"; - }; - readonly timers: { - readonly description: string; - readonly type: "string"; - }; - readonly transform: { - readonly description: string; - readonly type: "string"; - }; - readonly transformIgnorePatterns: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly unmockedModulePathPatterns: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly updateSnapshot: { - readonly alias: "u"; - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly useStderr: { - readonly default: undefined; - readonly description: "Divert all output to stderr."; - readonly type: "boolean"; - }; - readonly verbose: { - readonly default: undefined; - readonly description: "Display individual test results with the test suite hierarchy."; - readonly type: "boolean"; - }; - readonly version: { - readonly alias: "v"; - readonly default: undefined; - readonly description: "Print the version and exit"; - readonly type: "boolean"; - }; - readonly watch: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly watchAll: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly watchPathIgnorePatterns: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly watchman: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; -}; -//# sourceMappingURL=args.d.ts.map \ No newline at end of file diff --git a/node_modules/jest/node_modules/jest-cli/build/cli/args.d.ts.map b/node_modules/jest/node_modules/jest-cli/build/cli/args.d.ts.map deleted file mode 100644 index ce1dcd12..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/cli/args.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/cli/args.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAIxC,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,GAAG,IAAI,CA4D7C;AAED,eAAO,MAAM,KAAK,8DAC2C,CAAC;AAC9D,eAAO,MAAM,IAAI,sCAAsC,CAAC;AAExD,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+oBV,CAAC"} \ No newline at end of file diff --git a/node_modules/jest/node_modules/jest-cli/build/cli/args.js b/node_modules/jest/node_modules/jest-cli/build/cli/args.js deleted file mode 100644 index 957e8897..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/cli/args.js +++ /dev/null @@ -1,761 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.check = check; -exports.options = exports.docs = exports.usage = void 0; - -function _jestConfig() { - const data = require('jest-config'); - - _jestConfig = function () { - return data; - }; - - return data; -} - -function _isCi() { - const data = _interopRequireDefault(require('is-ci')); - - _isCi = function () { - return data; - }; - - return data; -} - -function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : {default: obj}; -} - -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -function check(argv) { - if (argv.runInBand && argv.hasOwnProperty('maxWorkers')) { - throw new Error( - 'Both --runInBand and --maxWorkers were specified, but these two ' + - 'options do not make sense together. Which is it?' - ); - } - - for (const key of [ - 'onlyChanged', - 'lastCommit', - 'changedFilesWithAncestor', - 'changedSince' - ]) { - if (argv[key] && argv.watchAll) { - throw new Error( - `Both --${key} and --watchAll were specified, but these two ` + - 'options do not make sense together. Try the --watch option which ' + - 'reruns only tests related to changed files.' - ); - } - } - - if (argv.findRelatedTests && argv._.length === 0) { - throw new Error( - 'The --findRelatedTests option requires file paths to be specified.\n' + - 'Example usage: jest --findRelatedTests ./src/source.js ' + - './src/index.js.' - ); - } - - if (argv.hasOwnProperty('maxWorkers') && argv.maxWorkers === undefined) { - throw new Error( - 'The --maxWorkers (-w) option requires a number or string to be specified.\n' + - 'Example usage: jest --maxWorkers 2\n' + - 'Example usage: jest --maxWorkers 50%\n' + - 'Or did you mean --watch?' - ); - } - - if ( - argv.config && - !(0, _jestConfig().isJSONString)(argv.config) && - !argv.config.match( - new RegExp( - `\\.(${_jestConfig() - .constants.JEST_CONFIG_EXT_ORDER.map(e => e.substring(1)) - .join('|')})$`, - 'i' - ) - ) - ) { - throw new Error( - `The --config option requires a JSON string literal, or a file path with one of these extensions: ${_jestConfig().constants.JEST_CONFIG_EXT_ORDER.join( - ', ' - )}.\nExample usage: jest --config ./jest.config.js` - ); - } - - return true; -} - -const usage = 'Usage: $0 [--config=] [TestPathPattern]'; -exports.usage = usage; -const docs = 'Documentation: https://jestjs.io/'; -exports.docs = docs; -const options = { - all: { - default: undefined, - description: - 'The opposite of `onlyChanged`. If `onlyChanged` is set by ' + - 'default, running jest with `--all` will force Jest to run all tests ' + - 'instead of running only tests related to changed files.', - type: 'boolean' - }, - automock: { - default: undefined, - description: 'Automock all files by default.', - type: 'boolean' - }, - bail: { - alias: 'b', - default: undefined, - description: - 'Exit the test suite immediately after `n` number of failing tests.', - type: 'boolean' - }, - browser: { - default: undefined, - description: - 'Respect the "browser" field in package.json ' + - 'when resolving modules. Some packages export different versions ' + - 'based on whether they are operating in node.js or a browser.', - type: 'boolean' - }, - cache: { - default: undefined, - description: - 'Whether to use the transform cache. Disable the cache ' + - 'using --no-cache.', - type: 'boolean' - }, - cacheDirectory: { - description: - 'The directory where Jest should store its cached ' + - ' dependency information.', - type: 'string' - }, - changedFilesWithAncestor: { - default: undefined, - description: - 'Runs tests related to the current changes and the changes made in the ' + - 'last commit. Behaves similarly to `--onlyChanged`.', - type: 'boolean' - }, - changedSince: { - description: - 'Runs tests related to the changes since the provided branch. If the ' + - 'current branch has diverged from the given branch, then only changes ' + - 'made locally will be tested. Behaves similarly to `--onlyChanged`.', - nargs: 1, - type: 'string' - }, - ci: { - default: _isCi().default, - description: - 'Whether to run Jest in continuous integration (CI) mode. ' + - 'This option is on by default in most popular CI environments. It will ' + - 'prevent snapshots from being written unless explicitly requested.', - type: 'boolean' - }, - clearCache: { - default: undefined, - description: - 'Clears the configured Jest cache directory and then exits. ' + - 'Default directory can be found by calling jest --showConfig', - type: 'boolean' - }, - clearMocks: { - default: undefined, - description: - 'Automatically clear mock calls and instances between every ' + - 'test. Equivalent to calling jest.clearAllMocks() between each test.', - type: 'boolean' - }, - collectCoverage: { - default: undefined, - description: 'Alias for --coverage.', - type: 'boolean' - }, - collectCoverageFrom: { - description: - 'A glob pattern relative to matching the files that coverage ' + - 'info needs to be collected from.', - type: 'string' - }, - collectCoverageOnlyFrom: { - description: 'Explicit list of paths coverage will be restricted to.', - string: true, - type: 'array' - }, - color: { - default: undefined, - description: - 'Forces test results output color highlighting (even if ' + - 'stdout is not a TTY). Set to false if you would like to have no colors.', - type: 'boolean' - }, - colors: { - default: undefined, - description: 'Alias for `--color`.', - type: 'boolean' - }, - config: { - alias: 'c', - description: - 'The path to a jest config file specifying how to find ' + - 'and execute tests. If no rootDir is set in the config, the directory ' + - 'containing the config file is assumed to be the rootDir for the project.' + - 'This can also be a JSON encoded value which Jest will use as configuration.', - type: 'string' - }, - coverage: { - default: undefined, - description: - 'Indicates that test coverage information should be ' + - 'collected and reported in the output.', - type: 'boolean' - }, - coverageDirectory: { - description: 'The directory where Jest should output its coverage files.', - type: 'string' - }, - coveragePathIgnorePatterns: { - description: - 'An array of regexp pattern strings that are matched ' + - 'against all file paths before executing the test. If the file path' + - 'matches any of the patterns, coverage information will be skipped.', - string: true, - type: 'array' - }, - coverageProvider: { - choices: ['babel', 'v8'], - description: 'Select between Babel and V8 to collect coverage' - }, - coverageReporters: { - description: - 'A list of reporter names that Jest uses when writing ' + - 'coverage reports. Any istanbul reporter can be used.', - string: true, - type: 'array' - }, - coverageThreshold: { - description: - 'A JSON string with which will be used to configure ' + - 'minimum threshold enforcement for coverage results', - type: 'string' - }, - debug: { - default: undefined, - description: 'Print debugging info about your jest config.', - type: 'boolean' - }, - detectLeaks: { - default: false, - description: - '**EXPERIMENTAL**: Detect memory leaks in tests. After executing a ' + - 'test, it will try to garbage collect the global object used, and fail ' + - 'if it was leaked', - type: 'boolean' - }, - detectOpenHandles: { - default: false, - description: - 'Print out remaining open handles preventing Jest from exiting at the ' + - 'end of a test run. Implies `runInBand`.', - type: 'boolean' - }, - env: { - description: - 'The test environment used for all tests. This can point to ' + - 'any file or node module. Examples: `jsdom`, `node` or ' + - '`path/to/my-environment.js`', - type: 'string' - }, - errorOnDeprecated: { - default: false, - description: 'Make calling deprecated APIs throw helpful error messages.', - type: 'boolean' - }, - expand: { - alias: 'e', - default: undefined, - description: 'Use this flag to show full diffs instead of a patch.', - type: 'boolean' - }, - filter: { - default: undefined, - description: - 'Path to a module exporting a filtering function. This method receives ' + - 'a list of tests which can be manipulated to exclude tests from ' + - 'running. Especially useful when used in conjunction with a testing ' + - 'infrastructure to filter known broken tests.', - type: 'string' - }, - findRelatedTests: { - default: undefined, - description: - 'Find related tests for a list of source files that were ' + - 'passed in as arguments. Useful for pre-commit hook integration to run ' + - 'the minimal amount of tests necessary.', - type: 'boolean' - }, - forceExit: { - default: undefined, - description: - 'Force Jest to exit after all tests have completed running. ' + - 'This is useful when resources set up by test code cannot be ' + - 'adequately cleaned up.', - type: 'boolean' - }, - globalSetup: { - description: 'The path to a module that runs before All Tests.', - type: 'string' - }, - globalTeardown: { - description: 'The path to a module that runs after All Tests.', - type: 'string' - }, - globals: { - description: - 'A JSON string with map of global variables that need ' + - 'to be available in all test environments.', - type: 'string' - }, - haste: { - description: - 'A JSON string with map of variables for the haste module system', - type: 'string' - }, - init: { - description: 'Generate a basic configuration file', - type: 'boolean' - }, - json: { - default: undefined, - description: - 'Prints the test results in JSON. This mode will send all ' + - 'other test output and user messages to stderr.', - type: 'boolean' - }, - lastCommit: { - default: undefined, - description: - 'Run all tests affected by file changes in the last commit made. ' + - 'Behaves similarly to `--onlyChanged`.', - type: 'boolean' - }, - listTests: { - default: false, - description: - 'Lists all tests Jest will run given the arguments and ' + - 'exits. Most useful in a CI system together with `--findRelatedTests` ' + - 'to determine the tests Jest will run based on specific files', - type: 'boolean' - }, - logHeapUsage: { - default: undefined, - description: - 'Logs the heap usage after every test. Useful to debug ' + - 'memory leaks. Use together with `--runInBand` and `--expose-gc` in ' + - 'node.', - type: 'boolean' - }, - mapCoverage: { - default: undefined, - description: - 'Maps code coverage reports against original source code ' + - 'when transformers supply source maps.\n\nDEPRECATED', - type: 'boolean' - }, - maxConcurrency: { - default: 5, - description: - 'Specifies the maximum number of tests that are allowed to run' + - 'concurrently. This only affects tests using `test.concurrent`.', - type: 'number' - }, - maxWorkers: { - alias: 'w', - description: - 'Specifies the maximum number of workers the worker-pool ' + - 'will spawn for running tests. This defaults to the number of the ' + - 'cores available on your machine. (its usually best not to override ' + - 'this default)', - type: 'string' - }, - moduleDirectories: { - description: - 'An array of directory names to be searched recursively ' + - "up from the requiring module's location.", - string: true, - type: 'array' - }, - moduleFileExtensions: { - description: - 'An array of file extensions your modules use. If you ' + - 'require modules without specifying a file extension, these are the ' + - 'extensions Jest will look for. ', - string: true, - type: 'array' - }, - moduleNameMapper: { - description: - 'A JSON string with a map from regular expressions to ' + - 'module names or to arrays of module names that allow to stub ' + - 'out resources, like images or styles with a single module', - type: 'string' - }, - modulePathIgnorePatterns: { - description: - 'An array of regexp pattern strings that are matched ' + - 'against all module paths before those paths are to be considered ' + - '"visible" to the module loader.', - string: true, - type: 'array' - }, - modulePaths: { - description: - 'An alternative API to setting the NODE_PATH env variable, ' + - 'modulePaths is an array of absolute paths to additional locations to ' + - 'search when resolving modules.', - string: true, - type: 'array' - }, - noStackTrace: { - default: undefined, - description: 'Disables stack trace in test results output', - type: 'boolean' - }, - notify: { - default: undefined, - description: 'Activates notifications for test results.', - type: 'boolean' - }, - notifyMode: { - default: 'failure-change', - description: 'Specifies when notifications will appear for test results.', - type: 'string' - }, - onlyChanged: { - alias: 'o', - default: undefined, - description: - 'Attempts to identify which tests to run based on which ' + - "files have changed in the current repository. Only works if you're " + - 'running tests in a git or hg repository at the moment.', - type: 'boolean' - }, - onlyFailures: { - alias: 'f', - default: undefined, - description: 'Run tests that failed in the previous execution.', - type: 'boolean' - }, - outputFile: { - description: - 'Write test results to a file when the --json option is ' + - 'also specified.', - type: 'string' - }, - passWithNoTests: { - default: false, - description: - 'Will not fail if no tests are found (for example while using `--testPathPattern`.)', - type: 'boolean' - }, - preset: { - description: "A preset that is used as a base for Jest's configuration.", - type: 'string' - }, - prettierPath: { - default: undefined, - description: 'The path to the "prettier" module used for inline snapshots.', - type: 'string' - }, - projects: { - description: - 'A list of projects that use Jest to run all tests of all ' + - 'projects in a single instance of Jest.', - string: true, - type: 'array' - }, - reporters: { - description: 'A list of custom reporters for the test suite.', - string: true, - type: 'array' - }, - resetMocks: { - default: undefined, - description: - 'Automatically reset mock state between every test. ' + - 'Equivalent to calling jest.resetAllMocks() between each test.', - type: 'boolean' - }, - resetModules: { - default: undefined, - description: - 'If enabled, the module registry for every test file will ' + - 'be reset before running each individual test.', - type: 'boolean' - }, - resolver: { - description: 'A JSON string which allows the use of a custom resolver.', - type: 'string' - }, - restoreMocks: { - default: undefined, - description: - 'Automatically restore mock state and implementation between every test. ' + - 'Equivalent to calling jest.restoreAllMocks() between each test.', - type: 'boolean' - }, - rootDir: { - description: - 'The root directory that Jest should scan for tests and ' + - 'modules within.', - type: 'string' - }, - roots: { - description: - 'A list of paths to directories that Jest should use to ' + - 'search for files in.', - string: true, - type: 'array' - }, - runInBand: { - alias: 'i', - default: undefined, - description: - 'Run all tests serially in the current process (rather than ' + - 'creating a worker pool of child processes that run tests). This ' + - 'is sometimes useful for debugging, but such use cases are pretty ' + - 'rare.', - type: 'boolean' - }, - runTestsByPath: { - default: false, - description: - 'Used when provided patterns are exact file paths. This avoids ' + - 'converting them into a regular expression and matching it against ' + - 'every single file.', - type: 'boolean' - }, - runner: { - description: - "Allows to use a custom runner instead of Jest's default test runner.", - type: 'string' - }, - setupFiles: { - description: - 'A list of paths to modules that run some code to configure or ' + - 'set up the testing environment before each test. ', - string: true, - type: 'array' - }, - setupFilesAfterEnv: { - description: - 'A list of paths to modules that run some code to configure or ' + - 'set up the testing framework before each test ', - string: true, - type: 'array' - }, - showConfig: { - default: undefined, - description: 'Print your jest config and then exits.', - type: 'boolean' - }, - silent: { - default: undefined, - description: 'Prevent tests from printing messages through the console.', - type: 'boolean' - }, - skipFilter: { - default: undefined, - description: - 'Disables the filter provided by --filter. Useful for CI jobs, or ' + - 'local enforcement when fixing tests.', - type: 'boolean' - }, - snapshotSerializers: { - description: - 'A list of paths to snapshot serializer modules Jest should ' + - 'use for snapshot testing.', - string: true, - type: 'array' - }, - testEnvironment: { - description: 'Alias for --env', - type: 'string' - }, - testEnvironmentOptions: { - description: - 'Test environment options that will be passed to the testEnvironment. ' + - 'The relevant options depend on the environment.', - type: 'string' // Object - }, - testFailureExitCode: { - description: 'Exit code of `jest` command if the test run failed', - type: 'string' // number - }, - testLocationInResults: { - default: false, - description: 'Add `location` information to the test results', - type: 'boolean' - }, - testMatch: { - description: 'The glob patterns Jest uses to detect test files.', - string: true, - type: 'array' - }, - testNamePattern: { - alias: 't', - description: 'Run only tests with a name that matches the regex pattern.', - type: 'string' - }, - testPathIgnorePatterns: { - description: - 'An array of regexp pattern strings that are matched ' + - 'against all test paths before executing the test. If the test path ' + - 'matches any of the patterns, it will be skipped.', - string: true, - type: 'array' - }, - testPathPattern: { - description: - 'A regexp pattern string that is matched against all tests ' + - 'paths before executing the test.', - string: true, - type: 'array' - }, - testRegex: { - description: - 'A string or array of string regexp patterns that Jest uses to detect test files.', - string: true, - type: 'array' - }, - testResultsProcessor: { - description: - 'Allows the use of a custom results processor. ' + - 'This processor must be a node module that exports ' + - 'a function expecting as the first argument the result object.', - type: 'string' - }, - testRunner: { - description: - 'Allows to specify a custom test runner. The default is ' + - ' `jasmine2`. A path to a custom test runner can be provided: ' + - '`/path/to/testRunner.js`.', - type: 'string' - }, - testSequencer: { - description: - 'Allows to specify a custom test sequencer. The default is ' + - '`@jest/test-sequencer`. A path to a custom test sequencer can be ' + - 'provided: `/path/to/testSequencer.js`', - type: 'string' - }, - testTimeout: { - description: 'This option sets the default timeouts of test cases.', - type: 'number' - }, - testURL: { - description: 'This option sets the URL for the jsdom environment.', - type: 'string' - }, - timers: { - description: - 'Setting this value to fake allows the use of fake timers ' + - 'for functions such as setTimeout.', - type: 'string' - }, - transform: { - description: - 'A JSON string which maps from regular expressions to paths ' + - 'to transformers.', - type: 'string' - }, - transformIgnorePatterns: { - description: - 'An array of regexp pattern strings that are matched ' + - 'against all source file paths before transformation.', - string: true, - type: 'array' - }, - unmockedModulePathPatterns: { - description: - 'An array of regexp pattern strings that are matched ' + - 'against all modules before the module loader will automatically ' + - 'return a mock for them.', - string: true, - type: 'array' - }, - updateSnapshot: { - alias: 'u', - default: undefined, - description: - 'Use this flag to re-record snapshots. ' + - 'Can be used together with a test suite pattern or with ' + - '`--testNamePattern` to re-record snapshot for test matching ' + - 'the pattern', - type: 'boolean' - }, - useStderr: { - default: undefined, - description: 'Divert all output to stderr.', - type: 'boolean' - }, - verbose: { - default: undefined, - description: - 'Display individual test results with the test suite hierarchy.', - type: 'boolean' - }, - version: { - alias: 'v', - default: undefined, - description: 'Print the version and exit', - type: 'boolean' - }, - watch: { - default: undefined, - description: - 'Watch files for changes and rerun tests related to ' + - 'changed files. If you want to re-run all tests when a file has ' + - 'changed, use the `--watchAll` option.', - type: 'boolean' - }, - watchAll: { - default: undefined, - description: - 'Watch files for changes and rerun all tests. If you want ' + - 'to re-run only the tests related to the changed files, use the ' + - '`--watch` option.', - type: 'boolean' - }, - watchPathIgnorePatterns: { - description: - 'An array of regexp pattern strings that are matched ' + - 'against all paths before trigger test re-run in watch mode. ' + - 'If the test path matches any of the patterns, it will be skipped.', - string: true, - type: 'array' - }, - watchman: { - default: undefined, - description: - 'Whether to use watchman for file crawling. Disable using ' + - '--no-watchman.', - type: 'boolean' - } -}; -exports.options = options; diff --git a/node_modules/jest/node_modules/jest-cli/build/cli/index.d.ts b/node_modules/jest/node_modules/jest-cli/build/cli/index.d.ts deleted file mode 100644 index 113d7f75..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/cli/index.d.ts +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import type { Config } from '@jest/types'; -import yargs = require('yargs'); -export declare function run(maybeArgv?: Array, project?: Config.Path): Promise; -export declare const buildArgv: (maybeArgv?: string[] | undefined) => yargs.Arguments>; -//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/node_modules/jest/node_modules/jest-cli/build/cli/index.d.ts.map b/node_modules/jest/node_modules/jest-cli/build/cli/index.d.ts.map deleted file mode 100644 index 4e6b7be9..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/cli/index.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAQxC,OAAO,KAAK,GAAG,QAAQ,OAAO,CAAC,CAAC;AAKhC,wBAAsB,GAAG,CACvB,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,EACzB,OAAO,CAAC,EAAE,MAAM,CAAC,IAAI,GACpB,OAAO,CAAC,IAAI,CAAC,CAyBf;AAED,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BrB,CAAC"} \ No newline at end of file diff --git a/node_modules/jest/node_modules/jest-cli/build/cli/index.js b/node_modules/jest/node_modules/jest-cli/build/cli/index.js deleted file mode 100644 index d7baf221..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/cli/index.js +++ /dev/null @@ -1,322 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.run = run; -exports.buildArgv = void 0; - -function path() { - const data = _interopRequireWildcard(require('path')); - - path = function () { - return data; - }; - - return data; -} - -function _jestUtil() { - const data = require('jest-util'); - - _jestUtil = function () { - return data; - }; - - return data; -} - -function _jestValidate() { - const data = require('jest-validate'); - - _jestValidate = function () { - return data; - }; - - return data; -} - -function _jestConfig() { - const data = require('jest-config'); - - _jestConfig = function () { - return data; - }; - - return data; -} - -function _core() { - const data = require('@jest/core'); - - _core = function () { - return data; - }; - - return data; -} - -function _chalk() { - const data = _interopRequireDefault(require('chalk')); - - _chalk = function () { - return data; - }; - - return data; -} - -function _exit() { - const data = _interopRequireDefault(require('exit')); - - _exit = function () { - return data; - }; - - return data; -} - -function _yargs() { - const data = _interopRequireDefault(require('yargs')); - - _yargs = function () { - return data; - }; - - return data; -} - -function _realpathNative() { - const data = require('realpath-native'); - - _realpathNative = function () { - return data; - }; - - return data; -} - -function _init() { - const data = _interopRequireDefault(require('../init')); - - _init = function () { - return data; - }; - - return data; -} - -var args = _interopRequireWildcard(require('./args')); - -function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : {default: obj}; -} - -function _getRequireWildcardCache() { - if (typeof WeakMap !== 'function') return null; - var cache = new WeakMap(); - _getRequireWildcardCache = function () { - return cache; - }; - return cache; -} - -function _interopRequireWildcard(obj) { - if (obj && obj.__esModule) { - return obj; - } - if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { - return {default: obj}; - } - var cache = _getRequireWildcardCache(); - if (cache && cache.has(obj)) { - return cache.get(obj); - } - var newObj = {}; - var hasPropertyDescriptor = - Object.defineProperty && Object.getOwnPropertyDescriptor; - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) { - var desc = hasPropertyDescriptor - ? Object.getOwnPropertyDescriptor(obj, key) - : null; - if (desc && (desc.get || desc.set)) { - Object.defineProperty(newObj, key, desc); - } else { - newObj[key] = obj[key]; - } - } - } - newObj.default = obj; - if (cache) { - cache.set(obj, newObj); - } - return newObj; -} - -function ownKeys(object, enumerableOnly) { - var keys = Object.keys(object); - if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(object); - if (enumerableOnly) - symbols = symbols.filter(function (sym) { - return Object.getOwnPropertyDescriptor(object, sym).enumerable; - }); - keys.push.apply(keys, symbols); - } - return keys; -} - -function _objectSpread(target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i] != null ? arguments[i] : {}; - if (i % 2) { - ownKeys(Object(source), true).forEach(function (key) { - _defineProperty(target, key, source[key]); - }); - } else if (Object.getOwnPropertyDescriptors) { - Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); - } else { - ownKeys(Object(source)).forEach(function (key) { - Object.defineProperty( - target, - key, - Object.getOwnPropertyDescriptor(source, key) - ); - }); - } - } - return target; -} - -function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - return obj; -} - -async function run(maybeArgv, project) { - try { - const argv = buildArgv(maybeArgv); - - if (argv.init) { - await (0, _init().default)(); - return; - } - - const projects = getProjectListFromCLIArgs(argv, project); - const {results, globalConfig} = await (0, _core().runCLI)(argv, projects); - readResultsAndExit(results, globalConfig); - } catch (error) { - (0, _jestUtil().clearLine)(process.stderr); - (0, _jestUtil().clearLine)(process.stdout); - - if (error.stack) { - console.error(_chalk().default.red(error.stack)); - } else { - console.error(_chalk().default.red(error)); - } - - (0, _exit().default)(1); - throw error; - } -} - -const buildArgv = maybeArgv => { - const version = - (0, _core().getVersion)() + - (__dirname.includes(`packages${path().sep}jest-cli`) ? '-dev' : ''); - const rawArgv = maybeArgv || process.argv.slice(2); - const argv = (0, _yargs().default)(rawArgv) - .usage(args.usage) - .version(version) - .alias('help', 'h') - .options(args.options) - .epilogue(args.docs) - .check(args.check).argv; - (0, _jestValidate().validateCLIOptions)( - argv, - _objectSpread({}, args.options, { - deprecationEntries: _jestConfig().deprecationEntries - }), // strip leading dashes - Array.isArray(rawArgv) - ? rawArgv.map(rawArgv => rawArgv.replace(/^--?/, '')) - : Object.keys(rawArgv) - ); // strip dashed args - - return Object.keys(argv).reduce((result, key) => { - if (!key.includes('-')) { - result[key] = argv[key]; - } - - return result; - }, {}); -}; - -exports.buildArgv = buildArgv; - -const getProjectListFromCLIArgs = (argv, project) => { - const projects = argv.projects ? argv.projects : []; - - if (project) { - projects.push(project); - } - - if (!projects.length && process.platform === 'win32') { - try { - projects.push((0, _realpathNative().sync)(process.cwd())); - } catch (err) { - // do nothing, just catch error - // process.binding('fs').realpath can throw, e.g. on mapped drives - } - } - - if (!projects.length) { - projects.push(process.cwd()); - } - - return projects; -}; - -const readResultsAndExit = (result, globalConfig) => { - const code = !result || result.success ? 0 : globalConfig.testFailureExitCode; // Only exit if needed - - process.on('exit', () => { - if (typeof code === 'number' && code !== 0) { - process.exitCode = code; - } - }); - - if (globalConfig.forceExit) { - if (!globalConfig.detectOpenHandles) { - console.warn( - _chalk().default.bold('Force exiting Jest: ') + - 'Have you considered using `--detectOpenHandles` to detect ' + - 'async operations that kept running after all tests finished?' - ); - } - - (0, _exit().default)(code); - } else if (!globalConfig.detectOpenHandles) { - setTimeout(() => { - console.warn( - _chalk().default.yellow.bold( - 'Jest did not exit one second after the test run has completed.\n\n' - ) + - _chalk().default.yellow( - 'This usually means that there are asynchronous operations that ' + - "weren't stopped in your tests. Consider running Jest with " + - '`--detectOpenHandles` to troubleshoot this issue.' - ) - ); - }, 1000).unref(); - } -}; diff --git a/node_modules/jest/node_modules/jest-cli/build/index.d.ts b/node_modules/jest/node_modules/jest-cli/build/index.d.ts deleted file mode 100644 index d4ee70eb..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/index.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -export { run } from './cli'; -//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/node_modules/jest/node_modules/jest-cli/build/index.d.ts.map b/node_modules/jest/node_modules/jest-cli/build/index.d.ts.map deleted file mode 100644 index ae46480c..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/index.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC"} \ No newline at end of file diff --git a/node_modules/jest/node_modules/jest-cli/build/index.js b/node_modules/jest/node_modules/jest-cli/build/index.js deleted file mode 100644 index fdfb92e9..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/index.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -Object.defineProperty(exports, 'run', { - enumerable: true, - get: function () { - return _cli.run; - } -}); - -var _cli = require('./cli'); diff --git a/node_modules/jest/node_modules/jest-cli/build/init/errors.d.ts b/node_modules/jest/node_modules/jest-cli/build/init/errors.d.ts deleted file mode 100644 index 54dfc65c..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/init/errors.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -export declare class NotFoundPackageJsonError extends Error { - constructor(rootDir: string); -} -export declare class MalformedPackageJsonError extends Error { - constructor(packageJsonPath: string); -} -//# sourceMappingURL=errors.d.ts.map \ No newline at end of file diff --git a/node_modules/jest/node_modules/jest-cli/build/init/errors.d.ts.map b/node_modules/jest/node_modules/jest-cli/build/init/errors.d.ts.map deleted file mode 100644 index 6b97d292..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/init/errors.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/init/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAK5B;AAED,qBAAa,yBAA0B,SAAQ,KAAK;gBACtC,eAAe,EAAE,MAAM;CAQpC"} \ No newline at end of file diff --git a/node_modules/jest/node_modules/jest-cli/build/init/errors.js b/node_modules/jest/node_modules/jest-cli/build/init/errors.js deleted file mode 100644 index eed7c8a6..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/init/errors.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.MalformedPackageJsonError = exports.NotFoundPackageJsonError = void 0; - -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -class NotFoundPackageJsonError extends Error { - constructor(rootDir) { - super(`Could not find a "package.json" file in ${rootDir}`); - this.name = ''; - Error.captureStackTrace(this, () => {}); - } -} - -exports.NotFoundPackageJsonError = NotFoundPackageJsonError; - -class MalformedPackageJsonError extends Error { - constructor(packageJsonPath) { - super( - `There is malformed json in ${packageJsonPath}\n` + - 'Fix it, and then run "jest --init"' - ); - this.name = ''; - Error.captureStackTrace(this, () => {}); - } -} - -exports.MalformedPackageJsonError = MalformedPackageJsonError; diff --git a/node_modules/jest/node_modules/jest-cli/build/init/generate_config_file.d.ts b/node_modules/jest/node_modules/jest-cli/build/init/generate_config_file.d.ts deleted file mode 100644 index 2e3adf26..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/init/generate_config_file.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -declare const generateConfigFile: (results: Record, generateEsm?: boolean) => string; -export default generateConfigFile; -//# sourceMappingURL=generate_config_file.d.ts.map \ No newline at end of file diff --git a/node_modules/jest/node_modules/jest-cli/build/init/generate_config_file.d.ts.map b/node_modules/jest/node_modules/jest-cli/build/init/generate_config_file.d.ts.map deleted file mode 100644 index 9b92906b..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/init/generate_config_file.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"generate_config_file.d.ts","sourceRoot":"","sources":["../../src/init/generate_config_file.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA4BH,QAAA,MAAM,kBAAkB,qEAmDvB,CAAC;AAEF,eAAe,kBAAkB,CAAC"} \ No newline at end of file diff --git a/node_modules/jest/node_modules/jest-cli/build/init/generate_config_file.js b/node_modules/jest/node_modules/jest-cli/build/init/generate_config_file.js deleted file mode 100644 index c86eabd6..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/init/generate_config_file.js +++ /dev/null @@ -1,87 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.default = void 0; - -function _jestConfig() { - const data = require('jest-config'); - - _jestConfig = function () { - return data; - }; - - return data; -} - -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -const stringifyOption = (option, map, linePrefix = '') => { - const optionDescription = ` // ${_jestConfig().descriptions[option]}`; - const stringifiedObject = `${option}: ${JSON.stringify( - map[option], - null, - 2 - )}`; - return ( - optionDescription + - '\n' + - stringifiedObject - .split('\n') - .map(line => ' ' + linePrefix + line) - .join('\n') + - ',\n' - ); -}; - -const generateConfigFile = (results, generateEsm = false) => { - const {coverage, clearMocks, environment} = results; - const overrides = {}; - - if (coverage) { - Object.assign(overrides, { - coverageDirectory: 'coverage' - }); - } - - if (environment === 'node') { - Object.assign(overrides, { - testEnvironment: 'node' - }); - } - - if (clearMocks) { - Object.assign(overrides, { - clearMocks: true - }); - } - - const overrideKeys = Object.keys(overrides); - const properties = []; - - for (const option in _jestConfig().descriptions) { - const opt = option; - - if (overrideKeys.includes(opt)) { - properties.push(stringifyOption(opt, overrides)); - } else { - properties.push(stringifyOption(opt, _jestConfig().defaults, '// ')); - } - } - - return ( - '// For a detailed explanation regarding each configuration property, visit:\n' + - '// https://jestjs.io/docs/en/configuration.html\n\n' + - (generateEsm ? 'export default {\n' : 'module.exports = {\n') + - properties.join('\n') + - '};\n' - ); -}; - -var _default = generateConfigFile; -exports.default = _default; diff --git a/node_modules/jest/node_modules/jest-cli/build/init/index.d.ts b/node_modules/jest/node_modules/jest-cli/build/init/index.d.ts deleted file mode 100644 index 49539d7e..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/init/index.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -declare const _default: (rootDir?: string) => Promise; -export default _default; -//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/node_modules/jest/node_modules/jest-cli/build/init/index.d.ts.map b/node_modules/jest/node_modules/jest-cli/build/init/index.d.ts.map deleted file mode 100644 index 9ff7ebeb..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/init/index.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/init/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AA+BH,wBAiHE"} \ No newline at end of file diff --git a/node_modules/jest/node_modules/jest-cli/build/init/index.js b/node_modules/jest/node_modules/jest-cli/build/init/index.js deleted file mode 100644 index f79b6bc8..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/init/index.js +++ /dev/null @@ -1,250 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.default = void 0; - -function fs() { - const data = _interopRequireWildcard(require('fs')); - - fs = function () { - return data; - }; - - return data; -} - -function path() { - const data = _interopRequireWildcard(require('path')); - - path = function () { - return data; - }; - - return data; -} - -function _chalk() { - const data = _interopRequireDefault(require('chalk')); - - _chalk = function () { - return data; - }; - - return data; -} - -function _prompts() { - const data = _interopRequireDefault(require('prompts')); - - _prompts = function () { - return data; - }; - - return data; -} - -function _realpathNative() { - const data = require('realpath-native'); - - _realpathNative = function () { - return data; - }; - - return data; -} - -function _jestConfig() { - const data = require('jest-config'); - - _jestConfig = function () { - return data; - }; - - return data; -} - -var _questions = _interopRequireWildcard(require('./questions')); - -var _errors = require('./errors'); - -var _generate_config_file = _interopRequireDefault( - require('./generate_config_file') -); - -var _modify_package_json = _interopRequireDefault( - require('./modify_package_json') -); - -function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : {default: obj}; -} - -function _getRequireWildcardCache() { - if (typeof WeakMap !== 'function') return null; - var cache = new WeakMap(); - _getRequireWildcardCache = function () { - return cache; - }; - return cache; -} - -function _interopRequireWildcard(obj) { - if (obj && obj.__esModule) { - return obj; - } - if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { - return {default: obj}; - } - var cache = _getRequireWildcardCache(); - if (cache && cache.has(obj)) { - return cache.get(obj); - } - var newObj = {}; - var hasPropertyDescriptor = - Object.defineProperty && Object.getOwnPropertyDescriptor; - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) { - var desc = hasPropertyDescriptor - ? Object.getOwnPropertyDescriptor(obj, key) - : null; - if (desc && (desc.get || desc.set)) { - Object.defineProperty(newObj, key, desc); - } else { - newObj[key] = obj[key]; - } - } - } - newObj.default = obj; - if (cache) { - cache.set(obj, newObj); - } - return newObj; -} - -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -const { - JEST_CONFIG_BASE_NAME, - JEST_CONFIG_EXT_MJS, - JEST_CONFIG_EXT_JS, - JEST_CONFIG_EXT_ORDER, - PACKAGE_JSON -} = _jestConfig().constants; - -const getConfigFilename = ext => JEST_CONFIG_BASE_NAME + ext; - -var _default = async (rootDir = (0, _realpathNative().sync)(process.cwd())) => { - // prerequisite checks - const projectPackageJsonPath = path().join(rootDir, PACKAGE_JSON); - - if (!fs().existsSync(projectPackageJsonPath)) { - throw new _errors.NotFoundPackageJsonError(rootDir); - } - - const questions = _questions.default.slice(0); - - let hasJestProperty = false; - let projectPackageJson; - - try { - projectPackageJson = JSON.parse( - fs().readFileSync(projectPackageJsonPath, 'utf-8') - ); - } catch (error) { - throw new _errors.MalformedPackageJsonError(projectPackageJsonPath); - } - - if (projectPackageJson.jest) { - hasJestProperty = true; - } - - const existingJestConfigPath = JEST_CONFIG_EXT_ORDER.find(ext => - fs().existsSync(path().join(rootDir, getConfigFilename(ext))) - ); - const jestConfigPath = - existingJestConfigPath || - path().join( - rootDir, - getConfigFilename( - projectPackageJson.type === 'module' - ? JEST_CONFIG_EXT_MJS - : JEST_CONFIG_EXT_JS - ) - ); - - if (hasJestProperty || existingJestConfigPath) { - const result = await (0, _prompts().default)({ - initial: true, - message: - 'It seems that you already have a jest configuration, do you want to override it?', - name: 'continue', - type: 'confirm' - }); - - if (!result.continue) { - console.log(); - console.log('Aborting...'); - return; - } - } // Add test script installation only if needed - - if ( - !projectPackageJson.scripts || - projectPackageJson.scripts.test !== 'jest' - ) { - questions.unshift(_questions.testScriptQuestion); - } // Start the init process - - console.log(); - console.log( - _chalk().default.underline( - `The following questions will help Jest to create a suitable configuration for your project\n` - ) - ); - let promptAborted = false; // @ts-ignore: Return type cannot be object - faulty typings - - const results = await (0, _prompts().default)(questions, { - onCancel: () => { - promptAborted = true; - } - }); - - if (promptAborted) { - console.log(); - console.log('Aborting...'); - return; - } - - const shouldModifyScripts = results.scripts; - - if (shouldModifyScripts || hasJestProperty) { - const modifiedPackageJson = (0, _modify_package_json.default)({ - projectPackageJson, - shouldModifyScripts - }); - fs().writeFileSync(projectPackageJsonPath, modifiedPackageJson); - console.log(''); - console.log( - `✏️ Modified ${_chalk().default.cyan(projectPackageJsonPath)}` - ); - } - - const generatedConfig = (0, _generate_config_file.default)( - results, - projectPackageJson.type === 'module' || - jestConfigPath.endsWith(JEST_CONFIG_EXT_MJS) - ); - fs().writeFileSync(jestConfigPath, generatedConfig); - console.log(''); - console.log( - `πŸ“ Configuration file created at ${_chalk().default.cyan(jestConfigPath)}` - ); -}; - -exports.default = _default; diff --git a/node_modules/jest/node_modules/jest-cli/build/init/modify_package_json.d.ts b/node_modules/jest/node_modules/jest-cli/build/init/modify_package_json.d.ts deleted file mode 100644 index 8139ab5f..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/init/modify_package_json.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import type { ProjectPackageJson } from './types'; -declare const modifyPackageJson: ({ projectPackageJson, shouldModifyScripts, }: { - projectPackageJson: ProjectPackageJson; - shouldModifyScripts: boolean; -}) => string; -export default modifyPackageJson; -//# sourceMappingURL=modify_package_json.d.ts.map \ No newline at end of file diff --git a/node_modules/jest/node_modules/jest-cli/build/init/modify_package_json.d.ts.map b/node_modules/jest/node_modules/jest-cli/build/init/modify_package_json.d.ts.map deleted file mode 100644 index 5dcedaf2..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/init/modify_package_json.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"modify_package_json.d.ts","sourceRoot":"","sources":["../../src/init/modify_package_json.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,SAAS,CAAC;AAEhD,QAAA,MAAM,iBAAiB;;;YAgBtB,CAAC;AAEF,eAAe,iBAAiB,CAAC"} \ No newline at end of file diff --git a/node_modules/jest/node_modules/jest-cli/build/init/modify_package_json.js b/node_modules/jest/node_modules/jest-cli/build/init/modify_package_json.js deleted file mode 100644 index 526b485b..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/init/modify_package_json.js +++ /dev/null @@ -1,28 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.default = void 0; - -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -const modifyPackageJson = ({projectPackageJson, shouldModifyScripts}) => { - if (shouldModifyScripts) { - projectPackageJson.scripts - ? (projectPackageJson.scripts.test = 'jest') - : (projectPackageJson.scripts = { - test: 'jest' - }); - } - - delete projectPackageJson.jest; - return JSON.stringify(projectPackageJson, null, 2) + '\n'; -}; - -var _default = modifyPackageJson; -exports.default = _default; diff --git a/node_modules/jest/node_modules/jest-cli/build/init/questions.d.ts b/node_modules/jest/node_modules/jest-cli/build/init/questions.d.ts deleted file mode 100644 index 23dee5b8..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/init/questions.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import type { PromptObject } from 'prompts'; -declare const defaultQuestions: Array; -export default defaultQuestions; -export declare const testScriptQuestion: PromptObject; -//# sourceMappingURL=questions.d.ts.map \ No newline at end of file diff --git a/node_modules/jest/node_modules/jest-cli/build/init/questions.d.ts.map b/node_modules/jest/node_modules/jest-cli/build/init/questions.d.ts.map deleted file mode 100644 index 993f9f2f..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/init/questions.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"questions.d.ts","sourceRoot":"","sources":["../../src/init/questions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,SAAS,CAAC;AAE1C,QAAA,MAAM,gBAAgB,EAAE,KAAK,CAAC,YAAY,CAuBzC,CAAC;AAEF,eAAe,gBAAgB,CAAC;AAEhC,eAAO,MAAM,kBAAkB,EAAE,YAMhC,CAAC"} \ No newline at end of file diff --git a/node_modules/jest/node_modules/jest-cli/build/init/questions.js b/node_modules/jest/node_modules/jest-cli/build/init/questions.js deleted file mode 100644 index e4790b96..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/init/questions.js +++ /dev/null @@ -1,53 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); -exports.testScriptQuestion = exports.default = void 0; - -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -const defaultQuestions = [ - { - choices: [ - { - title: 'node', - value: 'node' - }, - { - title: 'jsdom (browser-like)', - value: 'jsdom' - } - ], - initial: 0, - message: 'Choose the test environment that will be used for testing', - name: 'environment', - type: 'select' - }, - { - initial: false, - message: 'Do you want Jest to add coverage reports?', - name: 'coverage', - type: 'confirm' - }, - { - initial: false, - message: 'Automatically clear mock calls and instances between every test?', - name: 'clearMocks', - type: 'confirm' - } -]; -var _default = defaultQuestions; -exports.default = _default; -const testScriptQuestion = { - initial: true, - message: - 'Would you like to use Jest when running "test" script in "package.json"?', - name: 'scripts', - type: 'confirm' -}; -exports.testScriptQuestion = testScriptQuestion; diff --git a/node_modules/jest/node_modules/jest-cli/build/init/types.d.ts b/node_modules/jest/node_modules/jest-cli/build/init/types.d.ts deleted file mode 100644 index d14b3077..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/init/types.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import type { Config } from '@jest/types'; -export declare type ProjectPackageJson = { - jest?: Partial; - scripts?: Record; - type?: 'commonjs' | 'module'; -}; -//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/node_modules/jest/node_modules/jest-cli/build/init/types.d.ts.map b/node_modules/jest/node_modules/jest-cli/build/init/types.d.ts.map deleted file mode 100644 index 5d6876b2..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/init/types.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/init/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAExC,oBAAY,kBAAkB,GAAG;IAC/B,IAAI,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,UAAU,GAAG,QAAQ,CAAC;CAC9B,CAAC"} \ No newline at end of file diff --git a/node_modules/jest/node_modules/jest-cli/build/init/types.js b/node_modules/jest/node_modules/jest-cli/build/init/types.js deleted file mode 100644 index ad9a93a7..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/init/types.js +++ /dev/null @@ -1 +0,0 @@ -'use strict'; diff --git a/node_modules/jest/node_modules/jest-cli/build/ts3.4/cli/args.d.ts b/node_modules/jest/node_modules/jest-cli/build/ts3.4/cli/args.d.ts deleted file mode 100644 index 362e14fd..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/ts3.4/cli/args.d.ts +++ /dev/null @@ -1,498 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import { Config } from '@jest/types'; -export declare function check(argv: Config.Argv): true; -export declare const usage = "Usage: $0 [--config=] [TestPathPattern]"; -export declare const docs = "Documentation: https://jestjs.io/"; -export declare const options: { - readonly all: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly automock: { - readonly default: undefined; - readonly description: "Automock all files by default."; - readonly type: "boolean"; - }; - readonly bail: { - readonly alias: "b"; - readonly default: undefined; - readonly description: "Exit the test suite immediately after `n` number of failing tests."; - readonly type: "boolean"; - }; - readonly browser: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly cache: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly cacheDirectory: { - readonly description: string; - readonly type: "string"; - }; - readonly changedFilesWithAncestor: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly changedSince: { - readonly description: string; - readonly nargs: 1; - readonly type: "string"; - }; - readonly ci: { - readonly default: boolean; - readonly description: string; - readonly type: "boolean"; - }; - readonly clearCache: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly clearMocks: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly collectCoverage: { - readonly default: undefined; - readonly description: "Alias for --coverage."; - readonly type: "boolean"; - }; - readonly collectCoverageFrom: { - readonly description: string; - readonly type: "string"; - }; - readonly collectCoverageOnlyFrom: { - readonly description: "Explicit list of paths coverage will be restricted to."; - readonly string: true; - readonly type: "array"; - }; - readonly color: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly colors: { - readonly default: undefined; - readonly description: "Alias for `--color`."; - readonly type: "boolean"; - }; - readonly config: { - readonly alias: "c"; - readonly description: string; - readonly type: "string"; - }; - readonly coverage: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly coverageDirectory: { - readonly description: "The directory where Jest should output its coverage files."; - readonly type: "string"; - }; - readonly coveragePathIgnorePatterns: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly coverageProvider: { - readonly choices: readonly ["babel", "v8"]; - readonly description: "Select between Babel and V8 to collect coverage"; - }; - readonly coverageReporters: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly coverageThreshold: { - readonly description: string; - readonly type: "string"; - }; - readonly debug: { - readonly default: undefined; - readonly description: "Print debugging info about your jest config."; - readonly type: "boolean"; - }; - readonly detectLeaks: { - readonly default: false; - readonly description: string; - readonly type: "boolean"; - }; - readonly detectOpenHandles: { - readonly default: false; - readonly description: string; - readonly type: "boolean"; - }; - readonly env: { - readonly description: string; - readonly type: "string"; - }; - readonly errorOnDeprecated: { - readonly default: false; - readonly description: "Make calling deprecated APIs throw helpful error messages."; - readonly type: "boolean"; - }; - readonly expand: { - readonly alias: "e"; - readonly default: undefined; - readonly description: "Use this flag to show full diffs instead of a patch."; - readonly type: "boolean"; - }; - readonly filter: { - readonly default: undefined; - readonly description: string; - readonly type: "string"; - }; - readonly findRelatedTests: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly forceExit: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly globalSetup: { - readonly description: "The path to a module that runs before All Tests."; - readonly type: "string"; - }; - readonly globalTeardown: { - readonly description: "The path to a module that runs after All Tests."; - readonly type: "string"; - }; - readonly globals: { - readonly description: string; - readonly type: "string"; - }; - readonly haste: { - readonly description: "A JSON string with map of variables for the haste module system"; - readonly type: "string"; - }; - readonly init: { - readonly description: "Generate a basic configuration file"; - readonly type: "boolean"; - }; - readonly json: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly lastCommit: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly listTests: { - readonly default: false; - readonly description: string; - readonly type: "boolean"; - }; - readonly logHeapUsage: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly mapCoverage: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly maxConcurrency: { - readonly default: 5; - readonly description: string; - readonly type: "number"; - }; - readonly maxWorkers: { - readonly alias: "w"; - readonly description: string; - readonly type: "string"; - }; - readonly moduleDirectories: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly moduleFileExtensions: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly moduleNameMapper: { - readonly description: string; - readonly type: "string"; - }; - readonly modulePathIgnorePatterns: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly modulePaths: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly noStackTrace: { - readonly default: undefined; - readonly description: "Disables stack trace in test results output"; - readonly type: "boolean"; - }; - readonly notify: { - readonly default: undefined; - readonly description: "Activates notifications for test results."; - readonly type: "boolean"; - }; - readonly notifyMode: { - readonly default: "failure-change"; - readonly description: "Specifies when notifications will appear for test results."; - readonly type: "string"; - }; - readonly onlyChanged: { - readonly alias: "o"; - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly onlyFailures: { - readonly alias: "f"; - readonly default: undefined; - readonly description: "Run tests that failed in the previous execution."; - readonly type: "boolean"; - }; - readonly outputFile: { - readonly description: string; - readonly type: "string"; - }; - readonly passWithNoTests: { - readonly default: false; - readonly description: "Will not fail if no tests are found (for example while using `--testPathPattern`.)"; - readonly type: "boolean"; - }; - readonly preset: { - readonly description: "A preset that is used as a base for Jest's configuration."; - readonly type: "string"; - }; - readonly prettierPath: { - readonly default: undefined; - readonly description: "The path to the \"prettier\" module used for inline snapshots."; - readonly type: "string"; - }; - readonly projects: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly reporters: { - readonly description: "A list of custom reporters for the test suite."; - readonly string: true; - readonly type: "array"; - }; - readonly resetMocks: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly resetModules: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly resolver: { - readonly description: "A JSON string which allows the use of a custom resolver."; - readonly type: "string"; - }; - readonly restoreMocks: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly rootDir: { - readonly description: string; - readonly type: "string"; - }; - readonly roots: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly runInBand: { - readonly alias: "i"; - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly runTestsByPath: { - readonly default: false; - readonly description: string; - readonly type: "boolean"; - }; - readonly runner: { - readonly description: "Allows to use a custom runner instead of Jest's default test runner."; - readonly type: "string"; - }; - readonly setupFiles: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly setupFilesAfterEnv: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly showConfig: { - readonly default: undefined; - readonly description: "Print your jest config and then exits."; - readonly type: "boolean"; - }; - readonly silent: { - readonly default: undefined; - readonly description: "Prevent tests from printing messages through the console."; - readonly type: "boolean"; - }; - readonly skipFilter: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly snapshotSerializers: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly testEnvironment: { - readonly description: "Alias for --env"; - readonly type: "string"; - }; - readonly testEnvironmentOptions: { - readonly description: string; - readonly type: "string"; - }; - readonly testFailureExitCode: { - readonly description: "Exit code of `jest` command if the test run failed"; - readonly type: "string"; - }; - readonly testLocationInResults: { - readonly default: false; - readonly description: "Add `location` information to the test results"; - readonly type: "boolean"; - }; - readonly testMatch: { - readonly description: "The glob patterns Jest uses to detect test files."; - readonly string: true; - readonly type: "array"; - }; - readonly testNamePattern: { - readonly alias: "t"; - readonly description: "Run only tests with a name that matches the regex pattern."; - readonly type: "string"; - }; - readonly testPathIgnorePatterns: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly testPathPattern: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly testRegex: { - readonly description: "A string or array of string regexp patterns that Jest uses to detect test files."; - readonly string: true; - readonly type: "array"; - }; - readonly testResultsProcessor: { - readonly description: string; - readonly type: "string"; - }; - readonly testRunner: { - readonly description: string; - readonly type: "string"; - }; - readonly testSequencer: { - readonly description: string; - readonly type: "string"; - }; - readonly testTimeout: { - readonly description: "This option sets the default timeouts of test cases."; - readonly type: "number"; - }; - readonly testURL: { - readonly description: "This option sets the URL for the jsdom environment."; - readonly type: "string"; - }; - readonly timers: { - readonly description: string; - readonly type: "string"; - }; - readonly transform: { - readonly description: string; - readonly type: "string"; - }; - readonly transformIgnorePatterns: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly unmockedModulePathPatterns: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly updateSnapshot: { - readonly alias: "u"; - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly useStderr: { - readonly default: undefined; - readonly description: "Divert all output to stderr."; - readonly type: "boolean"; - }; - readonly verbose: { - readonly default: undefined; - readonly description: "Display individual test results with the test suite hierarchy."; - readonly type: "boolean"; - }; - readonly version: { - readonly alias: "v"; - readonly default: undefined; - readonly description: "Print the version and exit"; - readonly type: "boolean"; - }; - readonly watch: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly watchAll: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; - readonly watchPathIgnorePatterns: { - readonly description: string; - readonly string: true; - readonly type: "array"; - }; - readonly watchman: { - readonly default: undefined; - readonly description: string; - readonly type: "boolean"; - }; -}; -//# sourceMappingURL=args.d.ts.map diff --git a/node_modules/jest/node_modules/jest-cli/build/ts3.4/cli/index.d.ts b/node_modules/jest/node_modules/jest-cli/build/ts3.4/cli/index.d.ts deleted file mode 100644 index 20929ac4..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/ts3.4/cli/index.d.ts +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import { Config } from '@jest/types'; -import yargs = require('yargs'); -export declare function run(maybeArgv?: Array, project?: Config.Path): Promise; -export declare const buildArgv: (maybeArgv?: string[] | undefined) => yargs.Arguments>; -//# sourceMappingURL=index.d.ts.map diff --git a/node_modules/jest/node_modules/jest-cli/build/ts3.4/index.d.ts b/node_modules/jest/node_modules/jest-cli/build/ts3.4/index.d.ts deleted file mode 100644 index 2bd6c06b..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/ts3.4/index.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -export { run } from './cli'; -//# sourceMappingURL=index.d.ts.map diff --git a/node_modules/jest/node_modules/jest-cli/build/ts3.4/init/errors.d.ts b/node_modules/jest/node_modules/jest-cli/build/ts3.4/init/errors.d.ts deleted file mode 100644 index 4a05894e..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/ts3.4/init/errors.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -export declare class NotFoundPackageJsonError extends Error { - constructor(rootDir: string); -} -export declare class MalformedPackageJsonError extends Error { - constructor(packageJsonPath: string); -} -//# sourceMappingURL=errors.d.ts.map diff --git a/node_modules/jest/node_modules/jest-cli/build/ts3.4/init/generate_config_file.d.ts b/node_modules/jest/node_modules/jest-cli/build/ts3.4/init/generate_config_file.d.ts deleted file mode 100644 index b292b37d..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/ts3.4/init/generate_config_file.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -declare const generateConfigFile: (results: Record, generateEsm?: boolean) => string; -export default generateConfigFile; -//# sourceMappingURL=generate_config_file.d.ts.map diff --git a/node_modules/jest/node_modules/jest-cli/build/ts3.4/init/index.d.ts b/node_modules/jest/node_modules/jest-cli/build/ts3.4/init/index.d.ts deleted file mode 100644 index 68207c5a..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/ts3.4/init/index.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -declare const _default: (rootDir?: string) => Promise; -export default _default; -//# sourceMappingURL=index.d.ts.map diff --git a/node_modules/jest/node_modules/jest-cli/build/ts3.4/init/modify_package_json.d.ts b/node_modules/jest/node_modules/jest-cli/build/ts3.4/init/modify_package_json.d.ts deleted file mode 100644 index c088cba6..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/ts3.4/init/modify_package_json.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import { ProjectPackageJson } from './types'; -declare const modifyPackageJson: ({ projectPackageJson, shouldModifyScripts, }: { - projectPackageJson: ProjectPackageJson; - shouldModifyScripts: boolean; -}) => string; -export default modifyPackageJson; -//# sourceMappingURL=modify_package_json.d.ts.map diff --git a/node_modules/jest/node_modules/jest-cli/build/ts3.4/init/questions.d.ts b/node_modules/jest/node_modules/jest-cli/build/ts3.4/init/questions.d.ts deleted file mode 100644 index 1748cb05..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/ts3.4/init/questions.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import { PromptObject } from 'prompts'; -declare const defaultQuestions: Array; -export default defaultQuestions; -export declare const testScriptQuestion: PromptObject; -//# sourceMappingURL=questions.d.ts.map diff --git a/node_modules/jest/node_modules/jest-cli/build/ts3.4/init/types.d.ts b/node_modules/jest/node_modules/jest-cli/build/ts3.4/init/types.d.ts deleted file mode 100644 index bfaf33de..00000000 --- a/node_modules/jest/node_modules/jest-cli/build/ts3.4/init/types.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -import { Config } from '@jest/types'; -export declare type ProjectPackageJson = { - jest?: Partial; - scripts?: Record; - type?: 'commonjs' | 'module'; -}; -//# sourceMappingURL=types.d.ts.map