tsc-ts 0.0.10 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/tsc-ts.js +70 -1
- package/dist/api/compiler/ast-utilities.d.ts +19 -1
- package/dist/api/compiler/ast-utilities.js +180 -95
- package/dist/api/compiler/ast.d.ts +29 -18
- package/dist/api/compiler/ast.js +1040 -1007
- package/dist/api/compiler/astnav.js +15 -15
- package/dist/api/compiler/binder-utilities.js +186 -186
- package/dist/api/compiler/binder.js +290 -263
- package/dist/api/compiler/character-codes.js +2 -2
- package/dist/api/compiler/checker-calls.js +173 -123
- package/dist/api/compiler/checker-classes.d.ts +14 -3
- package/dist/api/compiler/checker-classes.js +136 -91
- package/dist/api/compiler/checker-contextual.d.ts +20 -0
- package/dist/api/compiler/checker-contextual.js +175 -62
- package/dist/api/compiler/checker-declaration-order.js +79 -79
- package/dist/api/compiler/checker-declarations.d.ts +1 -0
- package/dist/api/compiler/checker-declarations.js +160 -136
- package/dist/api/compiler/checker-declared-types.js +67 -65
- package/dist/api/compiler/checker-decorators.js +77 -77
- package/dist/api/compiler/checker-deprecation.d.ts +8 -3
- package/dist/api/compiler/checker-deprecation.js +76 -55
- package/dist/api/compiler/checker-destructuring.js +47 -45
- package/dist/api/compiler/checker-elaboration.js +24 -24
- package/dist/api/compiler/checker-emit-helpers.js +4 -4
- package/dist/api/compiler/checker-emit-resolver.d.ts +4 -2
- package/dist/api/compiler/checker-emit-resolver.js +25 -13
- package/dist/api/compiler/checker-evaluator.js +9 -9
- package/dist/api/compiler/checker-expressions.js +258 -212
- package/dist/api/compiler/checker-functions.js +113 -107
- package/dist/api/compiler/checker-generated-code.d.ts +0 -11
- package/dist/api/compiler/checker-generated-code.js +28 -52
- package/dist/api/compiler/checker-grammar.d.ts +1 -0
- package/dist/api/compiler/checker-grammar.js +469 -438
- package/dist/api/compiler/checker-heritage.js +91 -93
- package/dist/api/compiler/checker-inference.d.ts +77 -5
- package/dist/api/compiler/checker-inference.js +487 -113
- package/dist/api/compiler/checker-iteration.d.ts +0 -10
- package/dist/api/compiler/checker-iteration.js +35 -52
- package/dist/api/compiler/checker-javascript.js +14 -14
- package/dist/api/compiler/checker-jsdoc.d.ts +8 -10
- package/dist/api/compiler/checker-jsdoc.js +67 -58
- package/dist/api/compiler/checker-jsx.js +107 -89
- package/dist/api/compiler/checker-members.d.ts +9 -2
- package/dist/api/compiler/checker-members.js +210 -74
- package/dist/api/compiler/checker-modules.d.ts +15 -6
- package/dist/api/compiler/checker-modules.js +469 -309
- package/dist/api/compiler/checker-narrowing.js +273 -189
- package/dist/api/compiler/checker-object-literals.js +25 -22
- package/dist/api/compiler/checker-operators.js +126 -118
- package/dist/api/compiler/checker-overloads.js +27 -27
- package/dist/api/compiler/checker-property-access.js +59 -55
- package/dist/api/compiler/checker-services.d.ts +1 -0
- package/dist/api/compiler/checker-services.js +222 -210
- package/dist/api/compiler/checker-signatures.js +65 -49
- package/dist/api/compiler/checker-source-file.d.ts +5 -0
- package/dist/api/compiler/checker-source-file.js +154 -130
- package/dist/api/compiler/checker-statements.js +33 -32
- package/dist/api/compiler/checker-super.js +50 -50
- package/dist/api/compiler/checker-symbol-types.js +109 -93
- package/dist/api/compiler/checker-symbols.d.ts +13 -1
- package/dist/api/compiler/checker-symbols.js +264 -149
- package/dist/api/compiler/checker-type-factory.d.ts +5 -0
- package/dist/api/compiler/checker-type-factory.js +190 -46
- package/dist/api/compiler/checker-type-nodes.d.ts +1 -0
- package/dist/api/compiler/checker-type-nodes.js +179 -141
- package/dist/api/compiler/checker-type-operators.d.ts +2 -0
- package/dist/api/compiler/checker-type-operators.js +110 -63
- package/dist/api/compiler/checker-types.d.ts +80 -3
- package/dist/api/compiler/checker-types.js +121 -2
- package/dist/api/compiler/checker-unused.js +114 -118
- package/dist/api/compiler/checker-utilities.js +11 -11
- package/dist/api/compiler/checker.d.ts +97 -31
- package/dist/api/compiler/checker.js +149 -35
- package/dist/api/compiler/command-line.d.ts +1 -3
- package/dist/api/compiler/command-line.js +47 -44
- package/dist/api/compiler/compile-program.d.ts +24 -4
- package/dist/api/compiler/compile-program.js +53 -26
- package/dist/api/compiler/diagnostic-messages.d.ts +1849 -1774
- package/dist/api/compiler/diagnostic-messages.js +128 -122
- package/dist/api/compiler/diagnostics.js +7 -7
- package/dist/api/compiler/emitter.d.ts +7 -1
- package/dist/api/compiler/emitter.js +53 -11
- package/dist/api/compiler/expr-record.d.ts +11 -0
- package/dist/api/compiler/expr-record.js +53 -0
- package/dist/api/compiler/file-include.d.ts +2 -1
- package/dist/api/compiler/file-include.js +11 -7
- package/dist/api/compiler/file-loader.d.ts +10 -0
- package/dist/api/compiler/file-loader.js +138 -41
- package/dist/api/compiler/identifier-name.d.ts +9 -0
- package/dist/api/compiler/identifier-name.js +10 -0
- package/dist/api/compiler/instantiation.d.ts +7 -0
- package/dist/api/compiler/instantiation.js +101 -49
- package/dist/api/compiler/jsdoc.js +27 -25
- package/dist/api/compiler/link-tables.d.ts +48 -18
- package/dist/api/compiler/link-tables.js +80 -37
- package/dist/api/compiler/locales/cs-CZ.d.ts +1 -1
- package/dist/api/compiler/locales/cs-CZ.js +1 -1
- package/dist/api/compiler/locales/de-DE.d.ts +1 -1
- package/dist/api/compiler/locales/de-DE.js +1 -1
- package/dist/api/compiler/locales/es-ES.d.ts +1 -1
- package/dist/api/compiler/locales/es-ES.js +1 -1
- package/dist/api/compiler/locales/fr-FR.d.ts +1 -1
- package/dist/api/compiler/locales/fr-FR.js +1 -1
- package/dist/api/compiler/locales/it-IT.d.ts +1 -1
- package/dist/api/compiler/locales/it-IT.js +1 -1
- package/dist/api/compiler/locales/ja-JP.d.ts +1 -1
- package/dist/api/compiler/locales/ja-JP.js +1 -1
- package/dist/api/compiler/locales/ko-KR.d.ts +1 -1
- package/dist/api/compiler/locales/ko-KR.js +1 -1
- package/dist/api/compiler/locales/pl-PL.d.ts +1 -1
- package/dist/api/compiler/locales/pl-PL.js +1 -1
- package/dist/api/compiler/locales/pt-BR.d.ts +1 -1
- package/dist/api/compiler/locales/pt-BR.js +1 -1
- package/dist/api/compiler/locales/ru-RU.d.ts +1 -1
- package/dist/api/compiler/locales/ru-RU.js +1 -1
- package/dist/api/compiler/locales/tr-TR.d.ts +1 -1
- package/dist/api/compiler/locales/tr-TR.js +1 -1
- package/dist/api/compiler/locales/zh-CN.d.ts +1 -1
- package/dist/api/compiler/locales/zh-CN.js +1 -1
- package/dist/api/compiler/locales/zh-TW.d.ts +1 -1
- package/dist/api/compiler/locales/zh-TW.js +1 -1
- package/dist/api/compiler/module-resolution-types.js +6 -6
- package/dist/api/compiler/module-resolution.d.ts +10 -1
- package/dist/api/compiler/module-resolution.js +115 -84
- package/dist/api/compiler/module-specifiers.d.ts +15 -0
- package/dist/api/compiler/module-specifiers.js +24 -18
- package/dist/api/compiler/name-resolver.js +74 -65
- package/dist/api/compiler/node-builder-names.d.ts +11 -3
- package/dist/api/compiler/node-builder-names.js +210 -90
- package/dist/api/compiler/node-builder-pseudo.js +29 -31
- package/dist/api/compiler/node-builder-reuse.js +23 -22
- package/dist/api/compiler/node-builder.d.ts +18 -1
- package/dist/api/compiler/node-builder.js +191 -102
- package/dist/api/compiler/option-declarations.d.ts +2 -6
- package/dist/api/compiler/option-declarations.js +315 -375
- package/dist/api/compiler/options.d.ts +15 -33
- package/dist/api/compiler/options.js +21 -54
- package/dist/api/compiler/output-paths.d.ts +4 -1
- package/dist/api/compiler/output-paths.js +6 -11
- package/dist/api/compiler/package-json.d.ts +3 -3
- package/dist/api/compiler/package-json.js +11 -10
- package/dist/api/compiler/parser.d.ts +42 -20
- package/dist/api/compiler/parser.js +318 -224
- package/dist/api/compiler/path.d.ts +9 -0
- package/dist/api/compiler/path.js +20 -3
- package/dist/api/compiler/printer/emit-context.d.ts +3 -1
- package/dist/api/compiler/printer/emit-context.js +16 -1
- package/dist/api/compiler/printer/factory-base.d.ts +2 -2
- package/dist/api/compiler/printer/factory-base.js +7 -3
- package/dist/api/compiler/printer/factory.js +6 -3
- package/dist/api/compiler/printer/helpers.js +10 -1
- package/dist/api/compiler/printer/name-generator.d.ts +1 -1
- package/dist/api/compiler/printer/name-generator.js +35 -16
- package/dist/api/compiler/printer/printer.d.ts +1 -0
- package/dist/api/compiler/printer/printer.js +306 -283
- package/dist/api/compiler/printer/utilities.js +149 -147
- package/dist/api/compiler/program-checker.d.ts +8 -2
- package/dist/api/compiler/program-checker.js +84 -34
- package/dist/api/compiler/program-utilities.d.ts +3 -1
- package/dist/api/compiler/program-utilities.js +28 -15
- package/dist/api/compiler/program.d.ts +2 -0
- package/dist/api/compiler/program.js +69 -57
- package/dist/api/compiler/pseudo-bigint.d.ts +2 -0
- package/dist/api/compiler/pseudo-bigint.js +18 -0
- package/dist/api/compiler/regexp-checker.d.ts +1 -1
- package/dist/api/compiler/regexp-checker.js +93 -76
- package/dist/api/compiler/relations.d.ts +27 -4
- package/dist/api/compiler/relations.js +337 -180
- package/dist/api/compiler/reparser.js +64 -59
- package/dist/api/compiler/scanner.d.ts +27 -2
- package/dist/api/compiler/scanner.js +181 -150
- package/dist/api/compiler/shared-results.d.ts +696 -0
- package/dist/api/compiler/shared-results.js +2905 -0
- package/dist/api/compiler/sourcemap.js +2 -2
- package/dist/api/compiler/symbol-accessibility.js +87 -74
- package/dist/api/compiler/symbol.d.ts +22 -13
- package/dist/api/compiler/symbol.js +15 -1
- package/dist/api/compiler/syntax-kind.d.ts +198 -197
- package/dist/api/compiler/transformers/alias-references.js +247 -139
- package/dist/api/compiler/transformers/async-utilities.js +25 -25
- package/dist/api/compiler/transformers/async.d.ts +0 -1
- package/dist/api/compiler/transformers/async.js +64 -77
- package/dist/api/compiler/transformers/class-fields.d.ts +1 -0
- package/dist/api/compiler/transformers/class-fields.js +81 -78
- package/dist/api/compiler/transformers/commonjs-module.js +18 -15
- package/dist/api/compiler/transformers/const-enum-inliner.js +1 -1
- package/dist/api/compiler/transformers/declarations-diagnostics.js +247 -244
- package/dist/api/compiler/transformers/declarations-pseudo.js +100 -100
- package/dist/api/compiler/transformers/declarations-resolver.d.ts +0 -3
- package/dist/api/compiler/transformers/declarations-syntactic.d.ts +1 -2
- package/dist/api/compiler/transformers/declarations-syntactic.js +134 -156
- package/dist/api/compiler/transformers/declarations-tracker.js +18 -18
- package/dist/api/compiler/transformers/declarations.d.ts +4 -1
- package/dist/api/compiler/transformers/declarations.js +307 -239
- package/dist/api/compiler/transformers/decorator-metadata.d.ts +1 -1
- package/dist/api/compiler/transformers/decorator-metadata.js +53 -45
- package/dist/api/compiler/transformers/decorator-utilities.js +24 -24
- package/dist/api/compiler/transformers/destructuring.js +19 -18
- package/dist/api/compiler/transformers/emit-resolver.js +1 -1
- package/dist/api/compiler/transformers/es-decorators.js +55 -55
- package/dist/api/compiler/transformers/external-module-info.js +3 -3
- package/dist/api/compiler/transformers/for-await.js +25 -25
- package/dist/api/compiler/transformers/import-elision.js +14 -14
- package/dist/api/compiler/transformers/jsx.js +12 -12
- package/dist/api/compiler/transformers/legacy-decorators.js +17 -17
- package/dist/api/compiler/transformers/module.js +8 -8
- package/dist/api/compiler/transformers/named-evaluation.js +4 -4
- package/dist/api/compiler/transformers/object-rest-spread.js +20 -20
- package/dist/api/compiler/transformers/optional-chain.js +10 -10
- package/dist/api/compiler/transformers/reference-resolver.d.ts +12 -1
- package/dist/api/compiler/transformers/reference-resolver.js +131 -69
- package/dist/api/compiler/transformers/runtime-syntax.js +35 -31
- package/dist/api/compiler/transformers/subtree-facts.js +47 -47
- package/dist/api/compiler/transformers/syntax-facts.js +56 -58
- package/dist/api/compiler/transformers/type-eraser.js +73 -66
- package/dist/api/compiler/transformers/type-serialization.js +24 -24
- package/dist/api/compiler/transformers/using.js +12 -12
- package/dist/api/compiler/transformers/utilities.js +77 -77
- package/dist/api/compiler/transformers/visitor-base.js +172 -172
- package/dist/api/compiler/transformers/visitor-hooks.js +6 -2
- package/dist/api/compiler/tsconfig.d.ts +10 -2
- package/dist/api/compiler/tsconfig.js +136 -48
- package/dist/api/compiler/type-printer.js +40 -3
- package/dist/api/compiler/types.d.ts +2 -1
- package/dist/api/library/ast.generated.d.ts +42 -39
- package/dist/api/library/ast.generated.js +1 -1
- package/dist/api/library/compiler-options.generated.d.ts +111 -100
- package/dist/api/library/compiler-options.generated.js +1 -1
- package/dist/api/library/disk.js +12 -1
- package/dist/api/library/enums.generated.d.ts +206 -206
- package/dist/api/library/enums.generated.js +206 -206
- package/dist/api/library/nodes.js +26 -26
- package/package.json +9 -9
- package/src/compiler/ast-utilities.ts +99 -7
- package/src/compiler/ast.ts +74 -38
- package/src/compiler/binder.ts +39 -4
- package/src/compiler/cgroup.ts +157 -0
- package/src/compiler/character-codes.ts +2 -2
- package/src/compiler/checker-calls.ts +76 -8
- package/src/compiler/checker-classes.ts +80 -25
- package/src/compiler/checker-contextual.ts +110 -1
- package/src/compiler/checker-declarations.ts +31 -4
- package/src/compiler/checker-declared-types.ts +8 -5
- package/src/compiler/checker-decorators.ts +1 -1
- package/src/compiler/checker-deprecation.ts +29 -8
- package/src/compiler/checker-destructuring.ts +10 -3
- package/src/compiler/checker-emit-helpers.ts +1 -0
- package/src/compiler/checker-emit-resolver.ts +16 -6
- package/src/compiler/checker-expressions.ts +95 -47
- package/src/compiler/checker-functions.ts +21 -6
- package/src/compiler/checker-generated-code.ts +2 -22
- package/src/compiler/checker-grammar.ts +133 -60
- package/src/compiler/checker-heritage.ts +22 -21
- package/src/compiler/checker-inference.ts +514 -87
- package/src/compiler/checker-iteration.ts +18 -31
- package/src/compiler/checker-javascript.ts +1 -1
- package/src/compiler/checker-jsdoc.ts +50 -27
- package/src/compiler/checker-jsx.ts +28 -5
- package/src/compiler/checker-members.ts +197 -55
- package/src/compiler/checker-modules.ts +332 -65
- package/src/compiler/checker-narrowing.ts +98 -19
- package/src/compiler/checker-object-literals.ts +3 -0
- package/src/compiler/checker-operators.ts +11 -4
- package/src/compiler/checker-property-access.ts +7 -2
- package/src/compiler/checker-services.ts +39 -12
- package/src/compiler/checker-signatures.ts +15 -1
- package/src/compiler/checker-source-file.ts +39 -13
- package/src/compiler/checker-statements.ts +3 -2
- package/src/compiler/checker-symbol-types.ts +29 -6
- package/src/compiler/checker-symbols.ts +158 -15
- package/src/compiler/checker-type-factory.ts +173 -35
- package/src/compiler/checker-type-nodes.ts +46 -3
- package/src/compiler/checker-type-operators.ts +83 -26
- package/src/compiler/checker-types.ts +147 -4
- package/src/compiler/checker-unused.ts +9 -14
- package/src/compiler/checker.ts +175 -41
- package/src/compiler/command-line.ts +28 -28
- package/src/compiler/compile-program.ts +59 -25
- package/src/compiler/decoder.ts +15 -5
- package/src/compiler/diagnostic-messages.ts +1973 -1892
- package/src/compiler/doctor-report.ts +133 -0
- package/src/compiler/emitter.ts +57 -8
- package/src/compiler/encoder.ts +23 -8
- package/src/compiler/expr-record.ts +59 -0
- package/src/compiler/file-include.ts +9 -3
- package/src/compiler/file-loader.ts +139 -32
- package/src/compiler/help.ts +10 -14
- package/src/compiler/identifier-name.ts +13 -0
- package/src/compiler/incremental.ts +86 -18
- package/src/compiler/init.ts +2 -7
- package/src/compiler/instantiation.ts +77 -22
- package/src/compiler/jsdoc.ts +7 -3
- package/src/compiler/link-tables.ts +82 -37
- package/src/compiler/locales/cs-CZ.ts +1 -1
- package/src/compiler/locales/de-DE.ts +1 -1
- package/src/compiler/locales/es-ES.ts +1 -1
- package/src/compiler/locales/fr-FR.ts +1 -1
- package/src/compiler/locales/it-IT.ts +1 -1
- package/src/compiler/locales/ja-JP.ts +1 -1
- package/src/compiler/locales/ko-KR.ts +1 -1
- package/src/compiler/locales/pl-PL.ts +1 -1
- package/src/compiler/locales/pt-BR.ts +1 -1
- package/src/compiler/locales/ru-RU.ts +1 -1
- package/src/compiler/locales/tr-TR.ts +1 -1
- package/src/compiler/locales/zh-CN.ts +1 -1
- package/src/compiler/locales/zh-TW.ts +1 -1
- package/src/compiler/module-resolution.ts +44 -8
- package/src/compiler/module-specifiers.ts +62 -20
- package/src/compiler/name-resolver.ts +9 -1
- package/src/compiler/node-builder-names.ts +236 -54
- package/src/compiler/node-builder-pseudo.ts +4 -7
- package/src/compiler/node-builder-reuse.ts +5 -4
- package/src/compiler/node-builder.ts +130 -31
- package/src/compiler/option-declarations.ts +33 -103
- package/src/compiler/options.ts +23 -62
- package/src/compiler/output-paths.ts +5 -18
- package/src/compiler/package-entrypoints.ts +345 -0
- package/src/compiler/package-json.ts +4 -4
- package/src/compiler/parallel-check.ts +543 -147
- package/src/compiler/parallel-emit.ts +4 -4
- package/src/compiler/parser.ts +166 -47
- package/src/compiler/path.ts +22 -2
- package/src/compiler/printer/emit-context.ts +16 -0
- package/src/compiler/printer/factory-base.ts +10 -3
- package/src/compiler/printer/factory.ts +7 -3
- package/src/compiler/printer/helpers.ts +10 -1
- package/src/compiler/printer/name-generator.ts +24 -2
- package/src/compiler/printer/printer.ts +39 -16
- package/src/compiler/printer/utilities.ts +8 -2
- package/src/compiler/program-checker.ts +53 -5
- package/src/compiler/program-utilities.ts +23 -10
- package/src/compiler/program.ts +13 -1
- package/src/compiler/pseudo-bigint.ts +17 -0
- package/src/compiler/regexp-checker.ts +63 -30
- package/src/compiler/relations.ts +233 -77
- package/src/compiler/reparser.ts +14 -5
- package/src/compiler/run-config.ts +1383 -0
- package/src/compiler/run-record-read.ts +87 -0
- package/src/compiler/run-records.ts +575 -0
- package/src/compiler/scanner.ts +166 -120
- package/src/compiler/shared-results.ts +3144 -0
- package/src/compiler/show-config.ts +18 -1
- package/src/compiler/sourcemap.ts +2 -2
- package/src/compiler/symbol-accessibility.ts +26 -3
- package/src/compiler/symbol.ts +31 -14
- package/src/compiler/syntax-kind.ts +188 -187
- package/src/compiler/thread-entry.ts +22 -3
- package/src/compiler/transformers/alias-references.ts +123 -4
- package/src/compiler/transformers/async.ts +2 -17
- package/src/compiler/transformers/class-fields.ts +13 -12
- package/src/compiler/transformers/commonjs-module.ts +11 -7
- package/src/compiler/transformers/declarations-diagnostics.ts +5 -3
- package/src/compiler/transformers/declarations-pseudo.ts +2 -4
- package/src/compiler/transformers/declarations-resolver.ts +0 -3
- package/src/compiler/transformers/declarations-syntactic.ts +1 -21
- package/src/compiler/transformers/declarations.ts +136 -49
- package/src/compiler/transformers/decorator-metadata.ts +9 -1
- package/src/compiler/transformers/destructuring.ts +4 -3
- package/src/compiler/transformers/external-module-info.ts +1 -1
- package/src/compiler/transformers/jsx.ts +2 -1
- package/src/compiler/transformers/reference-resolver.ts +83 -19
- package/src/compiler/transformers/runtime-syntax.ts +6 -1
- package/src/compiler/transformers/syntax-facts.ts +2 -7
- package/src/compiler/transformers/type-eraser.ts +10 -1
- package/src/compiler/transformers/type-serialization.ts +3 -2
- package/src/compiler/transformers/visitor-base.ts +2 -1
- package/src/compiler/transformers/visitor-hooks.ts +9 -4
- package/src/compiler/tsc-build.ts +67 -6
- package/src/compiler/tsc-cli.ts +35 -4
- package/src/compiler/tsc-compile.ts +220 -10
- package/src/compiler/tsc-watch.ts +97 -47
- package/src/compiler/tsconfig.ts +176 -19
- package/src/compiler/type-printer.ts +36 -2
- package/src/compiler/types.ts +2 -1
- package/src/library/ast.generated.ts +57 -41
- package/src/library/compiler-options.generated.ts +117 -103
- package/src/library/disk.ts +10 -1
- package/src/library/enums.generated.ts +196 -196
|
@@ -43,11 +43,26 @@ export declare abstract class ModuleSpecifierHost {
|
|
|
43
43
|
/** For output paths of `package.json` `imports` targets. */
|
|
44
44
|
abstract getOutputPathsHost(): OutputPathsHost;
|
|
45
45
|
}
|
|
46
|
+
/** Where a module specifier came from: an existing import (None), `node_modules`, `paths`, a redirect, a relative path, or an ambient module. */
|
|
47
|
+
export declare const enum ModuleSpecifierResultKind {
|
|
48
|
+
None = 0,
|
|
49
|
+
NodeModules = 1,
|
|
50
|
+
Paths = 2,
|
|
51
|
+
Redirect = 3,
|
|
52
|
+
Relative = 4,
|
|
53
|
+
Ambient = 5
|
|
54
|
+
}
|
|
55
|
+
export interface ModuleSpecifiersResult {
|
|
56
|
+
readonly specifiers: string[];
|
|
57
|
+
readonly kind: ModuleSpecifierResultKind;
|
|
58
|
+
}
|
|
46
59
|
/**
|
|
47
60
|
* Specifiers `importingFile` can import `moduleFileName` with, best first, as tsgo's
|
|
48
61
|
* `GetModuleSpecifiersForFileWithInfo`. `overrideImportMode` is `None` for the file's own mode.
|
|
49
62
|
*/
|
|
50
63
|
export declare function getModuleSpecifiersForFile(importingFile: SourceFile, moduleFileName: string, options: CompilerOptions, host: ModuleSpecifierHost, preferences: ModuleSpecifierPreferences, overrideImportMode: ModuleKind, forAutoImports: boolean): string[];
|
|
64
|
+
/** The specifiers `getModuleSpecifiersForFile` gives, and where they came from. */
|
|
65
|
+
export declare function getModuleSpecifiersForFileWithInfo(importingFile: SourceFile, moduleFileName: string, options: CompilerOptions, host: ModuleSpecifierHost, preferences: ModuleSpecifierPreferences, overrideImportMode: ModuleKind, forAutoImports: boolean): ModuleSpecifiersResult;
|
|
51
66
|
/** Number of `/` in a specifier, ignoring a leading `./`. */
|
|
52
67
|
export declare function countPathComponents(path: string): number;
|
|
53
68
|
/** The package name of a file or directory in `node_modules`, or `''`. */
|
|
@@ -65,12 +65,15 @@ class ResolvedPreferences {
|
|
|
65
65
|
return getAllowedEndingsInPreferredOrder(this.preferences, this.host, this.options, this.importingFile, this.oldImportSpecifier, syntaxImpliedNodeFormat);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
//// Entry points
|
|
69
68
|
/**
|
|
70
69
|
* Specifiers `importingFile` can import `moduleFileName` with, best first, as tsgo's
|
|
71
70
|
* `GetModuleSpecifiersForFileWithInfo`. `overrideImportMode` is `None` for the file's own mode.
|
|
72
71
|
*/
|
|
73
72
|
export function getModuleSpecifiersForFile(importingFile, moduleFileName, options, host, preferences, overrideImportMode, forAutoImports) {
|
|
73
|
+
return getModuleSpecifiersForFileWithInfo(importingFile, moduleFileName, options, host, preferences, overrideImportMode, forAutoImports).specifiers;
|
|
74
|
+
}
|
|
75
|
+
/** The specifiers `getModuleSpecifiersForFile` gives, and where they came from. */
|
|
76
|
+
export function getModuleSpecifiersForFileWithInfo(importingFile, moduleFileName, options, host, preferences, overrideImportMode, forAutoImports) {
|
|
74
77
|
const modulePaths = getAllModulePaths(new ImporterInfo(host.getSourceOfProjectReferenceIfOutputIncluded(importingFile), host.useCaseSensitiveFileNames()), moduleFileName, host);
|
|
75
78
|
return computeModuleSpecifiers(modulePaths, options, importingFile, host, preferences, overrideImportMode, forAutoImports);
|
|
76
79
|
}
|
|
@@ -231,7 +234,7 @@ function computeModuleSpecifiers(modulePaths, options, importingFile, host, user
|
|
|
231
234
|
// An import resolved in another mode may not resolve the same way.
|
|
232
235
|
if (existingMode !== targetMode && existingMode !== ModuleKind.None && targetMode !== ModuleKind.None)
|
|
233
236
|
continue;
|
|
234
|
-
return [text];
|
|
237
|
+
return { specifiers: [text], kind: 0 /* ModuleSpecifierResultKind.None */ };
|
|
235
238
|
}
|
|
236
239
|
let importedFileIsInNodeModules = false;
|
|
237
240
|
for (const p of modulePaths)
|
|
@@ -251,7 +254,7 @@ function computeModuleSpecifiers(modulePaths, options, importingFile, host, user
|
|
|
251
254
|
nodeModulesSpecifiers.push(specifier);
|
|
252
255
|
// A specifier for a redirect is a bare package name; nothing beats it.
|
|
253
256
|
if (modulePath.isRedirect)
|
|
254
|
-
return nodeModulesSpecifiers;
|
|
257
|
+
return { specifiers: nodeModulesSpecifiers, kind: 1 /* ModuleSpecifierResultKind.NodeModules */ };
|
|
255
258
|
}
|
|
256
259
|
const local = getLocalModuleSpecifier(modulePath.fileName, info, options, host, targetMode, preferences, modulePath.isRedirect || specifier !== '');
|
|
257
260
|
if (local === '')
|
|
@@ -275,12 +278,12 @@ function computeModuleSpecifiers(modulePaths, options, importingFile, host, user
|
|
|
275
278
|
}
|
|
276
279
|
}
|
|
277
280
|
if (pathsSpecifiers.length > 0)
|
|
278
|
-
return pathsSpecifiers;
|
|
281
|
+
return { specifiers: pathsSpecifiers, kind: 2 /* ModuleSpecifierResultKind.Paths */ };
|
|
279
282
|
if (redirectPathsSpecifiers.length > 0)
|
|
280
|
-
return redirectPathsSpecifiers;
|
|
283
|
+
return { specifiers: redirectPathsSpecifiers, kind: 3 /* ModuleSpecifierResultKind.Redirect */ };
|
|
281
284
|
if (nodeModulesSpecifiers.length > 0)
|
|
282
|
-
return nodeModulesSpecifiers;
|
|
283
|
-
return relativeSpecifiers;
|
|
285
|
+
return { specifiers: nodeModulesSpecifiers, kind: 1 /* ModuleSpecifierResultKind.NodeModules */ };
|
|
286
|
+
return { specifiers: relativeSpecifiers, kind: 4 /* ModuleSpecifierResultKind.Relative */ };
|
|
284
287
|
}
|
|
285
288
|
/** A specifier through `paths`, `package.json` `imports`, `rootDirs` or a relative path. */
|
|
286
289
|
function getLocalModuleSpecifier(moduleFileName, info, options, host, importMode, preferences, pathsOnly) {
|
|
@@ -489,9 +492,17 @@ function tryGetModuleNameAsNodeModule(modulePath, info, importingFile, host, opt
|
|
|
489
492
|
const parts = getNodeModulePathParts(modulePath.fileName);
|
|
490
493
|
if (parts === undefined)
|
|
491
494
|
return '';
|
|
495
|
+
// Only a `node_modules` in the importing file's directory or above can be used, and not the global typings
|
|
496
|
+
// cache. This is checked before `exports`, which can give a bare specifier directly.
|
|
497
|
+
const caseSensitive = host.useCaseSensitiveFileNames();
|
|
498
|
+
const globalTypingsCacheLocation = host.getGlobalTypingsCacheLocation();
|
|
499
|
+
const pathToTopLevelNodeModules = modulePath.fileName.slice(0, parts.topLevelNodeModulesIndex);
|
|
500
|
+
if (!hasPrefix(info.sourceDirectory, pathToTopLevelNodeModules, caseSensitive) ||
|
|
501
|
+
(globalTypingsCacheLocation !== '' &&
|
|
502
|
+
hasPrefix(globalTypingsCacheLocation, pathToTopLevelNodeModules, caseSensitive)))
|
|
503
|
+
return '';
|
|
492
504
|
const preferences = resolvePreferences(userPreferences, host, options, importingFile, '');
|
|
493
505
|
const allowedEndings = preferences.allowedEndings(ModuleKind.None);
|
|
494
|
-
const caseSensitive = host.useCaseSensitiveFileNames();
|
|
495
506
|
let moduleSpecifier = modulePath.fileName;
|
|
496
507
|
let isPackageRootPath = false;
|
|
497
508
|
if (!packageNameOnly) {
|
|
@@ -512,14 +523,6 @@ function tryGetModuleNameAsNodeModule(modulePath, info, importingFile, host, opt
|
|
|
512
523
|
}
|
|
513
524
|
if (modulePath.isRedirect && !isPackageRootPath)
|
|
514
525
|
return '';
|
|
515
|
-
// Only a `node_modules` in the importing file's directory or above can be used, and not the
|
|
516
|
-
// global typings cache.
|
|
517
|
-
const globalTypingsCacheLocation = host.getGlobalTypingsCacheLocation();
|
|
518
|
-
const pathToTopLevelNodeModules = moduleSpecifier.slice(0, parts.topLevelNodeModulesIndex);
|
|
519
|
-
if (!hasPrefix(info.sourceDirectory, pathToTopLevelNodeModules, caseSensitive) ||
|
|
520
|
-
(globalTypingsCacheLocation !== '' &&
|
|
521
|
-
hasPrefix(globalTypingsCacheLocation, pathToTopLevelNodeModules, caseSensitive)))
|
|
522
|
-
return '';
|
|
523
526
|
// A package found in `@types` is imported by its own name.
|
|
524
527
|
return getPackageNameFromTypesPackageName(moduleSpecifier.slice(parts.topLevelPackageNameIndex + 1));
|
|
525
528
|
}
|
|
@@ -914,10 +917,13 @@ function getPreferredEnding(preferences, host, options, importingFile, oldImport
|
|
|
914
917
|
/** The endings a specifier from `importingFile` may have, most preferred first. */
|
|
915
918
|
export function getAllowedEndingsInPreferredOrder(preferences, host, options, importingFile, oldImportSpecifier, syntaxImpliedNodeFormat) {
|
|
916
919
|
let preferred = getPreferredEnding(preferences, host, options, importingFile, oldImportSpecifier, ModuleKind.None);
|
|
917
|
-
|
|
920
|
+
const resolutionMode = host.getDefaultResolutionModeForFile(importingFile);
|
|
921
|
+
if (resolutionMode !== syntaxImpliedNodeFormat)
|
|
918
922
|
preferred = getPreferredEnding(preferences, host, options, importingFile, oldImportSpecifier, syntaxImpliedNodeFormat);
|
|
919
923
|
const allowTs = shouldAllowImportingTsExtension(options, importingFile.fileName);
|
|
920
|
-
|
|
924
|
+
// Without a mode implied by the syntax, the file's default resolution mode applies.
|
|
925
|
+
const effectiveSyntaxMode = syntaxImpliedNodeFormat !== ModuleKind.None ? syntaxImpliedNodeFormat : resolutionMode;
|
|
926
|
+
if (effectiveSyntaxMode === ModuleKind.ESNext && isNodeNext(options))
|
|
921
927
|
return allowTs
|
|
922
928
|
? [3 /* ModuleSpecifierEnding.TsExtension */, 2 /* ModuleSpecifierEnding.JsExtension */]
|
|
923
929
|
: [2 /* ModuleSpecifierEnding.JsExtension */];
|
|
@@ -76,7 +76,7 @@ export class NameResolver {
|
|
|
76
76
|
if (nameIsConst && isConstAssertion(current))
|
|
77
77
|
return undefined;
|
|
78
78
|
// From the name of a namespace or enum, skip its own scope: its locals could conflict.
|
|
79
|
-
if ((current.kind ===
|
|
79
|
+
if ((current.kind === 269 /* SyntaxKind.ModuleDeclaration */ || current.kind === 268 /* SyntaxKind.EnumDeclaration */) &&
|
|
80
80
|
lastLocation !== undefined &&
|
|
81
81
|
getName(current) === lastLocation) {
|
|
82
82
|
lastLocation = current;
|
|
@@ -84,25 +84,32 @@ export class NameResolver {
|
|
|
84
84
|
if (current === undefined)
|
|
85
85
|
break;
|
|
86
86
|
}
|
|
87
|
+
// A module's import attributes type sees neither the module's locals nor its exports.
|
|
88
|
+
const isModuleAttributes = current.kind === 269 /* SyntaxKind.ModuleDeclaration */ &&
|
|
89
|
+
current.attributes !== undefined &&
|
|
90
|
+
lastLocation === current.attributes;
|
|
87
91
|
const locals = getLocalsOf(current);
|
|
88
92
|
// Locals of a global source file are merged into the globals.
|
|
89
93
|
if (locals !== undefined && !isGlobalSourceFile(current)) {
|
|
90
94
|
result = this.lookup(locals, name, meaning);
|
|
91
95
|
if (result !== undefined) {
|
|
92
96
|
let useResult = true;
|
|
93
|
-
if (
|
|
97
|
+
if (isModuleAttributes) {
|
|
98
|
+
useResult = false;
|
|
99
|
+
}
|
|
100
|
+
else if (isFunctionLike(current) && lastLocation !== undefined && lastLocation !== getBody(current)) {
|
|
94
101
|
// Type parameters are in scope in the whole signature, but local types only in the
|
|
95
102
|
// body; parameters only in the body, parameter list and return type. JSDoc types
|
|
96
103
|
// are parented above type parameters, so this doesn't apply to them.
|
|
97
|
-
if ((meaning & result.flags & 788968 /* SymbolFlags.Type */) !== 0 && lastLocation.kind !==
|
|
104
|
+
if ((meaning & result.flags & 788968 /* SymbolFlags.Type */) !== 0 && lastLocation.kind !== 316 /* SyntaxKind.JSDoc */) {
|
|
98
105
|
useResult =
|
|
99
106
|
(result.flags & 262144 /* SymbolFlags.TypeParameter */) !== 0 &&
|
|
100
107
|
((lastLocation.flags & 16 /* NodeFlags.Synthesized */) !== 0 ||
|
|
101
108
|
lastLocation === getType(current) ||
|
|
102
|
-
lastLocation.kind ===
|
|
103
|
-
lastLocation.kind ===
|
|
104
|
-
lastLocation.kind ===
|
|
105
|
-
lastLocation.kind ===
|
|
109
|
+
lastLocation.kind === 171 /* SyntaxKind.Parameter */ ||
|
|
110
|
+
lastLocation.kind === 334 /* SyntaxKind.JSDocParameterTag */ ||
|
|
111
|
+
lastLocation.kind === 335 /* SyntaxKind.JSDocReturnTag */ ||
|
|
112
|
+
lastLocation.kind === 170 /* SyntaxKind.TypeParameter */);
|
|
106
113
|
}
|
|
107
114
|
if ((meaning & result.flags & 3 /* SymbolFlags.Variable */) !== 0) {
|
|
108
115
|
if (this.useOuterVariableScopeInParameter(result, current, lastLocation))
|
|
@@ -110,7 +117,7 @@ export class NameResolver {
|
|
|
110
117
|
else if ((result.flags & 1 /* SymbolFlags.FunctionScopedVariable */) !== 0) {
|
|
111
118
|
// Initializers referencing later parameters are checked separately.
|
|
112
119
|
useResult =
|
|
113
|
-
lastLocation.kind ===
|
|
120
|
+
lastLocation.kind === 171 /* SyntaxKind.Parameter */ ||
|
|
114
121
|
(lastLocation.flags & 16 /* NodeFlags.Synthesized */) !== 0 ||
|
|
115
122
|
(lastLocation === getType(current) && isInParameter(result.valueDeclaration));
|
|
116
123
|
}
|
|
@@ -127,15 +134,17 @@ export class NameResolver {
|
|
|
127
134
|
}
|
|
128
135
|
withinDeferredContext = withinDeferredContext || isDeferredContext(current, lastLocation);
|
|
129
136
|
switch (current.kind) {
|
|
130
|
-
case
|
|
131
|
-
case
|
|
132
|
-
if (current.kind ===
|
|
137
|
+
case 308 /* SyntaxKind.SourceFile */:
|
|
138
|
+
case 269 /* SyntaxKind.ModuleDeclaration */: {
|
|
139
|
+
if (current.kind === 308 /* SyntaxKind.SourceFile */ && !isExternalOrCommonJSModule(current))
|
|
140
|
+
break;
|
|
141
|
+
if (isModuleAttributes)
|
|
133
142
|
break;
|
|
134
143
|
const moduleSymbol = this.getSymbolOfDeclaration(current);
|
|
135
144
|
if (moduleSymbol === undefined)
|
|
136
145
|
break;
|
|
137
146
|
const moduleExports = moduleSymbol.exports ?? emptyTable;
|
|
138
|
-
if (current.kind ===
|
|
147
|
+
if (current.kind === 308 /* SyntaxKind.SourceFile */ ||
|
|
139
148
|
((current.flags & 8388608 /* NodeFlags.Ambient */) !== 0 && !isGlobalScopeAugmentationNode(current))) {
|
|
140
149
|
// An external module: the local name of its default export is in scope.
|
|
141
150
|
result = moduleExports.get("default" /* InternalSymbolName.Default */);
|
|
@@ -150,14 +159,14 @@ export class NameResolver {
|
|
|
150
159
|
const moduleExport = moduleExports.get(name);
|
|
151
160
|
if (moduleExport !== undefined &&
|
|
152
161
|
moduleExport.flags === 2097152 /* SymbolFlags.Alias */ &&
|
|
153
|
-
(getDeclarationOfKind(moduleExport,
|
|
154
|
-
getDeclarationOfKind(moduleExport,
|
|
162
|
+
(getDeclarationOfKind(moduleExport, 283 /* SyntaxKind.ExportSpecifier */) !== undefined ||
|
|
163
|
+
getDeclarationOfKind(moduleExport, 282 /* SyntaxKind.NamespaceExport */) !== undefined))
|
|
155
164
|
break;
|
|
156
165
|
}
|
|
157
166
|
if (name !== "default" /* InternalSymbolName.Default */) {
|
|
158
167
|
result = this.lookup(moduleExports, name, meaning & 2623475 /* SymbolFlags.ModuleMember */);
|
|
159
168
|
if (result !== undefined) {
|
|
160
|
-
if (current.kind ===
|
|
169
|
+
if (current.kind === 308 /* SyntaxKind.SourceFile */ &&
|
|
161
170
|
current.commonJSModuleIndicator !== undefined &&
|
|
162
171
|
(result.flags & 788968 /* SymbolFlags.Type */) === 0)
|
|
163
172
|
result = undefined;
|
|
@@ -167,7 +176,7 @@ export class NameResolver {
|
|
|
167
176
|
}
|
|
168
177
|
break;
|
|
169
178
|
}
|
|
170
|
-
case
|
|
179
|
+
case 268 /* SyntaxKind.EnumDeclaration */: {
|
|
171
180
|
const enumSymbol = this.getSymbolOfDeclaration(current);
|
|
172
181
|
if (enumSymbol === undefined)
|
|
173
182
|
break;
|
|
@@ -185,7 +194,7 @@ export class NameResolver {
|
|
|
185
194
|
}
|
|
186
195
|
break;
|
|
187
196
|
}
|
|
188
|
-
case
|
|
197
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
189
198
|
if (!isStatic(current)) {
|
|
190
199
|
const ctor = findConstructorDeclaration(current.parent);
|
|
191
200
|
if (ctor !== undefined) {
|
|
@@ -196,9 +205,9 @@ export class NameResolver {
|
|
|
196
205
|
}
|
|
197
206
|
}
|
|
198
207
|
break;
|
|
199
|
-
case
|
|
200
|
-
case
|
|
201
|
-
case
|
|
208
|
+
case 265 /* SyntaxKind.ClassDeclaration */:
|
|
209
|
+
case 233 /* SyntaxKind.ClassExpression */:
|
|
210
|
+
case 266 /* SyntaxKind.InterfaceDeclaration */: {
|
|
202
211
|
const classSymbol = this.getSymbolOfDeclaration(current);
|
|
203
212
|
result =
|
|
204
213
|
classSymbol === undefined
|
|
@@ -213,12 +222,12 @@ export class NameResolver {
|
|
|
213
222
|
// Type parameters aren't in scope in static members.
|
|
214
223
|
if (lastLocation !== undefined && isStatic(lastLocation)) {
|
|
215
224
|
if (nameNotFoundMessage !== undefined)
|
|
216
|
-
this.error(originalLocation,
|
|
225
|
+
this.error(originalLocation, 487 /* Diagnostics.Static_members_cannot_reference_class_type_parameters */, noArgs);
|
|
217
226
|
return undefined;
|
|
218
227
|
}
|
|
219
228
|
break loop;
|
|
220
229
|
}
|
|
221
|
-
if (current.kind ===
|
|
230
|
+
if (current.kind === 233 /* SyntaxKind.ClassExpression */ && (meaning & 32 /* SymbolFlags.Class */) !== 0) {
|
|
222
231
|
const className = getName(current);
|
|
223
232
|
if (className !== undefined && name === getText(className)) {
|
|
224
233
|
result = symbolOfNode(current);
|
|
@@ -227,7 +236,7 @@ export class NameResolver {
|
|
|
227
236
|
}
|
|
228
237
|
break;
|
|
229
238
|
}
|
|
230
|
-
case
|
|
239
|
+
case 235 /* SyntaxKind.ExpressionWithTypeArguments */: {
|
|
231
240
|
const heritage = current.parent;
|
|
232
241
|
if (lastLocation === current.expression &&
|
|
233
242
|
heritage instanceof HeritageClause &&
|
|
@@ -241,17 +250,17 @@ export class NameResolver {
|
|
|
241
250
|
: this.lookup(classSymbol.members ?? emptyTable, name, meaning & 788968 /* SymbolFlags.Type */);
|
|
242
251
|
if (result !== undefined) {
|
|
243
252
|
if (nameNotFoundMessage !== undefined)
|
|
244
|
-
this.error(originalLocation,
|
|
253
|
+
this.error(originalLocation, 723 /* Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters */, noArgs);
|
|
245
254
|
return undefined;
|
|
246
255
|
}
|
|
247
256
|
}
|
|
248
257
|
}
|
|
249
258
|
break;
|
|
250
259
|
}
|
|
251
|
-
case
|
|
260
|
+
case 169 /* SyntaxKind.ComputedPropertyName */: {
|
|
252
261
|
// A class's computed property names can't reference its own type parameters.
|
|
253
262
|
const grandparent = current.parent.parent;
|
|
254
|
-
if (isClassLike(grandparent) || grandparent.kind ===
|
|
263
|
+
if (isClassLike(grandparent) || grandparent.kind === 266 /* SyntaxKind.InterfaceDeclaration */) {
|
|
255
264
|
const containerSymbol = this.getSymbolOfDeclaration(grandparent);
|
|
256
265
|
result =
|
|
257
266
|
containerSymbol === undefined
|
|
@@ -259,23 +268,23 @@ export class NameResolver {
|
|
|
259
268
|
: this.lookup(containerSymbol.members ?? emptyTable, name, meaning & 788968 /* SymbolFlags.Type */);
|
|
260
269
|
if (result !== undefined) {
|
|
261
270
|
if (nameNotFoundMessage !== undefined)
|
|
262
|
-
this.error(originalLocation,
|
|
271
|
+
this.error(originalLocation, 640 /* Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type */, noArgs);
|
|
263
272
|
return undefined;
|
|
264
273
|
}
|
|
265
274
|
}
|
|
266
275
|
break;
|
|
267
276
|
}
|
|
268
|
-
case
|
|
269
|
-
case
|
|
270
|
-
case
|
|
271
|
-
case
|
|
272
|
-
case
|
|
277
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
278
|
+
case 178 /* SyntaxKind.Constructor */:
|
|
279
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
280
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
281
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
273
282
|
if ((meaning & 3 /* SymbolFlags.Variable */) !== 0 && name === 'arguments') {
|
|
274
283
|
result = this.getArgumentsSymbol();
|
|
275
284
|
break loop;
|
|
276
285
|
}
|
|
277
286
|
break;
|
|
278
|
-
case
|
|
287
|
+
case 220 /* SyntaxKind.FunctionExpression */: {
|
|
279
288
|
if ((meaning & 3 /* SymbolFlags.Variable */) !== 0 && name === 'arguments') {
|
|
280
289
|
result = this.getArgumentsSymbol();
|
|
281
290
|
break loop;
|
|
@@ -287,18 +296,18 @@ export class NameResolver {
|
|
|
287
296
|
}
|
|
288
297
|
break;
|
|
289
298
|
}
|
|
290
|
-
case
|
|
299
|
+
case 172 /* SyntaxKind.Decorator */: {
|
|
291
300
|
// Decorators resolve at the class: a parameter's at its class member, a member's at the class.
|
|
292
301
|
let parent = current.parent;
|
|
293
|
-
if (parent !== undefined && parent.kind ===
|
|
302
|
+
if (parent !== undefined && parent.kind === 171 /* SyntaxKind.Parameter */) {
|
|
294
303
|
current = parent;
|
|
295
304
|
parent = current.parent;
|
|
296
305
|
}
|
|
297
|
-
if (parent !== undefined && (isClassElement(parent) || parent.kind ===
|
|
306
|
+
if (parent !== undefined && (isClassElement(parent) || parent.kind === 265 /* SyntaxKind.ClassDeclaration */))
|
|
298
307
|
current = parent;
|
|
299
308
|
break;
|
|
300
309
|
}
|
|
301
|
-
case
|
|
310
|
+
case 171 /* SyntaxKind.Parameter */: {
|
|
302
311
|
const parameter = current;
|
|
303
312
|
if (lastLocation !== undefined &&
|
|
304
313
|
(lastLocation === parameter.initializer ||
|
|
@@ -307,7 +316,7 @@ export class NameResolver {
|
|
|
307
316
|
associatedDeclarationForContainingInitializerOrBindingName = current;
|
|
308
317
|
break;
|
|
309
318
|
}
|
|
310
|
-
case
|
|
319
|
+
case 210 /* SyntaxKind.BindingElement */: {
|
|
311
320
|
const element = current;
|
|
312
321
|
if (lastLocation !== undefined &&
|
|
313
322
|
(lastLocation === element.initializer ||
|
|
@@ -317,7 +326,7 @@ export class NameResolver {
|
|
|
317
326
|
associatedDeclarationForContainingInitializerOrBindingName = current;
|
|
318
327
|
break;
|
|
319
328
|
}
|
|
320
|
-
case
|
|
329
|
+
case 197 /* SyntaxKind.InferType */:
|
|
321
330
|
if ((meaning & 262144 /* SymbolFlags.TypeParameter */) !== 0) {
|
|
322
331
|
const typeParameter = current.typeParameter;
|
|
323
332
|
if (name === typeParameter.name.text) {
|
|
@@ -326,7 +335,7 @@ export class NameResolver {
|
|
|
326
335
|
}
|
|
327
336
|
}
|
|
328
337
|
break;
|
|
329
|
-
case
|
|
338
|
+
case 283 /* SyntaxKind.ExportSpecifier */: {
|
|
330
339
|
// `export { a as b } from "m"`: `a` resolves outside this module.
|
|
331
340
|
const specifier = current;
|
|
332
341
|
const exportDeclaration = current.parent.parent;
|
|
@@ -371,7 +380,7 @@ export class NameResolver {
|
|
|
371
380
|
* aren't in scope there unless emit moves the parameter into the body.
|
|
372
381
|
*/
|
|
373
382
|
useOuterVariableScopeInParameter(result, location, lastLocation) {
|
|
374
|
-
if (lastLocation.kind !==
|
|
383
|
+
if (lastLocation.kind !== 171 /* SyntaxKind.Parameter */)
|
|
375
384
|
return false;
|
|
376
385
|
const body = getBody(location);
|
|
377
386
|
const declaration = result.valueDeclaration;
|
|
@@ -407,17 +416,17 @@ class ScopeChangeFinder extends NodeVisitor {
|
|
|
407
416
|
}
|
|
408
417
|
requiresScopeChange(node) {
|
|
409
418
|
switch (node.kind) {
|
|
410
|
-
case
|
|
411
|
-
case
|
|
412
|
-
case
|
|
413
|
-
case
|
|
419
|
+
case 221 /* SyntaxKind.ArrowFunction */:
|
|
420
|
+
case 220 /* SyntaxKind.FunctionExpression */:
|
|
421
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
422
|
+
case 178 /* SyntaxKind.Constructor */:
|
|
414
423
|
return false;
|
|
415
|
-
case
|
|
416
|
-
case
|
|
417
|
-
case
|
|
418
|
-
case
|
|
424
|
+
case 176 /* SyntaxKind.MethodDeclaration */:
|
|
425
|
+
case 179 /* SyntaxKind.GetAccessor */:
|
|
426
|
+
case 180 /* SyntaxKind.SetAccessor */:
|
|
427
|
+
case 304 /* SyntaxKind.PropertyAssignment */:
|
|
419
428
|
return this.requiresScopeChange(getName(node));
|
|
420
|
-
case
|
|
429
|
+
case 174 /* SyntaxKind.PropertyDeclaration */:
|
|
421
430
|
if (hasStaticModifier(node))
|
|
422
431
|
return !getEmitStandardClassFields(this.options);
|
|
423
432
|
return this.requiresScopeChange(getName(node));
|
|
@@ -426,7 +435,7 @@ class ScopeChangeFinder extends NodeVisitor {
|
|
|
426
435
|
return getEmitScriptTarget(this.options) < 7 /* ScriptTarget.ES2020 */;
|
|
427
436
|
if (node instanceof BindingElement &&
|
|
428
437
|
node.dotDotDotToken !== undefined &&
|
|
429
|
-
node.parent.kind ===
|
|
438
|
+
node.parent.kind === 208 /* SyntaxKind.ObjectBindingPattern */)
|
|
430
439
|
return getEmitScriptTarget(this.options) < 4 /* ScriptTarget.ES2017 */;
|
|
431
440
|
if (isTypeNodeKind(node.kind))
|
|
432
441
|
return false;
|
|
@@ -446,14 +455,14 @@ function getLocalsOf(node) {
|
|
|
446
455
|
return getLocals(node);
|
|
447
456
|
}
|
|
448
457
|
function isBindingPattern(node) {
|
|
449
|
-
return node.kind ===
|
|
458
|
+
return node.kind === 208 /* SyntaxKind.ObjectBindingPattern */ || node.kind === 209 /* SyntaxKind.ArrayBindingPattern */;
|
|
450
459
|
}
|
|
451
460
|
function isGlobalScopeAugmentationNode(node) {
|
|
452
461
|
return node instanceof ModuleDeclaration && node.keyword === 162 /* SyntaxKind.GlobalKeyword */;
|
|
453
462
|
}
|
|
454
463
|
function isInParameter(declaration) {
|
|
455
464
|
for (let current = declaration; current !== undefined; current = current.parent)
|
|
456
|
-
if (current.kind ===
|
|
465
|
+
if (current.kind === 171 /* SyntaxKind.Parameter */)
|
|
457
466
|
return true;
|
|
458
467
|
return false;
|
|
459
468
|
}
|
|
@@ -471,11 +480,11 @@ export function getLocalSymbolForExportDefault(symbol) {
|
|
|
471
480
|
}
|
|
472
481
|
/** Whether a reference at `location` runs later than its scope's own code, like in a function body. */
|
|
473
482
|
function isDeferredContext(location, lastLocation) {
|
|
474
|
-
if (location.kind !==
|
|
483
|
+
if (location.kind !== 221 /* SyntaxKind.ArrowFunction */ && location.kind !== 220 /* SyntaxKind.FunctionExpression */) {
|
|
475
484
|
// Instance property initializers run in the constructor; a declaration's name runs in its scope.
|
|
476
|
-
return (location.kind ===
|
|
485
|
+
return (location.kind === 188 /* SyntaxKind.TypeQuery */ ||
|
|
477
486
|
((isFunctionLikeDeclarationKind(location.kind) ||
|
|
478
|
-
(location.kind ===
|
|
487
|
+
(location.kind === 174 /* SyntaxKind.PropertyDeclaration */ && !isStatic(location))) &&
|
|
479
488
|
(lastLocation === undefined || lastLocation !== getName(location))));
|
|
480
489
|
}
|
|
481
490
|
if (lastLocation !== undefined && lastLocation === getName(location))
|
|
@@ -487,21 +496,21 @@ function isDeferredContext(location, lastLocation) {
|
|
|
487
496
|
}
|
|
488
497
|
function isTypeParameterSymbolDeclaredInContainer(symbol, container) {
|
|
489
498
|
for (const declaration of getDeclarations(symbol))
|
|
490
|
-
if (declaration.kind ===
|
|
499
|
+
if (declaration.kind === 170 /* SyntaxKind.TypeParameter */ && declaration.parent === container)
|
|
491
500
|
return true;
|
|
492
501
|
return false;
|
|
493
502
|
}
|
|
494
503
|
function isSelfReferenceLocation(node, lastLocation) {
|
|
495
504
|
switch (node.kind) {
|
|
496
|
-
case
|
|
505
|
+
case 171 /* SyntaxKind.Parameter */:
|
|
497
506
|
return lastLocation !== undefined && lastLocation === getName(node);
|
|
498
|
-
case
|
|
499
|
-
case
|
|
500
|
-
case
|
|
501
|
-
case
|
|
502
|
-
case
|
|
503
|
-
case
|
|
504
|
-
case
|
|
507
|
+
case 264 /* SyntaxKind.FunctionDeclaration */:
|
|
508
|
+
case 265 /* SyntaxKind.ClassDeclaration */:
|
|
509
|
+
case 266 /* SyntaxKind.InterfaceDeclaration */:
|
|
510
|
+
case 268 /* SyntaxKind.EnumDeclaration */:
|
|
511
|
+
case 267 /* SyntaxKind.TypeAliasDeclaration */:
|
|
512
|
+
case 346 /* SyntaxKind.JSTypeAliasDeclaration */:
|
|
513
|
+
case 269 /* SyntaxKind.ModuleDeclaration */:
|
|
505
514
|
// `namespace N { N; }`
|
|
506
515
|
return true;
|
|
507
516
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Node, type NodeList, SourceFile } from './ast.js';
|
|
2
|
+
import { type Type } from './checker-types.js';
|
|
2
3
|
import type { Checker } from './checker.js';
|
|
3
4
|
import { ModuleSpecifierPreferences } from './module-specifiers.js';
|
|
4
5
|
import { ModuleKind } from './options.js';
|
|
@@ -21,12 +22,19 @@ export declare function symbolToExpression(b: NodeBuilder, symbol: Symbol, meani
|
|
|
21
22
|
*/
|
|
22
23
|
export declare function getNameOfSymbolAsWritten(b: NodeBuilder, symbol: Symbol): string;
|
|
23
24
|
/** The name node of a property. */
|
|
24
|
-
export declare function getPropertyNameNodeForSymbol(b: NodeBuilder, symbol: Symbol): Node;
|
|
25
|
+
export declare function getPropertyNameNodeForSymbol(b: NodeBuilder, symbol: Symbol, enclosingDeclaration: Node | undefined): Node;
|
|
26
|
+
/** A module specifier, and the import attributes type an `import()` type with it needs. */
|
|
27
|
+
export declare class ModuleSpecifierResult {
|
|
28
|
+
readonly specifier: string;
|
|
29
|
+
readonly importAttributesType: Type | undefined;
|
|
30
|
+
constructor(specifier: string, importAttributesType: Type | undefined);
|
|
31
|
+
}
|
|
25
32
|
/**
|
|
26
33
|
* The specifier an `import("…")` type names a module with: an ambient module's name, the file
|
|
27
34
|
* name without an enclosing file, else what module specifier generation gives for the enclosing
|
|
28
|
-
* file. `overrideImportMode` is `None` for the mode of the enclosing import or file.
|
|
35
|
+
* file. `overrideImportMode` is `None` for the mode of the enclosing import or file. A pattern
|
|
36
|
+
* ambient module's specifier comes with the attributes type that resolves it.
|
|
29
37
|
*/
|
|
30
|
-
export declare function getSpecifierForModuleSymbol(b: NodeBuilder, symbol: Symbol, overrideImportMode: ModuleKind):
|
|
38
|
+
export declare function getSpecifierForModuleSymbol(b: NodeBuilder, symbol: Symbol, overrideImportMode: ModuleKind): ModuleSpecifierResult;
|
|
31
39
|
/** Specifiers `importingFile` can import the module `moduleSymbol` with, best first. */
|
|
32
40
|
export declare function getModuleSpecifiers(c: Checker, moduleSymbol: Symbol, importingFile: SourceFile, preferences: ModuleSpecifierPreferences, overrideImportMode: ModuleKind): string[];
|