Developer tools dump stack traces, exit codes, and jargon. Figuring out *what to do next* often means searching the same Stack Overflow answers again.
| Rule( |
| 9 | id="typescript.ts2307", |
| 10 | tool="typescript", |
| 11 | title="Cannot find module (TS2307)", |
| 12 | why="TypeScript cannot resolve a module path — missing package, wrong path, " |
| 13 | "or missing type declarations.", |
| 14 | checks=( |
| 15 | "Is the package installed?", |
| 16 | "Does the path match the file location?", |
| 17 | "Are @types/* needed for a JS library?", |
| 18 | ), |
| 19 | fixes=( |
| 20 | "npm install <package>", |
| 21 | "npm install -D @types/<package>", |
| 22 | "Fix the import path", |
| 23 | ), |
| 24 | patterns=( |
| 25 | Pattern("TS2307", kind="exact", required=True, weight=8), |
| 26 | ), |
| 27 | confidence="high", |
| 28 | secondary=("Cannot find module",), |
| 29 | ), |
| 30 | Rule( |
| 31 | id="typescript.ts2322", |
| 32 | tool="typescript", |
| 33 | title="Type is not assignable (TS2322)", |
| 34 | why="A value was assigned to a variable/prop whose type does not accept it.", |
| 35 | checks=( |
| 36 | "What are the source and target types in the error?", |
| 37 | "Is null/undefined disallowed?", |
| 38 | ), |
| 39 | fixes=( |
| 40 | "Align the value type with the declared type", |
| 41 | "Widen or narrow the type intentionally", |
| 42 | ), |
| 43 | patterns=( |
| 44 | Pattern("TS2322", kind="exact", required=True), |
| 45 | ), |
| 46 | confidence="high", |
| 47 | secondary=("is not assignable to type",), |
| 48 | ), |
| 49 | Rule( |
| 50 | id="typescript.ts2339", |
| 51 | tool="typescript", |
| 52 | title="Property does not exist (TS2339)", |
| 53 | why="Code accessed a property that is not declared on the type.", |
| 54 | checks=( |
| 55 | "Is the property name misspelled?", |
| 56 | "Is the object typed too narrowly?", |
| 57 | "Did a library API change?", |
| 58 | ), |
| 59 | fixes=( |
| 60 | "Use the correct property name", |
| 61 | "Update the type / interface to include the property", |
| 62 | ), |
| 63 | patterns=( |
| 64 | Pattern("TS2339", kind="exact", required=True), |
| 65 | ), |
| 66 | confidence="high", |
| 67 | secondary=("Property", "does not exist"), |
| 68 | ), |
| 69 | Rule( |
| 70 | id="typescript.ts2345", |
| 71 | tool="typescript", |
| 72 | title="Argument type mismatch (TS2345)", |
| 73 | why="A function was called with an argument whose type does not match the parameter type.", |
| 74 | checks=( |
| 75 | "Which parameter index is wrong?", |
| 76 | "Are optional/required args out of order?", |
| 77 | ), |
| 78 | fixes=( |
| 79 | "Pass a value matching the expected parameter type", |
| 80 | "Update the function signature if the API changed", |
| 81 | ), |
| 82 | patterns=( |
| 83 | Pattern("TS2345", kind="exact", required=True), |
| 84 | ), |
| 85 | confidence="high", |
| 86 | secondary=("Argument of type", "is not assignable"), |
| 87 | ), |
| 88 | Rule( |
| 89 | id="typescript.ts7006", |
| 90 | tool="typescript", |
| 91 | title="Parameter implicitly has an 'any' type (TS7006)", |
| 92 | why="With noImplicitAny, a parameter has no type annotation and cannot be inferred.", |
| 93 | checks=( |
| 94 | "Is noImplicitAny / strict mode enabled?", |
| 95 | "Can the type be inferred from usage?", |
| 96 | ), |
| 97 | fixes=( |
| 98 | "Add an explicit type annotation to the parameter", |
| 99 | "Or provide a typed default / context that allows inference", |
| 100 | ), |
| 101 | patterns=( |
| 102 | Pattern("TS7006", kind="exact", required=True), |
| 103 | ), |
| 104 | confidence="high", |
| 105 | secondary=("implicitly has an 'any' type",), |
| 106 | ), |
| 107 | Rule( |
| 108 | id="typescript.ts2551", |
| 109 | tool="typescript", |
| 110 | title="Property does not exist — did you mean...? (TS2551)", |
| 111 | why="A property access looks like a typo; TypeScript suggests a similar name.", |
| 112 | checks=( |
| 113 | "Does the suggested property name match intent?", |
| 114 | ), |
| 115 | fixes=( |
| 116 | "Use the suggested property name from the error message", |
| 117 | ), |
| 118 | patterns=( |
| 119 | Pattern("TS2551", kind="exact", required=True), |
| 120 | ), |
| 121 | confidence="high", |
| 122 | secondary=("Did you mean",), |
| 123 | ), |
| 124 | Rule( |
| 125 | id="typescript.cannot_find_module", |
| 126 | tool="typescript", |
| 127 | title="Cannot find module", |
| 128 | why="Module resolution failed without an explicit TS error code in the snippet.", |
| 129 | checks=( |
| 130 | "Is the dependency installed?", |
| 131 | "Are path aliases configured in tsconfig paths?", |
| 132 | ), |
| 133 | fixes=( |
| 134 | "npm install", |
| 135 | "Check tsconfig.json paths / baseUrl / moduleResolution", |
| 136 | ), |
| 137 | patterns=( |
| 138 | Pattern("Cannot find module", kind="exact", required=True), |
| 139 | Pattern( |
| 140 | r"typescript|\btsc\b|tsconfig", |
| 141 | kind="regex", |
| 142 | required=True, |
| 143 | ), |
| 144 | ), |
| 145 | confidence="medium", |
| 146 | ), |
| 147 | Rule( |
| 148 | id="typescript.type_not_assignable", |
| 149 | tool="typescript", |
| 150 | title="Type is not assignable", |
| 151 | why="TypeScript rejected an assignment due to incompatible types.", |
| 152 | checks=( |
| 153 | "Compare the reported source and target types", |
| 154 | ), |
| 155 | fixes=( |
| 156 | "Adjust types or convert the value safely", |
| 157 | ), |
| 158 | patterns=( |
| 159 | Pattern("Type is not assignable", kind="exact", required=True), |
| 160 | ), |
| 161 | confidence="medium", |
| 162 | secondary=("Type '", "is not assignable to type"), |
| 163 | ), |
| 164 | Rule( |
| 165 | id="typescript.property_does_not_exist", |
| 166 | tool="typescript", |
| 167 | title="Property does not exist on type", |
| 168 | why="A property was accessed that is missing from the declared type.", |
| 169 | checks=( |
| 170 | "Is optional chaining needed?", |
| 171 | "Should the type be extended?", |
| 172 | ), |
| 173 | fixes=( |
| 174 | "Fix the property name or update the type definition", |
| 175 | ), |
| 176 | patterns=( |
| 177 | Pattern( |
| 178 | r"Property '.+' does not exist on type", |
| 179 | kind="regex", |
| 180 | required=True, |
| 181 | ), |
| 182 | ), |
| 183 | confidence="medium", |
| 184 | ), |
| 185 | ] |