Typescript type declaration issue
See original GitHub issueHi 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:
- Created 6 years ago
- Comments:31 (12 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
Please try v3.0.2-rc.1 which has the fix #51
Edit: The patch adds a
default
export toexpress-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…