mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Exempt ambient [#]private from unused error (#37050)
* Exempt ambient [#]private from unused error These declarations exist to create nominality so they _must_ be unused. There should be no error for them. * Switch to fourslash test I don't know how to baseline suggestion diagnostics in the compiler tests.
This commit is contained in:
@@ -30566,7 +30566,9 @@ namespace ts {
|
||||
break;
|
||||
}
|
||||
const symbol = getSymbolOfNode(member);
|
||||
if (!symbol.isReferenced && (hasModifier(member, ModifierFlags.Private) || isNamedDeclaration(member) && isPrivateIdentifier(member.name))) {
|
||||
if (!symbol.isReferenced
|
||||
&& (hasModifier(member, ModifierFlags.Private) || isNamedDeclaration(member) && isPrivateIdentifier(member.name))
|
||||
&& !(member.flags & NodeFlags.Ambient)) {
|
||||
addDiagnostic(member, UnusedKind.Local, createDiagnosticForNode(member.name!, Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol)));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @noUnusedLocals: false
|
||||
////class greeter {
|
||||
//// [|private greeting: string;|]
|
||||
////}
|
||||
|
||||
verify.codeFix({
|
||||
description: "Remove unused declaration for: 'greeting'",
|
||||
newRangeContent: "",
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
// @noUnusedLocals: true
|
||||
// @target: esnext
|
||||
////declare class greeter {
|
||||
//// #private;
|
||||
//// private name;
|
||||
////}
|
||||
|
||||
verify.noErrors()
|
||||
Reference in New Issue
Block a user