ricop / webgl.d.ts Goto Github PK
View Code? Open in Web Editor NEWA WebGL definition file for TypeScript
A WebGL definition file for TypeScript
Your definition of the interface WindowAnimationTiming from lines 517 to 529 clashes with the definition of the same in the updated lib.d.ts which comes with TypeScript 0.8.1:
C:/Program Files (x86)/Microsoft SDKs/TypeScript/0.8.1.0/lib.d.ts(6874,4): Signature for 'msCancelRequestAnimationFrame' is duplicated
Yours is better because it contains the prefixed declarations for Firefox and Chrome etc. but I'm not sure whether it's safe to edit lib.d.ts without recompiling the TypeScript compiler.
WebGL defines a bunch of emtpy interfaces to mark different types of WebGL objects that apparently have no methods. TypeScript treats interfaces with identical fields as compatible, which allows to pass for example WebGLProgram where WebGLShader is required. Actually it allows to pass any object really, because any object implements all empty interfaces. That's not cool cause we are using TypeScript to force type correctness ;).
My proposition is to translate empty every interface to declare class
construct which tightens type checking. The other solution is to leave interfaces as interfaces and add an auto-generated field based on interface name. That's not pretty but it's some alternative if one is needed.
First variant looks like this:
declare class WebGLObject {
};
declare class WebGLBuffer extends WebGLObject {
};
declare class WebGLFramebuffer extends WebGLObject {
};
declare class WebGLProgram extends WebGLObject {
};
declare class WebGLRenderbuffer extends WebGLObject {
};
declare class WebGLShader extends WebGLObject {
};
declare class WebGLTexture extends WebGLObject {
};
declare class WebGLUniformLocation {
};
The second looks like this:
interface WebGLObject {
___WebGLObject_: any;
};
interface WebGLBuffer extends WebGLObject {
___WebGLBuffer_extends_WebGLObject_: any;
};
interface WebGLFramebuffer extends WebGLObject {
___WebGLFramebuffer_extends_WebGLObject_: any;
};
interface WebGLProgram extends WebGLObject {
___WebGLProgram_extends_WebGLObject_: any;
};
interface WebGLRenderbuffer extends WebGLObject {
___WebGLRenderbuffer_extends_WebGLObject_: any;
};
interface WebGLShader extends WebGLObject {
___WebGLShader_extends_WebGLObject_: any;
};
interface WebGLTexture extends WebGLObject {
___WebGLTexture_extends_WebGLObject_: any;
};
interface WebGLUniformLocation {
___WebGLUniformLocation_: any;
};
I've created a gist with my parser for the record but I believe your parser idl2typings is more robust. (Mine is regexp-based and was hacked in one evening ;) .) https://gist.github.com/91b49468eedb09aceaee
To keep the TypeScript linter (4.7.3) happy I needed to rename bool to boolean and understand definition for FrameRequestCallback. Any help on the later would be much appreciated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.