diff --git a/public/docs/ts/latest/guide/dependency-injection.jade b/public/docs/ts/latest/guide/dependency-injection.jade index 759f303791..2ad5b7a7ed 100644 --- a/public/docs/ts/latest/guide/dependency-injection.jade +++ b/public/docs/ts/latest/guide/dependency-injection.jade @@ -430,11 +430,20 @@ block injectable-not-always-needed-in-ts +ifDocsFor('ts') .l-sub-section :marked - Injectors use a class's constructor metadata to determine dependent types as - identified by the constructor's parameter types. - TypeScript generates such metadata for any class with a decorator, and any decorator will do. - But of course, it is more meaningful to mark a class using the appropriate - InjectableMetadata #{_decorator}. + At runtime, injectors can read class metadata in the transpiled JavaScript code + and use the constructor parameter type information + to determine what things to inject. + + Not every JavaScript class has metadata. + The TypeScript compiler discards metadata by default. + If the `emitDecoratorMetadata` compiler option is true + (as it should be in the `tsconfig.json`), + the compiler adds the metadata to the generated JavaScript + for _every class with at least one decorator_. + + While any decorator will trigger this effect, mark the service class with the + InjectableMetadata #{_decorator} + to make the intent clear. .callout.is-critical header Always include the parentheses