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

Add various effective UID and groups operations #21256

Merged
merged 3 commits into from Nov 14, 2017

Conversation

jez9999
Copy link
Contributor

@jez9999 jez9999 commented Nov 5, 2017

Addresses issue #21114.

@dt-bot
Copy link
Member

dt-bot commented Nov 5, 2017

types/node/index.d.ts

to authors (@DefinitelyTyped/DefinitelyTyped @parambirs @tellnes @WilcoBakker @octo-sniffle @smac89 @Flarna @mwiktorczyk @wwwy3y3 @DeividasBakanas @kjin @alvis Microsoft TypeScript (account can't be detected)). Could you review this PR?
👍 or 👎?

@RyanCavanaugh RyanCavanaugh added the Popular package This PR affects a popular package (as counted by NPM download counts). label Nov 5, 2017
@@ -477,6 +477,14 @@ declare namespace NodeJS {
getuid(): number;
setuid(id: number): void;
setuid(id: string): void;
geteuid(): number;
seteuid(id: number): void;
seteuid(id: string): void;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use an union type instead an overload, e.a. seteuid(id: string | number): void.
Would be nice if you could adapt the nearby functions setgid and setuid also...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why is a union type better than an overload?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's the way how typescript does the lookup and type detection. If you use an union type it's one function with one signature, if you use overloads then they are two functions.
Following does not transpile currently but works if union types are used:

function foo<T>(f: (p: T) => void, p: T) {
    return f(p);
}
foo(process.setgid, "foo"); // OK
foo(process.setgid, 5); // Argument of type '5' is not assignable to parameter of type 'string'

Typescript select always the last overload in such situations.

seteuid(id: number): void;
seteuid(id: string): void;
getegid(): number;
setegid(id: number): void;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as for seteuid, please use an union type instead an overload.

setegid(id: number): void;
setegid(id: string): void;
getgroups(): number[];
setgroups(groups: (string | number)[]): void;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you have to write Array<string | number> to keep lint happy.

@RyanCavanaugh
Copy link
Member

@jez9999 Please fix the failures indicated in the Travis CI log.

@@ -13,7 +13,7 @@
// Deividas Bakanas <https://github.com/DeividasBakanas>
// Kelvin Jin <https://github.com/kjin>
// Alvis HT Tang <https://github.com/alvis>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped)
Copy link
Contributor

Choose a reason for hiding this comment

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

I expect this change was not intended.

@jez9999
Copy link
Contributor Author

jez9999 commented Nov 5, 2017

I changed it to unions.

@jez9999
Copy link
Contributor Author

jez9999 commented Nov 6, 2017

@Flarna @RyanCavanaugh Can these be merged now?

@Flarna
Copy link
Contributor

Flarna commented Nov 6, 2017

@jez9999 I have no write access in this reqo so I can't help here. My part was done by reviewing the PR. I know that contributing to node typings is cumbersome currently as CI fails usually and as a result PRs are not merged for quite some time. see #20308

@jez9999
Copy link
Contributor Author

jez9999 commented Nov 9, 2017

@DanielRosenwasser Can this be merged please?

@typescript-bot
Copy link
Contributor

@jez9999 Please fix the failures indicated in the Travis CI log.

@jez9999
Copy link
Contributor Author

jez9999 commented Nov 10, 2017

I don't think that failure has anything to do with my changes.

@jez9999
Copy link
Contributor Author

jez9999 commented Nov 11, 2017

@andy-ms @ianfp @DanielRosenwasser @andypyrope @evanshortiss Somebody please merge this in! Otherwise my code using Process breaks unless i hack it temporarily. And this project needs more people reviewing/checking stuff in :-\

@evanshortiss
Copy link
Contributor

@jez9999 not sure why you've mentioned me, I'm not an org member with merge rights. Maybe a mistake?

@jez9999
Copy link
Contributor Author

jez9999 commented Nov 14, 2017

It said you merged this: 02fc61f

@typescript-bot
Copy link
Contributor

Approved by a listed owner. PR ready to merge pending express review by a maintainer.

@sandersn sandersn merged commit 15033df into DefinitelyTyped:master Nov 14, 2017
@typescript-bot typescript-bot removed this from Merge: Express in Pull Request Triage Backlog Nov 14, 2017
@evanshortiss
Copy link
Contributor

@jez9999 I see, I made the PR yep - most folks here so you could reference them by typing @DefinitelyTyped/DefinitelyTyped - a trick I learned recently 😄

@jez9999
Copy link
Contributor Author

jez9999 commented Nov 16, 2017

Luckily it's been merged now.

KSXGitHub pushed a commit to KSXGitHub/DefinitelyTyped that referenced this pull request May 12, 2018
Add various effective UID and groups operations
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).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants