Error - The type you provided for 'RoomInfo' does not match its requirements

Why this error occurred

You have provided a custom RoomInfo type for your application, but the type you provided isn’t a (completely) valid definition.

In the example above, the problem is the URL field. Values like Date, Map, Set, functions, classes (including URL), or unknown aren’t valid JSON.

The rules of the RoomInfo type

The following rules apply if you want to specify a custom RoomInfo type:

  • You can provide any keys and values here, as long as the values are valid JSON.
  • Two small constraints:
    • If you specify name, it must be assignable to string | undefined.
    • If you specify url, then it must be assignable to string | undefined.

The reason for these two restrictions is that some of our higher-level components will pick these values up and use them to provide default UIs.

How to fix it

You’ll need to figure out what part of your provided RoomInfo type definition isn’t valid. The example above can be fixed as follows:

If you cannot find the root cause

Sometimes types can be complex and the root cause is still unclear. In those cases, there is a small trick you can use. Try to assign your type to the required base type, with this line:

Now TypeScript will explain why it thinks your type isn’t valid room info: