Skip to content

Commit

Permalink
fix: properly export types dependent on dayjs plugins (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeraS authored Feb 8, 2023
1 parent c4a44bc commit 8445819
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/constants/timeZone.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import {TimeZone} from '../typings';
import type {TimeZone} from '../typings';

export const UtcTimeZone: TimeZone = 'UTC';
6 changes: 4 additions & 2 deletions src/dateTime/dateTime.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import dayjs, {ConfigType} from '../dayjs';
import {DateTime, DateTimeInput, FormatInput, TimeZone} from '../typings';
import dayjs from '../dayjs';
import {STRICT, UtcTimeZone} from '../constants';
import {compareStrings} from '../utils';

import type {ConfigType} from '../dayjs';
import type {DateTime, DateTimeInput, FormatInput, TimeZone} from '../typings';

export const createDateTime = (
input?: DateTimeInput,
format?: FormatInput,
Expand Down
2 changes: 1 addition & 1 deletion src/datemath/datemath.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {each} from 'lodash';

import {dateTime} from '../dateTime';
import * as dateMath from './datemath';
import {DurationUnit, DateTime} from '../typings';
import type {DurationUnit, DateTime} from '../typings';

describe('DateMath', () => {
const spans: DurationUnit[] = ['s', 'm', 'h', 'd', 'w', 'M', 'Q', 'y'];
Expand Down
16 changes: 15 additions & 1 deletion src/dayjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,18 @@ dayjs.extend(updateLocale);
// but not vice versa, therefore it should come last
dayjs.extend(objectSupport);

export = dayjs;
export default dayjs;

export type {ConfigTypeMap, ConfigType} from 'dayjs';
export type {
arraySupport,
customParseFormat,
isoWeek,
quarterOfYear,
relativeTime,
timezone,
utc,
localizedFormat,
updateLocale,
objectSupport,
};
2 changes: 1 addition & 1 deletion src/parser/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import dayjs from '../dayjs';
import {dateTime} from '../dateTime';
import {parse, isValid} from '../datemath';
import {DateTimeOptionsWhenParsing, DateTime, DateTimeParser} from '../typings';
import type {DateTimeOptionsWhenParsing, DateTime, DateTimeParser} from '../typings';

const parseInput: DateTimeParser<DateTimeOptionsWhenParsing> = (
input,
Expand Down
6 changes: 2 additions & 4 deletions src/settings/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import dayjs from '../dayjs';
import type dayjs from '../dayjs';

// https://dayjs.gitee.io/docs/ru/customization/customization
export type UpdateLocaleConfig = Parameters<typeof dayjs.updateLocale>[1] & {
weekStart?: number;
};
export type UpdateLocaleConfig = Parameters<typeof dayjs.updateLocale>[1] | Partial<ILocale>;
2 changes: 1 addition & 1 deletion src/timeZone/timeZone.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import dayjs from '../dayjs';
import {UtcTimeZone} from '../constants';
import {TimeZone, TimeZoneOptions} from '../typings';
import type {TimeZone, TimeZoneOptions} from '../typings';

export const getTimeZone = <T extends TimeZoneOptions>(options?: T): TimeZone => {
return options?.timeZone ?? UtcTimeZone;
Expand Down
2 changes: 1 addition & 1 deletion src/typings/common.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2015 Grafana Labs
// Copyright 2021 YANDEX LLC

import {TimeZoneOptions} from './timeZone';
import type {TimeZoneOptions} from './timeZone';

export interface DateTimeOptions extends TimeZoneOptions {
/**
Expand Down
4 changes: 2 additions & 2 deletions src/typings/parser.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2015 Grafana Labs
// Copyright 2021 YANDEX LLC

import {DateTimeOptions} from './common';
import {DateTime, DateTimeInput} from './dateTime';
import type {DateTimeOptions} from './common';
import type {DateTime, DateTimeInput} from './dateTime';

export type DateTimeParser<T extends DateTimeOptions = DateTimeOptions> = (
value: DateTimeInput,
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"target": "es5",
"allowJs": false,
"declaration": true,
"importsNotUsedAsValues": "error",
"outDir": "build"
},
"include": [
Expand Down

0 comments on commit 8445819

Please sign in to comment.