typed-object-interfaces
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

typed-object-interfaces

Typed object interfaces. Types for plain objects.

Examples

import { NumberObject } from 'typed-object-interfaces';
  
/** key is a User ID, value is Age of the User */
let userAges: NumberObject = {};
  
userAges[ 1 ]   = 13;   // ok
userAges[ '2' ] = 45;   // ok
userAges[ 3 ]   = '45'; // error

Source Code

export interface NumberObject {
  [name: string]: number;
  [name: number]: number;
}

export interface StringObject {
  [name: string]: string;
  [name: number]: string;
}

export interface BooleanObject {
  [name: string]: boolean;
  [name: number]: boolean;
}

export interface DefaultObject {
  [name: string]: string | number;
  [name: number]: string | number;
}

export interface StdObject {
  [name: string]: string | number | boolean;
  [name: number]: string | number | boolean;
}

export interface AnyObject {
  [name: string]: any;
  [name: number]: any;
}

export interface TypeObject<T> {
  [name: string]: T;
  [name: number]: T;
}

export interface ArrayObject<T> {
  [name: string]: T[];
  [name: number]: T[];
}

export type IObject<T> = {[key in keyof T]?: T[key]};

Readme

Keywords

none

Package Sidebar

Install

npm i typed-object-interfaces

Weekly Downloads

2

Version

1.3.0

License

MIT

Last publish

Collaborators

  • ankor