Skip to content

Commit 8485579

Browse files
SkyZeroZxAndrewKushnir
authored andcommitted
refactor(common): remove redundant providedIn: 'root' from injection tokens
Removes unnecessary declarations from injection tokens
1 parent 1a9bfa8 commit 8485579

4 files changed

Lines changed: 5 additions & 4 deletions

File tree

packages/common/http/src/interceptor.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ export const HTTP_ROOT_INTERCEPTOR_FNS = new InjectionToken<readonly HttpInterce
215215
// Should HttpClient contribute to stability automatically at all?
216216
export const REQUESTS_CONTRIBUTE_TO_STABILITY = new InjectionToken<boolean>(
217217
typeof ngDevMode !== 'undefined' && ngDevMode ? 'REQUESTS_CONTRIBUTE_TO_STABILITY' : '',
218-
{providedIn: 'root', factory: () => true},
218+
// Providing a factory implies that the token is provided in root by default
219+
{factory: () => true},
219220
);
220221

221222
/**

packages/common/http/src/xsrf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const XSRF_DEFAULT_COOKIE_NAME = 'XSRF-TOKEN';
3232
export const XSRF_COOKIE_NAME = new InjectionToken<string>(
3333
typeof ngDevMode !== 'undefined' && ngDevMode ? 'XSRF_COOKIE_NAME' : '',
3434
{
35-
providedIn: 'root',
35+
// Providing a factory implies that the token is provided in root by default
3636
factory: () => XSRF_DEFAULT_COOKIE_NAME,
3737
},
3838
);

packages/common/http/test/provider_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ describe('provideHttpClient', () => {
206206

207207
it('should allow injection from an interceptor context', () => {
208208
const ALPHA = new InjectionToken<string>('alpha', {
209-
providedIn: 'root',
209+
// Providing a factory implies that the token is provided in root by default
210210
factory: () => 'alpha',
211211
});
212212
const BETA = new InjectionToken<string>('beta', {providedIn: 'root', factory: () => 'beta'});

packages/common/testing/src/navigation/provide_fake_platform_navigation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
import {FakeNavigation} from './fake_navigation';
1818

1919
const FAKE_NAVIGATION = new InjectionToken<FakeNavigation>('fakeNavigation', {
20-
providedIn: 'root',
20+
// Providing a factory implies that the token is provided in root by default
2121
factory: () => {
2222
const config = inject(MOCK_PLATFORM_LOCATION_CONFIG, {optional: true});
2323
const baseFallback = 'http://_empty_/';

0 commit comments

Comments
 (0)