ionic-team / ionic-team/ionic-framework
feat: Angular - make certain inputs `booleanAttribute`s
- Ngôn ngữ chính
- TypeScript
- Star
- 52.7k
- Fork
- 13.3k
- Merge trung bình
- 1 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 51
Mô tả
### Prerequisites
- [x] I have read the [Contributing Guidelines](https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#creating-an-issue).
- [x] I agree to follow the [Code of Conduct](https://ionicframework.com/code-of-conduct).
- [x] I have searched for [existing issues](https://github.com/ionic-team/ionic-framework/issues) that already include this feature request, without success.
### Describe the Feature Request
This issue was brought up as a bug 5 years ago in #21638, but I'm making it a feature request.
My editor complains when I don't specify the value of certain valid ionic attributes:
```html
~~~~~~ ~~~~~
```
The error is: `TS2322: Type string is not assignable to type boolean`
It compiles fine and works in my app, but in order to get rid of the complaints of my IDE, I have to specify the values of these attributes as `true`:
```html
```
### Describe the Use Case
Make these errors go away, and make this approach work! It looks much cleaner.
```html
```
### Describe Preferred Solution
Coerce the value of these attributes to booleans:
```js
// Using `coerceBooleanProperty` allows for the disabled value of a button to be set as
// `` instead of ``.
// It also allows for a string to be passed like ``.
@Input()
get button() { return this._button; }
set button(value: BooleanInput) {
this._button = coerceBooleanProperty(value);
}
private _button = false;
```
### Describe Alternatives
Give the attributes explicit values:
```html
```
### Related Code
_No response_
### Additional Information
_No response_
Hướng dẫn đóng góp
Hướng nghiên cứu
The issue does not name files, inputs, or tests. Start by locating the Angular input declarations for the Ionic attributes shown in the example, then inspect how their values are typed and processed. Done means bare attributes such as `button` and `detail` pass Angular template type checking without requiring `[attr]="true"`.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- angular, typescript
- Lĩnh vực
- frontend
- Loại issue
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 35/100