Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

1031 - '{0}' modifier cannot appear on class elements of this kind.

🔍 Regex Patterns

regexFind: /(export|import)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/
regexReplace: $2(

💡 Suggestion

Remove invalid modifier from class method. Export and import modifiers cannot be used on class methods - they are only for module-level declarations.

📝 Examples

Example 1: Export modifier on method

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

Explanation: Remove export modifier from class method declaration

Example 2: Import modifier on method

class DataClass {
-  import process() {
+  process() {
     return 'data'
   }
}

Explanation: Remove import modifier from class method declaration

🖼️ Visual Output

Command

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

Result

docs/1031/index.ts:2:3 - error TS1031: 'export' modifier cannot appear on class elements of this kind.

2   export method() {
  ~~~~~~

OR (without --pretty flag):

docs/1031/index.ts(2,3): error TS1031: 'export' modifier cannot appear on class elements of this kind.