TypeScript

Type declarations ship with the package (dist/index.d.ts, wired via exports.types) — no @types/steem-js needed. Every generated steem.api.* and steem.broadcast.* method is declared (108 API methods + 63 broadcast operations + 4 auth helpers), so you get name autocomplete and arity checking.

import steem from '@blazeapps/steem';

// Promise variants are typed as Promise<any>; callbacks as (err, result) => void.
const accounts = await steem.api.getAccountsAsync(['ned', 'dan']);

const wif: string = steem.auth.toWif('alice', 'password', 'posting');
await steem.broadcast.vote(wif, 'alice', 'ned', 'permlink', 10000);

Importing the namespace and helper types

import steem, {
  api,            // also available as named exports
  broadcast,
  auth,
} from '@blazeapps/steem';

import type {
  SteemApi,
  SteemBroadcast,
  SteemAuth,
  SteemOptions,
  Callback,
  StreamMode,
} from '@blazeapps/steem';

function configure(opts: SteemOptions) {
  steem.api.setOptions(opts);
}

Callback style is typed too

import type { Callback } from '@blazeapps/steem';

const cb: Callback = (err, result) => {
  if (err) return console.error(err);
  console.log(result);
};

steem.api.getAccounts(['ned'], cb);

Notes on the types

  • Method names and arity are precise (generated from the same descriptors the runtime uses). Parameter and return payloads are typed as any — the chain’s response shapes vary per method; see the API reference for the documented shapes, or cast results to your own interfaces.
  • The declarations are generated by npm run gen-types from methods.js / operations.js, so they never drift from the implementation.

Works with both node/node16/nodenext and bundler module resolution:

{
  "compilerOptions": {
    "module": "ESNext",
    "moduleResolution": "Bundler",
    "target": "ES2020",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true
  }
}

This site uses Just the Docs, a documentation theme for Jekyll.