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)
- Regression with advanced text renderer and line height. HOT 1
- Regression with rendering text that uses normal spaces HOT 3
- Tree shaking HOT 3
- Unable to run lightning on QT5 browser HOT 3
- Bind attempt of recently deleted buffers and textures
- Alpha channel heuristic when not using ImageWorker doesn't deal with uppercase file extensions HOT 6
- Unnecessary allocations per frame HOT 3
- Enable to use webgl2 when webgl is not enabled in device. HOT 2
- Calling `chidlList.add` to add an element that's already in the childList throws "out of bounds" error
- Issue with dynamic width and height HOT 4
- Font renderer smoothness issues on EOS STBs HOT 1
- Duplicate call for `_cleanupLookupMap`
- Draw function crashing because of undefined texture
- Version 2.12.1 not including typescript types HOT 4
- Double texture freeing bug
- Text Truncated with advancedRenderer but Ellipsis Included in New Line
- Wrong calculation for `getRoundRect` stroke width HOT 2
- Lightning Core > 2.11.0 Unsupported on older browsers HOT 2
- Unable to use `monospace` system font HOT 1
- Arabic Text with English Numbers Not Rendering Correctly in RTL Format
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.