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 platform field to Result, add TypeScript definition #40

Merged
merged 9 commits into from
May 17, 2019
Merged

Add platform field to Result, add TypeScript definition #40

merged 9 commits into from
May 17, 2019

Conversation

BendingBender
Copy link
Contributor

@BendingBender BendingBender commented Mar 17, 2019

Waiting for tsdjs/tsd#19

@sindresorhus
Copy link
Owner

Why are you adding a platform field? Users can just check process.platform themselves, or am I missing a use-case?

@BendingBender
Copy link
Contributor Author

BendingBender commented Mar 17, 2019

It's for the discriminated union type in TypeScript to work correctly.

This way, no null checks are needed, just a check for a platform. You can take a look at the TS tests, its visible there.

@sindresorhus
Copy link
Owner

Ah, I see. So there's no way of doing this with the NodeJS.Platform instead? Just feels weird exposing a field just for TS usage, but if there's no other way, I'm ok with it.

index.d.ts Outdated Show resolved Hide resolved
@BendingBender BendingBender marked this pull request as ready for review March 18, 2019 19:57
@BendingBender BendingBender changed the title Add platform field to Result, add TypeScript definition WIP: Add platform field to Result, add TypeScript definition Mar 18, 2019
@sindresorhus
Copy link
Owner

@BendingBender This still has WIP: in the title, but it looks ready to me. Is there anything else left or is the title just outdated?

@BendingBender
Copy link
Contributor Author

BendingBender commented Mar 20, 2019

Waiting for tsdjs/tsd#19. Otherwise the expectError statements will fail in the test.

@BendingBender BendingBender changed the title WIP: Add platform field to Result, add TypeScript definition Add platform field to Result, add TypeScript definition Mar 20, 2019
@sindresorhus
Copy link
Owner

Can you update this to use CommonJS-compatible syntax?

Also needs to be updated for f06f7e3

@BendingBender
Copy link
Contributor Author

BendingBender commented Mar 25, 2019

Waiting for tsdjs/tsd#20.

@BendingBender BendingBender changed the title Add platform field to Result, add TypeScript definition WIP: Add platform field to Result, add TypeScript definition Mar 25, 2019
@BendingBender BendingBender changed the title WIP: Add platform field to Result, add TypeScript definition Add platform field to Result, add TypeScript definition Apr 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants