I have a function that, can accept only two possible values (for validation). For this I do:

```
interface PossibleValues {
    key: "str1" | "str2";
}

```

I can call the function with a **string** type only. This is by our architectural design and I have to deal with it.

```
set({key: type})

```

Because `type` is **string** and `key` can accept only `"str1" | "str2"` it says:
**TS2322: Type 'string' is not assignable to type '"str1" | "str2"'** which makes sense.

The question is how to overcome this in a most elegant way? I mean I want to pass a **string** but the function call should fail if the string is not one of the two `"str1" | "str2"`

What I tried to do is:
`set({key: type} as PossibleValues)` and it stopped complaining but the desired behavior is not achieved. If I pass "str333" for example it still works.

Any ideas?