unplugin-print-type
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

unplugin-print-type

Experimental TS type printer.

Print TS type deeply handle all subtypes. Useful if you want to document types.

Features

  • Render type during build (Zero runtime-code)
  • Render type aliases and interfaces to string
  • Resolve imported types

Usage

import type { UserRole } from './user'

interface User {
  name: string
  role: UserRole
}

console.log(`User type: ${PrintType<User>()}`)

Output

User type: {
  name: string
  role: 'admin' | 'user'
}

Install

npm i unplugin-print-type
Vite
// vite.config.ts
import Untype from 'unplugin-print-type/vite'

export default defineConfig({
  plugins: [
    Untype({ /* options */ }),
  ],
})

Example: playground/


Webpack
// webpack.config.js
module.exports = {
  /* ... */
  plugins: [
    require('unplugin-print-type/webpack')({ /* options */ })
  ]
}


Nuxt
// nuxt.config.js
export default {
  buildModules: [
    ['unplugin-print-type/nuxt', { /* options */ }],
  ],
}

This module works for both Nuxt 2 and Nuxt Vite


Vue CLI
// vue.config.js
module.exports = {
  configureWebpack: {
    plugins: [
      require('unplugin-print-type/webpack')({ /* options */ }),
    ],
  },
}


Package Sidebar

Install

npm i unplugin-print-type

Weekly Downloads

1

Version

0.1.2

License

MIT

Unpacked Size

413 kB

Total Files

26

Last publish

Collaborators

  • m0ksem