-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 plugin type definitions #418
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e6f3b88
Bump rollup to rid of @types/acorn
ypresto 4b8b23a
Move type definition to types dir
ypresto 68a4c3a
Remove trailing spaces in index.d.ts
ypresto 069c4af
Fix wrong argument types
ypresto e088cb4
Add type definitions for plugins
ypresto 3610c73
Fix wrong argument in index.d.test.ts
ypresto 1051814
Add more plugin types
ypresto 0bb72c6
Fix OptionType signature to accept format
ypresto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ coverage | |
/plugin | ||
dayjs.min.js | ||
/esm | ||
index.d.ts | ||
|
||
#dev | ||
demo.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import * as dayjs from 'dayjs' | ||
import * as dayOfYear from 'dayjs/plugin/dayOfYear' | ||
|
||
dayjs.extend(dayOfYear) | ||
|
||
dayjs('2015-01-01T00:00:00.000').dayOfYear() === 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import * as dayjs from 'dayjs' | ||
import * as isBetween from 'dayjs/plugin/isBetween' | ||
|
||
dayjs.extend(isBetween) | ||
|
||
dayjs('2010-10-20').isBetween('2010-10-19', dayjs('2010-10-25')) === true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import * as dayjs from 'dayjs' | ||
import * as isLeapYear from 'dayjs/plugin/isLeapYear' | ||
|
||
dayjs.extend(isLeapYear) | ||
|
||
dayjs('2010-10-20').isLeapYear() === false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import * as dayjs from 'dayjs' | ||
import * as isSameOrAfter from 'dayjs/plugin/isSameOrAfter' | ||
|
||
dayjs.extend(isSameOrAfter) | ||
|
||
dayjs('2010-10-20').isSameOrAfter('2010-10-19', 'year') === true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import * as dayjs from 'dayjs' | ||
import * as isSameOrBefore from 'dayjs/plugin/isSameOrBefore' | ||
|
||
dayjs.extend(isSameOrBefore) | ||
|
||
dayjs('2010-10-20').isSameOrBefore('2010-10-19', 'year') === true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import * as dayjs from 'dayjs' | ||
import * as quarterOfYear from 'dayjs/plugin/quarterOfYear' | ||
|
||
dayjs.extend(quarterOfYear) | ||
|
||
dayjs('2013-01-01T00:00:00.000').quarter() === 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import * as dayjs from 'dayjs' | ||
import * as relativeTime from 'dayjs/plugin/relativeTime' | ||
|
||
dayjs.extend(relativeTime) | ||
|
||
dayjs().fromNow().trim() | ||
dayjs().fromNow(true).trim() | ||
|
||
dayjs().from(dayjs()).trim() | ||
dayjs().from(123, true).trim() | ||
dayjs().from('2018-01-23').trim() | ||
dayjs().from(new Date(), true).trim() | ||
|
||
dayjs().toNow().trim() | ||
dayjs().toNow(true).trim() | ||
|
||
dayjs().to(dayjs()).trim() | ||
dayjs().to(123, true).trim() | ||
dayjs().to('2018-01-23').trim() | ||
dayjs().to(new Date(), true).trim() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import * as dayjs from 'dayjs' | ||
import * as weekOfYear from 'dayjs/plugin/weekOfYear' | ||
|
||
dayjs.extend(weekOfYear) | ||
|
||
dayjs('2010-10-20').week() === 43 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"noEmit": true, | ||
"lib": [ | ||
// TODO: Unfortunately, rollup brings @types/node and etc. with "dependencies", not "devDependencies". | ||
// It references Symbol type. | ||
"es5", | ||
"es2015.symbol" | ||
], | ||
"baseUrl": "./types", | ||
"paths": { | ||
"dayjs": [ "." ], | ||
"dayjs/*": [ "*" ] | ||
} | ||
}, | ||
"exclude": [ | ||
"node_modules" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { PluginFunc } from 'dayjs' | ||
|
||
declare const plugin: PluginFunc | ||
export = plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { PluginFunc } from 'dayjs' | ||
|
||
declare const plugin: PluginFunc | ||
export = plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { PluginFunc } from 'dayjs' | ||
|
||
declare const plugin: PluginFunc | ||
export = plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { PluginFunc } from 'dayjs' | ||
|
||
declare const plugin: PluginFunc | ||
export = plugin | ||
|
||
declare module 'dayjs' { | ||
interface Dayjs { | ||
dayOfYear(): number | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { PluginFunc, DateType } from 'dayjs' | ||
|
||
declare const plugin: PluginFunc | ||
export = plugin | ||
|
||
declare module 'dayjs' { | ||
interface Dayjs { | ||
isBetween(a: DateType, b: DateType): boolean | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { PluginFunc } from 'dayjs' | ||
|
||
declare const plugin: PluginFunc | ||
export = plugin | ||
|
||
declare module 'dayjs' { | ||
interface Dayjs { | ||
isLeapYear(): boolean | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { PluginFunc } from 'dayjs' | ||
|
||
declare const plugin: PluginFunc | ||
export = plugin | ||
|
||
declare module 'dayjs' { | ||
interface Dayjs { | ||
isSameOrAfter(date: DateType, unit?: OpUnitType): boolean | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { PluginFunc } from 'dayjs' | ||
|
||
declare const plugin: PluginFunc | ||
export = plugin | ||
|
||
declare module 'dayjs' { | ||
interface Dayjs { | ||
isSameOrBefore(date: DateType, unit?: OpUnitType): boolean | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { PluginFunc } from 'dayjs' | ||
|
||
declare const plugin: PluginFunc | ||
export = plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { PluginFunc } from 'dayjs' | ||
|
||
declare const plugin: PluginFunc | ||
export = plugin | ||
|
||
declare module 'dayjs' { | ||
interface Dayjs { | ||
quarter(): number | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { PluginFunc, DateType } from 'dayjs' | ||
|
||
declare const plugin: PluginFunc | ||
export = plugin | ||
|
||
declare module 'dayjs' { | ||
interface Dayjs { | ||
fromNow(withoutSuffix?: boolean): string | ||
from(compared: DateType, withoutSuffix?: boolean): string | ||
toNow(withoutSuffix?: boolean): string | ||
to(compared: DateType, withoutSuffix?: boolean): string | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { PluginFunc } from 'dayjs' | ||
|
||
declare const plugin: PluginFunc | ||
export = plugin | ||
|
||
declare module 'dayjs' { | ||
interface Dayjs { | ||
week(): number | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could be a breaking change for those, who use TS and rely on semver. I suppose it is better to increase at least minor version, or to not change naming right now at all, but leave comments that it is deprecated and will be replaced in newer versions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added type alias with
@deprecated
marker!