Giter VIP home page Giter VIP logo

Comments (6)

jefbarn avatar jefbarn commented on August 16, 2024 1

Put the file somewhere in your src directory (i.e. somewhere that your tsconfig will compile, I have a src/types folder I put all this stuff in), and just
import 'moment-recur'

from moment-recur.

jefbarn avatar jefbarn commented on August 16, 2024 1

@dessalines This project is not being maintained, you can check out my moment-recur-ts fork for complete typescript support.

from moment-recur.

jefbarn avatar jefbarn commented on August 16, 2024

Assuming typescript, you need a moment-recur.d.ts
Here's mine:

import { Moment, MomentInput } from 'moment'

declare module 'moment' {

  interface MomentRecurrence {
    (start: MomentInput, end: MomentInput): MomentRecurrence
    every (interval: number | (string | number)[], intervalType?: string): MomentRecurrence
    fromDate (from: MomentInput): MomentRecurrence
    all (format: string): string[]

    day (): MomentRecurrence
    days (): MomentRecurrence
    week (): MomentRecurrence
    weeks (): MomentRecurrence
    month (): MomentRecurrence
    months (): MomentRecurrence
    year (): MomentRecurrence
    years (): MomentRecurrence

    dayOfWeek (): MomentRecurrence
    daysOfWeek (): MomentRecurrence
    dayOfMonth (): MomentRecurrence
    daysOfMonth (): MomentRecurrence
    weekOfMonth (): MomentRecurrence
    weeksOfMonth (): MomentRecurrence
    weekOfYear (): MomentRecurrence
    weeksOfYear (): MomentRecurrence
    monthOfYear (): MomentRecurrence
    monthsOfYear (): MomentRecurrence
    weeksOfMonthByDay (): MomentRecurrence
  }

  interface Moment {
    recur (start: MomentInput, end: MomentInput): MomentRecurrence
  }

  const recur: MomentRecurrence
}

from moment-recur.

shaolinshaosson avatar shaolinshaosson commented on August 16, 2024

Thank you, still strugling with trying to get it working :(
Should I place that file in "node_modules/moment_recur"?
And how should I type the import ?

from moment-recur.

shaolinshaosson avatar shaolinshaosson commented on August 16, 2024

Much obliged @jefbarn, worked perfectly!

from moment-recur.

dessalines avatar dessalines commented on August 16, 2024

This should be reopened, and these typings added to the project.

from moment-recur.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.