npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

typework

v0.1.1

Published

Manage And Vendor JSDoc Types. Import Typedefs Into Target Projects.

Downloads

28

Readme

typework

npm version

Typework is used to Manage And Vendor JSDoc Types. With the special /* typework */ keyword, JSDoc type declarations can be moved across JS files, and imported files in types (import('../types/context')) will be copied across to the target project.

yarn add typework

Table Of Contents

CLI

The package works via a CLI by passing the configuration file to it.

typework example/config.json

The config must include 3 properties:

{
  "entry": "@typedefs/goa",
  "js": "compile/index.js",
  "destination": "types"
}
  • 🔖 entry This is where the types are coming form. This can be a separate package, e.g., @typedefs/goa
  • 🎯 js The project source code into where to place the original types into.
  • 📂 destination Whenever the types import other files with import('../types/'), the target files will be copied to this folder.

Upon run, the types' JSDoc declarations are copied from the entry into the source JS file, so that they become a native part of the project. All other files found under relative import paths, will be placed into the Destination folder.

The example below demonstrates, how types written for the Goa package and published as @typedefs/goa, were imported into the Goa/Koa project, so that they can be distributed without having to install @typedefs/goa from NPM as a production dependency. This is a strategy for distribution of JSDoc types.

export {}

/* typework */
/**
 * @typedef {import('./vendor/cookies').Keygrip} Keygrip
 * @typedef {import('./typedefs/application').Middleware} Middleware
 * @typedef {import('./typedefs/application').Application} Application
 * @typedef {import('./typedefs/context').KoaContext} Context
 * @typedef {import('./typedefs/request').Request} Request
 * @typedef {import('./typedefs/request').ContextDelegatedRequest} ContextDelegatedRequest
 * @typedef {import('./typedefs/response').Response} Response
 * @typedef {import('./typedefs/response').ContextDelegatedResponse} ContextDelegatedResponse
 */
const _Koa = require('./koa')

class Koa extends _Koa {
  /**
   * Initialize a new `Application`.
   */
  constructor() {
    super()
  }
}

module.exports = Koa
/* typework */
/**
 * @typedef {import('types/vendor/cookies').Keygrip} Keygrip
 * @typedef {import('types/typedefs/application').Middleware} Middleware
 * @typedef {import('types/typedefs/application').Application} Application
 * @typedef {import('types/typedefs/context').KoaContext} Context
 * @typedef {import('types/typedefs/request').Request} Request
 * @typedef {import('types/typedefs/request').ContextDelegatedRequest} ContextDelegatedRequest
 * @typedef {import('types/typedefs/response').Response} Response
 * @typedef {import('types/typedefs/response').ContextDelegatedResponse} ContextDelegatedResponse
 */
example/types
├── typedefs
│   ├── application.js
│   ├── context.js
│   ├── request.js
│   └── response.js
└── vendor
    ├── accepts.js
    └── cookies.js

Copyright

(c) Art Deco 2019