@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 CHANGED
@@ -1,3 +1,6 @@
1
1
  @battis/typescript-tricks
2
2
 
3
+ [![npm version](https://badge.fury.io/js/@battis%2Ftypescript-tricks.svg)](https://badge.fury.io/js/@battis%2Ftypescript-tricks)
4
+ [![Module type: CJS](https://img.shields.io/badge/module%20type-cjs-brightgreen)](https://nodejs.org/api/modules.html#modules-commonjs-modules)
5
+
3
6
  Stupid pet tricks, but with Typescript
@@ -2,3 +2,6 @@ export type AsynchronousFunction = () => Promise<any>;
2
2
  export type Nullable<T> = T | null;
3
3
  export type Optional<T> = T | undefined;
4
4
  export type Subset<T, U extends T> = T;
5
+ export type AssociativeArray<T> = {
6
+ [key: string]: T;
7
+ };
@@ -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
@@ -2,3 +2,4 @@ export * from './Constructor';
2
2
  export * from './Mixin';
3
3
  export * from './PropertyRequirements';
4
4
  export * from './Shorthand';
5
+ export * from './StaticImplements';
package/dist/index.js CHANGED
@@ -18,3 +18,4 @@ __exportStar(require("./Constructor"), exports);
18
18
  __exportStar(require("./Mixin"), exports);
19
19
  __exportStar(require("./PropertyRequirements"), exports);
20
20
  __exportStar(require("./Shorthand"), exports);
21
+ __exportStar(require("./StaticImplements"), exports);
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.0",
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
- "deploy": "run-s deploy:*",
25
- "deploy:build": "npm run build",
26
- "deploy:publish": "npx np --omit=dev"
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",