Which package(s) are affected?
Context (@lit-labs/context)
Description
It's not possible to use optional fields with @contextProvided because of the use of Record in the decorator types.
This should work, since it's always possible that there is no provider for a context key:
const fooContext = createContext<Foo>('foo');
class MyElement extends LitElement {
@contextProvided({context: fooContext})
foo?: Foo;
}
Reproduction
See above
Workaround
Mark fields and context keys as X | undefined instead of optional.
Is this a regression?
No or unsure. This never worked, or I haven't tried before.
Affected versions
all
Browser/OS/Node environment
all