question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Types provided don't seem to work

See original GitHub issue

We can’t get our previously working code to work with the new types provided.

import * as sizeof from 'object-sizeof'; results in error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'typeof 'object-sizeof'' has no compatible call signatures. at compile time, but…

import sizeof from 'object-sizeof'; results in object_sizeof_1.default is not a function at runtime.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
toddobryan-clevercommented, Nov 27, 2018

I’ve gotten it to work, but had to make a couple of changes. I’m not sure if there’s an easier/better way to do this.

I changed the types declaration to

declare module 'object-sizeof' {
    /**
     * Calculates Bytes for the provided parameter
     *
     * @param object The given object/string/boolean/buffer
     * @returns The size
     */
    function sizeof<T>(object: T): number;

    export = sizeof;
}

Note export = instead of default.

But then my import has to be changed to the TS-only:

import sizeof = require('object-sizeof');

Maybe this is the only way to do it? I don’t know enough about TypeScript to be sure.

1reaction
cryodreamcommented, Mar 24, 2019

Does not work with the same ts(2349) error:

Cannot invoke an expression whose type lacks a call signature. Type 'typeof import("object-sizeof")' has no compatible call signatures.
Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Handle a Lack of Support at Work (And Why It's ...
In a supportive work environment, company leaders are often present and accessible to provide tips and listen to the concerns of employees.
Read more >
4 types of difficult co-workers and how to deal with ... - CNBC
Everyone wants to work in a friendly and productive environment, but sometimes even one bad co-worker can make getting your job done seem...
Read more >
Personality Disorders: Types, Causes, Symptoms & Treatment
People with personality disorders often don't realize their thoughts and behaviors ... including work, relationships and social functioning.
Read more >
Hierarchy of Controls | NIOSH - CDC
Controlling exposures to hazards in the workplace is vital to protecting workers. The hierarchy of controls is a way of determining which ...
Read more >
Troubleshoot Surface Type Cover or Keyboard
The Keyboard or Type Cover appears to disconnect or stop responding randomly. The Keyboard or Type Cover goes back and forth between working,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found