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

Export duration interface from definition file #9

Merged
merged 1 commit into from
Mar 11, 2019
Merged

Conversation

bhishp
Copy link
Contributor

@bhishp bhishp commented Sep 26, 2018

I am using this lib but the Duration interface is not currently exported. I parse a duration code in my project within a function and want to describe the return type of that function as Duration but as it is not exported, I do not have access to the type.

e.g.

import { parse, Duration } from 'iso8601-duration';
// ^ Complains, no exported member - Duration

export const emptyDuration: Duration = {};

export const parseDuration = (durationCode?: string): Duration => {
  if (!durationCode) {
    return emptyDuration;
  }
  try {
    return parse(durationCode);
  } catch {
    console.warn('Failed to parse durationCode: ', durationCode);
    return emptyDuration;
  }
};

I am using this lib but the Duration interface is not currently exported. I parse a duration code in my project within a function and want to describe the return type of that function as `Duration` but as it is not exported, I do not have access to the type.

e.g.

```
import { parse, Duration } from 'iso8601-duration';
// ^ Complains, no exported member - Duration

export const emptyDuration: Duration = {};

export const parseDuration = (durationCode?: string): Duration => {
  if (!durationCode) {
    return emptyDuration;
  }
  try {
    return parse(durationCode);
  } catch {
    console.warn('Failed to parse durationCode: ', durationCode);
    return emptyDuration;
  }
};
```
@tolu tolu merged commit f52bfb2 into tolu:master Mar 11, 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