Skip to content

Commit

Permalink
docs: changes Model.md to reflect known issue
Browse files Browse the repository at this point in the history
Changes Model.md to reflect a known issue with property reflection when dealing with type aliases and extracted types. Edit - adds example suggested by @raymondfeng.  See #3863. No code changes.
  • Loading branch information
taicho authored and raymondfeng committed Oct 7, 2019
1 parent 819a660 commit 09bafe1
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions docs/site/Model.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,33 @@ The property decorator leverages LoopBack's
[metadata package](https://github.com/strongloop/loopback-next/tree/master/packages/metadata)
to determine the type of a particular property.

{% include note.html content=" Currently, property types must be specified
explicitly either on the property itself or via the `type` option of the
property decorator. Aliased types or types that extracted from a class or
interface (e.g. `public name: OtherClass['otherProperty']`) will not work
properly and will result in the property type being resolved as an empty object
rather than the intended type in the generated OpenAPI specifcation. This is due
to a limitation and flaw in the way TypeScript currently generates the metadata
that is used to generate the OpenAPI specification for the application.

Example:

```ts
export class StandardUser {
public email: string;
public anotherProperty: boolean;
}

@model()
export class UserModel {
@property()
public email: StandardUser['email']; // => results in \"__metadata(\"design:type\", Object)\" instead of \"__metadata(\"design:type\", String)\"
}
```

(see [Issue #3863](https://github.com/strongloop/loopback-next/issues/3863) for
more details) " %}

```ts
@model()
class Product extends Entity {
Expand Down

0 comments on commit 09bafe1

Please sign in to comment.