TypeScript Version: 3.7.3
Search Terms: array element type checking, error type checking, stops checking function argument types
Code
https://github.com/vjancik/dont-find-me-yet/blob/tsc-issue/src/index.ts#L63-L64
https://github.com/vjancik/dont-find-me-yet/blob/tsc-issue/src/index.ts#L146
createProgram doesn't enforce WebGLShader[] at all on the first argument, or seemingly any of the other arguments as well. I can add any variable in there and the array accepts it (also Playground)Expected behavior:
Types of fn. arguments on createProgram get enforced correctly.
Optional: Return type on loadShader & createProgram gets inferred correctly as ... | Error
Actual behavior:
The issue doesn't resolve even if I specify all return types on all functions manually.
Playground Link:
Playground link
Related Issues:
No, there are multiple problems and I can't pinpoint the cause in a very specific setup.
The root cause here is that WebGLShader is an empty type, which causes all sorts of downstream problems. We should do something with it so this doesn't happen.
Just a thought, but isn't it possible to have a "strict / strong" typing flag that enforces a prototype instead of just the properties (duck typing)?
I suspect there will be more and more opaque types in the future as the Web standard becomes more and more integrated with the OS.
No
Most helpful comment
No