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
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
// - grammar: checker-grammar.ts (checks the parser leaves to the checker)
|
|
11
11
|
// - type nodes: `checkTypeNode` below
|
|
12
12
|
import { checkPendingExternalEmitHelpers } from './checker-emit-helpers.js';
|
|
13
|
-
import { produceDeferredCollisionChecks } from './checker-generated-code.js';
|
|
14
13
|
import { resolveUntypedCall } from './checker-calls.js';
|
|
15
14
|
import { NodeVisitor, getComment, getElements, getExpression, getName, getParameters, getText, getNodeId, getStatements, getType, getTypeParameters, getHeritageClauses, getFlowNode, } from './ast.js';
|
|
16
15
|
import { getSourceFileOfNode, isEnumConst, isExternalOrCommonJSModule, isPotentiallyExecutableNode, } from './binder-utilities.js';
|
|
@@ -23,23 +22,22 @@ import { nodeIsMissing } from './ast-utilities.js';
|
|
|
23
22
|
import { getAttachedJSDoc } from './parser.js';
|
|
24
23
|
import { shouldPreserveConstEnums } from './options.js';
|
|
25
24
|
import { isReachableFlowNode } from './checker-narrowing.js';
|
|
26
|
-
import { getTupleElementFlags, getTypeFromIndexedAccessTypeNode, getTypeFromTypeNode } from './checker-type-nodes.js';
|
|
25
|
+
import { getTupleElementFlags, getTypeFromIndexedAccessTypeNode, getTypeFromTypeNode, isAssertionExpression, } from './checker-type-nodes.js';
|
|
27
26
|
import { isArrayLikeType } from './checker-members.js';
|
|
28
27
|
import { checkBlock, checkDoStatement, checkExpressionStatement, checkForInStatement, checkForOfStatement, checkForStatement, checkIfStatement, checkLabeledStatement, checkReturnStatement, checkSwitchStatement, checkThrowStatement, checkTryStatement, checkWhileStatement, } from './checker-statements.js';
|
|
29
28
|
import { checkEnumDeclaration, checkEnumMember, checkExternalModuleExports, checkFunctionDeclaration, checkModuleDeclaration, checkTypeAliasDeclaration, checkTypeArgumentConstraintsOfReference, checkTypeParameter, checkTypeParameterDeferred, checkTypeParameters, checkVariableStatement, checkVariableLikeDeclaration, checkUnusedRenamedBindingElements, isInstantiatedModule, } from './checker-declarations.js';
|
|
30
|
-
import { checkExportAssignment, checkExportDeclaration, checkImportDeclaration, checkImportEqualsDeclaration, resolveJSDocMemberName, } from './checker-modules.js';
|
|
29
|
+
import { checkExportAssignment, checkExportDeclaration, checkImportAttributes, checkImportDeclaration, checkImportEqualsDeclaration, resolveJSDocMemberName, } from './checker-modules.js';
|
|
31
30
|
import { checkAccessorDeclaration, checkClassDeclaration, checkClassLikeDeferred, checkInterfaceDeclaration, } from './checker-classes.js';
|
|
32
31
|
import { checkJsxElementDeferred } from './checker-jsx.js';
|
|
33
|
-
import { checkAssertionDeferred, checkComputedPropertyName, checkExpression, checkIndexedAccessIndexType, } from './checker-expressions.js';
|
|
32
|
+
import { checkAssertionDeferred, checkComputedPropertyName, checkExpression, checkIndexedAccessIndexType, isConstTypeReference, } from './checker-expressions.js';
|
|
34
33
|
import { checkFunctionLikeBody } from './checker-functions.js';
|
|
35
|
-
import { produceDeferredIterationErrors } from './checker-iteration.js';
|
|
36
34
|
import { checkFunctionOrMethodSymbols } from './checker-overloads.js';
|
|
37
35
|
import { checkInferTypeParameterDeclarations, checkTypeLiteralMembers } from './checker-heritage.js';
|
|
38
36
|
import { checkGrammarSourceFile } from './checker-grammar.js';
|
|
39
37
|
import { getTypeOfSymbol, reportImplicitAny } from './checker-symbol-types.js';
|
|
40
38
|
import { getSymbolOfDeclaration } from './checker-symbols.js';
|
|
41
39
|
import { checkUnusedIdentifiers } from './checker-unused.js';
|
|
42
|
-
import { checkDeprecatedTypeReference } from './checker-deprecation.js';
|
|
40
|
+
import { checkContextualDeprecations, checkDeprecatedTypeReference } from './checker-deprecation.js';
|
|
43
41
|
/**
|
|
44
42
|
* Checks `file` once; diagnostics accumulate in the checker. `checkUnused` also reports unused
|
|
45
43
|
* identifiers, which need the whole file checked first.
|
|
@@ -57,7 +55,6 @@ export function checkSourceFile(c, file, checkUnused = false) {
|
|
|
57
55
|
}
|
|
58
56
|
function checkSourceFileWorker(c, file) {
|
|
59
57
|
c.fileBeingChecked = file;
|
|
60
|
-
c.saveDeferredDiagnostics = true;
|
|
61
58
|
for (const statement of getStatements(file).nodes)
|
|
62
59
|
checkSourceElement(c, statement);
|
|
63
60
|
checkDeferredNodes(c, file);
|
|
@@ -73,9 +70,7 @@ function checkSourceFileWorker(c, file) {
|
|
|
73
70
|
checkDeferredNodes(c, file);
|
|
74
71
|
checkPendingExternalEmitHelpers(c, file);
|
|
75
72
|
c.fileBeingChecked = undefined;
|
|
76
|
-
c
|
|
77
|
-
produceDeferredIterationErrors(c);
|
|
78
|
-
produceDeferredCollisionChecks(c);
|
|
73
|
+
produceDeferredDiagnostics(c);
|
|
79
74
|
// The file's deferred nodes are all checked; later ones are not queued (checkNodeDeferred).
|
|
80
75
|
const links = c.nodeLinks(file);
|
|
81
76
|
links.typeChecked = true;
|
|
@@ -95,7 +90,6 @@ function checkSourceFileWorker(c, file) {
|
|
|
95
90
|
export function checkSourceFileRange(c, file, start, end) {
|
|
96
91
|
const statements = getStatements(file).nodes;
|
|
97
92
|
c.fileBeingChecked = file;
|
|
98
|
-
c.saveDeferredDiagnostics = true;
|
|
99
93
|
for (let i = start; i < end; i++)
|
|
100
94
|
checkSourceElement(c, statements[i]);
|
|
101
95
|
checkDeferredNodes(c, file);
|
|
@@ -109,13 +103,24 @@ export function checkSourceFileRange(c, file, start, end) {
|
|
|
109
103
|
checkPendingExternalEmitHelpers(c, file);
|
|
110
104
|
}
|
|
111
105
|
c.fileBeingChecked = undefined;
|
|
112
|
-
c
|
|
113
|
-
produceDeferredIterationErrors(c);
|
|
114
|
-
produceDeferredCollisionChecks(c);
|
|
106
|
+
produceDeferredDiagnostics(c);
|
|
115
107
|
// Deferred nodes of a later range are queued again (checkNodeDeferred).
|
|
116
108
|
c.nodeLinks(file).deferredNodes = undefined;
|
|
117
109
|
return c.diagnostics.forFile(file.fileName).length > 0;
|
|
118
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Reports the deferred diagnostics, in the order they were deferred. Diagnostics deferred while they
|
|
113
|
+
* are reported are dropped.
|
|
114
|
+
*/
|
|
115
|
+
export function produceDeferredDiagnostics(c) {
|
|
116
|
+
const callbacks = c.deferredDiagnostics;
|
|
117
|
+
if (callbacks.length === 0)
|
|
118
|
+
return;
|
|
119
|
+
const count = callbacks.length;
|
|
120
|
+
for (let i = 0; i < count; i++)
|
|
121
|
+
callbacks[i]();
|
|
122
|
+
c.deferredDiagnostics = [];
|
|
123
|
+
}
|
|
119
124
|
/** Checks a statement, declaration, class member or type node. */
|
|
120
125
|
export function checkSourceElement(c, node) {
|
|
121
126
|
if (node === undefined)
|
|
@@ -154,16 +159,16 @@ function checkSourceElementUnreachable(c, node) {
|
|
|
154
159
|
}
|
|
155
160
|
// A missing statement starts where it ends, before the trivia of the next token.
|
|
156
161
|
const start = nodeIsMissing(node) ? node.pos : skipTrivia(file.text, node.pos);
|
|
157
|
-
const diagnostic = new Diagnostic(file.diagnosticFile(), start, endNode.end,
|
|
162
|
+
const diagnostic = new Diagnostic(file.diagnosticFile(), start, endNode.end, 1717 /* Diagnostics.Unreachable_code_detected */, []);
|
|
158
163
|
c.addErrorOrSuggestion(c.compilerOptions.allowUnreachableCode === false, diagnostic);
|
|
159
164
|
return true;
|
|
160
165
|
}
|
|
161
166
|
function isSourceElementUnreachable(c, node) {
|
|
162
167
|
if ((node.flags & 134217728 /* NodeFlags.Unreachable */) !== 0) {
|
|
163
168
|
// The binder knows the code is unreachable; const enums only count when preserved.
|
|
164
|
-
if (node.kind ===
|
|
169
|
+
if (node.kind === 268 /* SyntaxKind.EnumDeclaration */)
|
|
165
170
|
return !isEnumConst(node) || shouldPreserveConstEnums(c.compilerOptions);
|
|
166
|
-
if (node.kind ===
|
|
171
|
+
if (node.kind === 269 /* SyntaxKind.ModuleDeclaration */)
|
|
167
172
|
return isInstantiatedModule(node, shouldPreserveConstEnums(c.compilerOptions));
|
|
168
173
|
return true;
|
|
169
174
|
}
|
|
@@ -186,98 +191,98 @@ function checkSourceElementWorker(c, node) {
|
|
|
186
191
|
c.withinUnreachableCode = true;
|
|
187
192
|
switch (node.kind) {
|
|
188
193
|
// Statements
|
|
189
|
-
case
|
|
190
|
-
case
|
|
194
|
+
case 243 /* SyntaxKind.Block */:
|
|
195
|
+
case 270 /* SyntaxKind.ModuleBlock */:
|
|
191
196
|
checkBlock(c, node);
|
|
192
197
|
return;
|
|
193
|
-
case
|
|
194
|
-
case
|
|
195
|
-
case
|
|
196
|
-
case
|
|
198
|
+
case 244 /* SyntaxKind.EmptyStatement */:
|
|
199
|
+
case 261 /* SyntaxKind.DebuggerStatement */:
|
|
200
|
+
case 254 /* SyntaxKind.BreakStatement */:
|
|
201
|
+
case 253 /* SyntaxKind.ContinueStatement */:
|
|
197
202
|
return;
|
|
198
|
-
case
|
|
203
|
+
case 245 /* SyntaxKind.VariableStatement */:
|
|
199
204
|
checkVariableStatement(c, node);
|
|
200
205
|
return;
|
|
201
|
-
case
|
|
206
|
+
case 246 /* SyntaxKind.ExpressionStatement */:
|
|
202
207
|
checkExpressionStatement(c, node);
|
|
203
208
|
return;
|
|
204
|
-
case
|
|
209
|
+
case 247 /* SyntaxKind.IfStatement */:
|
|
205
210
|
checkIfStatement(c, node);
|
|
206
211
|
return;
|
|
207
|
-
case
|
|
212
|
+
case 248 /* SyntaxKind.DoStatement */:
|
|
208
213
|
checkDoStatement(c, node);
|
|
209
214
|
return;
|
|
210
|
-
case
|
|
215
|
+
case 249 /* SyntaxKind.WhileStatement */:
|
|
211
216
|
checkWhileStatement(c, node);
|
|
212
217
|
return;
|
|
213
|
-
case
|
|
218
|
+
case 250 /* SyntaxKind.ForStatement */:
|
|
214
219
|
checkForStatement(c, node);
|
|
215
220
|
return;
|
|
216
|
-
case
|
|
221
|
+
case 251 /* SyntaxKind.ForInStatement */:
|
|
217
222
|
checkForInStatement(c, node);
|
|
218
223
|
return;
|
|
219
|
-
case
|
|
224
|
+
case 252 /* SyntaxKind.ForOfStatement */:
|
|
220
225
|
checkForOfStatement(c, node);
|
|
221
226
|
return;
|
|
222
|
-
case
|
|
227
|
+
case 255 /* SyntaxKind.ReturnStatement */:
|
|
223
228
|
checkReturnStatement(c, node);
|
|
224
229
|
return;
|
|
225
|
-
case
|
|
230
|
+
case 257 /* SyntaxKind.SwitchStatement */:
|
|
226
231
|
checkSwitchStatement(c, node);
|
|
227
232
|
return;
|
|
228
|
-
case
|
|
233
|
+
case 258 /* SyntaxKind.LabeledStatement */:
|
|
229
234
|
checkLabeledStatement(c, node);
|
|
230
235
|
return;
|
|
231
|
-
case
|
|
236
|
+
case 259 /* SyntaxKind.ThrowStatement */:
|
|
232
237
|
checkThrowStatement(c, node);
|
|
233
238
|
return;
|
|
234
|
-
case
|
|
239
|
+
case 260 /* SyntaxKind.TryStatement */:
|
|
235
240
|
checkTryStatement(c, node);
|
|
236
241
|
return;
|
|
237
|
-
case
|
|
242
|
+
case 256 /* SyntaxKind.WithStatement */:
|
|
238
243
|
// The body isn't checked: every name in it has type `any`.
|
|
239
244
|
checkExpression(c, getExpression(node));
|
|
240
245
|
return;
|
|
241
246
|
// Declarations
|
|
242
|
-
case
|
|
247
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
243
248
|
checkFunctionDeclaration(c, node);
|
|
244
249
|
return;
|
|
245
|
-
case
|
|
250
|
+
case 265 /* SyntaxKind.ClassDeclaration */:
|
|
246
251
|
checkClassDeclaration(c, node);
|
|
247
252
|
return;
|
|
248
|
-
case
|
|
253
|
+
case 266 /* SyntaxKind.InterfaceDeclaration */:
|
|
249
254
|
checkInterfaceDeclaration(c, node);
|
|
250
255
|
return;
|
|
251
|
-
case
|
|
252
|
-
case
|
|
256
|
+
case 267 /* SyntaxKind.TypeAliasDeclaration */:
|
|
257
|
+
case 346 /* SyntaxKind.JSTypeAliasDeclaration */:
|
|
253
258
|
checkTypeAliasDeclaration(c, node);
|
|
254
259
|
return;
|
|
255
|
-
case
|
|
260
|
+
case 268 /* SyntaxKind.EnumDeclaration */:
|
|
256
261
|
checkEnumDeclaration(c, node);
|
|
257
262
|
return;
|
|
258
|
-
case
|
|
263
|
+
case 307 /* SyntaxKind.EnumMember */:
|
|
259
264
|
checkEnumMember(c, node);
|
|
260
265
|
return;
|
|
261
|
-
case
|
|
266
|
+
case 269 /* SyntaxKind.ModuleDeclaration */:
|
|
262
267
|
checkModuleDeclaration(c, node);
|
|
263
268
|
return;
|
|
264
|
-
case
|
|
265
|
-
case
|
|
269
|
+
case 274 /* SyntaxKind.ImportDeclaration */:
|
|
270
|
+
case 347 /* SyntaxKind.JSImportDeclaration */:
|
|
266
271
|
checkImportDeclaration(c, node);
|
|
267
272
|
return;
|
|
268
|
-
case
|
|
273
|
+
case 273 /* SyntaxKind.ImportEqualsDeclaration */:
|
|
269
274
|
checkImportEqualsDeclaration(c, node);
|
|
270
275
|
return;
|
|
271
|
-
case
|
|
276
|
+
case 280 /* SyntaxKind.ExportDeclaration */:
|
|
272
277
|
checkExportDeclaration(c, node);
|
|
273
278
|
return;
|
|
274
|
-
case
|
|
279
|
+
case 279 /* SyntaxKind.ExportAssignment */:
|
|
275
280
|
checkExportAssignment(c, node);
|
|
276
281
|
return;
|
|
277
|
-
case
|
|
278
|
-
case
|
|
282
|
+
case 272 /* SyntaxKind.NamespaceExportDeclaration */:
|
|
283
|
+
case 284 /* SyntaxKind.MissingDeclaration */:
|
|
279
284
|
return;
|
|
280
|
-
case
|
|
285
|
+
case 170 /* SyntaxKind.TypeParameter */:
|
|
281
286
|
checkTypeParameter(c, node);
|
|
282
287
|
return;
|
|
283
288
|
}
|
|
@@ -287,7 +292,7 @@ function checkSourceElementWorker(c, node) {
|
|
|
287
292
|
/** Resolves the names of `{@link}` tags in a JSDoc comment and its tags, which references them. */
|
|
288
293
|
function checkJSDocLinks(c, jsDoc) {
|
|
289
294
|
checkJSDocCommentLinks(c, getComment(jsDoc));
|
|
290
|
-
const tags = jsDoc.kind ===
|
|
295
|
+
const tags = jsDoc.kind === 316 /* SyntaxKind.JSDoc */ ? jsDoc.tags : undefined;
|
|
291
296
|
if (tags !== undefined)
|
|
292
297
|
for (const tag of tags.nodes)
|
|
293
298
|
checkJSDocCommentLinks(c, getComment(tag));
|
|
@@ -296,9 +301,9 @@ function checkJSDocCommentLinks(c, comments) {
|
|
|
296
301
|
if (comments === undefined)
|
|
297
302
|
return;
|
|
298
303
|
for (const comment of comments.nodes)
|
|
299
|
-
if (comment.kind ===
|
|
300
|
-
comment.kind ===
|
|
301
|
-
comment.kind ===
|
|
304
|
+
if (comment.kind === 320 /* SyntaxKind.JSDocLink */ ||
|
|
305
|
+
comment.kind === 321 /* SyntaxKind.JSDocLinkCode */ ||
|
|
306
|
+
comment.kind === 322 /* SyntaxKind.JSDocLinkPlain */)
|
|
302
307
|
resolveJSDocMemberName(c, getName(comment));
|
|
303
308
|
}
|
|
304
309
|
// ---- Type nodes
|
|
@@ -311,12 +316,12 @@ export function checkTypeNodeIfPresent(c, node) {
|
|
|
311
316
|
function checkSignatureMember(c, node) {
|
|
312
317
|
if (getType(node) !== undefined || !c.noImplicitAny)
|
|
313
318
|
return;
|
|
314
|
-
if (node.kind ===
|
|
319
|
+
if (node.kind === 175 /* SyntaxKind.MethodSignature */)
|
|
315
320
|
reportImplicitAny(c, node, c.anyType);
|
|
316
|
-
else if (node.kind ===
|
|
317
|
-
c.error(node,
|
|
321
|
+
else if (node.kind === 181 /* SyntaxKind.CallSignature */)
|
|
322
|
+
c.error(node, 1711 /* Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type */);
|
|
318
323
|
else
|
|
319
|
-
c.error(node,
|
|
324
|
+
c.error(node, 1704 /* Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type */);
|
|
320
325
|
}
|
|
321
326
|
function checkTypeNode(c, node) {
|
|
322
327
|
const saveCurrentNode = c.currentNode;
|
|
@@ -327,10 +332,10 @@ function checkTypeNode(c, node) {
|
|
|
327
332
|
}
|
|
328
333
|
function isTypeReferenceHeritageElement(node) {
|
|
329
334
|
const clause = node.parent;
|
|
330
|
-
if (clause === undefined || clause.kind !==
|
|
335
|
+
if (clause === undefined || clause.kind !== 300 /* SyntaxKind.HeritageClause */)
|
|
331
336
|
return false;
|
|
332
337
|
const token = clause.token;
|
|
333
|
-
if ((token === 118 /* SyntaxKind.ImplementsKeyword */) === (clause.parent.kind ===
|
|
338
|
+
if ((token === 118 /* SyntaxKind.ImplementsKeyword */) === (clause.parent.kind === 266 /* SyntaxKind.InterfaceDeclaration */))
|
|
334
339
|
return false;
|
|
335
340
|
// Only the first clause of each kind counts.
|
|
336
341
|
for (const other of getHeritageClauses(clause.parent).nodes)
|
|
@@ -340,73 +345,78 @@ function isTypeReferenceHeritageElement(node) {
|
|
|
340
345
|
}
|
|
341
346
|
function checkTypeNodeWorker(c, node) {
|
|
342
347
|
switch (node.kind) {
|
|
343
|
-
case
|
|
348
|
+
case 184 /* SyntaxKind.TypePredicate */:
|
|
344
349
|
checkTypePredicate(c, node);
|
|
345
350
|
return;
|
|
346
|
-
case
|
|
347
|
-
case
|
|
348
|
-
case
|
|
351
|
+
case 175 /* SyntaxKind.MethodSignature */:
|
|
352
|
+
case 181 /* SyntaxKind.CallSignature */:
|
|
353
|
+
case 182 /* SyntaxKind.ConstructSignature */: {
|
|
349
354
|
checkTypeParameters(c, getTypeParameters(node));
|
|
350
355
|
checkSignatureMember(c, node);
|
|
351
356
|
const name = getName(node);
|
|
352
|
-
if (name !== undefined && name.kind ===
|
|
357
|
+
if (name !== undefined && name.kind === 169 /* SyntaxKind.ComputedPropertyName */)
|
|
353
358
|
checkComputedPropertyName(c, name);
|
|
354
359
|
break;
|
|
355
360
|
}
|
|
356
|
-
case
|
|
357
|
-
case
|
|
361
|
+
case 186 /* SyntaxKind.FunctionType */:
|
|
362
|
+
case 187 /* SyntaxKind.ConstructorType */:
|
|
358
363
|
checkTypeParameters(c, getTypeParameters(node));
|
|
359
364
|
break;
|
|
360
|
-
case
|
|
361
|
-
case
|
|
365
|
+
case 185 /* SyntaxKind.TypeReference */:
|
|
366
|
+
case 207 /* SyntaxKind.ImportType */: {
|
|
367
|
+
// `const` in `x as const` is not checked as a type: its type is the type of `x`.
|
|
368
|
+
if (isConstTypeReference(node) && isAssertionExpression(node.parent))
|
|
369
|
+
break;
|
|
362
370
|
const type = getTypeFromTypeNode(c, node);
|
|
363
371
|
checkTypeArgumentConstraintsOfReference(c, node, type);
|
|
364
372
|
checkDeprecatedTypeReference(c, node, type);
|
|
373
|
+
if (node.kind === 207 /* SyntaxKind.ImportType */)
|
|
374
|
+
checkImportAttributes(c, node);
|
|
365
375
|
break;
|
|
366
376
|
}
|
|
367
|
-
case
|
|
377
|
+
case 201 /* SyntaxKind.IndexedAccessType */:
|
|
368
378
|
// The indexed access type itself, not the substitution type of a conditional type's true branch.
|
|
369
379
|
checkIndexedAccessIndexType(c, getTypeFromIndexedAccessTypeNode(c, node), node);
|
|
370
380
|
break;
|
|
371
|
-
case
|
|
381
|
+
case 191 /* SyntaxKind.TupleType */:
|
|
372
382
|
checkTupleRestElements(c, node);
|
|
373
383
|
getTypeFromTypeNode(c, node);
|
|
374
|
-
case
|
|
384
|
+
case 235 /* SyntaxKind.ExpressionWithTypeArguments */:
|
|
375
385
|
// Implemented types and interface base types are type references; class base types are
|
|
376
386
|
// checked with the base constructor's type parameters.
|
|
377
387
|
if (isTypeReferenceHeritageElement(node))
|
|
378
388
|
checkTypeArgumentConstraintsOfReference(c, node, getTypeFromTypeNode(c, node));
|
|
379
389
|
break;
|
|
380
|
-
case
|
|
381
|
-
case
|
|
382
|
-
case
|
|
383
|
-
case
|
|
390
|
+
case 188 /* SyntaxKind.TypeQuery */:
|
|
391
|
+
case 200 /* SyntaxKind.TypeOperator */:
|
|
392
|
+
case 203 /* SyntaxKind.LiteralType */:
|
|
393
|
+
case 199 /* SyntaxKind.ThisType */:
|
|
384
394
|
getTypeFromTypeNode(c, node);
|
|
385
395
|
break;
|
|
386
396
|
}
|
|
387
397
|
// Type arguments of an import type are only resolved with its type.
|
|
388
|
-
if (node.kind ===
|
|
398
|
+
if (node.kind === 207 /* SyntaxKind.ImportType */) {
|
|
389
399
|
checkTypeNode(c, node.argument);
|
|
390
400
|
return;
|
|
391
401
|
}
|
|
392
402
|
// Type arguments of a type query are checked with its type.
|
|
393
|
-
if (node.kind ===
|
|
403
|
+
if (node.kind === 188 /* SyntaxKind.TypeQuery */)
|
|
394
404
|
return;
|
|
395
|
-
if (node.kind ===
|
|
405
|
+
if (node.kind === 202 /* SyntaxKind.MappedType */) {
|
|
396
406
|
checkMappedType(c, node);
|
|
397
407
|
return;
|
|
398
408
|
}
|
|
399
|
-
if (node.kind ===
|
|
409
|
+
if (node.kind === 205 /* SyntaxKind.TemplateLiteralType */) {
|
|
400
410
|
checkTemplateLiteralType(c, node);
|
|
401
411
|
return;
|
|
402
412
|
}
|
|
403
413
|
node.forEachChild(c.typeNodeVisitor);
|
|
404
414
|
// Unions and intersections are resolved after their constituents.
|
|
405
|
-
if (node.kind ===
|
|
415
|
+
if (node.kind === 194 /* SyntaxKind.UnionType */ || node.kind === 195 /* SyntaxKind.IntersectionType */)
|
|
406
416
|
getTypeFromTypeNode(c, node);
|
|
407
|
-
if (node.kind ===
|
|
417
|
+
if (node.kind === 175 /* SyntaxKind.MethodSignature */)
|
|
408
418
|
checkFunctionOrMethodSymbols(c, node);
|
|
409
|
-
else if (node.kind ===
|
|
419
|
+
else if (node.kind === 189 /* SyntaxKind.TypeLiteral */)
|
|
410
420
|
checkTypeLiteralMembers(c, node);
|
|
411
421
|
}
|
|
412
422
|
/** Checks that each span of a template literal type can be written in a template, then its type. */
|
|
@@ -433,6 +443,8 @@ function checkMappedType(c, node) {
|
|
|
433
443
|
checkTypeAssignableTo(c, getConstraintTypeFromMappedType(c, t), c.stringNumberSymbolType, node.typeParameter.constraint, undefined);
|
|
434
444
|
}
|
|
435
445
|
function checkTypePredicate(c, node) {
|
|
446
|
+
// The predicate's type is checked also in a position a predicate can't have.
|
|
447
|
+
checkTypeNodeIfPresent(c, node.type);
|
|
436
448
|
const parent = getTypePredicateParent(node);
|
|
437
449
|
if (parent === undefined) {
|
|
438
450
|
c.error(node, 178 /* Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods */);
|
|
@@ -442,7 +454,6 @@ function checkTypePredicate(c, node) {
|
|
|
442
454
|
const typePredicate = getTypePredicateOfSignature(c, signature);
|
|
443
455
|
if (typePredicate === undefined)
|
|
444
456
|
return;
|
|
445
|
-
checkTypeNodeIfPresent(c, node.type);
|
|
446
457
|
if (typePredicate.kind === 0 /* TypePredicateKind.This */ || typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */)
|
|
447
458
|
return;
|
|
448
459
|
const parameterName = node.parameterName;
|
|
@@ -452,13 +463,13 @@ function checkTypePredicate(c, node) {
|
|
|
452
463
|
else if (typePredicate.type !== undefined) {
|
|
453
464
|
const diagnostics = [];
|
|
454
465
|
if (!checkTypeRelatedTo(c, typePredicate.type, getTypeOfSymbol(c, signature.parameters[typePredicate.parameterIndex]), c.assignableRelation, node.type, undefined, diagnostics))
|
|
455
|
-
c.addDiagnostic(chainDiagnostic(diagnostics[0],
|
|
466
|
+
c.addDiagnostic(chainDiagnostic(diagnostics[0], 818 /* Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type */));
|
|
456
467
|
}
|
|
457
468
|
return;
|
|
458
469
|
}
|
|
459
470
|
for (const param of getParameters(parent).nodes) {
|
|
460
471
|
const name = getName(param);
|
|
461
|
-
if ((name.kind ===
|
|
472
|
+
if ((name.kind === 208 /* SyntaxKind.ObjectBindingPattern */ || name.kind === 209 /* SyntaxKind.ArrayBindingPattern */) &&
|
|
462
473
|
checkIfTypePredicateVariableIsDeclaredInBindingPattern(c, name, parameterName, typePredicate.parameterName))
|
|
463
474
|
return;
|
|
464
475
|
}
|
|
@@ -468,13 +479,13 @@ function checkTypePredicate(c, node) {
|
|
|
468
479
|
function getTypePredicateParent(node) {
|
|
469
480
|
const parent = node.parent;
|
|
470
481
|
switch (parent.kind) {
|
|
471
|
-
case
|
|
472
|
-
case
|
|
473
|
-
case
|
|
474
|
-
case
|
|
475
|
-
case
|
|
476
|
-
case
|
|
477
|
-
case
|
|
482
|
+
case 221 /* SyntaxKind.ArrowFunction */:
|
|
483
|
+
case 181 /* SyntaxKind.CallSignature */:
|
|
484
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
485
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
486
|
+
case 186 /* SyntaxKind.FunctionType */:
|
|
487
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
488
|
+
case 175 /* SyntaxKind.MethodSignature */:
|
|
478
489
|
if (getType(parent) === node)
|
|
479
490
|
return parent;
|
|
480
491
|
}
|
|
@@ -489,7 +500,7 @@ function checkIfTypePredicateVariableIsDeclaredInBindingPattern(c, pattern, pred
|
|
|
489
500
|
c.error(predicateVariableNode, 180 /* Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern */, predicateVariableName);
|
|
490
501
|
return true;
|
|
491
502
|
}
|
|
492
|
-
if ((name.kind ===
|
|
503
|
+
if ((name.kind === 209 /* SyntaxKind.ArrayBindingPattern */ || name.kind === 208 /* SyntaxKind.ObjectBindingPattern */) &&
|
|
493
504
|
checkIfTypePredicateVariableIsDeclaredInBindingPattern(c, name, predicateVariableNode, predicateVariableName))
|
|
494
505
|
return true;
|
|
495
506
|
}
|
|
@@ -498,7 +509,7 @@ function checkIfTypePredicateVariableIsDeclaredInBindingPattern(c, pattern, pred
|
|
|
498
509
|
/** Checks an accessor of a type literal or interface. */
|
|
499
510
|
function checkTypeMemberAccessor(c, node) {
|
|
500
511
|
const name = getName(node);
|
|
501
|
-
if (name !== undefined && name.kind ===
|
|
512
|
+
if (name !== undefined && name.kind === 169 /* SyntaxKind.ComputedPropertyName */)
|
|
502
513
|
checkComputedPropertyName(c, name);
|
|
503
514
|
const symbol = getSymbolOfDeclaration(c, node);
|
|
504
515
|
if (symbol !== undefined)
|
|
@@ -512,7 +523,7 @@ function checkTupleRestElements(c, node) {
|
|
|
512
523
|
if ((getTupleElementFlags(c, e) & 8 /* ElementFlags.Variadic */) === 0)
|
|
513
524
|
continue;
|
|
514
525
|
if (!isArrayLikeType(c, getTypeFromTypeNode(c, getType(e)))) {
|
|
515
|
-
c.error(e,
|
|
526
|
+
c.error(e, 732 /* Diagnostics.A_rest_element_type_must_be_an_array_type */);
|
|
516
527
|
return;
|
|
517
528
|
}
|
|
518
529
|
}
|
|
@@ -529,42 +540,42 @@ export class TypeNodeVisitor extends NodeVisitor {
|
|
|
529
540
|
checkJSDocLinksOfNode(this.c, node);
|
|
530
541
|
switch (node.kind) {
|
|
531
542
|
case 79 /* SyntaxKind.Identifier */:
|
|
532
|
-
case
|
|
543
|
+
case 168 /* SyntaxKind.QualifiedName */:
|
|
533
544
|
case 10 /* SyntaxKind.StringLiteral */:
|
|
534
545
|
case 8 /* SyntaxKind.NumericLiteral */:
|
|
535
546
|
return false;
|
|
536
|
-
case
|
|
547
|
+
case 171 /* SyntaxKind.Parameter */:
|
|
537
548
|
checkVariableLikeDeclaration(this.c, node);
|
|
538
549
|
return false;
|
|
539
|
-
case
|
|
540
|
-
case
|
|
541
|
-
case
|
|
550
|
+
case 175 /* SyntaxKind.MethodSignature */:
|
|
551
|
+
case 181 /* SyntaxKind.CallSignature */:
|
|
552
|
+
case 182 /* SyntaxKind.ConstructSignature */:
|
|
542
553
|
checkTypeNode(this.c, node);
|
|
543
554
|
return false;
|
|
544
|
-
case
|
|
555
|
+
case 173 /* SyntaxKind.PropertySignature */:
|
|
545
556
|
checkVariableLikeDeclaration(this.c, node);
|
|
546
557
|
return false;
|
|
547
|
-
case
|
|
548
|
-
case
|
|
558
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
559
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
549
560
|
checkTypeMemberAccessor(this.c, node);
|
|
550
561
|
return false;
|
|
551
|
-
case
|
|
562
|
+
case 183 /* SyntaxKind.IndexSignature */:
|
|
552
563
|
node.forEachChild(this);
|
|
553
564
|
return false;
|
|
554
|
-
case
|
|
565
|
+
case 170 /* SyntaxKind.TypeParameter */:
|
|
555
566
|
// Lists of signatures are checked as a whole; `infer` and mapped type parameters alone.
|
|
556
|
-
if (node.parent.kind ===
|
|
567
|
+
if (node.parent.kind === 197 /* SyntaxKind.InferType */ || node.parent.kind === 202 /* SyntaxKind.MappedType */)
|
|
557
568
|
checkTypeParameter(this.c, node);
|
|
558
|
-
if (node.parent.kind ===
|
|
569
|
+
if (node.parent.kind === 197 /* SyntaxKind.InferType */) {
|
|
559
570
|
const symbol = getSymbolOfDeclaration(this.c, node);
|
|
560
571
|
if (symbol !== undefined)
|
|
561
572
|
checkInferTypeParameterDeclarations(this.c, symbol);
|
|
562
573
|
}
|
|
563
574
|
return false;
|
|
564
575
|
}
|
|
565
|
-
if (node.kind >=
|
|
576
|
+
if (node.kind >= 184 /* SyntaxKind.FirstTypeNode */ && node.kind <= 207 /* SyntaxKind.LastTypeNode */)
|
|
566
577
|
checkTypeNode(this.c, node);
|
|
567
|
-
else if (node.kind ===
|
|
578
|
+
else if (node.kind === 235 /* SyntaxKind.ExpressionWithTypeArguments */)
|
|
568
579
|
checkTypeNode(this.c, node);
|
|
569
580
|
return false;
|
|
570
581
|
}
|
|
@@ -603,7 +614,7 @@ function checkDeferredNodes(c, file) {
|
|
|
603
614
|
}
|
|
604
615
|
/** Resolves the type of an object literal accessor, which reports accessors implicitly typed `any`. */
|
|
605
616
|
function checkObjectLiteralAccessorType(c, node) {
|
|
606
|
-
if (node.parent.kind !==
|
|
617
|
+
if (node.parent.kind !== 212 /* SyntaxKind.ObjectLiteralExpression */)
|
|
607
618
|
return;
|
|
608
619
|
const symbol = getSymbolOfDeclaration(c, node);
|
|
609
620
|
if (symbol !== undefined)
|
|
@@ -614,39 +625,52 @@ function checkDeferredNode(c, node) {
|
|
|
614
625
|
c.currentNode = node;
|
|
615
626
|
c.instantiationCount = 0;
|
|
616
627
|
switch (node.kind) {
|
|
617
|
-
case
|
|
618
|
-
case
|
|
619
|
-
case
|
|
628
|
+
case 215 /* SyntaxKind.CallExpression */:
|
|
629
|
+
case 216 /* SyntaxKind.NewExpression */:
|
|
630
|
+
case 217 /* SyntaxKind.TaggedTemplateExpression */:
|
|
620
631
|
// Deferred when overload resolution fails, so that the arguments are checked once.
|
|
621
632
|
resolveUntypedCall(c, node);
|
|
622
633
|
break;
|
|
623
|
-
case
|
|
624
|
-
case
|
|
625
|
-
case
|
|
634
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
635
|
+
case 221 /* SyntaxKind.ArrowFunction */:
|
|
636
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
626
637
|
checkFunctionLikeBody(c, node);
|
|
627
638
|
break;
|
|
628
|
-
case
|
|
629
|
-
case
|
|
639
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
640
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
630
641
|
checkObjectLiteralAccessorType(c, node);
|
|
631
642
|
checkFunctionLikeBody(c, node);
|
|
632
|
-
if (node.parent.kind ===
|
|
643
|
+
if (node.parent.kind === 212 /* SyntaxKind.ObjectLiteralExpression */)
|
|
633
644
|
checkAccessorDeclaration(c, node);
|
|
634
645
|
break;
|
|
635
|
-
case
|
|
646
|
+
case 233 /* SyntaxKind.ClassExpression */:
|
|
636
647
|
checkClassLikeDeferred(c, node);
|
|
637
648
|
break;
|
|
638
|
-
case
|
|
639
|
-
|
|
649
|
+
case 212 /* SyntaxKind.ObjectLiteralExpression */: {
|
|
650
|
+
// Reported only as suggestions, which are computed when they are asked for (`getSuggestionDiagnostics`).
|
|
651
|
+
const file = getSourceFileOfNode(node);
|
|
652
|
+
const pending = c.objectLiteralsForDeprecations.get(file);
|
|
653
|
+
if (pending === undefined)
|
|
654
|
+
c.objectLiteralsForDeprecations.set(file, [node]);
|
|
655
|
+
else
|
|
656
|
+
pending.push(node);
|
|
657
|
+
break;
|
|
658
|
+
}
|
|
659
|
+
case 294 /* SyntaxKind.JsxAttributes */:
|
|
660
|
+
checkContextualDeprecations(c, node);
|
|
661
|
+
break;
|
|
662
|
+
case 236 /* SyntaxKind.AsExpression */:
|
|
663
|
+
case 218 /* SyntaxKind.TypeAssertionExpression */:
|
|
640
664
|
checkAssertionDeferred(c, node);
|
|
641
665
|
break;
|
|
642
|
-
case
|
|
666
|
+
case 170 /* SyntaxKind.TypeParameter */:
|
|
643
667
|
checkTypeParameterDeferred(c, node);
|
|
644
668
|
break;
|
|
645
|
-
case
|
|
646
|
-
case
|
|
669
|
+
case 286 /* SyntaxKind.JsxElement */:
|
|
670
|
+
case 287 /* SyntaxKind.JsxSelfClosingElement */:
|
|
647
671
|
checkJsxElementDeferred(c, node);
|
|
648
672
|
break;
|
|
649
|
-
case
|
|
673
|
+
case 224 /* SyntaxKind.VoidExpression */:
|
|
650
674
|
checkExpression(c, getExpression(node));
|
|
651
675
|
break;
|
|
652
676
|
}
|