diff --git a/types/gl/gl-tests.ts b/types/gl/gl-tests.ts new file mode 100644 index 0000000000..9b0a64b491 --- /dev/null +++ b/types/gl/gl-tests.ts @@ -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 diff --git a/types/gl/index.d.ts b/types/gl/index.d.ts new file mode 100644 index 0000000000..ad8a7b5767 --- /dev/null +++ b/types/gl/index.d.ts @@ -0,0 +1,21 @@ +// Type definitions for gl 4.1 +// Project: https://github.com/stackgl/headless-gl#readme +// Definitions by: 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; diff --git a/types/gl/tsconfig.json b/types/gl/tsconfig.json new file mode 100644 index 0000000000..36e5d3af07 --- /dev/null +++ b/types/gl/tsconfig.json @@ -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" + ] +} diff --git a/types/gl/tslint.json b/types/gl/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/gl/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }