Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Multiple properties of the same type with default value

Đang mở
#1 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
typescript
Lĩnh vực
tooling

Hướng nghiên cứu

Bắt đầu với app.ts quanh dòng 100, nơi DefaultValueTypeAttributeKind.combine phát sinh ngoại lệ, và so sánh nó với các mục stack của quicktype-core TypeAttributes và GraphRewriting. Tái tạo schema bằng cách sử dụng cả hai giá trị mặc định kiểu string, sau đó xác minh rằng ví dụ chấp nhận các giá trị mặc định khác nhau mà không báo cáo các giá trị không nhất quán.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Hello,
your example does not work if you have multiple properties of the same type with default value.
For example, I've added a property of type string and I want to set a default value.

"properties": {
    "name": { "type": "string", "default": "Emmerich" },
    "test": { "type": "string", "default": "myTest" },
    "position": { "$ref": "#/definitions/Coordinates" },
    "hitPoints": { "type": "integer", "default": 100 }
},

The result is an exception

Error: Inconsistent default values
    at DefaultValueTypeAttributeKind.combine (mypath\quicktype-custom-csharp-example\app.ts:100:23)
    at combine (mypath\quicktype-custom-csharp-example\node_modules\quicktype-core\dist\TypeAttributes.js:93:25)
    at Object.mapMap (mypath\quicktype-custom-csharp-example\node_modules\quicktype-core\dist\support\Containers.js:149:23)
    at Object.combineTypeAttributes (mypath\quicktype-custom-csharp-example\node_modules\quicktype-core\dist\TypeAttributes.js:9
9:25)
    at Object.combineTypeAttributesOfTypes (mypath\quicktype-custom-csharp-example\node_modules\quicktype-core\dist\TypeUtils.js
:81:29)
    at GraphRemapBuilder.forceReconstituteTypeRef (mypath\quicktype-custom-csharp-example\node_modules\quicktype-core\dist\Graph
Rewriting.js:258:130)
    at GraphRemapBuilder.reconstituteTypeRef (mypath\quicktype-custom-csharp-example\node_modules\quicktype-core\dist\GraphRewri
ting.js:170:21)
    at TypeReconstituter.reconstitute (mypath\quicktype-custom-csharp-example\node_modules\quicktype-core\dist\GraphRewriting.js
:72:38)
    at mypath\quicktype-custom-csharp-example\node_modules\quicktype-core\dist\Type.js:428:92
    at Object.mapMap (mypath\quicktype-custom-csharp-example\node_modules\quicktype-core\dist\support\Containers.js:149:23)

Can you give us the right way to do that ?

thank you

Ngôn ngữ chính
TypeScript
Star
7
Fork
5
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của glideapps/quicktype-custom-csharp-example

Tất cả issue của glideapps/quicktype-custom-csharp-example

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.