If a domain isolation is strong, you don't necessarily have to extract out the module the same structure as other domains
service/repository/gateway
split
gateway
from the same directory as a service
when the domain isolation is strongExport symbols through public contract (index.ts
)
index.ts
is a JS feature to reference default export of a directoryWhat does this mean: export/import of type references only in index
index
, it shouldn’t be referenced and abstracted away
Class
itself can be an interface contract
Since instantiation of class is an object (what essentially Interface
achieves), you can use the Class directly as the interface
// Bclass.js import Aclass from "./Aclass.js"; export class Bclass { constructor(private a: Aclass) { ... } }
Another Valid Example
class Person { "name": "sam" } let s = "hello"; let n: Person; n = { "name": "sam", }