[js] Add guidance about avoiding subclassing across package boundaries. (#3205)

* Add guidance about avoiding subclassing across package boundaries.
This commit is contained in:
Jeff Fisher 2022-05-16 11:41:56 -07:00 коммит произвёл GitHub
Родитель 53cd66a0dc
Коммит dc94ded866
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 2 добавлений и 0 удалений

Просмотреть файл

@ -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