Skip to content

Add deprecated process.bindings to node.js #24521

Closed
mohsen1 wants to merge 5 commits intoDefinitelyTyped:masterfrom
mohsen1:patch-30
Closed

Add deprecated process.bindings to node.js #24521
mohsen1 wants to merge 5 commits intoDefinitelyTyped:masterfrom
mohsen1:patch-30

Conversation

@mohsen1
Copy link
Copy Markdown
Contributor

@mohsen1 mohsen1 commented Mar 25, 2018

nodejs/node#2768

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 provide its own types, and you can not add them.
  • 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.

If changing an existing definition:

  • Provide a URL to documentation or source code which provides context for the suggested changes: <>
  • Increase the version number in the header if appropriate.
  • If you are making substantial changes, consider adding a tslint.json containing { "extends": "dtslint/dt.json" }.

If removing a declaration:

  • If a package was never on DefinitelyTyped, you don't need to do anything. (If you wrote a package and provided types, you don't need to register it with us.)
  • Delete the package's directory.
  • Add it to notNeededPackages.json.

@mohsen1 mohsen1 changed the title Add deprecated process.binding Add deprecated process.bindings Mar 25, 2018
@typescript-bot typescript-bot added Popular package This PR affects a popular package (as counted by NPM download counts). Awaiting reviewer feedback labels Mar 25, 2018
@typescript-bot
Copy link
Copy Markdown
Contributor

typescript-bot commented Mar 25, 2018

@mohsen1 Thank you for submitting this PR!

🔔 @parambirs @tellnes @WilcoBakker @octo-sniffle @smac89 @Flarna @mwiktorczyk @wwwy3y3 @DeividasBakanas @kjin @alvis @OliverJAsh @eps1lon @Hannes-Magnusson-CK @jkomyno @ajafff @hoo29 - please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead.

@typescript-bot
Copy link
Copy Markdown
Contributor

typescript-bot commented Mar 25, 2018

@mohsen1 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. Thank you!

Copy link
Copy Markdown
Contributor

@ajafff ajafff left a comment

Choose a reason for hiding this comment

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

Why add it if it's already deprecated? Without the type declaration you cannot use it anyway.

Also note that the PR you linked is about process.bindings, which is a function.

@mohsen1
Copy link
Copy Markdown
Contributor Author

mohsen1 commented Mar 27, 2018

@ajafff I've seen many deprecated APIs in this repo. I think we do add them to not break builds

@mohsen1 mohsen1 changed the title Add deprecated process.bindings Add deprecated process.bindings to node.js Mar 27, 2018
@typescript-bot
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

@Flarna Flarna left a comment

Choose a reason for hiding this comment

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

There is not process.bindings. I can find process.binding but this is actually a function taking a string

@typescript-bot typescript-bot added the Revision needed This PR needs code changes before it can be merged. label Mar 29, 2018
@mohsen1
Copy link
Copy Markdown
Contributor Author

mohsen1 commented Mar 29, 2018

@Flarna good catch! fixed!

@Flarna
Copy link
Copy Markdown
Contributor

Flarna commented Mar 29, 2018

By the way, usually internals are not added here. I recommend to use a local .d.ts file holding such extensions; e.g. something like this:

declare namespace NodeJS {
  interface Process {
    binding(internalModule: string): any;
  }
}

@typescript-bot typescript-bot removed the Revision needed This PR needs code changes before it can be merged. label Mar 29, 2018
@typescript-bot
Copy link
Copy Markdown
Contributor

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

@mohsen1
Copy link
Copy Markdown
Contributor Author

mohsen1 commented Mar 29, 2018

It's not internal. It's deprecated public api

@ajafff
Copy link
Copy Markdown
Contributor

ajafff commented Mar 29, 2018

If it's not documented, it's not intended for public use.

@mohsen1
Copy link
Copy Markdown
Contributor Author

mohsen1 commented Mar 29, 2018

It's documented in older versions.

Comment thread types/node/index.d.ts
* Using process.binding() in general should be avoided.
* The type checking methods in particular can be replaced by using util.types.
*/
binding: { [key: string]: string; };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it should be binding(internalModule: string): any;.

Comment thread types/node/index.d.ts
/**
* @deprecated
* Using process.binding() in general should be avoided.
* The type checking methods in particular can be replaced by using util.types.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's not clear to me what this comment should tell me. What related to process.binding should be replaced by util.types?

@typescript-bot typescript-bot added the Revision needed This PR needs code changes before it can be merged. label Mar 29, 2018
@mohsen1
Copy link
Copy Markdown
Contributor Author

mohsen1 commented Mar 30, 2018

I am closing this because I am convinced that we should not encourage this API usage. Thanks for your help @ajafff @Flarna

@mohsen1 mohsen1 closed this Mar 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Popular package This PR affects a popular package (as counted by NPM download counts). 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.

4 participants