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 {
32
32
vm . _provided [ key as string ] = value ;
33
33
}
34
34
35
- export function inject < T > ( key : InjectionKey < T > | string ) : T | void ;
35
+ export function inject < T > ( key : InjectionKey < T > | string ) : T | undefined ;
36
36
export 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 {
38
38
if ( ! key ) {
39
39
return defaultValue ;
40
40
}
@@ -43,9 +43,10 @@ export function inject<T>(key: InjectionKey<T> | string, defaultValue?: T): T |
43
43
const val = resolveInject ( key as InjectionKey < T > , vm ) ;
44
44
if ( val !== NOT_FOUND ) {
45
45
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
+ }
47
50
return defaultValue ;
48
- } else if ( process . env . NODE_ENV !== 'production' ) {
49
- warn ( `Injection "${ String ( key ) } " not found` , vm ) ;
50
51
}
51
52
}
You can’t perform that action at this time.
0 commit comments