New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[jss] feature request: font-face types #35614
Comments
Please include code that currently fails the type checker and a link to the documentation for that runtime behavior. |
Here's a link to the There's no occurrence of In practice, I'm using Where it trips is when I try to pass an array, so I have to cast it to trick it. For example: // avenirFont is an array of font rules, as per JSS docs.
'@global': {
'@font-face': ([...avenirFont] as unknown) as CSSProperties,
}, What I've done in my local code to give the font faces a type is export type FontFaceRule = {
fontFamily: string
src: string
fallbacks: { src: string }[]
fontStyle: string
fontWeight: 0
} and I'm using Material-ui is typing import * as CSS from 'csstype';
import * as JSS from 'jss';
export interface CSSProperties extends CSS.Properties<number | string> {
// Allow pseudo selectors and media queries
[k: string]: CSS.Properties<number | string>[keyof CSS.Properties] | CSSProperties;
}
/**
* This is basically the API of JSS. It defines a Map<string, CSS>,
* where
*
* - the `keys` are the class (names) that will be created
* - the `values` are objects that represent CSS rules (`React.CSSProperties`).
*/
export type StyleRules<ClassKey extends string = string> = Record<ClassKey, CSSProperties>;
export type StyleRulesCallback<ClassKey extends string = string> = (
theme: Theme,
) => StyleRules<ClassKey>; Seems like material-ui is making some custom styles on top of If the |
I'm asking because I need some code to test this on. It's not apparent to me how this code would look in isolation. |
I believe @kof and company are maintaining a d.ts in the primary repo now. Should we even still have an |
Hi thread, we're moving DefinitelyTyped to use GitHub Discussions for conversations the To help with the transition, we're closing all issues which haven't had activity in the last 6 months, which includes this issue. If you think closing this issue is a mistake, please pop into the TypeScript Community Discord and mention the issue in the |
@appsforartists, @kof, @pelotom, @eps1lon
A typing for font face rules could be convenient.
The text was updated successfully, but these errors were encountered: