tsc-ts 0.0.4 → 0.0.5
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 +33 -1
- package/dist/api/compiler/ast-utilities.d.ts +82 -0
- package/dist/api/compiler/ast-utilities.js +462 -0
- package/dist/api/compiler/ast.d.ts +2350 -0
- package/dist/api/compiler/ast.js +11206 -0
- package/dist/api/compiler/astnav.d.ts +37 -0
- package/dist/api/compiler/astnav.js +767 -0
- package/dist/api/compiler/binder-utilities.d.ts +182 -0
- package/dist/api/compiler/binder-utilities.js +1240 -0
- package/dist/api/compiler/binder.d.ts +33 -0
- package/dist/api/compiler/binder.js +2358 -0
- package/dist/api/compiler/character-codes.d.ts +161 -0
- package/dist/api/compiler/character-codes.js +160 -0
- package/dist/api/compiler/checker-calls.d.ts +46 -0
- package/dist/api/compiler/checker-calls.js +1640 -0
- package/dist/api/compiler/checker-classes.d.ts +30 -0
- package/dist/api/compiler/checker-classes.js +582 -0
- package/dist/api/compiler/checker-contextual.d.ts +77 -0
- package/dist/api/compiler/checker-contextual.js +1136 -0
- package/dist/api/compiler/checker-declaration-order.d.ts +12 -0
- package/dist/api/compiler/checker-declaration-order.js +356 -0
- package/dist/api/compiler/checker-declarations.d.ts +33 -0
- package/dist/api/compiler/checker-declarations.js +888 -0
- package/dist/api/compiler/checker-declared-types.d.ts +48 -0
- package/dist/api/compiler/checker-declared-types.js +787 -0
- package/dist/api/compiler/checker-decorators.d.ts +26 -0
- package/dist/api/compiler/checker-decorators.js +562 -0
- package/dist/api/compiler/checker-deprecation.d.ts +33 -0
- package/dist/api/compiler/checker-deprecation.js +315 -0
- package/dist/api/compiler/checker-destructuring.d.ts +34 -0
- package/dist/api/compiler/checker-destructuring.js +584 -0
- package/dist/api/compiler/checker-elaboration.d.ts +15 -0
- package/dist/api/compiler/checker-elaboration.js +290 -0
- package/dist/api/compiler/checker-emit-helpers.d.ts +58 -0
- package/dist/api/compiler/checker-emit-helpers.js +154 -0
- package/dist/api/compiler/checker-emit-resolver.d.ts +75 -0
- package/dist/api/compiler/checker-emit-resolver.js +579 -0
- package/dist/api/compiler/checker-evaluator.d.ts +27 -0
- package/dist/api/compiler/checker-evaluator.js +188 -0
- package/dist/api/compiler/checker-expressions.d.ts +67 -0
- package/dist/api/compiler/checker-expressions.js +1351 -0
- package/dist/api/compiler/checker-features.d.ts +6 -0
- package/dist/api/compiler/checker-features.js +354 -0
- package/dist/api/compiler/checker-flow.d.ts +86 -0
- package/dist/api/compiler/checker-flow.js +169 -0
- package/dist/api/compiler/checker-functions.d.ts +43 -0
- package/dist/api/compiler/checker-functions.js +1002 -0
- package/dist/api/compiler/checker-generated-code.d.ts +25 -0
- package/dist/api/compiler/checker-generated-code.js +168 -0
- package/dist/api/compiler/checker-globals.d.ts +14 -0
- package/dist/api/compiler/checker-globals.js +37 -0
- package/dist/api/compiler/checker-grammar.d.ts +35 -0
- package/dist/api/compiler/checker-grammar.js +2573 -0
- package/dist/api/compiler/checker-heritage.d.ts +28 -0
- package/dist/api/compiler/checker-heritage.js +900 -0
- package/dist/api/compiler/checker-inference.d.ts +179 -0
- package/dist/api/compiler/checker-inference.js +2105 -0
- package/dist/api/compiler/checker-iteration.d.ts +115 -0
- package/dist/api/compiler/checker-iteration.js +857 -0
- package/dist/api/compiler/checker-javascript.d.ts +42 -0
- package/dist/api/compiler/checker-javascript.js +441 -0
- package/dist/api/compiler/checker-jsdoc.d.ts +30 -0
- package/dist/api/compiler/checker-jsdoc.js +320 -0
- package/dist/api/compiler/checker-jsx.d.ts +94 -0
- package/dist/api/compiler/checker-jsx.js +1433 -0
- package/dist/api/compiler/checker-literals.d.ts +6 -0
- package/dist/api/compiler/checker-literals.js +43 -0
- package/dist/api/compiler/checker-members.d.ts +198 -0
- package/dist/api/compiler/checker-members.js +2126 -0
- package/dist/api/compiler/checker-modules.d.ts +85 -0
- package/dist/api/compiler/checker-modules.js +2141 -0
- package/dist/api/compiler/checker-narrowing.d.ts +120 -0
- package/dist/api/compiler/checker-narrowing.js +2797 -0
- package/dist/api/compiler/checker-object-literals.d.ts +14 -0
- package/dist/api/compiler/checker-object-literals.js +479 -0
- package/dist/api/compiler/checker-operators.d.ts +33 -0
- package/dist/api/compiler/checker-operators.js +1040 -0
- package/dist/api/compiler/checker-overloads.d.ts +7 -0
- package/dist/api/compiler/checker-overloads.js +270 -0
- package/dist/api/compiler/checker-property-access.d.ts +34 -0
- package/dist/api/compiler/checker-property-access.js +672 -0
- package/dist/api/compiler/checker-services.d.ts +49 -0
- package/dist/api/compiler/checker-services.js +995 -0
- package/dist/api/compiler/checker-signatures.d.ts +55 -0
- package/dist/api/compiler/checker-signatures.js +788 -0
- package/dist/api/compiler/checker-source-file.d.ts +27 -0
- package/dist/api/compiler/checker-source-file.js +619 -0
- package/dist/api/compiler/checker-statements.d.ts +18 -0
- package/dist/api/compiler/checker-statements.js +226 -0
- package/dist/api/compiler/checker-super.d.ts +13 -0
- package/dist/api/compiler/checker-super.js +241 -0
- package/dist/api/compiler/checker-symbol-types.d.ts +67 -0
- package/dist/api/compiler/checker-symbol-types.js +1885 -0
- package/dist/api/compiler/checker-symbols.d.ts +181 -0
- package/dist/api/compiler/checker-symbols.js +1782 -0
- package/dist/api/compiler/checker-type-factory.d.ts +142 -0
- package/dist/api/compiler/checker-type-factory.js +2501 -0
- package/dist/api/compiler/checker-type-nodes.d.ts +26 -0
- package/dist/api/compiler/checker-type-nodes.js +828 -0
- package/dist/api/compiler/checker-type-operators.d.ts +109 -0
- package/dist/api/compiler/checker-type-operators.js +1842 -0
- package/dist/api/compiler/checker-types.d.ts +1027 -0
- package/dist/api/compiler/checker-types.js +1697 -0
- package/dist/api/compiler/checker-unused.d.ts +19 -0
- package/dist/api/compiler/checker-unused.js +524 -0
- package/dist/api/compiler/checker-utilities.d.ts +33 -0
- package/dist/api/compiler/checker-utilities.js +141 -0
- package/dist/api/compiler/checker.d.ts +491 -0
- package/dist/api/compiler/checker.js +912 -0
- package/dist/api/compiler/command-line.d.ts +32 -0
- package/dist/api/compiler/command-line.js +383 -0
- package/dist/api/compiler/compile-program.d.ts +118 -0
- package/dist/api/compiler/compile-program.js +384 -0
- package/dist/api/compiler/diagnostic-locales.d.ts +22 -0
- package/dist/api/compiler/diagnostic-locales.js +64 -0
- package/dist/api/compiler/diagnostic-messages.d.ts +2166 -0
- package/dist/api/compiler/diagnostic-messages.js +184 -0
- package/dist/api/compiler/diagnostics.d.ts +167 -0
- package/dist/api/compiler/diagnostics.js +820 -0
- package/dist/api/compiler/emitter.d.ts +71 -0
- package/dist/api/compiler/emitter.js +327 -0
- package/dist/api/compiler/file-include.d.ts +117 -0
- package/dist/api/compiler/file-include.js +536 -0
- package/dist/api/compiler/file-loader.d.ts +261 -0
- package/dist/api/compiler/file-loader.js +1257 -0
- package/dist/api/compiler/file-system.d.ts +51 -0
- package/dist/api/compiler/file-system.js +132 -0
- package/dist/api/compiler/flow.d.ts +60 -0
- package/dist/api/compiler/flow.js +45 -0
- package/dist/api/compiler/instantiation.d.ts +74 -0
- package/dist/api/compiler/instantiation.js +799 -0
- package/dist/api/compiler/jsdoc.d.ts +75 -0
- package/dist/api/compiler/jsdoc.js +1229 -0
- package/dist/api/compiler/link-tables.d.ts +36 -0
- package/dist/api/compiler/link-tables.js +83 -0
- package/dist/api/compiler/locale-data.d.ts +24 -0
- package/dist/api/compiler/locale-data.js +183 -0
- package/dist/api/compiler/locale.d.ts +4 -0
- package/dist/api/compiler/locale.js +317 -0
- package/dist/api/compiler/locales/cs-CZ.d.ts +2 -0
- package/dist/api/compiler/locales/cs-CZ.js +3 -0
- package/dist/api/compiler/locales/de-DE.d.ts +2 -0
- package/dist/api/compiler/locales/de-DE.js +3 -0
- package/dist/api/compiler/locales/es-ES.d.ts +2 -0
- package/dist/api/compiler/locales/es-ES.js +3 -0
- package/dist/api/compiler/locales/fr-FR.d.ts +2 -0
- package/dist/api/compiler/locales/fr-FR.js +3 -0
- package/dist/api/compiler/locales/it-IT.d.ts +2 -0
- package/dist/api/compiler/locales/it-IT.js +3 -0
- package/dist/api/compiler/locales/ja-JP.d.ts +2 -0
- package/dist/api/compiler/locales/ja-JP.js +3 -0
- package/dist/api/compiler/locales/ko-KR.d.ts +2 -0
- package/dist/api/compiler/locales/ko-KR.js +3 -0
- package/dist/api/compiler/locales/pl-PL.d.ts +2 -0
- package/dist/api/compiler/locales/pl-PL.js +3 -0
- package/dist/api/compiler/locales/pt-BR.d.ts +2 -0
- package/dist/api/compiler/locales/pt-BR.js +3 -0
- package/dist/api/compiler/locales/ru-RU.d.ts +2 -0
- package/dist/api/compiler/locales/ru-RU.js +3 -0
- package/dist/api/compiler/locales/tr-TR.d.ts +2 -0
- package/dist/api/compiler/locales/tr-TR.js +3 -0
- package/dist/api/compiler/locales/zh-CN.d.ts +2 -0
- package/dist/api/compiler/locales/zh-CN.js +3 -0
- package/dist/api/compiler/locales/zh-TW.d.ts +2 -0
- package/dist/api/compiler/locales/zh-TW.js +3 -0
- package/dist/api/compiler/module-resolution-types.d.ts +83 -0
- package/dist/api/compiler/module-resolution-types.js +176 -0
- package/dist/api/compiler/module-resolution.d.ts +71 -0
- package/dist/api/compiler/module-resolution.js +1598 -0
- package/dist/api/compiler/module-specifiers.d.ts +64 -0
- package/dist/api/compiler/module-specifiers.js +1101 -0
- package/dist/api/compiler/name-resolver.d.ts +43 -0
- package/dist/api/compiler/name-resolver.js +509 -0
- package/dist/api/compiler/node-builder-names.d.ts +32 -0
- package/dist/api/compiler/node-builder-names.js +854 -0
- package/dist/api/compiler/node-builder-pseudo.d.ts +36 -0
- package/dist/api/compiler/node-builder-pseudo.js +744 -0
- package/dist/api/compiler/node-builder-reuse.d.ts +4 -0
- package/dist/api/compiler/node-builder-reuse.js +647 -0
- package/dist/api/compiler/node-builder.d.ts +270 -0
- package/dist/api/compiler/node-builder.js +2645 -0
- package/dist/api/compiler/option-declarations.d.ts +90 -0
- package/dist/api/compiler/option-declarations.js +1460 -0
- package/dist/api/compiler/options.d.ts +289 -0
- package/dist/api/compiler/options.js +1197 -0
- package/dist/api/compiler/output-paths.d.ts +42 -0
- package/dist/api/compiler/output-paths.js +195 -0
- package/dist/api/compiler/package-json.d.ts +175 -0
- package/dist/api/compiler/package-json.js +1015 -0
- package/dist/api/compiler/parallel-parse.d.ts +219 -0
- package/dist/api/compiler/parallel-parse.js +537 -0
- package/dist/api/compiler/parser.d.ts +587 -0
- package/dist/api/compiler/parser.js +6407 -0
- package/dist/api/compiler/path.d.ts +91 -0
- package/dist/api/compiler/path.js +705 -0
- package/dist/api/compiler/printer/async-helpers.d.ts +22 -0
- package/dist/api/compiler/printer/async-helpers.js +91 -0
- package/dist/api/compiler/printer/auto-generate.d.ts +13 -0
- package/dist/api/compiler/printer/auto-generate.js +20 -0
- package/dist/api/compiler/printer/decorator-helpers.d.ts +24 -0
- package/dist/api/compiler/printer/decorator-helpers.js +118 -0
- package/dist/api/compiler/printer/emit-context.d.ts +154 -0
- package/dist/api/compiler/printer/emit-context.js +576 -0
- package/dist/api/compiler/printer/emit-flags.d.ts +60 -0
- package/dist/api/compiler/printer/emit-flags.js +2 -0
- package/dist/api/compiler/printer/factory-base.d.ts +171 -0
- package/dist/api/compiler/printer/factory-base.js +1505 -0
- package/dist/api/compiler/printer/factory.d.ts +147 -0
- package/dist/api/compiler/printer/factory.js +542 -0
- package/dist/api/compiler/printer/helpers.d.ts +27 -0
- package/dist/api/compiler/printer/helpers.js +164 -0
- package/dist/api/compiler/printer/name-generator.d.ts +41 -0
- package/dist/api/compiler/printer/name-generator.js +283 -0
- package/dist/api/compiler/printer/printer.d.ts +411 -0
- package/dist/api/compiler/printer/printer.js +4517 -0
- package/dist/api/compiler/printer/text-writer.d.ts +46 -0
- package/dist/api/compiler/printer/text-writer.js +172 -0
- package/dist/api/compiler/printer/utilities.d.ts +82 -0
- package/dist/api/compiler/printer/utilities.js +817 -0
- package/dist/api/compiler/program-checker.d.ts +156 -0
- package/dist/api/compiler/program-checker.js +526 -0
- package/dist/api/compiler/program-utilities.d.ts +52 -0
- package/dist/api/compiler/program-utilities.js +365 -0
- package/dist/api/compiler/program.d.ts +180 -0
- package/dist/api/compiler/program.js +1011 -0
- package/dist/api/compiler/pseudo-bigint.d.ts +5 -0
- package/dist/api/compiler/pseudo-bigint.js +61 -0
- package/dist/api/compiler/regexp-checker.d.ts +38 -0
- package/dist/api/compiler/regexp-checker.js +942 -0
- package/dist/api/compiler/relations.d.ts +263 -0
- package/dist/api/compiler/relations.js +4002 -0
- package/dist/api/compiler/reparser.d.ts +48 -0
- package/dist/api/compiler/reparser.js +1323 -0
- package/dist/api/compiler/scanner.d.ts +256 -0
- package/dist/api/compiler/scanner.js +2853 -0
- package/dist/api/compiler/side-state.d.ts +16 -0
- package/dist/api/compiler/side-state.js +89 -0
- package/dist/api/compiler/sourcemap.d.ts +55 -0
- package/dist/api/compiler/sourcemap.js +340 -0
- package/dist/api/compiler/spelling.d.ts +14 -0
- package/dist/api/compiler/spelling.js +128 -0
- package/dist/api/compiler/symbol-accessibility.d.ts +57 -0
- package/dist/api/compiler/symbol-accessibility.js +894 -0
- package/dist/api/compiler/symbol.d.ts +240 -0
- package/dist/api/compiler/symbol.js +228 -0
- package/dist/api/compiler/symlinks.d.ts +32 -0
- package/dist/api/compiler/symlinks.js +114 -0
- package/dist/api/compiler/syntax-kind.d.ts +389 -0
- package/dist/api/compiler/syntax-kind.js +2 -0
- package/dist/api/compiler/timeline.d.ts +9 -0
- package/dist/api/compiler/timeline.js +54 -0
- package/dist/api/compiler/transformers/alias-references.d.ts +39 -0
- package/dist/api/compiler/transformers/alias-references.js +676 -0
- package/dist/api/compiler/transformers/async-utilities.d.ts +51 -0
- package/dist/api/compiler/transformers/async-utilities.js +260 -0
- package/dist/api/compiler/transformers/async.d.ts +53 -0
- package/dist/api/compiler/transformers/async.js +645 -0
- package/dist/api/compiler/transformers/class-fields.d.ts +206 -0
- package/dist/api/compiler/transformers/class-fields.js +2418 -0
- package/dist/api/compiler/transformers/class-utilities.d.ts +46 -0
- package/dist/api/compiler/transformers/class-utilities.js +261 -0
- package/dist/api/compiler/transformers/commonjs-module.d.ts +103 -0
- package/dist/api/compiler/transformers/commonjs-module.js +1180 -0
- package/dist/api/compiler/transformers/const-enum-inliner.d.ts +11 -0
- package/dist/api/compiler/transformers/const-enum-inliner.js +36 -0
- package/dist/api/compiler/transformers/declarations-diagnostics.d.ts +52 -0
- package/dist/api/compiler/transformers/declarations-diagnostics.js +538 -0
- package/dist/api/compiler/transformers/declarations-pseudo.d.ts +160 -0
- package/dist/api/compiler/transformers/declarations-pseudo.js +797 -0
- package/dist/api/compiler/transformers/declarations-resolver.d.ts +152 -0
- package/dist/api/compiler/transformers/declarations-resolver.js +35 -0
- package/dist/api/compiler/transformers/declarations-syntactic.d.ts +119 -0
- package/dist/api/compiler/transformers/declarations-syntactic.js +1582 -0
- package/dist/api/compiler/transformers/declarations-tracker.d.ts +46 -0
- package/dist/api/compiler/transformers/declarations-tracker.js +197 -0
- package/dist/api/compiler/transformers/declarations.d.ts +175 -0
- package/dist/api/compiler/transformers/declarations.js +2380 -0
- package/dist/api/compiler/transformers/decorator-metadata.d.ts +54 -0
- package/dist/api/compiler/transformers/decorator-metadata.js +554 -0
- package/dist/api/compiler/transformers/decorator-utilities.d.ts +38 -0
- package/dist/api/compiler/transformers/decorator-utilities.js +238 -0
- package/dist/api/compiler/transformers/destructuring.d.ts +25 -0
- package/dist/api/compiler/transformers/destructuring.js +626 -0
- package/dist/api/compiler/transformers/downlevel.d.ts +6 -0
- package/dist/api/compiler/transformers/downlevel.js +45 -0
- package/dist/api/compiler/transformers/emit-resolver.d.ts +61 -0
- package/dist/api/compiler/transformers/emit-resolver.js +197 -0
- package/dist/api/compiler/transformers/es-decorators.d.ts +118 -0
- package/dist/api/compiler/transformers/es-decorators.js +1901 -0
- package/dist/api/compiler/transformers/exponentiation.d.ts +11 -0
- package/dist/api/compiler/transformers/exponentiation.js +76 -0
- package/dist/api/compiler/transformers/external-module-info.d.ts +35 -0
- package/dist/api/compiler/transformers/external-module-info.js +351 -0
- package/dist/api/compiler/transformers/for-await.d.ts +43 -0
- package/dist/api/compiler/transformers/for-await.js +469 -0
- package/dist/api/compiler/transformers/import-elision.d.ts +16 -0
- package/dist/api/compiler/transformers/import-elision.js +124 -0
- package/dist/api/compiler/transformers/jsx-entities.d.ts +1 -0
- package/dist/api/compiler/transformers/jsx-entities.js +256 -0
- package/dist/api/compiler/transformers/jsx.d.ts +71 -0
- package/dist/api/compiler/transformers/jsx.js +700 -0
- package/dist/api/compiler/transformers/legacy-decorators.d.ts +56 -0
- package/dist/api/compiler/transformers/legacy-decorators.js +564 -0
- package/dist/api/compiler/transformers/logical-assignment.d.ts +14 -0
- package/dist/api/compiler/transformers/logical-assignment.js +62 -0
- package/dist/api/compiler/transformers/module-utilities.d.ts +9 -0
- package/dist/api/compiler/transformers/module-utilities.js +36 -0
- package/dist/api/compiler/transformers/module.d.ts +49 -0
- package/dist/api/compiler/transformers/module.js +296 -0
- package/dist/api/compiler/transformers/named-evaluation.d.ts +26 -0
- package/dist/api/compiler/transformers/named-evaluation.js +266 -0
- package/dist/api/compiler/transformers/nullish-coalescing.d.ts +9 -0
- package/dist/api/compiler/transformers/nullish-coalescing.js +26 -0
- package/dist/api/compiler/transformers/object-rest-spread.d.ts +34 -0
- package/dist/api/compiler/transformers/object-rest-spread.js +411 -0
- package/dist/api/compiler/transformers/optional-catch.d.ts +9 -0
- package/dist/api/compiler/transformers/optional-catch.js +20 -0
- package/dist/api/compiler/transformers/optional-chain.d.ts +14 -0
- package/dist/api/compiler/transformers/optional-chain.js +188 -0
- package/dist/api/compiler/transformers/reference-resolver.d.ts +128 -0
- package/dist/api/compiler/transformers/reference-resolver.js +1155 -0
- package/dist/api/compiler/transformers/runtime-syntax.d.ts +71 -0
- package/dist/api/compiler/transformers/runtime-syntax.js +753 -0
- package/dist/api/compiler/transformers/subtree-facts.d.ts +9 -0
- package/dist/api/compiler/transformers/subtree-facts.js +203 -0
- package/dist/api/compiler/transformers/syntax-facts.d.ts +51 -0
- package/dist/api/compiler/transformers/syntax-facts.js +254 -0
- package/dist/api/compiler/transformers/tagged-template.d.ts +17 -0
- package/dist/api/compiler/transformers/tagged-template.js +148 -0
- package/dist/api/compiler/transformers/transformer.d.ts +17 -0
- package/dist/api/compiler/transformers/transformer.js +54 -0
- package/dist/api/compiler/transformers/type-eraser.d.ts +21 -0
- package/dist/api/compiler/transformers/type-eraser.js +346 -0
- package/dist/api/compiler/transformers/type-serialization.d.ts +20 -0
- package/dist/api/compiler/transformers/type-serialization.js +347 -0
- package/dist/api/compiler/transformers/using.d.ts +56 -0
- package/dist/api/compiler/transformers/using.js +453 -0
- package/dist/api/compiler/transformers/utilities.d.ts +50 -0
- package/dist/api/compiler/transformers/utilities.js +347 -0
- package/dist/api/compiler/transformers/visitor-base.d.ts +6 -0
- package/dist/api/compiler/transformers/visitor-base.js +817 -0
- package/dist/api/compiler/transformers/visitor-hooks.d.ts +29 -0
- package/dist/api/compiler/transformers/visitor-hooks.js +189 -0
- package/dist/api/compiler/tsconfig.d.ts +177 -0
- package/dist/api/compiler/tsconfig.js +1311 -0
- package/dist/api/compiler/type-printer.d.ts +15 -0
- package/dist/api/compiler/type-printer.js +74 -0
- package/dist/api/compiler/types.d.ts +87 -0
- package/dist/api/compiler/types.js +23 -0
- package/dist/api/compiler/unicode-identifiers.d.ts +2 -0
- package/dist/api/compiler/unicode-identifiers.js +209 -0
- package/dist/api/compiler/unicode-properties.d.ts +8 -0
- package/dist/api/compiler/unicode-properties.js +531 -0
- package/dist/api/compiler/vfs-match.d.ts +24 -0
- package/dist/api/compiler/vfs-match.js +587 -0
- package/dist/api/library/ast.d.ts +3 -2
- package/dist/api/library/ast.generated.d.ts +127 -139
- package/dist/api/library/checker.d.ts +51 -0
- package/dist/api/library/checker.js +318 -0
- package/dist/api/library/diagnostics.d.ts +13 -0
- package/dist/api/library/diagnostics.js +50 -0
- package/dist/api/library/disk.d.ts +13 -0
- package/dist/api/library/disk.js +66 -0
- package/dist/api/library/errors.d.ts +13 -0
- package/dist/api/library/errors.js +24 -0
- package/dist/api/library/host.d.ts +24 -0
- package/dist/api/library/host.js +52 -0
- package/dist/api/library/index.d.ts +5 -1
- package/dist/api/library/index.js +4 -0
- package/dist/api/library/nodes.d.ts +51 -0
- package/dist/api/library/nodes.js +196 -0
- package/dist/api/library/options.d.ts +144 -0
- package/dist/api/library/options.js +308 -0
- package/dist/api/library/parse.d.ts +19 -0
- package/dist/api/library/parse.js +41 -0
- package/dist/api/library/program.d.ts +21 -0
- package/dist/api/library/program.js +234 -0
- package/dist/api/library/types.d.ts +14 -1
- package/package.json +12 -8
- package/src/compiler/ast-utilities.ts +548 -0
- package/src/compiler/ast.ts +12862 -0
- package/src/compiler/astnav.ts +799 -0
- package/src/compiler/binder-utilities.ts +1392 -0
- package/src/compiler/binder.ts +2703 -0
- package/src/compiler/build-info.ts +1197 -0
- package/src/compiler/character-codes.ts +323 -0
- package/src/compiler/checker-calls.ts +2155 -0
- package/src/compiler/checker-classes.ts +706 -0
- package/src/compiler/checker-contextual.ts +1457 -0
- package/src/compiler/checker-declaration-order.ts +438 -0
- package/src/compiler/checker-declarations.ts +1194 -0
- package/src/compiler/checker-declared-types.ts +919 -0
- package/src/compiler/checker-decorators.ts +694 -0
- package/src/compiler/checker-deprecation.ts +359 -0
- package/src/compiler/checker-destructuring.ts +805 -0
- package/src/compiler/checker-elaboration.ts +477 -0
- package/src/compiler/checker-emit-helpers.ts +224 -0
- package/src/compiler/checker-emit-resolver.ts +769 -0
- package/src/compiler/checker-evaluator.ts +243 -0
- package/src/compiler/checker-expressions.ts +1831 -0
- package/src/compiler/checker-features.ts +361 -0
- package/src/compiler/checker-flow.ts +394 -0
- package/src/compiler/checker-functions.ts +1296 -0
- package/src/compiler/checker-generated-code.ts +227 -0
- package/src/compiler/checker-globals.ts +52 -0
- package/src/compiler/checker-grammar.ts +3584 -0
- package/src/compiler/checker-heritage.ts +1233 -0
- package/src/compiler/checker-inference.ts +2576 -0
- package/src/compiler/checker-iteration.ts +1206 -0
- package/src/compiler/checker-javascript.ts +502 -0
- package/src/compiler/checker-jsdoc.ts +360 -0
- package/src/compiler/checker-jsx.ts +1924 -0
- package/src/compiler/checker-literals.ts +61 -0
- package/src/compiler/checker-members.ts +2436 -0
- package/src/compiler/checker-modules.ts +2886 -0
- package/src/compiler/checker-narrowing.ts +3230 -0
- package/src/compiler/checker-object-literals.ts +575 -0
- package/src/compiler/checker-operators.ts +1422 -0
- package/src/compiler/checker-overloads.ts +328 -0
- package/src/compiler/checker-property-access.ts +906 -0
- package/src/compiler/checker-services.ts +1149 -0
- package/src/compiler/checker-signatures.ts +1032 -0
- package/src/compiler/checker-source-file.ts +732 -0
- package/src/compiler/checker-statements.ts +292 -0
- package/src/compiler/checker-super.ts +261 -0
- package/src/compiler/checker-symbol-types.ts +2107 -0
- package/src/compiler/checker-symbols.ts +2150 -0
- package/src/compiler/checker-type-factory.ts +2579 -0
- package/src/compiler/checker-type-nodes.ts +1033 -0
- package/src/compiler/checker-type-operators.ts +2502 -0
- package/src/compiler/checker-types.ts +2340 -0
- package/src/compiler/checker-unused.ts +642 -0
- package/src/compiler/checker-utilities.ts +161 -0
- package/src/compiler/checker.ts +1116 -0
- package/src/compiler/command-line.ts +436 -0
- package/src/compiler/compile-program.ts +439 -0
- package/src/compiler/decoder.ts +1209 -0
- package/src/compiler/diagnostic-locales.ts +86 -0
- package/src/compiler/diagnostic-messages.ts +2349 -0
- package/src/compiler/diagnostics.ts +897 -0
- package/src/compiler/emitter.ts +434 -0
- package/src/compiler/encoder.ts +1945 -0
- package/src/compiler/file-include.ts +673 -0
- package/src/compiler/file-loader.ts +1528 -0
- package/src/compiler/file-system.ts +143 -0
- package/src/compiler/flow.ts +89 -0
- package/src/compiler/help.ts +473 -0
- package/src/compiler/incremental.ts +2784 -0
- package/src/compiler/init.ts +141 -0
- package/src/compiler/instantiation.ts +894 -0
- package/src/compiler/jsdoc.ts +1386 -0
- package/src/compiler/link-tables.ts +98 -0
- package/src/compiler/locale-data.ts +203 -0
- package/src/compiler/locale.ts +307 -0
- package/src/compiler/locales/cs-CZ.ts +5 -0
- package/src/compiler/locales/de-DE.ts +5 -0
- package/src/compiler/locales/es-ES.ts +5 -0
- package/src/compiler/locales/fr-FR.ts +5 -0
- package/src/compiler/locales/it-IT.ts +5 -0
- package/src/compiler/locales/ja-JP.ts +5 -0
- package/src/compiler/locales/ko-KR.ts +5 -0
- package/src/compiler/locales/pl-PL.ts +5 -0
- package/src/compiler/locales/pt-BR.ts +5 -0
- package/src/compiler/locales/ru-RU.ts +5 -0
- package/src/compiler/locales/tr-TR.ts +5 -0
- package/src/compiler/locales/zh-CN.ts +5 -0
- package/src/compiler/locales/zh-TW.ts +5 -0
- package/src/compiler/module-resolution-types.ts +243 -0
- package/src/compiler/module-resolution.ts +2072 -0
- package/src/compiler/module-specifiers.ts +1491 -0
- package/src/compiler/name-resolver.ts +646 -0
- package/src/compiler/node-builder-names.ts +1069 -0
- package/src/compiler/node-builder-pseudo.ts +892 -0
- package/src/compiler/node-builder-reuse.ts +764 -0
- package/src/compiler/node-builder.ts +3425 -0
- package/src/compiler/option-declarations.ts +1560 -0
- package/src/compiler/options.ts +1576 -0
- package/src/compiler/output-paths.ts +334 -0
- package/src/compiler/package-json.ts +1083 -0
- package/src/compiler/parallel-check.ts +1951 -0
- package/src/compiler/parallel-parse.ts +590 -0
- package/src/compiler/parse-thread.ts +140 -0
- package/src/compiler/parser.ts +7716 -0
- package/src/compiler/path.ts +717 -0
- package/src/compiler/printer/async-helpers.ts +183 -0
- package/src/compiler/printer/auto-generate.ts +27 -0
- package/src/compiler/printer/decorator-helpers.ts +218 -0
- package/src/compiler/printer/emit-context.ts +679 -0
- package/src/compiler/printer/emit-flags.ts +64 -0
- package/src/compiler/printer/factory-base.ts +2577 -0
- package/src/compiler/printer/factory.ts +764 -0
- package/src/compiler/printer/helpers.ts +291 -0
- package/src/compiler/printer/name-generator.ts +372 -0
- package/src/compiler/printer/printer.ts +5072 -0
- package/src/compiler/printer/text-writer.ts +183 -0
- package/src/compiler/printer/utilities.ts +884 -0
- package/src/compiler/program-checker.ts +592 -0
- package/src/compiler/program-utilities.ts +435 -0
- package/src/compiler/program.ts +1419 -0
- package/src/compiler/pseudo-bigint.ts +62 -0
- package/src/compiler/regexp-checker.ts +1142 -0
- package/src/compiler/relations.ts +5149 -0
- package/src/compiler/reparser.ts +1566 -0
- package/src/compiler/scanner.ts +2951 -0
- package/src/compiler/show-config.ts +239 -0
- package/src/compiler/side-state.ts +125 -0
- package/src/compiler/sourcemap.ts +366 -0
- package/src/compiler/spelling.ts +122 -0
- package/src/compiler/symbol-accessibility.ts +1071 -0
- package/src/compiler/symbol.ts +439 -0
- package/src/compiler/symlinks.ts +137 -0
- package/src/compiler/syntax-kind.ts +391 -0
- package/src/compiler/thread-entry.ts +191 -0
- package/src/compiler/timeline.ts +53 -0
- package/src/compiler/transformers/alias-references.ts +757 -0
- package/src/compiler/transformers/async-utilities.ts +335 -0
- package/src/compiler/transformers/async.ts +838 -0
- package/src/compiler/transformers/class-fields.ts +2967 -0
- package/src/compiler/transformers/class-utilities.ts +324 -0
- package/src/compiler/transformers/commonjs-module.ts +1621 -0
- package/src/compiler/transformers/const-enum-inliner.ts +50 -0
- package/src/compiler/transformers/declarations-diagnostics.ts +832 -0
- package/src/compiler/transformers/declarations-pseudo.ts +966 -0
- package/src/compiler/transformers/declarations-resolver.ts +249 -0
- package/src/compiler/transformers/declarations-syntactic.ts +1859 -0
- package/src/compiler/transformers/declarations-tracker.ts +269 -0
- package/src/compiler/transformers/declarations.ts +3120 -0
- package/src/compiler/transformers/decorator-metadata.ts +697 -0
- package/src/compiler/transformers/decorator-utilities.ts +283 -0
- package/src/compiler/transformers/destructuring.ts +708 -0
- package/src/compiler/transformers/downlevel.ts +50 -0
- package/src/compiler/transformers/emit-resolver.ts +258 -0
- package/src/compiler/transformers/es-decorators.ts +2682 -0
- package/src/compiler/transformers/exponentiation.ts +80 -0
- package/src/compiler/transformers/external-module-info.ts +412 -0
- package/src/compiler/transformers/for-await.ts +687 -0
- package/src/compiler/transformers/import-elision.ts +152 -0
- package/src/compiler/transformers/jsx-entities.ts +256 -0
- package/src/compiler/transformers/jsx.ts +824 -0
- package/src/compiler/transformers/legacy-decorators.ts +726 -0
- package/src/compiler/transformers/logical-assignment.ts +75 -0
- package/src/compiler/transformers/module-utilities.ts +42 -0
- package/src/compiler/transformers/module.ts +474 -0
- package/src/compiler/transformers/named-evaluation.ts +389 -0
- package/src/compiler/transformers/nullish-coalescing.ts +35 -0
- package/src/compiler/transformers/object-rest-spread.ts +577 -0
- package/src/compiler/transformers/optional-catch.ts +29 -0
- package/src/compiler/transformers/optional-chain.ts +246 -0
- package/src/compiler/transformers/reference-resolver.ts +1201 -0
- package/src/compiler/transformers/runtime-syntax.ts +942 -0
- package/src/compiler/transformers/subtree-facts.ts +245 -0
- package/src/compiler/transformers/syntax-facts.ts +353 -0
- package/src/compiler/transformers/tagged-template.ts +167 -0
- package/src/compiler/transformers/transformer.ts +56 -0
- package/src/compiler/transformers/type-eraser.ts +520 -0
- package/src/compiler/transformers/type-serialization.ts +374 -0
- package/src/compiler/transformers/using.ts +613 -0
- package/src/compiler/transformers/utilities.ts +419 -0
- package/src/compiler/transformers/visitor-base.ts +1601 -0
- package/src/compiler/transformers/visitor-hooks.ts +252 -0
- package/src/compiler/tsc-build.ts +1418 -0
- package/src/compiler/tsc-cli.ts +666 -0
- package/src/compiler/tsc-compile.ts +437 -0
- package/src/compiler/tsc-watch.ts +854 -0
- package/src/compiler/tsconfig.ts +1574 -0
- package/src/compiler/type-printer.ts +110 -0
- package/src/compiler/types.ts +115 -0
- package/src/compiler/unicode-identifiers.ts +212 -0
- package/src/compiler/unicode-properties.ts +537 -0
- package/src/compiler/vfs-match.ts +597 -0
- package/src/compiler/xxh3.ts +650 -0
- package/src/library/ast.generated.ts +141 -167
- package/src/library/ast.ts +4 -1
- package/src/library/checker.ts +384 -0
- package/src/library/diagnostics.ts +72 -0
- package/src/library/disk.ts +73 -0
- package/src/library/errors.ts +26 -0
- package/src/library/host.ts +63 -0
- package/src/library/index.ts +21 -0
- package/src/library/nodes.ts +232 -0
- package/src/library/options.ts +449 -0
- package/src/library/parse.ts +63 -0
- package/src/library/program.ts +293 -0
- package/src/library/types.ts +14 -1
|
@@ -0,0 +1,672 @@
|
|
|
1
|
+
// Property access: member lookup on `a.b` and `A.B`, accessibility and readonly checks, and
|
|
2
|
+
// errors for missing members.
|
|
3
|
+
import { ScriptTarget, getUseDefineForClassFields } from './options.js';
|
|
4
|
+
import { checkExternalEmitHelpers } from './checker-emit-helpers.js';
|
|
5
|
+
import { getBody, getExpression, getName, getParameters, getSymbol, getText, getType, BinaryExpression, getInitializer, } from './ast.js';
|
|
6
|
+
import { declarationNameToString, getContainingClass, getSourceFileOfNode, getThisContainer, isAccessExpression, hasSyntacticModifier, isClassLike, isOptionalChain, isPrivateIdentifierClassElementDeclaration, isStatic, skipParentheses, getElementOrPropertyAccessName, isBindableStaticAccessExpression, isBindableStaticNameExpression, } from './binder-utilities.js';
|
|
7
|
+
import { isFunctionLike, isInJSFile } from './ast-utilities.js';
|
|
8
|
+
import { createDiagnosticForNode } from './checker.js';
|
|
9
|
+
import { getSymbolId } from './symbol.js';
|
|
10
|
+
import { everyContainedType, getTargetType, getUnionType, isEmptyObjectType, isErrorType, typesOf, } from './checker-type-factory.js';
|
|
11
|
+
import { getApparentType, getApplicableIndexInfoForName, getDeclarationModifierFlagsFromSymbol, getPropertiesOfType, getPropertiesOfUnionOrIntersectionType, getPropertyOfType, getPropertyOfTypeEx, isConflictingPrivateProperty, isDiscriminantWithNeverType, } from './checker-members.js';
|
|
12
|
+
import { getDeclarationOfAliasSymbol, getParentOfSymbol, getSpellingSuggestionForName, getSymbolOfDeclaration, } from './checker-symbols.js';
|
|
13
|
+
import { getFeatureMap } from './checker-features.js';
|
|
14
|
+
import { lazyObjectFlags } from './side-state.js';
|
|
15
|
+
import { isNodeDescendantOf } from './instantiation.js';
|
|
16
|
+
import { getTypeOfSymbol, getWidenedType, getWriteTypeOfSymbol, isReadonlySymbol } from './checker-symbol-types.js';
|
|
17
|
+
import { getClassLikeDeclarationOfSymbol, getConstraintOfTypeParameter, getDeclaredTypeOfSymbol, hasBaseType, } from './checker-declared-types.js';
|
|
18
|
+
import { getBaseConstraintOfType } from './checker-members.js';
|
|
19
|
+
import { getTypeFromTypeNode } from './checker-type-nodes.js';
|
|
20
|
+
import { isGenericObjectType } from './checker-type-operators.js';
|
|
21
|
+
import { typeToString, symbolToString } from './type-printer.js';
|
|
22
|
+
import { getPromisedTypeOfPromise } from './checker-iteration.js';
|
|
23
|
+
import { getAssignmentTargetKind, getControlFlowContainer } from './checker-narrowing.js';
|
|
24
|
+
import { getSymbolNameForPrivateIdentifier } from './binder.js';
|
|
25
|
+
import { checkPropertyNotUsedBeforeDeclaration } from './checker-declaration-order.js';
|
|
26
|
+
import { grammarErrorOnNode } from './checker-operators.js';
|
|
27
|
+
import { markPropertyAliasReferenced } from './checker-modules.js';
|
|
28
|
+
import { checkDeprecatedIndexSignature, checkDeprecatedProperty } from './checker-deprecation.js';
|
|
29
|
+
import { isSelfTypeAccess, markPropertyAsReferenced } from './checker-unused.js';
|
|
30
|
+
import { getContextualThisParameterType, getFlowTypeOfAccessExpression, getResolvedSymbol, } from './checker-expressions.js';
|
|
31
|
+
import { isJSLiteralType, isThisPropertyAccessInConstructor } from './checker-javascript.js';
|
|
32
|
+
export function checkPropertyAccessExpressionOrQualifiedName(c, node, left, leftType, right, writeOnly, checkMode = 0 /* CheckMode.Normal */) {
|
|
33
|
+
const parentSymbol = c.resolvedSymbols.get(left.id);
|
|
34
|
+
const assignmentKind = getAssignmentTargetKind(node);
|
|
35
|
+
const widenedType = assignmentKind !== 0 /* AssignmentKind.None */ || isMethodAccessForCall(node) ? getWidenedType(c, leftType) : leftType;
|
|
36
|
+
const apparentType = getApparentType(c, widenedType);
|
|
37
|
+
const isAnyLike = (apparentType.flags & 1 /* TypeFlags.Any */) !== 0 || apparentType === c.silentNeverType;
|
|
38
|
+
const name = getText(right);
|
|
39
|
+
const isPrivate = right.kind === 80 /* SyntaxKind.PrivateIdentifier */;
|
|
40
|
+
let prop = undefined;
|
|
41
|
+
if (isPrivate) {
|
|
42
|
+
// Downleveled private names use __classPrivateFieldGet and __classPrivateFieldSet.
|
|
43
|
+
if (c.languageVersion < ScriptTarget.ESNext || !getUseDefineForClassFields(c.compilerOptions)) {
|
|
44
|
+
if (assignmentKind !== 0 /* AssignmentKind.None */)
|
|
45
|
+
checkExternalEmitHelpers(c, node, 16384 /* ExternalEmitHelpers.ClassPrivateFieldSet */);
|
|
46
|
+
if (assignmentKind !== 1 /* AssignmentKind.Definite */)
|
|
47
|
+
checkExternalEmitHelpers(c, node, 8192 /* ExternalEmitHelpers.ClassPrivateFieldGet */);
|
|
48
|
+
}
|
|
49
|
+
const lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(name, right);
|
|
50
|
+
if (assignmentKind !== 0 /* AssignmentKind.None */ &&
|
|
51
|
+
lexicallyScopedSymbol !== undefined &&
|
|
52
|
+
lexicallyScopedSymbol.valueDeclaration !== undefined &&
|
|
53
|
+
lexicallyScopedSymbol.valueDeclaration.kind === 175 /* SyntaxKind.MethodDeclaration */)
|
|
54
|
+
grammarErrorOnNode(c, right, 935 /* Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable */, name);
|
|
55
|
+
if (isAnyLike) {
|
|
56
|
+
if (lexicallyScopedSymbol !== undefined)
|
|
57
|
+
return isErrorType(c, apparentType) ? c.errorType : apparentType;
|
|
58
|
+
if (getContainingClassExcludingClassDecorators(right) === undefined) {
|
|
59
|
+
grammarErrorOnNode(c, right, 1838 /* Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies */);
|
|
60
|
+
return c.anyType;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (lexicallyScopedSymbol !== undefined)
|
|
64
|
+
prop = getPropertyOfType(c, leftType, lexicallyScopedSymbol.name);
|
|
65
|
+
if (prop === undefined) {
|
|
66
|
+
// Shadowing and lexical scoping errors specific to private names.
|
|
67
|
+
if (checkPrivateIdentifierPropertyAccess(c, leftType, right, lexicallyScopedSymbol))
|
|
68
|
+
return c.errorType;
|
|
69
|
+
}
|
|
70
|
+
else if ((prop.flags & 65536 /* SymbolFlags.SetAccessor */) !== 0 &&
|
|
71
|
+
(prop.flags & 32768 /* SymbolFlags.GetAccessor */) === 0 &&
|
|
72
|
+
assignmentKind !== 1 /* AssignmentKind.Definite */)
|
|
73
|
+
c.error(node, 937 /* Diagnostics.Private_accessor_was_defined_without_a_getter */);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
if (isAnyLike) {
|
|
77
|
+
if (left.kind === 79 /* SyntaxKind.Identifier */ && c.resolvedSymbols.get(left.id) !== undefined)
|
|
78
|
+
markPropertyAliasReferenced(c, node, undefined, leftType);
|
|
79
|
+
return isErrorType(c, apparentType) ? c.errorType : apparentType;
|
|
80
|
+
}
|
|
81
|
+
prop = getPropertyOfTypeEx(c, apparentType, name, isConstEnumObjectType(apparentType), node.kind === 167 /* SyntaxKind.QualifiedName */);
|
|
82
|
+
}
|
|
83
|
+
markPropertyAliasReferenced(c, node, prop, leftType);
|
|
84
|
+
let propType;
|
|
85
|
+
if (prop === undefined) {
|
|
86
|
+
const indexInfo = !isPrivate &&
|
|
87
|
+
(assignmentKind === 0 /* AssignmentKind.None */ || !isGenericObjectType(c, leftType) || isThisTypeParameter(leftType))
|
|
88
|
+
? getApplicableIndexInfoForName(c, apparentType, name)
|
|
89
|
+
: undefined;
|
|
90
|
+
if (indexInfo === undefined) {
|
|
91
|
+
if (isJSLiteralType(c, leftType))
|
|
92
|
+
return c.anyType;
|
|
93
|
+
if (leftType.symbol === c.globalThisSymbol) {
|
|
94
|
+
const globalSymbol = c.globalThisSymbol.exports?.get(name);
|
|
95
|
+
if (globalSymbol !== undefined && (globalSymbol.flags & 418 /* SymbolFlags.BlockScoped */) !== 0)
|
|
96
|
+
c.error(right, 516 /* Diagnostics.Property_0_does_not_exist_on_type_1 */, name, typeToString(c, leftType));
|
|
97
|
+
else if (c.noImplicitAny)
|
|
98
|
+
c.error(right, 1689 /* Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature */, typeToString(c, leftType));
|
|
99
|
+
return c.anyType;
|
|
100
|
+
}
|
|
101
|
+
if (name !== '')
|
|
102
|
+
reportNonexistentProperty(c, right, isThisTypeParameter(leftType) ? apparentType : leftType);
|
|
103
|
+
return c.errorType;
|
|
104
|
+
}
|
|
105
|
+
if (indexInfo.isReadonly && (assignmentKind !== 0 /* AssignmentKind.None */ || isDeleteTarget(node)))
|
|
106
|
+
c.error(node, 698 /* Diagnostics.Index_signature_in_type_0_only_permits_reading */, typeToString(c, apparentType));
|
|
107
|
+
propType = indexInfo.valueType;
|
|
108
|
+
if (c.noUncheckedIndexedAccess && assignmentKind !== 1 /* AssignmentKind.Definite */)
|
|
109
|
+
propType = getUnionType(c, [propType, c.missingType]);
|
|
110
|
+
if (c.compilerOptions.noPropertyAccessFromIndexSignature === true &&
|
|
111
|
+
node.kind === 212 /* SyntaxKind.PropertyAccessExpression */)
|
|
112
|
+
c.error(right, 1097 /* Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0 */, name);
|
|
113
|
+
checkDeprecatedIndexSignature(c, right, indexInfo.declaration);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
checkDeprecatedProperty(c, node, right, prop);
|
|
117
|
+
checkPropertyNotUsedBeforeDeclaration(c, prop, node, right);
|
|
118
|
+
markPropertyAsReferenced(c, prop, node, isSelfTypeAccess(c, left, parentSymbol));
|
|
119
|
+
// An access checked again (under another check mode) usually resolves to the same property.
|
|
120
|
+
if (c.resolvedSymbols.get(node.id) !== prop)
|
|
121
|
+
c.resolvedSymbols.set(node.id, prop);
|
|
122
|
+
checkPropertyAccessibility(c, node, left.kind === 107 /* SyntaxKind.SuperKeyword */, assignmentKind !== 0 /* AssignmentKind.None */, apparentType, prop);
|
|
123
|
+
if (isAssignmentToReadonlyEntity(c, node, prop, assignmentKind)) {
|
|
124
|
+
c.error(right, 697 /* Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property */, name);
|
|
125
|
+
return c.errorType;
|
|
126
|
+
}
|
|
127
|
+
if (isThisPropertyAccessInConstructor(c, node, prop))
|
|
128
|
+
propType = c.autoType;
|
|
129
|
+
else
|
|
130
|
+
propType =
|
|
131
|
+
writeOnly || assignmentKind === 1 /* AssignmentKind.Definite */
|
|
132
|
+
? getWriteTypeOfSymbol(c, prop)
|
|
133
|
+
: getTypeOfSymbol(c, prop);
|
|
134
|
+
}
|
|
135
|
+
return getFlowTypeOfAccessExpression(c, node, prop, propType, right, checkMode);
|
|
136
|
+
}
|
|
137
|
+
/** Whether `node` is a property of an object destructuring assignment from `this`. */
|
|
138
|
+
function isThisInitializedObjectBindingExpression(node) {
|
|
139
|
+
if (node.kind !== 304 /* SyntaxKind.ShorthandPropertyAssignment */ && node.kind !== 303 /* SyntaxKind.PropertyAssignment */)
|
|
140
|
+
return false;
|
|
141
|
+
const binary = node.parent.parent;
|
|
142
|
+
return (binary.kind === 227 /* SyntaxKind.BinaryExpression */ &&
|
|
143
|
+
binary.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ &&
|
|
144
|
+
binary.right.kind === 109 /* SyntaxKind.ThisKeyword */);
|
|
145
|
+
}
|
|
146
|
+
function isThisInitializedDeclaration(node) {
|
|
147
|
+
if (node.kind !== 261 /* SyntaxKind.VariableDeclaration */)
|
|
148
|
+
return false;
|
|
149
|
+
const initializer = getInitializer(node);
|
|
150
|
+
return initializer !== undefined && initializer.kind === 109 /* SyntaxKind.ThisKeyword */;
|
|
151
|
+
}
|
|
152
|
+
// ---- Private names
|
|
153
|
+
/** A private name used as an expression, as in `#x in obj`; records its declaration. */
|
|
154
|
+
export function checkPrivateIdentifierExpression(c, node) {
|
|
155
|
+
const symbol = getSymbolForPrivateIdentifierExpression(c, node);
|
|
156
|
+
if (symbol !== undefined)
|
|
157
|
+
markPropertyAsReferenced(c, symbol, undefined, false);
|
|
158
|
+
return c.anyType;
|
|
159
|
+
}
|
|
160
|
+
export function getSymbolForPrivateIdentifierExpression(c, node) {
|
|
161
|
+
let symbol = c.resolvedSymbols.get(node.id);
|
|
162
|
+
if (symbol === undefined) {
|
|
163
|
+
symbol = lookupSymbolForPrivateIdentifierDeclaration(getText(node), node);
|
|
164
|
+
c.resolvedSymbols.set(node.id, symbol);
|
|
165
|
+
}
|
|
166
|
+
return symbol;
|
|
167
|
+
}
|
|
168
|
+
/** The declaration of a private name in the enclosing classes, innermost first. */
|
|
169
|
+
function lookupSymbolForPrivateIdentifierDeclaration(name, location) {
|
|
170
|
+
for (let containingClass = getContainingClassExcludingClassDecorators(location); containingClass !== undefined; containingClass = getContainingClass(containingClass)) {
|
|
171
|
+
const symbol = getSymbol(containingClass);
|
|
172
|
+
if (symbol === undefined)
|
|
173
|
+
continue;
|
|
174
|
+
const memberName = getSymbolNameForPrivateIdentifier(symbol, name);
|
|
175
|
+
const prop = symbol.members?.get(memberName) ?? symbol.exports?.get(memberName);
|
|
176
|
+
if (prop !== undefined)
|
|
177
|
+
return prop;
|
|
178
|
+
}
|
|
179
|
+
return undefined;
|
|
180
|
+
}
|
|
181
|
+
/** The containing class of `node`, skipping classes whose decorators contain it. */
|
|
182
|
+
function getContainingClassExcludingClassDecorators(node) {
|
|
183
|
+
for (let current = node.parent; current !== undefined; current = current.parent) {
|
|
184
|
+
if (isClassLike(current))
|
|
185
|
+
break;
|
|
186
|
+
if (current.kind === 171 /* SyntaxKind.Decorator */) {
|
|
187
|
+
if (current.parent !== undefined && isClassLike(current.parent))
|
|
188
|
+
return getContainingClass(current.parent);
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return getContainingClass(node);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Reports a private name that's on the type but not reachable here: shadowed by another
|
|
196
|
+
* private name of the same spelling, or accessed outside its class.
|
|
197
|
+
*/
|
|
198
|
+
function checkPrivateIdentifierPropertyAccess(c, leftType, right, lexicallyScopedIdentifier) {
|
|
199
|
+
let propertyOnType = undefined;
|
|
200
|
+
for (const symbol of getPropertiesOfType(c, leftType)) {
|
|
201
|
+
const declaration = symbol.valueDeclaration;
|
|
202
|
+
const name = declaration !== undefined ? getName(declaration) : undefined;
|
|
203
|
+
if (name !== undefined && name.kind === 80 /* SyntaxKind.PrivateIdentifier */ && getText(name) === getText(right)) {
|
|
204
|
+
propertyOnType = symbol;
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (propertyOnType === undefined)
|
|
209
|
+
return false;
|
|
210
|
+
const diagName = declarationNameToString(getSourceFileOfNode(right), right);
|
|
211
|
+
const typeValueDecl = propertyOnType.valueDeclaration;
|
|
212
|
+
const typeClass = getContainingClass(typeValueDecl);
|
|
213
|
+
const lexicalValueDecl = lexicallyScopedIdentifier?.valueDeclaration;
|
|
214
|
+
if (lexicalValueDecl !== undefined) {
|
|
215
|
+
for (let n = getContainingClass(lexicalValueDecl); n !== undefined; n = n.parent) {
|
|
216
|
+
if (n !== typeClass)
|
|
217
|
+
continue;
|
|
218
|
+
const diagnostic = c.error(right, 1836 /* Diagnostics.The_property_0_cannot_be_accessed_on_type_1_within_this_class_because_it_is_shadowed_by_another_private_identifier_with_the_same_spelling */, diagName, typeToString(c, leftType));
|
|
219
|
+
diagnostic.addRelatedInfo(createDiagnosticForNode(lexicalValueDecl, 1839 /* Diagnostics.The_shadowing_declaration_of_0_is_defined_here */, [
|
|
220
|
+
diagName,
|
|
221
|
+
]));
|
|
222
|
+
diagnostic.addRelatedInfo(createDiagnosticForNode(typeValueDecl, 1840 /* Diagnostics.The_declaration_of_0_that_you_probably_intended_to_use_is_defined_here */, [diagName]));
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
c.error(right, 1835 /* Diagnostics.Property_0_is_not_accessible_outside_class_1_because_it_has_a_private_identifier */, diagName, symbolToString(c, getSymbol(typeClass)));
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
function isThisTypeParameter(t) {
|
|
230
|
+
return (t.flags & 524288 /* TypeFlags.TypeParameter */) !== 0 && t.isThisType;
|
|
231
|
+
}
|
|
232
|
+
function isConstEnumObjectType(t) {
|
|
233
|
+
return ((t.objectFlags & 16 /* ObjectFlags.Anonymous */) !== 0 &&
|
|
234
|
+
t.symbol !== undefined &&
|
|
235
|
+
(t.symbol.flags & 128 /* SymbolFlags.ConstEnum */) !== 0);
|
|
236
|
+
}
|
|
237
|
+
export function isMethodAccessForCall(node) {
|
|
238
|
+
let current = node;
|
|
239
|
+
while (current.parent.kind === 218 /* SyntaxKind.ParenthesizedExpression */)
|
|
240
|
+
current = current.parent;
|
|
241
|
+
const parent = current.parent;
|
|
242
|
+
return ((parent.kind === 214 /* SyntaxKind.CallExpression */ || parent.kind === 215 /* SyntaxKind.NewExpression */) &&
|
|
243
|
+
getExpression(parent) === current);
|
|
244
|
+
}
|
|
245
|
+
/** Whether `node` is the operand of `delete`, through parentheses. */
|
|
246
|
+
export function isDeleteTarget(node) {
|
|
247
|
+
if (!isAccessExpression(node))
|
|
248
|
+
return false;
|
|
249
|
+
let current = node.parent;
|
|
250
|
+
while (current.kind === 218 /* SyntaxKind.ParenthesizedExpression */)
|
|
251
|
+
current = current.parent;
|
|
252
|
+
return current.kind === 221 /* SyntaxKind.DeleteExpression */;
|
|
253
|
+
}
|
|
254
|
+
/** Whether assigning through `expr` targets a readonly entity, outside of initialization. */
|
|
255
|
+
export function isAssignmentToReadonlyEntity(c, expr, symbol, assignmentKind) {
|
|
256
|
+
if (assignmentKind === 0 /* AssignmentKind.None */)
|
|
257
|
+
return false;
|
|
258
|
+
// CommonJS `module.exports` is never readonly.
|
|
259
|
+
if (isAccessExpression(expr)) {
|
|
260
|
+
const target = skipParentheses(getExpression(expr));
|
|
261
|
+
if (target.kind === 79 /* SyntaxKind.Identifier */ && (getResolvedSymbol(c, target).flags & 134217728 /* SymbolFlags.ModuleExports */) !== 0)
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
if (isReadonlySymbol(c, symbol)) {
|
|
265
|
+
// Readonly properties may be assigned through `this` in the constructor of their class.
|
|
266
|
+
if ((symbol.flags & 4 /* SymbolFlags.Property */) !== 0 &&
|
|
267
|
+
isAccessExpression(expr) &&
|
|
268
|
+
getExpression(expr).kind === 109 /* SyntaxKind.ThisKeyword */) {
|
|
269
|
+
const ctor = getControlFlowContainer(expr);
|
|
270
|
+
if (ctor.kind !== 177 /* SyntaxKind.Constructor */)
|
|
271
|
+
return true;
|
|
272
|
+
const declaration = symbol.valueDeclaration;
|
|
273
|
+
if (declaration !== undefined) {
|
|
274
|
+
const isLocalPropertyDeclaration = ctor.parent === declaration.parent;
|
|
275
|
+
const isLocalParameterProperty = ctor === declaration.parent;
|
|
276
|
+
// A JavaScript `this.x = …` declaration of this class or constructor function.
|
|
277
|
+
const isAssignmentDeclaration = declaration.kind === 227 /* SyntaxKind.BinaryExpression */;
|
|
278
|
+
const parentDeclaration = symbol.parent?.valueDeclaration;
|
|
279
|
+
const isLocalThisPropertyAssignment = isAssignmentDeclaration && (parentDeclaration === ctor.parent || parentDeclaration === ctor);
|
|
280
|
+
return !isLocalPropertyDeclaration && !isLocalParameterProperty && !isLocalThisPropertyAssignment;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return true;
|
|
284
|
+
}
|
|
285
|
+
if (isAccessExpression(expr)) {
|
|
286
|
+
// References through namespace imports are readonly.
|
|
287
|
+
const node = skipParentheses(getExpression(expr));
|
|
288
|
+
if (node.kind === 79 /* SyntaxKind.Identifier */) {
|
|
289
|
+
const expressionSymbol = getResolvedSymbol(c, node);
|
|
290
|
+
if ((expressionSymbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0) {
|
|
291
|
+
const declaration = getDeclarationOfAliasSymbol(expressionSymbol);
|
|
292
|
+
return declaration !== undefined && declaration.kind === 275 /* SyntaxKind.NamespaceImport */;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
// ---- Accessibility
|
|
299
|
+
/** Checks that `prop` of `containingType` may be accessed at `node`; reports and returns false otherwise. */
|
|
300
|
+
export function checkPropertyAccessibility(c, node, isSuper, writing, containingType, prop) {
|
|
301
|
+
let errorNode;
|
|
302
|
+
if (node.kind === 212 /* SyntaxKind.PropertyAccessExpression */)
|
|
303
|
+
errorNode = node.name;
|
|
304
|
+
else if (node.kind === 167 /* SyntaxKind.QualifiedName */)
|
|
305
|
+
errorNode = node.right;
|
|
306
|
+
else if (node.kind === 206 /* SyntaxKind.ImportType */)
|
|
307
|
+
errorNode = node;
|
|
308
|
+
else if (node.kind === 209 /* SyntaxKind.BindingElement */)
|
|
309
|
+
errorNode = node.propertyName ?? node.name;
|
|
310
|
+
else
|
|
311
|
+
errorNode = getName(node) ?? node;
|
|
312
|
+
return checkPropertyAccessibilityAtLocation(c, node, isSuper, writing, containingType, prop, errorNode);
|
|
313
|
+
}
|
|
314
|
+
/** Whether `prop` of `containingType` may be accessed at `node`, without reporting errors. */
|
|
315
|
+
export function isPropertyAccessible(c, node, isSuper, isWrite, containingType, prop) {
|
|
316
|
+
if ((containingType.flags & 1 /* TypeFlags.Any */) !== 0)
|
|
317
|
+
return true;
|
|
318
|
+
// A #private property access in an optional chain is an error the parser reports.
|
|
319
|
+
const declaration = prop.valueDeclaration;
|
|
320
|
+
if (declaration !== undefined && isPrivateIdentifierClassElementDeclaration(declaration)) {
|
|
321
|
+
const declaringClass = getContainingClass(declaration);
|
|
322
|
+
return !isOptionalChain(node) && declaringClass !== undefined && isNodeDescendantOf(node, declaringClass);
|
|
323
|
+
}
|
|
324
|
+
return checkPropertyAccessibilityAtLocation(c, node, isSuper, isWrite, containingType, prop, undefined);
|
|
325
|
+
}
|
|
326
|
+
function checkPropertyAccessibilityAtLocation(c, location, isSuper, writing, containingTypeIn, prop, errorNode) {
|
|
327
|
+
const flags = getDeclarationModifierFlagsFromSymbol(c, prop, writing);
|
|
328
|
+
if (isSuper) {
|
|
329
|
+
// Abstract methods can't be reached through `super`.
|
|
330
|
+
if ((flags & 64 /* ModifierFlags.Abstract */) !== 0) {
|
|
331
|
+
if (errorNode !== undefined)
|
|
332
|
+
c.error(errorNode, 673 /* Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression */, symbolToString(c, prop), typeToString(c, getDeclaringClass(c, prop)));
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
// Class fields of the parent aren't on the prototype.
|
|
336
|
+
if ((flags & 256 /* ModifierFlags.Static */) === 0 && hasClassInstancePropertyDeclaration(prop)) {
|
|
337
|
+
if (errorNode !== undefined)
|
|
338
|
+
c.error(errorNode, 975 /* Diagnostics.Class_field_0_defined_by_the_parent_class_is_not_accessible_in_the_child_class_via_super */, symbolToString(c, prop));
|
|
339
|
+
return false;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
// Abstract properties can't be read during initialization of their class.
|
|
343
|
+
if ((flags & 64 /* ModifierFlags.Abstract */) !== 0 &&
|
|
344
|
+
symbolHasNonMethodDeclaration(c, prop) &&
|
|
345
|
+
(isThisProperty(location) ||
|
|
346
|
+
isThisInitializedObjectBindingExpression(location) ||
|
|
347
|
+
(location.parent.kind === 207 /* SyntaxKind.ObjectBindingPattern */ &&
|
|
348
|
+
isThisInitializedDeclaration(location.parent.parent)))) {
|
|
349
|
+
const parentSymbol = getParentOfSymbol(c, prop);
|
|
350
|
+
if (parentSymbol !== undefined &&
|
|
351
|
+
(parentSymbol.flags & 32 /* SymbolFlags.Class */) !== 0 &&
|
|
352
|
+
isNodeUsedDuringClassInitialization(location)) {
|
|
353
|
+
if (errorNode !== undefined)
|
|
354
|
+
c.error(errorNode, 847 /* Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor */, symbolToString(c, prop), symbolToString(c, parentSymbol));
|
|
355
|
+
return false;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
if ((flags & 6 /* ModifierFlags.NonPublicAccessibilityModifier */) === 0)
|
|
359
|
+
return true;
|
|
360
|
+
// Private members are accessible within their declaring class.
|
|
361
|
+
if ((flags & 2 /* ModifierFlags.Private */) !== 0) {
|
|
362
|
+
const parent = getParentOfSymbol(c, prop);
|
|
363
|
+
const declaringClassDeclaration = parent !== undefined ? getClassLikeDeclarationOfSymbol(parent) : undefined;
|
|
364
|
+
if (!isNodeWithinClass(location, declaringClassDeclaration)) {
|
|
365
|
+
if (errorNode !== undefined)
|
|
366
|
+
c.error(errorNode, 518 /* Diagnostics.Property_0_is_private_and_only_accessible_within_class_1 */, symbolToString(c, prop), typeToString(c, getDeclaringClass(c, prop)));
|
|
367
|
+
return false;
|
|
368
|
+
}
|
|
369
|
+
return true;
|
|
370
|
+
}
|
|
371
|
+
// Protected members of a supertype are accessible through `super`.
|
|
372
|
+
if (isSuper)
|
|
373
|
+
return true;
|
|
374
|
+
// The first enclosing class deriving from the declaring classes of the protected constituents.
|
|
375
|
+
let enclosingClass = undefined;
|
|
376
|
+
for (let container = getContainingClass(location); container !== undefined; container = getContainingClass(container)) {
|
|
377
|
+
const classSymbol = getSymbolOfDeclaration(c, container);
|
|
378
|
+
if (classSymbol === undefined)
|
|
379
|
+
continue;
|
|
380
|
+
const classType = getDeclaredTypeOfSymbol(c, classSymbol);
|
|
381
|
+
if (isClassDerivedFromDeclaringClasses(c, classType, prop, writing)) {
|
|
382
|
+
enclosingClass = classType;
|
|
383
|
+
break;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
if (enclosingClass === undefined) {
|
|
387
|
+
// Functions with a `this` parameter of a derived class may access instance members.
|
|
388
|
+
const thisClass = getEnclosingClassFromThisParameter(c, location);
|
|
389
|
+
if (thisClass !== undefined && isClassDerivedFromDeclaringClasses(c, thisClass, prop, writing))
|
|
390
|
+
enclosingClass = thisClass;
|
|
391
|
+
if ((flags & 256 /* ModifierFlags.Static */) !== 0 || enclosingClass === undefined) {
|
|
392
|
+
if (errorNode !== undefined)
|
|
393
|
+
c.error(errorNode, 613 /* Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses */, symbolToString(c, prop), typeToString(c, getDeclaringClass(c, prop) ?? containingTypeIn));
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
if ((flags & 256 /* ModifierFlags.Static */) !== 0)
|
|
398
|
+
return true;
|
|
399
|
+
let containingType = containingTypeIn;
|
|
400
|
+
if ((containingType.flags & 524288 /* TypeFlags.TypeParameter */) !== 0)
|
|
401
|
+
containingType = containingType.isThisType
|
|
402
|
+
? getConstraintOfTypeParameter(c, containingType)
|
|
403
|
+
: getBaseConstraintOfType(c, containingType);
|
|
404
|
+
if (containingType === undefined || !hasBaseType(c, containingType, enclosingClass)) {
|
|
405
|
+
if (containingType !== undefined && errorNode !== undefined)
|
|
406
|
+
c.error(errorNode, 614 /* Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_class_2 */, symbolToString(c, prop), typeToString(c, enclosingClass), typeToString(c, containingType));
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
return true;
|
|
410
|
+
}
|
|
411
|
+
function hasClassInstancePropertyDeclaration(symbol) {
|
|
412
|
+
for (const d of symbol.declarations)
|
|
413
|
+
if (isClassInstanceProperty(d))
|
|
414
|
+
return true;
|
|
415
|
+
return false;
|
|
416
|
+
}
|
|
417
|
+
function isClassInstanceProperty(node) {
|
|
418
|
+
// `this.x = v` in JavaScript declares a field, but `C.prototype.x = v` and `C.x = v` don't.
|
|
419
|
+
if (isInJSFile(node) && node instanceof BinaryExpression) {
|
|
420
|
+
const left = node.left;
|
|
421
|
+
return ((!isBindableStaticAccessExpression(left, false) || !isPrototypeAccess(getExpression(left))) &&
|
|
422
|
+
!isBindableStaticNameExpression(left, true));
|
|
423
|
+
}
|
|
424
|
+
return (node.parent !== undefined &&
|
|
425
|
+
isClassLike(node.parent) &&
|
|
426
|
+
node.kind === 173 /* SyntaxKind.PropertyDeclaration */ &&
|
|
427
|
+
!isStatic(node) &&
|
|
428
|
+
!hasSyntacticModifier(node, 512 /* ModifierFlags.Accessor */));
|
|
429
|
+
}
|
|
430
|
+
function isPrototypeAccess(node) {
|
|
431
|
+
if (!isBindableStaticAccessExpression(node, false))
|
|
432
|
+
return false;
|
|
433
|
+
const name = getElementOrPropertyAccessName(node);
|
|
434
|
+
return name !== undefined && getText(name) === 'prototype';
|
|
435
|
+
}
|
|
436
|
+
function isThisProperty(node) {
|
|
437
|
+
return isAccessExpression(node) && getExpression(node).kind === 109 /* SyntaxKind.ThisKeyword */;
|
|
438
|
+
}
|
|
439
|
+
function isNodeUsedDuringClassInitialization(node) {
|
|
440
|
+
for (let element = node.parent; element !== undefined; element = element.parent) {
|
|
441
|
+
if ((element.kind === 177 /* SyntaxKind.Constructor */ && getBody(element) !== undefined) ||
|
|
442
|
+
element.kind === 173 /* SyntaxKind.PropertyDeclaration */)
|
|
443
|
+
return true;
|
|
444
|
+
if (isClassLike(element) || isFunctionLike(element))
|
|
445
|
+
return false;
|
|
446
|
+
}
|
|
447
|
+
return false;
|
|
448
|
+
}
|
|
449
|
+
/** The declaring class of a class member. */
|
|
450
|
+
export function getDeclaringClass(c, prop) {
|
|
451
|
+
if (prop.parent === undefined || (prop.parent.flags & 32 /* SymbolFlags.Class */) === 0)
|
|
452
|
+
return undefined;
|
|
453
|
+
return getDeclaredTypeOfSymbol(c, getParentOfSymbol(c, prop));
|
|
454
|
+
}
|
|
455
|
+
function isNodeWithinClass(node, classDeclaration) {
|
|
456
|
+
for (let container = getContainingClass(node); container !== undefined; container = getContainingClass(container))
|
|
457
|
+
if (container === classDeclaration)
|
|
458
|
+
return true;
|
|
459
|
+
return false;
|
|
460
|
+
}
|
|
461
|
+
/** The properties a possibly synthetic union or intersection property stands for. */
|
|
462
|
+
function getUnderlyingProperties(c, prop, out) {
|
|
463
|
+
if ((prop.checkFlags & 6 /* CheckFlags.Synthetic */) === 0) {
|
|
464
|
+
out.push(prop);
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
const containingType = c.symbolContainingTypes.get(getSymbolId(prop));
|
|
468
|
+
if (containingType === undefined)
|
|
469
|
+
return;
|
|
470
|
+
for (const t of typesOf(containingType)) {
|
|
471
|
+
const p = getPropertyOfType(c, t, prop.name);
|
|
472
|
+
if (p !== undefined)
|
|
473
|
+
getUnderlyingProperties(c, p, out);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
function symbolHasNonMethodDeclaration(c, symbol) {
|
|
477
|
+
const props = [];
|
|
478
|
+
getUnderlyingProperties(c, symbol, props);
|
|
479
|
+
for (const p of props)
|
|
480
|
+
if ((p.flags & 8192 /* SymbolFlags.Method */) === 0)
|
|
481
|
+
return true;
|
|
482
|
+
return false;
|
|
483
|
+
}
|
|
484
|
+
function isClassDerivedFromDeclaringClasses(c, checkClass, prop, writing) {
|
|
485
|
+
const props = [];
|
|
486
|
+
getUnderlyingProperties(c, prop, props);
|
|
487
|
+
for (const p of props) {
|
|
488
|
+
if ((getDeclarationModifierFlagsFromSymbol(c, p, writing) & 4 /* ModifierFlags.Protected */) === 0)
|
|
489
|
+
continue;
|
|
490
|
+
const declaringClass = getDeclaringClass(c, p);
|
|
491
|
+
if (declaringClass === undefined || !hasBaseType(c, checkClass, declaringClass))
|
|
492
|
+
return false;
|
|
493
|
+
}
|
|
494
|
+
return true;
|
|
495
|
+
}
|
|
496
|
+
function getEnclosingClassFromThisParameter(c, node) {
|
|
497
|
+
const thisContainer = getThisContainer(node, false, false);
|
|
498
|
+
let thisType = undefined;
|
|
499
|
+
if (isFunctionLike(thisContainer)) {
|
|
500
|
+
const thisParameter = getThisParameterDeclaration(thisContainer);
|
|
501
|
+
const typeNode = thisParameter !== undefined ? getType(thisParameter) : undefined;
|
|
502
|
+
if (typeNode !== undefined) {
|
|
503
|
+
thisType = getTypeFromTypeNode(c, typeNode);
|
|
504
|
+
if ((thisType.flags & 524288 /* TypeFlags.TypeParameter */) !== 0)
|
|
505
|
+
thisType = getConstraintOfTypeParameter(c, thisType);
|
|
506
|
+
}
|
|
507
|
+
else
|
|
508
|
+
thisType = getContextualThisParameterType(c, thisContainer);
|
|
509
|
+
}
|
|
510
|
+
if (thisType !== undefined && (thisType.objectFlags & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */)) !== 0)
|
|
511
|
+
return getTargetType(thisType);
|
|
512
|
+
return undefined;
|
|
513
|
+
}
|
|
514
|
+
/** The explicit `this` parameter of a function, if any. */
|
|
515
|
+
function getThisParameterDeclaration(func) {
|
|
516
|
+
const parameters = getParameters(func);
|
|
517
|
+
if (parameters === undefined || parameters.nodes.length === 0)
|
|
518
|
+
return undefined;
|
|
519
|
+
const first = parameters.nodes[0];
|
|
520
|
+
const name = getName(first);
|
|
521
|
+
return name !== undefined && name.kind === 79 /* SyntaxKind.Identifier */ && getText(name) === 'this' ? first : undefined;
|
|
522
|
+
}
|
|
523
|
+
// ---- Missing properties
|
|
524
|
+
/** Reports a missing property once per name node, with the most helpful message available. */
|
|
525
|
+
export function reportNonexistentProperty(c, propNode, containingType) {
|
|
526
|
+
const links = c.nodeLinks(propNode);
|
|
527
|
+
if ((links.flags & 1) !== 0)
|
|
528
|
+
return;
|
|
529
|
+
links.flags |= 1;
|
|
530
|
+
const name = getText(propNode);
|
|
531
|
+
const missingProperty = declarationNameToString(getSourceFileOfNode(propNode), propNode);
|
|
532
|
+
const container = typeToString(c, containingType);
|
|
533
|
+
let chain = undefined;
|
|
534
|
+
if (propNode.kind !== 80 /* SyntaxKind.PrivateIdentifier */ &&
|
|
535
|
+
(containingType.flags & 134217728 /* TypeFlags.Union */) !== 0 &&
|
|
536
|
+
(containingType.flags & 12713980 /* TypeFlags.Primitive */) === 0) {
|
|
537
|
+
for (const subtype of typesOf(containingType)) {
|
|
538
|
+
if (getPropertyOfType(c, subtype, name) === undefined &&
|
|
539
|
+
getApplicableIndexInfoForName(c, subtype, name) === undefined) {
|
|
540
|
+
chain = createDiagnosticForNode(propNode, 516 /* Diagnostics.Property_0_does_not_exist_on_type_1 */, [
|
|
541
|
+
missingProperty,
|
|
542
|
+
typeToString(c, subtype),
|
|
543
|
+
]);
|
|
544
|
+
break;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
let diagnostic;
|
|
549
|
+
if (typeHasStaticProperty(c, name, containingType))
|
|
550
|
+
diagnostic = createDiagnosticForNode(propNode, 727 /* Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead */, [missingProperty, container, container + '.' + missingProperty]);
|
|
551
|
+
else {
|
|
552
|
+
const promisedType = getPromisedTypeOfPromise(c, containingType);
|
|
553
|
+
if (promisedType !== undefined && getPropertyOfType(c, promisedType, name) !== undefined) {
|
|
554
|
+
diagnostic = createDiagnosticForNode(propNode, 516 /* Diagnostics.Property_0_does_not_exist_on_type_1 */, [
|
|
555
|
+
missingProperty,
|
|
556
|
+
container,
|
|
557
|
+
]);
|
|
558
|
+
diagnostic.addRelatedInfo(createDiagnosticForNode(propNode, 905 /* Diagnostics.Did_you_forget_to_use_await */, []));
|
|
559
|
+
}
|
|
560
|
+
else {
|
|
561
|
+
const libSuggestion = getSuggestedLibForNonExistentProperty(c, missingProperty, containingType);
|
|
562
|
+
const suggestion = libSuggestion === '' ? getSuggestedSymbolForNonexistentProperty(c, propNode, containingType) : undefined;
|
|
563
|
+
if (libSuggestion !== '')
|
|
564
|
+
diagnostic = createDiagnosticForNode(propNode, 705 /* Diagnostics.Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2_or_later */, [missingProperty, container, libSuggestion]);
|
|
565
|
+
else if (suggestion !== undefined) {
|
|
566
|
+
diagnostic = createDiagnosticForNode(propNode, 706 /* Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2 */, [
|
|
567
|
+
missingProperty,
|
|
568
|
+
container,
|
|
569
|
+
suggestion.name,
|
|
570
|
+
]);
|
|
571
|
+
if (suggestion.valueDeclaration !== undefined)
|
|
572
|
+
diagnostic.addRelatedInfo(createDiagnosticForNode(suggestion.valueDeclaration, 860 /* Diagnostics.X_0_is_declared_here */, [suggestion.name]));
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
chain = elaborateNeverIntersection(c, chain, propNode, containingType);
|
|
576
|
+
diagnostic = createDiagnosticForNode(propNode, containerSeemsToBeEmptyDomElement(c, containingType)
|
|
577
|
+
? 943 /* Diagnostics.Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom */
|
|
578
|
+
: 516 /* Diagnostics.Property_0_does_not_exist_on_type_1 */, [missingProperty, container]);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
if (chain !== undefined)
|
|
583
|
+
diagnostic.addMessageChain(chain);
|
|
584
|
+
c.addDiagnostic(diagnostic);
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* `chain` under the reason an intersection reduced to `never` when `t` is one: a property with conflicting
|
|
588
|
+
* literal types, or one private in some constituents.
|
|
589
|
+
*/
|
|
590
|
+
export function elaborateNeverIntersection(c, chain, node, t) {
|
|
591
|
+
if ((t.flags & 268435456 /* TypeFlags.Intersection */) === 0 || (lazyObjectFlags(c, t) & 67108864 /* ObjectFlags.IsNeverIntersection */) === 0)
|
|
592
|
+
return chain;
|
|
593
|
+
const props = getPropertiesOfUnionOrIntersectionType(c, t);
|
|
594
|
+
let message = 1848 /* Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents */;
|
|
595
|
+
let prop = props.find((p) => isDiscriminantWithNeverType(c, p));
|
|
596
|
+
if (prop === undefined) {
|
|
597
|
+
message =
|
|
598
|
+
1849 /* Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some */;
|
|
599
|
+
prop = props.find(isConflictingPrivateProperty);
|
|
600
|
+
}
|
|
601
|
+
if (prop === undefined)
|
|
602
|
+
return chain;
|
|
603
|
+
const result = createDiagnosticForNode(node, message, [
|
|
604
|
+
typeToString(c, t, undefined, 536870912 /* TypeFormatFlags.NoTypeReduction */),
|
|
605
|
+
symbolToString(c, prop),
|
|
606
|
+
]);
|
|
607
|
+
return result.addMessageChain(chain);
|
|
608
|
+
}
|
|
609
|
+
/** The library that adds `missingProperty` to the apparent type's global, or '' if none does. */
|
|
610
|
+
function getSuggestedLibForNonExistentProperty(c, missingProperty, containingType) {
|
|
611
|
+
const container = getApparentType(c, containingType).symbol;
|
|
612
|
+
if (container === undefined)
|
|
613
|
+
return '';
|
|
614
|
+
const entries = getFeatureMap().get(container.name);
|
|
615
|
+
if (entries !== undefined)
|
|
616
|
+
for (const entry of entries)
|
|
617
|
+
if (entry.props.includes(missingProperty))
|
|
618
|
+
return entry.lib;
|
|
619
|
+
return '';
|
|
620
|
+
}
|
|
621
|
+
/** Whether the type looks like an empty DOM type, as when the DOM lib is missing. */
|
|
622
|
+
function containerSeemsToBeEmptyDomElement(c, containingType) {
|
|
623
|
+
return (!(c.compilerOptions.lib ?? []).includes('lib.dom.d.ts') &&
|
|
624
|
+
everyContainedType(containingType, hasCommonDomTypeName) &&
|
|
625
|
+
isEmptyObjectType(c, containingType));
|
|
626
|
+
}
|
|
627
|
+
function hasCommonDomTypeName(t) {
|
|
628
|
+
if (t.symbol === undefined)
|
|
629
|
+
return false;
|
|
630
|
+
const name = t.symbol.name;
|
|
631
|
+
return (name === 'EventTarget' ||
|
|
632
|
+
name === 'Node' ||
|
|
633
|
+
name === 'Element' ||
|
|
634
|
+
(name.startsWith('HTML') && name.endsWith('Element')));
|
|
635
|
+
}
|
|
636
|
+
/** Whether the type's symbol has a static member `name`, as when an instance member was expected. */
|
|
637
|
+
export function typeHasStaticProperty(c, name, containingType) {
|
|
638
|
+
if (containingType.symbol === undefined)
|
|
639
|
+
return false;
|
|
640
|
+
const prop = getPropertyOfType(c, getTypeOfSymbol(c, containingType.symbol), name);
|
|
641
|
+
return prop !== undefined && prop.valueDeclaration !== undefined && isStatic(prop.valueDeclaration);
|
|
642
|
+
}
|
|
643
|
+
/** The value member with the closest name, for "Did you mean" suggestions. */
|
|
644
|
+
export function getSuggestedSymbolForNonexistentProperty(c, name, containingType) {
|
|
645
|
+
let props = getPropertiesOfType(c, containingType);
|
|
646
|
+
const parent = name.parent;
|
|
647
|
+
if (parent.kind === 212 /* SyntaxKind.PropertyAccessExpression */) {
|
|
648
|
+
const valid = [];
|
|
649
|
+
for (const prop of props)
|
|
650
|
+
if (isValidPropertyAccessForCompletions(c, parent, containingType, prop))
|
|
651
|
+
valid.push(prop);
|
|
652
|
+
props = valid;
|
|
653
|
+
}
|
|
654
|
+
return getSpellingSuggestionForName(c, getText(name), props, 111551 /* SymbolFlags.Value */);
|
|
655
|
+
}
|
|
656
|
+
/** The value property of `containingType` with the closest name to `name`. */
|
|
657
|
+
export function getSuggestionForNonexistentProperty(c, name, containingType) {
|
|
658
|
+
return getSpellingSuggestionForName(c, name, getPropertiesOfType(c, containingType), 111551 /* SymbolFlags.Value */);
|
|
659
|
+
}
|
|
660
|
+
/** Whether `property` of `t` may be accessed at `node` without an error, as completions decide. */
|
|
661
|
+
function isValidPropertyAccessForCompletions(c, node, t, property) {
|
|
662
|
+
const isSuper = node.kind === 212 /* SyntaxKind.PropertyAccessExpression */ && getExpression(node).kind === 107 /* SyntaxKind.SuperKeyword */;
|
|
663
|
+
if ((t.flags & 1 /* TypeFlags.Any */) !== 0)
|
|
664
|
+
return true;
|
|
665
|
+
// `#private` access in an optional chain is a parse error.
|
|
666
|
+
const declaration = property.valueDeclaration;
|
|
667
|
+
if (declaration !== undefined && isPrivateIdentifierClassElementDeclaration(declaration)) {
|
|
668
|
+
const declClass = getContainingClass(declaration);
|
|
669
|
+
return !isOptionalChain(node) && declClass !== undefined && isNodeDescendantOf(node, declClass);
|
|
670
|
+
}
|
|
671
|
+
return checkPropertyAccessibilityAtLocation(c, node, isSuper, false, t, property, undefined);
|
|
672
|
+
}
|