eslint-plugin-total-functions icon indicating copy to clipboard operation
eslint-plugin-total-functions copied to clipboard

total-functions/no-unsafe-readonly-mutable-assignment false positive

Open JustFly1984 opened this issue 4 years ago • 0 comments

Error in vscode:

Passing a readonly type to a function that expects a mutable type can lead to unexpected mutation in the readonly value. eslinttotal-functions/no-unsafe-readonly-mutable-assignment

points to children in if statement.

import React, { memo, isValidElement } from 'react'
import type { ReactNode } from 'react'

interface Props {
  children: ReactNode
}

function Component({ children }: Props): JSX.Element | null {
  if (!isValidElement<ReactNode>(children)) return null
  
  return <div>{children}</div>
}

JustFly1984 avatar Oct 07 '21 22:10 JustFly1984