Skip to content

Commit f3e6f5b

Browse files
committed
Removing getGeneratedNameForNode from type serializers
1 parent 334b224 commit f3e6f5b

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

src/compiler/checker.ts

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11955,9 +11955,10 @@ module ts {
1195511955
}
1195611956

1195711957
/** Serializes an EntityName (with substitutions) to an appropriate JS constructor value. Used by the __metadata decorator. */
11958-
function serializeEntityName(node: EntityName, getGeneratedNameForNode: (Node: Node) => string, fallbackPath?: string[]): string {
11958+
function serializeEntityName(node: EntityName, fallbackPath?: string[]): string {
1195911959
if (node.kind === SyntaxKind.Identifier) {
11960-
// TODO(andersh): Fix this
11960+
// TODO(ron.buckton): The getExpressionNameSubstitution function has been removed, but calling it
11961+
// here has no effect anyway as an identifier in a type name is not an expression.
1196111962
// var substitution = getExpressionNameSubstitution(<Identifier>node, getGeneratedNameForNode);
1196211963
// var text = substitution || (<Identifier>node).text;
1196311964
var text = (<Identifier>node).text;
@@ -11969,16 +11970,16 @@ module ts {
1196911970
}
1197011971
}
1197111972
else {
11972-
var left = serializeEntityName((<QualifiedName>node).left, getGeneratedNameForNode, fallbackPath);
11973-
var right = serializeEntityName((<QualifiedName>node).right, getGeneratedNameForNode, fallbackPath);
11973+
var left = serializeEntityName((<QualifiedName>node).left, fallbackPath);
11974+
var right = serializeEntityName((<QualifiedName>node).right, fallbackPath);
1197411975
if (!fallbackPath) {
1197511976
return left + "." + right;
1197611977
}
1197711978
}
1197811979
}
1197911980

1198011981
/** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */
11981-
function serializeTypeReferenceNode(node: TypeReferenceNode, getGeneratedNameForNode: (Node: Node) => string): string | string[] {
11982+
function serializeTypeReferenceNode(node: TypeReferenceNode): string | string[] {
1198211983
// serialization of a TypeReferenceNode uses the following rules:
1198311984
//
1198411985
// * The serialized type of a TypeReference that is `void` is "void 0".
@@ -12011,11 +12012,11 @@ module ts {
1201112012
}
1201212013
else if (type === unknownType) {
1201312014
var fallbackPath: string[] = [];
12014-
serializeEntityName(node.typeName, getGeneratedNameForNode, fallbackPath);
12015+
serializeEntityName(node.typeName, fallbackPath);
1201512016
return fallbackPath;
1201612017
}
1201712018
else if (type.symbol && type.symbol.valueDeclaration) {
12018-
return serializeEntityName(node.typeName, getGeneratedNameForNode);
12019+
return serializeEntityName(node.typeName);
1201912020
}
1202012021
else if (typeHasCallOrConstructSignatures(type)) {
1202112022
return "Function";
@@ -12025,7 +12026,7 @@ module ts {
1202512026
}
1202612027

1202712028
/** Serializes a TypeNode to an appropriate JS constructor value. Used by the __metadata decorator. */
12028-
function serializeTypeNode(node: TypeNode | LiteralExpression, getGeneratedNameForNode: (Node: Node) => string): string | string[] {
12029+
function serializeTypeNode(node: TypeNode | LiteralExpression): string | string[] {
1202912030
// serialization of a TypeNode uses the following rules:
1203012031
//
1203112032
// * The serialized type of `void` is "void 0" (undefined).
@@ -12041,7 +12042,7 @@ module ts {
1204112042
case SyntaxKind.VoidKeyword:
1204212043
return "void 0";
1204312044
case SyntaxKind.ParenthesizedType:
12044-
return serializeTypeNode((<ParenthesizedTypeNode>node).type, getGeneratedNameForNode);
12045+
return serializeTypeNode((<ParenthesizedTypeNode>node).type);
1204512046
case SyntaxKind.FunctionType:
1204612047
case SyntaxKind.ConstructorType:
1204712048
return "Function";
@@ -12056,7 +12057,7 @@ module ts {
1205612057
case SyntaxKind.NumberKeyword:
1205712058
return "Number";
1205812059
case SyntaxKind.TypeReference:
12059-
return serializeTypeReferenceNode(<TypeReferenceNode>node, getGeneratedNameForNode);
12060+
return serializeTypeReferenceNode(<TypeReferenceNode>node);
1206012061
case SyntaxKind.TypeQuery:
1206112062
case SyntaxKind.TypeLiteral:
1206212063
case SyntaxKind.UnionType:
@@ -12072,7 +12073,7 @@ module ts {
1207212073
}
1207312074

1207412075
/** Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member. */
12075-
function serializeTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[] {
12076+
function serializeTypeOfNode(node: Node): string | string[] {
1207612077
// serialization of the type of a declaration uses the following rules:
1207712078
//
1207812079
// * The serialized type of a ClassDeclaration is "Function"
@@ -12085,10 +12086,10 @@ module ts {
1208512086
// For rules on serializing type annotations, see `serializeTypeNode`.
1208612087
switch (node.kind) {
1208712088
case SyntaxKind.ClassDeclaration: return "Function";
12088-
case SyntaxKind.PropertyDeclaration: return serializeTypeNode((<PropertyDeclaration>node).type, getGeneratedNameForNode);
12089-
case SyntaxKind.Parameter: return serializeTypeNode((<ParameterDeclaration>node).type, getGeneratedNameForNode);
12090-
case SyntaxKind.GetAccessor: return serializeTypeNode((<AccessorDeclaration>node).type, getGeneratedNameForNode);
12091-
case SyntaxKind.SetAccessor: return serializeTypeNode(getSetAccessorTypeAnnotationNode(<AccessorDeclaration>node), getGeneratedNameForNode);
12089+
case SyntaxKind.PropertyDeclaration: return serializeTypeNode((<PropertyDeclaration>node).type);
12090+
case SyntaxKind.Parameter: return serializeTypeNode((<ParameterDeclaration>node).type);
12091+
case SyntaxKind.GetAccessor: return serializeTypeNode((<AccessorDeclaration>node).type);
12092+
case SyntaxKind.SetAccessor: return serializeTypeNode(getSetAccessorTypeAnnotationNode(<AccessorDeclaration>node));
1209212093
}
1209312094
if (isFunctionLike(node)) {
1209412095
return "Function";
@@ -12097,7 +12098,7 @@ module ts {
1209712098
}
1209812099

1209912100
/** Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor. */
12100-
function serializeParameterTypesOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): (string | string[])[] {
12101+
function serializeParameterTypesOfNode(node: Node): (string | string[])[] {
1210112102
// serialization of parameter types uses the following rules:
1210212103
//
1210312104
// * If the declaration is a class, the parameters of the first constructor with a body are used.
@@ -12130,10 +12131,10 @@ module ts {
1213012131
else {
1213112132
parameterType = undefined;
1213212133
}
12133-
result[i] = serializeTypeNode(parameterType, getGeneratedNameForNode);
12134+
result[i] = serializeTypeNode(parameterType);
1213412135
}
1213512136
else {
12136-
result[i] = serializeTypeOfNode(parameters[i], getGeneratedNameForNode);
12137+
result[i] = serializeTypeOfNode(parameters[i]);
1213712138
}
1213812139
}
1213912140
return result;
@@ -12144,9 +12145,9 @@ module ts {
1214412145
}
1214512146

1214612147
/** Serializes the return type of function. Used by the __metadata decorator for a method. */
12147-
function serializeReturnTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[] {
12148+
function serializeReturnTypeOfNode(node: Node): string | string[] {
1214812149
if (node && isFunctionLike(node)) {
12149-
return serializeTypeNode((<FunctionLikeDeclaration>node).type, getGeneratedNameForNode);
12150+
return serializeTypeNode((<FunctionLikeDeclaration>node).type);
1215012151
}
1215112152
return "void 0";
1215212153
}

src/compiler/emitter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4307,7 +4307,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
43074307
let argumentsWritten = 0;
43084308
if (compilerOptions.emitDecoratorMetadata) {
43094309
if (shouldEmitTypeMetadata(node)) {
4310-
var serializedType = resolver.serializeTypeOfNode(node, getGeneratedNameForNode);
4310+
var serializedType = resolver.serializeTypeOfNode(node);
43114311
if (serializedType) {
43124312
if (writeComma) {
43134313
write(", ");
@@ -4320,7 +4320,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
43204320
}
43214321
}
43224322
if (shouldEmitParamTypesMetadata(node)) {
4323-
var serializedTypes = resolver.serializeParameterTypesOfNode(node, getGeneratedNameForNode);
4323+
var serializedTypes = resolver.serializeParameterTypesOfNode(node);
43244324
if (serializedTypes) {
43254325
if (writeComma || argumentsWritten) {
43264326
write(", ");
@@ -4338,7 +4338,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
43384338
}
43394339
}
43404340
if (shouldEmitReturnTypeMetadata(node)) {
4341-
var serializedType = resolver.serializeReturnTypeOfNode(node, getGeneratedNameForNode);
4341+
var serializedType = resolver.serializeReturnTypeOfNode(node);
43424342
if (serializedType) {
43434343
if (writeComma || argumentsWritten) {
43444344
write(", ");

src/compiler/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,9 +1416,9 @@ module ts {
14161416
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number;
14171417
getBlockScopedVariableId(node: Identifier): number;
14181418
getReferencedValueDeclaration(reference: Identifier): Declaration;
1419-
serializeTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
1420-
serializeParameterTypesOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): (string | string[])[];
1421-
serializeReturnTypeOfNode(node: Node, getGeneratedNameForNode: (Node: Node) => string): string | string[];
1419+
serializeTypeOfNode(node: Node): string | string[];
1420+
serializeParameterTypesOfNode(node: Node): (string | string[])[];
1421+
serializeReturnTypeOfNode(node: Node): string | string[];
14221422
}
14231423

14241424
export const enum SymbolFlags {

0 commit comments

Comments
 (0)