Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

install @types definition from fork

Context

I forked DefinitelyTyped and made a workaround to one type definition. This workaround is on a branch in this fork.

This change shouldn't be merged back, since it's only a temporary workaround.

Question

How do I install this customized type definition via npm or yarn?

Problems

  • I can't just install the branch, since it would install the whole DefinitelyTyped repo instead of just the library.
  • Ideally I'd like to have it installed the same way default type definitions are, so that no additional (global) configuration is required.
like image 346
Waog Avatar asked Jul 04 '18 07:07

Waog


People also ask

What does @types mean NPM?

Summary: The @types npm organization is for obtaining type definitions with npm . Using these type definitions is a feature is coming in TypeScript 2.0. This will replace the current projects/tools such as typings and tsd, though these will continue to be supported for some time.

What is definitely typed?

Definitely Typed is a project that provides a central repository of TypeScript definitions for NPM packages which do not have types.

What are type definitions in TypeScript?

A type definition file is a file that ends in “. d. ts”. It is a lot like a header file in some other languages. It is a file in which you provide the type definitions for another file, the signatures without implementation.


2 Answers

If this is just temporary like you say (or maybe a very specific use case), it probably makes most sense to just copy the modified type definitions into the repository of your project. You can then reference these definitions just like you would with any custom typings (see my other answer for instructions).

like image 128
MisterMetaphor Avatar answered Sep 18 '22 12:09

MisterMetaphor


This could be a time consuming process but doable (to the best of my knowledge).

Use the types-publisher project. The Manually Running section in the Readme covers the steps that needs to be executed.

The following steps specified in the Readme should be sufficient to generate and publish the package to your npm account:

  1. Update the local DefinitelyTyped repo
  2. Parse the definitions
  3. Calculate versions
  4. Generate packages on disk
  5. Publish packages on disk
  6. Publish registry

In the settings.json have the scopeName equal to npm username.

The package can be used as npm i @username/package-name

like image 20
dRoyson Avatar answered Sep 21 '22 12:09

dRoyson