Skip to content

Commit 91da5ae

Browse files
Reverted emit to original in error case.
1 parent adf815d commit 91da5ae

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

src/compiler/checker.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6742,9 +6742,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
67426742
function createAnonymousTypeNode(type: ObjectType): TypeNode {
67436743
const typeId = type.id;
67446744
const symbol = type.symbol;
6745-
// if (checkTruncationLength(context)) {
6746-
// return createElidedInformationPlaceholder(context);
6747-
// }
67486745
if (symbol) {
67496746
const isInstantiationExpressionType = !!(getObjectFlags(type) & ObjectFlags.InstantiationExpressionType);
67506747
if (isInstantiationExpressionType) {

src/compiler/expressionToTypeNode.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
ClassExpression,
99
CompilerOptions,
1010
ConditionalTypeNode,
11+
countWhere,
1112
Debug,
1213
Declaration,
1314
ElementAccessExpression,
@@ -99,6 +100,7 @@ import {
99100
isUnionTypeNode,
100101
isValueSignatureDeclaration,
101102
isVarConstLike,
103+
isVariableDeclaration,
102104
JSDocParameterTag,
103105
JSDocPropertyTag,
104106
JSDocSignature,
@@ -772,7 +774,7 @@ export function createSyntacticTypeNodeBuilder(
772774
if (declaredType) {
773775
resultType = syntacticResult(serializeTypeAnnotationOfDeclaration(declaredType, context, node, symbol));
774776
}
775-
else if (node.initializer) {
777+
else if (node.initializer && (symbol.declarations?.length === 1 || countWhere(symbol.declarations, isVariableDeclaration) === 1)) {
776778
if (!resolver.isExpandoFunctionDeclaration(node) && !isContextuallyTyped(node)) {
777779
resultType = typeFromExpression(node.initializer, context, /*isConstContext*/ undefined, /*requiresAddingUndefined*/ undefined, isVarConstLike(node));
778780
}

tests/baselines/reference/jsFileCompilationDuplicateVariableErrorReported.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ var x = 10; // Error reported
1414

1515
//// [out.d.ts]
1616
declare var x: string;
17-
declare var x: number;
17+
declare var x: string;

0 commit comments

Comments
 (0)