jsx-ast-utils icon indicating copy to clipboard operation
jsx-ast-utils copied to clipboard

The prop value with an expression type of TSSatisfiesExpression could not be resolved.

Open antho1jp opened this issue 2 years ago • 6 comments

Receiving the error:

The prop value with an expression type of TSSatisfiesExpression could not be resolved. Please file an issue ( https://github.com/jsx-eslint/jsx-ast-utils/issues/new ) to get this fixed immediately.

During local builds of NextJS application.

antho1jp avatar Jul 06 '23 17:07 antho1jp

Thanks! I believe that's pretty new in TS. Can you provide some code that uses satisfies?

ljharb avatar Jul 06 '23 17:07 ljharb

Same problem for me for a couple of months, sorry I didn't take the time to report it earlier. Here is an example of a code where eslint complain:

type FormData = {
  name: string;
}

function Input() {
  return <input type="text" name={"name" satsifies keyof FormData} />
}

It seems that it gives the error when a prop mix the expected type with a satisfies in it.

michaeldebetaz avatar Jul 16 '23 11:07 michaeldebetaz

I’m getting the same issue here, we also have some inputs we want to make sure are correct: name={'fieldName' satisfies keyof Fields}

We make extensive use of satisfies and the only places we see this issue are the places where we use this string satisifes keyof Type pattern

MattyBalaam avatar Mar 12 '24 08:03 MattyBalaam

Did anyone find a workaround? does TS have any other keyword that can be used instead of satisfies (inline in JSX)? I know of as but it's unsafe and cannot be used here

mifi avatar Mar 20 '24 07:03 mifi

The fix for this in this package isn’t hard, but getting the tests to run on a new enough TS version so it can be tested is, unfortunately.

@mifi there’s no way to have the safety of that TS feature without using the feature, i believe.

ljharb avatar Mar 20 '24 15:03 ljharb