Skip to content

Commit

Permalink
Merge pull request #106 from github/add-flow-definition-file
Browse files Browse the repository at this point in the history
Add flow definition file
  • Loading branch information
Kristján Oddsson authored May 16, 2019
2 parents 4e6f95a + be1f354 commit 2582f90
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
"module": "dist/time-elements.js",
"license": "MIT",
"scripts": {
"clean": "rm -rf ./dist ./node_modules",
"clean": "rm -rf dist",
"lint": "github-lint",
"build": "rollup -c",
"prebuild": "npm run clean && npm run lint && mkdir dist",
"build": "rollup -c && cp src/index.js.flow dist/time-elements.js.flow && cp src/index.js.flow dist/time-elements-legacy.js.flow",
"prepublishOnly": "npm run pretest",
"pretest": "npm run lint && npm run build",
"pretest": "npm run build",
"prepublishOnly": "npm run build",
"test": "karma start ./test/karma.config.js"
},
"repository": "github/time-elements",
Expand Down
24 changes: 24 additions & 0 deletions src/index.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* flow strict */

declare module 'time-elements' {
declare class ExtendedTimeElement extends HTMLElement {
getFormattedTitle(): ?string;
getFormattedDate(): ?string;
}

declare export class LocalTimeElement extends ExtendedTimeElement {
getFormattedDate(): ?string;
}

declare export class RelativeTimeElement extends ExtendedTimeElement {
getFormattedDate(): ?string;
}

declare export class TimeAgoElement extends RelativeTimeElement {
getFormattedDate(): ?string;
}

declare export class TimeUntilElement extends RelativeTimeElement {
getFormattedDate(): ?string;
}
}
2 changes: 1 addition & 1 deletion src/relative-time-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import RelativeTime from './relative-time'
import ExtendedTimeElement from './extended-time-element'

export default class RelativeTimeElement extends ExtendedTimeElement {
getFormattedDate() {
getFormattedDate(): ?string {
if (this._date) {
return new RelativeTime(this._date).toString()
}
Expand Down
2 changes: 1 addition & 1 deletion src/time-ago-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import RelativeTime from './relative-time'
import RelativeTimeElement from './relative-time-element'

export default class TimeAgoElement extends RelativeTimeElement {
getFormattedDate() {
getFormattedDate(): ?string {
const format = this.getAttribute('format')
if (!this._date) return
if (format === 'micro') {
Expand Down
2 changes: 1 addition & 1 deletion src/time-until-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import RelativeTime from './relative-time'
import RelativeTimeElement from './relative-time-element'

export default class TimeUntilElement extends RelativeTimeElement {
getFormattedDate() {
getFormattedDate(): ?string {
const format = this.getAttribute('format')
if (!this._date) return
if (format === 'micro') {
Expand Down

0 comments on commit 2582f90

Please sign in to comment.