Skip to content

instanceof has been used and there is a type inference errorΒ #58793

Closed as not planned

Description

πŸ”Ž Search Terms

Property 'dispose' does not exist on type 'string | number | boolean | Record<string, any> | Color | ((material: Material) => Material)

πŸ•— Version & Regression Information

image

⏯ Playground Link

No response

πŸ’» Code

export function disposeMaterial(material: THREE.Material) {
  if (material instanceof THREE.Material) {
    for (const key in material) {
      const k = key as keyof THREE.Material
      if (material[k] instanceof THREE.Texture) {
        //@ts-ignore 
        material[k].dispose()
      }
    }
    material.dispose()
  }
}

πŸ™ Actual behavior

no error

πŸ™‚ Expected behavior

no error

Additional information about the issue

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions