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.

Typescript type declaration issue

See original GitHub issue

Hi I have an issue with using your supplied type definition.

Typescript wants me to use your exported ‘default’ function instead of using your whole module as a function.

I got the following error

error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'typeof 'express-promise-router'' has no compatible call signatures.

On the following lines

import * as Router from "express-promise-router";
const router = Router() as express.Router;

Looking at your index.d.ts I suggest you take a look at this example by the TS team, which exports a specific function declaration as the whole module.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:31 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
mormahrcommented, Jan 26, 2018

I started working on this in #51 but there is still some work to do. Best case would be finishing this tomorrow. But i don’t know how much time i have and need exactly.

1reaction
mormahrcommented, Apr 12, 2018

Please try v3.0.2-rc.1 which has the fix #51

Edit: The patch adds a default export to express-promise-router, because that is what babel, etc. are doing when transpiling es6 modules. And afaik it does not create a runtime error using 3.0.2-rc.1…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - Type Declarations - TypeScript
A declaration file provides a way to declare the existence of some types or values ... TypeScript helps with this problem by varying...
Read more >
A quick introduction to “Type Declaration” files and adding ...
In this lesson, we are going to take a closer look at type declaration files which are one of the key ingredients of...
Read more >
TypeScript — Type Declaration Files | by Makesh Kumar
Type declaration files are the files with d.ts extension, where types were declared via interface or type . These declaration files have no...
Read more >
Support for all type features in declaration files. #35822 - GitHub
This is quite a problem! Search terms. "typescript declaration file limitations" "has or is using private name" "exported class expression may ...
Read more >
Could not find a declaration file for module 'module-name ...
TypeScript requires you to describe your data, so that the compiler can check your code and find errors. The compiler will let you...
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