@battis/typescript-tricks 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/Shorthand.d.ts +3 -0
- package/dist/StaticImplements.d.ts +1 -0
- package/dist/StaticImplements.js +25 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
@battis/typescript-tricks
|
|
2
2
|
|
|
3
|
+
[](https://badge.fury.io/js/@battis%2Ftypescript-tricks)
|
|
4
|
+
[](https://nodejs.org/api/modules.html#modules-commonjs-modules)
|
|
5
|
+
|
|
3
6
|
Stupid pet tricks, but with Typescript
|
package/dist/Shorthand.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type StaticImplements<I extends new (...args: any[]) => any, C extends I> = InstanceType<C>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*
|
|
4
|
+
|
|
5
|
+
https://stackoverflow.com/a/69571314/294171
|
|
6
|
+
|
|
7
|
+
Usage:
|
|
8
|
+
|
|
9
|
+
interface InstanceInterface {
|
|
10
|
+
instanceMethod();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface StaticInterface {
|
|
14
|
+
new(...args: any[]): InstanceInterface;
|
|
15
|
+
staticMethod();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
class MyClass implements StaticImplements<StaticInterface, typeof MyClass> {
|
|
19
|
+
static staticMethod() { }
|
|
20
|
+
static ownStaticMethod() { }
|
|
21
|
+
instanceMethod() { }
|
|
22
|
+
ownInstanceMethod() { }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
*/
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@battis/typescript-tricks",
|
|
3
3
|
"description": "A handful of useful types and operators",
|
|
4
|
-
"version": "0.1
|
|
4
|
+
"version": "0.2.1",
|
|
5
5
|
"author": "Seth Battis <seth@battis.net>",
|
|
6
6
|
"license": "GPL-3.0",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"build": "run-s build:*",
|
|
22
22
|
"build:clean": "shx rm -rf dist",
|
|
23
23
|
"build:compile": "tsc",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
24
|
+
"release": "run-s release:*",
|
|
25
|
+
"release:build": "npm run build",
|
|
26
|
+
"release:publish": "np --yolo --omit=dev"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@battis/eslint-config": "github:battis/eslint-config",
|