Skip to content

Instantly share code, notes, and snippets.

@john-osullivan
Last active September 17, 2019 02:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save john-osullivan/8e7c6b6723518dc646d7197a52020110 to your computer and use it in GitHub Desktop.
Save john-osullivan/8e7c6b6723518dc646d7197a52020110 to your computer and use it in GitHub Desktop.
Dev Diaries #2 - Module layout for easy imports
// 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