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

poi: add poi types #34424

Merged
merged 6 commits into from Apr 15, 2019
Merged

poi: add poi types #34424

merged 6 commits into from Apr 15, 2019

Conversation

bolasblack
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 Apr 3, 2019

@bolasblack 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!

@typescript-bot
Copy link
Contributor

typescript-bot commented Apr 3, 2019

@bolasblack 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!

types/poi/index.d.ts Outdated Show resolved Hide resolved
@egoist
Copy link

egoist commented Apr 3, 2019

This is a more detailed list of all the options: https://github.com/egoist/poi/blob/master/core/poi/lib/utils/validateConfig.js

hotEntries?: string[];
historyApiFallback?: WebpackDevServerConfig["historyApiFallback"];
open?: boolean;
proxy?: WebpackDevServerConfig["proxy"];
Copy link

Choose a reason for hiding this comment

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

proxy can be a string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @egoist, I found proxy also support function, but I can not find the function signature both in poi documention or webpack dev server documention

Can you tell me where introduced the definition of this function?

@bolasblack
Copy link
Contributor Author

bolasblack commented Apr 3, 2019

This is a more detailed list of all the options: egoist/poi:core/poi/lib/utils/validateConfig.js@master

@egoist Thanks, I will update the Config definition after reading the code

@typescript-bot
Copy link
Contributor

typescript-bot commented Apr 3, 2019

@bolasblack 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!

@typescript-bot
Copy link
Contributor

typescript-bot commented Apr 7, 2019

@bolasblack 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!

@bolasblack
Copy link
Contributor Author

Finally...It's weird, when I execute npm run lint poi, I get error:

Error: Errors in typescript@next for external dependencies:
../uglify-js/index.d.ts(9,30): error TS7016: Could not find a declaration file for module 'source-map'. '/Users/c4605/workSpace/DefinitelyTyped/node_modules/source-map/source-map.js' implicitly has an 'any' type.
  Try `npm install @types/source-map` if it exists or add a new declaration (.d.ts) file containing `declare module 'source-map';`
../webpack/index.d.ts(30,30): error TS7016: Could not find a declaration file for module 'source-map'. '/Users/c4605/workSpace/DefinitelyTyped/node_modules/source-map/source-map.js' implicitly has an 'any' type.
  Try `npm install @types/source-map` if it exists or add a new declaration (.d.ts) file containing `declare module 'source-map';`

    at /Users/c4605/workSpace/DefinitelyTyped/node_modules/dtslint/bin/index.js:189:19
    at Generator.next (<anonymous>)
    at fulfilled (/Users/c4605/workSpace/DefinitelyTyped/node_modules/dtslint/bin/index.js:5:58)

Copy link
Contributor

@uniqueiniquity uniqueiniquity left a comment

Choose a reason for hiding this comment

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

It appears that the poi package exports a class directly, rather than a module containing the class Poi.
Therefore, you should use the constructable module template so that the library can be imported without runtime failures.

@typescript-bot typescript-bot moved this from Review to Needs Author Attention in Pull Request Status Board Apr 11, 2019
@typescript-bot typescript-bot added the Revision needed This PR needs code changes before it can be merged. label Apr 11, 2019
@typescript-bot
Copy link
Contributor

@bolasblack 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!

@bolasblack
Copy link
Contributor Author

Hi @uniqueiniquity, thanks for your reply, do you mean I'd better write all the export in a namespace, then export this namespace at the end?

@uniqueiniquity
Copy link
Contributor

uniqueiniquity commented Apr 12, 2019

@bolasblack Yes, that's correct.
My suggestion would be to do something like the following:

declare class PoiCore {
...
}

declare namespace PoiCore {
  ...
  export interface Babel {
    ...
  }
  ...
}

export = PoiCore;

Then your test should be:

  import Poi = require("poi");
  const poi = new Poi();

or something similar. It would be good to also test the usage of the types you've defined.

@typescript-bot
Copy link
Contributor

@bolasblack 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!

{
"private": true,
"dependencies": {
"cac": "~6.4.2",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @egoist, I found cac@6.5 used the default export of 'event', it will make tsc report an error: Module '"events"' has no default export.

@bolasblack
Copy link
Contributor Author

Hi @uniqueiniquity, I modified the code according to your suggestion.

@typescript-bot
Copy link
Contributor

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

@uniqueiniquity uniqueiniquity merged commit 5d38a73 into DefinitelyTyped:master Apr 15, 2019
Pull Request Status Board automation moved this from Needs Author Attention to Done Apr 15, 2019
@typescript-bot
Copy link
Contributor

I just published @types/poi@12.5.0 to npm.

@bolasblack bolasblack deleted the poi branch April 16, 2019 00:54
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

4 participants