microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
101.12k stars 12.5k forks source link

Document WebGLContextAttributes #42290

Open mrchantey opened 3 years ago

mrchantey commented 3 years ago

lib Update Request

Configuration Check

My compilation target is ES2015 and my lib is the default.

Missing / Incorrect Definition

Missing documentation in interface WebGLContextAttributes lib.dom.d.ts, line 1960

Sample Code

The missing documentation results in gaps in auto-generated documentation for rendering libraries, i.e Babylon.js - EngineOptions.

Documentation Link

WebGLContextAttributes definitions can be found at WebGL Context Creation Spec.

mrchantey commented 3 years ago

Looks like this is an issue with the whatwg spec, I'll follow up there.

mrchantey commented 3 years ago

Turns out its not WHATWG but a Khronos thing. I understand that Typescript fetches a lot of the data for the lib.dom.d.ts file from remote sources, ie the WebGL pages, although it seems in this case the comments are not provided. When adding the comments (below) to comments.json, building produces the following error:

...\TypeScript-DOM-lib-generator\lib\emitter.js:185
            throw new Error("Unexpected nameless object: " + JSON.stringify(i));`
"WebGLContextAttributes": {
    "properties": {
        "property": {
            "alpha": {"comment": "/**\n * Whether the canvas contains an alpha (transparency) buffer or not. Default is true.\n */"},
            "antialias": {"comment": "/**\n * Whether to perform antialiasing. Default is true.\n*/"},
            "depth": {"comment": "/**\n * Whether the drawing buffer has a depth buffer of at least 16 bits. Default is true.\n*/"},
            "desynchronized": {"comment": "/**\n * Whether the canvas paint cycle will render seperately from the DOM event loop. Default is false.\n*/"},
            "failIfMajorPerformanceCaveat": {"comment": "/**\n * Whether context creation will fail if potential low perfomance is detected. Default is false.\n*/"},
            "powerPreference": {"comment": "/**\n * Indicates the most suitable GPU configuration to the user agent.\nCan be \"high-performance\", \"low-power\" or \"default\". Default is \"default\".\n*/"},
            "premultipliedAlpha": {"comment": "/**\n * Whether the renderer will assume that colors have premultiplied alpha. Default is true.\n*/"},
            "preserveDrawingBuffer": {"comment": "/**\n * Whether to preserve the drawing buffer until manually cleared or overwritten. Default is false.\n*/"},
            "stencil": {"comment": "/**\n * Whether the drawing buffer has a stencil buffer of at least 8 bits. Default is false.\n*/"}
        }
    }
}