Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export types/interfaces/etc from central index.ts file for consumer usage #86

Open
1 task done
brandongregoryscott opened this issue Jun 26, 2021 · 0 comments
Open
1 task done

Comments

@brandongregoryscott
Copy link
Contributor

brandongregoryscott commented Jun 26, 2021

Prerequisites

Summary

Currently, while Credentials, CredentialsArgs, TwitterStream, etc. are defined in TypeScript definition files, and included in the build, they cannot be imported without digging into the structure of the package:

import Credentials, { CredentialsArgs } from "twitter-v2/build/Credentials";
import TwitterStream from "twitter-v2/build/TwitterStream";

With an index.ts file that exports these types/class definitions, it could simplify the importing structure alongside the main client:

import Twitter, { Credentials, CredentialsArgs, TwitterStream } from "twitter-v2";

Motivation

For one, users can more easily figure out what is exported for public use through the index.ts file - there may be certain types/classes that aren't meant to be publicly exported that won't exist in here, but can be used internally. It also just cleans up the number of imports that a user might have for various parts of the package, without needing to know what the structure of the package looks like.

On a related note, it may be worth defining the files property in the package.json file which would send out the built files only - there's no need to pack up the src/*.ts files when consumers are actually using the build/*.js and build/*.d.ts files.

Describe alternatives you've considered

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant