tsc-ts 0.0.5 → 0.0.7
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/dist/api/compiler/ast.d.ts +67 -27
- package/dist/api/compiler/ast.js +156 -55
- package/dist/api/compiler/binder-utilities.js +4 -3
- package/dist/api/compiler/binder.js +14 -13
- package/dist/api/compiler/checker-calls.js +7 -6
- package/dist/api/compiler/checker-contextual.js +1 -1
- package/dist/api/compiler/checker-declaration-order.js +2 -1
- package/dist/api/compiler/checker-declarations.js +14 -14
- package/dist/api/compiler/checker-declared-types.d.ts +1 -1
- package/dist/api/compiler/checker-declared-types.js +12 -11
- package/dist/api/compiler/checker-decorators.js +3 -3
- package/dist/api/compiler/checker-deprecation.js +17 -18
- package/dist/api/compiler/checker-destructuring.d.ts +1 -1
- package/dist/api/compiler/checker-destructuring.js +3 -3
- package/dist/api/compiler/checker-elaboration.js +8 -7
- package/dist/api/compiler/checker-emit-helpers.d.ts +2 -1
- package/dist/api/compiler/checker-emit-helpers.js +5 -4
- package/dist/api/compiler/checker-emit-resolver.d.ts +1 -1
- package/dist/api/compiler/checker-emit-resolver.js +5 -4
- package/dist/api/compiler/checker-grammar.js +23 -9
- package/dist/api/compiler/checker-heritage.d.ts +1 -1
- package/dist/api/compiler/checker-heritage.js +14 -13
- package/dist/api/compiler/checker-inference.d.ts +21 -11
- package/dist/api/compiler/checker-inference.js +57 -34
- package/dist/api/compiler/checker-javascript.d.ts +1 -1
- package/dist/api/compiler/checker-javascript.js +5 -4
- package/dist/api/compiler/checker-jsx.d.ts +1 -1
- package/dist/api/compiler/checker-jsx.js +4 -4
- package/dist/api/compiler/checker-literals.js +2 -2
- package/dist/api/compiler/checker-members.d.ts +32 -3
- package/dist/api/compiler/checker-members.js +240 -53
- package/dist/api/compiler/checker-modules.d.ts +15 -1
- package/dist/api/compiler/checker-modules.js +86 -14
- package/dist/api/compiler/checker-object-literals.d.ts +1 -1
- package/dist/api/compiler/checker-object-literals.js +11 -7
- package/dist/api/compiler/checker-overloads.d.ts +1 -1
- package/dist/api/compiler/checker-overloads.js +4 -3
- package/dist/api/compiler/checker-property-access.d.ts +1 -1
- package/dist/api/compiler/checker-property-access.js +2 -2
- package/dist/api/compiler/checker-services.js +2 -2
- package/dist/api/compiler/checker-signatures.d.ts +1 -1
- package/dist/api/compiler/checker-signatures.js +9 -8
- package/dist/api/compiler/checker-symbol-types.d.ts +2 -18
- package/dist/api/compiler/checker-symbol-types.js +22 -952
- package/dist/api/compiler/checker-symbols.d.ts +2 -2
- package/dist/api/compiler/checker-symbols.js +29 -27
- package/dist/api/compiler/checker-type-factory.d.ts +2 -2
- package/dist/api/compiler/checker-type-factory.js +57 -16
- package/dist/api/compiler/checker-type-nodes.d.ts +1 -1
- package/dist/api/compiler/checker-type-nodes.js +2 -2
- package/dist/api/compiler/checker-type-operators.d.ts +1 -1
- package/dist/api/compiler/checker-type-operators.js +5 -5
- package/dist/api/compiler/checker-types.d.ts +73 -7
- package/dist/api/compiler/checker-types.js +220 -43
- package/dist/api/compiler/checker-unused.d.ts +1 -1
- package/dist/api/compiler/checker-unused.js +3 -3
- package/dist/api/compiler/checker.d.ts +45 -8
- package/dist/api/compiler/checker.js +46 -9
- package/dist/api/compiler/diagnostics.d.ts +2 -8
- package/dist/api/compiler/diagnostics.js +13 -45
- package/dist/api/compiler/file-include.d.ts +35 -8
- package/dist/api/compiler/file-include.js +81 -18
- package/dist/api/compiler/file-loader.d.ts +33 -4
- package/dist/api/compiler/file-loader.js +90 -24
- package/dist/api/compiler/instantiation.d.ts +1 -1
- package/dist/api/compiler/instantiation.js +86 -50
- package/dist/api/compiler/link-tables.d.ts +69 -0
- package/dist/api/compiler/link-tables.js +236 -0
- package/dist/api/compiler/name-resolver.js +3 -3
- package/dist/api/compiler/node-builder-names.d.ts +1 -1
- package/dist/api/compiler/node-builder-names.js +12 -12
- package/dist/api/compiler/node-builder-pseudo.d.ts +1 -1
- package/dist/api/compiler/node-builder-pseudo.js +2 -1
- package/dist/api/compiler/node-builder.d.ts +1 -1
- package/dist/api/compiler/node-builder.js +16 -16
- package/dist/api/compiler/parallel-parse.d.ts +2 -0
- package/dist/api/compiler/parallel-parse.js +7 -1
- package/dist/api/compiler/parser.d.ts +33 -16
- package/dist/api/compiler/parser.js +127 -98
- package/dist/api/compiler/printer/emit-context.d.ts +5 -2
- package/dist/api/compiler/printer/emit-context.js +19 -13
- package/dist/api/compiler/printer/factory-base.js +8 -8
- package/dist/api/compiler/printer/factory.js +4 -4
- package/dist/api/compiler/printer/printer.js +6 -6
- package/dist/api/compiler/program-checker.d.ts +5 -0
- package/dist/api/compiler/program-checker.js +14 -1
- package/dist/api/compiler/program.js +9 -1
- package/dist/api/compiler/relations.d.ts +1 -1
- package/dist/api/compiler/relations.js +18 -13
- package/dist/api/compiler/reparser.js +13 -5
- package/dist/api/compiler/symbol-accessibility.d.ts +1 -1
- package/dist/api/compiler/symbol-accessibility.js +123 -26
- package/dist/api/compiler/symbol.d.ts +45 -3
- package/dist/api/compiler/symbol.js +121 -10
- package/dist/api/compiler/transformers/alias-references.d.ts +1 -1
- package/dist/api/compiler/transformers/alias-references.js +2 -1
- package/dist/api/compiler/transformers/class-fields.js +3 -3
- package/dist/api/compiler/transformers/commonjs-module.js +3 -3
- package/dist/api/compiler/transformers/declarations-diagnostics.js +2 -1
- package/dist/api/compiler/transformers/declarations-pseudo.js +6 -4
- package/dist/api/compiler/transformers/declarations-syntactic.d.ts +1 -1
- package/dist/api/compiler/transformers/declarations-syntactic.js +9 -9
- package/dist/api/compiler/transformers/declarations-tracker.d.ts +1 -1
- package/dist/api/compiler/transformers/declarations-tracker.js +3 -2
- package/dist/api/compiler/transformers/declarations.js +6 -5
- package/dist/api/compiler/transformers/module.js +2 -2
- package/dist/api/compiler/transformers/optional-chain.js +3 -3
- package/dist/api/compiler/transformers/reference-resolver.d.ts +2 -1
- package/dist/api/compiler/transformers/reference-resolver.js +26 -24
- package/dist/api/compiler/transformers/subtree-facts.d.ts +1 -0
- package/dist/api/compiler/transformers/subtree-facts.js +9 -7
- package/dist/api/compiler/transformers/syntax-facts.d.ts +1 -0
- package/dist/api/compiler/transformers/syntax-facts.js +9 -5
- package/dist/api/compiler/transformers/tagged-template.js +2 -2
- package/dist/api/compiler/transformers/type-eraser.js +2 -2
- package/dist/api/compiler/transformers/type-serialization.js +12 -12
- package/dist/api/compiler/transformers/visitor-base.js +3 -3
- package/dist/api/compiler/tsconfig.js +2 -2
- package/package.json +9 -9
- package/src/compiler/ast.ts +211 -78
- package/src/compiler/binder-utilities.ts +4 -3
- package/src/compiler/binder.ts +26 -16
- package/src/compiler/checker-calls.ts +8 -6
- package/src/compiler/checker-contextual.ts +1 -1
- package/src/compiler/checker-declaration-order.ts +2 -2
- package/src/compiler/checker-declarations.ts +21 -14
- package/src/compiler/checker-declared-types.ts +12 -12
- package/src/compiler/checker-decorators.ts +3 -3
- package/src/compiler/checker-deprecation.ts +17 -21
- package/src/compiler/checker-destructuring.ts +3 -3
- package/src/compiler/checker-elaboration.ts +8 -8
- package/src/compiler/checker-emit-helpers.ts +5 -4
- package/src/compiler/checker-emit-resolver.ts +5 -5
- package/src/compiler/checker-grammar.ts +22 -8
- package/src/compiler/checker-heritage.ts +21 -14
- package/src/compiler/checker-inference.ts +66 -34
- package/src/compiler/checker-javascript.ts +5 -5
- package/src/compiler/checker-jsx.ts +12 -8
- package/src/compiler/checker-literals.ts +2 -2
- package/src/compiler/checker-members.ts +255 -47
- package/src/compiler/checker-modules.ts +115 -14
- package/src/compiler/checker-object-literals.ts +22 -6
- package/src/compiler/checker-overloads.ts +6 -6
- package/src/compiler/checker-property-access.ts +2 -2
- package/src/compiler/checker-services.ts +2 -2
- package/src/compiler/checker-signatures.ts +9 -9
- package/src/compiler/checker-symbol-types.ts +20 -940
- package/src/compiler/checker-symbols.ts +42 -35
- package/src/compiler/checker-type-factory.ts +53 -16
- package/src/compiler/checker-type-nodes.ts +2 -2
- package/src/compiler/checker-type-operators.ts +13 -5
- package/src/compiler/checker-types.ts +223 -43
- package/src/compiler/checker-unused.ts +3 -3
- package/src/compiler/checker.ts +50 -9
- package/src/compiler/decoder.ts +5 -4
- package/src/compiler/diagnostics.ts +14 -48
- package/src/compiler/encoder.ts +10 -5
- package/src/compiler/file-include.ts +85 -17
- package/src/compiler/file-loader.ts +104 -35
- package/src/compiler/incremental.ts +39 -5
- package/src/compiler/instantiation.ts +99 -55
- package/src/compiler/link-tables.ts +245 -0
- package/src/compiler/name-resolver.ts +3 -3
- package/src/compiler/node-builder-names.ts +21 -19
- package/src/compiler/node-builder-pseudo.ts +2 -2
- package/src/compiler/node-builder.ts +24 -16
- package/src/compiler/parallel-check.ts +11 -8
- package/src/compiler/parallel-parse.ts +8 -1
- package/src/compiler/parse-thread.ts +0 -4
- package/src/compiler/parser.ts +173 -93
- package/src/compiler/printer/emit-context.ts +20 -15
- package/src/compiler/printer/factory-base.ts +14 -7
- package/src/compiler/printer/factory.ts +5 -3
- package/src/compiler/printer/printer.ts +8 -6
- package/src/compiler/program-checker.ts +12 -1
- package/src/compiler/program.ts +8 -1
- package/src/compiler/relations.ts +20 -12
- package/src/compiler/reparser.ts +14 -4
- package/src/compiler/symbol-accessibility.ts +120 -25
- package/src/compiler/symbol.ts +127 -9
- package/src/compiler/transformers/alias-references.ts +2 -2
- package/src/compiler/transformers/class-fields.ts +12 -2
- package/src/compiler/transformers/commonjs-module.ts +3 -2
- package/src/compiler/transformers/declarations-diagnostics.ts +2 -1
- package/src/compiler/transformers/declarations-pseudo.ts +9 -5
- package/src/compiler/transformers/declarations-syntactic.ts +17 -9
- package/src/compiler/transformers/declarations-tracker.ts +3 -3
- package/src/compiler/transformers/declarations.ts +7 -7
- package/src/compiler/transformers/module.ts +2 -1
- package/src/compiler/transformers/optional-chain.ts +5 -2
- package/src/compiler/transformers/reference-resolver.ts +37 -25
- package/src/compiler/transformers/subtree-facts.ts +15 -6
- package/src/compiler/transformers/syntax-facts.ts +10 -5
- package/src/compiler/transformers/tagged-template.ts +2 -2
- package/src/compiler/transformers/type-eraser.ts +2 -1
- package/src/compiler/transformers/type-serialization.ts +12 -12
- package/src/compiler/transformers/visitor-base.ts +10 -5
- package/src/compiler/tsc-build.ts +17 -13
- package/src/compiler/tsc-cli.ts +9 -6
- package/src/compiler/tsc-compile.ts +16 -7
- package/src/compiler/tsc-watch.ts +94 -26
- package/src/compiler/tsconfig.ts +2 -1
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
import { type Node, type SourceFile } from './ast.js';
|
|
2
2
|
import { type DiagnosticMessage } from './diagnostics.js';
|
|
3
3
|
import { ModuleKind } from './options.js';
|
|
4
|
-
import { type Symbol, SymbolFlags, type SymbolTable } from './symbol.js';
|
|
5
4
|
import { type Checker, type CheckerHost } from './checker.js';
|
|
6
5
|
import { type Type } from './checker-types.js';
|
|
6
|
+
import { type Symbol, SymbolFlags, type SymbolTable } from './symbol.js';
|
|
7
7
|
/** The module symbol `moduleReference` names, reporting it when it isn't found unless `ignoreErrors`. */
|
|
8
8
|
export declare function resolveExternalModuleName(c: Checker, location: Node, moduleReference: Node | undefined, ignoreErrors: boolean): Symbol | undefined;
|
|
9
9
|
export declare function resolveExternalModuleNameWorker(c: Checker, location: Node, moduleReference: Node | undefined, moduleNotFoundError: DiagnosticMessage | undefined, ignoreErrors: boolean, isForAugmentation: boolean): Symbol | undefined;
|
|
10
|
+
/** A `resolveExternalModule` result that reported nothing, and the arguments it was computed for. */
|
|
11
|
+
export declare class ModuleResolution {
|
|
12
|
+
readonly moduleReference: string;
|
|
13
|
+
readonly moduleNotFoundError: DiagnosticMessage | undefined;
|
|
14
|
+
readonly isForAugmentation: boolean;
|
|
15
|
+
readonly symbol: Symbol | undefined;
|
|
16
|
+
constructor(moduleReference: string, moduleNotFoundError: DiagnosticMessage | undefined, isForAugmentation: boolean, symbol: Symbol | undefined);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The module symbol `moduleReference` resolves to from `location`, reporting resolution errors at
|
|
20
|
+
* `errorNode`. Each name an import or export declaration lists resolves its module specifier again,
|
|
21
|
+
* with the same result and the same diagnostics: a result that reported nothing is kept for the
|
|
22
|
+
* specifier and returned to later calls from the same declaration (`sharesSpecifierContext`).
|
|
23
|
+
*/
|
|
10
24
|
export declare function resolveExternalModule(c: Checker, location: Node, moduleReference: string, moduleNotFoundError: DiagnosticMessage | undefined, errorNode: Node | undefined, isForAugmentation: boolean): Symbol | undefined;
|
|
11
25
|
/** A message with its arguments, the elaboration of a diagnostic before it has a location. */
|
|
12
26
|
export declare class DiagnosticDetails {
|
|
@@ -15,7 +15,6 @@ import { getResolutionModeOverride, moduleKindName } from './program-utilities.j
|
|
|
15
15
|
import { hasExtension } from './vfs-match.js';
|
|
16
16
|
import { isNodeCoreModule } from './parser.js';
|
|
17
17
|
import { combinePaths, extensionIsTs, fileExtensionIsOneOf, getDeclarationFileExtension, getDirectoryPath, getNormalizedAbsolutePath, isDeclarationFileName, isExternalModuleNameRelative, pathIsRelative, removeExtension, supportedTSExtensionsFlat, tryExtractTSExtension, tryGetExtensionFromPath, } from './path.js';
|
|
18
|
-
import { getSymbolId } from './symbol.js';
|
|
19
18
|
import { isExpressionNode } from './transformers/alias-references.js';
|
|
20
19
|
import { createDiagnosticForNode } from './checker.js';
|
|
21
20
|
import { checkExternalEmitHelpers } from './checker-emit-helpers.js';
|
|
@@ -35,6 +34,7 @@ import { createPromiseType } from './checker-iteration.js';
|
|
|
35
34
|
import { symbolToString, typeToString } from './type-printer.js';
|
|
36
35
|
import { checkTypeAssignableToAndOptionallyElaborate } from './checker-expressions.js';
|
|
37
36
|
import { grammarErrorOnNode } from './checker-operators.js';
|
|
37
|
+
import { declarationAt, declarationCount, getDeclarations, getSymbolId, setDeclarations, } from './symbol.js';
|
|
38
38
|
// ---- Resolution
|
|
39
39
|
/** The module symbol `moduleReference` names, reporting it when it isn't found unless `ignoreErrors`. */
|
|
40
40
|
export function resolveExternalModuleName(c, location, moduleReference, ignoreErrors) {
|
|
@@ -57,7 +57,78 @@ export function resolveExternalModuleNameWorker(c, location, moduleReference, mo
|
|
|
57
57
|
return undefined;
|
|
58
58
|
return resolveExternalModule(c, location, getText(moduleReference), moduleNotFoundError, ignoreErrors ? undefined : moduleReference, isForAugmentation);
|
|
59
59
|
}
|
|
60
|
+
/** A `resolveExternalModule` result that reported nothing, and the arguments it was computed for. */
|
|
61
|
+
export class ModuleResolution {
|
|
62
|
+
moduleReference;
|
|
63
|
+
moduleNotFoundError;
|
|
64
|
+
isForAugmentation;
|
|
65
|
+
symbol;
|
|
66
|
+
constructor(moduleReference, moduleNotFoundError, isForAugmentation, symbol) {
|
|
67
|
+
this.moduleReference = moduleReference;
|
|
68
|
+
this.moduleNotFoundError = moduleNotFoundError;
|
|
69
|
+
this.isForAugmentation = isForAugmentation;
|
|
70
|
+
this.symbol = symbol;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The module symbol `moduleReference` resolves to from `location`, reporting resolution errors at
|
|
75
|
+
* `errorNode`. Each name an import or export declaration lists resolves its module specifier again,
|
|
76
|
+
* with the same result and the same diagnostics: a result that reported nothing is kept for the
|
|
77
|
+
* specifier and returned to later calls from the same declaration (`sharesSpecifierContext`).
|
|
78
|
+
*/
|
|
60
79
|
export function resolveExternalModule(c, location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) {
|
|
80
|
+
// An augmentation merged later can give the resolved module a new merged symbol, so results are
|
|
81
|
+
// kept only once every augmentation is merged.
|
|
82
|
+
const shared = c.modulesMerged && errorNode !== undefined && sharesSpecifierContext(location, errorNode);
|
|
83
|
+
if (shared) {
|
|
84
|
+
const known = c.moduleResolutions.get(errorNode);
|
|
85
|
+
if (known !== undefined &&
|
|
86
|
+
known.moduleReference === moduleReference &&
|
|
87
|
+
known.moduleNotFoundError === moduleNotFoundError &&
|
|
88
|
+
known.isForAugmentation === isForAugmentation)
|
|
89
|
+
return known.symbol;
|
|
90
|
+
}
|
|
91
|
+
const reports = c.reports;
|
|
92
|
+
const symbol = resolveExternalModuleWorker(c, location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation);
|
|
93
|
+
if (shared && c.reports === reports)
|
|
94
|
+
c.moduleResolutions.set(errorNode, new ModuleResolution(moduleReference, moduleNotFoundError, isForAugmentation, symbol));
|
|
95
|
+
return symbol;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Whether a resolution from `location` with errors at `errorNode` depends on `location` only through
|
|
99
|
+
* the declaration that `errorNode` is the module specifier of: `location` is that declaration, a
|
|
100
|
+
* clause or specifier inside it, or the specifier itself. The resolution mode, the emittability of
|
|
101
|
+
* the import and its resolution-mode attributes then all come from that declaration.
|
|
102
|
+
*/
|
|
103
|
+
function sharesSpecifierContext(location, errorNode) {
|
|
104
|
+
const declaration = errorNode.parent;
|
|
105
|
+
if (declaration === undefined ||
|
|
106
|
+
(declaration.kind !== 273 /* SyntaxKind.ImportDeclaration */ &&
|
|
107
|
+
declaration.kind !== 346 /* SyntaxKind.JSImportDeclaration */ &&
|
|
108
|
+
declaration.kind !== 279 /* SyntaxKind.ExportDeclaration */) ||
|
|
109
|
+
getModuleSpecifier(declaration) !== errorNode)
|
|
110
|
+
return false;
|
|
111
|
+
for (let current = location; current !== undefined; current = current.parent)
|
|
112
|
+
switch (current.kind) {
|
|
113
|
+
case 273 /* SyntaxKind.ImportDeclaration */:
|
|
114
|
+
case 346 /* SyntaxKind.JSImportDeclaration */:
|
|
115
|
+
case 279 /* SyntaxKind.ExportDeclaration */:
|
|
116
|
+
return current === declaration;
|
|
117
|
+
case 274 /* SyntaxKind.ImportClause */:
|
|
118
|
+
case 276 /* SyntaxKind.NamedImports */:
|
|
119
|
+
case 275 /* SyntaxKind.NamespaceImport */:
|
|
120
|
+
case 277 /* SyntaxKind.ImportSpecifier */:
|
|
121
|
+
case 280 /* SyntaxKind.NamedExports */:
|
|
122
|
+
case 281 /* SyntaxKind.NamespaceExport */:
|
|
123
|
+
case 282 /* SyntaxKind.ExportSpecifier */:
|
|
124
|
+
break;
|
|
125
|
+
default:
|
|
126
|
+
if (current !== errorNode)
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
function resolveExternalModuleWorker(c, location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) {
|
|
61
132
|
if (errorNode !== undefined && moduleReference.startsWith('@types/'))
|
|
62
133
|
c.error(errorNode, 1302 /* Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1 */, moduleReference.substring(7), moduleReference);
|
|
63
134
|
const ambient = tryFindAmbientModule(c, moduleReference, true);
|
|
@@ -490,13 +561,14 @@ function isOnlyImportableAsDefault(c, usage, resolvedModule) {
|
|
|
490
561
|
const moduleSymbol = resolvedModule ?? resolveExternalModuleName(c, usage, usage, true);
|
|
491
562
|
const targetFile = moduleSymbol !== undefined ? getSourceFileOfModuleSymbol(moduleSymbol) : undefined;
|
|
492
563
|
return (targetFile !== undefined &&
|
|
493
|
-
(isJsonSourceFile(targetFile) ||
|
|
564
|
+
(isJsonSourceFile(targetFile) ||
|
|
565
|
+
(targetFile.fileName.endsWith('.d.json.ts') && getDeclarationFileExtension(targetFile.fileName) === '.d.json.ts')));
|
|
494
566
|
}
|
|
495
567
|
/** The source file that declares a module: its value declaration, or its first declaration that is not an augmentation. */
|
|
496
568
|
function getSourceFileOfModuleSymbol(symbol) {
|
|
497
569
|
let declaration = symbol.valueDeclaration;
|
|
498
570
|
if (declaration === undefined)
|
|
499
|
-
for (const d of symbol
|
|
571
|
+
for (const d of getDeclarations(symbol))
|
|
500
572
|
if (!(isAmbientModule(d) && isModuleAugmentationExternal(d)) && !isGlobalScopeAugmentation(d)) {
|
|
501
573
|
declaration = d;
|
|
502
574
|
break;
|
|
@@ -549,7 +621,7 @@ function createDefaultPropertyWrapperForModule(c, symbol, originalSymbol, anonym
|
|
|
549
621
|
}
|
|
550
622
|
function cloneTypeAsModuleType(c, symbol, moduleType) {
|
|
551
623
|
const result = c.newSymbol(symbol.flags, symbol.name);
|
|
552
|
-
result
|
|
624
|
+
setDeclarations(result, getDeclarations(symbol).slice());
|
|
553
625
|
result.valueDeclaration = symbol.valueDeclaration;
|
|
554
626
|
if (symbol.members !== undefined)
|
|
555
627
|
result.members = new Map(symbol.members);
|
|
@@ -563,7 +635,7 @@ function cloneTypeAsModuleType(c, symbol, moduleType) {
|
|
|
563
635
|
function getSourceFileDeclaration(symbol) {
|
|
564
636
|
if (symbol === undefined)
|
|
565
637
|
return undefined;
|
|
566
|
-
for (const d of symbol
|
|
638
|
+
for (const d of getDeclarations(symbol))
|
|
567
639
|
if (d.kind === 307 /* SyntaxKind.SourceFile */)
|
|
568
640
|
return d;
|
|
569
641
|
return undefined;
|
|
@@ -605,7 +677,7 @@ function canHaveSyntheticDefault(c, file, moduleSymbol, dontResolveAlias, usage)
|
|
|
605
677
|
resolveExportByName(c, moduleSymbol, '__esModule', undefined, dontResolveAlias) === undefined);
|
|
606
678
|
}
|
|
607
679
|
function hasSyntacticDefault(symbol) {
|
|
608
|
-
for (const d of symbol
|
|
680
|
+
for (const d of getDeclarations(symbol))
|
|
609
681
|
if (isSyntacticDefault(d))
|
|
610
682
|
return true;
|
|
611
683
|
return false;
|
|
@@ -780,7 +852,7 @@ function reportNonDefaultExport(c, moduleSymbol, node) {
|
|
|
780
852
|
const exportStar = moduleSymbol.exports?.get("\uFFFEexport" /* InternalSymbolName.ExportStar */);
|
|
781
853
|
if (exportStar === undefined)
|
|
782
854
|
return;
|
|
783
|
-
for (const d of exportStar
|
|
855
|
+
for (const d of getDeclarations(exportStar)) {
|
|
784
856
|
const specifier = getModuleSpecifier(d);
|
|
785
857
|
if (d.kind !== 279 /* SyntaxKind.ExportDeclaration */ || specifier === undefined)
|
|
786
858
|
continue;
|
|
@@ -896,11 +968,11 @@ function combineValueAndTypeSymbols(c, valueSymbol, typeSymbol) {
|
|
|
896
968
|
if ((valueSymbol.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */)) !== 0)
|
|
897
969
|
return valueSymbol;
|
|
898
970
|
const result = c.newSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.name);
|
|
899
|
-
const declarations = valueSymbol.
|
|
900
|
-
for (const d of typeSymbol
|
|
971
|
+
const declarations = getDeclarations(valueSymbol).slice();
|
|
972
|
+
for (const d of getDeclarations(typeSymbol))
|
|
901
973
|
if (!declarations.includes(d))
|
|
902
974
|
declarations.push(d);
|
|
903
|
-
result
|
|
975
|
+
setDeclarations(result, declarations);
|
|
904
976
|
result.parent = valueSymbol.parent ?? typeSymbol.parent;
|
|
905
977
|
result.valueDeclaration = valueSymbol.valueDeclaration;
|
|
906
978
|
if (typeSymbol.members !== undefined)
|
|
@@ -963,8 +1035,8 @@ function reportNonExportedMember(c, name, declarationName, moduleSymbol, moduleN
|
|
|
963
1035
|
const diagnostic = exportedSymbol !== undefined
|
|
964
1036
|
? c.error(name, 626 /* Diagnostics.Module_0_declares_1_locally_but_it_is_exported_as_2 */, moduleName, declarationName, symbolToString(c, exportedSymbol))
|
|
965
1037
|
: c.error(name, 625 /* Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported */, moduleName, declarationName);
|
|
966
|
-
for (let i = 0; i < localSymbol
|
|
967
|
-
diagnostic.addRelatedInfo(createDiagnosticForNode(localSymbol
|
|
1038
|
+
for (let i = 0; i < declarationCount(localSymbol); i++)
|
|
1039
|
+
diagnostic.addRelatedInfo(createDiagnosticForNode(declarationAt(localSymbol, i), i === 0 ? 860 /* Diagnostics.X_0_is_declared_here */ : 1357 /* Diagnostics.X_and_here */, [declarationName]));
|
|
968
1040
|
}
|
|
969
1041
|
function isSameReference(c, s1, s2) {
|
|
970
1042
|
return (getMergedSymbol(c, resolveSymbol(c, getMergedSymbol(c, s1))) ===
|
|
@@ -1436,7 +1508,7 @@ class ExportCollector {
|
|
|
1436
1508
|
if (exportStars !== undefined) {
|
|
1437
1509
|
const nested = new Map();
|
|
1438
1510
|
const lookupTable = new Map();
|
|
1439
|
-
for (const node of exportStars
|
|
1511
|
+
for (const node of getDeclarations(exportStars)) {
|
|
1440
1512
|
const specifier = node.moduleSpecifier;
|
|
1441
1513
|
const resolved = resolveExternalModuleName(this.c, node, specifier, false);
|
|
1442
1514
|
const exported = this.visit(resolved, node, isTypeOnly || getIsTypeOnly(node));
|
|
@@ -1890,7 +1962,7 @@ function checkExportSpecifier(c, node) {
|
|
|
1890
1962
|
if (symbol !== undefined &&
|
|
1891
1963
|
(symbol === c.undefinedSymbol ||
|
|
1892
1964
|
symbol === c.globalThisSymbol ||
|
|
1893
|
-
(symbol
|
|
1965
|
+
(declarationCount(symbol) > 0 && isGlobalSourceFile(getDeclarationContainer(symbol.declaration)))))
|
|
1894
1966
|
c.error(exportedName, 795 /* Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module */, getText(exportedName));
|
|
1895
1967
|
else
|
|
1896
1968
|
markExportSpecifierAliasReferenced(c, node, symbol, exportedName);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Node, type PropertyAssignment, type ShorthandPropertyAssignment } from './ast.js';
|
|
2
2
|
import { type Checker } from './checker.js';
|
|
3
|
-
import { type Symbol } from './symbol.js';
|
|
4
3
|
import { CheckMode, ObjectFlags, type Type } from './checker-types.js';
|
|
4
|
+
import { type Symbol } from './symbol.js';
|
|
5
5
|
export declare function checkObjectLiteral(c: Checker, node: Node, checkMode: CheckMode): Type;
|
|
6
6
|
export declare function checkPropertyAssignment(c: Checker, node: PropertyAssignment, checkMode: CheckMode): Type;
|
|
7
7
|
export declare function checkShorthandPropertyAssignment(c: Checker, node: ShorthandPropertyAssignment, inDestructuringPattern: boolean, checkMode: CheckMode): Type;
|
|
@@ -3,10 +3,9 @@ import { checkGrammarObjectLiteralOfExpression } from './checker-grammar.js';
|
|
|
3
3
|
import { getExpression, getName, getProperties, getSymbol, getText, getType, } from './ast.js';
|
|
4
4
|
import { isAssignmentTarget } from './binder-utilities.js';
|
|
5
5
|
import { createDiagnosticForNode } from './checker.js';
|
|
6
|
-
import { internalSymbolNamePrefix, getSymbolId } from './symbol.js';
|
|
7
6
|
import { emptyIndexInfos, emptySignatures, IndexInfo, } from './checker-types.js';
|
|
8
7
|
import { checkCrossProductUnion, createAnonymousType, getIntersectionType, getUnionType, getUnionTypeEx, isErrorType, mapType, typesOf, } from './checker-type-factory.js';
|
|
9
|
-
import { getDeclarationModifierFlagsFromSymbol, getIndexInfoOfType, getIndexInfosOfType, getIndexTypeOfType, getPropertiesOfType, getPropertyOfType, getReducedType, } from './checker-members.js';
|
|
8
|
+
import { getDeclarationModifierFlagsFromSymbol, getIndexInfoOfType, getIndexInfosOfType, getIndexTypeOfType, getPropertiesOfType, getPropertyOfType, getReducedType, keepPropertiesOnly, scannedLiteralPropertiesLimit, } from './checker-members.js';
|
|
10
9
|
import { symbolToString, typeToString } from './type-printer.js';
|
|
11
10
|
import { getMergedSymbol, getSymbolOfDeclaration } from './checker-symbols.js';
|
|
12
11
|
import { addOptionality, getTypeOfSymbol, removeMissingOrUndefinedType } from './checker-symbol-types.js';
|
|
@@ -21,6 +20,7 @@ import { getApparentTypeOfContextualType, getInferenceContext, popContextualType
|
|
|
21
20
|
import { addIntraExpressionInferenceSite } from './checker-inference.js';
|
|
22
21
|
import { isEmptyObjectType } from './checker-type-factory.js';
|
|
23
22
|
import { getTypeOfExpandoObjectLiteral, isJSObjectLiteral } from './checker-javascript.js';
|
|
23
|
+
import { copyDeclarations, declarationCount, getDeclarations, getSymbolId, internalSymbolNamePrefix, setDeclarations, } from './symbol.js';
|
|
24
24
|
/** Builds the type of the members collected since the last spread. */
|
|
25
25
|
class ObjectLiteralBuilder {
|
|
26
26
|
node;
|
|
@@ -63,6 +63,8 @@ class ObjectLiteralBuilder {
|
|
|
63
63
|
result.objectFlags |= 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */;
|
|
64
64
|
if (this.inDestructuringPattern)
|
|
65
65
|
c.patternForType.set(result, this.node);
|
|
66
|
+
// A literal of a few properties keeps them as a list; a lookup by name compares their names.
|
|
67
|
+
keepPropertiesOnly(c, result, this.members, scannedLiteralPropertiesLimit);
|
|
66
68
|
return result;
|
|
67
69
|
}
|
|
68
70
|
reset() {
|
|
@@ -147,7 +149,7 @@ export function checkObjectLiteral(c, node, checkMode) {
|
|
|
147
149
|
else if (getIndexInfoOfType(c, contextualType, c.stringType) === undefined)
|
|
148
150
|
c.error(getName(memberDecl), 529 /* Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1 */, symbolToString(c, member), typeToString(c, contextualType));
|
|
149
151
|
}
|
|
150
|
-
prop
|
|
152
|
+
copyDeclarations(prop, member);
|
|
151
153
|
prop.parent = member.parent;
|
|
152
154
|
prop.valueDeclaration = member.valueDeclaration;
|
|
153
155
|
c.symbolTypes.set(id, t);
|
|
@@ -243,7 +245,7 @@ function getObjectLiteralIndexInfo(c, isReadonly, properties, keyType) {
|
|
|
243
245
|
(keyType === c.esSymbolType && isSymbolWithSymbolName(c, prop))) {
|
|
244
246
|
propTypes.push(getTypeOfSymbol(c, prop));
|
|
245
247
|
if (isSymbolWithComputedName(prop))
|
|
246
|
-
components.push(prop.
|
|
248
|
+
components.push(prop.declaration);
|
|
247
249
|
}
|
|
248
250
|
}
|
|
249
251
|
const unionType = propTypes.length !== 0
|
|
@@ -252,7 +254,7 @@ function getObjectLiteralIndexInfo(c, isReadonly, properties, keyType) {
|
|
|
252
254
|
return new IndexInfo(keyType, unionType, isReadonly, undefined, components);
|
|
253
255
|
}
|
|
254
256
|
function getFirstDeclarationName(symbol) {
|
|
255
|
-
return symbol
|
|
257
|
+
return declarationCount(symbol) !== 0 ? getName(symbol.declaration) : undefined;
|
|
256
258
|
}
|
|
257
259
|
function isSymbolWithSymbolName(c, symbol) {
|
|
258
260
|
if (symbol.name.startsWith(internalSymbolNamePrefix + '@'))
|
|
@@ -381,7 +383,7 @@ export function getSpreadType(c, leftIn, rightIn, symbol, objectFlags, readonly)
|
|
|
381
383
|
: getUnionTypeEx(c, [leftType, rightTypeWithoutUndefined], 2 /* UnionReduction.Subtype */, undefined, undefined));
|
|
382
384
|
c.symbolLeftSpreads.set(id, leftProp);
|
|
383
385
|
c.symbolRightSpreads.set(id, rightProp);
|
|
384
|
-
result
|
|
386
|
+
setDeclarations(result, getDeclarations(leftProp).concat(getDeclarations(rightProp)));
|
|
385
387
|
c.symbolNameTypes.set(id, c.symbolNameTypes.get(getSymbolId(leftProp)));
|
|
386
388
|
members.set(leftProp.name, result);
|
|
387
389
|
}
|
|
@@ -391,6 +393,7 @@ export function getSpreadType(c, leftIn, rightIn, symbol, objectFlags, readonly)
|
|
|
391
393
|
const spread = createAnonymousType(c, symbol, members, [], [], spreadIndexInfos);
|
|
392
394
|
spread.objectFlags |=
|
|
393
395
|
128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */ | 4194304 /* ObjectFlags.ContainsSpread */ | objectFlags;
|
|
396
|
+
keepPropertiesOnly(c, spread, members, scannedLiteralPropertiesLimit);
|
|
394
397
|
return spread;
|
|
395
398
|
}
|
|
396
399
|
function getIndexInfoWithReadonly(info, readonly) {
|
|
@@ -468,12 +471,13 @@ function tryMergeUnionOfObjectTypeAndEmptyObject(c, t, readonly) {
|
|
|
468
471
|
const result = c.newSymbolWithCheckFlags(4 /* SymbolFlags.Property */ | 16777216 /* SymbolFlags.Optional */, prop.name, (prop.checkFlags & 4096 /* CheckFlags.Late */) | (readonly ? 8 /* CheckFlags.Readonly */ : 0));
|
|
469
472
|
const id = getSymbolId(result);
|
|
470
473
|
c.symbolTypes.set(id, isSetonlyAccessor ? c.undefinedType : addOptionality(c, getTypeOfSymbol(c, prop), true, true));
|
|
471
|
-
result
|
|
474
|
+
copyDeclarations(result, prop);
|
|
472
475
|
c.symbolNameTypes.set(id, c.symbolNameTypes.get(getSymbolId(prop)));
|
|
473
476
|
c.symbolSyntheticOrigins.set(id, prop);
|
|
474
477
|
members.set(prop.name, result);
|
|
475
478
|
}
|
|
476
479
|
const spread = createAnonymousType(c, firstType.symbol, members, [], [], getIndexInfosOfType(c, firstType));
|
|
477
480
|
spread.objectFlags |= 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */;
|
|
481
|
+
keepPropertiesOnly(c, spread, members, scannedLiteralPropertiesLimit);
|
|
478
482
|
return spread;
|
|
479
483
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Node } from './ast.js';
|
|
2
|
-
import { type Symbol } from './symbol.js';
|
|
3
2
|
import { type Checker } from './checker.js';
|
|
3
|
+
import { type Symbol } from './symbol.js';
|
|
4
4
|
/** Checks the overloads of a function or method declaration's local and export symbols. */
|
|
5
5
|
export declare function checkFunctionOrMethodSymbols(c: Checker, node: Node): void;
|
|
6
6
|
/** Checks a function, method or constructor symbol's overloads and implementations, once. */
|
|
@@ -11,6 +11,7 @@ import { checkComputedPropertyName } from './checker-expressions.js';
|
|
|
11
11
|
import { hasDynamicName, hasLateBindableName } from './checker-utilities.js';
|
|
12
12
|
import { isSignatureAssignableTo, isTypeIdenticalTo, isTypeRelatedTo } from './relations.js';
|
|
13
13
|
import { getEffectiveDeclarationFlags } from './checker-declarations.js';
|
|
14
|
+
import { getDeclarations } from './symbol.js';
|
|
14
15
|
/** Checks the overloads of a function or method declaration's local and export symbols. */
|
|
15
16
|
export function checkFunctionOrMethodSymbols(c, node) {
|
|
16
17
|
if (hasDynamicName(node) && !hasLateBindableName(c, node))
|
|
@@ -52,7 +53,7 @@ class OverloadChecker {
|
|
|
52
53
|
}
|
|
53
54
|
check() {
|
|
54
55
|
const c = this.c;
|
|
55
|
-
const declarations = this.symbol
|
|
56
|
+
const declarations = getDeclarations(this.symbol);
|
|
56
57
|
let someNodeFlags = 0 /* ModifierFlags.None */;
|
|
57
58
|
let allNodeFlags = flagsToCheck();
|
|
58
59
|
let someHaveQuestionToken = false;
|
|
@@ -149,10 +150,10 @@ class OverloadChecker {
|
|
|
149
150
|
reportClassMergedWithFunction() {
|
|
150
151
|
const c = this.c;
|
|
151
152
|
const classes = [];
|
|
152
|
-
for (const d of this.symbol
|
|
153
|
+
for (const d of getDeclarations(this.symbol))
|
|
153
154
|
if (d.kind === 264 /* SyntaxKind.ClassDeclaration */)
|
|
154
155
|
classes.push(d);
|
|
155
|
-
for (const d of this.symbol
|
|
156
|
+
for (const d of getDeclarations(this.symbol)) {
|
|
156
157
|
let message;
|
|
157
158
|
if (d.kind === 264 /* SyntaxKind.ClassDeclaration */)
|
|
158
159
|
message = 944 /* Diagnostics.Class_declaration_cannot_implement_overload_list_for_0 */;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type Node } from './ast.js';
|
|
2
2
|
import { type Checker } from './checker.js';
|
|
3
3
|
import { type Diagnostic } from './diagnostics.js';
|
|
4
|
-
import { type Symbol } from './symbol.js';
|
|
5
4
|
import { CheckMode, type Type } from './checker-types.js';
|
|
6
5
|
import { AssignmentKind } from './checker-narrowing.js';
|
|
6
|
+
import { type Symbol } from './symbol.js';
|
|
7
7
|
export declare function checkPropertyAccessExpressionOrQualifiedName(c: Checker, node: Node, left: Node, leftType: Type, right: Node, writeOnly: boolean, checkMode?: CheckMode): Type;
|
|
8
8
|
/** A private name used as an expression, as in `#x in obj`; records its declaration. */
|
|
9
9
|
export declare function checkPrivateIdentifierExpression(c: Checker, node: Node): Type;
|
|
@@ -6,7 +6,6 @@ import { getBody, getExpression, getName, getParameters, getSymbol, getText, get
|
|
|
6
6
|
import { declarationNameToString, getContainingClass, getSourceFileOfNode, getThisContainer, isAccessExpression, hasSyntacticModifier, isClassLike, isOptionalChain, isPrivateIdentifierClassElementDeclaration, isStatic, skipParentheses, getElementOrPropertyAccessName, isBindableStaticAccessExpression, isBindableStaticNameExpression, } from './binder-utilities.js';
|
|
7
7
|
import { isFunctionLike, isInJSFile } from './ast-utilities.js';
|
|
8
8
|
import { createDiagnosticForNode } from './checker.js';
|
|
9
|
-
import { getSymbolId } from './symbol.js';
|
|
10
9
|
import { everyContainedType, getTargetType, getUnionType, isEmptyObjectType, isErrorType, typesOf, } from './checker-type-factory.js';
|
|
11
10
|
import { getApparentType, getApplicableIndexInfoForName, getDeclarationModifierFlagsFromSymbol, getPropertiesOfType, getPropertiesOfUnionOrIntersectionType, getPropertyOfType, getPropertyOfTypeEx, isConflictingPrivateProperty, isDiscriminantWithNeverType, } from './checker-members.js';
|
|
12
11
|
import { getDeclarationOfAliasSymbol, getParentOfSymbol, getSpellingSuggestionForName, getSymbolOfDeclaration, } from './checker-symbols.js';
|
|
@@ -29,6 +28,7 @@ import { checkDeprecatedIndexSignature, checkDeprecatedProperty } from './checke
|
|
|
29
28
|
import { isSelfTypeAccess, markPropertyAsReferenced } from './checker-unused.js';
|
|
30
29
|
import { getContextualThisParameterType, getFlowTypeOfAccessExpression, getResolvedSymbol, } from './checker-expressions.js';
|
|
31
30
|
import { isJSLiteralType, isThisPropertyAccessInConstructor } from './checker-javascript.js';
|
|
31
|
+
import { getDeclarations, getSymbolId } from './symbol.js';
|
|
32
32
|
export function checkPropertyAccessExpressionOrQualifiedName(c, node, left, leftType, right, writeOnly, checkMode = 0 /* CheckMode.Normal */) {
|
|
33
33
|
const parentSymbol = c.resolvedSymbols.get(left.id);
|
|
34
34
|
const assignmentKind = getAssignmentTargetKind(node);
|
|
@@ -409,7 +409,7 @@ function checkPropertyAccessibilityAtLocation(c, location, isSuper, writing, con
|
|
|
409
409
|
return true;
|
|
410
410
|
}
|
|
411
411
|
function hasClassInstancePropertyDeclaration(symbol) {
|
|
412
|
-
for (const d of symbol
|
|
412
|
+
for (const d of getDeclarations(symbol))
|
|
413
413
|
if (isClassInstanceProperty(d))
|
|
414
414
|
return true;
|
|
415
415
|
return false;
|
|
@@ -20,7 +20,7 @@ import { createAnonymousType, getRegularTypeOfLiteralType, isErrorType } from '.
|
|
|
20
20
|
import { getLiteralTypeFromPropertyName } from './checker-type-operators.js';
|
|
21
21
|
import { getTypeFromThisTypeNode, getTypeFromTypeNode, getUnresolvedSymbolForEntityName, } from './checker-type-nodes.js';
|
|
22
22
|
import { getNodeAtPosition } from './parser.js';
|
|
23
|
-
import { getSymbolId } from './symbol.js';
|
|
23
|
+
import { getSymbolId, setDeclarations } from './symbol.js';
|
|
24
24
|
// ---- Symbols at locations
|
|
25
25
|
/** The symbol a name, keyword or literal at `node` refers to. */
|
|
26
26
|
export function getSymbolAtLocation(c, node) {
|
|
@@ -295,7 +295,7 @@ function getApplicableIndexSymbol(c, t, keyType) {
|
|
|
295
295
|
declarations.push(other.declaration);
|
|
296
296
|
if (declarations.length !== 0) {
|
|
297
297
|
const symbol = c.newSymbolWithCheckFlags(4 /* SymbolFlags.Property */, "\uFFFEindex" /* InternalSymbolName.Index */, 8388608 /* CheckFlags.IndexSymbol */);
|
|
298
|
-
symbol
|
|
298
|
+
setDeclarations(symbol, declarations);
|
|
299
299
|
symbol.valueDeclaration = declarations[0];
|
|
300
300
|
symbol.parent = t.symbol;
|
|
301
301
|
c.symbolTypes.set(getSymbolId(symbol), info.valueType);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type Node } from './ast.js';
|
|
2
|
-
import { InternalSymbolName, type Symbol } from './symbol.js';
|
|
3
2
|
import type { Checker } from './checker.js';
|
|
4
3
|
import { ElementFlags, IndexInfo, type InterfaceType, Signature, SignatureKind, type Type, type TypeMapper, TypePredicate, type TypeReference } from './checker-types.js';
|
|
5
4
|
import { getSymbolOfDeclaration } from './checker-symbols.js';
|
|
@@ -7,6 +6,7 @@ import { getClassLikeDeclarationOfSymbol, getConstraintOfTypeParameter } from '.
|
|
|
7
6
|
import { instantiateTypes } from './instantiation.js';
|
|
8
7
|
import { getIndexInfosOfType } from './checker-members.js';
|
|
9
8
|
import { type TypeComparer } from './relations.js';
|
|
9
|
+
import { InternalSymbolName, type Symbol } from './symbol.js';
|
|
10
10
|
/** Signatures of a symbol's function-like declarations, skipping overload implementations. */
|
|
11
11
|
export declare function getSignaturesOfSymbol(c: Checker, symbol: Symbol | undefined): Signature[];
|
|
12
12
|
export declare function isFunctionLikeNode(node: Node): boolean;
|
|
@@ -18,13 +18,14 @@ import { isTypeAssignableTo } from './relations.js';
|
|
|
18
18
|
import { getReturnTypeFromBody, getTypePredicateFromBody } from './checker-functions.js';
|
|
19
19
|
import { checkComputedPropertyName } from './checker-expressions.js';
|
|
20
20
|
import { hasLateBindableIndexSignature } from './checker-utilities.js';
|
|
21
|
+
import { declarationCount, getDeclarations } from './symbol.js';
|
|
21
22
|
// ---- From declarations
|
|
22
23
|
/** Signatures of a symbol's function-like declarations, skipping overload implementations. */
|
|
23
24
|
export function getSignaturesOfSymbol(c, symbol) {
|
|
24
25
|
if (symbol === undefined)
|
|
25
26
|
return [];
|
|
26
27
|
const result = [];
|
|
27
|
-
const declarations = symbol
|
|
28
|
+
const declarations = getDeclarations(symbol);
|
|
28
29
|
for (let i = 0; i < declarations.length; i++) {
|
|
29
30
|
const decl = declarations[i];
|
|
30
31
|
if (!isFunctionLikeNode(decl))
|
|
@@ -236,7 +237,7 @@ export function getReturnTypeFromAnnotation(c, declaration) {
|
|
|
236
237
|
if (declaration.kind === 178 /* SyntaxKind.GetAccessor */) {
|
|
237
238
|
const symbol = getSymbolOfDeclaration(c, declaration);
|
|
238
239
|
if (symbol !== undefined) {
|
|
239
|
-
const setter = symbol.
|
|
240
|
+
const setter = getDeclarations(symbol).find((d) => d.kind === 179 /* SyntaxKind.SetAccessor */);
|
|
240
241
|
if (setter !== undefined) {
|
|
241
242
|
const parameters = getParameters(setter);
|
|
242
243
|
if (parameters !== undefined) {
|
|
@@ -655,7 +656,7 @@ export function getIndexInfosOfIndexSymbol(c, indexSymbol, siblingSymbols) {
|
|
|
655
656
|
let readonlyNumber = true;
|
|
656
657
|
let readonlySymbol = true;
|
|
657
658
|
const propertySymbols = [];
|
|
658
|
-
for (const declaration of indexSymbol
|
|
659
|
+
for (const declaration of getDeclarations(indexSymbol)) {
|
|
659
660
|
if (declaration.kind === 182 /* SyntaxKind.IndexSignature */) {
|
|
660
661
|
const parameters = getParameters(declaration)?.nodes ?? [];
|
|
661
662
|
const returnTypeNode = getType(declaration);
|
|
@@ -722,7 +723,7 @@ import { getContextualTypeEx } from './checker-contextual.js';
|
|
|
722
723
|
function isSymbolWithSymbolName(c, symbol) {
|
|
723
724
|
if (symbol.name.startsWith('\ufffe@'))
|
|
724
725
|
return true;
|
|
725
|
-
const name = symbol
|
|
726
|
+
const name = declarationCount(symbol) !== 0 ? getName(symbol.declaration) : undefined;
|
|
726
727
|
return (name !== undefined &&
|
|
727
728
|
name.kind === 168 /* SyntaxKind.ComputedPropertyName */ &&
|
|
728
729
|
isTypeAssignableToKind(c, checkComputedPropertyName(c, name), 512 /* TypeFlags.ESSymbol */));
|
|
@@ -731,7 +732,7 @@ function isSymbolWithSymbolName(c, symbol) {
|
|
|
731
732
|
function isSymbolWithNumericName(c, symbol) {
|
|
732
733
|
if (isNumericLiteralName(symbol.name))
|
|
733
734
|
return true;
|
|
734
|
-
const name = symbol
|
|
735
|
+
const name = declarationCount(symbol) !== 0 ? getName(symbol.declaration) : undefined;
|
|
735
736
|
if (name === undefined)
|
|
736
737
|
return false;
|
|
737
738
|
if (name.kind === 168 /* SyntaxKind.ComputedPropertyName */)
|
|
@@ -750,7 +751,7 @@ function getObjectLiteralIndexInfo(c, isReadonly, properties, keyType) {
|
|
|
750
751
|
(keyType === c.esSymbolType && isSymbolWithSymbolName(c, prop))) {
|
|
751
752
|
propTypes.push(getTypeOfSymbol(c, prop));
|
|
752
753
|
if (isSymbolWithComputedName(prop))
|
|
753
|
-
components.push(prop.
|
|
754
|
+
components.push(prop.declaration);
|
|
754
755
|
}
|
|
755
756
|
}
|
|
756
757
|
const unionType = propTypes.length !== 0
|
|
@@ -759,9 +760,9 @@ function getObjectLiteralIndexInfo(c, isReadonly, properties, keyType) {
|
|
|
759
760
|
return new IndexInfo(keyType, unionType, isReadonly, undefined, components);
|
|
760
761
|
}
|
|
761
762
|
function isSymbolWithComputedName(symbol) {
|
|
762
|
-
if (symbol
|
|
763
|
+
if (declarationCount(symbol) === 0)
|
|
763
764
|
return false;
|
|
764
|
-
const name = getName(symbol.
|
|
765
|
+
const name = getName(symbol.declaration);
|
|
765
766
|
return name !== undefined && name.kind === 168 /* SyntaxKind.ComputedPropertyName */;
|
|
766
767
|
}
|
|
767
768
|
export { getIndexInfosOfType, instantiateTypes, getConstraintOfTypeParameter, getClassLikeDeclarationOfSymbol, getSymbolOfDeclaration, };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { CheckMode } from './checker-types.js';
|
|
2
|
-
import { type Node
|
|
2
|
+
import { type Node } from './ast.js';
|
|
3
3
|
import { hasStaticModifier } from './binder-utilities.js';
|
|
4
|
-
import { type Symbol } from './symbol.js';
|
|
5
4
|
import { type Checker } from './checker.js';
|
|
6
5
|
import { type Type, TypeFlags, type UnionType } from './checker-types.js';
|
|
7
6
|
import { filterType } from './checker-type-factory.js';
|
|
8
7
|
import { getDeclarationOfAliasSymbol } from './checker-symbols.js';
|
|
8
|
+
import { type Symbol } from './symbol.js';
|
|
9
9
|
export declare function getTypeOfSymbol(c: Checker, symbol: Symbol): Type;
|
|
10
10
|
export declare function getTypeOfParameter(c: Checker, symbol: Symbol): Type;
|
|
11
11
|
export declare function getNonMissingTypeOfSymbol(c: Checker, symbol: Symbol): Type;
|
|
@@ -34,22 +34,6 @@ export declare const enum WideningKind {
|
|
|
34
34
|
export declare function reportErrorsFromWidening(c: Checker, declaration: Node, t: Type, wideningKind: WideningKind): void;
|
|
35
35
|
export declare function reportImplicitAny(c: Checker, declaration: Node, t: Type, wideningKind?: WideningKind): void;
|
|
36
36
|
export declare function getWidenedType(c: Checker, t: Type): Type;
|
|
37
|
-
/**
|
|
38
|
-
* By name, the first property of the unions of `file`'s object literals that leave the name missing.
|
|
39
|
-
* Without a checker, as on a parse thread, array literals are taken to have the global Array type, and
|
|
40
|
-
* the result is undefined where an enum the scan can't resolve decides which literals subtype reduction
|
|
41
|
-
* leaves out (`enumKeyOfMemberAccess`); the checker then scans the file itself.
|
|
42
|
-
*/
|
|
43
|
-
export declare function scanSiblingProperties(file: SourceFile, c: Checker | undefined): Map<string, Node> | undefined;
|
|
44
|
-
/** The first property of each name among the files of one of tsgo's checkers, scanned in order. */
|
|
45
|
-
export declare class SlotSiblingProperties {
|
|
46
|
-
readonly members: Map<string, Node>;
|
|
47
|
-
/** The index of the file of each name's property. */
|
|
48
|
-
readonly fileIndexes: Map<string, number>;
|
|
49
|
-
/** The index of the next file of the checker to scan. */
|
|
50
|
-
next: number;
|
|
51
|
-
constructor(first: number);
|
|
52
|
-
}
|
|
53
37
|
export declare function addOptionality(c: Checker, t: Type, isProperty: boolean, isOptional: boolean): Type;
|
|
54
38
|
export declare function getOptionalType(c: Checker, t: Type, isProperty: boolean): Type;
|
|
55
39
|
export declare function addOptionalTypeMarker(c: Checker, t: Type): Type;
|