Comments (8)
@thiblahute @Ms2ger @basvanmeurs @clopez
from lightning.
@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.
@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.
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.
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.
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.
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.
Implemented in #407. Released in Core 2.7.0
from lightning.
Related Issues (20)
- Bad zSorting when zIndex is the same HOT 6
- TypeScript: `getByRef()` error when using generic type param as Ref value
- Trying to access source on txLoaded triggers a max call stack exception
- TextTexture does not handle Chinese text well HOT 5
- TypeScript: Unable to override the `id` accessor of a Component with string
- this.stage.update is not working properly HOT 1
- Lightning interface to Selenium testing HOT 7
- Assumes WebGLObjects are extensible and include an Object prototype HOT 1
- Using scaleX/scaleY instead of alpha/visible to control visibility performs better HOT 12
- Class property this._tag HOT 3
- Handle loss of WebGL context HOT 4
- Text rendered at high precision levels can word-wrap incorrectly
- Incomplete regression fix on ziggo platforms HOT 2
- Direct usage of Module Augmentation with @lightningjs/core HOT 4
- Requested type change to `lightning.Component.Template` HOT 2
- Pointer Support - Apply coordinate change from browser context to canvas positioning HOT 1
- Pointer support - Event model HOT 1
- Regression with advanced text renderer and line height. HOT 1
- Regression with rendering text that uses normal spaces HOT 3
- Tree shaking HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lightning.