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

Added new types for trouter #33557

Merged
merged 9 commits into from
Mar 11, 2019
Merged

Added new types for trouter #33557

merged 9 commits into from
Mar 11, 2019

Conversation

demaggus83
Copy link
Contributor

Please fill in this template.

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Add or edit tests to reflect the change. (Run with npm test.)
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm run lint package-name (or tsc if no tslint.json is present).

Select one of these and delete the others:

If adding a new definition:

  • The package does not already provide its own types, or cannot have its .d.ts files generated via --declaration
  • If this is for an NPM package, match the name. If not, do not conflict with the name of an NPM package.
  • Create it with dts-gen --dt, not by basing it on an existing project.
  • tslint.json should be present, and tsconfig.json should have noImplicitAny, noImplicitThis, strictNullChecks, and strictFunctionTypes set to true.

@typescript-bot
Copy link
Contributor

typescript-bot commented Mar 3, 2019

@stahlstift Thank you for submitting this PR!

Because this is a new definition, a DefinitelyTyped maintainer will be reviewing this PR in the next few days once the Travis CI build passes.

In the meantime, if the build fails or a merge conflict occurs, I'll let you know. Have a nice day!

types/trouter/index.d.ts Outdated Show resolved Hide resolved
types/trouter/index.d.ts Show resolved Hide resolved
@typescript-bot typescript-bot moved this from Review to Needs Author Attention in Pull Request Status Board Mar 3, 2019
@typescript-bot typescript-bot added Revision needed This PR needs code changes before it can be merged. and removed Awaiting reviewer feedback labels Mar 3, 2019
@typescript-bot
Copy link
Contributor

@stahlstift One or more reviewers has requested changes. Please address their comments. I'll be back once they sign off or you've pushed new commits or comments. Thank you!

types/trouter/index.d.ts Outdated Show resolved Hide resolved

add(method: Trouter.ValidMethods, pattern: string, ...handlers: T[]): this;

all(pattern: string, ...handlers: T[]): this;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not important, but I feel like there ought to be a way to move all of these into a shared definition... possibly extending add?

Something like this but for classes, of course.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SimonSchick
I don't know if that is possible.
Do you know?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think so given the return type is this.

types/trouter/trouter-tests.ts Outdated Show resolved Hide resolved
@typescript-bot
Copy link
Contributor

🔔 @SimonSchick - Thanks for your review of this PR! Can you please look at the new code and update your review status if appropriate?

Copy link
Contributor

@lukeed lukeed left a comment

Choose a reason for hiding this comment

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

I included all HTTP methods, changing the type's name.
Also brought the definitions up to trouter@3.0.0 which was released over the weekend.

@lukeed
Copy link
Contributor

lukeed commented Mar 11, 2019

PS – I know everything here is automated, but if it helps fast-track things, I'm the library author 👍

@typescript-bot typescript-bot moved this from Needs Author Attention to Review in Pull Request Status Board Mar 11, 2019
@typescript-bot typescript-bot added Other Approved This PR was reviewed and signed-off by a community member. Awaiting reviewer feedback labels Mar 11, 2019
types/trouter/index.d.ts Outdated Show resolved Hide resolved
@typescript-bot typescript-bot moved this from Review to Needs Author Attention in Pull Request Status Board Mar 11, 2019
@typescript-bot typescript-bot removed Other Approved This PR was reviewed and signed-off by a community member. Awaiting reviewer feedback labels Mar 11, 2019
weswigham and others added 2 commits March 11, 2019 13:36
Co-Authored-By: lukeed <luke.edwards05@gmail.com>
Co-Authored-By: lukeed <luke.edwards05@gmail.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3

export interface FindResult<T> {
Copy link
Contributor

Choose a reason for hiding this comment

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

You want to put FindResult, HTTPMethod, and FindReturn into a namespace Trouter that merges with the class.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've no idea what this means, but it was done originally with contention: e83a760#r261887776

Copy link
Contributor

@weswigham weswigham Mar 11, 2019

Choose a reason for hiding this comment

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

image
It was thought unneeded because of the incorrect default export - with that gone, since it's now using export = to match runtime behavior, the namespace is actually required.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, thanks for the explanation 👍 I'll wrap it as before. However, does this mean that users won't be able to import the HTTPMethod & co?

Copy link
Contributor

Choose a reason for hiding this comment

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

You'll still be able to. import {HTTPMethod} from "trouter" will work fine - you'll just need to import Trouter = require("trouter") for the class. Trouter.HTTPMethod will also work on the latter.

Copy link
Contributor

Choose a reason for hiding this comment

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

Great, thanks for your help and patience :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry about this, I've been reviewing quite a lot of packages the last couple of days and might've mixed up exports in this case.

Copy link
Contributor

Choose a reason for hiding this comment

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

All good! I was confused to begin with 😉

@typescript-bot
Copy link
Contributor

@stahlstift The Travis CI build failed! Please review the logs for more information.

Once you've pushed the fixes, the build will automatically re-run. Thanks!

@weswigham weswigham merged commit 08257fb into DefinitelyTyped:master Mar 11, 2019
Pull Request Status Board automation moved this from Needs Author Attention to Done Mar 11, 2019
@typescript-bot
Copy link
Contributor

I just published @types/trouter@3.0.0 to npm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Definition This PR creates a new definition package. Revision needed This PR needs code changes before it can be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants