-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support named exports in TypeScript projects
Export single named exports from `picocolors.d.ts`. Test the functionality by `test/types.mts`. Include both `*.ts` files in the package. Include the test in the GitHub workflow.
- Loading branch information
Showing
5 changed files
with
67 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules | ||
picocolors.mjs | ||
tests/types.mjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,38 @@ | ||
import { Colors } from "./types" | ||
import { Colors, Formatter } from "./types" | ||
|
||
declare const picocolors: Colors & { createColors: (enabled?: boolean) => Colors } | ||
export { Colors } | ||
|
||
export = picocolors | ||
declare type Generator = (enabled?: boolean) => Colors | ||
|
||
declare const picocolors: Colors & { createColors: Generator } | ||
|
||
export default picocolors | ||
|
||
export let isColorSupported: boolean | ||
export let reset: Formatter | ||
export let bold: Formatter | ||
export let dim: Formatter | ||
export let italic: Formatter | ||
export let underline: Formatter | ||
export let inverse: Formatter | ||
export let hidden: Formatter | ||
export let strikethrough: Formatter | ||
export let black: Formatter | ||
export let red: Formatter | ||
export let green: Formatter | ||
export let yellow: Formatter | ||
export let blue: Formatter | ||
export let magenta: Formatter | ||
export let cyan: Formatter | ||
export let white: Formatter | ||
export let gray: Formatter | ||
export let bgBlack: Formatter | ||
export let bgRed: Formatter | ||
export let bgGreen: Formatter | ||
export let bgYellow: Formatter | ||
export let bgBlue: Formatter | ||
export let bgMagenta: Formatter | ||
export let bgCyan: Formatter | ||
export let bgWhite: Formatter | ||
|
||
export let createColors: Generator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import pc from "../picocolors.mjs" | ||
import { bold, createColors, Colors } from "../picocolors.mjs" | ||
|
||
test("default export", () => { | ||
let _result: string = pc.bold("test") | ||
}) | ||
|
||
test("named exports", () => { | ||
let _result: string = bold("test") | ||
}) | ||
|
||
test("factory function", () => { | ||
let _result1: Colors = pc.createColors() | ||
let _result2: Colors = createColors() | ||
}) | ||
|
||
function test(name: string, fn: () => void) : void { | ||
try { | ||
fn() | ||
console.log(pc.green("✓ " + name)) | ||
} catch (error) { | ||
console.log(pc.red("✗ " + name)) | ||
throw error | ||
} | ||
} |