feat: support BigUint64Array, BigInt64Array, and GenericArray#56163
feat: support BigUint64Array, BigInt64Array, and GenericArray#56163typescript-bot merged 10 commits intoDefinitelyTyped:masterfrom manzt:add-bigint
BigUint64Array, BigInt64Array, and GenericArray#56163Conversation
|
@manzt Thank you for submitting this PR! I see this is your first time submitting to DefinitelyTyped 👋 — I'm the local bot who will help you through the process of getting things through. This is a live comment which I will keep updated. 2 packages in this PRCode ReviewsBecause this PR edits multiple packages, it can be merged once it's reviewed by a DT maintainer. You can test the changes of this PR in the Playground. Status
All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes. Diagnostic Information: What the bot saw about this PR{
"type": "info",
"now": "-",
"pr_number": 56163,
"author": "manzt",
"headCommitOid": "878b2a71ecf88689abb04856adb75a420c864c96",
"lastPushDate": "2021-10-20T14:19:32.000Z",
"lastActivityDate": "2021-10-28T10:39:13.000Z",
"mergeOfferDate": "2021-10-28T08:25:42.000Z",
"mergeRequestDate": "2021-10-28T10:39:13.000Z",
"mergeRequestUser": "manzt",
"hasMergeConflict": false,
"isFirstContribution": true,
"tooManyFiles": false,
"popularityLevel": "Well-liked by everyone",
"pkgInfo": [
{
"name": "ndarray",
"kind": "edit",
"files": [
{
"path": "types/ndarray/index.d.ts",
"kind": "definition"
},
{
"path": "types/ndarray/ndarray-tests.ts",
"kind": "test"
}
],
"owners": [
"pawsong",
"taoqf",
"axelboc"
],
"addedOwners": [],
"deletedOwners": [],
"popularityLevel": "Well-liked by everyone"
},
{
"name": "numjs",
"kind": "edit",
"files": [
{
"path": "types/numjs/numjs-tests.ts",
"kind": "test"
}
],
"owners": [
"taoqf",
"mattmm3d"
],
"addedOwners": [],
"deletedOwners": [],
"popularityLevel": "Well-liked by everyone"
}
],
"reviews": [
{
"type": "approved",
"reviewer": "orta",
"date": "2021-10-28T08:25:06.000Z",
"isMaintainer": true
},
{
"type": "approved",
"reviewer": "axelboc",
"date": "2021-10-21T13:09:03.000Z",
"isMaintainer": false
},
{
"type": "stale",
"reviewer": "rbuckton",
"date": "2021-10-19T22:11:51.000Z",
"abbrOid": "5333643"
}
],
"mainBotCommentID": 933032741,
"ciResult": "pass"
} |
|
🔔 @pawsong @taoqf @axelboc @mattmm3d — please review this PR in the next few days. Be sure to explicitly select |
|
@manzt The CI build failed! Please review the logs for more information. Once you've pushed the fixes, the build will automatically re-run. Thanks! Note: builds which are failing do not end up on the list of PRs for the DT maintainers to review. |
|
@manzt The CI build failed! Please review the logs for more information. Once you've pushed the fixes, the build will automatically re-run. Thanks! Note: builds which are failing do not end up on the list of PRs for the DT maintainers to review. |
|
@manzt The CI build failed! Please review the logs for more information. Once you've pushed the fixes, the build will automatically re-run. Thanks! Note: builds which are failing do not end up on the list of PRs for the DT maintainers to review. |
| // Axel Bocciarelli <https://github.com/axelboc> | ||
| // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
| // TypeScript Version: 2.3 | ||
| /// <reference lib="esnext.bigint" /> |
There was a problem hiding this comment.
Ah nice, I was wondering how to make bigint work without impacting projects without esnext.bigint 💯
There was a problem hiding this comment.
This isn't the correct way to handle this. By adding a lib reference, you cause every compilation that depends on your package to assume that BigInt64Array is available. A lib reference should only be added for types provided from a host or runtime (such as NodeJS), or from a polyfill/shim library that adds the functionality.
If you want to depend on a "possibly available" BigInt64Array, you can do something like this instead:
type MaybeBigInt64Array = InstanceType<typeof globalThis extends { BigInt64Array: infer T } ? T : never>;
type MaybeBigUint64Array = InstanceType<typeof globalThis extends { BigUint64Array: infer T } ? T : never>;This conditionally gets the type for BigInt64Array and BigUint64Array based on the user's settings. If they are not present, then the types are never (and are thus removed from unions), but if they are present you get the correct type.
|
@manzt One or more reviewers has requested changes. Please address their comments. I'll be back once they sign off or you've pushed new commits. Thank you! |
|
@axelboc Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review? |
|
@axelboc Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review? |
| // Axel Bocciarelli <https://github.com/axelboc> | ||
| // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
| // TypeScript Version: 2.3 | ||
| /// <reference lib="esnext.bigint" /> |
There was a problem hiding this comment.
This isn't the correct way to handle this. By adding a lib reference, you cause every compilation that depends on your package to assume that BigInt64Array is available. A lib reference should only be added for types provided from a host or runtime (such as NodeJS), or from a polyfill/shim library that adds the functionality.
If you want to depend on a "possibly available" BigInt64Array, you can do something like this instead:
type MaybeBigInt64Array = InstanceType<typeof globalThis extends { BigInt64Array: infer T } ? T : never>;
type MaybeBigUint64Array = InstanceType<typeof globalThis extends { BigUint64Array: infer T } ? T : never>;This conditionally gets the type for BigInt64Array and BigUint64Array based on the user's settings. If they are not present, then the types are never (and are thus removed from unions), but if they are present you get the correct type.
|
@manzt One or more reviewers has requested changes. Please address their comments. I'll be back once they sign off or you've pushed new commits. Thank you! |
|
@rbuckton -- thank you for the suggestion. I was not aware of the correct way to conditionally include these types. Fixed. |
|
@rbuckton Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review? |
orta
left a comment
There was a problem hiding this comment.
Agree, these changes look good now 👍🏻
|
@manzt: Everything looks good here. I am ready to merge this PR (at 878b2a7) on your behalf whenever you think it's ready. If you'd like that to happen, please post a comment saying:
and I'll merge this PR almost instantly. Thanks for helping out! ❤️ |
|
Ready to merge |
Please fill in this template.
npm test <package to test>.Select one of these and delete the others:
If changing an existing definition:
ndarraysupportsBigInt64andBigUint64data (see link above). This PR adds support for these typed arrays but preserves the default the top-level signaturendarray.Ndarraywhen the type parameters ofDataaren't defined.