Last active
September 17, 2019 02:04
-
-
Save john-osullivan/8e7c6b6723518dc646d7197a52020110 to your computer and use it in GitHub Desktop.
Dev Diaries #2 - Module layout for easy imports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The type reference is so wordy! This isn't convenient. | |
import Types from '@eximchain/dappbot-types'; | |
const args: Types.Methods.Auth.Login.Args = { ... }; | |
// We can make the reference more compact by importing a | |
// more specific slice of the overall types. | |
import Auth from '@eximchain/dappbot-types/spec/methods'; | |
const args: Auth.Login.Args = { ... }; | |
// The narrowest import is grabbing specific values from | |
// the sub-module, like the Login namespace | |
import { Login } from '@eximchain/dappbot-types/spec/methods/auth'; | |
const args: Login.Args = { ... }; | |
// This isn't a valid import. If users could reference | |
// these names without their grouping namespace, the | |
// code wouldn't read as well: | |
import { Args, Path } from '@eximchain/dappbot-types/spec/methods/auth/login'; | |
// ... Lots of code | |
// Later in the file: but *which* Args is this? | |
const args:Args = { ... } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment