static-injector 2.0.0 → 2.1.1

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 (107) hide show
  1. package/import/commonjs/index.js +425 -163
  2. package/import/es2015/di/create_injector.js +5 -1
  3. package/import/es2015/di/forward_ref.js +3 -3
  4. package/import/es2015/di/injection_token.js +18 -11
  5. package/import/es2015/di/injector_compatibility.js +19 -10
  6. package/import/es2015/di/injector_token.js +3 -3
  7. package/import/es2015/di/interface/defs.js +21 -12
  8. package/import/es2015/di/interface/provider.js +3 -1
  9. package/import/es2015/di/null_injector.js +3 -3
  10. package/import/es2015/di/provider_collection.js +196 -1
  11. package/import/es2015/di/r3_injector.js +31 -28
  12. package/import/es2015/error_details_base_url.js +19 -0
  13. package/import/es2015/errors.js +42 -0
  14. package/import/es2015/interface/type.js +14 -1
  15. package/import/es2015/render3/definition_factory.js +2 -3
  16. package/import/es2015/render3/errors_di.js +2 -3
  17. package/import/es2015/render3/instructions/di.js +0 -7
  18. package/import/es2015/render3/util/stringify_utils.js +5 -5
  19. package/import/es2015/util/array_utils.js +0 -7
  20. package/import/es2015/util/decorators.js +24 -1
  21. package/import/es2015/util/empty.js +4 -0
  22. package/import/es2015/util/stringify.js +5 -5
  23. package/import/fesm2015/index.js +422 -161
  24. package/import/typings/di/forward_ref.d.ts +1 -1
  25. package/import/typings/di/injectable.d.ts +5 -4
  26. package/import/typings/di/injection_token.d.ts +21 -6
  27. package/import/typings/di/injector.d.ts +16 -0
  28. package/import/typings/di/injector_compatibility.d.ts +11 -5
  29. package/import/typings/di/injector_token.d.ts +2 -2
  30. package/import/typings/di/interface/defs.d.ts +15 -8
  31. package/import/typings/di/interface/provider.d.ts +62 -2
  32. package/import/typings/di/null_injector.d.ts +1 -1
  33. package/import/typings/di/provider_collection.d.ts +55 -2
  34. package/import/typings/di/provider_token.d.ts +3 -3
  35. package/import/typings/di/r3_injector.d.ts +3 -8
  36. package/import/typings/di/scope.d.ts +1 -1
  37. package/import/typings/error_details_base_url.d.ts +19 -0
  38. package/import/typings/errors.d.ts +89 -0
  39. package/import/typings/interface/type.d.ts +45 -0
  40. package/import/typings/render3/definition_factory.d.ts +1 -1
  41. package/import/typings/render3/errors_di.d.ts +7 -0
  42. package/import/typings/render3/instructions/di.d.ts +0 -7
  43. package/import/typings/util/array_utils.d.ts +15 -7
  44. package/import/typings/util/decorators.d.ts +2 -1
  45. package/import/typings/util/empty.d.ts +1 -0
  46. package/package.json +3 -3
  47. package/transform/compiler/compiler.d.ts +8 -0
  48. package/transform/compiler/compiler.js +28 -0
  49. package/transform/compiler/index.d.ts +8 -5
  50. package/transform/compiler/index.js +12 -5
  51. package/transform/compiler/public_api.d.ts +13 -0
  52. package/transform/compiler/public_api.js +30 -0
  53. package/transform/compiler/src/compiler.d.ts +27 -0
  54. package/transform/compiler/src/compiler.js +47 -0
  55. package/transform/compiler/src/output/output_ast.d.ts +1 -1
  56. package/transform/compiler/src/render3/partial/api.d.ts +1 -1
  57. package/transform/compiler/src/render3/partial/api.js +7 -0
  58. package/transform/compiler/src/render3/r3_factory.d.ts +8 -15
  59. package/transform/compiler/src/render3/r3_factory.js +37 -56
  60. package/transform/compiler/src/render3/view/util.d.ts +0 -8
  61. package/transform/compiler/src/render3/view/util.js +0 -8
  62. package/transform/compiler-cli/src/ngtsc/annotations/common/index.d.ts +10 -0
  63. package/transform/compiler-cli/src/ngtsc/annotations/common/index.js +26 -0
  64. package/transform/compiler-cli/src/ngtsc/annotations/common/src/di.d.ts +37 -0
  65. package/transform/compiler-cli/src/ngtsc/annotations/common/src/di.js +197 -0
  66. package/transform/compiler-cli/src/ngtsc/annotations/{src → common/src}/factory.d.ts +3 -3
  67. package/transform/compiler-cli/src/ngtsc/annotations/{src → common/src}/factory.js +2 -2
  68. package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.d.ts +3 -34
  69. package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.js +18 -216
  70. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.d.ts +3 -4
  71. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.js +31 -50
  72. package/transform/compiler-cli/src/ngtsc/diagnostics/index.d.ts +9 -2
  73. package/transform/compiler-cli/src/ngtsc/diagnostics/index.js +7 -0
  74. package/transform/compiler-cli/src/ngtsc/imports/index.d.ts +7 -0
  75. package/transform/compiler-cli/src/ngtsc/imports/index.js +7 -0
  76. package/transform/compiler-cli/src/ngtsc/imports/src/default.d.ts +19 -0
  77. package/transform/compiler-cli/src/ngtsc/imports/src/default.js +28 -0
  78. package/transform/compiler-cli/src/ngtsc/reflection/index.d.ts +10 -3
  79. package/transform/compiler-cli/src/ngtsc/reflection/index.js +7 -0
  80. package/transform/compiler-cli/src/ngtsc/reflection/src/host.d.ts +12 -13
  81. package/transform/compiler-cli/src/ngtsc/reflection/src/host.js +7 -28
  82. package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.d.ts +1 -1
  83. package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.js +17 -41
  84. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.d.ts +1 -1
  85. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.js +46 -65
  86. package/transform/compiler-cli/src/ngtsc/reflection/src/util.d.ts +2 -2
  87. package/transform/compiler-cli/src/ngtsc/reflection/src/util.js +7 -27
  88. package/transform/compiler-cli/src/ngtsc/transform/index.d.ts +9 -2
  89. package/transform/compiler-cli/src/ngtsc/transform/index.js +7 -0
  90. package/transform/compiler-cli/src/ngtsc/transform/src/api.d.ts +4 -4
  91. package/transform/compiler-cli/src/ngtsc/transform/src/utils.d.ts +1 -1
  92. package/transform/compiler-cli/src/ngtsc/transform/src/utils.js +15 -35
  93. package/transform/compiler-cli/src/ngtsc/translator/index.d.ts +12 -5
  94. package/transform/compiler-cli/src/ngtsc/translator/index.js +7 -0
  95. package/transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.d.ts +5 -5
  96. package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.d.ts +2 -2
  97. package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.js +4 -24
  98. package/transform/compiler-cli/src/ngtsc/translator/src/translator.d.ts +2 -2
  99. package/transform/compiler-cli/src/ngtsc/translator/src/translator.js +1 -1
  100. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.d.ts +1 -1
  101. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.js +76 -95
  102. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_translator.d.ts +4 -4
  103. package/transform/compiler-cli/src/ngtsc/ts_compatibility/src/ts_cross_version_utils.d.ts +20 -126
  104. package/transform/compiler-cli/src/ngtsc/ts_compatibility/src/ts_cross_version_utils.js +23 -147
  105. package/transform/compiler-cli/src/ngtsc/util/src/typescript.d.ts +1 -8
  106. package/transform/compiler-cli/src/ngtsc/util/src/typescript.js +4 -31
  107. package/transform/injectable-transform.js +36 -7
@@ -5,20 +5,23 @@
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 { RuntimeError } from '../errors';
8
9
  import { getFactoryDef } from '../render3/definition_factory';
9
10
  import { newArray } from '../util/array_utils';
10
11
  import { EMPTY_ARRAY } from '../util/empty';
11
12
  import { stringify } from '../util/stringify';
12
13
  import { resolveForwardRef } from './forward_ref';
13
14
  import { ENVIRONMENT_INITIALIZER } from './initializer_token';
15
+ import { setInjectImplementation } from './inject_switch';
14
16
  import { InjectionToken } from './injection_token';
15
- import { catchInjectorError, convertToBitFlags, injectArgs, NG_TEMP_TOKEN_PATH, setCurrentInjector, THROW_IF_NOT_FOUND, USE_VALUE, ɵɵinject, } from './injector_compatibility';
17
+ import { catchInjectorError, convertToBitFlags, injectArgs, NG_TEMP_TOKEN_PATH, setCurrentInjector, THROW_IF_NOT_FOUND, ɵɵinject, } from './injector_compatibility';
16
18
  import { INJECTOR } from './injector_token';
17
- import { setInjectImplementation } from './inject_switch';
18
19
  import { getInheritedInjectableDef, getInjectableDef, } from './interface/defs';
19
20
  import { InjectFlags } from './interface/injector';
21
+ import { isEnvironmentProviders, } from './interface/provider';
20
22
  import { INJECTOR_DEF_TYPES } from './internal_tokens';
21
23
  import { NullInjector } from './null_injector';
24
+ import { isExistingProvider, isFactoryProvider, isTypeProvider, isValueProvider, } from './provider_collection';
22
25
  import { INJECTOR_SCOPE } from './scope';
23
26
  /**
24
27
  * Marker which indicates that a value has not yet been created from the factory function.
@@ -49,6 +52,12 @@ export function getNullInjector() {
49
52
  export class EnvironmentInjector {
50
53
  }
51
54
  export class R3Injector extends EnvironmentInjector {
55
+ /**
56
+ * Flag indicating that this injector was previously destroyed.
57
+ */
58
+ get destroyed() {
59
+ return this._destroyed;
60
+ }
52
61
  constructor(providers, parent, source, scopes) {
53
62
  super();
54
63
  this.parent = parent;
@@ -82,12 +91,6 @@ export class R3Injector extends EnvironmentInjector {
82
91
  }
83
92
  this.injectorDefTypes = new Set(this.get(INJECTOR_DEF_TYPES.multi, EMPTY_ARRAY, InjectFlags.Self));
84
93
  }
85
- /**
86
- * Flag indicating that this injector was previously destroyed.
87
- */
88
- get destroyed() {
89
- return this._destroyed;
90
- }
91
94
  /**
92
95
  * Destroy the injector and release references to every instance or provider associated with it.
93
96
  *
@@ -203,6 +206,8 @@ export class R3Injector extends EnvironmentInjector {
203
206
  const previousInjectImplementation = setInjectImplementation(undefined);
204
207
  try {
205
208
  const initializers = this.get(ENVIRONMENT_INITIALIZER.multi, EMPTY_ARRAY, InjectFlags.Self);
209
+ if (false) {
210
+ }
206
211
  for (const initializer of initializers) {
207
212
  initializer();
208
213
  }
@@ -222,7 +227,7 @@ export class R3Injector extends EnvironmentInjector {
222
227
  }
223
228
  assertNotDestroyed() {
224
229
  if (this._destroyed) {
225
- throw new Error('Injector has already been destroyed.');
230
+ throw new RuntimeError(205 /* RuntimeErrorCode.INJECTOR_ALREADY_DESTROYED */, null);
226
231
  }
227
232
  }
228
233
  /**
@@ -243,6 +248,8 @@ export class R3Injector extends EnvironmentInjector {
243
248
  let multiRecord = this.records.get(token);
244
249
  if (multiRecord) {
245
250
  // It has. Throw a nice error if
251
+ if (false) {
252
+ }
246
253
  }
247
254
  else {
248
255
  multiRecord = makeRecord(undefined, NOT_YET, true);
@@ -254,11 +261,15 @@ export class R3Injector extends EnvironmentInjector {
254
261
  }
255
262
  else {
256
263
  const existing = this.records.get(token);
264
+ if (false) {
265
+ }
257
266
  }
258
267
  this.records.set(token, record);
259
268
  }
260
269
  hydrate(token, record) {
261
- if (record.value === NOT_YET) {
270
+ if (false) {
271
+ }
272
+ else if (record.value === NOT_YET) {
262
273
  record.value = CIRCULAR;
263
274
  record.value = record.factory();
264
275
  }
@@ -292,21 +303,21 @@ function injectableDefOrInjectorDefFactory(token) {
292
303
  // InjectionTokens should have an injectable def (ɵprov) and thus should be handled above.
293
304
  // If it's missing that, it's an error.
294
305
  if (token instanceof InjectionToken) {
295
- throw new Error(`Token ${stringify(token)} is missing a ɵprov definition.`);
306
+ throw new RuntimeError(204 /* RuntimeErrorCode.INVALID_INJECTION_TOKEN */, null);
296
307
  }
297
308
  // Undecorated types can sometimes be created if they have no constructor arguments.
298
309
  if (token instanceof Function) {
299
310
  return getUndecoratedInjectableFactory(token);
300
311
  }
301
312
  // There was no way to resolve a factory for this token.
302
- throw new Error('unreachable');
313
+ throw new RuntimeError(204 /* RuntimeErrorCode.INVALID_INJECTION_TOKEN */, null);
303
314
  }
304
315
  function getUndecoratedInjectableFactory(token) {
305
316
  // If the token has parameters then it has dependencies that we cannot resolve implicitly.
306
317
  const paramLength = token.length;
307
318
  if (paramLength > 0) {
308
319
  const args = newArray(paramLength, '?');
309
- throw new Error(`Can't resolve all parameters for ${stringify(token)}: (${args.join(', ')}).`);
320
+ throw new RuntimeError(204 /* RuntimeErrorCode.INVALID_INJECTION_TOKEN */, null);
310
321
  }
311
322
  // The constructor function appears to have no parameters.
312
323
  // This might be because it inherits from a super-class. In which case, use an injectable
@@ -337,6 +348,8 @@ function providerToRecord(provider) {
337
348
  */
338
349
  export function providerToFactory(provider, ngModuleType, providers) {
339
350
  let factory = undefined;
351
+ if (false) {
352
+ }
340
353
  if (isTypeProvider(provider)) {
341
354
  const unwrappedProvider = resolveForwardRef(provider);
342
355
  return (getFactoryDef(unwrappedProvider) ||
@@ -356,9 +369,8 @@ export function providerToFactory(provider, ngModuleType, providers) {
356
369
  const classRef = resolveForwardRef(provider &&
357
370
  (provider.useClass ||
358
371
  provider.provide));
359
- // if (ngDevMode && !classRef) {
360
- // throwInvalidProviderError(ngModuleType, providers, provider);
361
- // }
372
+ if (false) {
373
+ }
362
374
  if (hasDeps(provider)) {
363
375
  factory = () => new classRef(...injectArgs(provider.deps));
364
376
  }
@@ -376,18 +388,6 @@ function makeRecord(factory, value, multi = false) {
376
388
  multi: multi ? [] : undefined,
377
389
  };
378
390
  }
379
- function isValueProvider(value) {
380
- return value !== null && typeof value == 'object' && USE_VALUE in value;
381
- }
382
- function isExistingProvider(value) {
383
- return !!(value && value.useExisting);
384
- }
385
- function isFactoryProvider(value) {
386
- return !!(value && value.useFactory);
387
- }
388
- export function isTypeProvider(value) {
389
- return typeof value === 'function';
390
- }
391
391
  function hasDeps(value) {
392
392
  return !!value.deps;
393
393
  }
@@ -405,6 +405,9 @@ function forEachSingleProvider(providers, fn) {
405
405
  if (Array.isArray(provider)) {
406
406
  forEachSingleProvider(provider, fn);
407
407
  }
408
+ else if (provider && isEnvironmentProviders(provider)) {
409
+ forEachSingleProvider(provider.ɵproviders, fn);
410
+ }
408
411
  else {
409
412
  fn(provider);
410
413
  }
@@ -0,0 +1,19 @@
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
+ * Base URL for the error details page.
10
+ *
11
+ * Keep this constant in sync across:
12
+ * - packages/compiler-cli/src/ngtsc/diagnostics/src/error_details_base_url.ts
13
+ * - packages/core/src/error_details_base_url.ts
14
+ */
15
+ export const ERROR_DETAILS_PAGE_BASE_URL = 'https://angular.io/errors';
16
+ /**
17
+ * URL for the XSS security documentation.
18
+ */
19
+ export const XSS_SECURITY_URL = 'https://g.co/ng/security#xss';
@@ -0,0 +1,42 @@
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
+ * Class that represents a runtime error.
10
+ * Formats and outputs the error message in a consistent way.
11
+ *
12
+ * Example:
13
+ * ```
14
+ * throw new RuntimeError(
15
+ * RuntimeErrorCode.INJECTOR_ALREADY_DESTROYED,
16
+ * ngDevMode && 'Injector has already been destroyed.');
17
+ * ```
18
+ *
19
+ * Note: the `message` argument contains a descriptive error message as a string in development
20
+ * mode (when the `ngDevMode` is defined). In production mode (after tree-shaking pass), the
21
+ * `message` argument becomes `false`, thus we account for it in the typings and the runtime logic.
22
+ */
23
+ export class RuntimeError extends Error {
24
+ constructor(code, message) {
25
+ super(formatRuntimeError(code, message));
26
+ this.code = code;
27
+ }
28
+ }
29
+ /**
30
+ * Called to format a runtime error.
31
+ * See additional info on the `message` argument type in the `RuntimeError` class description.
32
+ */
33
+ export function formatRuntimeError(code, message) {
34
+ // Error code might be a negative number, which is a special marker that instructs the logic to
35
+ // generate a link to the error details page on angular.io.
36
+ // We also prepend `0` to non-compile-time errors.
37
+ const fullCode = `NG0${Math.abs(code)}`;
38
+ let errorMessage = `${fullCode}${message ? ': ' + message.trim() : ''}`;
39
+ if (false) {
40
+ }
41
+ return errorMessage;
42
+ }
@@ -5,4 +5,17 @@
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
- export {};
8
+ /**
9
+ * @description
10
+ *
11
+ * Represents a type that a Component or other object is instances of.
12
+ *
13
+ * An example of a `Type` is `MyCustomComponent` class, which in JavaScript is represented by
14
+ * the `MyCustomComponent` constructor function.
15
+ *
16
+ * @publicApi
17
+ */
18
+ export const Type = Function;
19
+ export function isType(v) {
20
+ return typeof v === 'function';
21
+ }
@@ -8,8 +8,7 @@
8
8
  import { NG_FACTORY_DEF } from './fields';
9
9
  export function getFactoryDef(type, throwNotFound) {
10
10
  const hasFactoryDef = type.hasOwnProperty(NG_FACTORY_DEF);
11
- // if (!hasFactoryDef && throwNotFound === true && ngDevMode) {
12
- // throw new Error(`Type ${stringify(type)} does not have 'ɵfac' property.`);
13
- // }
11
+ if (false) {
12
+ }
14
13
  return hasFactoryDef ? type[NG_FACTORY_DEF] : null;
15
14
  }
@@ -5,10 +5,9 @@
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 { RuntimeError } from './error_code';
9
- import { stringifyForError } from './util/stringify_utils';
8
+ import { RuntimeError } from '../errors';
10
9
  /** Throws an error when a token is not found in DI. */
11
10
  export function throwProviderNotFoundError(token, injectorName) {
12
11
  const injectorDetails = injectorName ? ` in ${injectorName}` : '';
13
- throw new RuntimeError("201" /* RuntimeErrorCode.PROVIDER_NOT_FOUND */, `No provider for ${stringifyForError(token)} found${injectorDetails}`);
12
+ throw new RuntimeError(-201 /* RuntimeErrorCode.PROVIDER_NOT_FOUND */, null);
14
13
  }
@@ -1,10 +1,3 @@
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
1
  /**
9
2
  * Throws an error indicating that a factory function could not be generated by the compiler for a
10
3
  * particular class.
@@ -12,10 +12,10 @@
12
12
  * Check `core/test/render3/perf/render_stringify` for benchmarks and alternate implementations.
13
13
  */
14
14
  export function renderStringify(value) {
15
- if (typeof value === "string")
15
+ if (typeof value === 'string')
16
16
  return value;
17
17
  if (value == null)
18
- return "";
18
+ return '';
19
19
  // Use `String` so that it invokes the `toString` method of the value. Note that this
20
20
  // appears to be faster than calling `value.toString` (see `render_stringify` benchmark).
21
21
  return String(value);
@@ -26,11 +26,11 @@ export function renderStringify(value) {
26
26
  * used for error messages.
27
27
  */
28
28
  export function stringifyForError(value) {
29
- if (typeof value === "function")
29
+ if (typeof value === 'function')
30
30
  return value.name || value.toString();
31
- if (typeof value === "object" &&
31
+ if (typeof value === 'object' &&
32
32
  value != null &&
33
- typeof value.type === "function") {
33
+ typeof value.type === 'function') {
34
34
  return value.type.name || value.type.toString();
35
35
  }
36
36
  return renderStringify(value);
@@ -1,10 +1,3 @@
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
1
  export function deepForEach(input, fn) {
9
2
  input.forEach((value) => Array.isArray(value) ? deepForEach(value, fn) : fn(value));
10
3
  }
@@ -6,6 +6,7 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  import { noSideEffects } from './closure';
9
+ export const PARAMETERS = '__parameters__';
9
10
  function makeMetadataCtor(props) {
10
11
  return function ctor(...args) {
11
12
  if (props) {
@@ -16,7 +17,7 @@ function makeMetadataCtor(props) {
16
17
  }
17
18
  };
18
19
  }
19
- export function makeParamDecorator(name, props) {
20
+ export function makeParamDecorator(name, props, parentClass) {
20
21
  return noSideEffects(() => {
21
22
  const metaCtor = makeMetadataCtor(props);
22
23
  function ParamDecoratorFactory(...args) {
@@ -24,7 +25,29 @@ export function makeParamDecorator(name, props) {
24
25
  metaCtor.apply(this, args);
25
26
  return this;
26
27
  }
28
+ const annotationInstance = new ParamDecoratorFactory(...args);
29
+ ParamDecorator.annotation = annotationInstance;
30
+ return ParamDecorator;
31
+ function ParamDecorator(cls, unusedKey, index) {
32
+ // Use of Object.defineProperty is important since it creates non-enumerable property which
33
+ // prevents the property is copied during subclassing.
34
+ const parameters = cls.hasOwnProperty(PARAMETERS)
35
+ ? cls[PARAMETERS]
36
+ : Object.defineProperty(cls, PARAMETERS, { value: [] })[PARAMETERS];
37
+ // there might be gaps if some in between parameters do not have annotations.
38
+ // we pad with nulls.
39
+ while (parameters.length <= index) {
40
+ parameters.push(null);
41
+ }
42
+ (parameters[index] = parameters[index] || []).push(annotationInstance);
43
+ return cls;
44
+ }
45
+ }
46
+ if (parentClass) {
47
+ ParamDecoratorFactory.prototype = Object.create(parentClass.prototype);
27
48
  }
49
+ ParamDecoratorFactory.prototype.ngMetadataName = name;
50
+ ParamDecoratorFactory.annotationCls = ParamDecoratorFactory;
28
51
  return ParamDecoratorFactory;
29
52
  });
30
53
  }
@@ -11,4 +11,8 @@
11
11
  * allows for identity checks against these values to be consistently used by the framework
12
12
  * code.
13
13
  */
14
+ export const EMPTY_OBJ = {};
14
15
  export const EMPTY_ARRAY = [];
16
+ // freezing the values prevents any code from accidentally inserting new values in
17
+ if (false) {
18
+ }
@@ -6,14 +6,14 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  export function stringify(token) {
9
- if (typeof token === "string") {
9
+ if (typeof token === 'string') {
10
10
  return token;
11
11
  }
12
12
  if (Array.isArray(token)) {
13
- return "[" + token.map(stringify).join(", ") + "]";
13
+ return '[' + token.map(stringify).join(', ') + ']';
14
14
  }
15
15
  if (token == null) {
16
- return "" + token;
16
+ return '' + token;
17
17
  }
18
18
  if (token.overriddenName) {
19
19
  return `${token.overriddenName}`;
@@ -23,8 +23,8 @@ export function stringify(token) {
23
23
  }
24
24
  const res = token.toString();
25
25
  if (res == null) {
26
- return "" + res;
26
+ return '' + res;
27
27
  }
28
- const newLineIndex = res.indexOf("\n");
28
+ const newLineIndex = res.indexOf('\n');
29
29
  return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
30
30
  }