Skip to content

Commit 5b8a468

Browse files
committed
chore(4.0.0-rc.6): clean up d.ts
1 parent 2103223 commit 5b8a468

File tree

3 files changed

+23
-42
lines changed

3 files changed

+23
-42
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ansis",
3-
"version": "4.0.0-rc.5",
3+
"version": "4.0.0-rc.6",
44
"description": "A small and fast library for applying ANSI colors in terminal or browser console",
55
"keywords": [
66
"ansi",

package.npm.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name":"ansis",
3-
"version":"4.0.0-rc.5",
3+
"version":"4.0.0-rc.6",
44
"description":"ANSI color lib",
55
"keywords":["ansi","colors","cli"],
66
"license":"ISC",
@@ -15,6 +15,5 @@
1515
}
1616
},
1717
"sideEffects":false,
18-
"engines":{"node":">=14"},
19-
"files":["index.*"]
18+
"engines":{"node":">=14"}
2019
}

src/index.d.ts

Lines changed: 20 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ type H = `${C}Bright`;
3636
*/
3737
export type AnsiColors =
3838
| 'black' | C | 'gray' | H
39-
//| 'bgBlack' | `bg${Capitalize<C> | Capitalize<H>}` | 'bgGray';
4039
| `bg${'Black' | Capitalize<C> | 'Gray' | Capitalize<H>}`;
4140

4241
/**
@@ -85,17 +84,15 @@ type R = (r: N, g: N, b: N) => A;
8584
// Short alias
8685
type A = Ansis;
8786

88-
type P = { open: S; close: S };
89-
9087
type Ansis = {
9188
/**
9289
* Opening ANSI escape code for a style or color.
9390
*/
94-
//open: S;
91+
open: S;
9592
/**
9693
* Closing ANSI escape code for a style or color.
9794
*/
98-
//close: S;
95+
close: S;
9996

10097
/**
10198
* @param {unknown} v The value to be processed, can be of any type, which will be converted to a string.
@@ -116,21 +113,6 @@ type Ansis = {
116113
*/
117114
(s: TemplateStringsArray, ...v: any[]): S;
118115

119-
/**
120-
* Whether the output supports ANSI color and styles.
121-
*
122-
* @return {boolean}
123-
*/
124-
isSupported(): B;
125-
126-
/**
127-
* Remove ANSI styling codes.
128-
*
129-
* @param {string} s
130-
* @return {string}
131-
*/
132-
strip(s: S): S;
133-
134116
/**
135117
* Set [256-color ANSI code](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) for foreground color.
136118
*/
@@ -161,7 +143,22 @@ type Ansis = {
161143
*/
162144
bgHex: L;
163145

164-
/**
146+
/**
147+
* Whether the output supports ANSI color and styles.
148+
*
149+
* @return {boolean}
150+
*/
151+
isSupported(): B;
152+
153+
/**
154+
* Remove ANSI styling codes.
155+
*
156+
* @param {string} s
157+
* @return {string}
158+
*/
159+
strip(s: S): S;
160+
161+
/**
165162
* Extends Ansis with additional colors.
166163
*
167164
* For example:
@@ -176,9 +173,8 @@ type Ansis = {
176173
* @param {string | { open: string; close: string }} c A record of new colors to add, with either a string or an object containing `open` and `close` sequences.
177174
* @return {Ansis} Return extended instance.
178175
*/
179-
//extend<U extends S>(c: Record<U, any>): A & Record<U, A>;
180-
extend<U extends S>(c: Record<U, S | P>): A & Record<U, A>;
181-
} & P
176+
extend<U extends S>(c: Record<U, S | { open: S; close: S }>): A & Record<U, A>;
177+
}
182178
// Dynamic properties
183179
& { [K in AnsiStyles | AnsiColors]: A };
184180

@@ -192,10 +188,6 @@ declare const
192188
Ansis: new (n?: N) => A,
193189
// declare all styles and colors of type Ansis
194190
a: A,
195-
//isSupported: () => B,
196-
//strip: (s: S) => S,
197-
//extend: A['extend'],
198-
199191
fg: Q,
200192
rgb: R,
201193
hex: L;
@@ -204,16 +196,6 @@ declare const
204196
export {
205197
a as default,
206198
Ansis,
207-
208-
// Named export of instance methods is a workaround for compatibility with various TypeScript module settings.
209-
// It works under all tsconfig settings (ESNext, Node16, verbatimModuleSyntax, etc.).
210-
// It is a hack for the `compilerOptions.module = "Node16"`, otherwise the TS compiler can't find they in default import:
211-
// import ansis from 'ansis';
212-
// ansis.strip(text); // <= TS2339: Property strip does not exist on type
213-
//isSupported,
214-
//strip,
215-
//extend,
216-
217199
fg,
218200
fg as bg,
219201
rgb,

0 commit comments

Comments
 (0)