Giter VIP home page Giter VIP logo

Comments (8)

stenalpjolly avatar stenalpjolly commented on August 18, 2024

@thiblahute @Ms2ger @basvanmeurs @clopez

from lightning.

wouterlucas avatar wouterlucas commented on August 18, 2024

@stenalpjolly what do you mean by "supports by default"? You mean rewrite the lightning project in TypeScript? Why? I do not see a lot of added value over regular ES6 (if this was entirely in ES5, maybe) but feel free to change my mind.

from lightning.

stenalpjolly avatar stenalpjolly commented on August 18, 2024

@wouterlucas I don't mean to rewrite everything in TypeScript. We only need to add types, something similar we have in https://github.com/DefinitelyTyped/DefinitelyTyped

from lightning.

wouterlucas avatar wouterlucas commented on August 18, 2024

Ah, okay that makes sense. I'm clearly oblivious to typescript and didn't know about the DefinitelyTyped concept but that would be a possibility. Though I wonder to what extend dts-gen would be able to generate all the type definitions automatically. If it's within a few hours of work I see no harm to look into it, but if its a major undertaking and since we have no real usage ourselves in typescript at the moment I don't think I can justify spending days on it.

from lightning.

g-zachar avatar g-zachar commented on August 18, 2024

Lightning's architecture doesn't go too well with TypeScript's type definitions, however I understand this could be quite neat addition and definitely worth considering in the future. Right now it's low priority.

from lightning.

octogonz avatar octogonz commented on August 18, 2024

Though I wonder to what extend dts-gen would be able to generate all the type definitions automatically.

Very unlikely that this would provide a satisfactory experience. TypeScript's type system is very rich, so there's usually lots of semantic information that cannot be inferred from code automatically. A human needs to author it. TypeScript is excellent at describing legacy APIs that were not designed for type safety, which is partly why it's so popular compared to other JavaScript type checkers.

I don't mean to rewrite everything in TypeScript. We only need to add types, something similar we have in https://github.com/DefinitelyTyped/DefinitelyTyped

We can do it via DefinitelyTyped, but this means @types/wpe-lightning and wpe-lightning would be managed in separate GitHub repos. Where possible it's generally recommended for the package owner to include typings. That way when you add a new API, you can make sure to add the corresponding typings in the same PR.

The mechanics are pretty simple -- we'd add a "typings" field to your package.json that points to some .d.ts files describing the APIs. The .mjs files would not need to change at all.

@g-zachar I might be willing to help out with this. If someone contributed a PR that adds TypeScript typings for wpe-lightning, would you accept it?

from lightning.

g-zachar avatar g-zachar commented on August 18, 2024

Hi @octogonz,

thanks for your input.

My main concern is that 90% of the code written are actually template objects, something like this:

class LiveDemo extends lng.Application {
    static _template() {
        return {
            Header: {
                rect: true, w: 1920, h: 50, color: 0xff005500,
                Title: {
                    x: 50, y: 30, mountY: 0.5, text: { text: 'Header' }
                }
            },
            Content: {
                y: 60,
                MyImage: {
                    x: 100,
                    y: 100,
                    src: "/Lightning/img/LngDocs_LilLightningIdle.png" 
                }
            }
        }
    };
}

So I think the main advantage of TS support would be having type checking/autocomplete on those objects' properties rather than looking them up in the documentation. I'm not sure if TS is designed to handle this sort of customised JS.

I will gladly check on any sort of POC on this if you're willing to contribute.

from lightning.

frank-weindel avatar frank-weindel commented on August 18, 2024

Implemented in #407. Released in Core 2.7.0

from lightning.

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.