Skip to content

Commit 647806a

Browse files
test(interface): add
1 parent f901966 commit 647806a

8 files changed

Lines changed: 47 additions & 0 deletions
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { CommonDescriptor } from './common-descriptor.interface';
2+
/**
3+
* Accessor descriptor with its unique `get` and `set` attributes and theirs generic `Value` type.
4+
*/
5+
export interface AccessorDescriptor<Value> extends CommonDescriptor {
6+
get: (() => Value) | undefined;
7+
set: ((value: Value) => void) | undefined;
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* Common `configurable` and `enumerable` of a `boolean` type attributes picked from default `PropertyDescriptor` for accessor and data
3+
* descriptor.
4+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty
5+
* "If a descriptor has neither of `value`, `writable`, `get` and `set` keys, it is treated as a data descriptor. "
6+
*/
7+
export interface CommonDescriptor extends Pick<PropertyDescriptor, 'configurable' | 'enumerable'> {}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { CommonDescriptor } from './common-descriptor.interface';
2+
/**
3+
* Data descriptor with its unique `writable`, `value` attributes, and a generic `Value` type for the `value`.
4+
*/
5+
export interface DataDescriptor<Value> extends CommonDescriptor {
6+
writable: boolean;
7+
value: Value;
8+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Interface.
2+
export { AccessorDescriptor } from './accessor-descriptor.interface';
3+
export { DataDescriptor } from './data-descriptor.interface';
4+
export { CommonDescriptor } from './common-descriptor.interface';
5+
export { ObjectOne } from './object-one.interface';
6+
export { ObjectTwo } from './object-two.interface';
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { NUMBER } from '../variables/strict/number.const';
2+
import { STRING } from '../variables/strict/string.const';
3+
import { SYMBOL_NUMBER, SYMBOL_STRING } from '../variables/strict/symbol.const';
4+
5+
export interface ObjectOne {
6+
'key as string'?: boolean;
7+
1030405027?: string;
8+
5?: string;
9+
[NUMBER]?: string;
10+
[STRING]?: string;
11+
[SYMBOL_NUMBER]?: string;
12+
[SYMBOL_STRING]?: number;
13+
x: number;
14+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export interface ObjectTwo { x: string; y: number; }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { ThisAccessorDescriptor } from './this-accessor-descriptor.type';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { AccessorDescriptor } from '../interface/accessor-descriptor.interface';
2+
export type ThisAccessorDescriptor<Value, Obj = any> = AccessorDescriptor<Value> & ThisType<Obj>;

0 commit comments

Comments
 (0)