Skip to content

Latest commit

 

History

History
56 lines (44 loc) · 1.14 KB

File metadata and controls

56 lines (44 loc) · 1.14 KB

1028 - Accessibility modifier already seen.

🔍 Regex Patterns

regexFind: /(public|private|protected)\s+(public|private|protected)\s+/
regexReplace: $1 

💡 Suggestion

Remove duplicate accessibility modifier. Each class member can only have one accessibility modifier (public, private, or protected).

📝 Examples

Example 1: Duplicate public modifier

class MyClass {
-  public public method() {
+  public method() {
     return 'test'
   }
}

Explanation: Remove duplicate public modifier from method declaration

Example 2: Duplicate private modifier

class DataClass {
-  private private property = 'data'
+  private property = 'data'
}

Explanation: Remove duplicate private modifier from property declaration

🖼️ Visual Output

Command

npx tsc ./docs/1028/index.ts --noEmit --pretty

Result

docs/1028/index.ts:2:10 - error TS1028: Accessibility modifier already seen.

2   public public method() {
          ~~~~~~

OR (without --pretty flag):

docs/1028/index.ts(2,10): error TS1028: Accessibility modifier already seen.