diff options
author | Carter Snook <cartersnook04@gmail.com> | 2020-10-19 21:41:40 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-20 13:41:40 +1100 |
commit | 4ff5003eb6cc929db9986a999c4366f5337a27f7 (patch) | |
tree | da38336e0a80c0ac2bb259ce6d06d043f9eda6b5 | |
parent | 623ac9e6df660b758aa3da281b6ff2b4db265ef0 (diff) |
docs(cli): interfaces used as parameters should be exported (#7500)
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
-rw-r--r-- | docs/contributing/style_guide.md | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/docs/contributing/style_guide.md b/docs/contributing/style_guide.md index 261a03cc9..d275274e7 100644 --- a/docs/contributing/style_guide.md +++ b/docs/contributing/style_guide.md @@ -174,6 +174,28 @@ export interface PWrite { export function pwrite(options: PWrite) {} ``` +### Export all interfaces that are used as parameters to an exported member + +Whenever you are using interfaces that are included in the arguments of an +exported member, you should export the interface that is used. Here is an +example: + +```ts +// my_file.ts +export interface Person { + name: string; + age: number; +} + +export function createPerson(name: string, age: number): Person { + return { name, age }; +} + +// mod.ts +export { createPerson } from "./my_file.ts"; +export type { Person } from "./my_file.ts"; +``` + ### Minimize dependencies; do not make circular imports. Although `cli/js` and `std` have no external dependencies, we must still be |