Declarations for a global library incorrectly interpreted as module
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
- 52/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- node.js, typescript
- Lĩnh vực
- testing-qa, tooling
Hướng nghiên cứu
Tái hiện lỗi với các tệp index.d.ts và -tests.ts được hiển thị bằng cách chạy pnpm test, tập trung vào các trường hợp CJS và ESM của node16 báo cáo "Masquerading as CJS.". So sánh kết quả với dtslint 0.0.199 và kiểm tra đường dẫn xác thực dtslint liên quan. Hoàn tất khi các khai báo StringLib toàn cục được chấp nhận và cả hai assertion ordinalize đều pass.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I'm trying to add some types to the DefinitelyTyped repo for a very small, quite old JS library, which uses a simple global. I used dts-gen to create the project after cloning the DT repo, and I believe the structure and setup is correct.
The library looks like this:
"use strict";
(function () {
if (window && !window.StringLib) {
const suffixes = new Map([
['1', 'st'],
['2', 'nd'],
['3', 'rd'],
]);
window.StringLib = {
version: '1.0.0',
ordinalize: function (ordinal) {
const o = '' + ordinal;
const numFormat = parseInt(o, 10);
if (!o || !numFormat || numFormat < 0)
return '';
const last = o.at(-1) ?? '';
return o + (suffixes.get(last) ?? 'th');
},
};
}
}());
The index.d.ts for this library, which I believe is correct according to the TS documentation, is as follows:
/**
* @name StringLib
* @description Simple global string utilities
*/
declare namespace StringLib {
/**
* version
* @description The version of the library
*/
const version: '1.0.0';
/**
* ordinalize
* @param {string|number} ordinal The number to ordinalize
* @returns {string}
*/
function ordinalize(ordinal: string|number): string;
}
My -tests.ts file is as follows:
StringLib.ordinalize('1'); // $ExpectType string
StringLib.ordinalize(1); // $ExpectType string
I can see the types and JSDoc descriptions from the index.d.ts when I hover on the library or method in the tests file. However, when I use pnpm test the tests fail and node16 (cjs and esm) both show "Masquerading as CJS".
The exact same library, index.d.ts file, and tests used to work in dtslint version 0.0.199.
I've tried running the tests from the root of the DT repo, and also from in the types folder.
Is this a bug with dtslint? Or am I doing something wrong?
- Ngôn ngữ chính
- TypeScript
- Star
- 422
- Fork
- 238
- Merge trung bình
- 1 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 8
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
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 microsoft/DefinitelyTyped-tools
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 66/100
microsoft/DefinitelyTyped-tools#1324 · 8 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 32/100
microsoft/DefinitelyTyped-tools#1230 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
microsoft/DefinitelyTyped-tools#1229 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
mergebot staleness comments do not respect tooManyOwnersCó thể đã có người làm @copilot-swe-agent đã nhận 321 ngày trước. Đang mở
microsoft/DefinitelyTyped-tools#1218 · 1 reaction · 1 người được giao ·
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 45/100
microsoft/DefinitelyTyped-tools#1211 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của microsoft/DefinitelyTyped-tools
Issue tương tự
-
dx hacktoberfest help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
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 68/100
cloudflare/agents#2498 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Missing repro Platform: Android
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
software-mansion/react-native-reanimated#10816 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
e2e-failure ready-to-code
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
redhat-developer/rhdh-plugin-export-overlays#4129 ·
Maintainer thường phản hồi trong vòng 1 ngày