I’m a programmer loving Web, JavaScript, CSS, Ruby, and Emacs!
ybiquitous / bem-ts Goto Github PK
View Code? Open in Web Editor NEWBEM class names generator for TypeScript
Home Page: https://npm.im/bem-ts
License: MIT License
BEM class names generator for TypeScript
Home Page: https://npm.im/bem-ts
License: MIT License
In the README is this example:
import * as React from "react";
import bem from "bem-ts";
import "./Button.scss";
const b = bem("Button");
interface Props {
state: "success" | "danger";
icon: React.ReactNode;
children: React.ReactNode;
}
export function Button({ state, icon, children }: Props) {
return (
<button className={b({ state })}>
<i className={b("icon", { state })}>{icon}</i>
{children}
</button>
);
}
But it produces type conflicts:
Argument of type '{ state: "success" | "danger"; }' is not assignable to parameter of type 'string | Modifiers | undefined'.
Types of property 'state' are incompatible.
Type '"success" | "danger"' is not assignable to type 'boolean | null | undefined'.
Type '"success"' is not assignable to type 'boolean | null | undefined'.
e.g.
b("elem__mod--foo");
//=> Error!?
E.g.,
// as Object
b({ [type]: true, [align]: true })
// as Array
b([type, align])
Was wondering if it is possible to generate css at build time and tree shake this whole library
Line 48 in 254b49c
When upgrading from 0.12.1 to 0.13.x typscript is complaining about the missing module bem-ts
ModuleNotFoundError: Could not find module in path: 'bem-ts' relative to '/src/index.ts'
I've created a code sandbox to demonstrate the issue running the following code
import bem from "bem-ts";
const b = bem("block");
console.log(b());
bem-ts v0.12.1: https://codesandbox.io/s/typescript-forked-959orq?file=/src/index.ts
bem-ts v0.13.0: https://codesandbox.io/s/typescript-forked-slo8ef?file=/src/index.ts
I hope the description makes sense and you can follow my lead. Happy to support fixing this bug.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.