Skip to content

Commit

Permalink
feat: fix strict-ts-lib (#1233)
Browse files Browse the repository at this point in the history
  • Loading branch information
noshiro-pf authored Jul 9, 2024
1 parent 2400264 commit 10df697
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 153 deletions.
8 changes: 4 additions & 4 deletions packages/strict-ts-lib/output-branded/diff/lib.es5.diff
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@
* This value is only used for numbers.
*/
- toString(radix?: number): string;
+ toString(radix?: UintRange<2, 37>): `${number}`;
+ toString(radix?: UintRange<2, 37>): string;

/**
* Returns a string representing a number in fixed-point notation.
Expand All @@ -599,7 +599,7 @@
* the range 0 - 20, inclusive.
*/
- toFixed(fractionDigits?: number): string;
+ toFixed(fractionDigits?: UintRange<0, 21>): `${number}`;
+ toFixed(fractionDigits?: UintRange<0, 101>): string;

/**
* Returns a string containing a number represented in exponential notation.
Expand All @@ -608,7 +608,7 @@
* the range 0 - 20, inclusive.
*/
- toExponential(fractionDigits?: number): string;
+ toExponential(fractionDigits?: UintRange<0, 21>): `${number}`;
+ toExponential(fractionDigits?: UintRange<1, 101>): string;

/**
* Returns a string containing a number represented either in exponential or
Expand All @@ -617,7 +617,7 @@
* inclusive.
*/
- toPrecision(precision?: number): string;
+ toPrecision(precision?: UintRange<1, 22>): `${number}`;
+ toPrecision(precision?: UintRange<1, 101>): string;

/** Returns the primitive value of the specified object. */
valueOf(): number;
Expand Down
8 changes: 4 additions & 4 deletions packages/strict-ts-lib/output-branded/lib-files/lib.es5.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -801,23 +801,23 @@ interface Number {
* @param radix Specifies a radix for converting numeric values to strings.
* This value is only used for numbers.
*/
toString(radix?: UintRange<2, 37>): `${number}`;
toString(radix?: UintRange<2, 37>): string;

/**
* Returns a string representing a number in fixed-point notation.
*
* @param fractionDigits Number of digits after the decimal point. Must be in
* the range 0 - 20, inclusive.
*/
toFixed(fractionDigits?: UintRange<0, 21>): `${number}`;
toFixed(fractionDigits?: UintRange<0, 101>): string;

/**
* Returns a string containing a number represented in exponential notation.
*
* @param fractionDigits Number of digits after the decimal point. Must be in
* the range 0 - 20, inclusive.
*/
toExponential(fractionDigits?: UintRange<0, 21>): `${number}`;
toExponential(fractionDigits?: UintRange<1, 101>): string;

/**
* Returns a string containing a number represented either in exponential or
Expand All @@ -826,7 +826,7 @@ interface Number {
* @param precision Number of significant digits. Must be in the range 1 - 21,
* inclusive.
*/
toPrecision(precision?: UintRange<1, 22>): `${number}`;
toPrecision(precision?: UintRange<1, 101>): string;

/** Returns the primitive value of the specified object. */
valueOf(): number;
Expand Down
8 changes: 4 additions & 4 deletions packages/strict-ts-lib/output-branded/packages/es5/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -801,23 +801,23 @@ interface Number {
* @param radix Specifies a radix for converting numeric values to strings.
* This value is only used for numbers.
*/
toString(radix?: UintRange<2, 37>): `${number}`;
toString(radix?: UintRange<2, 37>): string;

/**
* Returns a string representing a number in fixed-point notation.
*
* @param fractionDigits Number of digits after the decimal point. Must be in
* the range 0 - 20, inclusive.
*/
toFixed(fractionDigits?: UintRange<0, 21>): `${number}`;
toFixed(fractionDigits?: UintRange<0, 101>): string;

/**
* Returns a string containing a number represented in exponential notation.
*
* @param fractionDigits Number of digits after the decimal point. Must be in
* the range 0 - 20, inclusive.
*/
toExponential(fractionDigits?: UintRange<0, 21>): `${number}`;
toExponential(fractionDigits?: UintRange<1, 101>): string;

/**
* Returns a string containing a number represented either in exponential or
Expand All @@ -826,7 +826,7 @@ interface Number {
* @param precision Number of significant digits. Must be in the range 1 - 21,
* inclusive.
*/
toPrecision(precision?: UintRange<1, 22>): `${number}`;
toPrecision(precision?: UintRange<1, 101>): string;

/** Returns the primitive value of the specified object. */
valueOf(): number;
Expand Down
8 changes: 4 additions & 4 deletions packages/strict-ts-lib/output/diff/lib.es5.diff
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@
* This value is only used for numbers.
*/
- toString(radix?: number): string;
+ toString(radix?: UintRange<2, 37>): `${number}`;
+ toString(radix?: UintRange<2, 37>): string;

/**
* Returns a string representing a number in fixed-point notation.
Expand All @@ -490,7 +490,7 @@
* the range 0 - 20, inclusive.
*/
- toFixed(fractionDigits?: number): string;
+ toFixed(fractionDigits?: UintRange<0, 21>): `${number}`;
+ toFixed(fractionDigits?: UintRange<0, 101>): string;

/**
* Returns a string containing a number represented in exponential notation.
Expand All @@ -499,7 +499,7 @@
* the range 0 - 20, inclusive.
*/
- toExponential(fractionDigits?: number): string;
+ toExponential(fractionDigits?: UintRange<0, 21>): `${number}`;
+ toExponential(fractionDigits?: UintRange<1, 101>): string;

/**
* Returns a string containing a number represented either in exponential or
Expand All @@ -508,7 +508,7 @@
* inclusive.
*/
- toPrecision(precision?: number): string;
+ toPrecision(precision?: UintRange<1, 22>): `${number}`;
+ toPrecision(precision?: UintRange<1, 101>): string;

/** Returns the primitive value of the specified object. */
valueOf(): number;
Expand Down
8 changes: 4 additions & 4 deletions packages/strict-ts-lib/output/lib-files/lib.es5.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -780,23 +780,23 @@ interface Number {
* @param radix Specifies a radix for converting numeric values to strings.
* This value is only used for numbers.
*/
toString(radix?: UintRange<2, 37>): `${number}`;
toString(radix?: UintRange<2, 37>): string;

/**
* Returns a string representing a number in fixed-point notation.
*
* @param fractionDigits Number of digits after the decimal point. Must be in
* the range 0 - 20, inclusive.
*/
toFixed(fractionDigits?: UintRange<0, 21>): `${number}`;
toFixed(fractionDigits?: UintRange<0, 101>): string;

/**
* Returns a string containing a number represented in exponential notation.
*
* @param fractionDigits Number of digits after the decimal point. Must be in
* the range 0 - 20, inclusive.
*/
toExponential(fractionDigits?: UintRange<0, 21>): `${number}`;
toExponential(fractionDigits?: UintRange<1, 101>): string;

/**
* Returns a string containing a number represented either in exponential or
Expand All @@ -805,7 +805,7 @@ interface Number {
* @param precision Number of significant digits. Must be in the range 1 - 21,
* inclusive.
*/
toPrecision(precision?: UintRange<1, 22>): `${number}`;
toPrecision(precision?: UintRange<1, 101>): string;

/** Returns the primitive value of the specified object. */
valueOf(): number;
Expand Down
40 changes: 0 additions & 40 deletions packages/strict-ts-lib/output/lib/package.json

This file was deleted.

8 changes: 4 additions & 4 deletions packages/strict-ts-lib/output/packages/es5/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -780,23 +780,23 @@ interface Number {
* @param radix Specifies a radix for converting numeric values to strings.
* This value is only used for numbers.
*/
toString(radix?: UintRange<2, 37>): `${number}`;
toString(radix?: UintRange<2, 37>): string;

/**
* Returns a string representing a number in fixed-point notation.
*
* @param fractionDigits Number of digits after the decimal point. Must be in
* the range 0 - 20, inclusive.
*/
toFixed(fractionDigits?: UintRange<0, 21>): `${number}`;
toFixed(fractionDigits?: UintRange<0, 101>): string;

/**
* Returns a string containing a number represented in exponential notation.
*
* @param fractionDigits Number of digits after the decimal point. Must be in
* the range 0 - 20, inclusive.
*/
toExponential(fractionDigits?: UintRange<0, 21>): `${number}`;
toExponential(fractionDigits?: UintRange<1, 101>): string;

/**
* Returns a string containing a number represented either in exponential or
Expand All @@ -805,7 +805,7 @@ interface Number {
* @param precision Number of significant digits. Must be in the range 1 - 21,
* inclusive.
*/
toPrecision(precision?: UintRange<1, 22>): `${number}`;
toPrecision(precision?: UintRange<1, 101>): string;

/** Returns the primitive value of the specified object. */
valueOf(): number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,19 @@ export const convertLibEs5_Number = (): MonoTypeFunction<string> =>
mapFn: composeMonoTypeFns(
replaceWithNoMatchCheck(
'toString(radix?: number): string;',
// eslint-disable-next-line no-template-curly-in-string
'toString(radix?: UintRange<2, 37>): `${number}`;',
'toString(radix?: UintRange<2, 37>): string;',
),
replaceWithNoMatchCheck(
'toFixed(fractionDigits?: number): string;',
// eslint-disable-next-line no-template-curly-in-string
'toFixed(fractionDigits?: UintRange<0, 21>): `${number}`;',
'toFixed(fractionDigits?: UintRange<0, 101>): string;',
),
replaceWithNoMatchCheck(
'toExponential(fractionDigits?: number): string;',
// eslint-disable-next-line no-template-curly-in-string
'toExponential(fractionDigits?: UintRange<0, 21>): `${number}`;',
'toExponential(fractionDigits?: UintRange<1, 101>): string;',
),
replaceWithNoMatchCheck(
'toPrecision(precision?: number): string;',
// eslint-disable-next-line no-template-curly-in-string
'toPrecision(precision?: UintRange<1, 22>): `${number}`;',
'toPrecision(precision?: UintRange<1, 101>): string;',
),
),
});
2 changes: 1 addition & 1 deletion packages/utils/ts-utils/src/collections/iset.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe('ISet.map', () => {
const s0 = ISet.new([1, 3, 5, 6, 7]);
const result = s0.map((x) => (x * 2).toString());

expectType<typeof result, ISet<`${number}`>>('=');
expectType<typeof result, ISet<string>>('=');
expect(result).toStrictEqual(ISet.new(['2', '6', '10', '12', '14']));
expect(s0).toStrictEqual(ISet.new([1, 3, 5, 6, 7]));
});
Expand Down
Loading

0 comments on commit 10df697

Please sign in to comment.