Skip to content

πŸš€πŸ’ A tool to validate your library can be consumed by other TypeScript projects.

License

Notifications You must be signed in to change notification settings

ofrobots/post-install-check

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Google Cloud Platform logo

Post Install Check

Make sure TypeScript projects can use the d.ts you're feeding them.

This is not an officially supported Google product.

It's not uncommon to ship a library written in TypeScript that exports type definitions that cannot be used by dependent code. Typically if the library does not export all types correctly, a TypeScript codebase using the library will fail to compile, potentially forcing the codebase to use the library without typechecks.

The Install Check library is designed to be used as part of the tests for your library to verify that your library can be used by dependent code.

Installation

$ npm install --save-dev post-install-check

Usage

The following could be the contents of a test file in your module that is run with mocha as part of your test suite.

import * as check from 'post-install-check';

const tsCode = `
  import * as express from 'express';
  import {Something} from 'some-module';

  const app = express();

  // ensure a Something can be constructed
  const something = new Something({
    someStringOption: 'some-string',
    someBooleanOption: true
  });

  // ensure a Something can be used as middleware
  app.use(something);
`;

const jsCode = `
  const express = require('express');
  const {Something} = require('some-module');

  const app = express();

  // ensure a Something can be constructed
  const something = new Something({
    someStringOption: 'some-string',
    someBooleanOption: true
  });

  // ensure a Something can be used as middleware
  app.use(something);
`;

const TS_SAMPLES: check.CodeSample[] = [
  {
    code: tsCode,
    description: 'can be used with express',
    dependencies: ['express'],
    devDependencies: ['@types/express']
  }
]

const JS_SAMPLES: check.CodeSample[] = [
  {
    code: jsCode,
    description: 'can be used with express',
    dependencies: ['express'],
    devDependencies: []
  }
]

// Create a new project for each sample in a temp
// directory, with `some-module` installed, and
// ensure the sample code compiles (for TypeScript
// samples), and the code runs without errors.
check.testInstallation(TS_SAMPLES, JS_SAMPLES, {
  timeout: 2*60*1000
});

Questions/problems?

If you've found an bug/issue, please file it on GitHub.

Contributing

See CONTRIBUTING.

License

This library is licensed under Apache 2.0. Full license text is available in LICENSE.

Made with ❀️ by the Google Node.js team

About

πŸš€πŸ’ A tool to validate your library can be consumed by other TypeScript projects.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%