tsc-ts 0.0.5 → 0.0.6
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 +10 -9
- package/dist/api/compiler/ast.js +22 -16
- package/dist/api/compiler/binder-utilities.js +2 -1
- package/dist/api/compiler/binder.js +9 -8
- package/dist/api/compiler/checker-calls.js +3 -2
- 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-resolver.d.ts +1 -1
- package/dist/api/compiler/checker-emit-resolver.js +5 -4
- package/dist/api/compiler/checker-grammar.js +18 -4
- 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 +1 -1
- package/dist/api/compiler/checker-inference.js +9 -9
- 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 +5 -3
- package/dist/api/compiler/checker-members.js +75 -53
- package/dist/api/compiler/checker-modules.d.ts +1 -1
- package/dist/api/compiler/checker-modules.js +13 -13
- 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 +29 -8
- package/dist/api/compiler/checker.js +29 -9
- package/dist/api/compiler/diagnostics.d.ts +2 -8
- package/dist/api/compiler/diagnostics.js +4 -40
- 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 +4 -0
- package/dist/api/compiler/parser.d.ts +33 -16
- package/dist/api/compiler/parser.js +95 -76
- 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/program-checker.js +3 -0
- package/dist/api/compiler/program.js +9 -1
- package/dist/api/compiler/relations.d.ts +1 -1
- package/dist/api/compiler/relations.js +10 -10
- 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/declarations-diagnostics.js +2 -1
- package/dist/api/compiler/transformers/declarations-pseudo.js +4 -2
- 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/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 +7 -5
- 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/type-serialization.js +12 -12
- package/package.json +9 -9
- package/src/compiler/ast.ts +27 -19
- package/src/compiler/binder-utilities.ts +2 -2
- package/src/compiler/binder.ts +15 -11
- package/src/compiler/checker-calls.ts +3 -3
- 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-resolver.ts +5 -5
- package/src/compiler/checker-grammar.ts +17 -5
- package/src/compiler/checker-heritage.ts +21 -14
- package/src/compiler/checker-inference.ts +17 -9
- 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 +91 -47
- package/src/compiler/checker-modules.ts +23 -13
- 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 +31 -9
- package/src/compiler/diagnostics.ts +5 -44
- 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 +5 -0
- package/src/compiler/parse-thread.ts +0 -4
- package/src/compiler/parser.ts +120 -70
- package/src/compiler/printer/emit-context.ts +20 -15
- package/src/compiler/program-checker.ts +2 -0
- package/src/compiler/program.ts +8 -1
- package/src/compiler/relations.ts +10 -10
- 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/declarations-diagnostics.ts +2 -1
- package/src/compiler/transformers/declarations-pseudo.ts +7 -4
- package/src/compiler/transformers/declarations-syntactic.ts +17 -9
- package/src/compiler/transformers/declarations-tracker.ts +3 -3
- package/src/compiler/transformers/declarations.ts +6 -6
- package/src/compiler/transformers/reference-resolver.ts +37 -25
- package/src/compiler/transformers/subtree-facts.ts +13 -5
- package/src/compiler/transformers/syntax-facts.ts +10 -5
- package/src/compiler/transformers/type-serialization.ts +12 -12
- 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
|
@@ -4,7 +4,6 @@ import type { Node } from './ast.js';
|
|
|
4
4
|
import { getCombinedModifierFlags, getDeclarationOfKind } from './binder-utilities.js';
|
|
5
5
|
import { Diagnostics } from './diagnostics.js';
|
|
6
6
|
import { ModifierFlags, getSymbol, MappedTypeNode, getName } from './ast.js';
|
|
7
|
-
import { CheckFlags, InternalSymbolName, type Symbol, SymbolFlags, type SymbolTable, getSymbolId } from './symbol.js';
|
|
8
7
|
import { SyntaxKind } from './syntax-kind.js';
|
|
9
8
|
import type { Checker } from './checker.js';
|
|
10
9
|
import {
|
|
@@ -34,11 +33,13 @@ import {
|
|
|
34
33
|
type TypeParameter,
|
|
35
34
|
type TypeReference,
|
|
36
35
|
type UnionOrIntersectionType,
|
|
36
|
+
unionOrIntersectionMembers,
|
|
37
37
|
type UnionType,
|
|
38
38
|
emptyIndexInfos,
|
|
39
39
|
emptySignatures,
|
|
40
40
|
emptySymbols,
|
|
41
41
|
emptyTypes,
|
|
42
|
+
newThisArgumentTypeMapper,
|
|
42
43
|
newTypeMapper,
|
|
43
44
|
prependTypeMapping,
|
|
44
45
|
LiteralType,
|
|
@@ -151,7 +152,19 @@ import {
|
|
|
151
152
|
} from './checker-type-operators.js';
|
|
152
153
|
import { getGlobalBigIntType, getGlobalESSymbolType } from './checker-globals.js';
|
|
153
154
|
import { isLateBoundName, isNumericLiteralName } from './checker-utilities.js';
|
|
154
|
-
import { lazyObjectFlags, sideOf } from './side-state.js';
|
|
155
|
+
import { lazyObjectFlags, sideOf, sideOfIfAny } from './side-state.js';
|
|
156
|
+
import {
|
|
157
|
+
CheckFlags,
|
|
158
|
+
copyDeclarations,
|
|
159
|
+
declarationCount,
|
|
160
|
+
getDeclarations,
|
|
161
|
+
getSymbolId,
|
|
162
|
+
InternalSymbolName,
|
|
163
|
+
setDeclarations,
|
|
164
|
+
type Symbol,
|
|
165
|
+
SymbolFlags,
|
|
166
|
+
type SymbolTable,
|
|
167
|
+
} from './symbol.js';
|
|
155
168
|
|
|
156
169
|
// ---- Resolution
|
|
157
170
|
|
|
@@ -172,12 +185,18 @@ export function resolveStructuredTypeMembers(c: Checker, t: Type): StructuredTyp
|
|
|
172
185
|
* `t` writes them there; `t` keeps its identity and is never written.
|
|
173
186
|
*/
|
|
174
187
|
export function membersHolder(c: Checker, t: Type): StructuredType {
|
|
175
|
-
|
|
188
|
+
const side = sideOf(c, t);
|
|
189
|
+
if ((side.flags & TypeFlags.UnionOrIntersection) !== 0)
|
|
190
|
+
return unionOrIntersectionMembers(side as UnionOrIntersectionType);
|
|
191
|
+
return side as StructuredType;
|
|
176
192
|
}
|
|
177
193
|
|
|
178
194
|
/** The `objectFlags` of `t` that resolving its members sets (MembersResolved, UnresolvedMembers). */
|
|
179
195
|
export function memberResolutionFlags(c: Checker, t: Type): ObjectFlags {
|
|
180
|
-
return lazyObjectFlags(c, t);
|
|
196
|
+
if ((t.flags & TypeFlags.UnionOrIntersection) === 0) return lazyObjectFlags(c, t);
|
|
197
|
+
const side = sideOfIfAny(c, t) as UnionOrIntersectionType | undefined;
|
|
198
|
+
const members = side !== undefined ? side.membersOf : undefined;
|
|
199
|
+
return members !== undefined ? members.objectFlags : ObjectFlags.None;
|
|
181
200
|
}
|
|
182
201
|
|
|
183
202
|
function resolveMembersOfType(c: Checker, t: Type): void {
|
|
@@ -185,7 +204,7 @@ function resolveMembersOfType(c: Checker, t: Type): void {
|
|
|
185
204
|
const objectFlags = t.objectFlags;
|
|
186
205
|
if ((objectFlags & ObjectFlags.Reference) !== 0) resolveTypeReferenceMembers(c, t as TypeReference);
|
|
187
206
|
else if ((objectFlags & ObjectFlags.ClassOrInterface) !== 0)
|
|
188
|
-
resolveObjectTypeMembers(c, membersHolder(c, t), t as InterfaceType, emptyTypes, emptyTypes);
|
|
207
|
+
resolveObjectTypeMembers(c, membersHolder(c, t), t as InterfaceType, emptyTypes, emptyTypes, undefined);
|
|
189
208
|
else if ((objectFlags & ObjectFlags.ReverseMapped) !== 0) resolveReverseMappedTypeMembers(c, t);
|
|
190
209
|
else if ((objectFlags & ObjectFlags.Anonymous) !== 0) resolveAnonymousTypeMembers(c, t as ObjectType);
|
|
191
210
|
else if ((objectFlags & ObjectFlags.Mapped) !== 0) resolveMappedTypeMembers(c, t as MappedType);
|
|
@@ -197,29 +216,30 @@ function resolveTypeReferenceMembers(c: Checker, t: TypeReference): void {
|
|
|
197
216
|
const source = t.target as InterfaceType;
|
|
198
217
|
const typeParameters = source.allTypeParameters;
|
|
199
218
|
const typeArguments = getTypeArguments(c, t);
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
padded = [];
|
|
204
|
-
for (const typeArgument of typeArguments) padded.push(typeArgument);
|
|
205
|
-
padded.push(t as Type);
|
|
206
|
-
}
|
|
207
|
-
resolveObjectTypeMembers(c, membersHolder(c, t), source, typeParameters, padded);
|
|
219
|
+
// With one type argument fewer than parameters, the reference itself is the `this` type argument.
|
|
220
|
+
const thisArgument = typeArguments.length === typeParameters.length - 1 ? (t as Type) : undefined;
|
|
221
|
+
resolveObjectTypeMembers(c, membersHolder(c, t), source, typeParameters, typeArguments, thisArgument);
|
|
208
222
|
}
|
|
209
223
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
return
|
|
224
|
+
/** Whether `b`, followed by `last` where given, is the list `a`. */
|
|
225
|
+
function sameTypes(a: readonly Type[], b: readonly Type[], last: Type | undefined): boolean {
|
|
226
|
+
const count = b.length;
|
|
227
|
+
if (a.length !== (last !== undefined ? count + 1 : count)) return false;
|
|
228
|
+
for (let i = 0; i < count; i++) if (a[i]! !== b[i]!) return false;
|
|
229
|
+
return last === undefined || a[count]! === last;
|
|
214
230
|
}
|
|
215
231
|
|
|
216
|
-
/**
|
|
232
|
+
/**
|
|
233
|
+
* Resolves the members of an instantiation of `source` into `t`, the holder of its members: with
|
|
234
|
+
* `typeArguments` for its type parameters, followed by `thisArgument` where given.
|
|
235
|
+
*/
|
|
217
236
|
function resolveObjectTypeMembers(
|
|
218
237
|
c: Checker,
|
|
219
238
|
t: StructuredType,
|
|
220
239
|
source: InterfaceType,
|
|
221
240
|
typeParameters: Type[],
|
|
222
241
|
typeArguments: Type[],
|
|
242
|
+
thisArgument: Type | undefined,
|
|
223
243
|
): void {
|
|
224
244
|
const declared = resolveDeclaredMembers(c, source);
|
|
225
245
|
let mapper: TypeMapper | undefined;
|
|
@@ -230,14 +250,17 @@ function resolveObjectTypeMembers(
|
|
|
230
250
|
let instantiated = false;
|
|
231
251
|
// The member symbols of an instantiation are instantiated on demand (PendingInstantiatedMembers).
|
|
232
252
|
let pending: PendingInstantiatedMembers | undefined;
|
|
233
|
-
if (sameTypes(typeParameters, typeArguments)) {
|
|
253
|
+
if (sameTypes(typeParameters, typeArguments, thisArgument)) {
|
|
234
254
|
members = declared.declaredMembers;
|
|
235
255
|
callSignatures = declared.declaredCallSignatures;
|
|
236
256
|
constructSignatures = declared.declaredConstructSignatures;
|
|
237
257
|
indexInfos = declared.declaredIndexInfos;
|
|
238
258
|
} else {
|
|
239
259
|
instantiated = true;
|
|
240
|
-
mapper =
|
|
260
|
+
mapper =
|
|
261
|
+
thisArgument !== undefined
|
|
262
|
+
? newThisArgumentTypeMapper(typeParameters, typeArguments, thisArgument)
|
|
263
|
+
: newTypeMapper(typeParameters, typeArguments);
|
|
241
264
|
pending = pendingInstantiatedTable(c, source, mapper);
|
|
242
265
|
members = pending === undefined ? instantiateSymbolTable(c, declared.declaredMembers, mapper) : undefined;
|
|
243
266
|
callSignatures = instantiateSignatures(c, declared.declaredCallSignatures, mapper);
|
|
@@ -245,6 +268,9 @@ function resolveObjectTypeMembers(
|
|
|
245
268
|
indexInfos = instantiateIndexInfos(c, declared.declaredIndexInfos, mapper);
|
|
246
269
|
}
|
|
247
270
|
const baseTypes = getBaseTypes(c, source);
|
|
271
|
+
// The last type argument, the `this` type argument where the reference has one.
|
|
272
|
+
const lastArgument =
|
|
273
|
+
thisArgument ?? (typeArguments.length !== 0 ? typeArguments[typeArguments.length - 1]! : undefined);
|
|
248
274
|
if (pending !== undefined) {
|
|
249
275
|
resolvePendingObjectTypeMembers(
|
|
250
276
|
c,
|
|
@@ -252,7 +278,7 @@ function resolveObjectTypeMembers(
|
|
|
252
278
|
pending,
|
|
253
279
|
baseTypes,
|
|
254
280
|
mapper!,
|
|
255
|
-
|
|
281
|
+
lastArgument,
|
|
256
282
|
callSignatures,
|
|
257
283
|
constructSignatures,
|
|
258
284
|
indexInfos,
|
|
@@ -262,12 +288,11 @@ function resolveObjectTypeMembers(
|
|
|
262
288
|
if (baseTypes.length !== 0) {
|
|
263
289
|
members = !instantiated || members === undefined ? new Map(members ?? []) : members;
|
|
264
290
|
setStructuredTypeMembers(c, t, members, callSignatures, constructSignatures, indexInfos);
|
|
265
|
-
const thisArgument = typeArguments.length !== 0 ? typeArguments[typeArguments.length - 1]! : undefined;
|
|
266
291
|
t.objectFlags |= ObjectFlags.UnresolvedMembers;
|
|
267
292
|
for (const baseType of baseTypes) {
|
|
268
293
|
const instantiatedBaseType =
|
|
269
|
-
|
|
270
|
-
? getTypeWithThisArgument(c, instantiateType(c, baseType, mapper),
|
|
294
|
+
lastArgument !== undefined
|
|
295
|
+
? getTypeWithThisArgument(c, instantiateType(c, baseType, mapper), lastArgument, false)
|
|
271
296
|
: baseType;
|
|
272
297
|
addInheritedMembers(members, getPropertiesOfType(c, instantiatedBaseType));
|
|
273
298
|
// A base without signatures adds none: no copy of the list then.
|
|
@@ -576,14 +601,22 @@ export class PropertyMembers extends PendingMembers {
|
|
|
576
601
|
/** The most properties of a table that `keepPropertiesOnly` drops: a lookup compares that many names at most. */
|
|
577
602
|
const scannedPropertiesLimit = 8;
|
|
578
603
|
|
|
604
|
+
/** The most properties of an object literal's table that `keepPropertiesOnly` drops: literals are looked up often. */
|
|
605
|
+
export const scannedLiteralPropertiesLimit = 4;
|
|
606
|
+
|
|
579
607
|
/**
|
|
580
608
|
* After `setStructuredTypeMembers(c, t, members, ...)`: drops `members` where it holds only the
|
|
581
|
-
* type's properties, at most `
|
|
609
|
+
* type's properties, at most `limit` of them (`PropertyMembers`).
|
|
582
610
|
*/
|
|
583
|
-
export function keepPropertiesOnly(
|
|
611
|
+
export function keepPropertiesOnly(
|
|
612
|
+
c: Checker,
|
|
613
|
+
t: StructuredType,
|
|
614
|
+
members: SymbolTable,
|
|
615
|
+
limit: number = scannedPropertiesLimit,
|
|
616
|
+
): void {
|
|
584
617
|
const resolved = membersHolder(c, t);
|
|
585
618
|
const properties = resolved.propertiesValue;
|
|
586
|
-
if (members.size === 0 || members.size >
|
|
619
|
+
if (members.size === 0 || members.size > limit || properties.length !== members.size) return;
|
|
587
620
|
resolved.membersValue = undefined;
|
|
588
621
|
resolved.pendingMembers = new PropertyMembers(properties, undefined);
|
|
589
622
|
}
|
|
@@ -807,7 +840,7 @@ function resolvePendingObjectTypeMembers(
|
|
|
807
840
|
pending: PendingInstantiatedMembers,
|
|
808
841
|
baseTypes: Type[],
|
|
809
842
|
mapper: TypeMapper,
|
|
810
|
-
|
|
843
|
+
thisArgument: Type | undefined,
|
|
811
844
|
callSignatures: Signature[],
|
|
812
845
|
constructSignatures: Signature[],
|
|
813
846
|
indexInfos: IndexInfo[],
|
|
@@ -816,7 +849,6 @@ function resolvePendingObjectTypeMembers(
|
|
|
816
849
|
if (baseTypes.length === 0) return;
|
|
817
850
|
pending.hasBases = true;
|
|
818
851
|
pending.resolving = true;
|
|
819
|
-
const thisArgument = typeArguments.length !== 0 ? typeArguments[typeArguments.length - 1]! : undefined;
|
|
820
852
|
t.objectFlags |= ObjectFlags.UnresolvedMembers;
|
|
821
853
|
for (const baseType of baseTypes) {
|
|
822
854
|
const instantiatedBaseType =
|
|
@@ -999,7 +1031,7 @@ function resolveAnonymousTypeMembers(c: Checker, t: ObjectType): void {
|
|
|
999
1031
|
const varsOnly = new Map<string, Symbol>();
|
|
1000
1032
|
for (const p of members.values()) {
|
|
1001
1033
|
if ((p.flags & SymbolFlags.BlockScoped) !== 0) continue;
|
|
1002
|
-
if ((p.flags & SymbolFlags.ValueModule) !== 0 && isOnlyAmbientModuleDeclarations(p
|
|
1034
|
+
if ((p.flags & SymbolFlags.ValueModule) !== 0 && isOnlyAmbientModuleDeclarations(getDeclarations(p))) continue;
|
|
1003
1035
|
varsOnly.set(p.name, p);
|
|
1004
1036
|
}
|
|
1005
1037
|
members = varsOnly;
|
|
@@ -1494,8 +1526,9 @@ export function getPropertiesOfObjectType(c: Checker, t: Type): Symbol[] {
|
|
|
1494
1526
|
}
|
|
1495
1527
|
|
|
1496
1528
|
export function getPropertiesOfUnionOrIntersectionType(c: Checker, t: UnionOrIntersectionType): Symbol[] {
|
|
1497
|
-
const
|
|
1498
|
-
if (
|
|
1529
|
+
const known = sideOf(c, t).membersOf;
|
|
1530
|
+
if (known !== undefined && known.resolvedProperties !== undefined) return known.resolvedProperties;
|
|
1531
|
+
{
|
|
1499
1532
|
const checked = new Set<string>();
|
|
1500
1533
|
const props: Symbol[] = [];
|
|
1501
1534
|
for (const current of t.types) {
|
|
@@ -1513,9 +1546,11 @@ export function getPropertiesOfUnionOrIntersectionType(c: Checker, t: UnionOrInt
|
|
|
1513
1546
|
// Union properties are in every constituent: the first without index signatures suffices.
|
|
1514
1547
|
if ((t.flags & TypeFlags.Union) !== 0 && getIndexInfosOfType(c, current).length === 0) break;
|
|
1515
1548
|
}
|
|
1549
|
+
// Resolving the properties may have created the holder.
|
|
1550
|
+
const side = unionOrIntersectionMembers(sideOf(c, t));
|
|
1516
1551
|
side.resolvedProperties = props;
|
|
1552
|
+
return props;
|
|
1517
1553
|
}
|
|
1518
|
-
return side.resolvedProperties;
|
|
1519
1554
|
}
|
|
1520
1555
|
|
|
1521
1556
|
export function getPropertyOfType(c: Checker, t: Type, name: string): Symbol | undefined {
|
|
@@ -1614,16 +1649,24 @@ export function getUnionOrIntersectionProperty(
|
|
|
1614
1649
|
name: string,
|
|
1615
1650
|
skipObjectFunctionPropertyAugment: boolean,
|
|
1616
1651
|
): Symbol | undefined {
|
|
1617
|
-
const
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
if (
|
|
1652
|
+
const known = sideOf(c, t).membersOf;
|
|
1653
|
+
if (known !== undefined) {
|
|
1654
|
+
const cached = (
|
|
1655
|
+
skipObjectFunctionPropertyAugment ? known.propertyCacheWithoutFunctionPropertyAugment : known.propertyCache
|
|
1656
|
+
)?.get(name);
|
|
1657
|
+
if (cached !== undefined) return cached;
|
|
1658
|
+
if (!skipObjectFunctionPropertyAugment) {
|
|
1659
|
+
const withoutAugment = known.propertyCacheWithoutFunctionPropertyAugment?.get(name);
|
|
1660
|
+
if (withoutAugment !== undefined && (withoutAugment.checkFlags & CheckFlags.Partial) === 0) return withoutAugment;
|
|
1661
|
+
}
|
|
1624
1662
|
}
|
|
1625
1663
|
const prop = createUnionOrIntersectionProperty(c, t, name, skipObjectFunctionPropertyAugment);
|
|
1626
1664
|
if (prop !== undefined) {
|
|
1665
|
+
// Creating the property may have created the holder and its caches.
|
|
1666
|
+
const side = unionOrIntersectionMembers(sideOf(c, t));
|
|
1667
|
+
let cache = skipObjectFunctionPropertyAugment
|
|
1668
|
+
? side.propertyCacheWithoutFunctionPropertyAugment
|
|
1669
|
+
: side.propertyCache;
|
|
1627
1670
|
if (cache === undefined) {
|
|
1628
1671
|
cache = new Map<string, Symbol>();
|
|
1629
1672
|
if (skipObjectFunctionPropertyAugment) side.propertyCacheWithoutFunctionPropertyAugment = cache;
|
|
@@ -1765,7 +1808,7 @@ export function createUnionOrIntersectionProperty(
|
|
|
1765
1808
|
if (firstValueDeclaration === undefined) firstValueDeclaration = prop.valueDeclaration;
|
|
1766
1809
|
else if (prop.valueDeclaration !== undefined && prop.valueDeclaration !== firstValueDeclaration)
|
|
1767
1810
|
hasNonUniformValueDeclaration = true;
|
|
1768
|
-
for (const d of prop
|
|
1811
|
+
for (const d of getDeclarations(prop)) declarations.push(d);
|
|
1769
1812
|
const t = getTypeOfSymbol(c, prop);
|
|
1770
1813
|
if (firstType === undefined) {
|
|
1771
1814
|
firstType = t;
|
|
@@ -1783,7 +1826,7 @@ export function createUnionOrIntersectionProperty(
|
|
|
1783
1826
|
}
|
|
1784
1827
|
for (const t of indexTypes) propTypes.push(t);
|
|
1785
1828
|
const result = c.newSymbolWithCheckFlags(propFlags | optionalFlag, name, checkFlags | syntheticFlag);
|
|
1786
|
-
result
|
|
1829
|
+
setDeclarations(result, declarations);
|
|
1787
1830
|
if (!hasNonUniformValueDeclaration && firstValueDeclaration !== undefined) {
|
|
1788
1831
|
result.valueDeclaration = firstValueDeclaration;
|
|
1789
1832
|
result.parent = getSymbol(firstValueDeclaration)?.parent;
|
|
@@ -1821,13 +1864,13 @@ export function isPrototypeProperty(symbol: Symbol): boolean {
|
|
|
1821
1864
|
function hasCommonDeclaration(symbols: Symbol[]): boolean {
|
|
1822
1865
|
let common: Set<Node> | undefined;
|
|
1823
1866
|
for (const symbol of symbols) {
|
|
1824
|
-
if (symbol
|
|
1867
|
+
if (declarationCount(symbol) === 0) return false;
|
|
1825
1868
|
if (common === undefined) {
|
|
1826
|
-
common = new Set(symbol
|
|
1869
|
+
common = new Set(getDeclarations(symbol));
|
|
1827
1870
|
continue;
|
|
1828
1871
|
}
|
|
1829
1872
|
const next = new Set<Node>();
|
|
1830
|
-
for (const d of symbol
|
|
1873
|
+
for (const d of getDeclarations(symbol)) if (common.has(d)) next.add(d);
|
|
1831
1874
|
if (next.size === 0) return false;
|
|
1832
1875
|
common = next;
|
|
1833
1876
|
}
|
|
@@ -1836,7 +1879,7 @@ function hasCommonDeclaration(symbols: Symbol[]): boolean {
|
|
|
1836
1879
|
|
|
1837
1880
|
export function createSymbolWithType(c: Checker, source: Symbol, t: Type | undefined): Symbol {
|
|
1838
1881
|
const symbol = c.newSymbolWithCheckFlags(source.flags, source.name, source.checkFlags & CheckFlags.Readonly);
|
|
1839
|
-
symbol
|
|
1882
|
+
copyDeclarations(symbol, source);
|
|
1840
1883
|
symbol.parent = source.parent;
|
|
1841
1884
|
symbol.valueDeclaration = source.valueDeclaration;
|
|
1842
1885
|
const id = getSymbolId(symbol);
|
|
@@ -2111,7 +2154,8 @@ export function getReducedType(c: Checker, t: Type): Type {
|
|
|
2111
2154
|
* private, are combined, and the costliest constituent's properties are only looked up by name.
|
|
2112
2155
|
*/
|
|
2113
2156
|
function hasNeverReducedProperty(c: Checker, t: IntersectionType): boolean {
|
|
2114
|
-
const
|
|
2157
|
+
const members = sideOf(c, t).membersOf;
|
|
2158
|
+
const resolved = members !== undefined ? members.resolvedProperties : undefined;
|
|
2115
2159
|
if (resolved !== undefined) {
|
|
2116
2160
|
for (const p of resolved) if (isNeverReducedProperty(c, p)) return true;
|
|
2117
2161
|
return false;
|
|
@@ -112,7 +112,6 @@ import {
|
|
|
112
112
|
tryExtractTSExtension,
|
|
113
113
|
tryGetExtensionFromPath,
|
|
114
114
|
} from './path.js';
|
|
115
|
-
import { InternalSymbolName, type Symbol, SymbolFlags, type SymbolTable, getSymbolId } from './symbol.js';
|
|
116
115
|
import { SyntaxKind } from './syntax-kind.js';
|
|
117
116
|
import { isExpressionNode } from './transformers/alias-references.js';
|
|
118
117
|
import { type Checker, type CheckerHost, createDiagnosticForNode } from './checker.js';
|
|
@@ -162,6 +161,17 @@ import { createPromiseType } from './checker-iteration.js';
|
|
|
162
161
|
import { symbolToString, typeToString } from './type-printer.js';
|
|
163
162
|
import { checkTypeAssignableToAndOptionallyElaborate } from './checker-expressions.js';
|
|
164
163
|
import { grammarErrorOnNode } from './checker-operators.js';
|
|
164
|
+
import {
|
|
165
|
+
declarationAt,
|
|
166
|
+
declarationCount,
|
|
167
|
+
getDeclarations,
|
|
168
|
+
getSymbolId,
|
|
169
|
+
InternalSymbolName,
|
|
170
|
+
setDeclarations,
|
|
171
|
+
type Symbol,
|
|
172
|
+
SymbolFlags,
|
|
173
|
+
type SymbolTable,
|
|
174
|
+
} from './symbol.js';
|
|
165
175
|
|
|
166
176
|
// ---- Resolution
|
|
167
177
|
|
|
@@ -787,7 +797,7 @@ function isOnlyImportableAsDefault(c: Checker, usage: Node, resolvedModule: Symb
|
|
|
787
797
|
function getSourceFileOfModuleSymbol(symbol: Symbol): SourceFile | undefined {
|
|
788
798
|
let declaration = symbol.valueDeclaration;
|
|
789
799
|
if (declaration === undefined)
|
|
790
|
-
for (const d of symbol
|
|
800
|
+
for (const d of getDeclarations(symbol))
|
|
791
801
|
if (!(isAmbientModule(d) && isModuleAugmentationExternal(d)) && !isGlobalScopeAugmentation(d)) {
|
|
792
802
|
declaration = d;
|
|
793
803
|
break;
|
|
@@ -857,7 +867,7 @@ function createDefaultPropertyWrapperForModule(
|
|
|
857
867
|
|
|
858
868
|
function cloneTypeAsModuleType(c: Checker, symbol: Symbol, moduleType: Type): Symbol {
|
|
859
869
|
const result = c.newSymbol(symbol.flags, symbol.name);
|
|
860
|
-
result
|
|
870
|
+
setDeclarations(result, getDeclarations(symbol).slice());
|
|
861
871
|
result.valueDeclaration = symbol.valueDeclaration;
|
|
862
872
|
if (symbol.members !== undefined) result.members = new Map(symbol.members);
|
|
863
873
|
if (symbol.exports !== undefined) result.exports = new Map(symbol.exports);
|
|
@@ -869,7 +879,7 @@ function cloneTypeAsModuleType(c: Checker, symbol: Symbol, moduleType: Type): Sy
|
|
|
869
879
|
|
|
870
880
|
function getSourceFileDeclaration(symbol: Symbol | undefined): SourceFile | undefined {
|
|
871
881
|
if (symbol === undefined) return undefined;
|
|
872
|
-
for (const d of symbol
|
|
882
|
+
for (const d of getDeclarations(symbol)) if (d.kind === SyntaxKind.SourceFile) return d as SourceFile;
|
|
873
883
|
return undefined;
|
|
874
884
|
}
|
|
875
885
|
|
|
@@ -919,7 +929,7 @@ function canHaveSyntheticDefault(
|
|
|
919
929
|
}
|
|
920
930
|
|
|
921
931
|
function hasSyntacticDefault(symbol: Symbol): boolean {
|
|
922
|
-
for (const d of symbol
|
|
932
|
+
for (const d of getDeclarations(symbol)) if (isSyntacticDefault(d)) return true;
|
|
923
933
|
return false;
|
|
924
934
|
}
|
|
925
935
|
|
|
@@ -1154,7 +1164,7 @@ function reportNonDefaultExport(c: Checker, moduleSymbol: Symbol, node: Node): v
|
|
|
1154
1164
|
);
|
|
1155
1165
|
const exportStar = moduleSymbol.exports?.get(InternalSymbolName.ExportStar);
|
|
1156
1166
|
if (exportStar === undefined) return;
|
|
1157
|
-
for (const d of exportStar
|
|
1167
|
+
for (const d of getDeclarations(exportStar)) {
|
|
1158
1168
|
const specifier = getModuleSpecifier(d);
|
|
1159
1169
|
if (d.kind !== SyntaxKind.ExportDeclaration || specifier === undefined) continue;
|
|
1160
1170
|
const resolved = resolveExternalModuleName(c, d, specifier, false);
|
|
@@ -1304,9 +1314,9 @@ function combineValueAndTypeSymbols(c: Checker, valueSymbol: Symbol, typeSymbol:
|
|
|
1304
1314
|
if ((typeSymbol.flags & SymbolFlags.Value) !== 0) return typeSymbol;
|
|
1305
1315
|
if ((valueSymbol.flags & (SymbolFlags.Type | SymbolFlags.Namespace)) !== 0) return valueSymbol;
|
|
1306
1316
|
const result = c.newSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.name);
|
|
1307
|
-
const declarations = valueSymbol.
|
|
1308
|
-
for (const d of typeSymbol
|
|
1309
|
-
result
|
|
1317
|
+
const declarations = getDeclarations(valueSymbol).slice();
|
|
1318
|
+
for (const d of getDeclarations(typeSymbol)) if (!declarations.includes(d)) declarations.push(d);
|
|
1319
|
+
setDeclarations(result, declarations);
|
|
1310
1320
|
result.parent = valueSymbol.parent ?? typeSymbol.parent;
|
|
1311
1321
|
result.valueDeclaration = valueSymbol.valueDeclaration;
|
|
1312
1322
|
if (typeSymbol.members !== undefined) result.members = new Map(typeSymbol.members);
|
|
@@ -1412,10 +1422,10 @@ function reportNonExportedMember(
|
|
|
1412
1422
|
symbolToString(c, exportedSymbol),
|
|
1413
1423
|
)
|
|
1414
1424
|
: c.error(name, Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported, moduleName, declarationName);
|
|
1415
|
-
for (let i = 0; i < localSymbol
|
|
1425
|
+
for (let i = 0; i < declarationCount(localSymbol); i++)
|
|
1416
1426
|
diagnostic.addRelatedInfo(
|
|
1417
1427
|
createDiagnosticForNode(
|
|
1418
|
-
localSymbol
|
|
1428
|
+
declarationAt(localSymbol, i),
|
|
1419
1429
|
i === 0 ? Diagnostics.X_0_is_declared_here : Diagnostics.X_and_here,
|
|
1420
1430
|
[declarationName],
|
|
1421
1431
|
),
|
|
@@ -1985,7 +1995,7 @@ class ExportCollector {
|
|
|
1985
1995
|
if (exportStars !== undefined) {
|
|
1986
1996
|
const nested: SymbolTable = new Map<string, Symbol>();
|
|
1987
1997
|
const lookupTable = new Map<string, ExportCollision>();
|
|
1988
|
-
for (const node of exportStars
|
|
1998
|
+
for (const node of getDeclarations(exportStars)) {
|
|
1989
1999
|
const specifier = (node as ExportDeclaration).moduleSpecifier;
|
|
1990
2000
|
const resolved = resolveExternalModuleName(this.c, node, specifier, false);
|
|
1991
2001
|
const exported = this.visit(resolved, node, isTypeOnly || getIsTypeOnly(node));
|
|
@@ -2551,7 +2561,7 @@ function checkExportSpecifier(c: Checker, node: Node): void {
|
|
|
2551
2561
|
symbol !== undefined &&
|
|
2552
2562
|
(symbol === c.undefinedSymbol ||
|
|
2553
2563
|
symbol === c.globalThisSymbol ||
|
|
2554
|
-
(symbol
|
|
2564
|
+
(declarationCount(symbol) > 0 && isGlobalSourceFile(getDeclarationContainer(symbol.declaration!))))
|
|
2555
2565
|
)
|
|
2556
2566
|
c.error(
|
|
2557
2567
|
exportedName,
|
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
import { isAssignmentTarget } from './binder-utilities.js';
|
|
17
17
|
import { createDiagnosticForNode, type Checker } from './checker.js';
|
|
18
18
|
import { Diagnostics } from './diagnostics.js';
|
|
19
|
-
import { CheckFlags, type Symbol, SymbolFlags, internalSymbolNamePrefix, getSymbolId } from './symbol.js';
|
|
20
19
|
import { SyntaxKind } from './syntax-kind.js';
|
|
21
20
|
import {
|
|
22
21
|
CheckMode,
|
|
@@ -46,6 +45,8 @@ import {
|
|
|
46
45
|
getPropertiesOfType,
|
|
47
46
|
getPropertyOfType,
|
|
48
47
|
getReducedType,
|
|
48
|
+
keepPropertiesOnly,
|
|
49
|
+
scannedLiteralPropertiesLimit,
|
|
49
50
|
} from './checker-members.js';
|
|
50
51
|
import { symbolToString, typeToString } from './type-printer.js';
|
|
51
52
|
import { getMergedSymbol, getSymbolOfDeclaration } from './checker-symbols.js';
|
|
@@ -76,6 +77,17 @@ import {
|
|
|
76
77
|
import { addIntraExpressionInferenceSite } from './checker-inference.js';
|
|
77
78
|
import { isEmptyObjectType } from './checker-type-factory.js';
|
|
78
79
|
import { getTypeOfExpandoObjectLiteral, isJSObjectLiteral } from './checker-javascript.js';
|
|
80
|
+
import {
|
|
81
|
+
CheckFlags,
|
|
82
|
+
copyDeclarations,
|
|
83
|
+
declarationCount,
|
|
84
|
+
getDeclarations,
|
|
85
|
+
getSymbolId,
|
|
86
|
+
internalSymbolNamePrefix,
|
|
87
|
+
setDeclarations,
|
|
88
|
+
type Symbol,
|
|
89
|
+
SymbolFlags,
|
|
90
|
+
} from './symbol.js';
|
|
79
91
|
|
|
80
92
|
/** Builds the type of the members collected since the last spread. */
|
|
81
93
|
class ObjectLiteralBuilder {
|
|
@@ -123,6 +135,8 @@ class ObjectLiteralBuilder {
|
|
|
123
135
|
if (this.patternWithComputedProperties)
|
|
124
136
|
result.objectFlags |= ObjectFlags.ObjectLiteralPatternWithComputedProperties;
|
|
125
137
|
if (this.inDestructuringPattern) c.patternForType.set(result, this.node);
|
|
138
|
+
// A literal of a few properties keeps them as a list; a lookup by name compares their names.
|
|
139
|
+
keepPropertiesOnly(c, result, this.members, scannedLiteralPropertiesLimit);
|
|
126
140
|
return result;
|
|
127
141
|
}
|
|
128
142
|
|
|
@@ -229,7 +243,7 @@ export function checkObjectLiteral(c: Checker, node: Node, checkMode: CheckMode)
|
|
|
229
243
|
typeToString(c, contextualType!),
|
|
230
244
|
);
|
|
231
245
|
}
|
|
232
|
-
prop
|
|
246
|
+
copyDeclarations(prop, member);
|
|
233
247
|
prop.parent = member.parent;
|
|
234
248
|
prop.valueDeclaration = member.valueDeclaration;
|
|
235
249
|
c.symbolTypes.set(id, t);
|
|
@@ -317,7 +331,7 @@ function getObjectLiteralIndexInfo(c: Checker, isReadonly: boolean, properties:
|
|
|
317
331
|
(keyType === c.esSymbolType && isSymbolWithSymbolName(c, prop))
|
|
318
332
|
) {
|
|
319
333
|
propTypes.push(getTypeOfSymbol(c, prop));
|
|
320
|
-
if (isSymbolWithComputedName(prop)) components.push(prop.
|
|
334
|
+
if (isSymbolWithComputedName(prop)) components.push(prop.declaration!);
|
|
321
335
|
}
|
|
322
336
|
}
|
|
323
337
|
const unionType =
|
|
@@ -328,7 +342,7 @@ function getObjectLiteralIndexInfo(c: Checker, isReadonly: boolean, properties:
|
|
|
328
342
|
}
|
|
329
343
|
|
|
330
344
|
function getFirstDeclarationName(symbol: Symbol): Node | undefined {
|
|
331
|
-
return symbol
|
|
345
|
+
return declarationCount(symbol) !== 0 ? getName(symbol.declaration!) : undefined;
|
|
332
346
|
}
|
|
333
347
|
|
|
334
348
|
function isSymbolWithSymbolName(c: Checker, symbol: Symbol): boolean {
|
|
@@ -470,7 +484,7 @@ export function getSpreadType(
|
|
|
470
484
|
);
|
|
471
485
|
c.symbolLeftSpreads.set(id, leftProp);
|
|
472
486
|
c.symbolRightSpreads.set(id, rightProp);
|
|
473
|
-
result
|
|
487
|
+
setDeclarations(result, getDeclarations(leftProp).concat(getDeclarations(rightProp)));
|
|
474
488
|
c.symbolNameTypes.set(id, c.symbolNameTypes.get(getSymbolId(leftProp)));
|
|
475
489
|
members.set(leftProp.name, result);
|
|
476
490
|
}
|
|
@@ -479,6 +493,7 @@ export function getSpreadType(
|
|
|
479
493
|
const spread = createAnonymousType(c, symbol, members, [], [], spreadIndexInfos);
|
|
480
494
|
spread.objectFlags |=
|
|
481
495
|
ObjectFlags.ObjectLiteral | ObjectFlags.ContainsObjectOrArrayLiteral | ObjectFlags.ContainsSpread | objectFlags;
|
|
496
|
+
keepPropertiesOnly(c, spread, members, scannedLiteralPropertiesLimit);
|
|
482
497
|
return spread;
|
|
483
498
|
}
|
|
484
499
|
|
|
@@ -564,12 +579,13 @@ function tryMergeUnionOfObjectTypeAndEmptyObject(c: Checker, t: Type, readonly:
|
|
|
564
579
|
id,
|
|
565
580
|
isSetonlyAccessor ? c.undefinedType : addOptionality(c, getTypeOfSymbol(c, prop), true, true),
|
|
566
581
|
);
|
|
567
|
-
result
|
|
582
|
+
copyDeclarations(result, prop);
|
|
568
583
|
c.symbolNameTypes.set(id, c.symbolNameTypes.get(getSymbolId(prop)));
|
|
569
584
|
c.symbolSyntheticOrigins.set(id, prop);
|
|
570
585
|
members.set(prop.name, result);
|
|
571
586
|
}
|
|
572
587
|
const spread = createAnonymousType(c, firstType.symbol, members, [], [], getIndexInfosOfType(c, firstType));
|
|
573
588
|
spread.objectFlags |= ObjectFlags.ObjectLiteral | ObjectFlags.ContainsObjectOrArrayLiteral;
|
|
589
|
+
keepPropertiesOnly(c, spread, members, scannedLiteralPropertiesLimit);
|
|
574
590
|
return spread;
|
|
575
591
|
}
|
|
@@ -23,7 +23,6 @@ import {
|
|
|
23
23
|
} from './binder-utilities.js';
|
|
24
24
|
import { nodeIsMissing, nodeIsPresent } from './ast-utilities.js';
|
|
25
25
|
import { type DiagnosticMessage, Diagnostics } from './diagnostics.js';
|
|
26
|
-
import { type Symbol, SymbolFlags } from './symbol.js';
|
|
27
26
|
import { SyntaxKind } from './syntax-kind.js';
|
|
28
27
|
import { type Checker, createDiagnosticForNode } from './checker.js';
|
|
29
28
|
import type { Signature } from './checker-types.js';
|
|
@@ -39,6 +38,7 @@ import { checkComputedPropertyName } from './checker-expressions.js';
|
|
|
39
38
|
import { hasDynamicName, hasLateBindableName } from './checker-utilities.js';
|
|
40
39
|
import { isSignatureAssignableTo, isTypeIdenticalTo, isTypeRelatedTo } from './relations.js';
|
|
41
40
|
import { getEffectiveDeclarationFlags } from './checker-declarations.js';
|
|
41
|
+
import { getDeclarations, type Symbol, SymbolFlags } from './symbol.js';
|
|
42
42
|
|
|
43
43
|
/** Checks the overloads of a function or method declaration's local and export symbols. */
|
|
44
44
|
export function checkFunctionOrMethodSymbols(c: Checker, node: Node): void {
|
|
@@ -84,7 +84,7 @@ class OverloadChecker {
|
|
|
84
84
|
|
|
85
85
|
check(): void {
|
|
86
86
|
const c = this.c;
|
|
87
|
-
const declarations = this.symbol
|
|
87
|
+
const declarations = getDeclarations(this.symbol);
|
|
88
88
|
let someNodeFlags = ModifierFlags.None;
|
|
89
89
|
let allNodeFlags = flagsToCheck();
|
|
90
90
|
let someHaveQuestionToken = false;
|
|
@@ -184,8 +184,8 @@ class OverloadChecker {
|
|
|
184
184
|
reportClassMergedWithFunction(): void {
|
|
185
185
|
const c = this.c;
|
|
186
186
|
const classes: Node[] = [];
|
|
187
|
-
for (const d of this.symbol
|
|
188
|
-
for (const d of this.symbol
|
|
187
|
+
for (const d of getDeclarations(this.symbol)) if (d.kind === SyntaxKind.ClassDeclaration) classes.push(d);
|
|
188
|
+
for (const d of getDeclarations(this.symbol)) {
|
|
189
189
|
let message: DiagnosticMessage;
|
|
190
190
|
if (d.kind === SyntaxKind.ClassDeclaration)
|
|
191
191
|
message = Diagnostics.Class_declaration_cannot_implement_overload_list_for_0;
|
|
@@ -201,7 +201,7 @@ class OverloadChecker {
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
checkFlagAgreement(
|
|
204
|
-
overloads: Node[],
|
|
204
|
+
overloads: readonly Node[],
|
|
205
205
|
implementation: Node | undefined,
|
|
206
206
|
someOverloadFlags: ModifierFlags,
|
|
207
207
|
allOverloadFlags: ModifierFlags,
|
|
@@ -290,7 +290,7 @@ class OverloadChecker {
|
|
|
290
290
|
* The declaration whose flags overloads must agree with: the implementation when it shares the first
|
|
291
291
|
* overload's container (so overloads from other files aren't reported), else the first overload.
|
|
292
292
|
*/
|
|
293
|
-
function getCanonicalOverload(overloads: Node[], implementation: Node | undefined): Node {
|
|
293
|
+
function getCanonicalOverload(overloads: readonly Node[], implementation: Node | undefined): Node {
|
|
294
294
|
return implementation !== undefined && implementation.parent === overloads[0]!.parent
|
|
295
295
|
? implementation
|
|
296
296
|
: overloads[0]!;
|
|
@@ -37,7 +37,6 @@ import {
|
|
|
37
37
|
import { isFunctionLike, isInJSFile } from './ast-utilities.js';
|
|
38
38
|
import { type Checker, createDiagnosticForNode } from './checker.js';
|
|
39
39
|
import { type Diagnostic, Diagnostics } from './diagnostics.js';
|
|
40
|
-
import { CheckFlags, type Symbol, SymbolFlags, getSymbolId } from './symbol.js';
|
|
41
40
|
import { SyntaxKind } from './syntax-kind.js';
|
|
42
41
|
import {
|
|
43
42
|
CheckMode,
|
|
@@ -102,6 +101,7 @@ import {
|
|
|
102
101
|
getResolvedSymbol,
|
|
103
102
|
} from './checker-expressions.js';
|
|
104
103
|
import { isJSLiteralType, isThisPropertyAccessInConstructor } from './checker-javascript.js';
|
|
104
|
+
import { CheckFlags, getDeclarations, getSymbolId, type Symbol, SymbolFlags } from './symbol.js';
|
|
105
105
|
|
|
106
106
|
export function checkPropertyAccessExpressionOrQualifiedName(
|
|
107
107
|
c: Checker,
|
|
@@ -607,7 +607,7 @@ function checkPropertyAccessibilityAtLocation(
|
|
|
607
607
|
}
|
|
608
608
|
|
|
609
609
|
function hasClassInstancePropertyDeclaration(symbol: Symbol): boolean {
|
|
610
|
-
for (const d of symbol
|
|
610
|
+
for (const d of getDeclarations(symbol)) if (isClassInstanceProperty(d)) return true;
|
|
611
611
|
return false;
|
|
612
612
|
}
|
|
613
613
|
|
|
@@ -126,7 +126,7 @@ import {
|
|
|
126
126
|
} from './checker-type-nodes.js';
|
|
127
127
|
import { CheckMode, type Signature, type Type } from './checker-types.js';
|
|
128
128
|
import { getNodeAtPosition } from './parser.js';
|
|
129
|
-
import { CheckFlags, InternalSymbolName, type Symbol, SymbolFlags
|
|
129
|
+
import { CheckFlags, getSymbolId, InternalSymbolName, setDeclarations, type Symbol, SymbolFlags } from './symbol.js';
|
|
130
130
|
import { SyntaxKind } from './syntax-kind.js';
|
|
131
131
|
|
|
132
132
|
// ---- Symbols at locations
|
|
@@ -397,7 +397,7 @@ function getApplicableIndexSymbol(c: Checker, t: Type, keyType: Type): Symbol |
|
|
|
397
397
|
declarations.push(other.declaration);
|
|
398
398
|
if (declarations.length !== 0) {
|
|
399
399
|
const symbol = c.newSymbolWithCheckFlags(SymbolFlags.Property, InternalSymbolName.Index, CheckFlags.IndexSymbol);
|
|
400
|
-
symbol
|
|
400
|
+
setDeclarations(symbol, declarations);
|
|
401
401
|
symbol.valueDeclaration = declarations[0]!;
|
|
402
402
|
symbol.parent = t.symbol;
|
|
403
403
|
c.symbolTypes.set(getSymbolId(symbol), info.valueType);
|