Skip to content

Commit 2b2d508

Browse files
committed
Revert "Merge pull request #142 from tomoto/feat/infer-result-type-with-typescript"
This reverts commit 072d6f5, reversing changes made to afd78c2.
1 parent 072d6f5 commit 2b2d508

File tree

4 files changed

+7
-94
lines changed

4 files changed

+7
-94
lines changed

filesize.d.ts

+4-20
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// Type definitions for filesize 8.0.3
1+
// Type definitions for filesize 6.0.1
22
// Project: https://github.com/avoidwork/filesize.js, https://filesizejs.com
33
// Definitions by: Giedrius Grabauskas <https://github.com/GiedriusGrabauskas>
44
// Renaud Chaput <https://github.com/renchap>
55
// Roman Nuritdinov <https://github.com/Ky6uk>
66
// Sam Hulick <https://github.com/ffxsam>
7-
// Tomoto S. Washio <https://github.com/tomoto>
7+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
88

99
declare var fileSize: Filesize.Filesize;
1010
export = fileSize;
@@ -100,24 +100,8 @@ declare namespace Filesize {
100100
roundingMethod?: "round" | "floor" | "ceil";
101101
}
102102

103-
// Result type inference from the output option
104-
interface ResultTypeMap {
105-
array: [number, string];
106-
exponent: number;
107-
object: {
108-
value: number,
109-
symbol: string,
110-
exponent: number,
111-
unit: string,
112-
};
113-
string: string;
114-
}
115-
type DefaultOutput<O extends Options> = Exclude<O["output"], keyof ResultTypeMap> extends never ? never : "string"
116-
type CanonicalOutput<O extends Options> = Extract<O["output"], keyof ResultTypeMap> | DefaultOutput<O>
117-
118103
interface Filesize {
119-
(bytes: number): string;
120-
<O extends Options>(bytes: number, options: O): ResultTypeMap[CanonicalOutput<O>];
121-
partial: <O extends Options>(options: O) => ((bytes: number) => ResultTypeMap[CanonicalOutput<O>]);
104+
(bytes: number, options?: Options): string;
105+
partial: (options: Options) => ((bytes: number) => string);
122106
}
123107
}

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
"build": "rollup -c",
2828
"watch": "rollup -c -w",
2929
"changelog": "auto-changelog -p",
30-
"test": "npm run build && npm run lint && npm run test:unit && npm run test:type",
30+
"test": "npm run build && npm run lint && npm run test:unit",
3131
"test:unit": "nodeunit test/*.js",
32-
"test:type": "npx tsc -p test",
33-
"lint": "eslint test/*.js src/*.js"
32+
"lint": "eslint test/*.js src/*.js",
33+
"types": "npx typescript src/filesize.js --declaration --allowJs --emitDeclarationOnly --outDir ./"
3434
},
3535
"devDependencies": {
3636
"@babel/core": "^7.15.5",

test/tsconfig.json

-11
This file was deleted.

test/typeinference_test.ts

-60
This file was deleted.

0 commit comments

Comments
 (0)