tsc-ts 0.0.10 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/tsc-ts.js +70 -1
- package/dist/api/compiler/ast-utilities.d.ts +19 -1
- package/dist/api/compiler/ast-utilities.js +180 -95
- package/dist/api/compiler/ast.d.ts +20 -15
- package/dist/api/compiler/ast.js +1023 -995
- package/dist/api/compiler/astnav.js +15 -15
- package/dist/api/compiler/binder-utilities.js +186 -186
- package/dist/api/compiler/binder.js +290 -263
- package/dist/api/compiler/character-codes.js +2 -2
- package/dist/api/compiler/checker-calls.js +173 -123
- package/dist/api/compiler/checker-classes.d.ts +14 -3
- package/dist/api/compiler/checker-classes.js +134 -90
- package/dist/api/compiler/checker-contextual.js +64 -61
- package/dist/api/compiler/checker-declaration-order.js +79 -79
- package/dist/api/compiler/checker-declarations.d.ts +1 -0
- package/dist/api/compiler/checker-declarations.js +160 -136
- package/dist/api/compiler/checker-declared-types.js +67 -65
- package/dist/api/compiler/checker-decorators.js +77 -77
- package/dist/api/compiler/checker-deprecation.d.ts +8 -3
- package/dist/api/compiler/checker-deprecation.js +76 -55
- package/dist/api/compiler/checker-destructuring.js +47 -45
- package/dist/api/compiler/checker-elaboration.js +24 -24
- package/dist/api/compiler/checker-emit-helpers.js +4 -4
- package/dist/api/compiler/checker-emit-resolver.d.ts +4 -2
- package/dist/api/compiler/checker-emit-resolver.js +25 -13
- package/dist/api/compiler/checker-evaluator.js +9 -9
- package/dist/api/compiler/checker-expressions.js +244 -211
- package/dist/api/compiler/checker-functions.js +113 -107
- package/dist/api/compiler/checker-generated-code.d.ts +0 -11
- package/dist/api/compiler/checker-generated-code.js +28 -52
- package/dist/api/compiler/checker-grammar.d.ts +1 -0
- package/dist/api/compiler/checker-grammar.js +469 -438
- package/dist/api/compiler/checker-heritage.js +91 -93
- package/dist/api/compiler/checker-inference.d.ts +77 -5
- package/dist/api/compiler/checker-inference.js +487 -113
- package/dist/api/compiler/checker-iteration.d.ts +0 -10
- package/dist/api/compiler/checker-iteration.js +35 -52
- package/dist/api/compiler/checker-javascript.js +14 -14
- package/dist/api/compiler/checker-jsdoc.d.ts +8 -10
- package/dist/api/compiler/checker-jsdoc.js +67 -58
- package/dist/api/compiler/checker-jsx.js +105 -88
- package/dist/api/compiler/checker-members.d.ts +9 -2
- package/dist/api/compiler/checker-members.js +210 -74
- package/dist/api/compiler/checker-modules.d.ts +15 -6
- package/dist/api/compiler/checker-modules.js +469 -309
- package/dist/api/compiler/checker-narrowing.js +273 -189
- package/dist/api/compiler/checker-object-literals.js +25 -22
- package/dist/api/compiler/checker-operators.js +126 -118
- package/dist/api/compiler/checker-overloads.js +27 -27
- package/dist/api/compiler/checker-property-access.js +59 -55
- package/dist/api/compiler/checker-services.d.ts +1 -0
- package/dist/api/compiler/checker-services.js +222 -210
- package/dist/api/compiler/checker-signatures.js +65 -49
- package/dist/api/compiler/checker-source-file.d.ts +5 -0
- package/dist/api/compiler/checker-source-file.js +154 -130
- package/dist/api/compiler/checker-statements.js +33 -32
- package/dist/api/compiler/checker-super.js +50 -50
- package/dist/api/compiler/checker-symbol-types.js +109 -93
- package/dist/api/compiler/checker-symbols.d.ts +13 -1
- package/dist/api/compiler/checker-symbols.js +264 -149
- package/dist/api/compiler/checker-type-factory.d.ts +5 -0
- package/dist/api/compiler/checker-type-factory.js +137 -34
- package/dist/api/compiler/checker-type-nodes.d.ts +1 -0
- package/dist/api/compiler/checker-type-nodes.js +179 -141
- package/dist/api/compiler/checker-type-operators.d.ts +2 -0
- package/dist/api/compiler/checker-type-operators.js +110 -63
- package/dist/api/compiler/checker-types.d.ts +80 -3
- package/dist/api/compiler/checker-types.js +121 -2
- package/dist/api/compiler/checker-unused.js +114 -118
- package/dist/api/compiler/checker-utilities.js +11 -11
- package/dist/api/compiler/checker.d.ts +93 -31
- package/dist/api/compiler/checker.js +143 -35
- package/dist/api/compiler/command-line.d.ts +1 -3
- package/dist/api/compiler/command-line.js +47 -44
- package/dist/api/compiler/compile-program.d.ts +19 -4
- package/dist/api/compiler/compile-program.js +45 -26
- package/dist/api/compiler/diagnostic-messages.d.ts +1849 -1774
- package/dist/api/compiler/diagnostic-messages.js +128 -122
- package/dist/api/compiler/diagnostics.js +7 -7
- package/dist/api/compiler/emitter.d.ts +7 -1
- package/dist/api/compiler/emitter.js +53 -11
- package/dist/api/compiler/file-include.d.ts +2 -1
- package/dist/api/compiler/file-include.js +11 -7
- package/dist/api/compiler/file-loader.d.ts +10 -0
- package/dist/api/compiler/file-loader.js +138 -41
- package/dist/api/compiler/instantiation.d.ts +7 -0
- package/dist/api/compiler/instantiation.js +101 -49
- package/dist/api/compiler/jsdoc.js +23 -23
- package/dist/api/compiler/link-tables.d.ts +48 -18
- package/dist/api/compiler/link-tables.js +80 -37
- package/dist/api/compiler/locales/cs-CZ.d.ts +1 -1
- package/dist/api/compiler/locales/cs-CZ.js +1 -1
- package/dist/api/compiler/locales/de-DE.d.ts +1 -1
- package/dist/api/compiler/locales/de-DE.js +1 -1
- package/dist/api/compiler/locales/es-ES.d.ts +1 -1
- package/dist/api/compiler/locales/es-ES.js +1 -1
- package/dist/api/compiler/locales/fr-FR.d.ts +1 -1
- package/dist/api/compiler/locales/fr-FR.js +1 -1
- package/dist/api/compiler/locales/it-IT.d.ts +1 -1
- package/dist/api/compiler/locales/it-IT.js +1 -1
- package/dist/api/compiler/locales/ja-JP.d.ts +1 -1
- package/dist/api/compiler/locales/ja-JP.js +1 -1
- package/dist/api/compiler/locales/ko-KR.d.ts +1 -1
- package/dist/api/compiler/locales/ko-KR.js +1 -1
- package/dist/api/compiler/locales/pl-PL.d.ts +1 -1
- package/dist/api/compiler/locales/pl-PL.js +1 -1
- package/dist/api/compiler/locales/pt-BR.d.ts +1 -1
- package/dist/api/compiler/locales/pt-BR.js +1 -1
- package/dist/api/compiler/locales/ru-RU.d.ts +1 -1
- package/dist/api/compiler/locales/ru-RU.js +1 -1
- package/dist/api/compiler/locales/tr-TR.d.ts +1 -1
- package/dist/api/compiler/locales/tr-TR.js +1 -1
- package/dist/api/compiler/locales/zh-CN.d.ts +1 -1
- package/dist/api/compiler/locales/zh-CN.js +1 -1
- package/dist/api/compiler/locales/zh-TW.d.ts +1 -1
- package/dist/api/compiler/locales/zh-TW.js +1 -1
- package/dist/api/compiler/module-resolution-types.js +6 -6
- package/dist/api/compiler/module-resolution.d.ts +10 -1
- package/dist/api/compiler/module-resolution.js +115 -84
- package/dist/api/compiler/module-specifiers.d.ts +15 -0
- package/dist/api/compiler/module-specifiers.js +24 -18
- package/dist/api/compiler/name-resolver.js +74 -65
- package/dist/api/compiler/node-builder-names.d.ts +11 -3
- package/dist/api/compiler/node-builder-names.js +210 -90
- package/dist/api/compiler/node-builder-pseudo.js +29 -31
- package/dist/api/compiler/node-builder-reuse.js +23 -22
- package/dist/api/compiler/node-builder.d.ts +18 -1
- package/dist/api/compiler/node-builder.js +191 -102
- package/dist/api/compiler/option-declarations.d.ts +2 -6
- package/dist/api/compiler/option-declarations.js +315 -375
- package/dist/api/compiler/options.d.ts +15 -33
- package/dist/api/compiler/options.js +21 -54
- package/dist/api/compiler/output-paths.d.ts +4 -1
- package/dist/api/compiler/output-paths.js +6 -11
- package/dist/api/compiler/package-json.d.ts +3 -3
- package/dist/api/compiler/package-json.js +11 -10
- package/dist/api/compiler/parser.d.ts +40 -19
- package/dist/api/compiler/parser.js +308 -216
- package/dist/api/compiler/path.d.ts +9 -0
- package/dist/api/compiler/path.js +20 -3
- package/dist/api/compiler/printer/emit-context.d.ts +3 -1
- package/dist/api/compiler/printer/emit-context.js +16 -1
- package/dist/api/compiler/printer/factory-base.d.ts +2 -2
- package/dist/api/compiler/printer/factory-base.js +7 -3
- package/dist/api/compiler/printer/factory.js +3 -1
- package/dist/api/compiler/printer/helpers.js +10 -1
- package/dist/api/compiler/printer/name-generator.d.ts +1 -1
- package/dist/api/compiler/printer/name-generator.js +35 -16
- package/dist/api/compiler/printer/printer.d.ts +1 -0
- package/dist/api/compiler/printer/printer.js +303 -281
- package/dist/api/compiler/printer/utilities.js +149 -147
- package/dist/api/compiler/program-checker.d.ts +8 -2
- package/dist/api/compiler/program-checker.js +84 -34
- package/dist/api/compiler/program-utilities.d.ts +3 -1
- package/dist/api/compiler/program-utilities.js +28 -15
- package/dist/api/compiler/program.d.ts +2 -0
- package/dist/api/compiler/program.js +69 -57
- package/dist/api/compiler/pseudo-bigint.d.ts +2 -0
- package/dist/api/compiler/pseudo-bigint.js +18 -0
- package/dist/api/compiler/regexp-checker.d.ts +1 -1
- package/dist/api/compiler/regexp-checker.js +93 -76
- package/dist/api/compiler/relations.d.ts +27 -4
- package/dist/api/compiler/relations.js +337 -180
- package/dist/api/compiler/reparser.js +60 -56
- package/dist/api/compiler/scanner.d.ts +19 -2
- package/dist/api/compiler/scanner.js +123 -108
- package/dist/api/compiler/shared-results.d.ts +463 -0
- package/dist/api/compiler/shared-results.js +2128 -0
- package/dist/api/compiler/sourcemap.js +2 -2
- package/dist/api/compiler/symbol-accessibility.js +87 -74
- package/dist/api/compiler/symbol.d.ts +22 -13
- package/dist/api/compiler/symbol.js +15 -1
- package/dist/api/compiler/syntax-kind.d.ts +198 -197
- package/dist/api/compiler/transformers/alias-references.js +247 -139
- package/dist/api/compiler/transformers/async-utilities.js +25 -25
- package/dist/api/compiler/transformers/async.d.ts +0 -1
- package/dist/api/compiler/transformers/async.js +64 -77
- package/dist/api/compiler/transformers/class-fields.d.ts +1 -0
- package/dist/api/compiler/transformers/class-fields.js +81 -78
- package/dist/api/compiler/transformers/commonjs-module.js +18 -15
- package/dist/api/compiler/transformers/const-enum-inliner.js +1 -1
- package/dist/api/compiler/transformers/declarations-diagnostics.js +247 -244
- package/dist/api/compiler/transformers/declarations-pseudo.js +100 -100
- package/dist/api/compiler/transformers/declarations-resolver.d.ts +0 -3
- package/dist/api/compiler/transformers/declarations-syntactic.d.ts +1 -2
- package/dist/api/compiler/transformers/declarations-syntactic.js +134 -156
- package/dist/api/compiler/transformers/declarations-tracker.js +18 -18
- package/dist/api/compiler/transformers/declarations.d.ts +4 -1
- package/dist/api/compiler/transformers/declarations.js +305 -238
- package/dist/api/compiler/transformers/decorator-metadata.d.ts +1 -1
- package/dist/api/compiler/transformers/decorator-metadata.js +53 -45
- package/dist/api/compiler/transformers/decorator-utilities.js +24 -24
- package/dist/api/compiler/transformers/destructuring.js +19 -18
- package/dist/api/compiler/transformers/emit-resolver.js +1 -1
- package/dist/api/compiler/transformers/es-decorators.js +55 -55
- package/dist/api/compiler/transformers/external-module-info.js +3 -3
- package/dist/api/compiler/transformers/for-await.js +25 -25
- package/dist/api/compiler/transformers/import-elision.js +14 -14
- package/dist/api/compiler/transformers/jsx.js +12 -12
- package/dist/api/compiler/transformers/legacy-decorators.js +17 -17
- package/dist/api/compiler/transformers/module.js +8 -8
- package/dist/api/compiler/transformers/named-evaluation.js +4 -4
- package/dist/api/compiler/transformers/object-rest-spread.js +20 -20
- package/dist/api/compiler/transformers/optional-chain.js +10 -10
- package/dist/api/compiler/transformers/reference-resolver.d.ts +12 -1
- package/dist/api/compiler/transformers/reference-resolver.js +131 -69
- package/dist/api/compiler/transformers/runtime-syntax.js +35 -31
- package/dist/api/compiler/transformers/subtree-facts.js +47 -47
- package/dist/api/compiler/transformers/syntax-facts.js +56 -58
- package/dist/api/compiler/transformers/type-eraser.js +73 -66
- package/dist/api/compiler/transformers/type-serialization.js +24 -24
- package/dist/api/compiler/transformers/using.js +12 -12
- package/dist/api/compiler/transformers/utilities.js +77 -77
- package/dist/api/compiler/transformers/visitor-base.js +172 -172
- package/dist/api/compiler/transformers/visitor-hooks.js +6 -2
- package/dist/api/compiler/tsconfig.d.ts +10 -2
- package/dist/api/compiler/tsconfig.js +136 -48
- package/dist/api/compiler/type-printer.js +40 -3
- package/dist/api/compiler/types.d.ts +2 -1
- package/dist/api/library/ast.generated.d.ts +42 -39
- package/dist/api/library/ast.generated.js +1 -1
- package/dist/api/library/compiler-options.generated.d.ts +111 -100
- package/dist/api/library/compiler-options.generated.js +1 -1
- package/dist/api/library/disk.js +12 -1
- package/dist/api/library/enums.generated.d.ts +206 -206
- package/dist/api/library/enums.generated.js +206 -206
- package/dist/api/library/nodes.js +26 -26
- package/package.json +9 -9
- package/src/compiler/ast-utilities.ts +99 -7
- package/src/compiler/ast.ts +55 -26
- package/src/compiler/binder.ts +39 -4
- package/src/compiler/character-codes.ts +2 -2
- package/src/compiler/checker-calls.ts +76 -8
- package/src/compiler/checker-classes.ts +78 -24
- package/src/compiler/checker-contextual.ts +6 -1
- package/src/compiler/checker-declarations.ts +31 -4
- package/src/compiler/checker-declared-types.ts +8 -5
- package/src/compiler/checker-decorators.ts +1 -1
- package/src/compiler/checker-deprecation.ts +29 -8
- package/src/compiler/checker-destructuring.ts +10 -3
- package/src/compiler/checker-emit-helpers.ts +1 -0
- package/src/compiler/checker-emit-resolver.ts +16 -6
- package/src/compiler/checker-expressions.ts +79 -46
- package/src/compiler/checker-functions.ts +21 -6
- package/src/compiler/checker-generated-code.ts +2 -22
- package/src/compiler/checker-grammar.ts +133 -60
- package/src/compiler/checker-heritage.ts +22 -21
- package/src/compiler/checker-inference.ts +514 -87
- package/src/compiler/checker-iteration.ts +18 -31
- package/src/compiler/checker-javascript.ts +1 -1
- package/src/compiler/checker-jsdoc.ts +50 -27
- package/src/compiler/checker-jsx.ts +26 -4
- package/src/compiler/checker-members.ts +197 -55
- package/src/compiler/checker-modules.ts +332 -65
- package/src/compiler/checker-narrowing.ts +98 -19
- package/src/compiler/checker-object-literals.ts +3 -0
- package/src/compiler/checker-operators.ts +11 -4
- package/src/compiler/checker-property-access.ts +7 -2
- package/src/compiler/checker-services.ts +39 -12
- package/src/compiler/checker-signatures.ts +15 -1
- package/src/compiler/checker-source-file.ts +39 -13
- package/src/compiler/checker-statements.ts +3 -2
- package/src/compiler/checker-symbol-types.ts +29 -6
- package/src/compiler/checker-symbols.ts +158 -15
- package/src/compiler/checker-type-factory.ts +120 -21
- package/src/compiler/checker-type-nodes.ts +46 -3
- package/src/compiler/checker-type-operators.ts +83 -26
- package/src/compiler/checker-types.ts +147 -4
- package/src/compiler/checker-unused.ts +9 -14
- package/src/compiler/checker.ts +168 -41
- package/src/compiler/command-line.ts +28 -28
- package/src/compiler/compile-program.ts +51 -25
- package/src/compiler/decoder.ts +13 -4
- package/src/compiler/diagnostic-messages.ts +1973 -1892
- package/src/compiler/emitter.ts +57 -8
- package/src/compiler/encoder.ts +23 -8
- package/src/compiler/file-include.ts +9 -3
- package/src/compiler/file-loader.ts +139 -32
- package/src/compiler/help.ts +10 -14
- package/src/compiler/incremental.ts +86 -18
- package/src/compiler/init.ts +2 -7
- package/src/compiler/instantiation.ts +77 -22
- package/src/compiler/jsdoc.ts +3 -1
- package/src/compiler/link-tables.ts +82 -37
- package/src/compiler/locales/cs-CZ.ts +1 -1
- package/src/compiler/locales/de-DE.ts +1 -1
- package/src/compiler/locales/es-ES.ts +1 -1
- package/src/compiler/locales/fr-FR.ts +1 -1
- package/src/compiler/locales/it-IT.ts +1 -1
- package/src/compiler/locales/ja-JP.ts +1 -1
- package/src/compiler/locales/ko-KR.ts +1 -1
- package/src/compiler/locales/pl-PL.ts +1 -1
- package/src/compiler/locales/pt-BR.ts +1 -1
- package/src/compiler/locales/ru-RU.ts +1 -1
- package/src/compiler/locales/tr-TR.ts +1 -1
- package/src/compiler/locales/zh-CN.ts +1 -1
- package/src/compiler/locales/zh-TW.ts +1 -1
- package/src/compiler/module-resolution.ts +44 -8
- package/src/compiler/module-specifiers.ts +62 -20
- package/src/compiler/name-resolver.ts +9 -1
- package/src/compiler/node-builder-names.ts +236 -54
- package/src/compiler/node-builder-pseudo.ts +4 -7
- package/src/compiler/node-builder-reuse.ts +5 -4
- package/src/compiler/node-builder.ts +130 -31
- package/src/compiler/option-declarations.ts +33 -103
- package/src/compiler/options.ts +23 -62
- package/src/compiler/output-paths.ts +5 -18
- package/src/compiler/package-entrypoints.ts +345 -0
- package/src/compiler/package-json.ts +4 -4
- package/src/compiler/parallel-check.ts +197 -8
- package/src/compiler/parallel-emit.ts +1 -1
- package/src/compiler/parser.ts +156 -39
- package/src/compiler/path.ts +22 -2
- package/src/compiler/printer/emit-context.ts +16 -0
- package/src/compiler/printer/factory-base.ts +10 -3
- package/src/compiler/printer/factory.ts +4 -1
- package/src/compiler/printer/helpers.ts +10 -1
- package/src/compiler/printer/name-generator.ts +24 -2
- package/src/compiler/printer/printer.ts +35 -14
- package/src/compiler/printer/utilities.ts +8 -2
- package/src/compiler/program-checker.ts +53 -5
- package/src/compiler/program-utilities.ts +23 -10
- package/src/compiler/program.ts +13 -1
- package/src/compiler/pseudo-bigint.ts +17 -0
- package/src/compiler/regexp-checker.ts +63 -30
- package/src/compiler/relations.ts +233 -77
- package/src/compiler/reparser.ts +7 -2
- package/src/compiler/scanner.ts +109 -79
- package/src/compiler/shared-results.ts +2414 -0
- package/src/compiler/show-config.ts +18 -1
- package/src/compiler/sourcemap.ts +2 -2
- package/src/compiler/symbol-accessibility.ts +26 -3
- package/src/compiler/symbol.ts +31 -14
- package/src/compiler/syntax-kind.ts +188 -187
- package/src/compiler/thread-entry.ts +19 -2
- package/src/compiler/transformers/alias-references.ts +123 -4
- package/src/compiler/transformers/async.ts +2 -17
- package/src/compiler/transformers/class-fields.ts +13 -12
- package/src/compiler/transformers/commonjs-module.ts +11 -7
- package/src/compiler/transformers/declarations-diagnostics.ts +5 -3
- package/src/compiler/transformers/declarations-pseudo.ts +2 -4
- package/src/compiler/transformers/declarations-resolver.ts +0 -3
- package/src/compiler/transformers/declarations-syntactic.ts +1 -21
- package/src/compiler/transformers/declarations.ts +134 -48
- package/src/compiler/transformers/decorator-metadata.ts +9 -1
- package/src/compiler/transformers/destructuring.ts +4 -3
- package/src/compiler/transformers/external-module-info.ts +1 -1
- package/src/compiler/transformers/jsx.ts +2 -1
- package/src/compiler/transformers/reference-resolver.ts +83 -19
- package/src/compiler/transformers/runtime-syntax.ts +6 -1
- package/src/compiler/transformers/syntax-facts.ts +2 -7
- package/src/compiler/transformers/type-eraser.ts +10 -1
- package/src/compiler/transformers/type-serialization.ts +3 -2
- package/src/compiler/transformers/visitor-base.ts +2 -1
- package/src/compiler/transformers/visitor-hooks.ts +9 -4
- package/src/compiler/tsc-build.ts +3 -0
- package/src/compiler/tsc-cli.ts +2 -0
- package/src/compiler/tsc-compile.ts +7 -2
- package/src/compiler/tsc-watch.ts +74 -45
- package/src/compiler/tsconfig.ts +176 -19
- package/src/compiler/type-printer.ts +36 -2
- package/src/compiler/types.ts +2 -1
- package/src/library/ast.generated.ts +57 -41
- package/src/library/compiler-options.generated.ts +117 -103
- package/src/library/disk.ts +10 -1
- package/src/library/enums.generated.ts +196 -196
|
@@ -127,7 +127,7 @@ class RegularExpressionChecker {
|
|
|
127
127
|
for (const reference of this.groupNameReferences) {
|
|
128
128
|
if (this.groupSpecifiers.has(reference.name))
|
|
129
129
|
continue;
|
|
130
|
-
this.error(
|
|
130
|
+
this.error(445 /* Diagnostics.There_is_no_capturing_group_named_0_in_this_regular_expression */, reference.pos, reference.end - reference.pos, [reference.name]);
|
|
131
131
|
if (this.groupSpecifiers.size > 0) {
|
|
132
132
|
const suggestion = getSpellingSuggestion(reference.name, setToArray(this.groupSpecifiers));
|
|
133
133
|
if (suggestion !== '')
|
|
@@ -139,22 +139,36 @@ class RegularExpressionChecker {
|
|
|
139
139
|
if (escape.value <= this.numberOfCapturingGroups)
|
|
140
140
|
continue;
|
|
141
141
|
if (this.numberOfCapturingGroups > 0)
|
|
142
|
-
this.error(
|
|
142
|
+
this.error(446 /* Diagnostics.This_backreference_refers_to_a_group_that_does_not_exist_There_are_only_0_capturing_groups_in_this_regular_expression */, escape.pos, escape.end - escape.pos, [String(this.numberOfCapturingGroups)]);
|
|
143
143
|
else
|
|
144
|
-
this.error(
|
|
144
|
+
this.error(447 /* Diagnostics.This_backreference_refers_to_a_group_that_does_not_exist_There_are_no_capturing_groups_in_this_regular_expression */, escape.pos, escape.end - escape.pos, noArgs);
|
|
145
145
|
}
|
|
146
146
|
return this.numberOfCapturingGroups;
|
|
147
147
|
}
|
|
148
148
|
// Disjunction ::= Alternative ('|' Alternative)*
|
|
149
149
|
scanDisjunction(isInGroup) {
|
|
150
|
+
// The names any alternative defines. One alternative matches, so in a group they join the
|
|
151
|
+
// enclosing alternative's scope: `(?:(?<a>x))(?<a>z)` defines `a` twice.
|
|
152
|
+
let disjunctionNames;
|
|
150
153
|
for (;;) {
|
|
151
154
|
this.namedCapturingGroups.push(new Set());
|
|
152
155
|
this.scanAlternative(isInGroup);
|
|
153
|
-
this.namedCapturingGroups.pop();
|
|
156
|
+
const alternativeNames = this.namedCapturingGroups.pop();
|
|
157
|
+
if (alternativeNames.size > 0) {
|
|
158
|
+
if (disjunctionNames === undefined)
|
|
159
|
+
disjunctionNames = new Set();
|
|
160
|
+
for (const name of alternativeNames)
|
|
161
|
+
disjunctionNames.add(name);
|
|
162
|
+
}
|
|
154
163
|
if (this.char() !== 124 /* CharacterCodes.bar */)
|
|
155
|
-
|
|
164
|
+
break;
|
|
156
165
|
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
157
166
|
}
|
|
167
|
+
if (isInGroup && disjunctionNames !== undefined && this.namedCapturingGroups.length > 0) {
|
|
168
|
+
const parentScope = this.namedCapturingGroups[this.namedCapturingGroups.length - 1];
|
|
169
|
+
for (const name of disjunctionNames)
|
|
170
|
+
parentScope.add(name);
|
|
171
|
+
}
|
|
158
172
|
}
|
|
159
173
|
// Alternative ::= Term*
|
|
160
174
|
// Term ::= Assertion | Atom Quantifier?
|
|
@@ -201,7 +215,7 @@ class RegularExpressionChecker {
|
|
|
201
215
|
this.scanGroupName(false);
|
|
202
216
|
this.scanExpectedChar(62 /* CharacterCodes.greaterThan */);
|
|
203
217
|
if (this.scanner.languageVersion() < 5 /* ScriptTarget.ES2018 */)
|
|
204
|
-
this.error(
|
|
218
|
+
this.error(416 /* Diagnostics.Named_capturing_groups_are_only_available_when_targeting_ES2018_or_later */, groupNameStart, this.scanner.pos - groupNameStart, noArgs);
|
|
205
219
|
this.numberOfCapturingGroups++;
|
|
206
220
|
isPreviousTermQuantifiable = true;
|
|
207
221
|
}
|
|
@@ -213,8 +227,11 @@ class RegularExpressionChecker {
|
|
|
213
227
|
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
214
228
|
this.scanPatternModifiers(setFlags);
|
|
215
229
|
if (this.scanner.pos === flagsStart + 1)
|
|
216
|
-
this.error(
|
|
230
|
+
this.error(417 /* Diagnostics.Subpattern_flags_must_be_present_when_there_is_a_minus_sign */, flagsStart, this.scanner.pos - flagsStart, noArgs);
|
|
217
231
|
}
|
|
232
|
+
// Modifier characters make this `(?flags:` rather than a plain `(?:` group.
|
|
233
|
+
if (this.scanner.pos !== flagsStart && this.scanner.languageVersion() < 12 /* ScriptTarget.ES2025 */)
|
|
234
|
+
this.error(1897 /* Diagnostics.Regular_expression_pattern_modifiers_are_only_available_when_targeting_0_or_later */, flagsStart, this.scanner.pos - flagsStart, ['es2025']);
|
|
218
235
|
this.scanExpectedChar(58 /* CharacterCodes.colon */);
|
|
219
236
|
isPreviousTermQuantifiable = true;
|
|
220
237
|
}
|
|
@@ -239,10 +256,10 @@ class RegularExpressionChecker {
|
|
|
239
256
|
const max = this.scanDigits();
|
|
240
257
|
if (min === '') {
|
|
241
258
|
if (max !== '' || this.char() === 125 /* CharacterCodes.closeBrace */) {
|
|
242
|
-
this.error(
|
|
259
|
+
this.error(418 /* Diagnostics.Incomplete_quantifier_Digit_expected */, digitsStart, 0, noArgs);
|
|
243
260
|
}
|
|
244
261
|
else {
|
|
245
|
-
this.error(
|
|
262
|
+
this.error(421 /* Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash */, start, 1, [
|
|
246
263
|
String.fromCharCode(ch),
|
|
247
264
|
]);
|
|
248
265
|
isPreviousTermQuantifiable = true;
|
|
@@ -252,12 +269,12 @@ class RegularExpressionChecker {
|
|
|
252
269
|
else if (max !== '' &&
|
|
253
270
|
compareDecimalStrings(min, max) > 0 &&
|
|
254
271
|
(this.anyUnicodeModeOrNonAnnexB || this.char() === 125 /* CharacterCodes.closeBrace */)) {
|
|
255
|
-
this.error(
|
|
272
|
+
this.error(419 /* Diagnostics.Numbers_out_of_order_in_quantifier */, digitsStart, this.scanner.pos - digitsStart, noArgs);
|
|
256
273
|
}
|
|
257
274
|
}
|
|
258
275
|
else if (min === '') {
|
|
259
276
|
if (this.anyUnicodeModeOrNonAnnexB)
|
|
260
|
-
this.error(
|
|
277
|
+
this.error(421 /* Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash */, start, 1, [
|
|
261
278
|
String.fromCharCode(ch),
|
|
262
279
|
]);
|
|
263
280
|
isPreviousTermQuantifiable = true;
|
|
@@ -298,7 +315,7 @@ class RegularExpressionChecker {
|
|
|
298
315
|
if (ch === 41 /* CharacterCodes.closeParen */ && isInGroup)
|
|
299
316
|
return;
|
|
300
317
|
if (this.anyUnicodeModeOrNonAnnexB || ch === 41 /* CharacterCodes.closeParen */)
|
|
301
|
-
this.error(
|
|
318
|
+
this.error(421 /* Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash */, this.scanner.pos, 1, [
|
|
302
319
|
String.fromCharCode(ch),
|
|
303
320
|
]);
|
|
304
321
|
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
@@ -320,7 +337,7 @@ class RegularExpressionChecker {
|
|
|
320
337
|
if (this.char() === 63 /* CharacterCodes.question */)
|
|
321
338
|
this.scanner.pos = (this.scanner.pos + 1) | 0; // non-greedy
|
|
322
339
|
if (!isPreviousTermQuantifiable)
|
|
323
|
-
this.error(
|
|
340
|
+
this.error(420 /* Diagnostics.There_is_nothing_available_for_repetition */, start, this.scanner.pos - start, noArgs);
|
|
324
341
|
return false;
|
|
325
342
|
}
|
|
326
343
|
scanPatternModifiers(currentFlags) {
|
|
@@ -331,15 +348,14 @@ class RegularExpressionChecker {
|
|
|
331
348
|
const size = charSize(ch);
|
|
332
349
|
const flag = regularExpressionFlag(ch);
|
|
333
350
|
if (flag === 0 /* RegularExpressionFlags.None */)
|
|
334
|
-
this.error(
|
|
351
|
+
this.error(412 /* Diagnostics.Unknown_regular_expression_flag */, this.scanner.pos, size, noArgs);
|
|
335
352
|
else if ((currentFlags & flag) !== 0)
|
|
336
|
-
this.error(
|
|
353
|
+
this.error(413 /* Diagnostics.Duplicate_regular_expression_flag */, this.scanner.pos, size, noArgs);
|
|
337
354
|
else if ((flag & 28 /* RegularExpressionFlags.Modifiers */) === 0)
|
|
338
|
-
this.error(
|
|
339
|
-
|
|
355
|
+
this.error(422 /* Diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern */, this.scanner.pos, size, noArgs);
|
|
356
|
+
// Modifiers need ES2025, later than any flag they can toggle, and the group reports that.
|
|
357
|
+
else
|
|
340
358
|
currentFlags |= flag;
|
|
341
|
-
this.scanner.checkRegularExpressionFlagAvailability(flag, this.scanner.pos, size);
|
|
342
|
-
}
|
|
343
359
|
this.scanner.pos = (this.scanner.pos + size) | 0;
|
|
344
360
|
}
|
|
345
361
|
return currentFlags;
|
|
@@ -355,13 +371,13 @@ class RegularExpressionChecker {
|
|
|
355
371
|
this.scanExpectedChar(62 /* CharacterCodes.greaterThan */);
|
|
356
372
|
}
|
|
357
373
|
else if (this.anyUnicodeModeOrNonAnnexB || this.namedCaptureGroups) {
|
|
358
|
-
this.error(
|
|
374
|
+
this.error(423 /* Diagnostics.X_k_must_be_followed_by_a_capturing_group_name_enclosed_in_angle_brackets */, this.scanner.pos - 2, 2, noArgs);
|
|
359
375
|
}
|
|
360
376
|
return;
|
|
361
377
|
case 113 /* CharacterCodes.q */:
|
|
362
378
|
if (this.unicodeSetsMode) {
|
|
363
379
|
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
364
|
-
this.error(
|
|
380
|
+
this.error(424 /* Diagnostics.X_q_is_only_available_inside_character_class */, this.scanner.pos - 2, 2, noArgs);
|
|
365
381
|
return;
|
|
366
382
|
}
|
|
367
383
|
break;
|
|
@@ -385,7 +401,7 @@ class RegularExpressionChecker {
|
|
|
385
401
|
let ch = this.char();
|
|
386
402
|
switch (ch) {
|
|
387
403
|
case -1 /* CharacterCodes.EOF */:
|
|
388
|
-
this.error(
|
|
404
|
+
this.error(426 /* Diagnostics.Undetermined_character_escape */, this.scanner.pos - 1, 1, noArgs);
|
|
389
405
|
return 92 /* CharacterCodes.backslash */;
|
|
390
406
|
case 99 /* CharacterCodes.c */:
|
|
391
407
|
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
@@ -395,7 +411,7 @@ class RegularExpressionChecker {
|
|
|
395
411
|
return ch & 0x1f;
|
|
396
412
|
}
|
|
397
413
|
if (this.anyUnicodeModeOrNonAnnexB) {
|
|
398
|
-
this.error(
|
|
414
|
+
this.error(425 /* Diagnostics.X_c_must_be_followed_by_an_ASCII_letter */, this.scanner.pos - 2, 2, noArgs);
|
|
399
415
|
}
|
|
400
416
|
else if (atomEscape) {
|
|
401
417
|
this.scanner.pos = (this.scanner.pos - 1) | 0;
|
|
@@ -436,10 +452,9 @@ class RegularExpressionChecker {
|
|
|
436
452
|
scanGroupName(isReference) {
|
|
437
453
|
const scanner = this.scanner;
|
|
438
454
|
scanner.tokenStart = this.scanner.pos | 0;
|
|
439
|
-
scanner.scanIdentifier(0);
|
|
440
455
|
const start = scanner.tokenStart;
|
|
441
|
-
if (
|
|
442
|
-
this.error(
|
|
456
|
+
if (!scanner.scanIdentifier(0, 2 /* IdentifierVariant.RegExpGroupName */)) {
|
|
457
|
+
this.error(427 /* Diagnostics.Expected_a_capturing_group_name */, this.scanner.pos, 0, noArgs);
|
|
443
458
|
return;
|
|
444
459
|
}
|
|
445
460
|
const name = scanner.getTokenValue();
|
|
@@ -447,9 +462,16 @@ class RegularExpressionChecker {
|
|
|
447
462
|
this.groupNameReferences.push(new GroupNameReference(start, this.scanner.pos, name));
|
|
448
463
|
}
|
|
449
464
|
else if (this.namedCapturingGroupsContains(name)) {
|
|
450
|
-
this.error(
|
|
465
|
+
this.error(428 /* Diagnostics.Named_capturing_groups_with_the_same_name_must_be_mutually_exclusive_to_each_other */, start, this.scanner.pos - start, noArgs);
|
|
451
466
|
}
|
|
452
467
|
else {
|
|
468
|
+
// An earlier definition is in a mutually exclusive alternative. Below ES2018 the group is
|
|
469
|
+
// reported already.
|
|
470
|
+
const languageVersion = this.scanner.languageVersion();
|
|
471
|
+
if (this.groupSpecifiers.has(name) &&
|
|
472
|
+
languageVersion >= 5 /* ScriptTarget.ES2018 */ &&
|
|
473
|
+
languageVersion < 12 /* ScriptTarget.ES2025 */)
|
|
474
|
+
this.error(1898 /* Diagnostics.Duplicate_named_capturing_groups_are_only_available_when_targeting_0_or_later */, start, this.scanner.pos - start, ['es2025']);
|
|
453
475
|
if (this.namedCapturingGroups.length > 0)
|
|
454
476
|
this.namedCapturingGroups[this.namedCapturingGroups.length - 1].add(name);
|
|
455
477
|
this.groupSpecifiers.add(name);
|
|
@@ -480,15 +502,15 @@ class RegularExpressionChecker {
|
|
|
480
502
|
if (this.isClassContentExit(this.char()))
|
|
481
503
|
return false;
|
|
482
504
|
if (min === -1 /* ClassValue.None */ && this.anyUnicodeModeOrNonAnnexB)
|
|
483
|
-
this.error(
|
|
505
|
+
this.error(429 /* Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class */, minStart, this.scanner.pos - 1 - minStart, noArgs);
|
|
484
506
|
const maxStart = this.scanner.pos;
|
|
485
507
|
const max = this.scanClassAtom();
|
|
486
508
|
if (max === -1 /* ClassValue.None */ && this.anyUnicodeModeOrNonAnnexB) {
|
|
487
|
-
this.error(
|
|
509
|
+
this.error(429 /* Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class */, maxStart, this.scanner.pos - maxStart, noArgs);
|
|
488
510
|
continue;
|
|
489
511
|
}
|
|
490
512
|
if (min >= 0 && max >= 0 && min > max)
|
|
491
|
-
this.error(
|
|
513
|
+
this.error(430 /* Diagnostics.Range_out_of_order_in_character_class */, minStart, this.scanner.pos - minStart, noArgs);
|
|
492
514
|
}
|
|
493
515
|
return false;
|
|
494
516
|
}
|
|
@@ -513,7 +535,7 @@ class RegularExpressionChecker {
|
|
|
513
535
|
let start = this.scanner.pos;
|
|
514
536
|
let operand = -1 /* ClassValue.None */;
|
|
515
537
|
if (this.isDoublePunctuatorOperator()) {
|
|
516
|
-
this.error(
|
|
538
|
+
this.error(433 /* Diagnostics.Expected_a_class_set_operand */, this.scanner.pos, 0, noArgs);
|
|
517
539
|
this.mayContainStrings = false;
|
|
518
540
|
}
|
|
519
541
|
else {
|
|
@@ -523,7 +545,7 @@ class RegularExpressionChecker {
|
|
|
523
545
|
case 45 /* CharacterCodes.minus */:
|
|
524
546
|
if (this.scanner.pos + 1 < this.end && this.charAt(this.scanner.pos + 1) === 45 /* CharacterCodes.minus */) {
|
|
525
547
|
if (isCharacterComplement && this.mayContainStrings)
|
|
526
|
-
this.error(
|
|
548
|
+
this.error(431 /* Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class */, start, this.scanner.pos - start, noArgs);
|
|
527
549
|
expressionMayContainStrings = this.mayContainStrings;
|
|
528
550
|
this.scanClassSetSubExpression(3 /* ClassSetExpressionType.ClassSubtraction */);
|
|
529
551
|
this.mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
|
|
@@ -534,18 +556,15 @@ class RegularExpressionChecker {
|
|
|
534
556
|
if (this.scanner.pos + 1 < this.end && this.charAt(this.scanner.pos + 1) === 38 /* CharacterCodes.ampersand */) {
|
|
535
557
|
this.scanClassSetSubExpression(2 /* ClassSetExpressionType.ClassIntersection */);
|
|
536
558
|
if (isCharacterComplement && this.mayContainStrings)
|
|
537
|
-
this.error(
|
|
559
|
+
this.error(431 /* Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class */, start, this.scanner.pos - start, noArgs);
|
|
538
560
|
expressionMayContainStrings = this.mayContainStrings;
|
|
539
561
|
this.mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
|
|
540
562
|
return this.mayContainStrings;
|
|
541
563
|
}
|
|
542
|
-
this.error(423 /* Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash */, this.scanner.pos, 1, [
|
|
543
|
-
String.fromCharCode(ch),
|
|
544
|
-
]);
|
|
545
564
|
break;
|
|
546
565
|
default:
|
|
547
566
|
if (isCharacterComplement && this.mayContainStrings)
|
|
548
|
-
this.error(
|
|
567
|
+
this.error(431 /* Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class */, start, this.scanner.pos - start, noArgs);
|
|
549
568
|
expressionMayContainStrings = this.mayContainStrings;
|
|
550
569
|
break;
|
|
551
570
|
}
|
|
@@ -560,56 +579,54 @@ class RegularExpressionChecker {
|
|
|
560
579
|
}
|
|
561
580
|
if (ch === 45 /* CharacterCodes.minus */) {
|
|
562
581
|
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
563
|
-
this.error(
|
|
582
|
+
this.error(432 /* Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead */, this.scanner.pos - 2, 2, noArgs);
|
|
564
583
|
start = this.scanner.pos - 2;
|
|
565
584
|
operand = -2 /* ClassValue.String */;
|
|
566
585
|
continue;
|
|
567
586
|
}
|
|
568
587
|
if (operand === -1 /* ClassValue.None */)
|
|
569
|
-
this.error(
|
|
588
|
+
this.error(429 /* Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class */, start, this.scanner.pos - 1 - start, noArgs);
|
|
570
589
|
const secondStart = this.scanner.pos;
|
|
571
590
|
const secondOperand = this.scanClassSetOperand();
|
|
572
591
|
if (isCharacterComplement && this.mayContainStrings)
|
|
573
|
-
this.error(
|
|
592
|
+
this.error(431 /* Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class */, secondStart, this.scanner.pos - secondStart, noArgs);
|
|
574
593
|
expressionMayContainStrings = expressionMayContainStrings || this.mayContainStrings;
|
|
575
594
|
if (secondOperand === -1 /* ClassValue.None */) {
|
|
576
|
-
this.error(
|
|
595
|
+
this.error(429 /* Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class */, secondStart, this.scanner.pos - secondStart, noArgs);
|
|
577
596
|
}
|
|
578
597
|
else if (operand >= 0 && secondOperand >= 0 && operand > secondOperand) {
|
|
579
|
-
this.error(
|
|
598
|
+
this.error(430 /* Diagnostics.Range_out_of_order_in_character_class */, start, this.scanner.pos - start, noArgs);
|
|
580
599
|
}
|
|
581
600
|
}
|
|
582
|
-
else if (ch === 38 /* CharacterCodes.ampersand */
|
|
601
|
+
else if (ch === 38 /* CharacterCodes.ampersand */ &&
|
|
602
|
+
this.scanner.pos + 1 < this.end &&
|
|
603
|
+
this.charAt(this.scanner.pos + 1) === 38 /* CharacterCodes.ampersand */) {
|
|
583
604
|
start = this.scanner.pos;
|
|
584
|
-
this.scanner.pos = (this.scanner.pos +
|
|
605
|
+
this.scanner.pos = (this.scanner.pos + 2) | 0;
|
|
606
|
+
this.error(432 /* Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead */, this.scanner.pos - 2, 2, noArgs);
|
|
585
607
|
if (this.char() === 38 /* CharacterCodes.ampersand */) {
|
|
586
|
-
this.
|
|
587
|
-
this.error(434 /* Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead */, this.scanner.pos - 2, 2, noArgs);
|
|
588
|
-
if (this.char() === 38 /* CharacterCodes.ampersand */) {
|
|
589
|
-
this.error(423 /* Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash */, this.scanner.pos, 1, [
|
|
590
|
-
String.fromCharCode(ch),
|
|
591
|
-
]);
|
|
592
|
-
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
else {
|
|
596
|
-
this.error(423 /* Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash */, this.scanner.pos - 1, 1, [
|
|
608
|
+
this.error(421 /* Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash */, this.scanner.pos, 1, [
|
|
597
609
|
String.fromCharCode(ch),
|
|
598
610
|
]);
|
|
611
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
599
612
|
}
|
|
600
|
-
operand =
|
|
613
|
+
operand = -2 /* ClassValue.String */;
|
|
601
614
|
continue;
|
|
602
615
|
}
|
|
603
616
|
if (this.isClassContentExit(this.char()))
|
|
604
617
|
break;
|
|
605
618
|
start = this.scanner.pos;
|
|
606
619
|
if (this.isDoublePunctuatorOperator()) {
|
|
607
|
-
this.error(
|
|
620
|
+
this.error(432 /* Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead */, this.scanner.pos, 2, noArgs);
|
|
608
621
|
this.scanner.pos = (this.scanner.pos + 2) | 0;
|
|
609
622
|
operand = -2 /* ClassValue.String */;
|
|
610
623
|
}
|
|
611
624
|
else {
|
|
612
625
|
operand = this.scanClassSetOperand();
|
|
626
|
+
// Each operand of a negated union must match single characters.
|
|
627
|
+
if (isCharacterComplement && this.mayContainStrings)
|
|
628
|
+
this.error(431 /* Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class */, start, this.scanner.pos - start, noArgs);
|
|
629
|
+
expressionMayContainStrings = expressionMayContainStrings || this.mayContainStrings;
|
|
613
630
|
}
|
|
614
631
|
}
|
|
615
632
|
this.mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
|
|
@@ -634,10 +651,10 @@ class RegularExpressionChecker {
|
|
|
634
651
|
if (this.char() === 45 /* CharacterCodes.minus */) {
|
|
635
652
|
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
636
653
|
if (expressionType !== 3 /* ClassSetExpressionType.ClassSubtraction */)
|
|
637
|
-
this.error(
|
|
654
|
+
this.error(432 /* Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead */, this.scanner.pos - 2, 2, noArgs);
|
|
638
655
|
}
|
|
639
656
|
else {
|
|
640
|
-
this.error(
|
|
657
|
+
this.error(432 /* Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead */, this.scanner.pos - 1, 1, noArgs);
|
|
641
658
|
}
|
|
642
659
|
}
|
|
643
660
|
else if (ch === 38 /* CharacterCodes.ampersand */) {
|
|
@@ -645,16 +662,16 @@ class RegularExpressionChecker {
|
|
|
645
662
|
if (this.char() === 38 /* CharacterCodes.ampersand */) {
|
|
646
663
|
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
647
664
|
if (expressionType !== 2 /* ClassSetExpressionType.ClassIntersection */)
|
|
648
|
-
this.error(
|
|
665
|
+
this.error(432 /* Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead */, this.scanner.pos - 2, 2, noArgs);
|
|
649
666
|
if (this.char() === 38 /* CharacterCodes.ampersand */) {
|
|
650
|
-
this.error(
|
|
667
|
+
this.error(421 /* Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash */, this.scanner.pos, 1, [
|
|
651
668
|
String.fromCharCode(ch),
|
|
652
669
|
]);
|
|
653
670
|
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
654
671
|
}
|
|
655
672
|
}
|
|
656
673
|
else {
|
|
657
|
-
this.error(
|
|
674
|
+
this.error(421 /* Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash */, this.scanner.pos - 1, 1, [
|
|
658
675
|
String.fromCharCode(ch),
|
|
659
676
|
]);
|
|
660
677
|
}
|
|
@@ -667,7 +684,7 @@ class RegularExpressionChecker {
|
|
|
667
684
|
}
|
|
668
685
|
ch = this.char();
|
|
669
686
|
if (this.isClassContentExit(ch)) {
|
|
670
|
-
this.error(
|
|
687
|
+
this.error(433 /* Diagnostics.Expected_a_class_set_operand */, this.scanner.pos, 0, noArgs);
|
|
671
688
|
break;
|
|
672
689
|
}
|
|
673
690
|
this.scanClassSetOperand();
|
|
@@ -698,7 +715,7 @@ class RegularExpressionChecker {
|
|
|
698
715
|
this.scanExpectedChar(125 /* CharacterCodes.closeBrace */);
|
|
699
716
|
return -1 /* ClassValue.None */;
|
|
700
717
|
}
|
|
701
|
-
this.error(
|
|
718
|
+
this.error(434 /* Diagnostics.X_q_must_be_followed_by_string_alternatives_enclosed_in_braces */, this.scanner.pos - 2, 2, noArgs);
|
|
702
719
|
return 113 /* CharacterCodes.q */;
|
|
703
720
|
}
|
|
704
721
|
this.scanner.pos = (this.scanner.pos - 1) | 0;
|
|
@@ -778,7 +795,7 @@ class RegularExpressionChecker {
|
|
|
778
795
|
case 64 /* CharacterCodes.at */:
|
|
779
796
|
case 96 /* CharacterCodes.backtick */:
|
|
780
797
|
case 126 /* CharacterCodes.tilde */:
|
|
781
|
-
this.error(
|
|
798
|
+
this.error(435 /* Diagnostics.A_character_class_must_not_contain_a_reserved_double_punctuator_Did_you_mean_to_escape_it_with_backslash */, this.scanner.pos, 2, noArgs);
|
|
782
799
|
this.scanner.pos = (this.scanner.pos + 2) | 0;
|
|
783
800
|
return -2 /* ClassValue.String */;
|
|
784
801
|
}
|
|
@@ -793,7 +810,7 @@ class RegularExpressionChecker {
|
|
|
793
810
|
case 125 /* CharacterCodes.closeBrace */:
|
|
794
811
|
case 45 /* CharacterCodes.minus */:
|
|
795
812
|
case 124 /* CharacterCodes.bar */:
|
|
796
|
-
this.error(
|
|
813
|
+
this.error(421 /* Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash */, this.scanner.pos, 1, [
|
|
797
814
|
String.fromCharCode(ch),
|
|
798
815
|
]);
|
|
799
816
|
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
@@ -847,7 +864,7 @@ class RegularExpressionChecker {
|
|
|
847
864
|
this.scanner.pos = (this.scanner.pos - 1) | 0;
|
|
848
865
|
return false;
|
|
849
866
|
}
|
|
850
|
-
this.error(
|
|
867
|
+
this.error(444 /* Diagnostics.X_0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces */, this.scanner.pos - 2, 2, [String.fromCharCode(ch)]);
|
|
851
868
|
return true;
|
|
852
869
|
}
|
|
853
870
|
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
@@ -856,10 +873,10 @@ class RegularExpressionChecker {
|
|
|
856
873
|
if (this.char() === 61 /* CharacterCodes.equals */) {
|
|
857
874
|
const propertyName = nonBinaryUnicodeProperties.get(nameOrValue) ?? '';
|
|
858
875
|
if (this.scanner.pos === nameOrValueStart) {
|
|
859
|
-
this.error(
|
|
876
|
+
this.error(436 /* Diagnostics.Expected_a_Unicode_property_name */, this.scanner.pos, 0, noArgs);
|
|
860
877
|
}
|
|
861
878
|
else if (propertyName === '') {
|
|
862
|
-
this.error(
|
|
879
|
+
this.error(437 /* Diagnostics.Unknown_Unicode_property_name */, nameOrValueStart, this.scanner.pos - nameOrValueStart, noArgs);
|
|
863
880
|
const suggestion = getSpellingSuggestion(nameOrValue, mapKeys(nonBinaryUnicodeProperties));
|
|
864
881
|
if (suggestion !== '')
|
|
865
882
|
this.error(303 /* Diagnostics.Did_you_mean_0 */, nameOrValueStart, this.scanner.pos - nameOrValueStart, [suggestion]);
|
|
@@ -868,12 +885,12 @@ class RegularExpressionChecker {
|
|
|
868
885
|
const valueStart = this.scanner.pos;
|
|
869
886
|
const value = this.scanWordCharacters();
|
|
870
887
|
if (this.scanner.pos === valueStart) {
|
|
871
|
-
this.error(
|
|
888
|
+
this.error(438 /* Diagnostics.Expected_a_Unicode_property_value */, this.scanner.pos, 0, noArgs);
|
|
872
889
|
}
|
|
873
890
|
else if (propertyName !== '') {
|
|
874
891
|
const values = valuesOfNonBinaryUnicodeProperty(propertyName);
|
|
875
892
|
if (!values.has(value)) {
|
|
876
|
-
this.error(
|
|
893
|
+
this.error(439 /* Diagnostics.Unknown_Unicode_property_value */, valueStart, this.scanner.pos - valueStart, noArgs);
|
|
877
894
|
const suggestion = getSpellingSuggestion(value, setToArray(values));
|
|
878
895
|
if (suggestion !== '')
|
|
879
896
|
this.error(303 /* Diagnostics.Did_you_mean_0 */, valueStart, this.scanner.pos - valueStart, [suggestion]);
|
|
@@ -881,18 +898,18 @@ class RegularExpressionChecker {
|
|
|
881
898
|
}
|
|
882
899
|
}
|
|
883
900
|
else if (this.scanner.pos === nameOrValueStart) {
|
|
884
|
-
this.error(
|
|
901
|
+
this.error(440 /* Diagnostics.Expected_a_Unicode_property_name_or_value */, this.scanner.pos, 0, noArgs);
|
|
885
902
|
}
|
|
886
903
|
else if (binaryUnicodePropertiesOfStrings.has(nameOrValue)) {
|
|
887
904
|
if (!this.unicodeSetsMode)
|
|
888
|
-
this.error(
|
|
905
|
+
this.error(441 /* Diagnostics.Any_Unicode_property_that_would_possibly_match_more_than_a_single_character_is_only_available_when_the_Unicode_Sets_v_flag_is_set */, nameOrValueStart, this.scanner.pos - nameOrValueStart, noArgs);
|
|
889
906
|
else if (isCharacterComplement)
|
|
890
|
-
this.error(
|
|
907
|
+
this.error(431 /* Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class */, nameOrValueStart, this.scanner.pos - nameOrValueStart, noArgs);
|
|
891
908
|
else
|
|
892
909
|
this.mayContainStrings = true;
|
|
893
910
|
}
|
|
894
911
|
else if (!generalCategoryValues.has(nameOrValue) && !binaryUnicodeProperties.has(nameOrValue)) {
|
|
895
|
-
this.error(
|
|
912
|
+
this.error(442 /* Diagnostics.Unknown_Unicode_property_name_or_value */, nameOrValueStart, this.scanner.pos - nameOrValueStart, noArgs);
|
|
896
913
|
const candidates = setToArray(generalCategoryValues);
|
|
897
914
|
for (const name of binaryUnicodeProperties)
|
|
898
915
|
candidates.push(name);
|
|
@@ -904,7 +921,7 @@ class RegularExpressionChecker {
|
|
|
904
921
|
}
|
|
905
922
|
this.scanExpectedChar(125 /* CharacterCodes.closeBrace */);
|
|
906
923
|
if (!this.anyUnicodeMode)
|
|
907
|
-
this.error(
|
|
924
|
+
this.error(443 /* Diagnostics.Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set */, start, this.scanner.pos - start, noArgs);
|
|
908
925
|
return true;
|
|
909
926
|
}
|
|
910
927
|
scanWordCharacters() {
|
|
@@ -14,9 +14,8 @@ export declare const enum RelationComparisonResult {
|
|
|
14
14
|
ReportsUnmeasurable = 8,
|
|
15
15
|
ReportsUnreliable = 16,
|
|
16
16
|
ComplexityOverflow = 32,
|
|
17
|
-
StackDepthOverflow = 64,
|
|
18
17
|
ReportsMask = 24,
|
|
19
|
-
Overflow =
|
|
18
|
+
Overflow = 32
|
|
20
19
|
}
|
|
21
20
|
/**
|
|
22
21
|
* Cached results of one relation by numeric relation key (see getRelationKey): an open-addressing
|
|
@@ -30,7 +29,10 @@ export declare class Relation {
|
|
|
30
29
|
private results;
|
|
31
30
|
private count;
|
|
32
31
|
get(key: number): number;
|
|
33
|
-
|
|
32
|
+
/** Sets the result of `key`, and returns whether the key is new. */
|
|
33
|
+
set(key: number, result: number): boolean;
|
|
34
|
+
/** Removes `key`, moving later entries of its probe run back so lookups still find them. */
|
|
35
|
+
delete(key: number): void;
|
|
34
36
|
size(): number;
|
|
35
37
|
private grow;
|
|
36
38
|
}
|
|
@@ -138,6 +140,8 @@ export declare class Relater extends TypeComparer {
|
|
|
138
140
|
expandingFlags: ExpandingFlags;
|
|
139
141
|
overflow: boolean;
|
|
140
142
|
relationCount: number;
|
|
143
|
+
/** The keys this check added to the relation, while relating without reporting first. */
|
|
144
|
+
addedKeys: number[] | undefined;
|
|
141
145
|
/** The intersection state passed to `compare` during signature comparisons. */
|
|
142
146
|
signatureIntersectionState: IntersectionState;
|
|
143
147
|
varianceSetsCheckFailed: boolean;
|
|
@@ -165,6 +169,7 @@ export declare class Relater extends TypeComparer {
|
|
|
165
169
|
* comparing the pair, assumes related for deeply nested expansions, and overflows at depth 100.
|
|
166
170
|
*/
|
|
167
171
|
recursiveTypeRelatedTo(source: Type, target: Type, reportErrors: boolean, intersectionState: IntersectionState, recursionFlags: RecursionFlags): Ternary;
|
|
172
|
+
record(key: number, result: number): void;
|
|
168
173
|
resetMaybeStack(maybeStart: number, propagatingVarianceFlags: number, markAllAsSucceeded: boolean): void;
|
|
169
174
|
structuredTypeRelatedTo(source: Type, target: Type, reportErrors: boolean, intersectionState: IntersectionState): Ternary;
|
|
170
175
|
/**
|
|
@@ -236,11 +241,29 @@ export declare function setStackEntry(stack: Type[], depth: number, t: Type): vo
|
|
|
236
241
|
* last.
|
|
237
242
|
*/
|
|
238
243
|
export declare function isDeeplyNestedType(c: Checker, t: Type, stack: readonly Type[], depth: number, maxDepth: number): boolean;
|
|
244
|
+
/**
|
|
245
|
+
* isDeeplyNestedType for the newest entry of `stack[start..end)`, counting only the entries in that range.
|
|
246
|
+
* `identities` holds the recursion identity of each entry of the range once a check has computed it: 0 before
|
|
247
|
+
* that, and -1 for an entry whose recursion identity target is an intersection, which is matched by its
|
|
248
|
+
* constituents each time. Later checks compare the kept identities. The identities are computed when and in the
|
|
249
|
+
* order isDeeplyNestedType computes them, so the types and symbol ids they create come in the same order.
|
|
250
|
+
*/
|
|
251
|
+
export declare function isDeeplyNestedStackEntry(c: Checker, stack: readonly Type[], identities: RecursionId[], start: number, end: number, maxDepth: number): boolean;
|
|
239
252
|
/** An identity shared by instantiations of a type, so infinitely expanding instantiations can be detected. */
|
|
240
|
-
export declare function getRecursionIdentity(t: Type): RecursionId;
|
|
253
|
+
export declare function getRecursionIdentity(c: Checker, t: Type): RecursionId;
|
|
241
254
|
export declare function isMarkerType(c: Checker, t: Type): boolean;
|
|
242
255
|
export declare function getVariances(c: Checker, t: Type): VarianceFlags[];
|
|
243
256
|
export declare function getAliasVariances(c: Checker, symbol: Symbol): VarianceFlags[];
|
|
257
|
+
/**
|
|
258
|
+
* The measured variance of each type parameter, from relating marker instantiations; empty when
|
|
259
|
+
* requested recursively.
|
|
260
|
+
*/
|
|
261
|
+
/** A generic type whose variances are being computed. */
|
|
262
|
+
export declare class VarianceStackEntry {
|
|
263
|
+
readonly symbol: Symbol;
|
|
264
|
+
readonly typeParameters: readonly Type[];
|
|
265
|
+
constructor(symbol: Symbol, typeParameters: readonly Type[]);
|
|
266
|
+
}
|
|
244
267
|
export declare function createMarkerType(c: Checker, symbol: Symbol, source: Type, target: Type): Type;
|
|
245
268
|
export declare function getTypeParameterModifiers(tp: Type): ModifierFlags;
|
|
246
269
|
export declare function isEmptyArrayLiteralType(c: Checker, t: Type): boolean;
|