@types/classnames package and had problems.@adidahiya @JKillian @seansfkelley @mradamczyk
New version of classnames types doesn't allow to use ClassArray interface anymore. It was quite usefull…
I don't think there's much we can do here without breaking the existing import * as classNames syntax... perhaps we could add another definition file to the package that has the types you're looking for?
// index.d.ts
import { ClassArray, ClassDictionary, ClassValue } from "./common";
type ClassNamesFn = (...classes: ClassValue[]) => string;
declare const classNames: ClassNamesFn;
export = classNames;
export as namespace classNames;
// common.d.ts
export type ClassValue = string | number | ClassDictionary | ClassArray | undefined | null | false;
export interface ClassDictionary {
[id: string]: boolean | undefined | null;
}
export interface ClassArray extends Array<ClassValue> { } // tslint:disable-line no-empty-interface
then you'd be able to do
import { ClassArray } from "classnames/common";
// or maybe?
import { ClassArray } from "@types/classnames/common";
Maybe interfaces can be attached to classNames namespace ?
Is there any progress?
Maybe is there an opportunity to write additional declaration file?
E.g. custom_typings/classnames_override.d.ts and declare there all needed types.
But I have no idea how to use it, how can it be included in the project then?
typeRoots, types and files configs in tsconfig.json don't work for this...
Does somebody know a workaround?
This is a blocker to integrating classNames in to a component library. I am using it internally to my (React) components and want to expose a prop that accepts anything that classNames does. At the moment, I would have to duplicate the definitions to make that work.
Most helpful comment
Is there any progress?