JoshuaKGoldberg / JoshuaKGoldberg/TypeStat

JSDoc type info are not read when converting from js to ts

Open
#1,157 1 comment 1 reaction 0 assignees View on GitHub
area: fixers status: accepting prs type: enhancement
Dominant language
TypeScript
Stars
2.3k
Forks
47
Avg merge
15h 55m
Merged PRs (30d)
21

Description

### 🐛 Bug Report

- TypeStat version: 0.6.3
- TypeScript version: 4.7.4
- Node version: v16.15.0

original js file
```js
/*
* Utility function to compile a WebGL Vertex or Fragment shader.
*
* @param {WebGLRenderingContext} gl - the webgl context fo which to build the shader.
* @param {String} shaderSource - A string of shader code to compile.
* @param {number} shaderType - Shader type, either WebGLRenderingContext.VERTEX_SHADER or WebGLRenderingContext.FRAGMENT_SHADER.
*
* @return {WebGLShader} A compiled shader.
*
*/
export function compileShader(gl, shaderSource, shaderType) {
let shader = gl.createShader(shaderType);
gl.shaderSource(shader, shaderSource);
gl.compileShader(shader);
let success = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
if (!success) {
throw "could not compile shader:" + gl.getShaderInfoLog(shader);
}
return shader;
}
```

#### Actual Behavior

```ts
/*
* Utility function to compile a WebGL Vertex or Fragment shader.
*
* @param {WebGLRenderingContext} gl - the webgl context fo which to build the shader.
* @param {String} shaderSource - A string of shader code to compile.
* @param {number} shaderType - Shader type, either WebGLRenderingContext.VERTEX_SHADER or WebGLRenderingContext.FRAGMENT_SHADER.
*
* @return {WebGLShader} A compiled shader.
*
*/
export function compileShader(gl: { VERTEX_SHADER?: any; FRAGMENT_SHADER?: any; getParameter?: (arg0: any) => any; MAX_TEXTURE_IMAGE_UNITS?: any; texImage2D?: (arg0: any,arg1: number,arg2: any,arg3: any,arg4: any,arg5: number,arg6: any,arg7: any,arg8: any) => void; TEXTURE_2D?: any; RGBA?: any; canvas?: { width: any; height: any; }; UNSIGNED_BYTE?: any; createFramebuffer?: () => any; bindFramebuffer?: (arg0: any,arg1: any) => void; FRAMEBUFFER?: any; framebufferTexture2D?: (arg0: any,arg1: any,arg2: any,arg3: any,arg4: number) => void; COLOR_ATTACHMENT0?: any; TEXTURE0?: number; getUniformLocation?: (arg0: any,arg1: any) => any; getAttribLocation?: (arg0: any,arg1: string) => any; createBuffer?: () => any; bindBuffer?: (arg0: any,arg1: any) => void; ARRAY_BUFFER?: any; enableVertexAttribArray?: (arg0: any) => void; vertexAttribPointer?: (arg0: any,arg1: number,arg2: any,arg3: boolean,arg4: number,arg5: number) => void; FLOAT?: any; bufferData?: (arg0: any,arg1: Float32Array,arg2: any) => void; STATIC_DRAW?: any; createShader?: any; shaderSource?: any; compileShader?: any; getShaderParameter?: any; COMPILE_STATUS?: any; getShaderInfoLog?: any; }, shaderSource, shaderType) {
let shader = gl.createShader(shaderType);
gl.shaderSource(shader, shaderSource);
gl.compileShader(shader);
let success = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
if (!success) {
throw "could not compile shader:" + gl.getShaderInfoLog(shader);
}
return shader;
}

```

#### Expected Behavior

```ts
/*
* Utility function to compile a WebGL Vertex or Fragment shader.
*
* @param {WebGLRenderingContext} gl - the webgl context fo which to build the shader.
* @param {String} shaderSource - A string of shader code to compile.
* @param {number} shaderType - Shader type, either WebGLRenderingContext.VERTEX_SHADER or WebGLRenderingContext.FRAGMENT_SHADER.
*
* @return {WebGLShader} A compiled shader.
*
*/
export function compileShader(gl: WebGLRenderingContext, shaderSource: string, shaderType: number) {
let shader = gl.createShader(shaderType);
gl.shaderSource(shader, shaderSource);
gl.compileShader(shader);
let success = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
if (!success) {
throw "could not compile shader:" + gl.getShaderInfoLog(shader);
}
return shader;
}
```

#### Reproduction

Run typestat on https://github.com/bbc/VideoContext/blob/develop/src/utils.js

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.