$npx -y skills add wrtnlabs/autobe --skill fix-interfaceFix Interface and Controller compilation errors
| 1 | # Fix Interface Errors |
| 2 | |
| 3 | Fix interface and controller compilation errors according to code conventions. |
| 4 | |
| 5 | ## FORBIDDEN |
| 6 | |
| 7 | **NEVER use:** |
| 8 | - `as` keyword (type assertion) |
| 9 | - `any` type |
| 10 | |
| 11 | Fix type issues by properly defining interfaces. |
| 12 | |
| 13 | ## DO NOT MODIFY |
| 14 | |
| 15 | **Leave as-is:** |
| 16 | - `console.log` in Controller catch blocks |
| 17 | - `console.error` in Controller catch blocks |
| 18 | |
| 19 | These are intentional and should not be changed to NestJS Logger. |
| 20 | |
| 21 | --- |
| 22 | |
| 23 | ## Purpose |
| 24 | |
| 25 | Fix compilation errors in interface and controller files to ensure `npm run build:main` passes. |
| 26 | |
| 27 | ## Workflow |
| 28 | |
| 29 | ``` |
| 30 | ┌─────────────────────────────────────┐ |
| 31 | │ Step 1: Run Build │ |
| 32 | │ npm run build:main │ |
| 33 | └───────────────┬─────────────────────┘ |
| 34 | │ |
| 35 | ▼ |
| 36 | ┌─────────────────────────────────────┐ |
| 37 | │ Step 2: Parse Interface Errors │ |
| 38 | │ - Empty interfaces {} │ |
| 39 | │ - Type mismatches │ |
| 40 | │ - Missing properties │ |
| 41 | └───────────────┬─────────────────────┘ |
| 42 | │ |
| 43 | ▼ |
| 44 | ┌─────────────────────────────────────┐ |
| 45 | │ Step 3: Fix by Convention │ |
| 46 | │ - Fill empty interfaces │ |
| 47 | │ - Add typia tags │ |
| 48 | │ - Fix nullable types │ |
| 49 | └───────────────┬─────────────────────┘ |
| 50 | │ |
| 51 | ▼ |
| 52 | ┌─────────────────────────────────────┐ |
| 53 | │ Step 4: Re-run Build │ |
| 54 | │ Loop until 0 errors │ |
| 55 | └─────────────────────────────────────┘ |
| 56 | ``` |
| 57 | |
| 58 | --- |
| 59 | |
| 60 | ## Step 1: Run Build |
| 61 | |
| 62 | ```bash |
| 63 | npm run build:main 2>&1 | head -100 |
| 64 | ``` |
| 65 | |
| 66 | Capture interface-related errors. |
| 67 | |
| 68 | --- |
| 69 | |
| 70 | ## Step 2: Parse Errors |
| 71 | |
| 72 | Common error patterns: |
| 73 | - `Type '{}' is not assignable` → Empty interface |
| 74 | - `Property 'X' does not exist on type '{}'` → Empty interface |
| 75 | - `Type 'string' is not assignable to type 'string & Format<"uuid">'` → Missing typia tag |
| 76 | |
| 77 | --- |
| 78 | |
| 79 | ## Step 3: Fix by Convention |
| 80 | |
| 81 | ### Empty Interface Fix |
| 82 | Read Prisma schema and fill interface: |
| 83 | |
| 84 | ```typescript |
| 85 | // Before |
| 86 | export type IEntity = {}; |
| 87 | |
| 88 | // After |
| 89 | import { tags } from "typia"; |
| 90 | |
| 91 | export type IEntity = { |
| 92 | id: string & tags.Format<"uuid">; |
| 93 | name: string; |
| 94 | status: "active" | "inactive"; |
| 95 | created_at: string & tags.Format<"date-time">; |
| 96 | updated_at: string & tags.Format<"date-time">; |
| 97 | deleted_at: (string & tags.Format<"date-time">) | null; |
| 98 | }; |
| 99 | ``` |
| 100 | |
| 101 | ### ICreate Convention |
| 102 | ```typescript |
| 103 | export namespace IEntity { |
| 104 | export type ICreate = { |
| 105 | name: string; |
| 106 | status?: "active" | "inactive"; // optional with default |
| 107 | }; |
| 108 | } |
| 109 | ``` |
| 110 | |
| 111 | ### IUpdate Convention |
| 112 | ```typescript |
| 113 | export namespace IEntity { |
| 114 | export type IUpdate = { |
| 115 | name?: string; |
| 116 | status?: "active" | "inactive"; |
| 117 | }; |
| 118 | } |
| 119 | ``` |
| 120 | |
| 121 | ### ISummary Convention |
| 122 | ```typescript |
| 123 | export namespace IEntity { |
| 124 | export type ISummary = { |
| 125 | id: string & tags.Format<"uuid">; |
| 126 | name: string; |
| 127 | status: "active" | "inactive"; |
| 128 | created_at: string & tags.Format<"date-time">; |
| 129 | }; |
| 130 | } |
| 131 | ``` |
| 132 | |
| 133 | ### IRequest Convention |
| 134 | ```typescript |
| 135 | export namespace IEntity { |
| 136 | export type IRequest = { |
| 137 | page?: number & tags.Minimum<1>; |
| 138 | limit?: number & tags.Minimum<1> & tags.Maximum<100>; |
| 139 | search?: string; |
| 140 | status?: "active" | "inactive"; |
| 141 | }; |
| 142 | } |
| 143 | ``` |
| 144 | |
| 145 | ### Typia Tags |
| 146 | ```typescript |
| 147 | // UUID |
| 148 | id: string & tags.Format<"uuid">; |
| 149 | |
| 150 | |
| 151 | email: string & tags.Format<"email">; |
| 152 | |
| 153 | // URL |
| 154 | url: string & tags.Format<"uri">; |
| 155 | |
| 156 | // DateTime |
| 157 | created_at: string & tags.Format<"date-time">; |
| 158 | |
| 159 | // Numeric constraints |
| 160 | page: number & tags.Minimum<1>; |
| 161 | limit: number & tags.Minimum<1> & tags.Maximum<100>; |
| 162 | ``` |
| 163 | |
| 164 | ### Nullable Types |
| 165 | ```typescript |
| 166 | // Nullable field |
| 167 | deleted_at: (string & tags.Format<"date-time">) | null; |
| 168 | |
| 169 | // Optional nullable field |
| 170 | description?: string | null; |
| 171 | ``` |
| 172 | |
| 173 | ### Path Naming Fix |
| 174 | Fix redundant path segments where the same word repeats: |
| 175 | |
| 176 | ```typescript |
| 177 | // Before - redundant word in path: /{word}/{word}s |
| 178 | @Controller("{prefix}/{word}/{word}s") |
| 179 | export class {Word}{Word}sController { ... } |
| 180 | |
| 181 | // After - remove redundant segment |
| 182 | @Controller("{prefix}/{word}s") |
| 183 | export class {Word}sController { ... } |
| 184 | ``` |
| 185 | |
| 186 | Pattern to fix: |
| 187 | - `/{word}/{word}s` → `/{word}s` |
| 188 | - `/{word}/{word}-*` → `/{word}-*` or `/{word}/*` |
| 189 | |
| 190 | When fixing paths, also update: |
| 191 | 1. Controller `@Controller()` decorator |
| 192 | 2. Controller class name |
| 193 | 3. Controller file name and directory |
| 194 | 4. Related provider function names |
| 195 | 5. Test file paths and API calls |
| 196 | |
| 197 | --- |
| 198 | |
| 199 | ## Step 4: Verify |
| 200 | |
| 201 | ```bash |
| 202 | npm run build:main |
| 203 | ``` |
| 204 | |
| 205 | Repeat Steps 2-4 until no interface errors. |
| 206 | |
| 207 | --- |
| 208 | |
| 209 | ## Common Fixes |
| 210 | |
| 211 | | Error Pattern | Fix | |
| 212 | |---------------|-----| |
| 213 | | Empty interface `{}` | Read Prisma schema, define all fields | |
| 214 | | Missing typia tag | Add appropriate `tags.Format<>` | |
| 215 | | Nullable mismatch | Add `\| null` for nullable fields | |
| 216 | | Missing namespace | Add namespace with ICreate, IUpdate, etc. | |
| 217 | | Redundant path `/{word}/{word}s` | Remove duplication: `/{word}s` | |
| 218 | |
| 219 | --- |
| 220 | |
| 221 | ## Exit Condition |
| 222 | |
| 223 | - `npm run build:main` completes with no interface errors |
| 224 | - All |