Closed
Description
TypeScript Version: 2.8.0-dev.20180322
Code
I am experimenting with the Exclude
type introduced here #21847.
What I would like is to create a type that includes all strings except for "", I thought something like this would work:
type NonEmptyString = Exclude<string, "">;
function test(s: NonEmptyString) {}
test("");
so I was expecting an error, but no, it compiles fine. Also test("a");
compiles fine. I didn't get the reason why, I've asked on gitter and it looks like this code should give a compile error.
Expected behavior: I think a compiler error should be shown, but I'm really new with TypeScript, so it might easily be an error on my side
Actual behavior: No compiler error, both with test("")
and test("a")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment