Code Monkey home page Code Monkey logo

Comments (9)

LoganDark avatar LoganDark commented on July 20, 2024 9

Heh. If you rewrote terminal-kit in TypeScript, you could easily get a JS version and a typings file. It would also be much easier to maintain on your end...

I learned TypeScript in a week, I think it would be a fun project for you. Besides, every good library has TypeScript typings. TypeScript is like JavaScript for sane developers.

I understand if you're busy though or have other things to do. No maintainer I've ever seen has the time to rewrite their library.

from terminal-kit.

katsanva avatar katsanva commented on July 20, 2024 4

@ShadSterling https://www.npmjs.com/package/@types/terminal-kit

@cronvel this feature request is implemented and can be closed now.

from terminal-kit.

jhessin avatar jhessin commented on July 20, 2024 1

Who is maintaining those type definitions - because they aren't any good anymore.

from terminal-kit.

cronvel avatar cronvel commented on July 20, 2024

@ShadSterling Sorry, but I know nothing about Typescript beside the name. Type declaration works with some formatted comment in the code?

from terminal-kit.

ShadSterling avatar ShadSterling commented on July 20, 2024

No, Typescript is a superset of javascript which gets compiled down to javascript (after checking that every value matches the declared types). The compiler also generates type declarations as separate files, so if you compile foo.ts the normal output is foo.js (containing executable javascript) and foo.d.ts (containing type declarations). The type declarations can be used to check types when importing foo into another typescript project, which is commonly done when a typescript project depends on npm modules. If the original code wasn't written in typescript, the type declarations can also be written by hand, which has been done for a large number of npm modules, the node standard library, and the standard browser apis.

So, the feature I'm requesting is handmade typescript declarations the represent the method names and expected parameter and return types for terminal-kit.

I just found this library, and I find the code completion available for typescript far more helpful than what's available for plain javascript, especially when learning a new library.

I'd be happy to contribute, but I'm not familiar enough with hand-making type declarations to get it started myself. If someone else can get it started I'll be happy to help complete it, or if no-one beats me to it I might come back and get it started myself once I know how.

from terminal-kit.

martijnthe avatar martijnthe commented on July 20, 2024

+1

from terminal-kit.

kurogelee avatar kurogelee commented on July 20, 2024

As for Low-level API, ".d.ts" content seems like below.
(...values: any[]): Terminal; might be (...values: Array<string|number|boolean|null|undefined>): Terminal;

declare module "terminal-kit" {
    export var terminal: Terminal;
    interface Terminal {
        (...values: any[]): Terminal;
        //Properties
        width: number;
        height: number;

        //Foreground colors
        defaultColor: Terminal;
        black: Terminal;
        red: Terminal;
        green: Terminal;
        yellow: Terminal;
        blue: Terminal;
        magenta: Terminal;
        cyan: Terminal;
        white: Terminal;
        brightBlack: Terminal;
        gray: Terminal;
        brightRed: Terminal;
        brightGreen: Terminal;
        brightYellow: Terminal;
        brightBlue: Terminal;
        brightMagenta: Terminal;
        brightCyan: Terminal;
        brightWhite: Terminal;
        color: Terminal;
        darkColor: Terminal;
        brightColor: Terminal;
        color256: Terminal;
        colorRgb: Terminal;
        colorRgbHex: Terminal;
        colorGrayscale: Terminal;

        //Background colors
        bgDefaultColor: Terminal;
        bgBlack: Terminal;
        bgRed: Terminal;
        bgGreen: Terminal;
        bgYellow: Terminal;
        bgBlue: Terminal;
        bgMagenta: Terminal;
        bgCyan: Terminal;
        bgWhite: Terminal;
        bgDarkColor: Terminal;
        bgBrightBlack: Terminal;
        bgGray: Terminal;
        bgBrightRed: Terminal;
        bgBrightGreen: Terminal;
        bgBrightYellow: Terminal;
        bgBrightBlue: Terminal;
        bgBrightMagenta: Terminal;
        bgBrightCyan: Terminal;
        bgColor: Terminal;
        bgBrightWhite: Terminal;
        bgBrightColor: Terminal;
        bgColor256: Terminal;
        bgColorRgb: Terminal;
        bgColorRgbHex: Terminal;
        bgColorGrayscale: Terminal;

        //Styles
        styleReset: Terminal;
        bold: Terminal;
        dim: Terminal;
        italic: Terminal;
        underline: Terminal;
        blink: Terminal;
        inverse: Terminal;
        hidden: Terminal;
        strike: Terminal;

        //Moving the Cursor
        saveCursor: Terminal;
        restoreCursor: Terminal;
        up: Terminal;
        down: Terminal;
        right: Terminal;
        left: Terminal;
        nextLine: Terminal;
        previousLine: Terminal;
        column: Terminal;
        scrollUp: Terminal;
        scrollDown: Terminal;
        scrollingRegion: Terminal;
        resetScrollingRegion: Terminal;
        moveTo: Terminal;
        move: Terminal;
        hideCursor: Terminal;
        tabSet: Terminal;
        tabClear: Terminal;
        tabClearAll: Terminal;
        forwardTab: Terminal;
        backwardTab: Terminal;

        //Editing the Screen
        clear: Terminal;
        eraseDisplayBelow: Terminal;
        eraseDisplayAbove: Terminal;
        eraseDisplay: Terminal;
        eraseScrollback: Terminal;
        eraseLineAfter: Terminal;
        eraseLineBefore: Terminal;
        eraseLine: Terminal;
        eraseArea: Terminal;
        insertLine: Terminal;
        deleteLine: Terminal;
        insert: Terminal;
        delete: Terminal;
        backDelete: Terminal;
        // scrollUp: Terminal;
        // scrollDown: Terminal;
        alternateScreenBuffer: Terminal;

        //Input/Output
        requestCursorLocation: Terminal;
        requestScreenSize: Terminal;
        requestColor: Terminal;
        applicationKeypad: Terminal;

        //Internal input/output (do not use directly, use grabInput() instead)
        mouseButton: Terminal;
        mouseDrag: Terminal;
        mouseMotion: Terminal;
        mouseSGR: Terminal;
        focusEvent: Terminal;

        //Operating System
        cwd: Terminal;
        windowTitle: Terminal;
        iconName: Terminal;
        notify: Terminal;

        //Modifiers
        error: Terminal;
        str: Terminal;
        noFormat: Terminal;
        markupOnly: Terminal;
        bindArgs: Terminal;

        //Misc
        reset: Terminal;
        bell: Terminal;
        setCursorColor: Terminal;
        setCursorColorRgb: Terminal;
        resetCursorColorRgb: Terminal;
        setDefaultColorRgb: Terminal;
        resetDefaultColorRgb: Terminal;
        setDefaultBgColorRgb: Terminal;
        resetDefaultBgColorRgb: Terminal;
        setHighlightBgColorRgb: Terminal;
        resetHighlightBgColorRgb: Terminal;
    }
}

from terminal-kit.

LoganDark avatar LoganDark commented on July 20, 2024

Please...

from terminal-kit.

cronvel avatar cronvel commented on July 20, 2024

@LoganDark Like I said, I know nothing about TypeScript, so someone has to do it.
Moreover, that person has to maintain it.

from terminal-kit.

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.