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

Typescript declaration file #7

Closed
SKCrawford opened this issue Jul 10, 2019 · 3 comments
Closed

Typescript declaration file #7

SKCrawford opened this issue Jul 10, 2019 · 3 comments

Comments

@SKCrawford
Copy link

SKCrawford commented Jul 10, 2019

I've made a declaration file for typescript. There may need to be changes, but it seems pretty close to the source. Let me know what you think and I can make a pull request at some point.

https://gist.github.com/SKCrawford/9336481a7213875519a59f2487a83ce3

@SKCrawford
Copy link
Author

I thought it was working, but that was just a bug. It's still under revision...

@mathiasvr
Copy link
Owner

Hi, Thanks for taking the time to do this!
I actually created a branch, quite a while ago, that changes the source code to typescript, but did not finish it.

Since you reminded me, I have opened a PR #8 and tried to complete the work.
This way the declaration file will be generated automatically.

Currently, the declaration looks like this:

/// <reference types="node" />
import { EventEmitter } from 'events';
declare type Status = 'running' | 'paused' | 'stopped';
declare class Timer extends EventEmitter {
    private _interval;
    private _stopwatch;
    private _duration;
    private _endTime;
    private _pauseTime;
    private _status;
    private _timeoutID?;
    constructor({ interval, stopwatch }?: {
        interval?: number | undefined;
        stopwatch?: boolean | undefined;
    });
    start(duration: number, interval?: number): void;
    stop(): void;
    pause(): void;
    resume(): void;
    private _changeStatus;
    private tick;
    readonly time: number;
    readonly duration: number;
    readonly status: Status;
}
export default Timer;

I tried to compare with the file you've made, even though there are still some differences.
Does this look okay to you?

Also, I like the doc comments you made in your file. If you have time it would be great if you could pull request them directly into the source code of src/tiny-timer.ts on the ts branch.

@mathiasvr
Copy link
Owner

I have merged the PR, so closing this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants