1.1.1 • Published 10 months ago

ts-remote v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

ts-remote v1.1.1

npm version

This library is designed to solve the problem of transferring TypeScript type declarations between third-party javascript modules and improve the quality of TypeScript development.

For example, you can easily apply this solution for microfronted architecture built in any way.

Installing

For the latest stable version:

npm install -D ts-remote

Usage

DTS module compiler

import { compiler, type ModuleList } from 'ts-remote/compiler';
import path from 'path';

const moduleList: ModuleList = {
  'moduleName': `./app/index.ts`,
  'foo': `./app/foo.ts`,
  'bar': `./app/bar.ts`,
  // ...others
};

compiler({
  output: {
    filename: path.resolve(process.cwd(), '@types-remote-dist', 'moduleName.d.ts'),
    format: (result) => {
      const prettier = require('prettier');
      return prettier.format(result);
    },
  },
  moduleList,
  additionalDeclarations: [`./app/global.d.ts`,],
});

Example output

--> moduleName.d.ts

declare module "moduleName" {
  type A = number
  
  const a: A
}

declare module "foo" {
  // ..exports from module foo..
}

declare module "bar" {
  // ..exports from module foo..
}

Remote type loader

import { loader } from 'ts-remote/loader';

loader({
  moduleList: { 'https://example.com/types/modeuleName.d.ts': '@types-remote-loaded/remote.d.ts' },
});

Roadmap

In the near future, it is planned to expand the functionality and use more TypeScript features.

1.1.1

10 months ago

1.1.0

10 months ago

1.0.9

12 months ago

1.0.8

12 months ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

0.0.0

1 year ago

1.0.0

1 year ago