bem-cn: Provides its own types (#39653)

This commit is contained in:
Alexander T
2019-10-28 20:36:33 -07:00
committed by Jesse Trinity
parent 35a6164ede
commit 72bc7dbaba
5 changed files with 6 additions and 125 deletions
+6
View File
@@ -246,6 +246,12 @@
"sourceRepoURL": "https://github.com/sindresorhus/beeper",
"asOfVersion": "2.0.0"
},
{
"libraryName": "bem-cn",
"typingsPackageName": "bem-cn",
"sourceRepoURL": "https://github.com/albburtsev/bem-cn",
"asOfVersion": "3.0.0"
},
{
"libraryName": "BigInteger.js",
"typingsPackageName": "big-integer",
-54
View File
@@ -1,54 +0,0 @@
import * as block from "bem-cn";
import { Settings } from "bem-cn";
// expected 'block'
block("block")();
// expected 'block__elem'
block("block")("elem")();
// expected 'block__elem block__elem_disabled block__elem_size_small'
block("block")("elem", { disabled: true, size: 'small' })();
// expected 'block block_disabled'
block("block")({ disabled: true})();
// expected 'block mix'
block("block").mix("mix");
// expected 'block mix mix2'
block("block").mix(["mix", "mix2"]);
// expected 'block is-hidden'
block("block").state({ hidden: true });
// expected 'block'
block("block").state({ hidden: false });
// expected 'block is-hidden is-error'
block("block").state({ hidden: true, error: true });
// expected 'block is-loading'
block("block").is({ loading: true });
// expected 'block has-content'
block("block").has({ content: true });
block.setup({
el: '~~',
mod: '--',
modValue: '-'
});
// expected 'block~~elem'
block("block")("elem");
// expected 'block block--mod-value'
block("block")({ mod: "value"});
// I can use bem-cn interfaces
const customSettings: Settings = {
ns: 'prefix'
};
block.setup(customSettings);
-41
View File
@@ -1,41 +0,0 @@
// Type definitions for bem-cn 2.1
// Project: https://github.com/albburtsev/bem-cn
// Definitions by: Vitaly Selkin <https://github.com/selkinvitaly>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
type StateFn = (states: { [key: string]: boolean }) => BemCn.Inner;
declare function BemCn(name: string): BemCn.Inner;
declare namespace BemCn {
function reset(): void;
function setup(settings?: Settings): void;
interface Modifications {
[key: string]: (string | boolean);
}
interface Inner {
(elem: string | Modifications): Inner;
(elem: string, mods: Modifications): Inner;
(): string;
mix(mixes: string | string[]): Inner;
has: StateFn;
state: StateFn;
is: StateFn;
toString(): string;
valueOf(): string;
split(separator: string, limit?: number): string[];
}
interface Settings {
ns?: string;
el?: string;
mod?: string;
modValue?: string;
classMap?: { [className: string]: string } | null;
}
}
export as namespace BemCn;
export = BemCn;
-23
View File
@@ -1,23 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"bem-cn-tests.ts"
]
}
-7
View File
@@ -1,7 +0,0 @@
{
"extends": "dtslint/dt.json",
"rules": {
// TODO
"no-duplicate-imports": false
}
}