Closed kaisellgren closed 1 year ago
@raimohanska Is there a fix for this? This is quite annoying and prevents from writing simple TypeScript.
This shouldn't cause a type error:
const test: Bacon.Property<boolean> = Bacon.constant(true)
In regular TypeScript code this works fine:
interface Generic<T> {
a: T
}
const a: boolean = true
const b: Generic<boolean> = { a: true }
You may supply the type parameter explicitly like this:
const test = Bacon.constant<string | null>("");
const test = Bacon.constant<boolean>(false);
I guess this depends on TypeScript version and options, but for me, constant(true)
seems to create a Property<boolean>
:
A team member (Petri Väkeväinen) has informed me that with the latest version of TypeScript it appears to work just fine.
I'm closing this issue now. Thanks.
Given the following code:
For some reason when using strict mode in TypeScript, I get this type error:
This does not happen with this test code:
I am not sure where this goes wrong, but
string
should be assignable tostring | null
including with generics.And here's another way to reproduce this:
Apparently, true cannot be assigned to boolean when wrapped within a Bacon object.
I am using TypeScript 4.0.2