-
Notifications
You must be signed in to change notification settings - Fork 8
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
chore: upgrade Typescript to 5.7.2 and @types/node to 20.12.2 #104
base: master
Are you sure you want to change the base?
chore: upgrade Typescript to 5.7.2 and @types/node to 20.12.2 #104
Conversation
9627c53
to
0e7e438
Compare
src/utils/delay.ts
Outdated
@@ -1,4 +1,4 @@ | |||
export function delay<T = undefined>(ms: number, value?: T): Promise<T> { | |||
export function delay(ms: number, value?: undefined): Promise<undefined> { |
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.
Removing the generic will break usages like:
const val: string = await delay(100, 'cat');
Does something like this work? It keeps the internal API agnostic of the type of value
but external consumers have the option to return a value and have the proper return type inferred.
export function delay(ms: number, value?: undefined): Promise<undefined> { | |
export function delay(ms: number): Promise<undefined>; | |
export function delay<T>(ms: number, value: T): Promise<T>; | |
export function delay<T>(ms: number, value?: T): Promise<T | undefined> { |
src/utils/is-enum-value.ts
Outdated
@@ -2,7 +2,7 @@ | |||
* Type guard to check to see if the given value is a valid value for the enum. | |||
*/ | |||
export function isEnumValue<T>(enumType: T, value: unknown): value is T[keyof T] { | |||
return (Object.keys(enumType) as Array<keyof T>) | |||
return (Object.keys(enumType as {}) as Array<keyof T>) |
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.
as
casts can be dangerous. As such, we avoid them if at all possible. Would adjusting the function signature to the following example remove the need for the cast?
export function isEnumValue<T extends object>(enumType: T, value: unknown): value is T[keyof T] {
tests/utils/delay.test.ts
Outdated
@@ -4,7 +4,7 @@ import { delay, isPromiseLike } from '../../src'; | |||
describe('delay', () => { | |||
|
|||
it('delays before returning a value', async () => { | |||
let after: string | null = null, | |||
let after: string | undefined | null = null, |
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.
If the types for delay
change, this may no longer be needed.
tests/utils/is-empty.test.ts
Outdated
@@ -31,7 +31,7 @@ describe('isEmpty', () => { | |||
expect(t.isEmpty(() => {})).to.strictlyEqual(true); | |||
|
|||
// deleting all the keys from on object empties it | |||
o = { a: true }; | |||
o = { a: true } as { a?: boolean }; |
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.
Same note about as
casting.
o = { a: true } as { a?: boolean }; | |
const o: { a?: boolean } = { a: true }; |
0e7e438
to
276b464
Compare
276b464
to
8b9058a
Compare
8b9058a
to
fec0370
Compare
No description provided.