Skip to content

Commit

Permalink
fix alias type definiton
Browse files Browse the repository at this point in the history
  • Loading branch information
Im-Beast committed May 10, 2021
1 parent 3c06220 commit 723a94a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions deno_lib/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ export const addStyleFunction = (

export const addStyleAlias = (
alias: string,
aliased: CrayonStyle & string
aliased: CrayonStyle | string
): boolean => {
const style = styles[aliased]
const style = styles[aliased as CrayonStyle]

if (style) {
if (!style) {
crayonError(`Could not find style "${aliased}"`)
return false
}
Expand All @@ -181,13 +181,13 @@ export const addStyleAlias = (
}

export const addStyleAliases = (aliases: {
[name: string]: CrayonStyle & string
[name: string]: CrayonStyle | string
}): boolean => {
let status = true

for (let alias in aliases) {
const aliased = aliases[alias]
const style = styles[aliased]
const style = styles[aliased as CrayonStyle]

if (!style) {
crayonError(`Could not find style "${aliased}"`)
Expand Down
4 changes: 2 additions & 2 deletions lib/styles.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export declare const functions: {
};
export declare const styles: StyleObject;
export declare const addStyleFunction: (name: string, func: (...any: any[]) => string) => boolean;
export declare const addStyleAlias: (alias: string, aliased: CrayonStyle & string) => boolean;
export declare const addStyleAlias: (alias: string, aliased: CrayonStyle | string) => boolean;
export declare const addStyleAliases: (aliases: {
[name: string]: "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "lightBlack" | "lightRed" | "lightGreen" | "lightYellow" | "lightBlue" | "lightMagenta" | "lightCyan" | "lightWhite" | "bgBlack" | "bgRed" | "bgGreen" | "bgYellow" | "bgBlue" | "bgMagenta" | "bgCyan" | "bgWhite" | "bgLightBlack" | "bgLightRed" | "bgLightGreen" | "bgLightYellow" | "bgLightBlue" | "bgLightMagenta" | "bgLightCyan" | "bgLightWhite" | "reset" | "bold" | "dim" | "italic" | "underline" | "blink" | "fastBlink" | "invert" | "hidden" | "strikethrough" | "boldOff" | "doubleUnderline" | "boldOrDimOff" | "italicOff" | "underlineOff" | "blinkOff" | "invertOff" | "hiddenOff" | "strikethroughOff";
[name: string]: string;
}) => boolean;
export declare const addStyle: (name: string, value: string) => boolean;
export declare const addStyles: (styleObject: {
Expand Down
2 changes: 1 addition & 1 deletion lib/styles.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ export const addStyleFunction = (

export const addStyleAlias = (
alias: string,
aliased: CrayonStyle & string
aliased: CrayonStyle | string
): boolean => {
const style = styles[aliased]
const style = styles[aliased as CrayonStyle]

if (style) {
if (!style) {
crayonError(`Could not find style "${aliased}"`)
return false
}
Expand All @@ -181,13 +181,13 @@ export const addStyleAlias = (
}

export const addStyleAliases = (aliases: {
[name: string]: CrayonStyle & string
[name: string]: CrayonStyle | string
}): boolean => {
let status = true

for (let alias in aliases) {
const aliased = aliases[alias]
const style = styles[aliased]
const style = styles[aliased as CrayonStyle]

if (!style) {
crayonError(`Could not find style "${aliased}"`)
Expand Down

0 comments on commit 723a94a

Please sign in to comment.