0.9.5 - Changes in definition files ".d.ts" ?

Topics: General, Language Specification
Dec 9, 2013 at 10:44 AM
Hello !

I cannot find any information on changes to .d.ts definition files in the 0.9.5 compiler. The following definition file is not compiling:

https://github.com/away3d/away3d-core-ts/blob/master/build/ref/webgl.d.ts

Throws the following error in the compiler:

/src/away/core/display3D/Context3D.ts(83,22): error TS2094: The property 'width' does not exist on value of type '(x: number, y: number, width: number, height: number) => void'.
/src/away/core/display3D/Context3D.ts(84,22): error TS2094: The property 'height' does not exist on value of type '(x: number, y: number, width: number, height: number) => void'.
/src/away/core/display3D/Context3D.ts(645,22): error TS2094: The property 'width' does not exist on value of type '(x: number, y: number, width: number, height: number) => void'.
/src/away/core/display3D/Context3D.ts(646,22): error TS2094: The property 'height' does not exist on value of type '(x: number, y: number, width: number, height: number) => void'.

Any pointers appreciated.

Thank you .
Coordinator
Dec 9, 2013 at 5:27 PM
Do you have some of the code you're using to call webgl.d.ts? The lines the errors are pointing at are in Context3D.ts and might be helpful to figure out what is causing the error.
Dec 9, 2013 at 5:36 PM
Thank you Jon.

Here are the lines causing that error from Context3D:

this._gl.viewport.width = width;
this._gl.viewport.height = height;

Link to Context3D: https://github.com/away3d/away3d-core-ts/blob/master/src/away/core/display3D/Context3D.ts

I think there might be more errors in there than that one - but that is all that is showing up for now.
Developer
Dec 12, 2013 at 10:15 PM
this._gl.viewport is a function, it doesn't have a width or height property to assign to which is exactly what the error message is saying. The old version of this code worked because it was written as an index operation:

this._gl.viewport['width'] = width;

which returns an 'any' that can then be assigned anything. Your viewport function now has a width property in the underlying JavaScript but not in the TypeScript type system. It's possible to use a merged declaration to represent the viewport function as a function with a width property but my guess is this code just wasn't correct before either.