Skip to content

Commit

Permalink
fix(49993): skip the quick fix for an expression with an enum type (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
a-tarasyuk committed Sep 21, 2022
1 parent 2644f28 commit 7a3de81
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/services/codefixes/fixAddMissingMember.ts
Expand Up @@ -257,7 +257,7 @@ namespace ts.codefix {
}

const enumDeclaration = find(symbol.declarations, isEnumDeclaration);
if (enumDeclaration && !isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
if (enumDeclaration && !(leftExpressionType.flags & TypeFlags.EnumLike) && !isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
return { kind: InfoKind.Enum, token, parentDeclaration: enumDeclaration };
}

Expand Down
7 changes: 7 additions & 0 deletions tests/cases/fourslash/codeFixAddMissingEnumMember13.ts
@@ -0,0 +1,7 @@
/// <reference path="fourslash.ts" />

////enum E { A, B }
////declare var a: E;
////a.C;

verify.not.codeFixAvailable("fixMissingMember");

0 comments on commit 7a3de81

Please sign in to comment.