Describe the bug
When creating a signal with a union type that includes null or undefined, the resulting signal doesn't include null or undefined.
E.g. if we create a signal that can be null or a number using createSignal<null | number>(null), the return type is Signal<number> instead of Signal<number | null>
The issue is that the value of the signal is actually null, but the type signature doesn't reflect that. That means we loose type-safety.
Your Example Website or App
https://playground.solidjs.com/?version=1.3.13#NobwRAdghgtgpmAXGGUCWEwBowBcCeADgsrgM4Ae2YZA9gK4BOAxiWGjIbY7gAQi9GcCABM4jXgF9eAM0a0YvADo1aAGzQiAtACsyAegDucAEYqA3EogcuPfr2ZCouOAGU0Ac2hqps+YpU6DW09CysrGXoIZlw0WgheAGEGCBdGAAoASn4rXgd4sj5gZhTcLF4yOFxkqNwAXV4AXgcnF3cvKDUAHgh6GBNxXgAfXl61NQA+dLG1TMsE-IhC3gxHOHhUpt4spomKqprU9JLanYBqXgBGOdzlBf19XgADKCeVsl5aGV4CYmfe-riN4meh8MgACwYahEvAG-z6AwkIxmT1uJSWfCgWxOR0y4QWQlwTAS6VueS6INwuHiPyIcEaKkp1IgKk+EESGmYAGtGiBVkINrhJBMyXl+DjcFlJKK8iAoNKFuT9Ez4iKFjcIAqrEJROJ0jtGnsuoc0rx9BNyiJaMw+sJcAA6DxVACianWdoAQvgAJIiUlgKCEQgqTIasCSOpAA
Steps to Reproduce the Bug or Issue
- Create a signal with a nullable type, e.g.
number | null
- Observe that resulting signal type doesn't include null, e.g. only
number instead of number | null
Expected behavior
When using createSignal<T | null>(null), I'd expect the resulting signal to be of type Signal<T | null>
Screenshots or Videos
Example from the Solid playground with createSignal<number | null>()

Also an issue when creating a nullable signal using createSignal<number>(), where I'd expect the return type to be Signal<number | undefined>

Platform
- OS: [e.g. macOS, Windows, Linux]
- Browser: [e.g. Chrome, Safari, Firefox]
- Version: [e.g. 91.1]
Additional context
The issue may be related to #217, but that issue was focused on initialising without arguments.
Describe the bug
When creating a signal with a union type that includes
nullorundefined, the resulting signal doesn't includenullorundefined.E.g. if we create a signal that can be
nullor anumberusingcreateSignal<null | number>(null), the return type isSignal<number>instead ofSignal<number | null>The issue is that the value of the signal is actually
null, but the type signature doesn't reflect that. That means we loose type-safety.Your Example Website or App
https://playground.solidjs.com/?version=1.3.13#NobwRAdghgtgpmAXGGUCWEwBowBcCeADgsrgM4Ae2YZA9gK4BOAxiWGjIbY7gAQi9GcCABM4jXgF9eAM0a0YvADo1aAGzQiAtACsyAegDucAEYqA3EogcuPfr2ZCouOAGU0Ac2hqps+YpU6DW09CysrGXoIZlw0WgheAGEGCBdGAAoASn4rXgd4sj5gZhTcLF4yOFxkqNwAXV4AXgcnF3cvKDUAHgh6GBNxXgAfXl61NQA+dLG1TMsE-IhC3gxHOHhUpt4spomKqprU9JLanYBqXgBGOdzlBf19XgADKCeVsl5aGV4CYmfe-riN4meh8MgACwYahEvAG-z6AwkIxmT1uJSWfCgWxOR0y4QWQlwTAS6VueS6INwuHiPyIcEaKkp1IgKk+EESGmYAGtGiBVkINrhJBMyXl+DjcFlJKK8iAoNKFuT9Ez4iKFjcIAqrEJROJ0jtGnsuoc0rx9BNyiJaMw+sJcAA6DxVACianWdoAQvgAJIiUlgKCEQgqTIasCSOpAA
Steps to Reproduce the Bug or Issue
number | nullnumberinstead ofnumber | nullExpected behavior
When using
createSignal<T | null>(null), I'd expect the resulting signal to be of typeSignal<T | null>Screenshots or Videos
Example from the Solid playground with

createSignal<number | null>()Also an issue when creating a nullable signal using

createSignal<number>(), where I'd expect the return type to beSignal<number | undefined>Platform
Additional context
The issue may be related to #217, but that issue was focused on initialising without arguments.