Skip to content

Commit

Permalink
skip Class Interface and wait #58
Browse files Browse the repository at this point in the history
  • Loading branch information
huan committed Oct 5, 2021
1 parent ac54a28 commit 30ca356
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"@chatie/eslint-config": "^0.14.1",
"@chatie/git-scripts": "^0.6.2",
"@chatie/tsconfig": "^0.20.2",
"cross-env": "^7.0.3",
"file-box": "^0.19.5",
"npm-run-all": "^4.1.5",
"shx": "^0.3.3",
Expand Down
9 changes: 7 additions & 2 deletions src/constructor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,20 @@ test('Constructor<T> with private constructor class', async t => {
t.ok(typeTest, 'should be same after constructor')
})

test('class with static methods', async t => {
/**
* Huan(202110): TypeError: Cannot read property 'valueDeclaration' of undefined #58
* https://github.com/huan/clone-class/issues/58
*/
test.skip('class with static methods', async t => {
class StaticMethodClass {

static staticMethod () {}
protected constructor () {}

}

const C: typeof StaticMethodClass = StaticMethodClass as any as Constructor<StaticMethodClass, typeof StaticMethodClass>
// const C: typeof StaticMethodClass = StaticMethodClass as any as Constructor<StaticMethodClass, typeof StaticMethodClass>
const C: typeof StaticMethodClass = StaticMethodClass as any as Constructor<StaticMethodClass> as any

t.ok(C, 'should be ok')
})
13 changes: 9 additions & 4 deletions src/constructor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* P: `typeof Class`
*/

type ClassInterface<C> = {
export type ClassInterface<C> = {
[key in keyof C]: C[key];
}

Expand All @@ -30,12 +30,17 @@ type InstanceInterface <I> = {
prototype: I
}

type Constructor<I extends Object, C = any> = ClassInterface<C> & InstanceInterface<I>
type Constructor<I extends Object> = InstanceInterface<I>

// type Constructor<T extends Object, R = any> = {
/**
* Huan(202110): TypeError: Cannot read property 'valueDeclaration' of undefined #58
* https://github.com/huan/clone-class/issues/58
*/
// type Constructor<I extends Object, C = any> = ClassInterface<C> & InstanceInterface<I>

// type Constructor<T extends Object> = {
// new (...args: any[]): T
// prototype: T
// a: R
// }

/**
Expand Down

0 comments on commit 30ca356

Please sign in to comment.