Skip to content
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(node): 'Illegal invocation' in 'perf_hooks' module #1410

Merged
merged 3 commits into from
Oct 18, 2021

Conversation

bartlomieju
Copy link
Member

No description provided.

node/perf_hooks.ts Outdated Show resolved Hide resolved
Comment on lines 12 to 15
perfHooks.performance.measure!("test");
perfHooks.performance.mark!("test");
perfHooks.performance.clearMarks!("test");
perfHooks.performance.now!();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These not-null assertions are unlucky, but without them I get:

TS2722 [ERROR]: Cannot invoke an object which is possibly 'undefined'.
    perfHooks.performance!.now();
    ~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///Users/biwanczuk/dev/deno_std/node/perf_hooks_test.ts:13:5

@kitsonk can you take a look?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it comes from const performance: Partial<Performance>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I solved it by using Omit<> instead of Partial<>

Copy link
Contributor

@kitsonk kitsonk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, yeah, Omit<> is a lot better here.

@bartlomieju bartlomieju merged commit b83eb65 into denoland:main Oct 18, 2021
@bartlomieju bartlomieju deleted the fix_node_perf_hooks branch October 18, 2021 00:29
traceypooh pushed a commit to traceypooh/deno_std that referenced this pull request Nov 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants