diff --git a/src/index.js.flow b/src/index.js.flow index d7d1854..e96971a 100644 --- a/src/index.js.flow +++ b/src/index.js.flow @@ -46,8 +46,6 @@ declare export function runWithDi any>( declare export var stats: { /** Returns unused injectables */ unused: () => Array<{ get: () => Dependency, error: () => Error }>, - /** Returns dependencies missing an injectable override */ - missing: () => Array<{ get: () => Dependency, error: () => Error }>, /** Resets stats */ reset: () => void, }; diff --git a/src/react/__tests__/stats.test.js b/src/react/__tests__/stats.test.js index 2c96f75..820da0f 100644 --- a/src/react/__tests__/stats.test.js +++ b/src/react/__tests__/stats.test.js @@ -11,9 +11,7 @@ import { WrapperDi, apiHandler, fetchApiDi, - processApiData, processApiDataDi, - transformer, } from './common'; describe('stats', () => { @@ -65,16 +63,6 @@ describe('stats', () => { ); expect(stats.unused()).toHaveLength(0); }); - - it('should track missing injectables', () => { - render( - - - ); - expect(stats.missing()).toHaveLength(1); - expect(stats.missing()[0].get()).toEqual(Wrapper); - }); }); describe('with runWithDi', () => { @@ -91,13 +79,5 @@ describe('stats', () => { expect(stats.unused()[0].get()).toEqual(TextDi); expect(stats.unused()[1].get()).toEqual(WrapperDi); }); - - it('should track missing injectables', async () => { - const deps = [fetchApiDi]; - await runWithDi(() => apiHandler(), deps); - expect(stats.missing()).toHaveLength(2); - expect(stats.missing()[0].get()).toEqual(transformer); - expect(stats.missing()[1].get()).toEqual(processApiData); - }); }); }); diff --git a/src/react/__tests__/types.flow.js b/src/react/__tests__/types.flow.js index 1676ba6..24b5e40 100644 --- a/src/react/__tests__/types.flow.js +++ b/src/react/__tests__/types.flow.js @@ -75,14 +75,9 @@ async () => { * stats types tests */ const unused = stats.unused(); -const missing = stats.missing(); stats.reset(); // Correct unused.length > 1; unused[0].get().call; unused[0].error().stack; - -missing.length > 1; -missing[0].get().call; -missing[0].error().stack; diff --git a/src/react/stats.js b/src/react/stats.js index 6ee373c..41ddc63 100644 --- a/src/react/stats.js +++ b/src/react/stats.js @@ -3,7 +3,6 @@ import { KEY } from './constants'; const createState = () => ({ unused: new Map(), used: new Set(), - missing: new Map(), provided: new Set(), }); @@ -29,13 +28,7 @@ export const stats = { if (replacedDep) { this.state.unused.delete(replacedDep); this.state.used.add(replacedDep); - this.state.missing.delete(dep); this.state.provided.add(dep); - } else if (!dep[KEY]?.from && !this.state.provided.has(dep)) { - this.state.missing.set( - dep, - new Error(`Unreplaced di dependency: ${dep.displayName || dep}`) - ); } }, @@ -51,13 +44,4 @@ export const stats = { }) ); }, - - missing() { - return Array.from(this.state.missing.entries()).map( - ([dependency, error]) => ({ - get: () => dependency, - error: () => error, - }) - ); - }, }; diff --git a/types/index.d.ts b/types/index.d.ts index 857a6db..490e2ac 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -73,8 +73,6 @@ declare module 'react-magnetic-di' { const stats: { /** Returns unused injectables */ unused(): Array<{ get(): Injectable; error(): Error }>; - /** Returns dependencies missing an injectable override */ - missing(): Array<{ get(): Dependency; error(): Error }>; /** Resets stats */ reset(): void; }; diff --git a/types/test.tsx b/types/test.tsx index 16b0f4d..7797b4b 100644 --- a/types/test.tsx +++ b/types/test.tsx @@ -170,14 +170,9 @@ async () => { * stats types tests */ const unused = stats.unused(); -const missing = stats.missing(); stats.reset(); // Correct unused.length > 1; unused[0].get().call; unused[0].error().stack; - -missing.length > 1; -missing[0].get().call; -missing[0].error().stack;