static-injector 2.2.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/import/commonjs/index.js +94 -50
  2. package/import/es2022/di/index.js +1 -0
  3. package/import/es2022/di/initializer_token.js +1 -1
  4. package/import/es2022/di/inject_switch.js +1 -2
  5. package/import/es2022/di/injection_token.js +13 -6
  6. package/import/es2022/di/injector.js +3 -3
  7. package/import/es2022/di/injector_compatibility.js +23 -0
  8. package/import/es2022/di/injector_token.js +2 -3
  9. package/import/es2022/di/internal_tokens.js +1 -1
  10. package/import/es2022/di/r3_injector.js +19 -16
  11. package/import/es2022/di/scope.js +1 -1
  12. package/import/es2022/di.js +24 -0
  13. package/import/es2022/render3/errors_di.js +2 -2
  14. package/import/es2022/render3/instructions/di.js +7 -0
  15. package/import/es2022/render3/util/stringify_utils.js +1 -0
  16. package/import/es2022/util/array_utils.js +7 -0
  17. package/import/es2022/util/stringify.js +15 -0
  18. package/import/fesm2022/index.js +88 -44
  19. package/import/typings/di/create_injector.d.ts +2 -2
  20. package/import/typings/di/forward_ref.d.ts +1 -1
  21. package/import/typings/di/index.d.ts +1 -0
  22. package/import/typings/di/initializer_token.d.ts +1 -1
  23. package/import/typings/di/injection_token.d.ts +11 -6
  24. package/import/typings/di/injector.d.ts +3 -3
  25. package/import/typings/di/injector_compatibility.d.ts +2 -1
  26. package/import/typings/di/injector_token.d.ts +1 -1
  27. package/import/typings/di/interface/provider.d.ts +12 -12
  28. package/import/typings/di/internal_tokens.d.ts +1 -1
  29. package/import/typings/di/metadata.d.ts +2 -2
  30. package/import/typings/di/null_injector.d.ts +1 -1
  31. package/import/typings/di/r3_injector.d.ts +1 -1
  32. package/import/typings/di.d.ts +24 -0
  33. package/import/typings/errors.d.ts +11 -3
  34. package/import/typings/render3/errors_di.d.ts +2 -1
  35. package/import/typings/render3/instructions/di.d.ts +7 -0
  36. package/import/typings/render3/util/stringify_utils.d.ts +1 -0
  37. package/import/typings/util/array_utils.d.ts +7 -0
  38. package/import/typings/util/empty.d.ts +1 -1
  39. package/import/typings/util/stringify.d.ts +8 -0
  40. package/package.json +7 -5
  41. package/readme.md +2 -2
  42. package/transform/compiler/src/compiler.d.ts +0 -22
  43. package/transform/compiler/src/compiler.js +0 -26
  44. package/transform/compiler/src/core.d.ts +6 -0
  45. package/transform/compiler/src/core.js +13 -0
  46. package/transform/compiler/src/injectable_compiler_2.js +2 -2
  47. package/transform/compiler/src/output/output_ast.d.ts +21 -7
  48. package/transform/compiler/src/output/output_ast.js +55 -9
  49. package/transform/compiler/src/render3/partial/api.d.ts +5 -0
  50. package/transform/compiler/src/render3/r3_factory.js +1 -1
  51. package/transform/compiler/src/render3/r3_identifiers.js +4 -0
  52. package/transform/compiler/src/render3/util.js +1 -3
  53. package/transform/compiler/src/render3/view/util.d.ts +2 -0
  54. package/transform/compiler/src/render3/view/util.js +10 -2
  55. package/transform/compiler-cli/src/ngtsc/annotations/common/index.d.ts +0 -7
  56. package/transform/compiler-cli/src/ngtsc/annotations/common/index.js +0 -7
  57. package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.d.ts +3 -0
  58. package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.js +14 -2
  59. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.d.ts +3 -2
  60. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.js +3 -1
  61. package/transform/compiler-cli/src/ngtsc/diagnostics/error.d.ts +2 -2
  62. package/transform/compiler-cli/src/ngtsc/diagnostics/error_code.js +2 -2
  63. package/transform/compiler-cli/src/ngtsc/diagnostics/index.d.ts +0 -7
  64. package/transform/compiler-cli/src/ngtsc/diagnostics/index.js +0 -7
  65. package/transform/compiler-cli/src/ngtsc/imports/index.d.ts +0 -7
  66. package/transform/compiler-cli/src/ngtsc/imports/index.js +0 -7
  67. package/transform/compiler-cli/src/ngtsc/reflection/index.d.ts +0 -7
  68. package/transform/compiler-cli/src/ngtsc/reflection/index.js +0 -7
  69. package/transform/compiler-cli/src/ngtsc/reflection/src/host.d.ts +7 -2
  70. package/transform/compiler-cli/src/ngtsc/reflection/src/host.js +3 -1
  71. package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.d.ts +2 -1
  72. package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.js +16 -5
  73. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.d.ts +4 -3
  74. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.js +25 -9
  75. package/transform/compiler-cli/src/ngtsc/transform/index.d.ts +0 -7
  76. package/transform/compiler-cli/src/ngtsc/transform/index.js +0 -7
  77. package/transform/compiler-cli/src/ngtsc/transform/src/api.d.ts +18 -0
  78. package/transform/compiler-cli/src/ngtsc/transform/src/api.js +20 -0
  79. package/transform/compiler-cli/src/ngtsc/transform/src/utils.d.ts +1 -1
  80. package/transform/compiler-cli/src/ngtsc/transform/src/utils.js +35 -24
  81. package/transform/compiler-cli/src/ngtsc/translator/index.d.ts +0 -7
  82. package/transform/compiler-cli/src/ngtsc/translator/index.js +0 -7
  83. package/transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.d.ts +9 -1
  84. package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.d.ts +21 -3
  85. package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.js +13 -3
  86. package/transform/compiler-cli/src/ngtsc/translator/src/translator.d.ts +1 -0
  87. package/transform/compiler-cli/src/ngtsc/translator/src/translator.js +6 -0
  88. package/transform/compiler-cli/src/ngtsc/translator/src/ts_util.d.ts +12 -0
  89. package/transform/compiler-cli/src/ngtsc/translator/src/ts_util.js +27 -0
  90. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.d.ts +1 -0
  91. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.js +9 -1
  92. package/transform/index.d.ts +1 -1
  93. package/transform/injectable-transform.js +2 -2
@@ -161,6 +161,21 @@ function stringify(token) {
161
161
  const newLineIndex = res.indexOf('\n');
162
162
  return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
163
163
  }
164
+ /**
165
+ * Ellipses the string in the middle when longer than the max length
166
+ *
167
+ * @param string
168
+ * @param maxLength of the output string
169
+ * @returns ellipsed string with ... in the middle
170
+ */
171
+ function truncateMiddle(str, maxLength = 100) {
172
+ if (!str || maxLength < 1 || str.length <= maxLength)
173
+ return str;
174
+ if (maxLength == 1)
175
+ return str.substring(0, 1) + '...';
176
+ const halfLimit = Math.round(maxLength / 2);
177
+ return (str.substring(0, halfLimit) + '...' + str.substring(str.length - halfLimit));
178
+ }
164
179
 
165
180
  /**
166
181
  * @license
@@ -266,8 +281,8 @@ function isForwardRef(fn) {
266
281
  */
267
282
  /** Throws an error when a token is not found in DI. */
268
283
  function throwProviderNotFoundError(token, injectorName) {
269
- const injectorDetails = injectorName ? ` in ${injectorName}` : '';
270
- throw new RuntimeError(-201 /* RuntimeErrorCode.PROVIDER_NOT_FOUND */, null);
284
+ const errorMessage = null;
285
+ throw new RuntimeError(-201 /* RuntimeErrorCode.PROVIDER_NOT_FOUND */, errorMessage);
271
286
  }
272
287
 
273
288
  /**
@@ -449,7 +464,7 @@ function injectRootLimpMode(token, notFoundValue, flags) {
449
464
  return null;
450
465
  if (notFoundValue !== undefined)
451
466
  return notFoundValue;
452
- throwProviderNotFoundError(stringify(token), 'Injector');
467
+ throwProviderNotFoundError(token, 'Injector');
453
468
  }
454
469
 
455
470
  /**
@@ -514,6 +529,27 @@ function ɵɵinject(token, flags = InjectFlags.Default) {
514
529
  function ɵɵinvalidFactoryDep(index) {
515
530
  throw new RuntimeError(202 /* RuntimeErrorCode.INVALID_FACTORY_DEPENDENCY */, null);
516
531
  }
532
+ /**
533
+ * @param token A token that represents a static attribute on the host node that should be injected.
534
+ * @returns Value of the attribute if it exists.
535
+ * @throws If called outside of a supported context or the attribute does not exist.
536
+ *
537
+ * @publicApi
538
+ */
539
+ /**
540
+ * @param token A token that represents a static attribute on the host node that should be injected.
541
+ * @returns Value of the attribute if it exists, otherwise `null`.
542
+ * @throws If called outside of a supported context.
543
+ *
544
+ * @publicApi
545
+ */
546
+ /**
547
+ * @param token A token that represents a static attribute on the host node that should be injected.
548
+ * @returns Value of the attribute if it exists.
549
+ * @throws If called outside of a supported context or the attribute does not exist.
550
+ *
551
+ * @publicApi
552
+ */
517
553
  /**
518
554
  * Injects a token from the currently active injector.
519
555
  * `inject` is only supported in an [injection context](/guide/dependency-injection-context). It can
@@ -580,6 +616,8 @@ function ɵɵinvalidFactoryDep(index) {
580
616
  * @publicApi
581
617
  */
582
618
  function inject(token, flags = InjectFlags.Default) {
619
+ // The `as any` here _shouldn't_ be necessary, but without it JSCompiler
620
+ // throws a disambiguation error due to the multiple signatures.
583
621
  return ɵɵinject(token, convertToBitFlags(flags));
584
622
  }
585
623
  // Converts object-based DI flags (`InjectOptions`) to bit flags (`InjectFlags`).
@@ -774,17 +812,6 @@ function getFactoryDef(type, throwNotFound) {
774
812
  return hasFactoryDef ? type[NG_FACTORY_DEF] : null;
775
813
  }
776
814
 
777
- function deepForEach(input, fn) {
778
- input.forEach((value) => Array.isArray(value) ? deepForEach(value, fn) : fn(value));
779
- }
780
- function newArray(size, value) {
781
- const list = [];
782
- for (let i = 0; i < size; i++) {
783
- list.push(value);
784
- }
785
- return list;
786
- }
787
-
788
815
  /**
789
816
  * @license
790
817
  * Copyright Google LLC All Rights Reserved.
@@ -821,11 +848,17 @@ if (false) {
821
848
  * `InjectionToken` is parameterized on `T` which is the type of object which will be returned by
822
849
  * the `Injector`. This provides an additional level of type safety.
823
850
  *
824
- * ```
825
- * interface MyInterface {...}
826
- * const myInterface = injector.get(new InjectionToken<MyInterface>('SomeToken'));
827
- * // myInterface is inferred to be MyInterface.
828
- * ```
851
+ * <div class="alert is-helpful">
852
+ *
853
+ * **Important Note**: Ensure that you use the same instance of the `InjectionToken` in both the
854
+ * provider and the injection call. Creating a new instance of `InjectionToken` in different places,
855
+ * even with the same description, will be treated as different tokens by Angular's DI system,
856
+ * leading to a `NullInjectorError`.
857
+ *
858
+ * </div>
859
+ *
860
+ * <code-example format="typescript" language="typescript" path="injection-token/src/main.ts"
861
+ * region="InjectionToken"></code-example>
829
862
  *
830
863
  * When creating an `InjectionToken`, you can optionally specify a factory function which returns
831
864
  * (possibly by creating) a default value of the parameterized type `T`. This sets up the
@@ -852,7 +885,6 @@ if (false) {
852
885
  *
853
886
  * {@example core/di/ts/injector_spec.ts region='ShakableInjectionToken'}
854
887
  *
855
- *
856
888
  * @publicApi
857
889
  */
858
890
  class InjectionToken {
@@ -870,6 +902,8 @@ class InjectionToken {
870
902
  this._desc = _desc;
871
903
  this.ɵprov = undefined;
872
904
  if (typeof options == 'number') {
905
+ // This is a special hack to assign __NG_ELEMENT_ID__ to this instance.
906
+ // See `InjectorMarkers`
873
907
  }
874
908
  else if (options !== undefined) {
875
909
  this.ɵprov = ɵɵdefineInjectable({
@@ -903,7 +937,7 @@ class InjectionToken {
903
937
  *
904
938
  * @publicApi
905
939
  */
906
- const ENVIRONMENT_INITIALIZER = new InjectionToken('ENVIRONMENT_INITIALIZER');
940
+ const ENVIRONMENT_INITIALIZER = new InjectionToken('');
907
941
 
908
942
  /**
909
943
  * @license
@@ -920,11 +954,10 @@ const ENVIRONMENT_INITIALIZER = new InjectionToken('ENVIRONMENT_INITIALIZER');
920
954
  *
921
955
  * @publicApi
922
956
  */
923
- const INJECTOR = new InjectionToken('INJECTOR',
957
+ const INJECTOR = new InjectionToken('',
924
958
  // Disable tslint because this is const enum which gets inlined not top level prop access.
925
959
  // tslint:disable-next-line: no-toplevel-property-access
926
- -1 /* InjectorMarkers.Injector */ // Special value used by Ivy to identify `Injector`.
927
- );
960
+ -1 /* InjectorMarkers.Injector */);
928
961
 
929
962
  /**
930
963
  * @license
@@ -944,7 +977,7 @@ function isEnvironmentProviders(value) {
944
977
  * Use of this source code is governed by an MIT-style license that can be
945
978
  * found in the LICENSE file at https://angular.io/license
946
979
  */
947
- const INJECTOR_DEF_TYPES = new InjectionToken('INJECTOR_DEF_TYPES');
980
+ const INJECTOR_DEF_TYPES = new InjectionToken('');
948
981
 
949
982
  /**
950
983
  * @license
@@ -1080,7 +1113,7 @@ function isClassProvider(value) {
1080
1113
  * as a root scoped injector when processing requests for unknown tokens which may indicate
1081
1114
  * they are provided in the root scope.
1082
1115
  */
1083
- const INJECTOR_SCOPE = new InjectionToken('Set Injector scope.');
1116
+ const INJECTOR_SCOPE = new InjectionToken('');
1084
1117
 
1085
1118
  /**
1086
1119
  * @license
@@ -1159,7 +1192,7 @@ class R3Injector extends EnvironmentInjector {
1159
1192
  if (record != null && typeof record.value === 'string') {
1160
1193
  this.scopes.add(record.value);
1161
1194
  }
1162
- this.injectorDefTypes = new Set(this.get(INJECTOR_DEF_TYPES.multi, EMPTY_ARRAY, InjectFlags.Self));
1195
+ this.injectorDefTypes = new Set(this.get(INJECTOR_DEF_TYPES, EMPTY_ARRAY, InjectFlags.Self));
1163
1196
  }
1164
1197
  /**
1165
1198
  * Destroy the injector and release references to every instance or provider associated with it.
@@ -1233,6 +1266,8 @@ class R3Injector extends EnvironmentInjector {
1233
1266
  if (def && this.injectableDefInScope(def)) {
1234
1267
  // Found an injectable def and it's scoped to this injector. Pretend as if it was here
1235
1268
  // all along.
1269
+ if (false) {
1270
+ }
1236
1271
  record = makeRecord(injectableDefOrInjectorDefFactory(token), NOT_YET);
1237
1272
  }
1238
1273
  else {
@@ -1289,7 +1324,7 @@ class R3Injector extends EnvironmentInjector {
1289
1324
  if (false) {
1290
1325
  }
1291
1326
  try {
1292
- const initializers = this.get(ENVIRONMENT_INITIALIZER.multi, EMPTY_ARRAY, InjectFlags.Self);
1327
+ const initializers = this.get(ENVIRONMENT_INITIALIZER, EMPTY_ARRAY, InjectFlags.Self);
1293
1328
  if (false) {
1294
1329
  }
1295
1330
  for (const initializer of initializers) {
@@ -1346,29 +1381,32 @@ class R3Injector extends EnvironmentInjector {
1346
1381
  multiRecord.multi.push(provider);
1347
1382
  }
1348
1383
  else {
1349
- const existing = this.records.get(token);
1350
1384
  if (false) {
1351
1385
  }
1352
1386
  }
1353
1387
  this.records.set(token, record);
1354
1388
  }
1355
1389
  hydrate(token, record) {
1356
- if (false) {
1357
- }
1358
- else if (record.value === NOT_YET) {
1359
- record.value = CIRCULAR;
1390
+ try {
1360
1391
  if (false) {
1361
1392
  }
1362
- else {
1363
- record.value = record.factory();
1393
+ else if (record.value === NOT_YET) {
1394
+ record.value = CIRCULAR;
1395
+ if (false) {
1396
+ }
1397
+ else {
1398
+ record.value = record.factory();
1399
+ }
1400
+ }
1401
+ if (typeof record.value === 'object' &&
1402
+ record.value &&
1403
+ hasOnDestroy(record.value)) {
1404
+ this._ngOnDestroyHooks.add(record.value);
1364
1405
  }
1406
+ return record.value;
1365
1407
  }
1366
- if (typeof record.value === 'object' &&
1367
- record.value &&
1368
- hasOnDestroy(record.value)) {
1369
- this._ngOnDestroyHooks.add(record.value);
1408
+ finally {
1370
1409
  }
1371
- return record.value;
1372
1410
  }
1373
1411
  injectableDefInScope(def) {
1374
1412
  if (!def.providedIn) {
@@ -1412,7 +1450,6 @@ function getUndecoratedInjectableFactory(token) {
1412
1450
  // If the token has parameters then it has dependencies that we cannot resolve implicitly.
1413
1451
  const paramLength = token.length;
1414
1452
  if (paramLength > 0) {
1415
- const args = newArray(paramLength, '?');
1416
1453
  throw new RuntimeError(204 /* RuntimeErrorCode.INVALID_INJECTION_TOKEN */, null);
1417
1454
  }
1418
1455
  // The constructor function appears to have no parameters.
@@ -1548,10 +1585,10 @@ function createInjectorWithoutInjectorInstances(defType, parent = null, addition
1548
1585
  */
1549
1586
  /**
1550
1587
  * Concrete injectors implement this interface. Injectors are configured
1551
- * with [providers](guide/glossary#provider) that associate
1552
- * dependencies of various types with [injection tokens](guide/glossary#di-token).
1588
+ * with [providers](guide/dependency-injection-providers) that associate
1589
+ * dependencies of various types with [injection tokens](guide/dependency-injection-providers).
1553
1590
  *
1554
- * @see ["DI Providers"](guide/dependency-injection-providers).
1591
+ * @see [DI Providers](guide/dependency-injection-providers).
1555
1592
  * @see {@link StaticProvider}
1556
1593
  *
1557
1594
  * @usageNotes
@@ -1595,6 +1632,13 @@ class Injector {
1595
1632
  static __NG_ELEMENT_ID__ = -1 /* InjectorMarkers.Injector */;
1596
1633
  }
1597
1634
 
1635
+ /**
1636
+ * @license
1637
+ * Copyright Google LLC All Rights Reserved.
1638
+ *
1639
+ * Use of this source code is governed by an MIT-style license that can be
1640
+ * found in the LICENSE file at https://angular.io/license
1641
+ */
1598
1642
  /**
1599
1643
  * Throws an error indicating that a factory function could not be generated by the compiler for a
1600
1644
  * particular class.
@@ -5,8 +5,8 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import { Injector } from './injector';
9
- import { Provider, StaticProvider } from './interface/provider';
8
+ import type { Injector } from './injector';
9
+ import type { Provider, StaticProvider } from './interface/provider';
10
10
  import { R3Injector } from './r3_injector';
11
11
  import { InjectorScope } from './scope';
12
12
  /**
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import { Type } from '../interface/type';
9
9
  /**
10
- * An interface that a function passed into {@link forwardRef} has to implement.
10
+ * An interface that a function passed into `forwardRef` has to implement.
11
11
  *
12
12
  * @usageNotes
13
13
  * ### Example
@@ -0,0 +1 @@
1
+ export { ProviderToken } from './provider_token';
@@ -12,4 +12,4 @@ import { InjectionToken } from './injection_token';
12
12
  *
13
13
  * @publicApi
14
14
  */
15
- export declare const ENVIRONMENT_INITIALIZER: InjectionToken<() => void>;
15
+ export declare const ENVIRONMENT_INITIALIZER: InjectionToken<readonly (() => void)[]>;
@@ -16,11 +16,17 @@ import { Type } from '../interface/type';
16
16
  * `InjectionToken` is parameterized on `T` which is the type of object which will be returned by
17
17
  * the `Injector`. This provides an additional level of type safety.
18
18
  *
19
- * ```
20
- * interface MyInterface {...}
21
- * const myInterface = injector.get(new InjectionToken<MyInterface>('SomeToken'));
22
- * // myInterface is inferred to be MyInterface.
23
- * ```
19
+ * <div class="alert is-helpful">
20
+ *
21
+ * **Important Note**: Ensure that you use the same instance of the `InjectionToken` in both the
22
+ * provider and the injection call. Creating a new instance of `InjectionToken` in different places,
23
+ * even with the same description, will be treated as different tokens by Angular's DI system,
24
+ * leading to a `NullInjectorError`.
25
+ *
26
+ * </div>
27
+ *
28
+ * <code-example format="typescript" language="typescript" path="injection-token/src/main.ts"
29
+ * region="InjectionToken"></code-example>
24
30
  *
25
31
  * When creating an `InjectionToken`, you can optionally specify a factory function which returns
26
32
  * (possibly by creating) a default value of the parameterized type `T`. This sets up the
@@ -47,7 +53,6 @@ import { Type } from '../interface/type';
47
53
  *
48
54
  * {@example core/di/ts/injector_spec.ts region='ShakableInjectionToken'}
49
55
  *
50
- *
51
56
  * @publicApi
52
57
  */
53
58
  export declare class InjectionToken<T> {
@@ -11,10 +11,10 @@ import { Provider, StaticProvider } from './interface/provider';
11
11
  import { ProviderToken } from './provider_token';
12
12
  /**
13
13
  * Concrete injectors implement this interface. Injectors are configured
14
- * with [providers](guide/glossary#provider) that associate
15
- * dependencies of various types with [injection tokens](guide/glossary#di-token).
14
+ * with [providers](guide/dependency-injection-providers) that associate
15
+ * dependencies of various types with [injection tokens](guide/dependency-injection-providers).
16
16
  *
17
- * @see ["DI Providers"](guide/dependency-injection-providers).
17
+ * @see [DI Providers](guide/dependency-injection-providers).
18
18
  * @see {@link StaticProvider}
19
19
  *
20
20
  * @usageNotes
@@ -5,7 +5,7 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import { Injector } from './injector';
8
+ import type { Injector } from './injector';
9
9
  import { DecoratorFlags, InjectFlags, InjectOptions, InternalInjectFlags } from './interface/injector';
10
10
  import { ProviderToken } from './provider_token';
11
11
  export declare const THROW_IF_NOT_FOUND: {};
@@ -27,6 +27,7 @@ export declare function injectInjectorOnly<T>(token: ProviderToken<T>, flags?: I
27
27
  */
28
28
  export declare function ɵɵinject<T>(token: ProviderToken<T>): T;
29
29
  export declare function ɵɵinject<T>(token: ProviderToken<T>, flags?: InjectFlags): T | null;
30
+ export declare function ɵɵinject<T>(token: ProviderToken<T>, flags?: InjectFlags): string | null;
30
31
  /**
31
32
  * Throws an error indicating that a factory function could not be generated by the compiler for a
32
33
  * particular class.
@@ -6,7 +6,7 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  import { InjectionToken } from './injection_token';
9
- import { Injector } from './injector';
9
+ import type { Injector } from './injector';
10
10
  /**
11
11
  * An InjectionToken that gets the current `Injector` for `createInjector()`-style injectors.
12
12
  *
@@ -20,7 +20,7 @@ export interface ValueSansProvider {
20
20
  }
21
21
  /**
22
22
  * Configures the `Injector` to return a value for a token.
23
- * @see ["Dependency Injection Guide"](guide/dependency-injection).
23
+ * @see [Dependency Injection Guide](guide/dependency-injection).
24
24
  *
25
25
  * @usageNotes
26
26
  *
@@ -65,7 +65,7 @@ export interface StaticClassSansProvider {
65
65
  }
66
66
  /**
67
67
  * Configures the `Injector` to return an instance of `useClass` for a token.
68
- * @see ["Dependency Injection Guide"](guide/dependency-injection).
68
+ * @see [Dependency Injection Guide](guide/dependency-injection).
69
69
  *
70
70
  * @usageNotes
71
71
  *
@@ -95,7 +95,7 @@ export interface StaticClassProvider extends StaticClassSansProvider {
95
95
  /**
96
96
  * Configures the `Injector` to return an instance of a token.
97
97
  *
98
- * @see ["Dependency Injection Guide"](guide/dependency-injection).
98
+ * @see [Dependency Injection Guide](guide/dependency-injection).
99
99
  *
100
100
  * @usageNotes
101
101
  *
@@ -115,7 +115,7 @@ export interface ConstructorSansProvider {
115
115
  /**
116
116
  * Configures the `Injector` to return an instance of a token.
117
117
  *
118
- * @see ["Dependency Injection Guide"](guide/dependency-injection).
118
+ * @see [Dependency Injection Guide](guide/dependency-injection).
119
119
  *
120
120
  * @usageNotes
121
121
  *
@@ -142,7 +142,7 @@ export interface ConstructorProvider extends ConstructorSansProvider {
142
142
  * Configures the `Injector` to return a value of another `useExisting` token.
143
143
  *
144
144
  * @see {@link ExistingProvider}
145
- * @see ["Dependency Injection Guide"](guide/dependency-injection).
145
+ * @see [Dependency Injection Guide](guide/dependency-injection).
146
146
  *
147
147
  * @publicApi
148
148
  */
@@ -155,7 +155,7 @@ export interface ExistingSansProvider {
155
155
  /**
156
156
  * Configures the `Injector` to return a value of another `useExisting` token.
157
157
  *
158
- * @see ["Dependency Injection Guide"](guide/dependency-injection).
158
+ * @see [Dependency Injection Guide](guide/dependency-injection).
159
159
  *
160
160
  * @usageNotes
161
161
  *
@@ -182,7 +182,7 @@ export interface ExistingProvider extends ExistingSansProvider {
182
182
  * Configures the `Injector` to return a value by invoking a `useFactory` function.
183
183
  *
184
184
  * @see {@link FactoryProvider}
185
- * @see ["Dependency Injection Guide"](guide/dependency-injection).
185
+ * @see [Dependency Injection Guide](guide/dependency-injection).
186
186
  *
187
187
  * @publicApi
188
188
  */
@@ -200,7 +200,7 @@ export interface FactorySansProvider {
200
200
  }
201
201
  /**
202
202
  * Configures the `Injector` to return a value by invoking a `useFactory` function.
203
- * @see ["Dependency Injection Guide"](guide/dependency-injection).
203
+ * @see [Dependency Injection Guide](guide/dependency-injection).
204
204
  *
205
205
  * @usageNotes
206
206
  *
@@ -232,7 +232,7 @@ export interface FactoryProvider extends FactorySansProvider {
232
232
  * A static provider provides tokens to an injector for various types of dependencies.
233
233
  *
234
234
  * @see {@link Injector.create()}
235
- * @see ["Dependency Injection Guide"](guide/dependency-injection-providers).
235
+ * @see [Dependency Injection Guide](guide/dependency-injection-providers).
236
236
  *
237
237
  * @publicApi
238
238
  */
@@ -257,7 +257,7 @@ export interface TypeProvider extends Type<any> {
257
257
  * Configures the `Injector` to return a value by invoking a `useClass` function.
258
258
  * Base for `ClassProvider` decorator.
259
259
  *
260
- * @see ["Dependency Injection Guide"](guide/dependency-injection).
260
+ * @see [Dependency Injection Guide](guide/dependency-injection).
261
261
  *
262
262
  * @publicApi
263
263
  */
@@ -269,7 +269,7 @@ export interface ClassSansProvider {
269
269
  }
270
270
  /**
271
271
  * Configures the `Injector` to return an instance of `useClass` for a token.
272
- * @see ["Dependency Injection Guide"](guide/dependency-injection).
272
+ * @see [Dependency Injection Guide](guide/dependency-injection).
273
273
  *
274
274
  * @usageNotes
275
275
  *
@@ -298,7 +298,7 @@ export interface ClassProvider extends ClassSansProvider {
298
298
  }
299
299
  /**
300
300
  * Describes how the `Injector` should be configured.
301
- * @see ["Dependency Injection Guide"](guide/dependency-injection).
301
+ * @see [Dependency Injection Guide](guide/dependency-injection).
302
302
  *
303
303
  * @see {@link StaticProvider}
304
304
  *
@@ -7,4 +7,4 @@
7
7
  */
8
8
  import { Type } from '../interface/type';
9
9
  import { InjectionToken } from './injection_token';
10
- export declare const INJECTOR_DEF_TYPES: InjectionToken<Type<unknown>>;
10
+ export declare const INJECTOR_DEF_TYPES: InjectionToken<readonly Type<unknown>[]>;
@@ -25,7 +25,7 @@ export interface InjectDecorator {
25
25
  * <code-example path="core/di/ts/metadata_spec.ts" region="InjectWithoutDecorator">
26
26
  * </code-example>
27
27
  *
28
- * @see ["Dependency Injection Guide"](guide/dependency-injection)
28
+ * @see [Dependency Injection Guide](guide/dependency-injection)
29
29
  *
30
30
  */
31
31
  (token: any): any;
@@ -70,7 +70,7 @@ export interface OptionalDecorator {
70
70
  * <code-example path="core/di/ts/metadata_spec.ts" region="Optional">
71
71
  * </code-example>
72
72
  *
73
- * @see ["Dependency Injection Guide"](guide/dependency-injection).
73
+ * @see [Dependency Injection Guide](guide/dependency-injection).
74
74
  */
75
75
  (): any;
76
76
  new (): Optional;
@@ -5,7 +5,7 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import { Injector } from './injector';
8
+ import type { Injector } from './injector';
9
9
  export declare class NullInjector implements Injector {
10
10
  get(token: any, notFoundValue?: any): any;
11
11
  }
@@ -5,7 +5,7 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import { Injector } from './injector';
8
+ import type { Injector } from './injector';
9
9
  import { InjectorType } from './interface/defs';
10
10
  import { InjectFlags, InjectOptions } from './interface/injector';
11
11
  import { EnvironmentProviders, Provider } from './interface/provider';
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
8
+ /**
9
+ * This file should not be necessary because node resolution should just default to `./di/index`!
10
+ *
11
+ * However it does not seem to work and it breaks:
12
+ * - //packages/animations/browser/test:test_web_chromium-local
13
+ * - //packages/compiler-cli/test:extract_i18n
14
+ * - //packages/compiler-cli/test:ngc
15
+ * - //packages/compiler-cli/test:perform_watch
16
+ * - //packages/compiler-cli/test/diagnostics:check_types
17
+ * - //packages/compiler-cli/test/transformers:test
18
+ * - //packages/compiler/test:test
19
+ * - //tools/public_api_guard:core_api
20
+ *
21
+ * Remove this file once the above is solved or wait until `ngc` is deleted and then it should be
22
+ * safe to delete this file.
23
+ */
24
+ export * from './di/index';
@@ -26,7 +26,7 @@
26
26
  export declare const enum RuntimeErrorCode {
27
27
  EXPRESSION_CHANGED_AFTER_CHECKED = -100,
28
28
  RECURSIVE_APPLICATION_REF_TICK = 101,
29
- RECURSIVE_APPLICATION_RENDER = 102,
29
+ INFINITE_CHANGE_DETECTION = 103,
30
30
  CYCLIC_DI_DEPENDENCY = -200,
31
31
  PROVIDER_NOT_FOUND = -201,
32
32
  INVALID_FACTORY_DEPENDENCY = 202,
@@ -46,7 +46,7 @@ export declare const enum RuntimeErrorCode {
46
46
  INVALID_EVENT_BINDING = 306,
47
47
  HOST_DIRECTIVE_UNRESOLVABLE = 307,
48
48
  HOST_DIRECTIVE_NOT_STANDALONE = 308,
49
- DUPLICATE_DIRECTITVE = 309,
49
+ DUPLICATE_DIRECTIVE = 309,
50
50
  HOST_DIRECTIVE_COMPONENT = 310,
51
51
  HOST_DIRECTIVE_UNDEFINED_BINDING = 311,
52
52
  HOST_DIRECTIVE_CONFLICTING_ALIAS = 312,
@@ -69,8 +69,10 @@ export declare const enum RuntimeErrorCode {
69
69
  MISSING_SSR_CONTENT_INTEGRITY_MARKER = -507,
70
70
  SIGNAL_WRITE_FROM_ILLEGAL_CONTEXT = 600,
71
71
  REQUIRE_SYNC_WITHOUT_SYNC_EMIT = 601,
72
+ ASSERTION_NOT_INSIDE_REACTIVE_CONTEXT = -602,
72
73
  INVALID_I18N_STRUCTURE = 700,
73
74
  MISSING_LOCALE_DATA = 701,
75
+ DEFER_LOADING_FAILED = 750,
74
76
  IMPORT_PROVIDERS_FROM_STANDALONE = 800,
75
77
  INVALID_DIFFER_INPUT = 900,
76
78
  NO_SUPPORTING_DIFFER_FACTORY = 901,
@@ -85,7 +87,13 @@ export declare const enum RuntimeErrorCode {
85
87
  UNSAFE_IFRAME_ATTRS = -910,
86
88
  VIEW_ALREADY_DESTROYED = 911,
87
89
  COMPONENT_ID_COLLISION = -912,
88
- RUNTIME_DEPS_INVALID_IMPORTED_TYPE = 1000
90
+ IMAGE_PERFORMANCE_WARNING = -913,
91
+ REQUIRED_INPUT_NO_VALUE = -950,
92
+ REQUIRED_QUERY_NO_VALUE = -951,
93
+ REQUIRED_MODEL_NO_VALUE = -952,
94
+ OUTPUT_REF_DESTROYED = 953,
95
+ RUNTIME_DEPS_INVALID_IMPORTED_TYPE = 1000,
96
+ RUNTIME_DEPS_ORPHAN_COMPONENT = 1001
89
97
  }
90
98
  /**
91
99
  * Class that represents a runtime error.
@@ -5,5 +5,6 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
+ import type { ProviderToken } from '../di';
8
9
  /** Throws an error when a token is not found in DI. */
9
- export declare function throwProviderNotFoundError(token: any, injectorName?: string): never;
10
+ export declare function throwProviderNotFoundError(token: ProviderToken<unknown>, injectorName?: string): never;
@@ -1,3 +1,10 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
1
8
  /**
2
9
  * Throws an error indicating that a factory function could not be generated by the compiler for a
3
10
  * particular class.
@@ -14,6 +14,7 @@
14
14
  export declare function renderStringify(value: any): string;
15
15
  /**
16
16
  * Used to stringify a value so that it can be displayed in an error message.
17
+ *
17
18
  * Important! This function contains a megamorphic read and should only be
18
19
  * used for error messages.
19
20
  */
@@ -1,3 +1,10 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
1
8
  export declare function deepForEach<T>(input: (T | any[])[], fn: (value: T) => void): void;
2
9
  export declare function newArray<T = any>(size: number): T[];
3
10
  export declare function newArray<T>(size: number, value: T): T[];
@@ -11,5 +11,5 @@
11
11
  * allows for identity checks against these values to be consistently used by the framework
12
12
  * code.
13
13
  */
14
- export declare const EMPTY_OBJ: {};
14
+ export declare const EMPTY_OBJ: never;
15
15
  export declare const EMPTY_ARRAY: any[];