Merge pull request #31408 from sjx233/gl

Add type definitions for gl 4.1
This commit is contained in:
Nathan Shively-Sanders
2018-12-17 09:47:17 -08:00
committed by GitHub
4 changed files with 54 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
import createContext = require("gl");
createContext(0, 0); // $ExpectType WebGLRenderingContext & StackGLExtension
createContext(0, 0, { preserveDrawingBuffer: true }); // $ExpectType WebGLRenderingContext & StackGLExtension
createContext(0, 0).getExtension("STACKGL_resize_drawingbuffer"); // $ExpectType STACKGL_resize_drawingbuffer | null
createContext(0, 0).getExtension("STACKGL_destroy_context"); // $ExpectType STACKGL_destroy_context | null
createContext(0, 0).getExtension("STACKGL_resize_drawingbuffer")!.resize(0, 0); // $ExpectType void
createContext(0, 0).getExtension("STACKGL_destroy_context")!.destroy(); // $ExpectType void
+21
View File
@@ -0,0 +1,21 @@
// Type definitions for gl 4.1
// Project: https://github.com/stackgl/headless-gl#readme
// Definitions by: sjx233 <https://github.com/sjx233>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface StackGLExtension {
getExtension(extensionName: "STACKGL_resize_drawingbuffer"): STACKGL_resize_drawingbuffer | null;
getExtension(extensionName: "STACKGL_destroy_context"): STACKGL_destroy_context | null;
}
interface STACKGL_resize_drawingbuffer {
resize(width: GLint, height: GLint): void;
}
interface STACKGL_destroy_context {
destroy(): void;
}
declare function createContext(width: number, height: number, options?: WebGLContextAttributes): WebGLRenderingContext & StackGLExtension;
export = createContext;
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"gl-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }