tsc-ts 0.0.10 → 0.1.1
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 +29 -18
- package/dist/api/compiler/ast.js +1040 -1007
- 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 +136 -91
- package/dist/api/compiler/checker-contextual.d.ts +20 -0
- package/dist/api/compiler/checker-contextual.js +175 -62
- 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 +258 -212
- 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 +107 -89
- 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 +190 -46
- 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 +97 -31
- package/dist/api/compiler/checker.js +149 -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 +24 -4
- package/dist/api/compiler/compile-program.js +53 -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/expr-record.d.ts +11 -0
- package/dist/api/compiler/expr-record.js +53 -0
- 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/identifier-name.d.ts +9 -0
- package/dist/api/compiler/identifier-name.js +10 -0
- package/dist/api/compiler/instantiation.d.ts +7 -0
- package/dist/api/compiler/instantiation.js +101 -49
- package/dist/api/compiler/jsdoc.js +27 -25
- 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 +42 -20
- package/dist/api/compiler/parser.js +318 -224
- 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 +6 -3
- 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 +306 -283
- 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 +64 -59
- package/dist/api/compiler/scanner.d.ts +27 -2
- package/dist/api/compiler/scanner.js +181 -150
- package/dist/api/compiler/shared-results.d.ts +696 -0
- package/dist/api/compiler/shared-results.js +2905 -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 +307 -239
- 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 +74 -38
- package/src/compiler/binder.ts +39 -4
- package/src/compiler/cgroup.ts +157 -0
- package/src/compiler/character-codes.ts +2 -2
- package/src/compiler/checker-calls.ts +76 -8
- package/src/compiler/checker-classes.ts +80 -25
- package/src/compiler/checker-contextual.ts +110 -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 +95 -47
- 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 +28 -5
- 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 +173 -35
- 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 +175 -41
- package/src/compiler/command-line.ts +28 -28
- package/src/compiler/compile-program.ts +59 -25
- package/src/compiler/decoder.ts +15 -5
- package/src/compiler/diagnostic-messages.ts +1973 -1892
- package/src/compiler/doctor-report.ts +133 -0
- package/src/compiler/emitter.ts +57 -8
- package/src/compiler/encoder.ts +23 -8
- package/src/compiler/expr-record.ts +59 -0
- 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/identifier-name.ts +13 -0
- 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 +7 -3
- 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 +543 -147
- package/src/compiler/parallel-emit.ts +4 -4
- package/src/compiler/parser.ts +166 -47
- 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 +7 -3
- package/src/compiler/printer/helpers.ts +10 -1
- package/src/compiler/printer/name-generator.ts +24 -2
- package/src/compiler/printer/printer.ts +39 -16
- 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 +14 -5
- package/src/compiler/run-config.ts +1383 -0
- package/src/compiler/run-record-read.ts +87 -0
- package/src/compiler/run-records.ts +575 -0
- package/src/compiler/scanner.ts +166 -120
- package/src/compiler/shared-results.ts +3144 -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 +22 -3
- 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 +136 -49
- 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 +67 -6
- package/src/compiler/tsc-cli.ts +35 -4
- package/src/compiler/tsc-compile.ts +220 -10
- package/src/compiler/tsc-watch.ts +97 -47
- 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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// entity names and the checker's name resolver.
|
|
3
3
|
import { sideOf, signatureSideOf } from './side-state.js';
|
|
4
4
|
import { isTypeAssignableToKindEx } from './checker-type-operators.js';
|
|
5
|
-
import { BinaryExpression, getExpression, getInitializer, getMembers as getMemberNodes, getName, getSymbol, getText, getIsTypeOnly, getProperties, getType, getLocals, } from './ast.js';
|
|
5
|
+
import { BinaryExpression, PatternAmbientModule, getExpression, getInitializer, getMembers as getMemberNodes, getName, getSymbol, getText, getIsTypeOnly, getProperties, getType, getLocals, } from './ast.js';
|
|
6
6
|
import { isAmbientModule, isGlobalScopeAugmentation, nodeIsMissing } from './ast-utilities.js';
|
|
7
7
|
import { CodePoints, distanceToCandidate, utf8Length } from './spelling.js';
|
|
8
8
|
import { setValueDeclaration } from './binder.js';
|
|
@@ -16,12 +16,13 @@ import { getDeclaredTypeOfSymbol } from './checker-declared-types.js';
|
|
|
16
16
|
import { symbolToString } from './type-printer.js';
|
|
17
17
|
import { getTypeOfSymbol } from './checker-symbol-types.js';
|
|
18
18
|
import { getPropertyOfType } from './checker-members.js';
|
|
19
|
-
import { checkComputedPropertyName, checkExpressionCached, entityNameToString } from './checker-expressions.js';
|
|
19
|
+
import { checkComputedPropertyName, checkExpressionCached, entityNameToString, isConstTypeReference, } from './checker-expressions.js';
|
|
20
20
|
import { getLateBindableNameOfDeclaration, getPropertyNameFromType, isTypeUsableAsPropertyName, hasLateBindableName, hasLateBindableIndexSignature, } from './checker-utilities.js';
|
|
21
|
-
import { checkTypeOnlyAliasUse, markAliasDeclarationOfNameIfTypeOnly, getExportsOfModuleWorker, getTargetOfAliasDeclaration, getTypeOnlyAliasDeclaration, isTypeOnlyImportOrExportDeclaration, resolveExternalModuleNameWorker, resolveExternalModuleSymbol, resolveIndirectionAlias, } from './checker-modules.js';
|
|
21
|
+
import { checkTypeOnlyAliasUse, markAliasDeclarationOfNameIfTypeOnly, getExportsOfModuleWorker, getTargetOfAliasDeclaration, getTypeOfModuleImportAttributes, getTypeOnlyAliasDeclaration, isTypeOnlyImportOrExportDeclaration, resolveExternalModuleNameWorker, resolveExternalModuleSymbol, resolveIndirectionAlias, } from './checker-modules.js';
|
|
22
22
|
import { isJSAliasDeclaration } from './checker-javascript.js';
|
|
23
|
+
import { isTypeIdenticalTo } from './relations.js';
|
|
23
24
|
import { getFeatureMap } from './checker-features.js';
|
|
24
|
-
import { addDeclaration, declarationAt, declarationCount, getDeclarations, getSymbolId, setDeclarations, Symbol, } from './symbol.js';
|
|
25
|
+
import { addDeclaration, declarationAt, declarationCount, getDeclarations, getSymbolId, setDeclarations, Symbol, tryGetAmbientModuleNameFromSymbolName, } from './symbol.js';
|
|
25
26
|
// ---- Name resolution
|
|
26
27
|
/** The binder's name resolver with the checker's merging, alias handling and errors. */
|
|
27
28
|
export class CheckerNameResolver extends NameResolver {
|
|
@@ -67,8 +68,8 @@ export class CheckerNameResolver extends NameResolver {
|
|
|
67
68
|
const typeNode = getType(declaration);
|
|
68
69
|
const inType = typeNode !== undefined && typeNode.pos <= location.pos && location.pos <= typeNode.end;
|
|
69
70
|
c.error(location, inType
|
|
70
|
-
?
|
|
71
|
-
:
|
|
71
|
+
? 972 /* Diagnostics.Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor */
|
|
72
|
+
: 486 /* Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor */, declarationNameToString(getSourceFileOfNode(declaration), getName(declaration)), name);
|
|
72
73
|
return true;
|
|
73
74
|
}
|
|
74
75
|
onFailedToResolveSymbol(location, name, meaning, message) {
|
|
@@ -77,7 +78,7 @@ export class CheckerNameResolver extends NameResolver {
|
|
|
77
78
|
onSuccessfullyResolvedSymbol(location, result, meaning, lastLocation, associatedDeclarationForContainingInitializerOrBindingName, withinDeferredContext) {
|
|
78
79
|
const c = this.checker;
|
|
79
80
|
const isInExternalModule = lastLocation !== undefined &&
|
|
80
|
-
lastLocation.kind ===
|
|
81
|
+
lastLocation.kind === 308 /* SyntaxKind.SourceFile */ &&
|
|
81
82
|
isExternalOrCommonJSModule(lastLocation);
|
|
82
83
|
// Only names in value positions check block-scoped declaration order: a symbol may be both a
|
|
83
84
|
// block-scoped variable and a namespace, as in `const foo: foo.bar`.
|
|
@@ -93,9 +94,9 @@ export class CheckerNameResolver extends NameResolver {
|
|
|
93
94
|
(location.flags & 4194304 /* NodeFlags.JSDoc */) === 0) {
|
|
94
95
|
const merged = getMergedSymbol(c, result);
|
|
95
96
|
if (declarationCount(merged) !== 0 &&
|
|
96
|
-
getDeclarations(merged).every((d) => d.kind ===
|
|
97
|
-
(d.kind ===
|
|
98
|
-
c.addErrorOrSuggestion(c.compilerOptions.allowUmdGlobalAccess !== true, createDiagnosticForNode(location,
|
|
97
|
+
getDeclarations(merged).every((d) => d.kind === 272 /* SyntaxKind.NamespaceExportDeclaration */ ||
|
|
98
|
+
(d.kind === 308 /* SyntaxKind.SourceFile */ && d.globalExports !== undefined)))
|
|
99
|
+
c.addErrorOrSuggestion(c.compilerOptions.allowUmdGlobalAccess !== true, createDiagnosticForNode(location, 826 /* Diagnostics.X_0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead */, [result.name]));
|
|
99
100
|
}
|
|
100
101
|
// A parameter initializer or binding name can't reference its own parameter or the ones after it.
|
|
101
102
|
const associated = associatedDeclarationForContainingInitializerOrBindingName;
|
|
@@ -107,12 +108,12 @@ export class CheckerNameResolver extends NameResolver {
|
|
|
107
108
|
const root = getRootDeclaration(associated);
|
|
108
109
|
const file = getSourceFileOfNode(associated);
|
|
109
110
|
if (candidate === getSymbolOfDeclaration(c, associated))
|
|
110
|
-
c.error(location,
|
|
111
|
+
c.error(location, 553 /* Diagnostics.Parameter_0_cannot_reference_itself */, declarationNameToString(file, getName(associated)));
|
|
111
112
|
else if (candidate.valueDeclaration !== undefined &&
|
|
112
113
|
candidate.valueDeclaration.pos > associated.pos &&
|
|
113
114
|
getLocals(root.parent) !== undefined &&
|
|
114
115
|
getSymbolOfMeaning(c, getLocals(root.parent), candidate.name, meaning) === candidate)
|
|
115
|
-
c.error(location,
|
|
116
|
+
c.error(location, 554 /* Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it */, declarationNameToString(file, getName(associated)), declarationNameToString(file, location));
|
|
116
117
|
}
|
|
117
118
|
if (location !== undefined && (meaning & 111551 /* SymbolFlags.Value */) !== 0)
|
|
118
119
|
checkTypeOnlyAliasUse(this.checker, location, result, result.name);
|
|
@@ -125,12 +126,12 @@ export class CheckerNameResolver extends NameResolver {
|
|
|
125
126
|
const locals = isGlobal ? getLocals(lastLocation) : undefined;
|
|
126
127
|
const nonValueSymbol = locals !== undefined ? getSymbolOfMeaning(c, locals, name, ~111551 /* SymbolFlags.Value */) : undefined;
|
|
127
128
|
if (nonValueSymbol !== undefined) {
|
|
128
|
-
const importDeclaration = getDeclarations(nonValueSymbol).find((d) => d.kind ===
|
|
129
|
-
d.kind ===
|
|
130
|
-
d.kind ===
|
|
131
|
-
d.kind ===
|
|
129
|
+
const importDeclaration = getDeclarations(nonValueSymbol).find((d) => d.kind === 278 /* SyntaxKind.ImportSpecifier */ ||
|
|
130
|
+
d.kind === 275 /* SyntaxKind.ImportClause */ ||
|
|
131
|
+
d.kind === 276 /* SyntaxKind.NamespaceImport */ ||
|
|
132
|
+
d.kind === 273 /* SyntaxKind.ImportEqualsDeclaration */);
|
|
132
133
|
if (importDeclaration !== undefined && !isTypeOnlyImportOrExportDeclaration(importDeclaration))
|
|
133
|
-
c.error(importDeclaration,
|
|
134
|
+
c.error(importDeclaration, 993 /* Diagnostics.Import_0_conflicts_with_global_value_used_in_this_file_so_must_be_declared_with_a_type_only_import_when_isolatedModules_is_enabled */, name);
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
137
|
}
|
|
@@ -169,10 +170,21 @@ function isES2015OrLaterConstructorName(name) {
|
|
|
169
170
|
name === 'Set' ||
|
|
170
171
|
name === 'WeakSet');
|
|
171
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* The name-not-found message of an identifier resolved from its own location, chosen only once the name
|
|
175
|
+
* isn't found (`onFailedToResolveSymbol`). Choosing it up front, as tsgo does, compares every resolved
|
|
176
|
+
* identifier's text with the list of names `getCannotFindNameDiagnosticForName` has messages for.
|
|
177
|
+
*/
|
|
178
|
+
export const cannotFindNameAtLocation = -1;
|
|
172
179
|
function onFailedToResolveSymbol(c, location, name, meaning, message) {
|
|
180
|
+
if (message === cannotFindNameAtLocation)
|
|
181
|
+
message = getCannotFindNameDiagnosticForName(c, location);
|
|
173
182
|
let declarationName = name;
|
|
174
183
|
if (location !== undefined) {
|
|
175
|
-
|
|
184
|
+
// The `const` of a `const` assertion is not a name.
|
|
185
|
+
if (isConstTypeReferenceName(location))
|
|
186
|
+
return;
|
|
187
|
+
if (location.parent !== undefined && location.parent.kind === 320 /* SyntaxKind.JSDocLink */)
|
|
176
188
|
return;
|
|
177
189
|
if (checkAndReportErrorForMissingPrefix(c, location, name) ||
|
|
178
190
|
checkAndReportErrorForExtendingInterface(c, location) ||
|
|
@@ -198,10 +210,10 @@ function onFailedToResolveSymbol(c, location, name, meaning, message) {
|
|
|
198
210
|
isGlobalScopeAugmentation(suggestion.valueDeclaration))) {
|
|
199
211
|
const suggestionName = symbolToString(c, suggestion);
|
|
200
212
|
const diagnostic = createDiagnosticForNode(location, meaning === 1920 /* SymbolFlags.Namespace */
|
|
201
|
-
?
|
|
202
|
-
:
|
|
213
|
+
? 962 /* Diagnostics.Cannot_find_namespace_0_Did_you_mean_1 */
|
|
214
|
+
: 714 /* Diagnostics.Cannot_find_name_0_Did_you_mean_1 */, [declarationName, suggestionName]);
|
|
203
215
|
if (suggestion.valueDeclaration !== undefined)
|
|
204
|
-
diagnostic.addRelatedInfo(createDiagnosticForNode(suggestion.valueDeclaration,
|
|
216
|
+
diagnostic.addRelatedInfo(createDiagnosticForNode(suggestion.valueDeclaration, 867 /* Diagnostics.X_0_is_declared_here */, [suggestionName]));
|
|
205
217
|
c.addDiagnostic(diagnostic);
|
|
206
218
|
return;
|
|
207
219
|
}
|
|
@@ -221,13 +233,13 @@ function checkAndReportErrorForMissingPrefix(c, location, name) {
|
|
|
221
233
|
if (classSymbol === undefined)
|
|
222
234
|
break;
|
|
223
235
|
if (getPropertyOfType(c, getTypeOfSymbol(c, classSymbol), name) !== undefined) {
|
|
224
|
-
c.error(location,
|
|
236
|
+
c.error(location, 803 /* Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0 */, name, symbolToString(c, classSymbol));
|
|
225
237
|
return true;
|
|
226
238
|
}
|
|
227
239
|
if (current === container && !isStatic(current)) {
|
|
228
240
|
const thisType = getDeclaredTypeOfSymbol(c, classSymbol).thisType;
|
|
229
241
|
if (thisType !== undefined && getPropertyOfType(c, thisType, name) !== undefined) {
|
|
230
|
-
c.error(location,
|
|
242
|
+
c.error(location, 804 /* Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0 */, name);
|
|
231
243
|
return true;
|
|
232
244
|
}
|
|
233
245
|
}
|
|
@@ -236,15 +248,15 @@ function checkAndReportErrorForMissingPrefix(c, location, name) {
|
|
|
236
248
|
}
|
|
237
249
|
function isTypeReferenceIdentifier(node) {
|
|
238
250
|
let current = node;
|
|
239
|
-
while (current.parent !== undefined && current.parent.kind ===
|
|
251
|
+
while (current.parent !== undefined && current.parent.kind === 168 /* SyntaxKind.QualifiedName */)
|
|
240
252
|
current = current.parent;
|
|
241
|
-
return current.parent !== undefined && current.parent.kind ===
|
|
253
|
+
return current.parent !== undefined && current.parent.kind === 185 /* SyntaxKind.TypeReference */;
|
|
242
254
|
}
|
|
243
255
|
function checkAndReportErrorForExtendingInterface(c, location) {
|
|
244
256
|
const expression = getEntityNameForExtendingInterface(location);
|
|
245
257
|
if (expression !== undefined &&
|
|
246
258
|
resolveEntityName(c, expression, 64 /* SymbolFlags.Interface */, true, false, undefined) !== undefined) {
|
|
247
|
-
c.error(location,
|
|
259
|
+
c.error(location, 829 /* Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements */, getSourceTextOfNode(getSourceFileOfNode(expression), expression));
|
|
248
260
|
return true;
|
|
249
261
|
}
|
|
250
262
|
return false;
|
|
@@ -252,9 +264,12 @@ function checkAndReportErrorForExtendingInterface(c, location) {
|
|
|
252
264
|
function getEntityNameForExtendingInterface(node) {
|
|
253
265
|
switch (node.kind) {
|
|
254
266
|
case 79 /* SyntaxKind.Identifier */:
|
|
255
|
-
case
|
|
267
|
+
case 168 /* SyntaxKind.QualifiedName */:
|
|
268
|
+
case 213 /* SyntaxKind.PropertyAccessExpression */:
|
|
256
269
|
return node.parent !== undefined ? getEntityNameForExtendingInterface(node.parent) : undefined;
|
|
257
|
-
case
|
|
270
|
+
case 185 /* SyntaxKind.TypeReference */:
|
|
271
|
+
return node.typeName;
|
|
272
|
+
case 235 /* SyntaxKind.ExpressionWithTypeArguments */: {
|
|
258
273
|
const expression = getExpression(node);
|
|
259
274
|
return isEntityNameExpression(expression, false) ? expression : undefined;
|
|
260
275
|
}
|
|
@@ -364,37 +379,59 @@ function checkAndReportErrorForUsingTypeAsNamespace(c, location, name, meaning)
|
|
|
364
379
|
if (symbol === undefined)
|
|
365
380
|
return false;
|
|
366
381
|
const parent = location.parent;
|
|
367
|
-
if (parent !== undefined && parent.kind ===
|
|
368
|
-
const propName = parent.right
|
|
382
|
+
if (parent !== undefined && parent.kind === 168 /* SyntaxKind.QualifiedName */) {
|
|
383
|
+
const propName = getText(parent.right);
|
|
369
384
|
if (getPropertyOfType(c, getDeclaredTypeOfSymbol(c, symbol), propName) !== undefined) {
|
|
370
|
-
c.error(parent,
|
|
385
|
+
c.error(parent, 852 /* Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1 */, name, propName);
|
|
371
386
|
return true;
|
|
372
387
|
}
|
|
373
388
|
}
|
|
374
|
-
c.error(location,
|
|
389
|
+
c.error(location, 841 /* Diagnostics.X_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here */, name);
|
|
375
390
|
return true;
|
|
376
391
|
}
|
|
377
392
|
function checkAndReportErrorForExportingPrimitiveType(c, location, name) {
|
|
378
393
|
if (isPrimitiveTypeName(name) &&
|
|
379
394
|
location.parent !== undefined &&
|
|
380
|
-
location.parent.kind ===
|
|
381
|
-
c.error(location,
|
|
395
|
+
location.parent.kind === 283 /* SyntaxKind.ExportSpecifier */) {
|
|
396
|
+
c.error(location, 802 /* Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module */, name);
|
|
382
397
|
return true;
|
|
383
398
|
}
|
|
384
399
|
return false;
|
|
385
400
|
}
|
|
401
|
+
/** Whether `node` is the `const` of a `const` assertion (`x as const`, `<const>x`). */
|
|
402
|
+
function isConstTypeReferenceName(node) {
|
|
403
|
+
const parent = node.parent;
|
|
404
|
+
return (node.kind === 79 /* SyntaxKind.Identifier */ &&
|
|
405
|
+
parent !== undefined &&
|
|
406
|
+
isConstTypeReference(parent) &&
|
|
407
|
+
parent.parent !== undefined &&
|
|
408
|
+
(parent.parent.kind === 236 /* SyntaxKind.AsExpression */ || parent.parent.kind === 218 /* SyntaxKind.TypeAssertionExpression */));
|
|
409
|
+
}
|
|
410
|
+
/** Whether `node` is the expression of an `export =` or `export default`, or the leftmost name of it. */
|
|
411
|
+
function isExportAssignmentExpressionName(node) {
|
|
412
|
+
let current = node;
|
|
413
|
+
while (current.parent !== undefined &&
|
|
414
|
+
(current.parent.kind === 213 /* SyntaxKind.PropertyAccessExpression */ || current.parent.kind === 168 /* SyntaxKind.QualifiedName */))
|
|
415
|
+
current = current.parent;
|
|
416
|
+
const parent = current.parent;
|
|
417
|
+
return (parent !== undefined &&
|
|
418
|
+
parent.kind === 279 /* SyntaxKind.ExportAssignment */ &&
|
|
419
|
+
parent.expression === current);
|
|
420
|
+
}
|
|
386
421
|
function checkAndReportErrorForUsingNamespaceAsTypeOrValue(c, location, name, meaning) {
|
|
387
422
|
if ((meaning & (111551 /* SymbolFlags.Value */ & ~788968 /* SymbolFlags.Type */)) !== 0) {
|
|
388
423
|
const symbol = resolveSymbol(c, resolveName(c, location, name, 1024 /* SymbolFlags.NamespaceModule */, undefined, false, false));
|
|
389
424
|
if (symbol !== undefined) {
|
|
390
|
-
|
|
425
|
+
// checkExportAssignment decides whether `export = ns` is an error.
|
|
426
|
+
if (!isExportAssignmentExpressionName(location))
|
|
427
|
+
c.error(location, 847 /* Diagnostics.Cannot_use_namespace_0_as_a_value */, name);
|
|
391
428
|
return true;
|
|
392
429
|
}
|
|
393
430
|
}
|
|
394
431
|
else if ((meaning & (788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */)) !== 0) {
|
|
395
432
|
const symbol = resolveSymbol(c, resolveName(c, location, name, 1536 /* SymbolFlags.Module */, undefined, false, false));
|
|
396
433
|
if (symbol !== undefined) {
|
|
397
|
-
c.error(location,
|
|
434
|
+
c.error(location, 848 /* Diagnostics.Cannot_use_namespace_0_as_a_type */, name);
|
|
398
435
|
return true;
|
|
399
436
|
}
|
|
400
437
|
}
|
|
@@ -407,29 +444,32 @@ function checkAndReportErrorForUsingTypeAsValue(c, location, name, meaning) {
|
|
|
407
444
|
const grandparent = location.parent?.parent;
|
|
408
445
|
if (grandparent !== undefined &&
|
|
409
446
|
grandparent.parent !== undefined &&
|
|
410
|
-
grandparent.kind ===
|
|
447
|
+
grandparent.kind === 300 /* SyntaxKind.HeritageClause */) {
|
|
411
448
|
const heritageKind = grandparent.token;
|
|
412
449
|
const containerKind = grandparent.parent.kind;
|
|
413
|
-
const isClass = containerKind ===
|
|
414
|
-
if (containerKind ===
|
|
415
|
-
c.error(location,
|
|
450
|
+
const isClass = containerKind === 265 /* SyntaxKind.ClassDeclaration */ || containerKind === 233 /* SyntaxKind.ClassExpression */;
|
|
451
|
+
if (containerKind === 266 /* SyntaxKind.InterfaceDeclaration */ && heritageKind === 95 /* SyntaxKind.ExtendsKeyword */)
|
|
452
|
+
c.error(location, 969 /* Diagnostics.An_interface_cannot_extend_a_primitive_type_like_0_It_can_only_extend_other_named_object_types */, name);
|
|
416
453
|
else if (isClass && heritageKind === 95 /* SyntaxKind.ExtendsKeyword */)
|
|
417
|
-
c.error(location,
|
|
454
|
+
c.error(location, 990 /* Diagnostics.A_class_cannot_extend_a_primitive_type_like_0_Classes_can_only_extend_constructable_values */, name);
|
|
418
455
|
else if (isClass && heritageKind === 118 /* SyntaxKind.ImplementsKeyword */)
|
|
419
|
-
c.error(location,
|
|
456
|
+
c.error(location, 991 /* Diagnostics.A_class_cannot_implement_a_primitive_type_like_0_It_can_only_implement_other_named_object_types */, name);
|
|
420
457
|
}
|
|
421
458
|
else
|
|
422
|
-
c.error(location,
|
|
459
|
+
c.error(location, 832 /* Diagnostics.X_0_only_refers_to_a_type_but_is_being_used_as_a_value_here */, name);
|
|
423
460
|
return true;
|
|
424
461
|
}
|
|
425
462
|
const symbol = resolveSymbol(c, resolveName(c, location, name, 788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */, undefined, false, false));
|
|
426
463
|
if (symbol !== undefined && (getSymbolFlags(c, symbol) & 111551 /* SymbolFlags.Value */) === 0) {
|
|
464
|
+
// checkExportAssignment decides whether `export = T` of a type is an error.
|
|
465
|
+
if (isExportAssignmentExpressionName(location))
|
|
466
|
+
return true;
|
|
427
467
|
if (isES2015OrLaterConstructorName(name))
|
|
428
|
-
c.error(location,
|
|
468
|
+
c.error(location, 742 /* Diagnostics.X_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later */, name);
|
|
429
469
|
else if (maybeMappedType(c, location, symbol))
|
|
430
|
-
c.error(location,
|
|
470
|
+
c.error(location, 830 /* Diagnostics.X_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Did_you_mean_to_use_1_in_0 */, name, name === 'K' ? 'P' : 'K');
|
|
431
471
|
else
|
|
432
|
-
c.error(location,
|
|
472
|
+
c.error(location, 832 /* Diagnostics.X_0_only_refers_to_a_type_but_is_being_used_as_a_value_here */, name);
|
|
433
473
|
return true;
|
|
434
474
|
}
|
|
435
475
|
return false;
|
|
@@ -437,9 +477,9 @@ function checkAndReportErrorForUsingTypeAsValue(c, location, name, meaning) {
|
|
|
437
477
|
function maybeMappedType(c, node, symbol) {
|
|
438
478
|
let container = node.parent;
|
|
439
479
|
while (container !== undefined &&
|
|
440
|
-
(container.kind ===
|
|
480
|
+
(container.kind === 169 /* SyntaxKind.ComputedPropertyName */ || container.kind === 173 /* SyntaxKind.PropertySignature */))
|
|
441
481
|
container = container.parent;
|
|
442
|
-
if (container === undefined || container.kind !==
|
|
482
|
+
if (container === undefined || container.kind !== 189 /* SyntaxKind.TypeLiteral */)
|
|
443
483
|
return false;
|
|
444
484
|
const members = getMemberNodes(container);
|
|
445
485
|
if (members === undefined || members.nodes.length !== 1)
|
|
@@ -457,7 +497,7 @@ function checkAndReportErrorForUsingValueAsType(c, location, name, meaning) {
|
|
|
457
497
|
return false;
|
|
458
498
|
const symbol = resolveSymbol(c, resolveName(c, location, name, ~788968 /* SymbolFlags.Type */ & 111551 /* SymbolFlags.Value */, undefined, false, false));
|
|
459
499
|
if (symbol !== undefined && (symbol.flags & 1920 /* SymbolFlags.Namespace */) === 0) {
|
|
460
|
-
c.error(location,
|
|
500
|
+
c.error(location, 888 /* Diagnostics.X_0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0 */, name);
|
|
461
501
|
return true;
|
|
462
502
|
}
|
|
463
503
|
return false;
|
|
@@ -470,7 +510,7 @@ function mergeFileGlobals(c, file) {
|
|
|
470
510
|
const fileGlobalThis = locals.get('globalThis');
|
|
471
511
|
if (fileGlobalThis !== undefined)
|
|
472
512
|
for (const d of getDeclarations(fileGlobalThis))
|
|
473
|
-
c.addDiagnostic(createDiagnosticForNode(d,
|
|
513
|
+
c.addDiagnostic(createDiagnosticForNode(d, 575 /* Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0 */, [
|
|
474
514
|
'globalThis',
|
|
475
515
|
]));
|
|
476
516
|
for (const symbol of locals.values()) {
|
|
@@ -575,6 +615,7 @@ export class MergedGlobals {
|
|
|
575
615
|
ambientModuleSymbols;
|
|
576
616
|
patternAmbientModules;
|
|
577
617
|
patternAmbientModuleAugmentations;
|
|
618
|
+
patternAmbientModuleAugmentationTargets;
|
|
578
619
|
/** Whether the global `undefined` is the checker's own (no declaration of `undefined` merged). */
|
|
579
620
|
ownUndefined;
|
|
580
621
|
/** Ids of the symbols merged into each shared symbol. */
|
|
@@ -594,6 +635,7 @@ export class MergedGlobals {
|
|
|
594
635
|
this.ambientModuleSymbols = c.ambientModuleSymbols.slice();
|
|
595
636
|
this.patternAmbientModules = c.patternAmbientModules.slice();
|
|
596
637
|
this.patternAmbientModuleAugmentations = new Map(c.patternAmbientModuleAugmentations);
|
|
638
|
+
this.patternAmbientModuleAugmentationTargets = new Map(c.patternAmbientModuleAugmentationTargets);
|
|
597
639
|
for (const [id, target] of this.mergedSymbols) {
|
|
598
640
|
let ids = this.sources.get(target);
|
|
599
641
|
if (ids === undefined) {
|
|
@@ -711,6 +753,8 @@ export function initializeGlobals(c) {
|
|
|
711
753
|
c.patternAmbientModules.push(pattern);
|
|
712
754
|
for (const [name, symbol] of merged.patternAmbientModuleAugmentations)
|
|
713
755
|
c.patternAmbientModuleAugmentations.set(name, symbol);
|
|
756
|
+
for (const [name, symbol] of merged.patternAmbientModuleAugmentationTargets)
|
|
757
|
+
c.patternAmbientModuleAugmentationTargets.set(name, symbol);
|
|
714
758
|
addMergeDiagnostics(c, merged, 0);
|
|
715
759
|
if (merged.ownUndefined)
|
|
716
760
|
setGlobal(c, 'undefined', c.undefinedSymbol);
|
|
@@ -746,7 +790,7 @@ export function initializeGlobals(c) {
|
|
|
746
790
|
if (target !== undefined) {
|
|
747
791
|
for (const declaration of getDeclarations(target))
|
|
748
792
|
if (!isTypeDeclaration(declaration))
|
|
749
|
-
c.addDiagnostic(createDiagnosticForNode(declaration,
|
|
793
|
+
c.addDiagnostic(createDiagnosticForNode(declaration, 575 /* Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0 */, ['undefined']));
|
|
750
794
|
}
|
|
751
795
|
else
|
|
752
796
|
setGlobal(c, 'undefined', c.undefinedSymbol);
|
|
@@ -759,27 +803,28 @@ export function mergeAmbientModulesAndAugmentations(c) {
|
|
|
759
803
|
}
|
|
760
804
|
for (const symbol of c.ambientModuleSymbols)
|
|
761
805
|
mergeGlobalSymbol(c, symbol);
|
|
806
|
+
mergePatternAmbientModules(c);
|
|
762
807
|
for (const file of c.files)
|
|
763
808
|
for (const augmentation of file.moduleAugmentations)
|
|
764
809
|
if (augmentation.parent !== undefined && !isGlobalScopeAugmentation(augmentation.parent))
|
|
765
810
|
mergeModuleAugmentation(c, augmentation);
|
|
766
811
|
}
|
|
767
812
|
export function isAmbientModuleSymbolName(name) {
|
|
768
|
-
return
|
|
813
|
+
return tryGetAmbientModuleNameFromSymbolName(name) !== undefined;
|
|
769
814
|
}
|
|
770
815
|
function isTypeDeclaration(node) {
|
|
771
816
|
switch (node.kind) {
|
|
772
|
-
case
|
|
773
|
-
case
|
|
774
|
-
case
|
|
775
|
-
case
|
|
776
|
-
case
|
|
777
|
-
case
|
|
817
|
+
case 170 /* SyntaxKind.TypeParameter */:
|
|
818
|
+
case 265 /* SyntaxKind.ClassDeclaration */:
|
|
819
|
+
case 266 /* SyntaxKind.InterfaceDeclaration */:
|
|
820
|
+
case 267 /* SyntaxKind.TypeAliasDeclaration */:
|
|
821
|
+
case 346 /* SyntaxKind.JSTypeAliasDeclaration */:
|
|
822
|
+
case 268 /* SyntaxKind.EnumDeclaration */:
|
|
778
823
|
return true;
|
|
779
|
-
case
|
|
824
|
+
case 275 /* SyntaxKind.ImportClause */:
|
|
780
825
|
return getIsTypeOnly(node);
|
|
781
|
-
case
|
|
782
|
-
case
|
|
826
|
+
case 278 /* SyntaxKind.ImportSpecifier */:
|
|
827
|
+
case 283 /* SyntaxKind.ExportSpecifier */:
|
|
783
828
|
return getIsTypeOnly(node);
|
|
784
829
|
}
|
|
785
830
|
return false;
|
|
@@ -788,6 +833,43 @@ function mergeGlobalSymbol(c, symbol) {
|
|
|
788
833
|
const globalSymbol = c.globals.get(symbol.name);
|
|
789
834
|
setGlobal(c, symbol.name, globalSymbol !== undefined ? mergeSymbol(c, globalSymbol, symbol, false) : getMergedSymbol(c, symbol));
|
|
790
835
|
}
|
|
836
|
+
/** Merges the pattern ambient modules with the same pattern and identical import attributes types. */
|
|
837
|
+
function mergePatternAmbientModules(c) {
|
|
838
|
+
const modules = c.patternAmbientModules;
|
|
839
|
+
if (modules.length === 0)
|
|
840
|
+
return;
|
|
841
|
+
const groupsByPattern = new Map();
|
|
842
|
+
const grouped = [];
|
|
843
|
+
for (const module of modules) {
|
|
844
|
+
const attributesType = getTypeOfModuleImportAttributes(c, module.symbol);
|
|
845
|
+
let groups = groupsByPattern.get(module.text);
|
|
846
|
+
let groupIndex = -1;
|
|
847
|
+
if (groups !== undefined)
|
|
848
|
+
for (const index of groups)
|
|
849
|
+
if (isTypeIdenticalTo(c, attributesType, getTypeOfModuleImportAttributes(c, grouped[index].symbol))) {
|
|
850
|
+
groupIndex = index;
|
|
851
|
+
break;
|
|
852
|
+
}
|
|
853
|
+
if (groupIndex === -1) {
|
|
854
|
+
if (groups === undefined) {
|
|
855
|
+
groups = [];
|
|
856
|
+
groupsByPattern.set(module.text, groups);
|
|
857
|
+
}
|
|
858
|
+
groups.push(grouped.length);
|
|
859
|
+
grouped.push(new PatternAmbientModule(module.text, module.starIndex, module.symbol));
|
|
860
|
+
}
|
|
861
|
+
else {
|
|
862
|
+
const group = grouped[groupIndex];
|
|
863
|
+
grouped[groupIndex] = new PatternAmbientModule(group.text, group.starIndex, mergeSymbol(c, group.symbol, module.symbol, false));
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
for (const module of modules)
|
|
867
|
+
if (c.globals.has(module.symbol.name))
|
|
868
|
+
setGlobal(c, module.symbol.name, getMergedSymbol(c, module.symbol));
|
|
869
|
+
modules.length = 0;
|
|
870
|
+
for (const module of grouped)
|
|
871
|
+
modules.push(module);
|
|
872
|
+
}
|
|
791
873
|
function mergeModuleAugmentation(c, moduleName) {
|
|
792
874
|
const moduleNode = moduleName.parent;
|
|
793
875
|
const augmentationSymbol = moduleNode.symbol;
|
|
@@ -800,17 +882,20 @@ function mergeModuleAugmentation(c, moduleName) {
|
|
|
800
882
|
return;
|
|
801
883
|
}
|
|
802
884
|
const moduleNotFoundError = (moduleNode.parent.flags & 8388608 /* NodeFlags.Ambient */) === 0
|
|
803
|
-
?
|
|
885
|
+
? 805 /* Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found */
|
|
804
886
|
: undefined;
|
|
805
|
-
|
|
887
|
+
// Module augmentations can't have import attributes.
|
|
888
|
+
let mainModule = resolveExternalModuleNameWorker(c, moduleName, moduleName, moduleNotFoundError, false, true, undefined);
|
|
806
889
|
if (mainModule === undefined)
|
|
807
890
|
return;
|
|
808
891
|
mainModule = resolveExternalModuleSymbol(c, mainModule, false);
|
|
809
892
|
if ((mainModule.flags & 1920 /* SymbolFlags.Namespace */) !== 0) {
|
|
810
893
|
for (const pattern of c.patternAmbientModules)
|
|
811
|
-
if (pattern.symbol === mainModule) {
|
|
894
|
+
if (getMergedSymbol(c, pattern.symbol) === mainModule) {
|
|
895
|
+
// Merging the pattern into the augmentation keeps the pattern's own exports unchanged.
|
|
812
896
|
const merged = mergeSymbol(c, augmentationSymbol, mainModule, true);
|
|
813
897
|
c.patternAmbientModuleAugmentations.set(getText(moduleName), merged);
|
|
898
|
+
c.patternAmbientModuleAugmentationTargets.set(getText(moduleName), mainModule);
|
|
814
899
|
return;
|
|
815
900
|
}
|
|
816
901
|
// Exports the module gets through `export *` live on the re-exported symbols; merge into those.
|
|
@@ -830,7 +915,7 @@ function mergeModuleAugmentation(c, moduleName) {
|
|
|
830
915
|
mergeSymbol(c, mainModule, augmentationSymbol, false);
|
|
831
916
|
}
|
|
832
917
|
else
|
|
833
|
-
c.error(moduleName,
|
|
918
|
+
c.error(moduleName, 812 /* Diagnostics.Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity */, getText(moduleName));
|
|
834
919
|
}
|
|
835
920
|
export function mergeSymbolTable(c, target, source, unidirectional, mergedParent) {
|
|
836
921
|
for (const [id, sourceSymbol] of source) {
|
|
@@ -896,7 +981,7 @@ export function mergeSymbol(c, target, source, unidirectional) {
|
|
|
896
981
|
else if ((target.flags & 1024 /* SymbolFlags.NamespaceModule */) !== 0) {
|
|
897
982
|
// `var globalThis` already reports a conflict with the built-in.
|
|
898
983
|
if (target !== c.globalThisSymbol)
|
|
899
|
-
c.error(getNameOfDeclaration(source.declaration),
|
|
984
|
+
c.error(getNameOfDeclaration(source.declaration), 790 /* Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity */, symbolToString(c, target));
|
|
900
985
|
}
|
|
901
986
|
else
|
|
902
987
|
reportMergeSymbolError(c, target, source);
|
|
@@ -906,10 +991,10 @@ function reportMergeSymbolError(c, target, source) {
|
|
|
906
991
|
const isEitherEnum = ((target.flags | source.flags) & 384 /* SymbolFlags.Enum */) !== 0;
|
|
907
992
|
const isEitherBlockScoped = ((target.flags | source.flags) & 2 /* SymbolFlags.BlockScopedVariable */) !== 0;
|
|
908
993
|
const message = isEitherEnum
|
|
909
|
-
?
|
|
994
|
+
? 728 /* Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations */
|
|
910
995
|
: isEitherBlockScoped
|
|
911
|
-
?
|
|
912
|
-
:
|
|
996
|
+
? 626 /* Diagnostics.Cannot_redeclare_block_scoped_variable_0 */
|
|
997
|
+
: 485 /* Diagnostics.Duplicate_identifier_0 */;
|
|
913
998
|
const name = symbolToString(c, source);
|
|
914
999
|
if (!isPlainJSFile(source))
|
|
915
1000
|
addDuplicateDeclarationErrors(c, source, message, name, target);
|
|
@@ -933,8 +1018,8 @@ export function addDuplicateDeclarationError(c, node, message, name, relatedNode
|
|
|
933
1018
|
const adjusted = getNameOfDeclaration(relatedNode) ?? relatedNode;
|
|
934
1019
|
if (adjusted === errorNode)
|
|
935
1020
|
continue;
|
|
936
|
-
const leading = createDiagnosticForNode(adjusted,
|
|
937
|
-
const followOn = createDiagnosticForNode(adjusted,
|
|
1021
|
+
const leading = createDiagnosticForNode(adjusted, 1367 /* Diagnostics.X_0_was_also_declared_here */, [name]);
|
|
1022
|
+
const followOn = createDiagnosticForNode(adjusted, 1368 /* Diagnostics.X_and_here */, []);
|
|
938
1023
|
const related = error.relatedInformation;
|
|
939
1024
|
if (related.length >= 5 || hasMatchingDiagnostic(related, leading, followOn))
|
|
940
1025
|
continue;
|
|
@@ -948,12 +1033,7 @@ function hasMatchingDiagnostic(diagnostics, a, b) {
|
|
|
948
1033
|
return false;
|
|
949
1034
|
}
|
|
950
1035
|
function lookupOrIssueError(c, location, message, args) {
|
|
951
|
-
|
|
952
|
-
const existing = c.diagnostics.lookup(diagnostic);
|
|
953
|
-
if (existing !== undefined)
|
|
954
|
-
return existing;
|
|
955
|
-
c.addDiagnostic(diagnostic);
|
|
956
|
-
return diagnostic;
|
|
1036
|
+
return c.addDiagnostic(createDiagnosticForNode(location, message, args));
|
|
957
1037
|
}
|
|
958
1038
|
export function getExcludedSymbolFlags(flags) {
|
|
959
1039
|
let result = 0;
|
|
@@ -1098,10 +1178,10 @@ export function getGlobalSymbol(c, name, meaning, diagnostic) {
|
|
|
1098
1178
|
function getGlobalTypeDeclaration(symbol) {
|
|
1099
1179
|
for (const d of getDeclarations(symbol)) {
|
|
1100
1180
|
switch (d.kind) {
|
|
1101
|
-
case
|
|
1102
|
-
case
|
|
1103
|
-
case
|
|
1104
|
-
case
|
|
1181
|
+
case 265 /* SyntaxKind.ClassDeclaration */:
|
|
1182
|
+
case 266 /* SyntaxKind.InterfaceDeclaration */:
|
|
1183
|
+
case 268 /* SyntaxKind.EnumDeclaration */:
|
|
1184
|
+
case 267 /* SyntaxKind.TypeAliasDeclaration */:
|
|
1105
1185
|
return d;
|
|
1106
1186
|
}
|
|
1107
1187
|
}
|
|
@@ -1109,17 +1189,17 @@ function getGlobalTypeDeclaration(symbol) {
|
|
|
1109
1189
|
}
|
|
1110
1190
|
/** The global class or interface `name` with `arity` type parameters, or the empty (generic) object type. */
|
|
1111
1191
|
export function getGlobalType(c, name, arity, reportErrors) {
|
|
1112
|
-
const symbol = getGlobalSymbol(c, name, 788968 /* SymbolFlags.Type */, reportErrors ?
|
|
1192
|
+
const symbol = getGlobalSymbol(c, name, 788968 /* SymbolFlags.Type */, reportErrors ? 503 /* Diagnostics.Cannot_find_global_type_0 */ : undefined);
|
|
1113
1193
|
if (symbol !== undefined) {
|
|
1114
1194
|
if ((symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) !== 0) {
|
|
1115
1195
|
const type = getDeclaredTypeOfSymbol(c, symbol);
|
|
1116
1196
|
if (type.typeParameterCount() === arity)
|
|
1117
1197
|
return type;
|
|
1118
1198
|
if (reportErrors)
|
|
1119
|
-
c.error(getGlobalTypeDeclaration(symbol),
|
|
1199
|
+
c.error(getGlobalTypeDeclaration(symbol), 502 /* Diagnostics.Global_type_0_must_have_1_type_parameter_s */, symbol.name, String(arity));
|
|
1120
1200
|
}
|
|
1121
1201
|
else if (reportErrors)
|
|
1122
|
-
c.error(getGlobalTypeDeclaration(symbol),
|
|
1202
|
+
c.error(getGlobalTypeDeclaration(symbol), 501 /* Diagnostics.Global_type_0_must_be_a_class_or_interface_type */, symbol.name);
|
|
1123
1203
|
}
|
|
1124
1204
|
return arity !== 0 ? c.emptyGenericType : c.emptyObjectType;
|
|
1125
1205
|
}
|
|
@@ -1144,13 +1224,13 @@ export function getGlobalTypeAliasSymbol(c, name, arity, reportErrors) {
|
|
|
1144
1224
|
const cached = c.globalSymbolCache.get(key);
|
|
1145
1225
|
if (cached !== undefined)
|
|
1146
1226
|
return cached === null ? undefined : cached;
|
|
1147
|
-
let symbol = getGlobalSymbol(c, name, 524288 /* SymbolFlags.TypeAlias */, reportErrors ?
|
|
1227
|
+
let symbol = getGlobalSymbol(c, name, 524288 /* SymbolFlags.TypeAlias */, reportErrors ? 503 /* Diagnostics.Cannot_find_global_type_0 */ : undefined);
|
|
1148
1228
|
if (symbol !== undefined) {
|
|
1149
1229
|
getDeclaredTypeOfSymbol(c, symbol);
|
|
1150
1230
|
const typeParameters = c.symbolLinks(symbol).typeParameters;
|
|
1151
1231
|
if ((typeParameters === undefined ? 0 : typeParameters.length) !== arity) {
|
|
1152
1232
|
if (reportErrors) {
|
|
1153
|
-
c.error(getDeclarationOfKind(symbol,
|
|
1233
|
+
c.error(getDeclarationOfKind(symbol, 267 /* SyntaxKind.TypeAliasDeclaration */), 502 /* Diagnostics.Global_type_0_must_have_1_type_parameter_s */, symbol.name, String(arity));
|
|
1154
1234
|
}
|
|
1155
1235
|
symbol = undefined;
|
|
1156
1236
|
}
|
|
@@ -1163,7 +1243,7 @@ export function getGlobalValueSymbol(c, name, reportErrors) {
|
|
|
1163
1243
|
const cached = c.globalSymbolCache.get(key);
|
|
1164
1244
|
if (cached !== undefined)
|
|
1165
1245
|
return cached === null ? undefined : cached;
|
|
1166
|
-
const symbol = getGlobalSymbol(c, name, 111551 /* SymbolFlags.Value */, reportErrors ?
|
|
1246
|
+
const symbol = getGlobalSymbol(c, name, 111551 /* SymbolFlags.Value */, reportErrors ? 641 /* Diagnostics.Cannot_find_global_value_0 */ : undefined);
|
|
1167
1247
|
c.globalSymbolCache.set(key, symbol === undefined ? null : symbol);
|
|
1168
1248
|
return symbol;
|
|
1169
1249
|
}
|
|
@@ -1197,22 +1277,22 @@ export function getDeclarationOfAliasSymbol(symbol) {
|
|
|
1197
1277
|
}
|
|
1198
1278
|
export function isAliasSymbolDeclaration(node) {
|
|
1199
1279
|
switch (node.kind) {
|
|
1200
|
-
case
|
|
1201
|
-
case
|
|
1202
|
-
case
|
|
1203
|
-
case
|
|
1204
|
-
case
|
|
1205
|
-
case
|
|
1280
|
+
case 273 /* SyntaxKind.ImportEqualsDeclaration */:
|
|
1281
|
+
case 272 /* SyntaxKind.NamespaceExportDeclaration */:
|
|
1282
|
+
case 276 /* SyntaxKind.NamespaceImport */:
|
|
1283
|
+
case 282 /* SyntaxKind.NamespaceExport */:
|
|
1284
|
+
case 278 /* SyntaxKind.ImportSpecifier */:
|
|
1285
|
+
case 283 /* SyntaxKind.ExportSpecifier */:
|
|
1206
1286
|
return true;
|
|
1207
|
-
case
|
|
1287
|
+
case 275 /* SyntaxKind.ImportClause */:
|
|
1208
1288
|
return getName(node) !== undefined;
|
|
1209
|
-
case
|
|
1289
|
+
case 279 /* SyntaxKind.ExportAssignment */: {
|
|
1210
1290
|
const e = getExpression(node);
|
|
1211
1291
|
return e !== undefined && isEntityNameExpressionNode(e);
|
|
1212
1292
|
}
|
|
1213
|
-
case
|
|
1214
|
-
case
|
|
1215
|
-
case
|
|
1293
|
+
case 262 /* SyntaxKind.VariableDeclaration */:
|
|
1294
|
+
case 210 /* SyntaxKind.BindingElement */:
|
|
1295
|
+
case 228 /* SyntaxKind.BinaryExpression */:
|
|
1216
1296
|
return isJSAliasDeclaration(node);
|
|
1217
1297
|
}
|
|
1218
1298
|
return false;
|
|
@@ -1220,7 +1300,7 @@ export function isAliasSymbolDeclaration(node) {
|
|
|
1220
1300
|
function isEntityNameExpressionNode(node) {
|
|
1221
1301
|
if (node.kind === 79 /* SyntaxKind.Identifier */)
|
|
1222
1302
|
return true;
|
|
1223
|
-
if (node.kind ===
|
|
1303
|
+
if (node.kind === 213 /* SyntaxKind.PropertyAccessExpression */) {
|
|
1224
1304
|
const e = getExpression(node);
|
|
1225
1305
|
const name = getName(node);
|
|
1226
1306
|
return name !== undefined && name.kind === 79 /* SyntaxKind.Identifier */ && isEntityNameExpressionNode(e);
|
|
@@ -1249,7 +1329,7 @@ export function resolveAlias(c, symbol) {
|
|
|
1249
1329
|
target = resolved ?? c.unknownSymbol;
|
|
1250
1330
|
links.aliasTarget = target;
|
|
1251
1331
|
if (!popTypeResolution(c)) {
|
|
1252
|
-
c.error(node,
|
|
1332
|
+
c.error(node, 488 /* Diagnostics.Circular_definition_of_import_alias_0 */, symbolToString(c, symbol));
|
|
1253
1333
|
links.aliasTarget = c.unknownSymbol;
|
|
1254
1334
|
}
|
|
1255
1335
|
return links.aliasTarget;
|
|
@@ -1361,12 +1441,12 @@ function getResolvedMembersOrExports(c, symbol, isStatic) {
|
|
|
1361
1441
|
}
|
|
1362
1442
|
function getMembersOfDeclaration(decl) {
|
|
1363
1443
|
switch (decl.kind) {
|
|
1364
|
-
case
|
|
1365
|
-
case
|
|
1366
|
-
case
|
|
1367
|
-
case
|
|
1444
|
+
case 265 /* SyntaxKind.ClassDeclaration */:
|
|
1445
|
+
case 233 /* SyntaxKind.ClassExpression */:
|
|
1446
|
+
case 266 /* SyntaxKind.InterfaceDeclaration */:
|
|
1447
|
+
case 189 /* SyntaxKind.TypeLiteral */:
|
|
1368
1448
|
return getMemberNodes(decl)?.nodes;
|
|
1369
|
-
case
|
|
1449
|
+
case 212 /* SyntaxKind.ObjectLiteralExpression */:
|
|
1370
1450
|
return getProperties(decl).nodes;
|
|
1371
1451
|
}
|
|
1372
1452
|
return undefined;
|
|
@@ -1389,7 +1469,7 @@ function lateBindMember(c, parent, early, late, decl) {
|
|
|
1389
1469
|
// A recursive request falls back to the early-bound symbol.
|
|
1390
1470
|
c.resolvedSymbols.set(decl.id, getSymbol(decl));
|
|
1391
1471
|
const declName = getLateBindableNameOfDeclaration(decl);
|
|
1392
|
-
const type = declName.kind ===
|
|
1472
|
+
const type = declName.kind === 214 /* SyntaxKind.ElementAccessExpression */
|
|
1393
1473
|
? checkExpressionCached(c, declName.argumentExpression)
|
|
1394
1474
|
: checkComputedPropertyName(c, declName);
|
|
1395
1475
|
if (isTypeUsableAsPropertyName(type)) {
|
|
@@ -1397,7 +1477,7 @@ function lateBindMember(c, parent, early, late, decl) {
|
|
|
1397
1477
|
const symbolFlags = getSymbol(decl).flags;
|
|
1398
1478
|
let lateSymbol = late.get(memberName);
|
|
1399
1479
|
if (lateSymbol === undefined) {
|
|
1400
|
-
lateSymbol = c.newSymbolWithCheckFlags(0 /* SymbolFlags.None */, memberName,
|
|
1480
|
+
lateSymbol = c.newSymbolWithCheckFlags(0 /* SymbolFlags.None */, memberName, 32768 /* CheckFlags.Late */);
|
|
1401
1481
|
late.set(memberName, lateSymbol);
|
|
1402
1482
|
}
|
|
1403
1483
|
const earlySymbol = early.get(memberName);
|
|
@@ -1407,9 +1487,9 @@ function lateBindMember(c, parent, early, late, decl) {
|
|
|
1407
1487
|
: getDeclarations(lateSymbol);
|
|
1408
1488
|
const name = (type.flags & 16384) !== 0 ? declarationNameToString(getSourceFileOfNode(declName), declName) : memberName;
|
|
1409
1489
|
for (const d of declarations)
|
|
1410
|
-
c.error(getNameOfDeclaration(d) ?? d,
|
|
1411
|
-
c.error(declName,
|
|
1412
|
-
lateSymbol = c.newSymbolWithCheckFlags(0 /* SymbolFlags.None */, memberName,
|
|
1490
|
+
c.error(getNameOfDeclaration(d) ?? d, 485 /* Diagnostics.Duplicate_identifier_0 */, name);
|
|
1491
|
+
c.error(declName, 485 /* Diagnostics.Duplicate_identifier_0 */, name);
|
|
1492
|
+
lateSymbol = c.newSymbolWithCheckFlags(0 /* SymbolFlags.None */, memberName, 32768 /* CheckFlags.Late */);
|
|
1413
1493
|
}
|
|
1414
1494
|
c.symbolNameTypes.set(getSymbolId(lateSymbol), type);
|
|
1415
1495
|
addDeclarationToLateBoundSymbol(c, lateSymbol, decl, symbolFlags);
|
|
@@ -1425,10 +1505,10 @@ function lateBindIndexSignature(c, early, late, decl) {
|
|
|
1425
1505
|
if (indexSymbol === undefined) {
|
|
1426
1506
|
const earlyIndex = early.get("\uFFFEindex" /* InternalSymbolName.Index */);
|
|
1427
1507
|
if (earlyIndex === undefined)
|
|
1428
|
-
indexSymbol = c.newSymbolWithCheckFlags(0 /* SymbolFlags.None */, "\uFFFEindex" /* InternalSymbolName.Index */,
|
|
1508
|
+
indexSymbol = c.newSymbolWithCheckFlags(0 /* SymbolFlags.None */, "\uFFFEindex" /* InternalSymbolName.Index */, 32768 /* CheckFlags.Late */);
|
|
1429
1509
|
else {
|
|
1430
1510
|
indexSymbol = cloneSymbol(c, earlyIndex);
|
|
1431
|
-
indexSymbol.checkFlags |=
|
|
1511
|
+
indexSymbol.checkFlags |= 32768 /* CheckFlags.Late */;
|
|
1432
1512
|
}
|
|
1433
1513
|
late.set("\uFFFEindex" /* InternalSymbolName.Index */, indexSymbol);
|
|
1434
1514
|
}
|
|
@@ -1486,6 +1566,39 @@ export function getNamedMembers(c, members, container) {
|
|
|
1486
1566
|
sortSymbols(c, rest);
|
|
1487
1567
|
return contained.length === 0 ? rest : contained.concat(rest);
|
|
1488
1568
|
}
|
|
1569
|
+
/**
|
|
1570
|
+
* `getNamedMembers(c, table, container)` for a table that holds `members` in this order under their names, as
|
|
1571
|
+
* positions in `members`; undefined where a member is an alias (`symbolIsValue` then resolves it) or a name repeats.
|
|
1572
|
+
*/
|
|
1573
|
+
export function getNamedMemberPositions(c, members, container) {
|
|
1574
|
+
const isClassOrInterface = container !== undefined && (container.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) !== 0;
|
|
1575
|
+
const names = new Set();
|
|
1576
|
+
const contained = [];
|
|
1577
|
+
const rest = [];
|
|
1578
|
+
for (let i = 0; i < members.length; i++) {
|
|
1579
|
+
const symbol = members[i];
|
|
1580
|
+
if ((symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0 || names.has(symbol.name))
|
|
1581
|
+
return undefined;
|
|
1582
|
+
names.add(symbol.name);
|
|
1583
|
+
if (isReservedMemberName(symbol.name) || !symbolIsValue(c, symbol))
|
|
1584
|
+
continue;
|
|
1585
|
+
if (isClassOrInterface && isDeclarationContainedBy(symbol, container))
|
|
1586
|
+
contained.push(i);
|
|
1587
|
+
else
|
|
1588
|
+
rest.push(i);
|
|
1589
|
+
}
|
|
1590
|
+
sortPositions(c, members, contained);
|
|
1591
|
+
sortPositions(c, members, rest);
|
|
1592
|
+
return contained.length === 0 ? rest : contained.concat(rest);
|
|
1593
|
+
}
|
|
1594
|
+
/** `sortSymbols` for positions in `members`. */
|
|
1595
|
+
function sortPositions(c, members, positions) {
|
|
1596
|
+
for (let i = 1; i < positions.length; i++)
|
|
1597
|
+
if (compareSymbols(c, members[positions[i - 1]], members[positions[i]]) > 0) {
|
|
1598
|
+
positions.sort((a, b) => compareSymbols(c, members[a], members[b]));
|
|
1599
|
+
return;
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1489
1602
|
/** Sorts symbols by declaration order; members are usually in that order already. */
|
|
1490
1603
|
function sortSymbols(c, symbols) {
|
|
1491
1604
|
for (let i = 1; i < symbols.length; i++)
|
|
@@ -1498,9 +1611,9 @@ function sortSymbols(c, symbols) {
|
|
|
1498
1611
|
export function getFirstIdentifier(node) {
|
|
1499
1612
|
let current = node;
|
|
1500
1613
|
for (;;) {
|
|
1501
|
-
if (current.kind ===
|
|
1614
|
+
if (current.kind === 168 /* SyntaxKind.QualifiedName */)
|
|
1502
1615
|
current = current.left;
|
|
1503
|
-
else if (current.kind ===
|
|
1616
|
+
else if (current.kind === 213 /* SyntaxKind.PropertyAccessExpression */)
|
|
1504
1617
|
current = getExpression(current);
|
|
1505
1618
|
else
|
|
1506
1619
|
return current;
|
|
@@ -1514,8 +1627,10 @@ export function resolveEntityName(c, name, meaning, ignoreErrors, dontResolveAli
|
|
|
1514
1627
|
const message = ignoreErrors
|
|
1515
1628
|
? undefined
|
|
1516
1629
|
: meaning === 1920 /* SymbolFlags.Namespace */ || (name.flags & 16 /* NodeFlags.Synthesized */) !== 0
|
|
1517
|
-
?
|
|
1518
|
-
:
|
|
1630
|
+
? 670 /* Diagnostics.Cannot_find_namespace_0 */
|
|
1631
|
+
: location === undefined
|
|
1632
|
+
? cannotFindNameAtLocation
|
|
1633
|
+
: getCannotFindNameDiagnosticForName(c, getFirstIdentifier(name));
|
|
1519
1634
|
const resolveLocation = location ?? name;
|
|
1520
1635
|
const text = getText(name);
|
|
1521
1636
|
if (meaning === 1920 /* SymbolFlags.Namespace */) {
|
|
@@ -1536,20 +1651,20 @@ export function resolveEntityName(c, name, meaning, ignoreErrors, dontResolveAli
|
|
|
1536
1651
|
symbol = found !== undefined ? getMergedSymbol(c, found) : undefined;
|
|
1537
1652
|
}
|
|
1538
1653
|
}
|
|
1539
|
-
else if (name.kind ===
|
|
1654
|
+
else if (name.kind === 168 /* SyntaxKind.QualifiedName */) {
|
|
1540
1655
|
const qualified = name;
|
|
1541
1656
|
symbol = resolveQualifiedName(c, name, qualified.left, qualified.right, meaning, ignoreErrors, location);
|
|
1542
1657
|
}
|
|
1543
|
-
else if (name.kind ===
|
|
1658
|
+
else if (name.kind === 213 /* SyntaxKind.PropertyAccessExpression */) {
|
|
1544
1659
|
symbol = resolveQualifiedName(c, name, getExpression(name), getName(name), meaning, ignoreErrors, location);
|
|
1545
1660
|
}
|
|
1546
1661
|
else
|
|
1547
1662
|
return undefined;
|
|
1548
1663
|
if (symbol !== undefined && symbol !== c.unknownSymbol) {
|
|
1549
1664
|
if ((name.flags & 16 /* NodeFlags.Synthesized */) === 0 &&
|
|
1550
|
-
name.kind !==
|
|
1665
|
+
name.kind !== 213 /* SyntaxKind.PropertyAccessExpression */ &&
|
|
1551
1666
|
((symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0 ||
|
|
1552
|
-
(name.parent !== undefined && name.parent.kind ===
|
|
1667
|
+
(name.parent !== undefined && name.parent.kind === 279 /* SyntaxKind.ExportAssignment */)))
|
|
1553
1668
|
markAliasDeclarationOfNameIfTypeOnly(c, name);
|
|
1554
1669
|
// Resolve along the alias chain to the symbol with the meaning.
|
|
1555
1670
|
while ((symbol.flags & meaning) === 0 && !dontResolveAlias && (symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0)
|
|
@@ -1576,13 +1691,13 @@ function resolveQualifiedName(c, name, left, right, meaning, ignoreErrors, locat
|
|
|
1576
1691
|
const declarationName = declarationNameToString(getSourceFileOfNode(right), right);
|
|
1577
1692
|
const suggestion = getSpellingSuggestionForName(c, text, Array.from(getExportsOfModule(c, namespace).values()), 2623475 /* SymbolFlags.ModuleMember */);
|
|
1578
1693
|
if (suggestion !== undefined) {
|
|
1579
|
-
c.error(right,
|
|
1694
|
+
c.error(right, 863 /* Diagnostics.X_0_has_no_exported_member_named_1_Did_you_mean_2 */, namespaceName, declarationName, symbolToString(c, suggestion));
|
|
1580
1695
|
return undefined;
|
|
1581
1696
|
}
|
|
1582
1697
|
let containingQualifiedName;
|
|
1583
|
-
if (name.kind ===
|
|
1698
|
+
if (name.kind === 168 /* SyntaxKind.QualifiedName */) {
|
|
1584
1699
|
containingQualifiedName = name;
|
|
1585
|
-
while (containingQualifiedName.parent.kind ===
|
|
1700
|
+
while (containingQualifiedName.parent.kind === 168 /* SyntaxKind.QualifiedName */)
|
|
1586
1701
|
containingQualifiedName = containingQualifiedName.parent;
|
|
1587
1702
|
}
|
|
1588
1703
|
if (
|
|
@@ -1590,22 +1705,22 @@ function resolveQualifiedName(c, name, left, right, meaning, ignoreErrors, locat
|
|
|
1590
1705
|
c.hasGlobalObjectType &&
|
|
1591
1706
|
(meaning & 788968 /* SymbolFlags.Type */) !== 0 &&
|
|
1592
1707
|
containingQualifiedName !== undefined &&
|
|
1593
|
-
containingQualifiedName.parent.kind !==
|
|
1708
|
+
containingQualifiedName.parent.kind !== 223 /* SyntaxKind.TypeOfExpression */ &&
|
|
1594
1709
|
tryGetQualifiedNameAsValue(c, containingQualifiedName) !== undefined) {
|
|
1595
|
-
c.error(containingQualifiedName,
|
|
1710
|
+
c.error(containingQualifiedName, 888 /* Diagnostics.X_0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0 */, entityNameToString(containingQualifiedName));
|
|
1596
1711
|
return undefined;
|
|
1597
1712
|
}
|
|
1598
1713
|
if ((meaning & 1920 /* SymbolFlags.Namespace */) !== 0 &&
|
|
1599
1714
|
name.parent !== undefined &&
|
|
1600
|
-
name.parent.kind ===
|
|
1715
|
+
name.parent.kind === 168 /* SyntaxKind.QualifiedName */) {
|
|
1601
1716
|
const exportedType = getSymbolOfMeaning(c, getExportsOfSymbol(c, namespace), text, 788968 /* SymbolFlags.Type */);
|
|
1602
1717
|
if (exportedType !== undefined) {
|
|
1603
1718
|
const qualified = name.parent;
|
|
1604
|
-
c.error(qualified.right,
|
|
1719
|
+
c.error(qualified.right, 852 /* Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1 */, symbolToString(c, getMergedSymbol(c, exportedType)), getText(qualified.right));
|
|
1605
1720
|
return undefined;
|
|
1606
1721
|
}
|
|
1607
1722
|
}
|
|
1608
|
-
c.error(right,
|
|
1723
|
+
c.error(right, 833 /* Diagnostics.Namespace_0_has_no_exported_member_1 */, namespaceName, declarationName);
|
|
1609
1724
|
return undefined;
|
|
1610
1725
|
}
|
|
1611
1726
|
/** The value a qualified name denotes as a property access, if any. */
|
|
@@ -1615,8 +1730,8 @@ function tryGetQualifiedNameAsValue(c, node) {
|
|
|
1615
1730
|
if (symbol === undefined)
|
|
1616
1731
|
return undefined;
|
|
1617
1732
|
let current = id;
|
|
1618
|
-
while (current.parent.kind ===
|
|
1619
|
-
symbol = getPropertyOfType(c, getTypeOfSymbol(c, symbol), current.parent.right
|
|
1733
|
+
while (current.parent.kind === 168 /* SyntaxKind.QualifiedName */) {
|
|
1734
|
+
symbol = getPropertyOfType(c, getTypeOfSymbol(c, symbol), getText(current.parent.right));
|
|
1620
1735
|
if (symbol === undefined)
|
|
1621
1736
|
return undefined;
|
|
1622
1737
|
current = current.parent;
|
|
@@ -1637,31 +1752,31 @@ export function getCannotFindNameDiagnosticForName(c, node) {
|
|
|
1637
1752
|
switch (getText(node)) {
|
|
1638
1753
|
case 'document':
|
|
1639
1754
|
case 'console':
|
|
1640
|
-
return
|
|
1755
|
+
return 741 /* Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom */;
|
|
1641
1756
|
case '$':
|
|
1642
1757
|
return wildcard
|
|
1643
|
-
?
|
|
1644
|
-
:
|
|
1758
|
+
? 738 /* Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery */
|
|
1759
|
+
: 747 /* Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig */;
|
|
1645
1760
|
case 'beforeEach':
|
|
1646
1761
|
case 'describe':
|
|
1647
1762
|
case 'suite':
|
|
1648
1763
|
case 'it':
|
|
1649
1764
|
case 'test':
|
|
1650
1765
|
return wildcard
|
|
1651
|
-
?
|
|
1652
|
-
:
|
|
1766
|
+
? 739 /* Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha */
|
|
1767
|
+
: 748 /* Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig */;
|
|
1653
1768
|
case 'process':
|
|
1654
1769
|
case 'require':
|
|
1655
1770
|
case 'Buffer':
|
|
1656
1771
|
case 'module':
|
|
1657
1772
|
case 'NodeJS':
|
|
1658
1773
|
return wildcard
|
|
1659
|
-
?
|
|
1660
|
-
:
|
|
1774
|
+
? 737 /* Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode */
|
|
1775
|
+
: 746 /* Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig */;
|
|
1661
1776
|
case 'Bun':
|
|
1662
1777
|
return wildcard
|
|
1663
|
-
?
|
|
1664
|
-
:
|
|
1778
|
+
? 994 /* Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun */
|
|
1779
|
+
: 995 /* Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_Bun_Try_npm_i_save_dev_types_Slashbun_and_then_add_bun_to_the_types_field_in_your_tsconfig */;
|
|
1665
1780
|
// tsgo lists `ast.Symbol` here rather than `Symbol`.
|
|
1666
1781
|
case 'Map':
|
|
1667
1782
|
case 'Set':
|
|
@@ -1680,15 +1795,15 @@ export function getCannotFindNameDiagnosticForName(c, node) {
|
|
|
1680
1795
|
case 'Reflect':
|
|
1681
1796
|
case 'BigInt64Array':
|
|
1682
1797
|
case 'BigUint64Array':
|
|
1683
|
-
return
|
|
1798
|
+
return 740 /* Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later */;
|
|
1684
1799
|
case 'await':
|
|
1685
|
-
if (node.parent !== undefined && node.parent.kind ===
|
|
1686
|
-
return
|
|
1800
|
+
if (node.parent !== undefined && node.parent.kind === 215 /* SyntaxKind.CallExpression */)
|
|
1801
|
+
return 496 /* Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function */;
|
|
1687
1802
|
break;
|
|
1688
1803
|
}
|
|
1689
|
-
if (node.parent !== undefined && node.parent.kind ===
|
|
1690
|
-
return
|
|
1691
|
-
return
|
|
1804
|
+
if (node.parent !== undefined && node.parent.kind === 305 /* SyntaxKind.ShorthandPropertyAssignment */)
|
|
1805
|
+
return 1848 /* Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer */;
|
|
1806
|
+
return 489 /* Diagnostics.Cannot_find_name_0 */;
|
|
1692
1807
|
}
|
|
1693
1808
|
/**
|
|
1694
1809
|
* Pushes a resolution of `propertyName` on `target`. When the same resolution is already on the
|
|
@@ -1769,16 +1884,16 @@ export function reportCircularityError(c, symbol) {
|
|
|
1769
1884
|
const declaration = symbol.valueDeclaration;
|
|
1770
1885
|
if (declaration !== undefined) {
|
|
1771
1886
|
if (getType(declaration) !== undefined) {
|
|
1772
|
-
c.error(declaration,
|
|
1887
|
+
c.error(declaration, 669 /* Diagnostics.X_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation */, symbolToString(c, symbol));
|
|
1773
1888
|
return c.errorType;
|
|
1774
1889
|
}
|
|
1775
|
-
if (c.noImplicitAny && (declaration.kind !==
|
|
1776
|
-
c.error(declaration,
|
|
1890
|
+
if (c.noImplicitAny && (declaration.kind !== 171 /* SyntaxKind.Parameter */ || getInitializer(declaration) !== undefined))
|
|
1891
|
+
c.error(declaration, 1712 /* Diagnostics.X_0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer */, symbolToString(c, symbol));
|
|
1777
1892
|
}
|
|
1778
1893
|
else if ((symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0) {
|
|
1779
1894
|
const node = getDeclarationOfAliasSymbol(symbol);
|
|
1780
1895
|
if (node !== undefined)
|
|
1781
|
-
c.error(node,
|
|
1896
|
+
c.error(node, 488 /* Diagnostics.Circular_definition_of_import_alias_0 */, symbolToString(c, symbol));
|
|
1782
1897
|
}
|
|
1783
1898
|
// Circularities could also result from parameters in function expressions that end up having themselves as
|
|
1784
1899
|
// contextual types. Those are reported elsewhere.
|