Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit70cdafc

Browse files
committed
Don't add excess properties to type nodes in typeToTypeNode
1 parent5383e15 commit70cdafc

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

‎src/compiler/checker.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6581,7 +6581,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
65816581
context.truncating = true;
65826582
}
65836583
context.approximateLength += cachedResult.addedLength;
6584-
return deepCloneOrReuseNode(cachedResult) as TypeNode as T;
6584+
return deepCloneOrReuseNode(cachedResult.node) as T;
65856585
}
65866586

65876587
let depth: number | undefined;
@@ -6597,11 +6597,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
65976597
const result = transform(type);
65986598
const addedLength = context.approximateLength - startLength;
65996599
if (!context.reportedDiagnostic && !context.encounteredError) {
6600-
if (context.truncating) {
6601-
(result as any).truncating = true;
6602-
}
6603-
(result as any).addedLength = addedLength;
6604-
links?.serializedTypes?.set(key, result as TypeNode as TypeNode & {truncating?: boolean, addedLength: number});
6600+
links?.serializedTypes?.set(key, { node: result, truncating: context.truncating, addedLength });
66056601
}
66066602
context.visitedTypes.delete(typeId);
66076603
if (id) {

‎src/compiler/types.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5936,12 +5936,19 @@ export interface NodeLinks {
59365936
isExhaustive?:boolean|0;// Is node an exhaustive switch statement (0 indicates in-process resolution)
59375937
skipDirectInference?:true;// Flag set by the API `getContextualType` call on a node when `Completions` is passed to force the checker to skip making inferences to a node's type
59385938
declarationRequiresScopeChange?:boolean;// Set by `useOuterVariableScopeInParameter` in checker when downlevel emit would change the name resolution scope inside of a parameter.
5939-
serializedTypes?:Map<string,TypeNode&{truncating?:boolean,addedLength:number}>;// Collection of types serialized at this location
5939+
serializedTypes?:Map<string,SerializedTypeEntry>;// Collection of types serialized at this location
59405940

59415941
contextualType?:Type;// Used to temporarily assign a contextual type during overload resolution
59425942
inferenceContext?:InferenceContext;// Inference context for contextual type
59435943
}
59445944

5945+
/**@internal */
5946+
exportinterfaceSerializedTypeEntry{
5947+
node:TypeNode;
5948+
truncating?:boolean;
5949+
addedLength:number;
5950+
}
5951+
59455952
exportconstenumTypeFlags{
59465953
Any=1<<0,
59475954
Unknown=1<<1,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp