Skip to content

Instantly share code, notes, and snippets.

@mrmlnc
Created April 1, 2017 12:08
Show Gist options
  • Save mrmlnc/aef857a899cd76d6f5754ed4176d3556 to your computer and use it in GitHub Desktop.
Save mrmlnc/aef857a899cd76d6f5754ed4176d3556 to your computer and use it in GitHub Desktop.
declare namespace BemSDK {
export namespace EntityName {
/**
* Object to representation of entity name.
*/
interface EntityRepresentation {
/**
* The block name of entity.
*/
block: string;
/**
* The element name of entity.
*/
elem?: string;
mod?: any;
}
/**
* Strict object to representation of entity name.
*/
export interface StrictRepresentation extends EntityRepresentation {
/**
* The modifier of entity.
*/
mod?: ModifierRepresentation;
}
/**
* Object to representation of modifier of entity name.
*/
export interface ModifierRepresentation {
/**
* The modifier name of entity.
*/
name: string;
/**
* The modifier value of entity.
*/
val: string | true;
}
/**
* Non-strict object to representation of entity name.
*
* Contains old field: `val`, `modName` and `modVal.
*/
export interface NonStrictRepresentation extends EntityRepresentation {
/**
* The modifier of entity.
*/
mod?: string | {
/**
* The modifier name of entity.
*/
name: string;
/**
* The modifier value of entity.
*/
val?: string | boolean;
};
/**
* The modifier value of entity. Used if neither `mod.val` were not specified.
*/
val?: string;
/**
* The modifier name of entity. Used if `mod.name` wasn't specified.
*/
modName?: string;
/**
* The modifier value of entity. Used if neither `mod.val` nor `val` were not specified.
*/
modVal?: string;
}
}
}
declare module '@bem/entity-name' {
/**
* BEM entity name representation.
*/
class BemEntityName {
constructor(obj: BemSDK.EntityName.NonStrictRepresentation);
readonly block: string;
readonly elem: string | undefined;
readonly mod: BemSDK.EntityName.ModifierRepresentation | undefined;
readonly modName: string | undefined;
readonly modVal: string | boolean | undefined;
readonly id: string;
readonly type: string;
isSimpleMod(): boolean | null;
toString(): string;
valueOf(): BemSDK.EntityName.StrictRepresentation;
inspect(depth: number, options: object): string;
toJSON(): BemSDK.EntityName.StrictRepresentation;
isEqual(entityName: BemEntityName): boolean;
static isBemEntityName(entityName: any): boolean;
static create(obj: BemSDK.EntityName.NonStrictRepresentation | string): BemEntityName;
}
namespace BemEntityName { }
export = BemEntityName;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment