Socket
Socket
Sign inDemoInstall

typescript-to-json

Package Overview
Dependencies
1
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    typescript-to-json

Analysis of the d.ts file, collect the first level of property description It can be applied to DTS conversion to document API description


Version published
Weekly downloads
1
Maintainers
1
Created
Weekly downloads
 

Readme

Source

typescript-to-json

Analysis of the d.ts file, collect the first level of property description It can be applied to DTS conversion to document API description

install

npm i typescript-to-json --dev

demo

const parse = require("typescript-to-json");

console.info(
  parse(`import { ComponentClass } from 'react'
  import { PickerProps, IPickerInstance } from './picker'

  type IAnyObjectString = {
    [x: number | string]: string
  }

  /**
   * @desc API
   */
  export interface AreaProps
    extends Omit<PickerProps, 'columns' | 'onChange'>,
      ComponentClass {
    /**
     * @default
     * @desc    value of address
     */
    value?: string
    areaList?: {
      province_list: IAnyObjectString
      city_list: IAnyObjectString
      county_list: IAnyObjectString
    }
    /**
     * @desc count of columns
     */
    columnsNum?: string | number
    /**
     * @desc placeholder of columns
     */
    columnsPlaceholder?: string[]
    /**
     * @desc trigger function
     */
    onChange: (event: {
      detail: {
        values: number[] | string[]
        picker: IPickerInstance
        index: number
      }
    }) => void
  }
  declare const Area: ComponentClass<AreaProps>

  export { Area }
  `)
);

get the result, Only analyze the type description of Export Exposure; 'value' and 'require' come from code analysis, others come from comments

{
  AreaProps: {
    value: {
      default: '',
      desc: 'value of address',
      require: 'false',
      value: '  string\n\n'
    },
    areaList: {
      require: 'false',
      value: '  {\n' +
        '    province_list: IAnyObjectString\n' +
        '    city_list: IAnyObjectString\n' +
        '    county_list: IAnyObjectString\n' +
        '  }\n' +
        '\n'
    },
    columnsNum: {
      desc: 'count of columns',
      require: 'false',
      value: '  string | number\n\n'
    },
    columnsPlaceholder: {
      desc: 'placeholder of columns',
      require: 'false',
      value: '  string[]\n\n'
    },
    onChange: {
      desc: 'trigger function',
      require: 'true',
      value: '  (event: {\n' +
        '    detail: {\n' +
        '      values: number[] | string[]\n' +
        '      picker: IPickerInstance\n' +
        '      index: number\n' +
        '    }\n' +
        '  }) => void\n' +
        '\n'
    }
  }
}

Keywords

FAQs

Last updated on 17 Nov 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc