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

refactor(types): put recurring type in a type variable #27

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

privatenumber
Copy link
Collaborator

Problem

Previously, the type:

(str: string | number) => string;

was being re-declared for every function:
https://unpkg.com/browse/kolorist@1.7.0/dist/types/index.d.ts

Changes

Created a type variable so it can be reused. Should be much readable and smaller:

export declare const enum SupportLevel {
    none = 0,
    ansi = 1,
    ansi256 = 2
}
export declare let options: {
    enabled: boolean;
    supportLevel: SupportLevel;
};
declare type Kolorist = (str: string | number) => string;
export declare const stripColors: Kolorist;
export declare const reset: Kolorist;
export declare const bold: Kolorist;
export declare const dim: Kolorist;
export declare const italic: Kolorist;
export declare const underline: Kolorist;
export declare const inverse: Kolorist;
export declare const hidden: Kolorist;
export declare const strikethrough: Kolorist;
export declare const black: Kolorist;
export declare const red: Kolorist;
export declare const green: Kolorist;
export declare const yellow: Kolorist;
export declare const blue: Kolorist;
export declare const magenta: Kolorist;
export declare const cyan: Kolorist;
export declare const white: Kolorist;
export declare const gray: Kolorist;
export declare const lightGray: Kolorist;
export declare const lightRed: Kolorist;
export declare const lightGreen: Kolorist;
export declare const lightYellow: Kolorist;
export declare const lightBlue: Kolorist;
export declare const lightMagenta: Kolorist;
export declare const lightCyan: Kolorist;
export declare const bgBlack: Kolorist;
export declare const bgRed: Kolorist;
export declare const bgGreen: Kolorist;
export declare const bgYellow: Kolorist;
export declare const bgBlue: Kolorist;
export declare const bgMagenta: Kolorist;
export declare const bgCyan: Kolorist;
export declare const bgWhite: Kolorist;
export declare const bgGray: Kolorist;
export declare const bgLightRed: Kolorist;
export declare const bgLightGreen: Kolorist;
export declare const bgLightYellow: Kolorist;
export declare const bgLightBlue: Kolorist;
export declare const bgLightMagenta: Kolorist;
export declare const bgLightCyan: Kolorist;
export declare const bgLightGray: Kolorist;
export declare const ansi256: (n: number) => Kolorist;
export declare const ansi256Bg: (n: number) => Kolorist;
export declare function link(text: string, url: string): string;
export {};

@changeset-bot
Copy link

changeset-bot bot commented Feb 4, 2023

⚠️ No Changeset found

Latest commit: 044256c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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

Successfully merging this pull request may close these issues.

None yet

1 participant