[js] Add guidance about avoiding subclassing across package boundaries. (#3205)
* Add guidance about avoiding subclassing across package boundaries.
This commit is contained in:
Родитель
53cd66a0dc
Коммит
dc94ded866
|
@ -365,6 +365,8 @@ Both iterators and async iterators are built into JavaScript and easy to consume
|
|||
|
||||
{% include requirement/SHOULD id="ts-use-interface-parameters" %} prefer interface types to class types. JavaScript is fundamentally a duck-typed language, and so alternative classes that implement the same interface should be allowed. Declare parameters as interface types over class types whenever possible. Overloads with specific class types are fine but there should be an overload present with the generic interface.
|
||||
|
||||
{% include requirement/MUST id="ts-avoid-extending-cross-package" %} not extend classes from a different package. It can be non-obvious that a dependent package is broken by a change to a base class. For example, adding a non-compatible method signature or a new private member is considered a non-breaking additive change, but would potentially conflict in the derived class.
|
||||
|
||||
<a name="ts-example-iterators"></a>
|
||||
|
||||
```javascript
|
||||
|
|
Загрузка…
Ссылка в новой задаче