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,19 @@
|
|
|
1
|
+
import { type Node, type SourceFile } from './ast.js';
|
|
2
|
+
import { type Checker } from './checker.js';
|
|
3
|
+
import { type Symbol } from './symbol.js';
|
|
4
|
+
import type { Type } from './checker-types.js';
|
|
5
|
+
/** Whether `node` is only written, as the target of `=` or of a for-in/of initializer. */
|
|
6
|
+
export declare function isWriteOnlyAccess(node: Node): boolean;
|
|
7
|
+
/** Whether `node` is written, possibly also read. */
|
|
8
|
+
export declare function isWriteAccess(node: Node): boolean;
|
|
9
|
+
/** Whether `name` refers to the class or object `parent` itself, as `this` or its own name does. */
|
|
10
|
+
export declare function isSelfTypeAccess(c: Checker, name: Node, parent: Symbol | undefined): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Records a use of a private class member. Writes don't count, except to setters, and neither do
|
|
13
|
+
* uses of a method from inside itself.
|
|
14
|
+
*/
|
|
15
|
+
export declare function markPropertyAsReferenced(c: Checker, prop: Symbol, nodeForCheckWriteOnly: Node | undefined, isSelfTypeAccess: boolean): void;
|
|
16
|
+
/** Marks the property a destructuring name selects from `objectType` as referenced. */
|
|
17
|
+
export declare function markDestructuredPropertyAsReferenced(c: Checker, objectType: Type, name: Node, location: Node | undefined, isSelfTypeAccess: boolean): void;
|
|
18
|
+
/** Reports the unused identifiers of a checked file; declaration files have none. */
|
|
19
|
+
export declare function checkUnusedIdentifiers(c: Checker, file: SourceFile): void;
|
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
// Unused identifiers: locals, parameters, imports, private class members and type parameters that
|
|
2
|
+
// are declared but never referenced. Errors under noUnusedLocals/noUnusedParameters, suggestions
|
|
3
|
+
// otherwise. References are recorded in `SymbolLinks.referenceKinds` by name resolution and by
|
|
4
|
+
// `markPropertyAsReferenced`.
|
|
5
|
+
import { NodeVisitor, getBody, getDotDotDotToken, getElements, getExpression, getLocals, getMembers, getName, getParameters, getPropertyName, getSymbol, getText, getTypeParameters, } from './ast.js';
|
|
6
|
+
import { isAmbientModule, isAssignmentOperator, isGlobalScopeAugmentation, isTypeDeclaration, } from './ast-utilities.js';
|
|
7
|
+
import { getCombinedNodeFlags, getModifierFlags, getRootDeclaration, getSourceFileOfNode, hasSyntacticModifier, isExternalOrCommonJSModule, isParameterPropertyDeclaration, } from './binder-utilities.js';
|
|
8
|
+
import { createDiagnosticForNode } from './checker.js';
|
|
9
|
+
import { Diagnostic } from './diagnostics.js';
|
|
10
|
+
import { getSymbolId } from './symbol.js';
|
|
11
|
+
import { getMergedSymbol, getSymbolOfDeclaration } from './checker-symbols.js';
|
|
12
|
+
import { getResolvedSymbol } from './checker-expressions.js';
|
|
13
|
+
import { skipTrivia } from './scanner.js';
|
|
14
|
+
import { getContainingFunctionOrClassStaticBlock } from './checker-grammar.js';
|
|
15
|
+
import { nodeCanBeDecorated } from './checker-decorators.js';
|
|
16
|
+
import { symbolToString } from './type-printer.js';
|
|
17
|
+
import { getLiteralTypeFromPropertyName } from './checker-type-operators.js';
|
|
18
|
+
import { getPropertyOfType } from './checker-members.js';
|
|
19
|
+
import { getPropertyNameFromType, isTypeUsableAsPropertyName } from './checker-utilities.js';
|
|
20
|
+
// ---- References
|
|
21
|
+
/** Whether `node` is only written, as the target of `=` or of a for-in/of initializer. */
|
|
22
|
+
export function isWriteOnlyAccess(node) {
|
|
23
|
+
return accessKind(node) === 1 /* AccessKind.Write */;
|
|
24
|
+
}
|
|
25
|
+
/** Whether `node` is written, possibly also read. */
|
|
26
|
+
export function isWriteAccess(node) {
|
|
27
|
+
return accessKind(node) !== 0 /* AccessKind.Read */;
|
|
28
|
+
}
|
|
29
|
+
function accessKind(node) {
|
|
30
|
+
const parent = node.parent;
|
|
31
|
+
if (parent === undefined)
|
|
32
|
+
return 0 /* AccessKind.Read */;
|
|
33
|
+
switch (parent.kind) {
|
|
34
|
+
case 218 /* SyntaxKind.ParenthesizedExpression */:
|
|
35
|
+
case 210 /* SyntaxKind.ArrayLiteralExpression */:
|
|
36
|
+
return accessKind(parent);
|
|
37
|
+
case 225 /* SyntaxKind.PrefixUnaryExpression */:
|
|
38
|
+
case 226 /* SyntaxKind.PostfixUnaryExpression */: {
|
|
39
|
+
const operator = parent.kind === 225 /* SyntaxKind.PrefixUnaryExpression */
|
|
40
|
+
? parent.operator
|
|
41
|
+
: parent.operator;
|
|
42
|
+
return operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */
|
|
43
|
+
? 2 /* AccessKind.ReadWrite */
|
|
44
|
+
: 0 /* AccessKind.Read */;
|
|
45
|
+
}
|
|
46
|
+
case 227 /* SyntaxKind.BinaryExpression */: {
|
|
47
|
+
const binary = parent;
|
|
48
|
+
if (binary.left !== node || !isAssignmentOperator(binary.operatorToken.kind))
|
|
49
|
+
return 0 /* AccessKind.Read */;
|
|
50
|
+
return binary.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? 1 /* AccessKind.Write */ : 2 /* AccessKind.ReadWrite */;
|
|
51
|
+
}
|
|
52
|
+
case 212 /* SyntaxKind.PropertyAccessExpression */:
|
|
53
|
+
return parent.name !== node ? 0 /* AccessKind.Read */ : accessKind(parent);
|
|
54
|
+
case 303 /* SyntaxKind.PropertyAssignment */: {
|
|
55
|
+
const parentAccess = accessKind(parent.parent);
|
|
56
|
+
// In `({ x: name } = { x: 1 })`, the left `x` is a read and `name` a write.
|
|
57
|
+
return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess;
|
|
58
|
+
}
|
|
59
|
+
case 304 /* SyntaxKind.ShorthandPropertyAssignment */:
|
|
60
|
+
// The local variable is the one accessed: public properties aren't checked for use.
|
|
61
|
+
return node === parent.objectAssignmentInitializer
|
|
62
|
+
? 0 /* AccessKind.Read */
|
|
63
|
+
: accessKind(parent.parent);
|
|
64
|
+
case 250 /* SyntaxKind.ForInStatement */:
|
|
65
|
+
case 251 /* SyntaxKind.ForOfStatement */:
|
|
66
|
+
return node === parent.initializer ? 1 /* AccessKind.Write */ : 0 /* AccessKind.Read */;
|
|
67
|
+
}
|
|
68
|
+
return 0 /* AccessKind.Read */;
|
|
69
|
+
}
|
|
70
|
+
function reverseAccessKind(kind) {
|
|
71
|
+
switch (kind) {
|
|
72
|
+
case 0 /* AccessKind.Read */:
|
|
73
|
+
return 1 /* AccessKind.Write */;
|
|
74
|
+
case 1 /* AccessKind.Write */:
|
|
75
|
+
return 0 /* AccessKind.Read */;
|
|
76
|
+
}
|
|
77
|
+
return 2 /* AccessKind.ReadWrite */;
|
|
78
|
+
}
|
|
79
|
+
/** Whether `name` refers to the class or object `parent` itself, as `this` or its own name does. */
|
|
80
|
+
export function isSelfTypeAccess(c, name, parent) {
|
|
81
|
+
if (name.kind === 109 /* SyntaxKind.ThisKeyword */)
|
|
82
|
+
return true;
|
|
83
|
+
if (parent === undefined || !isEntityNameExpression(name))
|
|
84
|
+
return false;
|
|
85
|
+
return parent === getResolvedSymbol(c, getFirstIdentifierOfExpression(name));
|
|
86
|
+
}
|
|
87
|
+
function isEntityNameExpression(node) {
|
|
88
|
+
let current = node;
|
|
89
|
+
while (current.kind === 212 /* SyntaxKind.PropertyAccessExpression */) {
|
|
90
|
+
if (getName(current).kind !== 79 /* SyntaxKind.Identifier */)
|
|
91
|
+
return false;
|
|
92
|
+
current = current.expression;
|
|
93
|
+
}
|
|
94
|
+
return current.kind === 79 /* SyntaxKind.Identifier */;
|
|
95
|
+
}
|
|
96
|
+
function getFirstIdentifierOfExpression(node) {
|
|
97
|
+
let current = node;
|
|
98
|
+
while (current.kind === 212 /* SyntaxKind.PropertyAccessExpression */)
|
|
99
|
+
current = current.expression;
|
|
100
|
+
return current;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Records a use of a private class member. Writes don't count, except to setters, and neither do
|
|
104
|
+
* uses of a method from inside itself.
|
|
105
|
+
*/
|
|
106
|
+
export function markPropertyAsReferenced(c, prop, nodeForCheckWriteOnly, isSelfTypeAccess) {
|
|
107
|
+
const declaration = prop.valueDeclaration;
|
|
108
|
+
if ((prop.flags & 106500 /* SymbolFlags.ClassMember */) === 0 || declaration === undefined)
|
|
109
|
+
return;
|
|
110
|
+
const name = getName(declaration);
|
|
111
|
+
if (!hasSyntacticModifier(declaration, 2 /* ModifierFlags.Private */) &&
|
|
112
|
+
(name === undefined || name.kind !== 80 /* SyntaxKind.PrivateIdentifier */))
|
|
113
|
+
return;
|
|
114
|
+
if (nodeForCheckWriteOnly !== undefined &&
|
|
115
|
+
isWriteOnlyAccess(nodeForCheckWriteOnly) &&
|
|
116
|
+
(prop.flags & 65536 /* SymbolFlags.SetAccessor */) === 0)
|
|
117
|
+
return;
|
|
118
|
+
if (isSelfTypeAccess && nodeForCheckWriteOnly !== undefined) {
|
|
119
|
+
// A method, getter or setter using itself through `this` doesn't count.
|
|
120
|
+
let containingMethod = nodeForCheckWriteOnly;
|
|
121
|
+
while (containingMethod !== undefined && !isFunctionLikeDeclaration(containingMethod))
|
|
122
|
+
containingMethod = containingMethod.parent;
|
|
123
|
+
if (containingMethod !== undefined && getSymbol(containingMethod) === prop)
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const target = (prop.checkFlags & 1 /* CheckFlags.Instantiated */) !== 0 ? c.symbolTargets.get(getSymbolId(prop)) : prop;
|
|
127
|
+
const id = getSymbolId(target);
|
|
128
|
+
c.symbolReferenceKinds.set(id, c.symbolReferenceKinds.get(id) | 1073741823 /* SymbolFlags.All */);
|
|
129
|
+
}
|
|
130
|
+
/** Marks the property a destructuring name selects from `objectType` as referenced. */
|
|
131
|
+
export function markDestructuredPropertyAsReferenced(c, objectType, name, location, isSelfTypeAccess) {
|
|
132
|
+
if (name.kind === 207 /* SyntaxKind.ObjectBindingPattern */ || name.kind === 208 /* SyntaxKind.ArrayBindingPattern */)
|
|
133
|
+
return;
|
|
134
|
+
const nameType = getLiteralTypeFromPropertyName(c, name);
|
|
135
|
+
if (nameType === undefined || !isTypeUsableAsPropertyName(nameType))
|
|
136
|
+
return;
|
|
137
|
+
const prop = getPropertyOfType(c, objectType, getPropertyNameFromType(nameType));
|
|
138
|
+
if (prop !== undefined)
|
|
139
|
+
markPropertyAsReferenced(c, prop, location, isSelfTypeAccess);
|
|
140
|
+
}
|
|
141
|
+
function isFunctionLikeDeclaration(node) {
|
|
142
|
+
switch (node.kind) {
|
|
143
|
+
case 263 /* SyntaxKind.FunctionDeclaration */:
|
|
144
|
+
case 175 /* SyntaxKind.MethodDeclaration */:
|
|
145
|
+
case 177 /* SyntaxKind.Constructor */:
|
|
146
|
+
case 178 /* SyntaxKind.GetAccessor */:
|
|
147
|
+
case 179 /* SyntaxKind.SetAccessor */:
|
|
148
|
+
case 219 /* SyntaxKind.FunctionExpression */:
|
|
149
|
+
case 220 /* SyntaxKind.ArrowFunction */:
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
// ---- Checks
|
|
155
|
+
/** Reports the unused identifiers of a checked file; declaration files have none. */
|
|
156
|
+
export function checkUnusedIdentifiers(c, file) {
|
|
157
|
+
if (file.isDeclarationFile)
|
|
158
|
+
return;
|
|
159
|
+
const collector = new PotentiallyUnusedCollector(c.legacyDecorators);
|
|
160
|
+
collector.visitNode(file);
|
|
161
|
+
for (const node of collector.nodes)
|
|
162
|
+
checkUnusedIdentifiersOfNode(c, node);
|
|
163
|
+
}
|
|
164
|
+
/** The checked declarations and scopes that can declare unused identifiers. */
|
|
165
|
+
class PotentiallyUnusedCollector extends NodeVisitor {
|
|
166
|
+
nodes = [];
|
|
167
|
+
legacyDecorators;
|
|
168
|
+
constructor(legacyDecorators) {
|
|
169
|
+
super();
|
|
170
|
+
this.legacyDecorators = legacyDecorators;
|
|
171
|
+
}
|
|
172
|
+
visitNode(node) {
|
|
173
|
+
// The body of a `with` statement isn't checked.
|
|
174
|
+
if (node.kind === 255 /* SyntaxKind.WithStatement */)
|
|
175
|
+
this.visitNode(getExpression(node));
|
|
176
|
+
else if (!this.isUnchecked(node))
|
|
177
|
+
node.forEachChild(this);
|
|
178
|
+
if (isPotentiallyUnusedContainer(node))
|
|
179
|
+
this.nodes.push(node);
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Whether the checker skips the children of `node`: a `return` outside a function body, or in a class
|
|
184
|
+
* static block, and a decorator of a declaration that can't be decorated, are reported as errors and
|
|
185
|
+
* not checked further.
|
|
186
|
+
*/
|
|
187
|
+
isUnchecked(node) {
|
|
188
|
+
if (node.kind === 254 /* SyntaxKind.ReturnStatement */) {
|
|
189
|
+
const container = getContainingFunctionOrClassStaticBlock(node);
|
|
190
|
+
return container === undefined || container.kind === 176 /* SyntaxKind.ClassStaticBlockDeclaration */;
|
|
191
|
+
}
|
|
192
|
+
if (node.kind === 171 /* SyntaxKind.Decorator */) {
|
|
193
|
+
const declaration = node.parent;
|
|
194
|
+
return !nodeCanBeDecorated(this.legacyDecorators, declaration, declaration.parent, declaration.parent?.parent);
|
|
195
|
+
}
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function isPotentiallyUnusedContainer(node) {
|
|
200
|
+
switch (node.kind) {
|
|
201
|
+
case 307 /* SyntaxKind.SourceFile */:
|
|
202
|
+
return isExternalOrCommonJSModule(node);
|
|
203
|
+
case 242 /* SyntaxKind.Block */:
|
|
204
|
+
case 270 /* SyntaxKind.CaseBlock */:
|
|
205
|
+
case 249 /* SyntaxKind.ForStatement */:
|
|
206
|
+
case 250 /* SyntaxKind.ForInStatement */:
|
|
207
|
+
case 251 /* SyntaxKind.ForOfStatement */: {
|
|
208
|
+
const locals = getLocals(node);
|
|
209
|
+
return locals !== undefined && locals.size !== 0;
|
|
210
|
+
}
|
|
211
|
+
case 268 /* SyntaxKind.ModuleDeclaration */:
|
|
212
|
+
return getBody(node) !== undefined && !isGlobalScopeAugmentation(node);
|
|
213
|
+
case 266 /* SyntaxKind.TypeAliasDeclaration */:
|
|
214
|
+
case 345 /* SyntaxKind.JSTypeAliasDeclaration */: {
|
|
215
|
+
const type = node.type;
|
|
216
|
+
return type === undefined || type.kind !== 141 /* SyntaxKind.IntrinsicKeyword */;
|
|
217
|
+
}
|
|
218
|
+
case 264 /* SyntaxKind.ClassDeclaration */:
|
|
219
|
+
case 232 /* SyntaxKind.ClassExpression */:
|
|
220
|
+
case 265 /* SyntaxKind.InterfaceDeclaration */:
|
|
221
|
+
case 196 /* SyntaxKind.InferType */:
|
|
222
|
+
case 177 /* SyntaxKind.Constructor */:
|
|
223
|
+
case 219 /* SyntaxKind.FunctionExpression */:
|
|
224
|
+
case 263 /* SyntaxKind.FunctionDeclaration */:
|
|
225
|
+
case 220 /* SyntaxKind.ArrowFunction */:
|
|
226
|
+
case 175 /* SyntaxKind.MethodDeclaration */:
|
|
227
|
+
case 178 /* SyntaxKind.GetAccessor */:
|
|
228
|
+
case 179 /* SyntaxKind.SetAccessor */:
|
|
229
|
+
case 174 /* SyntaxKind.MethodSignature */:
|
|
230
|
+
case 180 /* SyntaxKind.CallSignature */:
|
|
231
|
+
case 181 /* SyntaxKind.ConstructSignature */:
|
|
232
|
+
case 185 /* SyntaxKind.FunctionType */:
|
|
233
|
+
case 186 /* SyntaxKind.ConstructorType */:
|
|
234
|
+
return true;
|
|
235
|
+
}
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
function checkUnusedIdentifiersOfNode(c, node) {
|
|
239
|
+
switch (node.kind) {
|
|
240
|
+
case 264 /* SyntaxKind.ClassDeclaration */:
|
|
241
|
+
case 232 /* SyntaxKind.ClassExpression */:
|
|
242
|
+
checkUnusedClassMembers(c, node);
|
|
243
|
+
checkUnusedTypeParameters(c, node);
|
|
244
|
+
return;
|
|
245
|
+
case 307 /* SyntaxKind.SourceFile */:
|
|
246
|
+
case 268 /* SyntaxKind.ModuleDeclaration */:
|
|
247
|
+
case 242 /* SyntaxKind.Block */:
|
|
248
|
+
case 270 /* SyntaxKind.CaseBlock */:
|
|
249
|
+
case 249 /* SyntaxKind.ForStatement */:
|
|
250
|
+
case 250 /* SyntaxKind.ForInStatement */:
|
|
251
|
+
case 251 /* SyntaxKind.ForOfStatement */:
|
|
252
|
+
checkUnusedLocalsAndParameters(c, node);
|
|
253
|
+
return;
|
|
254
|
+
case 177 /* SyntaxKind.Constructor */:
|
|
255
|
+
case 219 /* SyntaxKind.FunctionExpression */:
|
|
256
|
+
case 263 /* SyntaxKind.FunctionDeclaration */:
|
|
257
|
+
case 220 /* SyntaxKind.ArrowFunction */:
|
|
258
|
+
case 175 /* SyntaxKind.MethodDeclaration */:
|
|
259
|
+
case 178 /* SyntaxKind.GetAccessor */:
|
|
260
|
+
case 179 /* SyntaxKind.SetAccessor */:
|
|
261
|
+
// Parameters are reported on implementations only, not overloads.
|
|
262
|
+
if (getBody(node) !== undefined)
|
|
263
|
+
checkUnusedLocalsAndParameters(c, node);
|
|
264
|
+
checkUnusedTypeParameters(c, node);
|
|
265
|
+
return;
|
|
266
|
+
case 196 /* SyntaxKind.InferType */:
|
|
267
|
+
checkUnusedInferTypeParameter(c, node);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
checkUnusedTypeParameters(c, node);
|
|
271
|
+
}
|
|
272
|
+
function isReferenced(c, symbol) {
|
|
273
|
+
return c.symbolReferenceKinds.get(getSymbolId(symbol)) !== 0;
|
|
274
|
+
}
|
|
275
|
+
function referenceKindsOfDeclaration(c, node) {
|
|
276
|
+
const symbol = getSymbolOfDeclaration(c, node);
|
|
277
|
+
return symbol === undefined ? 0 /* SymbolFlags.None */ : c.symbolReferenceKinds.get(getSymbolId(symbol));
|
|
278
|
+
}
|
|
279
|
+
function reportUnused(c, location, kind, diagnostic) {
|
|
280
|
+
if ((location.flags & (8388608 /* NodeFlags.Ambient */ | 131072 /* NodeFlags.ThisNodeOrAnySubNodesHasError */)) !== 0)
|
|
281
|
+
return;
|
|
282
|
+
const options = c.compilerOptions;
|
|
283
|
+
const isError = kind === 0 /* UnusedKind.Local */ ? options.noUnusedLocals === true : options.noUnusedParameters === true;
|
|
284
|
+
if (!isError)
|
|
285
|
+
diagnostic.category = 2 /* DiagnosticCategory.Suggestion */;
|
|
286
|
+
c.addErrorOrSuggestion(isError, diagnostic);
|
|
287
|
+
}
|
|
288
|
+
function reportUnusedVariable(c, location, diagnostic) {
|
|
289
|
+
let current = location;
|
|
290
|
+
while (current.kind === 209 /* SyntaxKind.BindingElement */ ||
|
|
291
|
+
current.kind === 207 /* SyntaxKind.ObjectBindingPattern */ ||
|
|
292
|
+
current.kind === 208 /* SyntaxKind.ArrayBindingPattern */)
|
|
293
|
+
current = current.parent;
|
|
294
|
+
reportUnused(c, current, current.kind === 170 /* SyntaxKind.Parameter */ ? 1 /* UnusedKind.Parameter */ : 0 /* UnusedKind.Local */, diagnostic);
|
|
295
|
+
}
|
|
296
|
+
function checkUnusedClassMembers(c, node) {
|
|
297
|
+
for (const member of getMembers(node).nodes) {
|
|
298
|
+
switch (member.kind) {
|
|
299
|
+
case 175 /* SyntaxKind.MethodDeclaration */:
|
|
300
|
+
case 173 /* SyntaxKind.PropertyDeclaration */:
|
|
301
|
+
case 178 /* SyntaxKind.GetAccessor */:
|
|
302
|
+
case 179 /* SyntaxKind.SetAccessor */: {
|
|
303
|
+
// An unused accessor pair is reported on the getter.
|
|
304
|
+
if (member.kind === 179 /* SyntaxKind.SetAccessor */ && (getSymbol(member).flags & 32768 /* SymbolFlags.GetAccessor */) !== 0)
|
|
305
|
+
break;
|
|
306
|
+
const symbol = getSymbolOfDeclaration(c, member);
|
|
307
|
+
const name = getName(member);
|
|
308
|
+
if (!isReferenced(c, symbol) &&
|
|
309
|
+
((getModifierFlags(member) & 2 /* ModifierFlags.Private */) !== 0 ||
|
|
310
|
+
(name !== undefined && name.kind === 80 /* SyntaxKind.PrivateIdentifier */)) &&
|
|
311
|
+
(member.flags & 8388608 /* NodeFlags.Ambient */) === 0)
|
|
312
|
+
reportUnused(c, member, 0 /* UnusedKind.Local */, createDiagnosticForNode(name, 1298 /* Diagnostics.X_0_is_declared_but_its_value_is_never_read */, [
|
|
313
|
+
symbolToString(c, symbol),
|
|
314
|
+
]));
|
|
315
|
+
break;
|
|
316
|
+
}
|
|
317
|
+
case 177 /* SyntaxKind.Constructor */:
|
|
318
|
+
for (const parameter of getParameters(member).nodes) {
|
|
319
|
+
const symbol = getSymbol(parameter);
|
|
320
|
+
if (symbol !== undefined &&
|
|
321
|
+
!isReferenced(c, symbol) &&
|
|
322
|
+
hasSyntacticModifier(parameter, 2 /* ModifierFlags.Private */))
|
|
323
|
+
reportUnused(c, parameter, 0 /* UnusedKind.Local */, createDiagnosticForNode(getName(parameter), 1303 /* Diagnostics.Property_0_is_declared_but_its_value_is_never_read */, [symbol.name]));
|
|
324
|
+
}
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
function checkUnusedLocalsAndParameters(c, node) {
|
|
330
|
+
const locals = getLocals(node);
|
|
331
|
+
if (locals === undefined)
|
|
332
|
+
return;
|
|
333
|
+
const variableParents = new Set();
|
|
334
|
+
const importClauses = new Map();
|
|
335
|
+
for (const local of locals.values()) {
|
|
336
|
+
const referenceKinds = c.symbolReferenceKinds.get(getSymbolId(local));
|
|
337
|
+
if ((local.flags & 262144 /* SymbolFlags.TypeParameter */) !== 0) {
|
|
338
|
+
if ((local.flags & 3 /* SymbolFlags.Variable */) === 0 || (referenceKinds & 3 /* SymbolFlags.Variable */) !== 0)
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
else if (referenceKinds !== 0 ||
|
|
342
|
+
local.exportSymbol !== undefined ||
|
|
343
|
+
(local.flags & 134217728 /* SymbolFlags.ModuleExports */) !== 0)
|
|
344
|
+
continue;
|
|
345
|
+
for (const declaration of local.declarations) {
|
|
346
|
+
switch (declaration.kind) {
|
|
347
|
+
case 261 /* SyntaxKind.VariableDeclaration */:
|
|
348
|
+
case 170 /* SyntaxKind.Parameter */:
|
|
349
|
+
case 209 /* SyntaxKind.BindingElement */:
|
|
350
|
+
variableParents.add(getRootDeclaration(declaration).parent);
|
|
351
|
+
break;
|
|
352
|
+
case 274 /* SyntaxKind.ImportClause */:
|
|
353
|
+
case 277 /* SyntaxKind.ImportSpecifier */:
|
|
354
|
+
case 275 /* SyntaxKind.NamespaceImport */:
|
|
355
|
+
if (!isIdentifierThatStartsWithUnderscore(getName(declaration))) {
|
|
356
|
+
const importClause = importClauseFromImported(declaration);
|
|
357
|
+
const unuseds = importClauses.get(importClause);
|
|
358
|
+
if (unuseds === undefined)
|
|
359
|
+
importClauses.set(importClause, [declaration]);
|
|
360
|
+
else
|
|
361
|
+
unuseds.push(declaration);
|
|
362
|
+
}
|
|
363
|
+
break;
|
|
364
|
+
default:
|
|
365
|
+
if (declaration.kind !== 169 /* SyntaxKind.TypeParameter */ && !isAmbientModule(declaration))
|
|
366
|
+
reportUnusedLocal(c, declaration, local.name);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
for (const declaration of variableParents) {
|
|
371
|
+
if (declaration.kind === 262 /* SyntaxKind.VariableDeclarationList */)
|
|
372
|
+
reportUnusedVariables(c, declaration, declaration.declarations.nodes);
|
|
373
|
+
else
|
|
374
|
+
reportUnusedVariableDeclarations(c, getParameters(declaration).nodes);
|
|
375
|
+
}
|
|
376
|
+
for (const [declaration, unuseds] of importClauses)
|
|
377
|
+
reportUnusedImports(c, declaration, unuseds);
|
|
378
|
+
}
|
|
379
|
+
function reportUnusedLocal(c, node, name) {
|
|
380
|
+
const message = isTypeDeclaration(node)
|
|
381
|
+
? 1349 /* Diagnostics.X_0_is_declared_but_never_used */
|
|
382
|
+
: 1298 /* Diagnostics.X_0_is_declared_but_its_value_is_never_read */;
|
|
383
|
+
reportUnused(c, node, 0 /* UnusedKind.Local */, createDiagnosticForNode(getName(node) ?? node, message, [name]));
|
|
384
|
+
}
|
|
385
|
+
function reportUnusedVariables(c, node, declarations) {
|
|
386
|
+
if (declarations.length > 1 && areUnreferencedVariableDeclarations(c, declarations))
|
|
387
|
+
reportUnusedVariable(c, node, createDiagnosticForNode(node, 1352 /* Diagnostics.All_variables_are_unused */, []));
|
|
388
|
+
else
|
|
389
|
+
reportUnusedVariableDeclarations(c, declarations);
|
|
390
|
+
}
|
|
391
|
+
function reportUnusedBindingElements(c, node) {
|
|
392
|
+
const declarations = getElements(node).nodes;
|
|
393
|
+
if (declarations.length > 1 && areUnreferencedVariableDeclarations(c, declarations))
|
|
394
|
+
reportUnusedVariable(c, node, createDiagnosticForNode(node, 1351 /* Diagnostics.All_destructured_elements_are_unused */, []));
|
|
395
|
+
else
|
|
396
|
+
reportUnusedVariableDeclarations(c, declarations);
|
|
397
|
+
}
|
|
398
|
+
function reportUnusedVariableDeclarations(c, declarations) {
|
|
399
|
+
for (const declaration of declarations) {
|
|
400
|
+
const name = getName(declaration);
|
|
401
|
+
if (name === undefined ||
|
|
402
|
+
isParameterPropertyDeclaration(declaration, declaration.parent) ||
|
|
403
|
+
isThisParameter(declaration))
|
|
404
|
+
continue;
|
|
405
|
+
if (name.kind === 207 /* SyntaxKind.ObjectBindingPattern */ || name.kind === 208 /* SyntaxKind.ArrayBindingPattern */)
|
|
406
|
+
reportUnusedBindingElements(c, name);
|
|
407
|
+
else if (isUnreferencedVariableDeclaration(c, declaration))
|
|
408
|
+
reportUnusedVariable(c, declaration, createDiagnosticForNode(name, 1298 /* Diagnostics.X_0_is_declared_but_its_value_is_never_read */, [getText(name)]));
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
function isThisParameter(node) {
|
|
412
|
+
if (node.kind !== 170 /* SyntaxKind.Parameter */)
|
|
413
|
+
return false;
|
|
414
|
+
const name = getName(node);
|
|
415
|
+
return name !== undefined && name.kind === 79 /* SyntaxKind.Identifier */ && getText(name) === 'this';
|
|
416
|
+
}
|
|
417
|
+
function areUnreferencedVariableDeclarations(c, declarations) {
|
|
418
|
+
for (const d of declarations)
|
|
419
|
+
if (!isUnreferencedVariableDeclaration(c, d))
|
|
420
|
+
return false;
|
|
421
|
+
return true;
|
|
422
|
+
}
|
|
423
|
+
function isUnreferencedVariableDeclaration(c, node) {
|
|
424
|
+
const name = getName(node);
|
|
425
|
+
if (name === undefined)
|
|
426
|
+
return true;
|
|
427
|
+
if (name.kind === 207 /* SyntaxKind.ObjectBindingPattern */ || name.kind === 208 /* SyntaxKind.ArrayBindingPattern */)
|
|
428
|
+
return areUnreferencedVariableDeclarations(c, getElements(name).nodes);
|
|
429
|
+
if ((referenceKindsOfDeclaration(c, node) & 3 /* SymbolFlags.Variable */) !== 0)
|
|
430
|
+
return false;
|
|
431
|
+
const parent = node.parent;
|
|
432
|
+
if (node.kind === 209 /* SyntaxKind.BindingElement */ && parent.kind === 207 /* SyntaxKind.ObjectBindingPattern */) {
|
|
433
|
+
// In `{ a, ...b }`, `a` counts as used: it removes a property from `b`.
|
|
434
|
+
const elements = getElements(parent).nodes;
|
|
435
|
+
const lastElement = elements[elements.length - 1];
|
|
436
|
+
if (node !== lastElement && getDotDotDotToken(lastElement) !== undefined)
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
439
|
+
const underscoreExempt = node.kind === 170 /* SyntaxKind.Parameter */ ||
|
|
440
|
+
(node.kind === 261 /* SyntaxKind.VariableDeclaration */ &&
|
|
441
|
+
(isForInOrOfStatement(parent.parent) || (getCombinedNodeFlags(node) & 4 /* NodeFlags.Using */) !== 0)) ||
|
|
442
|
+
(node.kind === 209 /* SyntaxKind.BindingElement */ &&
|
|
443
|
+
!(parent.kind === 207 /* SyntaxKind.ObjectBindingPattern */ && getPropertyName(node) === undefined));
|
|
444
|
+
return !(underscoreExempt && isIdentifierThatStartsWithUnderscore(name));
|
|
445
|
+
}
|
|
446
|
+
function isForInOrOfStatement(node) {
|
|
447
|
+
return node.kind === 250 /* SyntaxKind.ForInStatement */ || node.kind === 251 /* SyntaxKind.ForOfStatement */;
|
|
448
|
+
}
|
|
449
|
+
function reportUnusedImports(c, node, unuseds) {
|
|
450
|
+
let declarationCount = node.name !== undefined ? 1 : 0;
|
|
451
|
+
const namedBindings = node.namedBindings;
|
|
452
|
+
if (namedBindings !== undefined) {
|
|
453
|
+
if (namedBindings.kind === 275 /* SyntaxKind.NamespaceImport */)
|
|
454
|
+
declarationCount++;
|
|
455
|
+
else
|
|
456
|
+
declarationCount += getElements(namedBindings).nodes.length;
|
|
457
|
+
}
|
|
458
|
+
if (declarationCount > 1 && declarationCount === unuseds.length)
|
|
459
|
+
reportUnused(c, node, 0 /* UnusedKind.Local */, createDiagnosticForNode(node.parent, 1345 /* Diagnostics.All_imports_in_import_declaration_are_unused */, []));
|
|
460
|
+
else
|
|
461
|
+
for (const unused of unuseds)
|
|
462
|
+
reportUnusedLocal(c, unused, getText(getName(unused)));
|
|
463
|
+
}
|
|
464
|
+
function isIdentifierThatStartsWithUnderscore(node) {
|
|
465
|
+
return node !== undefined && node.kind === 79 /* SyntaxKind.Identifier */ && getText(node).charCodeAt(0) === 0x5f;
|
|
466
|
+
}
|
|
467
|
+
function importClauseFromImported(node) {
|
|
468
|
+
switch (node.kind) {
|
|
469
|
+
case 274 /* SyntaxKind.ImportClause */:
|
|
470
|
+
return node;
|
|
471
|
+
case 275 /* SyntaxKind.NamespaceImport */:
|
|
472
|
+
return node.parent;
|
|
473
|
+
}
|
|
474
|
+
return node.parent.parent;
|
|
475
|
+
}
|
|
476
|
+
function checkUnusedInferTypeParameter(c, node) {
|
|
477
|
+
const typeParameter = node.typeParameter;
|
|
478
|
+
if (isUnreferencedTypeParameter(c, typeParameter))
|
|
479
|
+
reportUnused(c, node, 1 /* UnusedKind.Parameter */, createDiagnosticForNode(typeParameter.name, 1349 /* Diagnostics.X_0_is_declared_but_never_used */, [
|
|
480
|
+
getText(typeParameter.name),
|
|
481
|
+
]));
|
|
482
|
+
}
|
|
483
|
+
function areUnreferencedTypeParameters(c, typeParameters) {
|
|
484
|
+
for (const p of typeParameters)
|
|
485
|
+
if (!isUnreferencedTypeParameter(c, p))
|
|
486
|
+
return false;
|
|
487
|
+
return true;
|
|
488
|
+
}
|
|
489
|
+
function checkUnusedTypeParameters(c, node) {
|
|
490
|
+
const symbol = getSymbolOfDeclaration(c, node);
|
|
491
|
+
if (symbol !== undefined && !allDeclarationsInSameSourceFile(symbol))
|
|
492
|
+
return;
|
|
493
|
+
const typeParameterList = getTypeParameters(node);
|
|
494
|
+
if (typeParameterList === undefined)
|
|
495
|
+
return;
|
|
496
|
+
const typeParameters = typeParameterList.nodes;
|
|
497
|
+
if (typeParameters.length > 1 && areUnreferencedTypeParameters(c, typeParameters)) {
|
|
498
|
+
const file = getSourceFileOfNode(node);
|
|
499
|
+
const text = file.text;
|
|
500
|
+
const end = Math.min(text.length, skipTrivia(text, typeParameterList.end) + 1);
|
|
501
|
+
reportUnused(c, node, 1 /* UnusedKind.Parameter */, new Diagnostic(file.diagnosticFile(), typeParameterList.pos - 1, end, 1358 /* Diagnostics.All_type_parameters_are_unused */));
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
for (const typeParameter of typeParameters)
|
|
505
|
+
if (isUnreferencedTypeParameter(c, typeParameter))
|
|
506
|
+
reportUnused(c, node, 1 /* UnusedKind.Parameter */, createDiagnosticForNode(typeParameter, 1349 /* Diagnostics.X_0_is_declared_but_never_used */, [
|
|
507
|
+
getText(getName(typeParameter)),
|
|
508
|
+
]));
|
|
509
|
+
}
|
|
510
|
+
function isUnreferencedTypeParameter(c, typeParameter) {
|
|
511
|
+
const symbol = getSymbol(typeParameter);
|
|
512
|
+
const referenceKinds = symbol === undefined ? 0 : c.symbolReferenceKinds.get(getSymbolId(getMergedSymbol(c, symbol)));
|
|
513
|
+
return ((referenceKinds & 262144 /* SymbolFlags.TypeParameter */) === 0 && !isIdentifierThatStartsWithUnderscore(getName(typeParameter)));
|
|
514
|
+
}
|
|
515
|
+
function allDeclarationsInSameSourceFile(symbol) {
|
|
516
|
+
const declarations = symbol.declarations;
|
|
517
|
+
if (declarations.length <= 1)
|
|
518
|
+
return true;
|
|
519
|
+
const file = getSourceFileOfNode(declarations[0]);
|
|
520
|
+
for (let i = 1; i < declarations.length; i++)
|
|
521
|
+
if (getSourceFileOfNode(declarations[i]) !== file)
|
|
522
|
+
return false;
|
|
523
|
+
return true;
|
|
524
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type Node } from './ast.js';
|
|
2
|
+
import type { Checker } from './checker.js';
|
|
3
|
+
import { type Type, TypeFlags } from './checker-types.js';
|
|
4
|
+
export declare function isTypeUsableAsPropertyName(t: Type): boolean;
|
|
5
|
+
/** The member name a literal or unique symbol type denotes. */
|
|
6
|
+
export declare function getPropertyNameFromType(t: Type): string;
|
|
7
|
+
/** Whether `ToString(ToNumber(name))` is `name`; true for Infinity, -Infinity and NaN. */
|
|
8
|
+
export declare function isNumericLiteralName(name: string): boolean;
|
|
9
|
+
/** Names of members keyed by unique symbols. */
|
|
10
|
+
export declare function isLateBoundName(name: string): boolean;
|
|
11
|
+
export declare function maybeTypeOfKind(t: Type, kind: TypeFlags): boolean;
|
|
12
|
+
export declare function isValidIndexKeyType(c: Checker, t: Type): boolean;
|
|
13
|
+
/** A computed name of entity-name form whose type is a literal or unique symbol. */
|
|
14
|
+
export declare function hasLateBindableName(c: Checker, node: Node): boolean;
|
|
15
|
+
/** Whether a computed name or `F[name]` target has a unique symbol or literal type. */
|
|
16
|
+
export declare function isLateBindableName(c: Checker, name: Node): boolean;
|
|
17
|
+
/** The name of a member, or the `F[name]` target of a JavaScript element access assignment. */
|
|
18
|
+
export declare function getLateBindableNameOfDeclaration(node: Node): Node | undefined;
|
|
19
|
+
export declare function hasLateBindableIndexSignature(c: Checker, node: Node): boolean;
|
|
20
|
+
/** Whether a declaration's name is a computed name that isn't a literal. */
|
|
21
|
+
export declare function hasDynamicName(node: Node): boolean;
|
|
22
|
+
export declare const enum FunctionFlags {
|
|
23
|
+
Normal = 0,
|
|
24
|
+
Generator = 1,
|
|
25
|
+
Async = 2,
|
|
26
|
+
Invalid = 4,
|
|
27
|
+
AsyncGenerator = 3
|
|
28
|
+
}
|
|
29
|
+
/** Whether a function-like declaration is async and/or a generator. */
|
|
30
|
+
export declare function getFunctionFlags(node: Node | undefined): FunctionFlags;
|
|
31
|
+
export declare function isBindingPattern(node: Node | undefined): boolean;
|
|
32
|
+
/** The index of the node with `node`'s range among `nodes`, which are in source order; -1 if none. */
|
|
33
|
+
export declare function indexOfNode(nodes: readonly Node[], node: Node): number;
|