@shanzhai/convert-json-to-type-script-step

A Shanzhai step which converts a JSON value to TypeScript source code for ambient declarations.

Usage no npm install needed!

<script type="module">
  import shanzhaiConvertJsonToTypeScriptStep from 'https://cdn.skypack.dev/@shanzhai/convert-json-to-type-script-step';
</script>

README

@shanzhai/convert-json-to-type-script-step Continuous Integration License FOSSA Status Renovate enabled npm npm type definitions

A Shanzhai step which converts a JSON value to TypeScript source code for ambient declarations.

Usage

Use ConvertJsonToTypeScriptStep to convert an object containing constants into a set of TypeScript type declarations. For example, returning the following from a trigger's event handler:

new ConvertJsonToTypeScriptStep(
  `A description of the operation being performed`,
  new ConstantInput({
    theFirstDeclaration: 3,
    theSecondDeclaration: {
      anObjectContaining: [
        `an`,
        `array`,
      ],
    }
  })
);

To produce the following output:

declare const theFirstDeclaration: 3;

declare const theSecondDeclaration: {
  readonly anObjectContaining: readonly [
    `an`,
    `array`,
  ],
};

The values are not included; these should be injected during minification.

Dependencies

This package has no runtime dependencies.

Peer Dependencies

This package has no runtime peer dependencies (it does not expect any other packages to be installed alongside itself).

License

FOSSA Status