We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TS 2.0.3
See the comments and last line in the code below for expected/actual.
{ type Foo = { foo: true }; const isFoo = (foo: Foo) => foo.foo; const xs = [{ foo: true }, undefined]; isFoo(xs[1]) // good, errors const x = undefined as Foo | undefined; isFoo(x) // good, errors xs.filter(isFoo) // bad, didn't fail, expected filter arg to fail, should be Foo | undefined }
The text was updated successfully, but these errors were encountered:
This is expected. Consider
declare function f(x: number): any; declare function g(x?: number): any; declare function h(x: number | undefined): any; let i = f; i = g; i = f; i = h; let k = f; k = h; k = g;
Also, see this section of the handbook. type-compatibility
Sorry, something went wrong.
In the example above, I would receive a type error at runtime. Is there any way to enforce this at compile time?
See https://github.com/Microsoft/TypeScript/wiki/FAQ#why-are-function-parameters-bivariant
No branches or pull requests
TS 2.0.3
See the comments and last line in the code below for expected/actual.
The text was updated successfully, but these errors were encountered: