@@ -24172,41 +24172,10 @@ namespace ts {
2417224172 switch (node.kind) {
2417324173 case SyntaxKind.IntersectionType:
2417424174 case SyntaxKind.UnionType:
24175- let commonEntityName: EntityName | undefined;
24176- for (let typeNode of (<UnionOrIntersectionTypeNode>node).types) {
24177- while (typeNode.kind === SyntaxKind.ParenthesizedType) {
24178- typeNode = (typeNode as ParenthesizedTypeNode).type; // Skip parens if need be
24179- }
24180- if (typeNode.kind === SyntaxKind.NeverKeyword) {
24181- continue; // Always elide `never` from the union/intersection if possible
24182- }
24183- if (!strictNullChecks && (typeNode.kind === SyntaxKind.NullKeyword || typeNode.kind === SyntaxKind.UndefinedKeyword)) {
24184- continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks
24185- }
24186- const individualEntityName = getEntityNameForDecoratorMetadata(typeNode);
24187- if (!individualEntityName) {
24188- // Individual is something like string number
24189- // So it would be serialized to either that type or object
24190- // Safe to return here
24191- return undefined;
24192- }
24175+ return getEntityNameForDecoratorMetadataFromTypeList((<UnionOrIntersectionTypeNode>node).types);
2419324176
24194- if (commonEntityName) {
24195- // Note this is in sync with the transformation that happens for type node.
24196- // Keep this in sync with serializeUnionOrIntersectionType
24197- // Verify if they refer to same entity and is identifier
24198- // return undefined if they dont match because we would emit object
24199- if (!isIdentifier(commonEntityName) ||
24200- !isIdentifier(individualEntityName) ||
24201- commonEntityName.escapedText !== individualEntityName.escapedText) {
24202- return undefined;
24203- }
24204- }
24205- else {
24206- commonEntityName = individualEntityName;
24207- }
24208- }
24209- return commonEntityName;
24177+ case SyntaxKind.ConditionalType:
24178+ return getEntityNameForDecoratorMetadataFromTypeList([(<ConditionalTypeNode>node).trueType, (<ConditionalTypeNode>node).falseType]);
2421024179
2421124180 case SyntaxKind.ParenthesizedType:
2421224181 return getEntityNameForDecoratorMetadata((<ParenthesizedTypeNode>node).type);
@@ -24217,6 +24186,44 @@ namespace ts {
2421724186 }
2421824187 }
2421924188
24189+ function getEntityNameForDecoratorMetadataFromTypeList(types: ReadonlyArray<TypeNode>): EntityName | undefined {
24190+ let commonEntityName: EntityName | undefined;
24191+ for (let typeNode of types) {
24192+ while (typeNode.kind === SyntaxKind.ParenthesizedType) {
24193+ typeNode = (typeNode as ParenthesizedTypeNode).type; // Skip parens if need be
24194+ }
24195+ if (typeNode.kind === SyntaxKind.NeverKeyword) {
24196+ continue; // Always elide `never` from the union/intersection if possible
24197+ }
24198+ if (!strictNullChecks && (typeNode.kind === SyntaxKind.NullKeyword || typeNode.kind === SyntaxKind.UndefinedKeyword)) {
24199+ continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks
24200+ }
24201+ const individualEntityName = getEntityNameForDecoratorMetadata(typeNode);
24202+ if (!individualEntityName) {
24203+ // Individual is something like string number
24204+ // So it would be serialized to either that type or object
24205+ // Safe to return here
24206+ return undefined;
24207+ }
24208+
24209+ if (commonEntityName) {
24210+ // Note this is in sync with the transformation that happens for type node.
24211+ // Keep this in sync with serializeUnionOrIntersectionType
24212+ // Verify if they refer to same entity and is identifier
24213+ // return undefined if they dont match because we would emit object
24214+ if (!isIdentifier(commonEntityName) ||
24215+ !isIdentifier(individualEntityName) ||
24216+ commonEntityName.escapedText !== individualEntityName.escapedText) {
24217+ return undefined;
24218+ }
24219+ }
24220+ else {
24221+ commonEntityName = individualEntityName;
24222+ }
24223+ }
24224+ return commonEntityName;
24225+ }
24226+
2422024227 function getParameterTypeNodeForDecoratorCheck(node: ParameterDeclaration): TypeNode | undefined {
2422124228 const typeNode = getEffectiveTypeAnnotationNode(node);
2422224229 return isRestParameter(node) ? getRestParameterElementType(typeNode) : typeNode;
0 commit comments