Skip to content

Typescript support #41

@ecosky

Description

@ecosky

I attempted to incorporate this module into a typescript project, but hit some barriers that prevented me from completing the task. I was able to get it to build successfully with the addition of a small file "shadertoy-react.d.ts" with the following contents:

declare module 'shadertoy-react'
{
    // tslint:disable-next-line:no-empty-interface
    export default class ShadertoyReact { props; render; context; setState; forceUpdate; state; refs }
}

however when attempting to run the code I would get runtime errors that so far I have been unable to resolve, primarily because the page would include shadertoy-react.min.js despite my best efforts to include unminified code. I am pretty new to react and typescript, so it might be a simple problem however I have been completely stumped by this. Here's a partial callstack for the error I get:

Uncaught TypeError TypeError: Failed to execute 'shaderSource' on 'WebGLRenderingContext': parameter 1 is not of type 'WebGLShader'.
    at <anonymous> (d:\dev\projects\BBGWebsite\bbg\node_modules\shadertoy-react\lib\shadertoy-react.min.js:1:1)
    at <anonymous> (d:\dev\projects\BBGWebsite\bbg\node_modules\shadertoy-react\lib\shadertoy-react.min.js:1:1)
    at <anonymous> (d:\dev\projects\BBGWebsite\bbg\node_modules\shadertoy-react\lib\shadertoy-react.min.js:1:1)
    at invokeLayoutEffectMountInDEV (d:\dev\projects\BBGWebsite\bbg\node_modules\react-dom\cjs\react-dom.development.js:25133:1)
    at invokeEffectsInDev (d:\dev\projects\BBGWebsite\bbg\node_modules\react-dom\cjs\react-dom.development.js:27351:1)
    at commitDoubleInvokeEffectsInDEV (d:\dev\projects\BBGWebsite\bbg\node_modules\react-dom\cjs\react-dom.development.js:27327:1)

I've spent a lot of time trying to get Visual Studio to use the unminified version but I'm stuck.

It would be really helpful if this module supported two features:

  • Typescript support, just in case my approach is wrong.
  • An explanation of how to enable the non-minified version for debugging.

Thanks!
shadertoy-react.d.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions