Skip to content

Commit e914824

Browse files
committed
docs: fix misleading claims about TypeScript compile-time validation
Corrected Developer Experience section to accurately reflect: - @Map() uses string paths validated at RUNTIME, not compile-time - @MapFrom() provides COMPILE-TIME type checking for transformers - TypeScript validates target field types, not source property names in @Map() Changed 'Full TypeScript support' to 'Compile-time for transformers' in comparison table to be more accurate. This prevents misleading users about TypeScript's actual capabilities with decorator string literals.
1 parent 2aa6a27 commit e914824

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,27 +201,30 @@ const result = plainToInstance(UserMapper, data); // ✅ Type-safe
201201
| **Dependencies** | reflect-metadata required | **Zero dependencies** |
202202
| **Bundle Size** | ~50KB | **~15KB (70% smaller)** |
203203
| **Decorators** | Legacy (experimental) | **TC39 Stage 3 (standard)** |
204-
| **Type Safety** | Partial | **Full TypeScript support** |
204+
| **Type Safety** | Runtime only | **Compile-time for transformers** |
205205
| **JIT Compilation** || **✅ Optimized code generation** |
206206
| **Null Safety** | Manual | **Automatic optional chaining** |
207207
| **Error Handling** | Throws exceptions | **Structured error reporting** |
208208

209209
### 🎓 Developer Experience
210210

211211
```typescript
212-
//Autocomplete and type checking
212+
//Type-safe mapper definition
213213
@Mapper<UserSource, UserDTO>()
214214
class UserMapper {
215-
@Map('firstName') // ← IDE knows 'firstName' exists in UserSource
216-
name!: string; // ← IDE knows this should be string in UserDTO
215+
@Map('firstName') // String paths - runtime validation
216+
name!: string; // TypeScript validates target type
217+
218+
@MapFrom((src: UserSource) => src.firstName) // ← Full type checking!
219+
fullName!: string; // ← TypeScript knows src type and validates return type
217220
}
218221

219-
//Compile-time errors
220-
@Map('nonExistentField') //TypeScript error: Property doesn't exist
221-
invalidField!: string;
222+
//Type-safe transformers
223+
@MapFrom((src: UserSource) => src.age) //Autocomplete for 'src' properties
224+
age!: number; // ← TypeScript validates return type matches field type
222225

223-
// ✅ Refactoring support
224-
// Rename 'firstName' → IDE updates all @Map('firstName') automatically
226+
// ⚠️ Note: String paths in @Map() are validated at runtime, not compile-time
227+
// For compile-time safety, use @MapFrom() with typed functions
225228
```
226229

227230
### 🔒 Production Ready

0 commit comments

Comments
 (0)