Skip to content
This repository was archived by the owner on Feb 4, 2018. It is now read-only.

Commit 8f754dc

Browse files
author
blond
committed
doc(jsdoc): use typing
1 parent 2032118 commit 8f754dc

File tree

3 files changed

+14
-32
lines changed

3 files changed

+14
-32
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ Determines whether specified entity is an instance of BemEntityName.
262262

263263
Parameter | Type | Description
264264
-------------|-----------------|-----------------------
265-
`entityName` | `BemEntityName` | The entity to check.
265+
`entityName` | `*` | The entity to check.
266266

267267
```js
268268
const BemEntityName = require('@bem/entity-name');

index.js

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const stringifyEntity = require('@bem/naming').stringify;
99
* Enum for types of BEM entities.
1010
*
1111
* @readonly
12-
* @enum {String}
12+
* @enum {string}
1313
*/
1414
const TYPES = {
1515
BLOCK: 'block',
@@ -35,15 +35,7 @@ class EntityTypeError extends ExtendableError {
3535

3636
class BemEntityName {
3737
/**
38-
* @param {object} obj — representation of entity name.
39-
* @param {string} obj.block — the block name of entity.
40-
* @param {string} [obj.elem] — the element name of entity.
41-
* @param {object} [obj.mod] — the modifier of entity.
42-
* @param {string} obj.mod.name — the modifier name of entity.
43-
* @param {string} [obj.mod.val] — the modifier value of entity.
44-
* @param {string} [obj.modName] — the modifier name of entity. Used if `mod.name` wasn't specified.
45-
* @param {string} [obj.modVal] — the modifier value of entity.
46-
* Used if neither `mod.val` nor `val` were not specified.
38+
* @param {BemSDK.EntityName.Options} obj — representation of entity name.
4739
*/
4840
constructor(obj) {
4941
if (!obj.block) {
@@ -94,7 +86,7 @@ class BemEntityName {
9486
*
9587
* name.elem; // text
9688
*
97-
* @returns {string|undefined} - name of entity element.
89+
* @returns {?string} - name of entity element.
9890
*/
9991
get elem() { return this._data.elem; }
10092

@@ -112,7 +104,7 @@ class BemEntityName {
112104
* modName.mod; // { name: 'disabled', val: true }
113105
* blockName.mod; // undefined
114106
*
115-
* @returns {{mod: string, val: (string|true)}|undefined} - entity modifier.
107+
* @returns {?BemSDK.EntityName.ModifierRepresentation} - entity modifier.
116108
*/
117109
get mod() { return this._data.mod; }
118110

@@ -121,7 +113,7 @@ class BemEntityName {
121113
*
122114
* If entity is not modifier then returns `undefined`.
123115
*
124-
* @returns {string|undefined} - entity modifier name.
116+
* @returns {?string} - entity modifier name.
125117
* @deprecated - use `mod.name` instead.
126118
*/
127119
get modName() { return this.mod && this.mod.name; }
@@ -131,7 +123,7 @@ class BemEntityName {
131123
*
132124
* If entity is not modifier then returns `undefined`.
133125
*
134-
* @returns {string|undefined} - entity modifier name.
126+
* @returns {?(string|true)} - entity modifier name.
135127
* @deprecated - use `mod.val` instead.
136128
*/
137129
get modVal() { return this.mod && this.mod.val; }
@@ -211,7 +203,7 @@ class BemEntityName {
211203
*
212204
* name.isSimpleMod(); // null
213205
*
214-
* @returns {boolean|null}
206+
* @returns {(boolean|null)}
215207
*/
216208
isSimpleMod() {
217209
return this.mod ? this.mod.val === true : null;
@@ -250,7 +242,7 @@ class BemEntityName {
250242
*
251243
* // ➜ { block: 'button', mod: { name: 'focused', value: true } }
252244
*
253-
* @returns {{block: string, elem: (string|undefined), mod: ({name: string, val: (string|true)}|undefined)}}
245+
* @returns {BemSDK.EntityName.StrictRepresentation}
254246
*/
255247
valueOf() { return this._data; }
256248

@@ -284,8 +276,7 @@ class BemEntityName {
284276
/**
285277
* Return raw data for `JSON.stringify()`.
286278
*
287-
* @returns {{block: string, elem: (string|undefined),
288-
* mod: ({name: string, val: (string|true|undefined)}|undefined)}}
279+
* @returns {BemSDK.EntityName.StrictRepresentation}
289280
*/
290281
toJSON() {
291282
return this._data;
@@ -313,7 +304,7 @@ class BemEntityName {
313304
/**
314305
* Determines whether specified entity is instance of BemEntityName.
315306
*
316-
* @param {BemEntityName} entityName - the entity to check.
307+
* @param {*} entityName - the entity to check.
317308
*
318309
* @returns {boolean} A Boolean indicating whether or not specified entity is instance of BemEntityName.
319310
* @example
@@ -331,17 +322,7 @@ class BemEntityName {
331322
/**
332323
* Creates BemEntityName instance by any object representation.
333324
*
334-
* @param {object|string} obj — representation of entity name.
335-
* @param {string} obj.block — the block name of entity.
336-
* @param {string} [obj.elem] — the element name of entity.
337-
* @param {object|string} [obj.mod] — the modifier of entity.
338-
* @param {string} [obj.val] - the modifier value of entity. Used if `obj.mod` is a string.
339-
* @param {string} obj.mod.name — the modifier name of entity.
340-
* @param {string} [obj.mod.val] — the modifier value of entity.
341-
* @param {string} [obj.modName] — the modifier name of entity. Used if `obj.mod.name` wasn't specified.
342-
* @param {string} [obj.modVal] — the modifier value of entity.
343-
* Used if neither `obj.mod.val` nor `obj.val` were not specified.
344-
*
325+
* @param {(BemSDK.EntityName.NonStrictRepresentation|string)} obj — representation of entity name.
345326
* @returns {BemEntityName} An object representing entity name.
346327
* @example
347328
* const BemEntityName = require('@bem/entity-name');

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"typings": "index.d.ts",
2626
"files": [
2727
"index.js",
28-
"index.d.ts"
28+
"index.d.ts",
29+
"globals.d.ts"
2930
],
3031
"engines": {
3132
"node": ">= 4.0"

0 commit comments

Comments
 (0)