Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ts-file-exports

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-file-exports

Utility for reading and resolving the module export names from a TypeScript or JavaScript file

  • 0.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ts-file-exports

A utility for getting all the named exports of a TypeScript or JavaScript file.

What kinds of module exports are supported?

In .ts files:

  • Typescript exports, and typescript wildcard exports In .js files:
  • ES Modules exports including wildcard exports
  • CommonJS exports

For more details on the supported export types, see the tests/cli.ts file and the fixtures/ folders.

How to use from CLI

yarn global add ts-file-exports
# or 
npm install -g ts-file-exports

Then:

ts-file-exports path/to/ts/or/js/file.ts

It will print the names of the exports in that file, each on a separate line.

How to use as an API

import getExports from 'ts-file-exports';

const exports: string[] = getExports('path/to/ts/or/js/file.ts');
console.log(exports);
// Prints an array of string names of the exports for the referenced file.

How does it work?

It just loads typescript to parse/analyze/check the file. Then it calls to the checker.getExportsAndPropertiesOfModule TypeScript API.

It's pretty slow...

Yes, it has to spin up all of TypeScript to be able to work.

Keywords

FAQs

Package last updated on 02 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc