-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(promise-kit): make strict typing compliant #3397
Conversation
// deleting p.domain may break functionality. To retain current | ||
// functionality at the expense of safety, set unsafe to true. | ||
const unsafe = false; | ||
if (unsafe) { | ||
const originalDomain = p.domain; | ||
const originalDomain = /** @type {*} */ (p).domain; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is *
an alias for any
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The convention we have in several of the packages is to use any
when we really mean any
, and reserve *
for when we mean "I can't be bothered to type this right now, so I guess I'll punt until somebody cleans up after my mess."
Given that, I'd recommend:
const originalDomain = /** @type {*} */ (p).domain; | |
const originalDomain = /** @type {any} */ (p).domain; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The convention we have in several of the packages is to use any when we really mean
any
, and reserve*
for when we mean "I can't be bothered to type this right now, so I guess I'll punt until somebody cleans up after my mess."
Cool. I didn't know that. Is it explained anywhere?
This has nothing whatsoever to do with JavaScript strict-vs-sloppy mode, right? |
None whatsoever. This is purely a type checking matter (https://www.typescriptlang.org/tsconfig#strict). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider my suggested changes, but this otherwise LGTM.
// deleting p.domain may break functionality. To retain current | ||
// functionality at the expense of safety, set unsafe to true. | ||
const unsafe = false; | ||
if (unsafe) { | ||
const originalDomain = p.domain; | ||
const originalDomain = /** @type {*} */ (p).domain; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The convention we have in several of the packages is to use any
when we really mean any
, and reserve *
for when we mean "I can't be bothered to type this right now, so I guess I'll punt until somebody cleans up after my mess."
Given that, I'd recommend:
const originalDomain = /** @type {*} */ (p).domain; | |
const originalDomain = /** @type {any} */ (p).domain; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
87dbd90
to
3ac3679
Compare
Description
@agoric/promise-kit
doesn't specify atypes
entry in itspackage.json
causingtsc
to parse its.js
source to extract jsdoc typing. This parsing would also validate this internal implementation, which would raise errors when the consumer of the package is instrict
mode (mostlynoImplicitAny
).Security Considerations
There is a single runtime change from
p.domain
to'domain' in p
which is actually more correct.Documentation Considerations
N/A
Testing Considerations
We should enable
"strict": true
for this package'sjsconfig.json
but that currently isn't possible becauseglobal.HandledPromise
is only declared in@agoric/eventual-send
which is not imported directly bypromise-kit
.