Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27657,6 +27657,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
return Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer;
}
else {
// Check if there's a type symbol with the same name
const typeSymbol = resolveName(node, node.escapedText, SymbolFlags.Type, /*nameNotFoundMessage*/ undefined, /*isUse*/ false);
if (typeSymbol && !(typeSymbol.flags & SymbolFlags.Value)) {
return Diagnostics.Cannot_find_name_0_1_only_refers_to_a_type_but_is_being_used_as_a_value_here;
}
Comment on lines +27660 to +27664
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This checker enhancement is unrelated to the PR's stated purpose of fixing the "Move to file" refactor for unbraced if/else statements. This appears to improve error messages when type aliases are used as values, which matches the typeAliasUsedAsValue.ts test but has no connection to the refactoring bug fix. These changes should be in a separate PR.

Copilot uses AI. Check for mistakes.
return Diagnostics.Cannot_find_name_0;
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2840,6 +2840,10 @@
"category": "Error",
"code": 2552
},
"Cannot find name '{0}'. '{1}' only refers to a type, but is being used as a value here.": {
"category": "Error",
"code": 2888
},
"Computed values are not permitted in an enum with string valued members.": {
Comment on lines +2843 to 2847
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new diagnostic message is unrelated to the PR's stated purpose of fixing the "Move to file" refactor for unbraced if/else statements. This message is about type aliases being used as values, not about refactoring. This change should be in a separate PR along with the related checker and test changes.

Suggested change
"Cannot find name '{0}'. '{1}' only refers to a type, but is being used as a value here.": {
"category": "Error",
"code": 2888
},
"Computed values are not permitted in an enum with string valued members.": {
"Computed values are not permitted in an enum with string valued members.": {
"category": "Error",
"code": 2553
},

Copilot uses AI. Check for mistakes.
"category": "Error",
"code": 2553
Expand Down
Loading
Loading