Skip to content

Commit

Permalink
chore: add deprecated of @InputBoolean
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk committed Jan 19, 2024
1 parent 8dea58b commit 94a0176
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
8 changes: 8 additions & 0 deletions packages/util/decorator/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export function toBoolean(
}

/**
* @deprecated Recommended to use the built-in `transform` and `static ngAcceptInputType_` can be removed
* - Use `@Input({ transform: booleanAttribute })` instead of `@InputBoolean()`
* - Use `@Input({ transform: (v: unknown) => (v == null ? null : booleanAttribute(v)) })` instead of `@InputBoolean(null)`
*
* Input decorator that handle a prop to do get/set automatically with toBoolean
*
* ```ts
Expand All @@ -71,6 +75,10 @@ export function toNumber(value: unknown, fallbackValue: number = 0): number {
}

/**
* @deprecated Recommended to use the built-in `transform` and `static ngAcceptInputType_` can be removed
* - Use `@Input({ transform: numberAttribute })` instead of `@InputNumber()`
* - Use `@Input({ transform: (v: unknown) => (v == null ? null : numberAttribute(v)) })` instead of `@InputNumber(null)`
*
* Input decorator that handle a prop to do get/set automatically with toNumber
*
* ```ts
Expand Down
6 changes: 5 additions & 1 deletion packages/util/decorator/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ type: Tools

## toBoolean, @InputBoolean

> Recommended to use the built-in `transform` and `static ngAcceptInputType_` can be removed
Convert to `boolean`, `@InputBoolean()` can enhance the experience of binding number attributes, for example:

```ts
Expand All @@ -24,6 +26,8 @@ The following calling methods will all be considered effective:

## toNumber, @InputNumber

> Recommended to use the built-in `transform` and `static ngAcceptInputType_` can be removed
Convert to `number`, `@InputNumber()` can enhance the experience of binding number attributes, for example:

```ts
Expand Down Expand Up @@ -61,4 +65,4 @@ class MockClass {
@ZoneRun()
run(): void {}
}
```
```
6 changes: 5 additions & 1 deletion packages/util/decorator/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ type: Tools

## toBoolean, @InputBoolean

> 建议使用内置的 `transform` 来替代,并且不再需要 `static ngAcceptInputType_`
转换 `boolean` 属性,其中 `@InputBoolean()` 可以强化布尔属性绑定的体验,例如:

```ts
Expand All @@ -24,6 +26,8 @@ type: Tools

## toNumber, @InputNumber

> 建议使用内置的 `transform` 来替代,并且不再需要 `static ngAcceptInputType_`
转换 `number` 属性,其中 `@InputNumber()` 可以强化数字属性绑定的体验,例如:

```ts
Expand Down Expand Up @@ -61,4 +65,4 @@ class MockClass {
@ZoneRun()
run(): void {}
}
```
```

0 comments on commit 94a0176

Please sign in to comment.