tsc-ts 0.0.9 → 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 +2 -2
- 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 +22 -15
- package/dist/api/compiler/ast.js +1026 -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 +178 -124
- 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 +472 -440
- 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 -107
- 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 +212 -75
- 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 +145 -36
- 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 +104 -31
- package/dist/api/compiler/checker.js +181 -33
- 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 +42 -3
- package/dist/api/compiler/compile-program.js +139 -27
- package/dist/api/compiler/diagnostic-messages.d.ts +1849 -1774
- package/dist/api/compiler/diagnostic-messages.js +128 -122
- package/dist/api/compiler/diagnostics.d.ts +22 -0
- package/dist/api/compiler/diagnostics.js +93 -11
- 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 +21 -1
- package/dist/api/compiler/file-loader.js +201 -48
- 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/parallel-parse.d.ts +3 -2
- package/dist/api/compiler/parallel-parse.js +17 -5
- 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 +5 -1
- package/dist/api/compiler/printer/emit-context.js +20 -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 +49 -2
- package/dist/api/compiler/printer/printer.js +539 -293
- package/dist/api/compiler/printer/utilities.js +149 -147
- package/dist/api/compiler/program-checker.d.ts +12 -2
- package/dist/api/compiler/program-checker.js +88 -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 +4 -6
- package/dist/api/compiler/program.js +74 -87
- 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 +347 -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 +23 -14
- package/dist/api/compiler/symbol.js +23 -11
- 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 +58 -26
- package/src/compiler/binder.ts +39 -4
- package/src/compiler/character-codes.ts +2 -2
- package/src/compiler/checker-calls.ts +79 -9
- 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 +136 -62
- package/src/compiler/checker-heritage.ts +22 -21
- package/src/compiler/checker-inference.ts +514 -82
- 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 +200 -56
- 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 +124 -23
- 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 +203 -39
- package/src/compiler/command-line.ts +28 -28
- package/src/compiler/compile-program.ts +167 -27
- package/src/compiler/decoder.ts +13 -4
- package/src/compiler/diagnostic-messages.ts +1973 -1892
- package/src/compiler/diagnostics.ts +84 -3
- 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 +197 -38
- package/src/compiler/help.ts +10 -14
- package/src/compiler/incremental.ts +165 -30
- 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 +326 -52
- package/src/compiler/parallel-emit.ts +320 -0
- package/src/compiler/parallel-parse.ts +16 -5
- package/src/compiler/parse-thread.ts +3 -0
- package/src/compiler/parser.ts +156 -39
- package/src/compiler/path.ts +22 -2
- package/src/compiler/printer/emit-context.ts +21 -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 +266 -30
- package/src/compiler/printer/utilities.ts +8 -2
- package/src/compiler/program-checker.ts +57 -5
- package/src/compiler/program-utilities.ts +23 -10
- package/src/compiler/program.ts +18 -26
- package/src/compiler/pseudo-bigint.ts +17 -0
- package/src/compiler/regexp-checker.ts +63 -30
- package/src/compiler/relations.ts +240 -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 +46 -24
- package/src/compiler/syntax-kind.ts +188 -187
- package/src/compiler/thread-entry.ts +64 -4
- 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 +66 -9
- package/src/compiler/tsc-cli.ts +7 -0
- package/src/compiler/tsc-compile.ts +284 -4
- 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
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { checkCollisionsForDeclarationName } from './checker-generated-code.js';
|
|
3
3
|
import { checkExternalEmitHelpers } from './checker-emit-helpers.js';
|
|
4
4
|
import { convertAutoToAny } from './checker-narrowing.js';
|
|
5
|
+
import { grammarErrorOnNode } from './checker-operators.js';
|
|
5
6
|
import { markPropertyAsReferenced } from './checker-unused.js';
|
|
6
7
|
import { NodeVisitor, getExpression, getInitializer, getName, getType, getElements, getSymbol, getLocalSymbol, getBody, getDotDotDotToken, getParameters, getStatements, getText, getTypeArguments, getModifiers, } from './ast.js';
|
|
7
8
|
import { ModuleKind, ScriptTarget } from './options.js';
|
|
@@ -32,7 +33,7 @@ import { getContainerFlags } from './binder.js';
|
|
|
32
33
|
import { isAmbientModule, isFunctionLike, isGlobalScopeAugmentation, isInJSFile, nodeIsMissing, nodeIsPresent, } from './ast-utilities.js';
|
|
33
34
|
import { getTypeForBindingElementParent } from './checker-destructuring.js';
|
|
34
35
|
import { checkFunctionOrMethodSymbols } from './checker-overloads.js';
|
|
35
|
-
import { checkJSDocFullSignature } from './checker-jsdoc.js';
|
|
36
|
+
import { checkJSDocFullSignature, checkJSDocFullSignatureType } from './checker-jsdoc.js';
|
|
36
37
|
import { checkAliasSymbol } from './checker-modules.js';
|
|
37
38
|
import { checkDecorators } from './checker-decorators.js';
|
|
38
39
|
import { declarationCount, getDeclarations, getSymbolId, } from './symbol.js';
|
|
@@ -56,33 +57,33 @@ function checkUsingDeclarationInitializer(c, node, initializer, initType) {
|
|
|
56
57
|
const globalAsyncDisposableType = getCachedGlobalType(c, 'AsyncDisposable', 0, true);
|
|
57
58
|
const globalDisposableType = getCachedGlobalType(c, 'Disposable', 0, true);
|
|
58
59
|
if (globalAsyncDisposableType !== c.emptyObjectType && globalDisposableType !== c.emptyObjectType)
|
|
59
|
-
checkTypeAssignableTo(c, widenTypeForVariableLikeDeclaration(c, initType, node, false), getUnionType(c, [globalAsyncDisposableType, globalDisposableType, c.nullType, c.undefinedType]), initializer,
|
|
60
|
+
checkTypeAssignableTo(c, widenTypeForVariableLikeDeclaration(c, initType, node, false), getUnionType(c, [globalAsyncDisposableType, globalDisposableType, c.nullType, c.undefinedType]), initializer, 978 /* Diagnostics.The_initializer_of_an_await_using_declaration_must_be_either_an_object_with_a_Symbol_asyncDispose_or_Symbol_dispose_method_or_be_null_or_undefined */);
|
|
60
61
|
}
|
|
61
62
|
else if (blockScopeKind === 4 /* NodeFlags.Using */) {
|
|
62
63
|
const globalDisposableType = getCachedGlobalType(c, 'Disposable', 0, true);
|
|
63
64
|
if (globalDisposableType !== c.emptyObjectType)
|
|
64
|
-
checkTypeAssignableTo(c, widenTypeForVariableLikeDeclaration(c, initType, node, false), getUnionType(c, [globalDisposableType, c.nullType, c.undefinedType]), initializer,
|
|
65
|
+
checkTypeAssignableTo(c, widenTypeForVariableLikeDeclaration(c, initType, node, false), getUnionType(c, [globalDisposableType, c.nullType, c.undefinedType]), initializer, 977 /* Diagnostics.The_initializer_of_a_using_declaration_must_be_either_an_object_with_a_Symbol_dispose_method_or_be_null_or_undefined */);
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
/** Checks a variable, parameter, property or binding element declaration. */
|
|
68
69
|
export function checkVariableLikeDeclaration(c, node) {
|
|
69
70
|
checkDecorators(c, node);
|
|
70
|
-
if (node.kind ===
|
|
71
|
+
if (node.kind === 171 /* SyntaxKind.Parameter */)
|
|
71
72
|
checkParameter(c, node);
|
|
72
73
|
const typeNode = getType(node);
|
|
73
74
|
checkTypeNodeIfPresent(c, typeNode);
|
|
74
75
|
const name = getName(node);
|
|
75
|
-
if (node.kind ===
|
|
76
|
-
c.error(node,
|
|
77
|
-
if (name !== undefined && name.kind ===
|
|
76
|
+
if (node.kind === 173 /* SyntaxKind.PropertySignature */ && name !== undefined && name.kind === 80 /* SyntaxKind.PrivateIdentifier */)
|
|
77
|
+
c.error(node, 1858 /* Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies */);
|
|
78
|
+
if (name !== undefined && name.kind === 169 /* SyntaxKind.ComputedPropertyName */)
|
|
78
79
|
checkComputedPropertyName(c, name);
|
|
79
80
|
const initializer = getInitializer(node);
|
|
80
81
|
// Parameter initializers need an implementation.
|
|
81
|
-
const initializerNotAllowed = initializer !== undefined && node.kind ===
|
|
82
|
+
const initializerNotAllowed = initializer !== undefined && node.kind === 171 /* SyntaxKind.Parameter */ && nodeIsMissing(getBody(node.parent));
|
|
82
83
|
if (name !== undefined &&
|
|
83
|
-
(name.kind ===
|
|
84
|
+
(name.kind === 208 /* SyntaxKind.ObjectBindingPattern */ || name.kind === 209 /* SyntaxKind.ArrayBindingPattern */)) {
|
|
84
85
|
if (initializerNotAllowed)
|
|
85
|
-
c.error(node,
|
|
86
|
+
c.error(node, 552 /* Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation */);
|
|
86
87
|
for (const element of getElements(name).nodes)
|
|
87
88
|
checkBindingElement(c, element);
|
|
88
89
|
if (!initializerNotAllowed)
|
|
@@ -90,11 +91,11 @@ export function checkVariableLikeDeclaration(c, node) {
|
|
|
90
91
|
return;
|
|
91
92
|
}
|
|
92
93
|
if (initializerNotAllowed) {
|
|
93
|
-
c.error(node,
|
|
94
|
+
c.error(node, 552 /* Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation */);
|
|
94
95
|
return;
|
|
95
96
|
}
|
|
96
97
|
if (name !== undefined && name.kind === 9 /* SyntaxKind.BigIntLiteral */)
|
|
97
|
-
c.error(name,
|
|
98
|
+
c.error(name, 452 /* Diagnostics.A_bigint_literal_cannot_be_used_as_a_property_name */);
|
|
98
99
|
const symbol = getSymbolOfDeclaration(c, node);
|
|
99
100
|
if (symbol === undefined) {
|
|
100
101
|
if (initializer !== undefined)
|
|
@@ -108,20 +109,20 @@ export function checkVariableLikeDeclaration(c, node) {
|
|
|
108
109
|
}
|
|
109
110
|
if (name !== undefined &&
|
|
110
111
|
name.kind === 79 /* SyntaxKind.Identifier */ &&
|
|
111
|
-
node.kind !==
|
|
112
|
-
node.kind !==
|
|
112
|
+
node.kind !== 174 /* SyntaxKind.PropertyDeclaration */ &&
|
|
113
|
+
node.kind !== 173 /* SyntaxKind.PropertySignature */)
|
|
113
114
|
checkCollisionsForDeclarationName(c, node, name);
|
|
114
115
|
const t = convertAutoToAny(c, getTypeOfSymbol(c, symbol));
|
|
115
|
-
if (node.kind !==
|
|
116
|
-
node.kind !==
|
|
117
|
-
node.kind !==
|
|
116
|
+
if (node.kind !== 174 /* SyntaxKind.PropertyDeclaration */ &&
|
|
117
|
+
node.kind !== 173 /* SyntaxKind.PropertySignature */ &&
|
|
118
|
+
node.kind !== 171 /* SyntaxKind.Parameter */) {
|
|
118
119
|
checkExportsOnMergedDeclarations(c, node);
|
|
119
|
-
if (node.kind ===
|
|
120
|
+
if (node.kind === 262 /* SyntaxKind.VariableDeclaration */)
|
|
120
121
|
checkVarDeclaredNamesNotShadowed(c, node, symbol);
|
|
121
122
|
}
|
|
122
123
|
if (node === symbol.valueDeclaration) {
|
|
123
124
|
// A for-in initializer is already an error.
|
|
124
|
-
if (initializer !== undefined && node.parent.parent.kind !==
|
|
125
|
+
if (initializer !== undefined && node.parent.parent.kind !== 251 /* SyntaxKind.ForInStatement */) {
|
|
125
126
|
const initType = checkExpressionCached(c, initializer);
|
|
126
127
|
checkTypeAssignableToAndOptionallyElaborate(c, initType, t, node, initializer);
|
|
127
128
|
checkUsingDeclarationInitializer(c, node, initializer, initType);
|
|
@@ -158,7 +159,7 @@ function checkBindingPatternInitializer(c, node, name, initializer) {
|
|
|
158
159
|
if (isInAmbientOrTypeNode(node))
|
|
159
160
|
return;
|
|
160
161
|
// A for-in initializer is already an error.
|
|
161
|
-
const needCheckInitializer = initializer !== undefined && node.parent.parent.kind !==
|
|
162
|
+
const needCheckInitializer = initializer !== undefined && node.parent.parent.kind !== 251 /* SyntaxKind.ForInStatement */;
|
|
162
163
|
let needCheckWidenedType = true;
|
|
163
164
|
for (const e of getElements(name).nodes) {
|
|
164
165
|
if (getName(e) !== undefined) {
|
|
@@ -177,7 +178,7 @@ function checkBindingPatternInitializer(c, node, name, initializer) {
|
|
|
177
178
|
checkTypeAssignableToAndOptionallyElaborate(c, initializerType, getWidenedTypeForVariableLikeDeclaration(c, node, false), node, initializer);
|
|
178
179
|
}
|
|
179
180
|
if (needCheckWidenedType) {
|
|
180
|
-
if (name.kind ===
|
|
181
|
+
if (name.kind === 209 /* SyntaxKind.ArrayBindingPattern */)
|
|
181
182
|
checkIteratedTypeOrElementType(c, 65 /* IterationUse.Destructuring */, widenedType, c.undefinedType, node);
|
|
182
183
|
else if (c.strictNullChecks)
|
|
183
184
|
checkNonNullNonVoidType(c, widenedType, node);
|
|
@@ -202,20 +203,20 @@ function checkVarDeclaredNamesNotShadowed(c, node, symbol) {
|
|
|
202
203
|
if (declaration === undefined || (getCombinedNodeFlags(declaration) & 7 /* NodeFlags.BlockScoped */) === 0)
|
|
203
204
|
return;
|
|
204
205
|
let list = declaration;
|
|
205
|
-
while (list !== undefined && list.kind !==
|
|
206
|
+
while (list !== undefined && list.kind !== 263 /* SyntaxKind.VariableDeclarationList */)
|
|
206
207
|
list = list.parent;
|
|
207
208
|
const statement = list?.parent;
|
|
208
|
-
const container = statement !== undefined && statement.kind ===
|
|
209
|
+
const container = statement !== undefined && statement.kind === 245 /* SyntaxKind.VariableStatement */ ? statement.parent : undefined;
|
|
209
210
|
// Block-scoped variables of the function, module or file scope share it with hoisted `var`s.
|
|
210
211
|
const namesShareScope = container !== undefined &&
|
|
211
|
-
((container.kind ===
|
|
212
|
-
container.kind ===
|
|
213
|
-
container.kind ===
|
|
214
|
-
container.kind ===
|
|
212
|
+
((container.kind === 243 /* SyntaxKind.Block */ && isFunctionLike(container.parent)) ||
|
|
213
|
+
container.kind === 270 /* SyntaxKind.ModuleBlock */ ||
|
|
214
|
+
container.kind === 269 /* SyntaxKind.ModuleDeclaration */ ||
|
|
215
|
+
container.kind === 308 /* SyntaxKind.SourceFile */);
|
|
215
216
|
if (namesShareScope)
|
|
216
217
|
return;
|
|
217
218
|
const localName = symbolToString(c, local);
|
|
218
|
-
c.error(node,
|
|
219
|
+
c.error(node, 651 /* Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1 */, localName, localName);
|
|
219
220
|
}
|
|
220
221
|
/** Parameter properties, `this` parameters and rest parameter types. */
|
|
221
222
|
function checkParameter(c, node) {
|
|
@@ -225,27 +226,27 @@ function checkParameter(c, node) {
|
|
|
225
226
|
if (hasSyntacticModifier(node, 31 /* ModifierFlags.ParameterPropertyModifier */)) {
|
|
226
227
|
if (shouldCheckErasableSyntax(c, node))
|
|
227
228
|
c.error(node, 243 /* Diagnostics.This_syntax_is_not_allowed_when_erasableSyntaxOnly_is_enabled */);
|
|
228
|
-
if (fn.kind !==
|
|
229
|
-
c.error(node,
|
|
230
|
-
if (fn.kind ===
|
|
231
|
-
c.error(name,
|
|
229
|
+
if (fn.kind !== 178 /* SyntaxKind.Constructor */ || !nodeIsPresent(getBody(fn)))
|
|
230
|
+
c.error(node, 550 /* Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation */);
|
|
231
|
+
if (fn.kind === 178 /* SyntaxKind.Constructor */ && paramName === 'constructor')
|
|
232
|
+
c.error(name, 576 /* Diagnostics.X_constructor_cannot_be_used_as_a_parameter_property_name */);
|
|
232
233
|
}
|
|
233
234
|
if (getInitializer(node) === undefined &&
|
|
234
235
|
isOptionalDeclaration(node) &&
|
|
235
236
|
isBindingPattern(name) &&
|
|
236
237
|
getBody(fn) !== undefined)
|
|
237
|
-
c.error(node,
|
|
238
|
+
c.error(node, 636 /* Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature */);
|
|
238
239
|
if (paramName === 'this' || paramName === 'new') {
|
|
239
240
|
if (getParameters(fn).nodes.indexOf(node) !== 0)
|
|
240
|
-
c.error(node,
|
|
241
|
-
if (fn.kind ===
|
|
242
|
-
fn.kind ===
|
|
243
|
-
fn.kind ===
|
|
244
|
-
c.error(node,
|
|
245
|
-
if (fn.kind ===
|
|
246
|
-
c.error(node,
|
|
247
|
-
if (fn.kind ===
|
|
248
|
-
c.error(node,
|
|
241
|
+
c.error(node, 821 /* Diagnostics.A_0_parameter_must_be_the_first_parameter */, paramName);
|
|
242
|
+
if (fn.kind === 178 /* SyntaxKind.Constructor */ ||
|
|
243
|
+
fn.kind === 182 /* SyntaxKind.ConstructSignature */ ||
|
|
244
|
+
fn.kind === 187 /* SyntaxKind.ConstructorType */)
|
|
245
|
+
c.error(node, 822 /* Diagnostics.A_constructor_cannot_have_a_this_parameter */);
|
|
246
|
+
if (fn.kind === 221 /* SyntaxKind.ArrowFunction */)
|
|
247
|
+
c.error(node, 869 /* Diagnostics.An_arrow_function_cannot_have_a_this_parameter */);
|
|
248
|
+
if (fn.kind === 179 /* SyntaxKind.GetAccessor */ || fn.kind === 180 /* SyntaxKind.SetAccessor */)
|
|
249
|
+
c.error(node, 923 /* Diagnostics.X_get_and_set_accessors_cannot_declare_this_parameters */);
|
|
249
250
|
}
|
|
250
251
|
// Binding patterns in rest parameters are a grammar error. Generic rest types are skipped: the
|
|
251
252
|
// implied `any[]` constraints of `infer` positions aren't computed yet.
|
|
@@ -253,27 +254,27 @@ function checkParameter(c, node) {
|
|
|
253
254
|
const symbol = getSymbolOfDeclaration(c, node);
|
|
254
255
|
const t = symbol !== undefined ? getReducedType(c, getTypeOfSymbol(c, symbol)) : undefined;
|
|
255
256
|
if (t !== undefined && !isTypeAssignableTo(c, t, c.anyReadonlyArrayType))
|
|
256
|
-
c.error(node,
|
|
257
|
+
c.error(node, 551 /* Diagnostics.A_rest_parameter_must_be_of_an_array_type */);
|
|
257
258
|
}
|
|
258
259
|
}
|
|
259
|
-
function isVariableLike(node) {
|
|
260
|
+
export function isVariableLike(node) {
|
|
260
261
|
switch (node.kind) {
|
|
261
|
-
case
|
|
262
|
-
case
|
|
263
|
-
case
|
|
264
|
-
case
|
|
265
|
-
case
|
|
266
|
-
case
|
|
267
|
-
case
|
|
268
|
-
case
|
|
262
|
+
case 210 /* SyntaxKind.BindingElement */:
|
|
263
|
+
case 307 /* SyntaxKind.EnumMember */:
|
|
264
|
+
case 171 /* SyntaxKind.Parameter */:
|
|
265
|
+
case 304 /* SyntaxKind.PropertyAssignment */:
|
|
266
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
267
|
+
case 173 /* SyntaxKind.PropertySignature */:
|
|
268
|
+
case 305 /* SyntaxKind.ShorthandPropertyAssignment */:
|
|
269
|
+
case 262 /* SyntaxKind.VariableDeclaration */:
|
|
269
270
|
return true;
|
|
270
271
|
}
|
|
271
272
|
return false;
|
|
272
273
|
}
|
|
273
274
|
function areDeclarationFlagsIdentical(left, right) {
|
|
274
275
|
// Parameters and variables may differ in optionality.
|
|
275
|
-
if ((left.kind ===
|
|
276
|
-
(left.kind ===
|
|
276
|
+
if ((left.kind === 171 /* SyntaxKind.Parameter */ && right.kind === 262 /* SyntaxKind.VariableDeclaration */) ||
|
|
277
|
+
(left.kind === 262 /* SyntaxKind.VariableDeclaration */ && right.kind === 171 /* SyntaxKind.Parameter */))
|
|
277
278
|
return true;
|
|
278
279
|
if (isOptionalDeclaration(left) !== isOptionalDeclaration(right))
|
|
279
280
|
return false;
|
|
@@ -286,12 +287,14 @@ function areDeclarationFlagsIdentical(left, right) {
|
|
|
286
287
|
return (getModifierFlags(left) & interestingFlags) === (getModifierFlags(right) & interestingFlags);
|
|
287
288
|
}
|
|
288
289
|
function reportNonIdenticalModifiers(c, name) {
|
|
289
|
-
c.error(name,
|
|
290
|
+
c.error(name, 827 /* Diagnostics.All_declarations_of_0_must_have_identical_modifiers */, declarationNameToString(getSourceFileOfNode(name), name));
|
|
290
291
|
}
|
|
291
292
|
function checkBindingElement(c, element) {
|
|
292
293
|
// Missing array binding elements have no name.
|
|
293
294
|
if (element.name === undefined)
|
|
294
295
|
return;
|
|
296
|
+
if (element.propertyName !== undefined && element.propertyName.kind === 80 /* SyntaxKind.PrivateIdentifier */)
|
|
297
|
+
grammarErrorOnNode(c, element.propertyName, 1899 /* Diagnostics.Private_identifiers_cannot_be_used_in_destructuring_patterns */);
|
|
295
298
|
if (element.propertyName !== undefined &&
|
|
296
299
|
element.name.kind === 79 /* SyntaxKind.Identifier */ &&
|
|
297
300
|
isPartOfParameterDeclaration(element) &&
|
|
@@ -304,11 +307,11 @@ function checkBindingElement(c, element) {
|
|
|
304
307
|
if (element.name.kind === 79 /* SyntaxKind.Identifier */)
|
|
305
308
|
checkCollisionsForDeclarationName(c, element, element.name);
|
|
306
309
|
// An object rest binding before ES2018 uses __rest.
|
|
307
|
-
if (element.parent.kind ===
|
|
310
|
+
if (element.parent.kind === 208 /* SyntaxKind.ObjectBindingPattern */ &&
|
|
308
311
|
element.dotDotDotToken !== undefined &&
|
|
309
312
|
c.languageVersion < ScriptTarget.ES2018)
|
|
310
313
|
checkExternalEmitHelpers(c, element, 1 /* ExternalEmitHelpers.Rest */);
|
|
311
|
-
if (element.propertyName !== undefined && element.propertyName.kind ===
|
|
314
|
+
if (element.propertyName !== undefined && element.propertyName.kind === 169 /* SyntaxKind.ComputedPropertyName */)
|
|
312
315
|
checkComputedPropertyName(c, element.propertyName);
|
|
313
316
|
// Private and protected properties can't be destructured outside their classes.
|
|
314
317
|
const parent = element.parent.parent;
|
|
@@ -327,7 +330,7 @@ function checkBindingElement(c, element) {
|
|
|
327
330
|
}
|
|
328
331
|
const name = element.name;
|
|
329
332
|
if (name !== undefined &&
|
|
330
|
-
(name.kind ===
|
|
333
|
+
(name.kind === 208 /* SyntaxKind.ObjectBindingPattern */ || name.kind === 209 /* SyntaxKind.ArrayBindingPattern */)) {
|
|
331
334
|
for (const e of getElements(name).nodes)
|
|
332
335
|
checkBindingElement(c, e);
|
|
333
336
|
}
|
|
@@ -335,10 +338,10 @@ function checkBindingElement(c, element) {
|
|
|
335
338
|
if (element.initializer !== undefined &&
|
|
336
339
|
isPartOfParameterDeclaration(element) &&
|
|
337
340
|
nodeIsMissing(getBody(getRootDeclaration(element).parent))) {
|
|
338
|
-
c.error(element,
|
|
341
|
+
c.error(element, 552 /* Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation */);
|
|
339
342
|
return;
|
|
340
343
|
}
|
|
341
|
-
if (name.kind ===
|
|
344
|
+
if (name.kind === 208 /* SyntaxKind.ObjectBindingPattern */ || name.kind === 209 /* SyntaxKind.ArrayBindingPattern */) {
|
|
342
345
|
checkBindingPatternInitializer(c, element, name, element.initializer);
|
|
343
346
|
return;
|
|
344
347
|
}
|
|
@@ -355,7 +358,7 @@ function checkBindingElement(c, element) {
|
|
|
355
358
|
const initializer = element.initializer;
|
|
356
359
|
if (element === symbol.valueDeclaration) {
|
|
357
360
|
// A for-in initializer is already an error.
|
|
358
|
-
if (initializer !== undefined && getRootDeclaration(element).parent.parent.kind !==
|
|
361
|
+
if (initializer !== undefined && getRootDeclaration(element).parent.parent.kind !== 251 /* SyntaxKind.ForInStatement */)
|
|
359
362
|
checkTypeAssignableToAndOptionallyElaborate(c, checkExpressionCached(c, initializer), t, element, initializer);
|
|
360
363
|
}
|
|
361
364
|
else if (symbol.valueDeclaration !== undefined) {
|
|
@@ -381,13 +384,13 @@ function checkBindingElement(c, element) {
|
|
|
381
384
|
}
|
|
382
385
|
function errorNextVariableOrPropertyDeclarationMustHaveSameType(c, firstDeclaration, firstType, nextDeclaration, nextType) {
|
|
383
386
|
const nextDeclarationName = getNameOfDeclaration(nextDeclaration);
|
|
384
|
-
const message = nextDeclaration.kind ===
|
|
385
|
-
?
|
|
386
|
-
:
|
|
387
|
+
const message = nextDeclaration.kind === 174 /* SyntaxKind.PropertyDeclaration */ || nextDeclaration.kind === 173 /* SyntaxKind.PropertySignature */
|
|
388
|
+
? 856 /* Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 */
|
|
389
|
+
: 581 /* Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2 */;
|
|
387
390
|
const declName = declarationNameToString(getSourceFileOfNode(nextDeclaration), nextDeclarationName);
|
|
388
391
|
const err = c.error(nextDeclarationName, message, declName, typeToString(c, firstType), typeToString(c, nextType));
|
|
389
392
|
if (firstDeclaration !== undefined)
|
|
390
|
-
err.addRelatedInfo(createDiagnosticForNode(getNameOfDeclaration(firstDeclaration) ?? firstDeclaration,
|
|
393
|
+
err.addRelatedInfo(createDiagnosticForNode(getNameOfDeclaration(firstDeclaration) ?? firstDeclaration, 1367 /* Diagnostics.X_0_was_also_declared_here */, [declName]));
|
|
391
394
|
}
|
|
392
395
|
// ---- Functions
|
|
393
396
|
export function checkFunctionDeclaration(c, node) {
|
|
@@ -395,6 +398,7 @@ export function checkFunctionDeclaration(c, node) {
|
|
|
395
398
|
if (symbol !== undefined)
|
|
396
399
|
getTypeOfSymbol(c, symbol);
|
|
397
400
|
checkFunctionLikeBody(c, node);
|
|
401
|
+
checkJSDocFullSignatureType(c, node);
|
|
398
402
|
checkJSDocFullSignature(c, node);
|
|
399
403
|
checkFunctionOrMethodSymbols(c, node);
|
|
400
404
|
checkCollisionsForDeclarationName(c, node, getName(node));
|
|
@@ -411,19 +415,19 @@ export function checkTypeParameter(c, node) {
|
|
|
411
415
|
// Resolving the base constraint reveals circularities.
|
|
412
416
|
getBaseConstraintOfType(c, typeParameter);
|
|
413
417
|
if (getResolvedTypeParameterDefault(c, typeParameter) === c.circularConstraintType)
|
|
414
|
-
c.error(tp.defaultType,
|
|
418
|
+
c.error(tp.defaultType, 855 /* Diagnostics.Type_parameter_0_has_a_circular_default */, typeToString(c, typeParameter));
|
|
415
419
|
const constraintType = getConstraintOfTypeParameter(c, typeParameter);
|
|
416
420
|
const defaultType = getDefaultFromTypeParameter(c, typeParameter);
|
|
417
421
|
if (constraintType !== undefined && defaultType !== undefined)
|
|
418
|
-
checkTypeAssignableTo(c, defaultType, getTypeWithThisArgument(c, instantiateType(c, constraintType, new SimpleTypeMapper(typeParameter, defaultType)), defaultType, false), tp.defaultType,
|
|
419
|
-
checkTypeNameIsReserved(c, tp.name,
|
|
422
|
+
checkTypeAssignableTo(c, defaultType, getTypeWithThisArgument(c, instantiateType(c, constraintType, new SimpleTypeMapper(typeParameter, defaultType)), defaultType, false), tp.defaultType, 527 /* Diagnostics.Type_0_does_not_satisfy_the_constraint_1 */);
|
|
423
|
+
checkTypeNameIsReserved(c, tp.name, 549 /* Diagnostics.Type_parameter_name_cannot_be_0 */);
|
|
420
424
|
checkNodeDeferred(c, node);
|
|
421
425
|
}
|
|
422
426
|
/** Variance annotations are only allowed on type aliases of object, function, constructor and mapped types. */
|
|
423
427
|
export function checkTypeParameterDeferred(c, node) {
|
|
424
428
|
const parent = node.parent;
|
|
425
|
-
const isTypeAlias = parent.kind ===
|
|
426
|
-
if (!isTypeAlias && parent.kind !==
|
|
429
|
+
const isTypeAlias = parent.kind === 267 /* SyntaxKind.TypeAliasDeclaration */ || parent.kind === 346 /* SyntaxKind.JSTypeAliasDeclaration */;
|
|
430
|
+
if (!isTypeAlias && parent.kind !== 266 /* SyntaxKind.InterfaceDeclaration */ && !isClassLike(parent))
|
|
427
431
|
return;
|
|
428
432
|
const typeParameterSymbol = getSymbolOfDeclaration(c, node);
|
|
429
433
|
if (typeParameterSymbol === undefined)
|
|
@@ -437,7 +441,7 @@ export function checkTypeParameterDeferred(c, node) {
|
|
|
437
441
|
return;
|
|
438
442
|
if (isTypeAlias &&
|
|
439
443
|
(getDeclaredTypeOfSymbol(c, symbol).objectFlags & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */)) === 0)
|
|
440
|
-
c.error(node,
|
|
444
|
+
c.error(node, 787 /* Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types */);
|
|
441
445
|
else if (modifiers === 8192 /* ModifierFlags.In */ || modifiers === 16384 /* ModifierFlags.Out */) {
|
|
442
446
|
// The declared variance must hold between instantiations with marker sub- and supertypes.
|
|
443
447
|
const isOut = modifiers === 16384 /* ModifierFlags.Out */;
|
|
@@ -445,7 +449,7 @@ export function checkTypeParameterDeferred(c, node) {
|
|
|
445
449
|
const target = createMarkerType(c, symbol, typeParameter, isOut ? c.markerSuperTypeForCheck : c.markerSubTypeForCheck);
|
|
446
450
|
const saveVarianceTypeParameter = c.varianceTypeParameter;
|
|
447
451
|
c.varianceTypeParameter = typeParameter;
|
|
448
|
-
checkTypeAssignableTo(c, source, target, node,
|
|
452
|
+
checkTypeAssignableTo(c, source, target, node, 786 /* Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation */);
|
|
449
453
|
c.varianceTypeParameter = saveVarianceTypeParameter;
|
|
450
454
|
}
|
|
451
455
|
}
|
|
@@ -464,10 +468,10 @@ export function checkTypeParameters(c, list) {
|
|
|
464
468
|
finder.visitNode(node.defaultType);
|
|
465
469
|
}
|
|
466
470
|
else if (seenDefault)
|
|
467
|
-
c.error(node,
|
|
471
|
+
c.error(node, 845 /* Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters */);
|
|
468
472
|
for (let j = 0; j < i; j++)
|
|
469
473
|
if (getSymbol(typeParameters[j]) === getSymbol(node))
|
|
470
|
-
c.error(node.name,
|
|
474
|
+
c.error(node.name, 485 /* Diagnostics.Duplicate_identifier_0 */, declarationNameToString(getSourceFileOfNode(node), node.name));
|
|
471
475
|
}
|
|
472
476
|
}
|
|
473
477
|
/** Reports references in a type parameter default to the parameter itself or later ones. */
|
|
@@ -482,12 +486,12 @@ class LaterTypeParameterReferenceFinder extends NodeVisitor {
|
|
|
482
486
|
this.index = index;
|
|
483
487
|
}
|
|
484
488
|
visitNode(node) {
|
|
485
|
-
if (node.kind ===
|
|
489
|
+
if (node.kind === 185 /* SyntaxKind.TypeReference */) {
|
|
486
490
|
const t = getTypeFromTypeNode(this.c, node);
|
|
487
491
|
if ((t.flags & 524288 /* TypeFlags.TypeParameter */) !== 0)
|
|
488
492
|
for (let i = this.index; i < this.typeParameters.length; i++)
|
|
489
493
|
if (t.symbol === getSymbolOfDeclaration(this.c, this.typeParameters[i]))
|
|
490
|
-
this.c.error(node,
|
|
494
|
+
this.c.error(node, 883 /* Diagnostics.Type_parameter_defaults_can_only_reference_previously_declared_type_parameters */);
|
|
491
495
|
}
|
|
492
496
|
return node.forEachChild(this);
|
|
493
497
|
}
|
|
@@ -495,7 +499,7 @@ class LaterTypeParameterReferenceFinder extends NodeVisitor {
|
|
|
495
499
|
export function checkTypeAliasDeclaration(c, node) {
|
|
496
500
|
const alias = node;
|
|
497
501
|
const typeParameters = alias.typeParameters;
|
|
498
|
-
checkTypeNameIsReserved(c, alias.name,
|
|
502
|
+
checkTypeNameIsReserved(c, alias.name, 630 /* Diagnostics.Type_alias_name_cannot_be_0 */);
|
|
499
503
|
checkExportsOnMergedDeclarations(c, node);
|
|
500
504
|
checkTypeParameters(c, typeParameters);
|
|
501
505
|
if (alias.type.kind === 141 /* SyntaxKind.IntrinsicKeyword */) {
|
|
@@ -503,7 +507,7 @@ export function checkTypeAliasDeclaration(c, node) {
|
|
|
503
507
|
const count = typeParameters !== undefined ? typeParameters.nodes.length : 0;
|
|
504
508
|
if (!(count === 0 && name === 'BuiltinIteratorReturn') &&
|
|
505
509
|
!(count === 1 && intrinsicTypeKind(name) !== 0 /* IntrinsicTypeKind.Unknown */))
|
|
506
|
-
c.error(alias.type,
|
|
510
|
+
c.error(alias.type, 934 /* Diagnostics.The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types */);
|
|
507
511
|
}
|
|
508
512
|
else
|
|
509
513
|
checkSourceElement(c, alias.type);
|
|
@@ -530,7 +534,10 @@ export function checkTypeArgumentConstraintsOfReference(c, node, type) {
|
|
|
530
534
|
export function checkEnumMember(c, node) {
|
|
531
535
|
const name = getName(node);
|
|
532
536
|
if (name !== undefined && name.kind === 80 /* SyntaxKind.PrivateIdentifier */)
|
|
533
|
-
c.error(node,
|
|
537
|
+
c.error(node, 1862 /* Diagnostics.An_enum_member_cannot_be_named_with_a_private_identifier */);
|
|
538
|
+
// A computed name is a grammar error, but its expression is checked.
|
|
539
|
+
if (name !== undefined && name.kind === 169 /* SyntaxKind.ComputedPropertyName */)
|
|
540
|
+
checkExpression(c, getExpression(name));
|
|
534
541
|
const initializer = getInitializer(node);
|
|
535
542
|
if (initializer !== undefined)
|
|
536
543
|
checkExpression(c, initializer);
|
|
@@ -538,7 +545,7 @@ export function checkEnumMember(c, node) {
|
|
|
538
545
|
export function checkEnumDeclaration(c, node) {
|
|
539
546
|
const name = getName(node);
|
|
540
547
|
checkCollisionsForDeclarationName(c, node, name);
|
|
541
|
-
checkTypeNameIsReserved(c, name,
|
|
548
|
+
checkTypeNameIsReserved(c, name, 606 /* Diagnostics.Enum_name_cannot_be_0 */);
|
|
542
549
|
checkExportsOnMergedDeclarations(c, node);
|
|
543
550
|
for (const member of node.members.nodes)
|
|
544
551
|
checkSourceElement(c, member);
|
|
@@ -553,25 +560,33 @@ export function checkEnumDeclaration(c, node) {
|
|
|
553
560
|
return;
|
|
554
561
|
links.enumChecked = true;
|
|
555
562
|
if (declarationCount(symbol) > 1) {
|
|
556
|
-
|
|
563
|
+
// Reported against the first enum declaration, whichever declaration is checked first.
|
|
564
|
+
const enumIsConst = isEnumConst(getDeclarationOfKind(symbol, 268 /* SyntaxKind.EnumDeclaration */));
|
|
557
565
|
for (const d of getDeclarations(symbol))
|
|
558
|
-
if (d.kind ===
|
|
559
|
-
c.error(getNameOfDeclaration(d),
|
|
566
|
+
if (d.kind === 268 /* SyntaxKind.EnumDeclaration */ && isEnumConst(d) !== enumIsConst)
|
|
567
|
+
c.error(getNameOfDeclaration(d), 644 /* Diagnostics.Enum_declarations_must_all_be_const_or_non_const */);
|
|
560
568
|
}
|
|
561
569
|
// Only one declaration of a merged enum may continue automatic numbering from zero.
|
|
562
570
|
let seenEnumMissingInitialInitializer = false;
|
|
563
571
|
for (const d of getDeclarations(symbol)) {
|
|
564
|
-
if (d.kind !==
|
|
572
|
+
if (d.kind !== 268 /* SyntaxKind.EnumDeclaration */)
|
|
565
573
|
continue;
|
|
566
574
|
const members = d.members.nodes;
|
|
567
575
|
if (members.length === 0 || getInitializer(members[0]) !== undefined)
|
|
568
576
|
continue;
|
|
569
577
|
if (seenEnumMissingInitialInitializer)
|
|
570
|
-
c.error(getName(members[0]),
|
|
578
|
+
c.error(getName(members[0]), 607 /* Diagnostics.In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element */);
|
|
571
579
|
else
|
|
572
580
|
seenEnumMissingInitialInitializer = true;
|
|
573
581
|
}
|
|
574
582
|
}
|
|
583
|
+
/** An ambient module's import attributes type must be assignable to the global `ImportAttributes`. */
|
|
584
|
+
function checkImportAttributesType(c, attributes) {
|
|
585
|
+
checkSourceElement(c, attributes);
|
|
586
|
+
const importAttributesType = getCachedGlobalType(c, 'ImportAttributes', 0, true);
|
|
587
|
+
if (importAttributesType !== c.emptyObjectType)
|
|
588
|
+
checkTypeAssignableTo(c, getTypeFromTypeNode(c, attributes), importAttributesType, attributes, undefined);
|
|
589
|
+
}
|
|
575
590
|
/** Whether erasableSyntaxOnly applies at `node`: it is set, and `node` is in a TypeScript file. */
|
|
576
591
|
export function shouldCheckErasableSyntax(c, node) {
|
|
577
592
|
return c.compilerOptions.erasableSyntaxOnly === true && !isInJSFile(node);
|
|
@@ -584,7 +599,10 @@ export function checkModuleDeclaration(c, node) {
|
|
|
584
599
|
const isGlobalAugmentation = isGlobalScopeAugmentation(node);
|
|
585
600
|
const inAmbientContext = (node.flags & 8388608 /* NodeFlags.Ambient */) !== 0;
|
|
586
601
|
if (isGlobalAugmentation && !inAmbientContext)
|
|
587
|
-
c.error(module.name,
|
|
602
|
+
c.error(module.name, 811 /* Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context */);
|
|
603
|
+
const attributes = module.attributes;
|
|
604
|
+
if (attributes !== undefined)
|
|
605
|
+
checkImportAttributesType(c, attributes);
|
|
588
606
|
const contextMessage = isAmbientModule(node)
|
|
589
607
|
? 184 /* Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file */
|
|
590
608
|
: 185 /* Diagnostics.A_namespace_declaration_is_only_allowed_at_the_top_level_of_a_namespace_or_module */;
|
|
@@ -593,7 +611,7 @@ export function checkModuleDeclaration(c, node) {
|
|
|
593
611
|
if (module.name.kind === 79 /* SyntaxKind.Identifier */)
|
|
594
612
|
checkCollisionsForDeclarationName(c, node, module.name);
|
|
595
613
|
if (module.name.kind === 79 /* SyntaxKind.Identifier */ && module.keyword === 144 /* SyntaxKind.ModuleKeyword */)
|
|
596
|
-
c.error(module.name,
|
|
614
|
+
c.error(module.name, 453 /* Diagnostics.A_namespace_declaration_should_not_be_declared_using_the_module_keyword_Please_use_the_namespace_keyword_instead */);
|
|
597
615
|
checkExportsOnMergedDeclarations(c, node);
|
|
598
616
|
const symbol = getSymbolOfDeclaration(c, node);
|
|
599
617
|
// Only non-ambient instantiated namespaces.
|
|
@@ -610,13 +628,13 @@ export function checkModuleDeclaration(c, node) {
|
|
|
610
628
|
const classOrFunction = getFirstNonAmbientClassOrFunctionDeclaration(symbol);
|
|
611
629
|
if (classOrFunction !== undefined) {
|
|
612
630
|
if (getSourceFileOfNode(node) !== getSourceFileOfNode(classOrFunction))
|
|
613
|
-
c.error(module.name,
|
|
631
|
+
c.error(module.name, 608 /* Diagnostics.A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged */);
|
|
614
632
|
else if (node.pos < classOrFunction.pos)
|
|
615
|
-
c.error(module.name,
|
|
633
|
+
c.error(module.name, 609 /* Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged */);
|
|
616
634
|
}
|
|
617
635
|
}
|
|
618
636
|
if (c.compilerOptions.verbatimModuleSyntax === true &&
|
|
619
|
-
node.parent.kind ===
|
|
637
|
+
node.parent.kind === 308 /* SyntaxKind.SourceFile */ &&
|
|
620
638
|
hasSyntacticModifier(node, 32 /* ModifierFlags.Export */) &&
|
|
621
639
|
c.host.getEmitModuleFormatOfFile(node.parent) === ModuleKind.CommonJS) {
|
|
622
640
|
const exportModifier = getModifiers(node).nodes.find((m) => m.kind === 94 /* SyntaxKind.ExportKeyword */);
|
|
@@ -626,22 +644,24 @@ export function checkModuleDeclaration(c, node) {
|
|
|
626
644
|
if (!isAmbientModule(node))
|
|
627
645
|
return;
|
|
628
646
|
if (isModuleAugmentationExternal(node)) {
|
|
647
|
+
if (attributes !== undefined)
|
|
648
|
+
c.error(attributes, 464 /* Diagnostics.Import_attributes_are_not_allowed_on_a_module_augmentation */);
|
|
629
649
|
// Check an augmentation's body only when it merged with its target.
|
|
630
650
|
const checkBody = isGlobalAugmentation || (symbol !== undefined && (symbol.flags & 33554432 /* SymbolFlags.Transient */) !== 0);
|
|
631
|
-
if (checkBody && body !== undefined && body.kind ===
|
|
651
|
+
if (checkBody && body !== undefined && body.kind === 270 /* SyntaxKind.ModuleBlock */)
|
|
632
652
|
for (const statement of getStatements(body).nodes)
|
|
633
653
|
checkModuleAugmentationElement(c, statement);
|
|
634
654
|
return;
|
|
635
655
|
}
|
|
636
656
|
const parent = node.parent;
|
|
637
657
|
if (isGlobalAugmentation)
|
|
638
|
-
c.error(module.name,
|
|
639
|
-
else if (parent.kind ===
|
|
658
|
+
c.error(module.name, 810 /* Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations */);
|
|
659
|
+
else if (parent.kind === 308 /* SyntaxKind.SourceFile */ && !isExternalModule(parent)) {
|
|
640
660
|
if (isExternalModuleNameRelative(getText(module.name)))
|
|
641
|
-
c.error(module.name,
|
|
661
|
+
c.error(module.name, 611 /* Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name */);
|
|
642
662
|
}
|
|
643
663
|
else
|
|
644
|
-
c.error(module.name,
|
|
664
|
+
c.error(module.name, 610 /* Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces */);
|
|
645
665
|
}
|
|
646
666
|
export function isInstantiatedModule(node, preserveConstEnums) {
|
|
647
667
|
const state = getModuleInstanceState(node);
|
|
@@ -649,31 +669,31 @@ export function isInstantiatedModule(node, preserveConstEnums) {
|
|
|
649
669
|
}
|
|
650
670
|
function getFirstNonAmbientClassOrFunctionDeclaration(symbol) {
|
|
651
671
|
for (const d of getDeclarations(symbol))
|
|
652
|
-
if ((d.kind ===
|
|
653
|
-
(d.kind ===
|
|
672
|
+
if ((d.kind === 265 /* SyntaxKind.ClassDeclaration */ ||
|
|
673
|
+
(d.kind === 264 /* SyntaxKind.FunctionDeclaration */ && nodeIsPresent(getBody(d)))) &&
|
|
654
674
|
(d.flags & 8388608 /* NodeFlags.Ambient */) === 0)
|
|
655
675
|
return d;
|
|
656
676
|
return undefined;
|
|
657
677
|
}
|
|
658
678
|
function checkModuleAugmentationElement(c, node) {
|
|
659
679
|
switch (node.kind) {
|
|
660
|
-
case
|
|
680
|
+
case 245 /* SyntaxKind.VariableStatement */:
|
|
661
681
|
// Each name, rather than the whole statement.
|
|
662
682
|
for (const d of node.declarationList.declarations.nodes)
|
|
663
683
|
checkModuleAugmentationElement(c, d);
|
|
664
684
|
return;
|
|
665
|
-
case
|
|
666
|
-
case
|
|
667
|
-
grammarErrorOnFirstToken(c, node,
|
|
685
|
+
case 279 /* SyntaxKind.ExportAssignment */:
|
|
686
|
+
case 280 /* SyntaxKind.ExportDeclaration */:
|
|
687
|
+
grammarErrorOnFirstToken(c, node, 807 /* Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations */);
|
|
668
688
|
return;
|
|
669
|
-
case
|
|
689
|
+
case 273 /* SyntaxKind.ImportEqualsDeclaration */:
|
|
670
690
|
// `import a = e.x` is allowed; `import a = require("m")` isn't.
|
|
671
|
-
if (node.moduleReference.kind !==
|
|
691
|
+
if (node.moduleReference.kind !== 285 /* SyntaxKind.ExternalModuleReference */)
|
|
672
692
|
return;
|
|
673
|
-
grammarErrorOnFirstToken(c, node,
|
|
693
|
+
grammarErrorOnFirstToken(c, node, 808 /* Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module */);
|
|
674
694
|
return;
|
|
675
|
-
case
|
|
676
|
-
grammarErrorOnFirstToken(c, node,
|
|
695
|
+
case 274 /* SyntaxKind.ImportDeclaration */:
|
|
696
|
+
grammarErrorOnFirstToken(c, node, 808 /* Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module */);
|
|
677
697
|
return;
|
|
678
698
|
}
|
|
679
699
|
}
|
|
@@ -692,7 +712,7 @@ function grammarErrorOnFirstToken(c, node, message) {
|
|
|
692
712
|
*/
|
|
693
713
|
function checkModuleElementContext(c, node, message) {
|
|
694
714
|
const parent = node.parent.kind;
|
|
695
|
-
if (parent ===
|
|
715
|
+
if (parent === 308 /* SyntaxKind.SourceFile */ || parent === 270 /* SyntaxKind.ModuleBlock */ || parent === 269 /* SyntaxKind.ModuleDeclaration */)
|
|
696
716
|
return false;
|
|
697
717
|
grammarErrorOnFirstToken(c, node, message);
|
|
698
718
|
return true;
|
|
@@ -712,7 +732,7 @@ export function checkExternalModuleExports(c, node) {
|
|
|
712
732
|
(hasExportedMembersOfKind(c, moduleSymbol, 111551 /* SymbolFlags.Value */) || hasShadowedNamespace(c, exportEquals))) {
|
|
713
733
|
const declaration = getDeclarationOfAliasSymbol(exportEquals) ?? exportEquals.valueDeclaration;
|
|
714
734
|
if (declaration !== undefined && !isTopLevelInExternalModuleAugmentation(declaration))
|
|
715
|
-
c.error(declaration,
|
|
735
|
+
c.error(declaration, 494 /* Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements */);
|
|
716
736
|
}
|
|
717
737
|
for (const [id, symbol] of getExportsOfModule(c, moduleSymbol)) {
|
|
718
738
|
// Namespaces, enums, interfaces and overloads may have several declarations.
|
|
@@ -720,7 +740,7 @@ export function checkExternalModuleExports(c, node) {
|
|
|
720
740
|
continue;
|
|
721
741
|
let count = 0;
|
|
722
742
|
for (const d of getDeclarations(symbol))
|
|
723
|
-
if (isNotOverload(d) && !isAccessorDeclaration(d) && d.kind !==
|
|
743
|
+
if (isNotOverload(d) && !isAccessorDeclaration(d) && d.kind !== 266 /* SyntaxKind.InterfaceDeclaration */)
|
|
724
744
|
count++;
|
|
725
745
|
// A type alias may merge with one value.
|
|
726
746
|
if ((symbol.flags & 524288 /* SymbolFlags.TypeAlias */) !== 0 && count <= 2)
|
|
@@ -735,7 +755,7 @@ export function checkExternalModuleExports(c, node) {
|
|
|
735
755
|
continue;
|
|
736
756
|
for (const d of getDeclarations(symbol))
|
|
737
757
|
if (isNotOverload(d))
|
|
738
|
-
c.error(d,
|
|
758
|
+
c.error(d, 508 /* Diagnostics.Cannot_redeclare_exported_variable_0 */, id);
|
|
739
759
|
}
|
|
740
760
|
}
|
|
741
761
|
function hasExportedMembersOfKind(c, moduleSymbol, kind) {
|
|
@@ -754,15 +774,15 @@ function hasShadowedNamespace(c, symbol) {
|
|
|
754
774
|
hasExportedMembersOfKind(c, target, 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */));
|
|
755
775
|
}
|
|
756
776
|
function isNotOverload(node) {
|
|
757
|
-
return ((node.kind !==
|
|
777
|
+
return ((node.kind !== 264 /* SyntaxKind.FunctionDeclaration */ && node.kind !== 176 /* SyntaxKind.MethodDeclaration */) ||
|
|
758
778
|
getBody(node) !== undefined);
|
|
759
779
|
}
|
|
760
780
|
function isAccessorDeclaration(node) {
|
|
761
|
-
return node.kind ===
|
|
781
|
+
return node.kind === 179 /* SyntaxKind.GetAccessor */ || node.kind === 180 /* SyntaxKind.SetAccessor */;
|
|
762
782
|
}
|
|
763
783
|
function isTopLevelInExternalModuleAugmentation(node) {
|
|
764
784
|
const parent = node.parent;
|
|
765
|
-
if (parent === undefined || parent.kind !==
|
|
785
|
+
if (parent === undefined || parent.kind !== 270 /* SyntaxKind.ModuleBlock */)
|
|
766
786
|
return false;
|
|
767
787
|
const module = parent.parent;
|
|
768
788
|
return isAmbientModule(module) && isModuleAugmentationExternal(module);
|
|
@@ -775,8 +795,12 @@ export function checkExportsOnMergedDeclarations(c, node) {
|
|
|
775
795
|
if (symbol === undefined || symbol.exportSymbol === undefined)
|
|
776
796
|
return;
|
|
777
797
|
}
|
|
778
|
-
if (
|
|
798
|
+
if (declarationCount(symbol) < 2)
|
|
799
|
+
return;
|
|
800
|
+
const links = c.symbolLinks(symbol);
|
|
801
|
+
if (links.mergedExportsChecked)
|
|
779
802
|
return;
|
|
803
|
+
links.mergedExportsChecked = true;
|
|
780
804
|
let exported = 0 /* DeclarationSpaces.None */;
|
|
781
805
|
let nonExported = 0 /* DeclarationSpaces.None */;
|
|
782
806
|
let defaultExported = 0 /* DeclarationSpaces.None */;
|
|
@@ -802,28 +826,28 @@ export function checkExportsOnMergedDeclarations(c, node) {
|
|
|
802
826
|
const name = getNameOfDeclaration(d);
|
|
803
827
|
const text = declarationNameToString(getSourceFileOfNode(d), name);
|
|
804
828
|
if ((spaces & commonForDefaultAndNonDefault) !== 0)
|
|
805
|
-
c.error(name,
|
|
829
|
+
c.error(name, 793 /* Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead */, text);
|
|
806
830
|
else if ((spaces & commonForExportsAndLocals) !== 0)
|
|
807
|
-
c.error(name,
|
|
831
|
+
c.error(name, 573 /* Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local */, text);
|
|
808
832
|
}
|
|
809
833
|
}
|
|
810
834
|
function getDeclarationSpaces(c, node) {
|
|
811
835
|
switch (node.kind) {
|
|
812
|
-
case
|
|
813
|
-
case
|
|
814
|
-
case
|
|
836
|
+
case 266 /* SyntaxKind.InterfaceDeclaration */:
|
|
837
|
+
case 267 /* SyntaxKind.TypeAliasDeclaration */:
|
|
838
|
+
case 346 /* SyntaxKind.JSTypeAliasDeclaration */:
|
|
815
839
|
return 2 /* DeclarationSpaces.ExportType */;
|
|
816
|
-
case
|
|
840
|
+
case 269 /* SyntaxKind.ModuleDeclaration */:
|
|
817
841
|
return isAmbientModule(node) || getModuleInstanceState(node) !== 1 /* ModuleInstanceState.NonInstantiated */
|
|
818
842
|
? 4 /* DeclarationSpaces.ExportNamespace */ | 1 /* DeclarationSpaces.ExportValue */
|
|
819
843
|
: 4 /* DeclarationSpaces.ExportNamespace */;
|
|
820
|
-
case
|
|
821
|
-
case
|
|
822
|
-
case
|
|
844
|
+
case 265 /* SyntaxKind.ClassDeclaration */:
|
|
845
|
+
case 268 /* SyntaxKind.EnumDeclaration */:
|
|
846
|
+
case 307 /* SyntaxKind.EnumMember */:
|
|
823
847
|
return 2 /* DeclarationSpaces.ExportType */ | 1 /* DeclarationSpaces.ExportValue */;
|
|
824
|
-
case
|
|
848
|
+
case 308 /* SyntaxKind.SourceFile */:
|
|
825
849
|
return 2 /* DeclarationSpaces.ExportType */ | 1 /* DeclarationSpaces.ExportValue */ | 4 /* DeclarationSpaces.ExportNamespace */;
|
|
826
|
-
case
|
|
850
|
+
case 279 /* SyntaxKind.ExportAssignment */: {
|
|
827
851
|
const expression = getExpression(node);
|
|
828
852
|
const symbol = getSymbolOfDeclaration(c, node);
|
|
829
853
|
if (!isEntityNameExpression(expression, false) ||
|
|
@@ -832,12 +856,12 @@ function getDeclarationSpaces(c, node) {
|
|
|
832
856
|
return 1 /* DeclarationSpaces.ExportValue */;
|
|
833
857
|
return getAliasDeclarationSpaces(c, node);
|
|
834
858
|
}
|
|
835
|
-
case
|
|
836
|
-
case
|
|
837
|
-
case
|
|
859
|
+
case 273 /* SyntaxKind.ImportEqualsDeclaration */:
|
|
860
|
+
case 276 /* SyntaxKind.NamespaceImport */:
|
|
861
|
+
case 275 /* SyntaxKind.ImportClause */:
|
|
838
862
|
return getAliasDeclarationSpaces(c, node);
|
|
839
|
-
case
|
|
840
|
-
case
|
|
863
|
+
case 175 /* SyntaxKind.MethodSignature */:
|
|
864
|
+
case 173 /* SyntaxKind.PropertySignature */:
|
|
841
865
|
return 2 /* DeclarationSpaces.ExportType */;
|
|
842
866
|
}
|
|
843
867
|
return 1 /* DeclarationSpaces.ExportValue */;
|
|
@@ -854,9 +878,9 @@ function getAliasDeclarationSpaces(c, node) {
|
|
|
854
878
|
export function getEffectiveDeclarationFlags(node, flagsToCheck) {
|
|
855
879
|
let flags = getCombinedModifierFlags(node);
|
|
856
880
|
const parent = node.parent;
|
|
857
|
-
if (parent.kind !==
|
|
858
|
-
parent.kind !==
|
|
859
|
-
parent.kind !==
|
|
881
|
+
if (parent.kind !== 266 /* SyntaxKind.InterfaceDeclaration */ &&
|
|
882
|
+
parent.kind !== 265 /* SyntaxKind.ClassDeclaration */ &&
|
|
883
|
+
parent.kind !== 233 /* SyntaxKind.ClassExpression */ &&
|
|
860
884
|
(node.flags & 8388608 /* NodeFlags.Ambient */) !== 0) {
|
|
861
885
|
let container = node.parent;
|
|
862
886
|
while (container !== undefined && (getContainerFlags(container) & 1 /* ContainerFlags.IsContainer */) === 0)
|
|
@@ -864,7 +888,7 @@ export function getEffectiveDeclarationFlags(node, flagsToCheck) {
|
|
|
864
888
|
if (container !== undefined &&
|
|
865
889
|
(container.flags & 64 /* NodeFlags.ExportContext */) !== 0 &&
|
|
866
890
|
(flags & 128 /* ModifierFlags.Ambient */) === 0 &&
|
|
867
|
-
!(parent.kind ===
|
|
891
|
+
!(parent.kind === 270 /* SyntaxKind.ModuleBlock */ && isGlobalScopeAugmentation(parent.parent)))
|
|
868
892
|
flags |= 32 /* ModifierFlags.Export */;
|
|
869
893
|
flags |= 128 /* ModifierFlags.Ambient */;
|
|
870
894
|
}
|
|
@@ -879,10 +903,10 @@ export function checkUnusedRenamedBindingElements(c) {
|
|
|
879
903
|
const file = getSourceFileOfNode(element);
|
|
880
904
|
const name = element.name;
|
|
881
905
|
const propertyName = declarationNameToString(file, element.propertyName);
|
|
882
|
-
const diagnostic = c.error(name,
|
|
906
|
+
const diagnostic = c.error(name, 970 /* Diagnostics.X_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation */, declarationNameToString(file, name), propertyName);
|
|
883
907
|
const parameter = getRootDeclaration(element);
|
|
884
908
|
if (getType(parameter) === undefined)
|
|
885
|
-
diagnostic.addRelatedInfo(new Diagnostic(file.diagnosticFile(), parameter.end, parameter.end,
|
|
909
|
+
diagnostic.addRelatedInfo(new Diagnostic(file.diagnosticFile(), parameter.end, parameter.end, 971 /* Diagnostics.We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here */, [propertyName]));
|
|
886
910
|
}
|
|
887
911
|
c.renamedBindingElementsInTypes.length = 0;
|
|
888
912
|
}
|