This repository was archived by the owner on Dec 4, 2017. It is now read-only.
File tree 1 file changed +14
-5
lines changed
public/docs/ts/latest/guide 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -430,11 +430,20 @@ block injectable-not-always-needed-in-ts
430
430
+ ifDocsFor('ts' )
431
431
.l-sub-section
432
432
:marked
433
- Injectors use a class's constructor metadata to determine dependent types as
434
- identified by the constructor's parameter types.
435
- TypeScript generates such metadata for any class with a decorator, and any decorator will do.
436
- But of course, it is more meaningful to mark a class using the appropriate
437
- <a href="#{injMetaUrl}">InjectableMetadata</a> #{_decorator}.
433
+ At runtime, injectors can read class metadata in the transpiled JavaScript code
434
+ and use the constructor parameter type information
435
+ to determine what things to inject.
436
+
437
+ Not every JavaScript class has metadata.
438
+ The TypeScript compiler discards metadata by default.
439
+ If the `emitDecoratorMetadata` compiler option is true
440
+ (as it should be in the `tsconfig.json`),
441
+ the compiler adds the metadata to the generated JavaScript
442
+ for _every class with at least one decorator_.
443
+
444
+ While any decorator will trigger this effect, mark the service class with the
445
+ <a href="#{injMetaUrl}">InjectableMetadata</a> #{_decorator}
446
+ to make the intent clear.
438
447
439
448
.callout.is-critical
440
449
header Always include the parentheses
You can’t perform that action at this time.
0 commit comments