#176 with missing properties:
|
export function createLocaleFallback (): LocaleContext { |
|
return { |
|
size: 0, |
|
t: (key: string) => key, |
|
n: String, |
|
} as unknown as LocaleContext |
|
} |
fallback factory exists and we have injection context so the fallback instance is passed to useContext:
|
function useX<_E extends E = E> (namespace = defaultNamespace): _E { |
|
if (config?.fallback) { |
|
const instance = config.fallback(namespace) as _E |
|
if (!hasInjectionContext()) return instance |
|
return useContext<_E>(namespace, instance) |
|
} |
inject returns the fallback so isUndefined is false:
|
export function useContext<Z> (key: ContextKey<Z>, defaultValue?: Z) { |
|
const context = inject<Z>(key, defaultValue as Z) |
|
|
|
if (isUndefined(context)) { |
|
throw new Error(`Context "${String(key)}" not found. Ensure it's provided by an ancestor.`) |
|
} |
|
|
|
return context |
|
} |
If createLocaleContext is missing we get a runtime error instead of the warning:
const locale = useLocale()
locale.select('de') // Uncaught TypeError: locale.select is not a function
#176 with missing properties:
0/packages/0/src/composables/useLocale/index.ts
Lines 168 to 174 in 83df82d
fallback factory exists and we have injection context so the fallback instance is passed to useContext:
0/packages/0/src/composables/createPlugin/index.ts
Lines 206 to 211 in debbd99
inject returns the fallback so isUndefined is false:
0/packages/0/src/composables/createContext/index.ts
Lines 53 to 61 in 953ab79
If createLocaleContext is missing we get a runtime error instead of the warning: