Strict types for WebGL and WebGL2
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- tooling
Research direction
Start by reviewing the proposed types in TypeScript PR #21902 and its changed files, then inspect how auto-generated typings feed into dom.generated.d.ts. Determine whether WebGL/WebGL2 declarations should be additional inputs or a separate lib option, and assess the overload and shared-supertype concerns described in the issue. Done means an agreed integration approach and appropriate strict typings.
Written by the indexing model from the issue text.
Description
Opening a new issue, as requested. See also https://github.com/Microsoft/TypeScript/pull/21902.
I wrote some strict types for WebGL/WebGL2, which would fix https://github.com/Microsoft/TypeScript/issues/5855 among others. See https://github.com/Microsoft/TypeScript/pull/21902/files.
The auto-generated typings would need to be excluded. Maybe this should be added as a separate option for the lib compiler option as it's not exactly lightweight.
I might have made some of the types too strict, for example for texImage2D I added overloads which exactly match the internalFormat/format/type combinations allowed by the WebGL spec. When calling the function with immediate values, this is fine, but calling it with values in variables is going to require as any casts. (Which could be fine, as at that point you're responsible for the correct types anyway).
Also the following would fail, because TS doesn't currently generate a common supertype (?).
declare const randomParameter: GL['ACTIVE_TEXTURE'] | GL['ALIASED_LINE_WIDTH_RANGE']
const x = gl.getParameter(randomParameter)
// no matching overload, but a return type of GL.TextureUnits | Float32Array would make sense.
Is adding the .d.ts files as additional inputFiles which are concatenated to the dom.generated.d.ts (or a separate webgl lib file) an option? I added a number of subtypes which are only implicitly in the spec: all constants are typed as a generic GLenum in spec, although there are many different subgroups which I typed explicitly. It is highly unlikely that those will be added to the IDL.
- Dominant language
- TypeScript
- Stars
- 740
- Forks
- 474
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 15
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/TypeScript-DOM-lib-generator
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
microsoft/TypeScript-DOM-lib-generator#2554 · 6 comments ·
-
lib.d.ts bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
lib.d.ts bug
Difficulty 1/5 Under an hour Newbie friendliness 68/100
microsoft/TypeScript-DOM-lib-generator#2154 · 1 reaction ·
-
lib.d.ts bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
microsoft/TypeScript-DOM-lib-generator#2107 · 5 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
microsoft/TypeScript-DOM-lib-generator#1675 · 2 comments · 1 reaction ·
All issues in microsoft/TypeScript-DOM-lib-generator
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
copse-dev/agent-pane#2953 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·