Skip to content

Commit

Permalink
docs: add lookup types limitation on custom type converter (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
micalevisk authored Oct 31, 2021
1 parent c6ac457 commit 9ab6023
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs-site/docs/mapping-configuration/custom-type-converter.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,10 @@ const destination = mapper.map(source, Destination, Source);

- Custom Type Converters are currently available **only** to `mapInitialize` aka same property names with different types. For the above example, AutoMapper does nothing when it encounters a `String` and a `Number` if `forMember` is used.
- Custom Type Converters only works with Primitive types at the moment aka `String`, `Number`, `Boolean`, and `Date`.
- Due to a Reflection limitation, if you use [TypeScript _lookup types_ (or _indexed access types_)](https://www.typescriptlang.org/docs/handbook/2/indexed-access-types.html) on either source or destination class fields, the type converter won't work unless you explicity write the target type in `@AutoMap()`. For instance, this will work:
```ts
// ...
@AutoMap({ typeFn: () => String })
value: IFoo['str']`
```
in which `interface IFoo { str: string }`

0 comments on commit 9ab6023

Please sign in to comment.