File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -32,9 +32,9 @@ export function provide<T>(key: InjectionKey<T> | string, value: T): void {
3232 vm . _provided [ key as string ] = value ;
3333}
3434
35- export function inject < T > ( key : InjectionKey < T > | string ) : T | void ;
35+ export function inject < T > ( key : InjectionKey < T > | string ) : T | undefined ;
3636export function inject < T > ( key : InjectionKey < T > | string , defaultValue : T ) : T ;
37- export function inject < T > ( key : InjectionKey < T > | string , defaultValue ?: T ) : T | void {
37+ export function inject < T > ( key : InjectionKey < T > | string , defaultValue ?: T ) : T | undefined {
3838 if ( ! key ) {
3939 return defaultValue ;
4040 }
@@ -43,9 +43,10 @@ export function inject<T>(key: InjectionKey<T> | string, defaultValue?: T): T |
4343 const val = resolveInject ( key as InjectionKey < T > , vm ) ;
4444 if ( val !== NOT_FOUND ) {
4545 return val ;
46- } else if ( defaultValue !== undefined ) {
46+ } else {
47+ if ( defaultValue === undefined && process . env . NODE_ENV !== 'production' ) {
48+ warn ( `Injection "${ String ( key ) } " not found` , vm ) ;
49+ }
4750 return defaultValue ;
48- } else if ( process . env . NODE_ENV !== 'production' ) {
49- warn ( `Injection "${ String ( key ) } " not found` , vm ) ;
5051 }
5152}
You can’t perform that action at this time.
0 commit comments