From 61ce8148e3272a21a4cb009537c2db761b21a9df Mon Sep 17 00:00:00 2001 From: Justin Fagnani Date: Thu, 2 Feb 2023 09:21:50 -0800 Subject: [PATCH] Add type parameter for key to createContext() (#3628) --- .changeset/happy-apricots-pay.md | 5 +++++ packages/labs/context/src/lib/create-context.ts | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/happy-apricots-pay.md diff --git a/.changeset/happy-apricots-pay.md b/.changeset/happy-apricots-pay.md new file mode 100644 index 0000000000..21799b9131 --- /dev/null +++ b/.changeset/happy-apricots-pay.md @@ -0,0 +1,5 @@ +--- +'@lit-labs/context': patch +--- + +Add type parameter for key to createContext() diff --git a/packages/labs/context/src/lib/create-context.ts b/packages/labs/context/src/lib/create-context.ts index 5e8840ba49..2e4ad4220f 100644 --- a/packages/labs/context/src/lib/create-context.ts +++ b/packages/labs/context/src/lib/create-context.ts @@ -49,8 +49,8 @@ export type ContextType> = * * @param key a context key value * @template ValueType the type of value that can be provided by this context. - * @returns the context key value with the correct type + * @returns the context key value cast to `Context` */ -export function createContext(key: unknown) { - return key as Context; +export function createContext(key: K) { + return key as Context; }