Skip to content

Commit

Permalink
Merge pull request #408 from jecraig/407-fix
Browse files Browse the repository at this point in the history
Made the exports into explicitly types
  • Loading branch information
spencermountain authored Feb 6, 2024
2 parents 84a4b61 + dea71aa commit 4fe5898
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
15 changes: 7 additions & 8 deletions types/constraints.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,22 @@ export type Format =
| 'nice-full'
| string


export interface I18nOptions {
/** Alternatives to Monday, Tuesday..*/
days?: {
short: string[],
long: string[],
short: string[]
long: string[]
}
/** Alternatives to Jan, Feb..*/
months?: {
short: string[],
long: string[],
short: string[]
long: string[]
}
/** Alternatives to am, pm*/
ampm?: {
am: string,
pm: string,
am: string
pm: string
}
/** Default dayname formatting */
useTitleCase?: boolean
}
}
10 changes: 6 additions & 4 deletions types/constructors.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Spacetime, ParsableDate, TimezoneSet } from './types'
import type { Spacetime, ParsableDate, TimezoneSet } from './types'

export interface SpacetimeConstructorOptions {
/** javascript dates use millisecond-epochs, instead of second-epochs, like some other languages. This is a common bug, and by default spacetime warns if you set an epoch within January 1970. to disable set to true */
Expand Down Expand Up @@ -54,7 +54,11 @@ export interface SpacetimeConstructor {
* @param timezone Optional timezone. If omitted uses the browser timezone.
* @param options Options for silencing warnings.
*/
(parsableDate?: ParsableDate | null, timezone?: string, options?: SpacetimeConstructorOptions): Spacetime
(
parsableDate?: ParsableDate | null,
timezone?: string,
options?: SpacetimeConstructorOptions
): Spacetime
}

export interface SpacetimeStatic extends SpacetimeConstructor {
Expand Down Expand Up @@ -84,6 +88,4 @@ export interface SpacetimeStatic extends SpacetimeConstructor {

/** set as furthest-possible future date */
max: (timezone?: string, options?: SpacetimeConstructorOptions) => Spacetime

}

8 changes: 4 additions & 4 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { SpacetimeStatic } from './constructors'
import type { SpacetimeStatic } from './constructors'

declare const spacetime: SpacetimeStatic

// We need to use a single default export here so everything lines up with the actual imported object from JS
export default spacetime

export * from './constructors'
export * from './constraints'
export * from './types'
export { SpacetimeConstructor, SpacetimeConstructorOptions, SpacetimeStatic } from './constructors'
export { Format, I18nOptions, TimeUnit } from './constraints'
export { Spacetime, Diff, ParsableDate, Progress, Since, TimezoneMeta, TimezoneSet } from './types'
2 changes: 1 addition & 1 deletion types/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TimeUnit, Format, I18nOptions } from './constraints'
import type { TimeUnit, Format, I18nOptions } from './constraints'

/** a date/timezone object */
export interface Spacetime {
Expand Down

0 comments on commit 4fe5898

Please sign in to comment.