-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
50 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { NodeImpl } from './nodes/Node'; | ||
|
||
type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y | ||
? 1 | ||
: 2 | ||
? true | ||
: false; | ||
|
||
type Expect<T extends true> = T; | ||
|
||
type FindValidFields<T> = { | ||
[K in keyof T]: T[K] extends never ? never : K; | ||
}[keyof T]; | ||
|
||
type CheckStrictCompatible< | ||
StandardType, | ||
ImplType extends StandardType, | ||
Checked = { | ||
[k in keyof StandardType]: Equal<StandardType[k], ImplType[k]> extends true | ||
? never | ||
: [StandardType[k], ImplType[k]]; | ||
} | ||
> = Pick<Checked, FindValidFields<Checked>>; | ||
|
||
/** | ||
* Check the consistency between the jsar-dom implementation and the standard dom implementation, | ||
* return the incompatible fields. | ||
*/ | ||
type IncompatibleFields = CheckStrictCompatible<Node, NodeImpl>; | ||
|
||
type cases = [Expect<Equal<{}, IncompatibleFields>>]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export type Equal<X, Y> = | ||
(<T>() => T extends X ? 1 : 2) extends | ||
(<T>() => T extends Y ? 1 : 2) ? true : false; | ||
|
||
export type NotEqual<X, Y> = true extends Equal<X, Y> ? false : true; | ||
export type Expect<T extends true> = T; | ||
|
||
export type FindValidFields<T> = { | ||
[K in keyof T]: T[K] extends never ? never : K; | ||
}[keyof T]; | ||
|
||
export type CheckStrictCompatible<StandardType, ImplType extends StandardType, Checked = {[k in keyof StandardType]: Equal<StandardType[k], ImplType[k]> extends true ? never : [StandardType[k], ImplType[k]]}> = Pick<Checked, FindValidFields<Checked>>; |