From 2e57e99e34d853edfe4b645efaf1cbf9c9f248a4 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 30 Nov 2021 14:15:25 +0000 Subject: [PATCH] clarify when to use type and interface --- doc/TS-MIGRATION.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/TS-MIGRATION.md b/doc/TS-MIGRATION.md index 7cb5bb34..006b3077 100644 --- a/doc/TS-MIGRATION.md +++ b/doc/TS-MIGRATION.md @@ -5,3 +5,11 @@ - find all methods and getters that throw or are empty in base classes and turn into abstract method or if all methods are abstract, into an interface. - change child impls to not call super.method and to add override - don't allow implicit override in ts config + +## Use `type` rather than `interface` for named parameters and POJO return values. + +`type` and `interface` can be used somewhat interchangebly used, but let's use `type` to describe data and `interface` to describe (polymorphic) behaviour. + +Good examples of data are option objects to have named parameters, and POJO (plain old javascript objects) without any methods, just fields. + +Also see [this playground](https://www.typescriptlang.org/play?#code/C4TwDgpgBACghgJwgO2AeTMAlge2QZygF4oBvAKCiqmTgFsIAuKfYBLZAcwG5LqATCABs4IAPzNkAVzoAjCAl4BfcuVCQoAYQAWWIfwzY8hEvCSpDuAlABkZPlQDGOITgTNW7LstWOR+QjMUYHtqKGcCNilHYDcAChxMK3xmIIsk4wBKewcoFRVyPzgArV19KAgAD2AUfkDEYNDqCM9o2IQEjIJmHT0DLvxsijCw-ClIDsSjAkzeEebjEIYAuE5oEgADABJSKeSAOloGJSgsQh29433nVwQlDbnqfKA)