mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
refactor(common): remove redundant providedIn: 'root' from injection tokens
Removes unnecessary declarations from injection tokens
(cherry picked from commit 8485579649)
This commit is contained in:
parent
0b90940461
commit
6d9d2b83f6
4 changed files with 5 additions and 4 deletions
|
|
@ -215,7 +215,8 @@ export const HTTP_ROOT_INTERCEPTOR_FNS = new InjectionToken<readonly HttpInterce
|
|||
// Should HttpClient contribute to stability automatically at all?
|
||||
export const REQUESTS_CONTRIBUTE_TO_STABILITY = new InjectionToken<boolean>(
|
||||
typeof ngDevMode !== 'undefined' && ngDevMode ? 'REQUESTS_CONTRIBUTE_TO_STABILITY' : '',
|
||||
{providedIn: 'root', factory: () => true},
|
||||
// Providing a factory implies that the token is provided in root by default
|
||||
{factory: () => true},
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ export const XSRF_DEFAULT_COOKIE_NAME = 'XSRF-TOKEN';
|
|||
export const XSRF_COOKIE_NAME = new InjectionToken<string>(
|
||||
typeof ngDevMode !== 'undefined' && ngDevMode ? 'XSRF_COOKIE_NAME' : '',
|
||||
{
|
||||
providedIn: 'root',
|
||||
// Providing a factory implies that the token is provided in root by default
|
||||
factory: () => XSRF_DEFAULT_COOKIE_NAME,
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ describe('provideHttpClient', () => {
|
|||
|
||||
it('should allow injection from an interceptor context', () => {
|
||||
const ALPHA = new InjectionToken<string>('alpha', {
|
||||
providedIn: 'root',
|
||||
// Providing a factory implies that the token is provided in root by default
|
||||
factory: () => 'alpha',
|
||||
});
|
||||
const BETA = new InjectionToken<string>('beta', {providedIn: 'root', factory: () => 'beta'});
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import {
|
|||
import {FakeNavigation} from './fake_navigation';
|
||||
|
||||
const FAKE_NAVIGATION = new InjectionToken<FakeNavigation>('fakeNavigation', {
|
||||
providedIn: 'root',
|
||||
// Providing a factory implies that the token is provided in root by default
|
||||
factory: () => {
|
||||
const config = inject(MOCK_PLATFORM_LOCATION_CONFIG, {optional: true});
|
||||
const baseFallback = 'http://_empty_/';
|
||||
|
|
|
|||
Loading…
Reference in a new issue