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

TypeScript typings #47

Merged
merged 8 commits into from
Jan 19, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
declare module 'express-promise-router' {

Choose a reason for hiding this comment

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

You are importing Router to the scope, and then redefining a Router function, which at least on my version of typescript leads to a conflict

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm using 2.5.3,and works fine.

Choose a reason for hiding this comment

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

I tried to upgrade to 2.6.2, and the problem still maintains itself:
node_modules/express-promise-router/index.d.ts(2,13): error TS2440: Import declaration conflicts with local declaration of 'Router'..

Still, the fix is pretty simple:

import {Router as RouterExpress, RouterOptions} from 'express'

     function Router(options?: RouterOptions): RouterExpress
 
     export = Router
 }

What do you think?

import {Router, RouterOptions} from 'express'

function Router(options?: RouterOptions): Router

export = Router
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"methods": "^1.0.0"
},
"peerDependencies": {
"@types/express": "^4.0.0",
"express": "4.x"
},
"devDependencies": {
Expand All @@ -51,6 +52,7 @@
"shared-git-hooks": "^1.2.1",
"sinon": "^4.0.0"
},
"types": "index.d.ts",
"scripts": {
"format": "prettier --write --trailing-comma es5 --print-width 120 --single-quote --tab-width 4 'lib/*.js' 'test/*.js'",
"lint": "eslint {lib,test}/**/*.js",
Expand Down