Thoughts on the CSV ParseOptions type
Maintainer thường phản hồi trong vòng 1 ngày
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
- data
Hướng nghiên cứu
Bắt đầu từ điểm vào parse của mô-đun CSV và kiểm tra kiểu ParseOptions cùng chữ ký generic hiện tại. So sánh constraint được đề xuất cho các khóa không hợp lệ với hành vi kiểu hiện có; công việc được hoàn tất khi các lỗi chính tả như lacyQuotes bị từ chối, trong khi các tùy chọn hợp lệ và việc suy luận columns vẫn tiếp tục hoạt động.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hello, I don't know if it is intentional and what the gains are of the CSV module's options that are passed in through the parse function.
This is the function signature:
export function parse<const T extends ParseOptions>(
input: string,
options: T,
): ParseResult<ParseOptions, T>
I understand the reason for having it extend like above gives the possibility of the parser to extract the columns attribute and use that to make the resulting array "know" which keys are in object.
But the current implementation allows the options to be any record that extends the ParseOptions type, allowing developers to add extra options to the object that are then ignored if just one valid key is given, as in this example:
parse('a;b;c', { skipFirstRow: true, lacyQuotes: true })
This doesn't get caught.
This can become an issue when making typos as the TypeScript compiler doesn't catch any mistakes.
I suggest instead that we make the function signature something like this:
type ExcludeInvalidKeys<T> = Record<
Exclude<keyof T, keyof ParseOptions>,
never
>
export function parse<const T extends ParseOptions>(
input: string,
options: ExcludeInvalidKeys<T>,
): ParseResult<ParseOptions, T>
Which now correctly rejects invalid keys, but the error could be nicer. I just don't have the TypeScript-fu to do it. The error becomes:
type 'false' is not assignable to 'never'
The expected type comes from property 'lacyQuotes' which is declared here on type '{ readonly skipFirstRow: true; readonly lacyQuotes: true }' ...
- Ngôn ngữ chính
- TypeScript
- Star
- 3.6k
- Fork
- 713
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của denoland/std
-
`assertEquals` throws on structurally equal `Error` objects due to different stack traceCó thể đã có người làm @powerman2026 đã nhận 1 ngày trước. Đang mởbug needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
streams: DelimiterStream leaves delimiter bytes in the output when the delimiter spans more than two chunksCó thể đã có người làm @helmipradita đã nhận 15 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
@std/encoding: decodeAscii85 corrupts delimited data ending in "<", decodeVarint32 reads past the end of the bufferCó thể đã có người làm @helmipradita đã nhận 16 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
@std/yaml: stringify() with condenseFlow wraps already quoted keys in a second pair of quotesCó thể đã có người làm @sebxt đã nhận 35 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
@std/ini parse silently drops an entire section when the section name repeatsCó thể đã có người làm @Harsh23Kashyap đã nhận 35 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
Maintainer thường phản hồi trong vòng 1 ngày
-
security: set top-level least-privilege permissions in five workflowsCó thể đã có người làm @JonathanTSilva đã nhận hôm nay. Đang mởpriority: p2 size: xs type: security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
JonathanTSilva/jts-website#150 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] SETUP.md is out of dateĐang mởbug Needs Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
scottbenton/Iron-Link#437 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
speakeasy-api/speakeasy#2159 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
vercel-labs/ui#1066 ·
Maintainer thường phản hồi trong vòng 1 ngày