-
Notifications
You must be signed in to change notification settings - Fork 672
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
@theme-ui/typography => Typescript #890
Conversation
Doing this; I felt 2 things that I share here :
|
@mxstbr (can't find that "tag as reviewer" feature) |
FWIW, if it's easier to ditch the dependencies on |
@jxnblk yeah why not. Though I hand-wrote some decent type definitions; I'm publishing them to DT this evening and we'll be fine. The code of I think my strategy is OK for now; I digged into code; types and created some type "decorators" for internal use. This would introduce some breaking changes; but I definitely think for the mid / long term; we should just rethink the entire stuff with Polished / Shevy. I'd even vote to do this for v1 IMHO; especially as digging into Suprinsingly, Typography.js on itself seems pretty good (though not-that-typescript ready). |
How to proceed with that snapshot stuff in the tests dir ? |
PRed DefinitelyTyped for :
Forced |
BTW I kinda hate that git thinks packages/typography/src/to-theme.ts is new file. The only workaround i know is renaming the file in one commit and changing it in another. |
packages/typography/src/to-theme.ts
Outdated
blockMarginBottom: 1, | ||
} | ||
|
||
// TODO: find better theme definition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't you looking for this?
theme-ui/packages/css/src/types.ts
Line 513 in 9388b45
export interface Theme { |
@theme-ui/typography is sort of a plugin, so it could probably augment the Theme.
declare module '@theme-ui/css' {
export interface Theme {
typography: Typography
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly for Theme
interface. Giving this a try in the week.
Thanks bud :)
modularscale PR approved. Waiting for merge |
As seen inside #668; local module augmentation is not really "allowed" in that Monorepo strategy. To avoid something dirty (copy / paste, local-only typing, ...); I'm just waiting for DT PRs to be aproved + merged + published to finish the work here |
We can augment stuff in our |
@cyrilchapon has the DT PRs been merged yet? Can we get this PR ready for review again? |
Hey @cyrilchapon, would you be okay with me taking over this PR? |
Hey, I noticed we're removing const unwantedTypographyOptions = [
'headerColor',
'bodyColor',
'overrideStyles',
'overrideThemeStyles',
'plugins',
] as const Just wanted to notice it to make sure it's intentional. |
I took the liberty of fixing test fixtures, and merging #1002 here to make @theme-ui/css strict and avoid future merge problems. |
@hasparus yeah, I think the docs mention this, but it's not a 1:1 replacement for how typography.js works, so I don't think any of those options were used before. |
Sorry guys, as we like to say, "life interferred 🙂
Yep; I'm very glad my branch was usable and a good starting point !
Yeah I had just made it explicit with this variable, for a core-contributor to review it; because I did not know if it was intentional in the first place. (I literally just typed the existing, not removed / added stuff). I'm so glad it's merged ❤️ |
hey @timonbimon, this is actually a good question, and your confusion is understandable.
Theme UI 0.3 is written in JavaScript with types in DefinitelyTyped. |
Ok, great, that makes sense (and I see there are already a few release candidates for 0.4)! Thanks a lot for your help. 🤗 |
First pass; add typescript, headache with libs, small refactor.
Some notes :
compass-vertical-rhythm
modularscale
(I'll probably PR this to DT; but for now this is in local module augmentations)
TypographyOptions
andVerticalRhythm
. I had some headache with the various definitions of this acrosstheme-ui
,typography
,compass-vertical-rhythm
. I choose to expose to the world the official typography'sTypographyOptions
type (throughwithTheme
function, as argument). This is a choice (versus exposing the "custom" - modified -CustomTypographyOptions
type the package needs). I'm not sure of this choice. The core idea isTypographyOptions
as argument of the functionobject-assign
dependency on the way, and replaced this with plain ES7...spread
modularscale
andcompass-vertical-rhythm
; they are special (especially regardingVerticalRhythm
type difference across those libs)I'll probably do unit-tests this evening, along with documentation.