Skip to content
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

Task, AddTaskArgs and UpdateTaskArgs types are missing duration #241

Closed
thales-fukuda opened this issue Oct 11, 2023 · 4 comments · Fixed by #242
Closed

Task, AddTaskArgs and UpdateTaskArgs types are missing duration #241

thales-fukuda opened this issue Oct 11, 2023 · 4 comments · Fixed by #242
Labels
bug Something isn't working

Comments

@thales-fukuda
Copy link
Contributor

thales-fukuda commented Oct 11, 2023

Bug description

Task, AddTaskArgs, and UpdateTaskArgs are missing the type for duration property or related.

Expected behaviour

Task should have a duration property.

// src/types/entities.ts

// ...
export const BiggetThanZero =  Number.withConstraint(n => n > 0);

export type BiggerThanZero Static<typeof BiggerThanZero>

export const Unit = Union(Literal('minute'), Literal('day'))

export type Unit = Static<typeof Unit>

export const Duration = Record({
    amount: BiggerThanZero
    unit: Unit
})

export type Duration  = Static<typeof Duration>

export const Task = Record({
    // ...
   duration: Duration.Or(Null)
})

// ...

AddTaskArgs and UpdateTaskArgs should have a duration and duration_unit property.

// src/types/requests.ts

export type WithDuration = {
    duration: BiggerThanZero
    duration_unit: Unit
}

// ...

export type AddTaskArgs = AddTask | (AddTask & WithDuration)

// ...

export type UpdateTaskArgs = UpdateTask | (UpdateTask & WithDuration)

// ...

Is reproducible

Yes

To reproduce

api.getTask('[taskId]')
    .then((task) => {
        const duration = task.duration // <- ts-error: Property 'duration' does not exist on
                                       //  type '{ id: string; order: number. ... }'

        console.log(duration)
    })

Version information

  • Package version: 2.1.2
  • Node version: 18.18.0
  • Bun version: 1.0.2

Additional information

There is an issue open on the Python API repository for the same thing: Doist/todoist-api-python#108

@thales-fukuda thales-fukuda added the bug Something isn't working label Oct 11, 2023
@henningmu
Copy link
Contributor

Thank you for the report @thales-fukuda. Is this something you'd like to create a PR for?

@thales-fukuda
Copy link
Contributor Author

Thank you for the report @thales-fukuda. Is this something you'd like to create a PR for?

I would be glad to contribute!

I couldn't find much information on contribution guidelines for this repository, is there something I should be aware of?

@henningmu
Copy link
Contributor

Thank you. There's nothing to be aware of 👍

@thales-fukuda
Copy link
Contributor Author

Hey @henningmu, here is the PR: #242

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants