RSS FeedTwitterMastodonBlueskyShare IconHeart IconGithub IconArrow IconClock IconGUI Challenges IconHome IconNote IconBlog IconCSS IconJS IconHTML IconShows IconOpen Source Software IconSpeaking IconTools IconShuffle IconNext IconPrevious IconCalendar IconCalendar Edit IconNotebook IconObservable Notebooks IconSlash IconGoogle G Icon
A cartoon skull with a hotpink hat on.
atom@argyleink
notecss

TcsS - Typed Cascade Style Sheets

Why hasn't this been made yet? CSS has all the type information needed to create a comparable experience to TypeScript.

The TS logo and the CSS logo combine into a TcsS logo

71 mentions #

178likes
30reposts
  • Elly Loel ✨🌱
  • Jordan Dingle
  • Oliver
  • Erik J Brown
  • unpunnyfuns
  • @chancethedev@mas.to
  • ユイト
  • GENKI
  • David
  • Wagner 💎⚡️👨‍💻
  • Alberto Silva
  • Wade Hammes
  • Vi Pro
  • NekoChan 🌸
  • Fynn Becker
  • mmurden
  • Ari Palo
  • Florian Geierstanger
  • Bruce B Anderson
  • bLaCkwEw
  • Justgu.us
  • NOMURA
  • Osama BCK
  • Mapl3.eth | zildine.hi
  • ⁠꒪⁠꒳⁠꒪
  • priya joseph
  • Tanner Hodges
  • Cory Etzkorn
  • CNine
  • techie quickhatch ⚛ 🐾 (Айті Росомаха)

Join the conversation on

@argyleink vanilla-extract is probably the closest thing, but like, it's not CSS at that point. it's TS.

someone needs to make a superset of CSS (like SCSS) with types and autocomplete, especially for things like gradients and shadows.

it could also be built into CSS maybe. i've also asked for this multiple times in surveys. the closest thing we might have is `@property` but that's only for custom properties

Mayank :verified:Mayank :verified:

@argyleink ...because "it's not a programming language" ... ?

ppk 🇪🇺ppk 🇪🇺

@argyleink Preface: I haven't read your article yet.

Would something like typed CSS solve a commonly had issue?

jerryjerry

@argyleink I’m kind of shocked that it never occurred to me to wonder about this. I suspect that back in the day I simply internalised browsers’ *application* of CSS as a black box that one reasons about indirectly?

OliverOliver

@argyleink If there was ever a moment that was ripe for such an intervention, this is certainly it!

What would be the mechanism for such a check do you think? What would a validator query against?

OliverOliver

@argyleink That would certainly be a spicy way to hold vendors to account for their implementations 😀

OliverOliver

@argyleink More seriously, that actually makes perfect sense: you can literally type-check syntax & values

OliverOliver

@argyleink please no. We are *just* getting to where CSS has absorbed enough from SCSS that we can finally get rid of pre-processors.

Half of the measure of progress of core web tech is being able to finally bin the bullshit stack required to compile “how we write it” into “what we wrote”.

Hard pass.

Matt WilcoxMatt Wilcox

@argyleink I think it's a pretty difficult lift when you get into details. Do we need to know the unique syntax of 700+ properties? How do we keep that up to date? Do we track browser support? Are we only checking value types, or also valid values? Both 'grid' and 'gord' are the same 'ident' type, but only one is a value for display.

And after solving all that, you're still limited to parse-time errors, unless you implement DOM & cascade. At which point you have a full browser… with dev tools.

Miriam SuzanneMiriam Suzanne

@argyleink Pre-processors & linters do some of these things that don't require maintaining a database of all possible properties/values. And it might be reasonable to write a Sass library with validation wrappers for CSS functions. Sass core does that with eg CSS color functions. But that all falls apart once custom properties/currentColor get the cascade involved.

PostCSS might be able to validate custom prop syntax against against `@property`? Again, that only gets you part way.

Miriam SuzanneMiriam Suzanne

@mia @argyleink all I really want now is stroke-linecap: gord

Adam KuhnAdam Kuhn

@cobra_winfrey @argyleink If we slip it into a spec, will anyone notice?

Miriam SuzanneMiriam Suzanne

@alvaromontoro @jerryD @argyleink Yeah, there are very few issues where you'd need to add custom typing to CSS. Only if you want to add extra restrictions for a design system, like to only use your declared variables for colours or something.

For most cases, the issue is that the tools people are using to edit CSS aren't giving feedback about errors. However, the in-browser Dev tools are starting to add that. And maybe that's where it needs to stay, so it can stay up to date?

Amelia Bellamy-RoydsAmelia Bellamy-Royds

@argyleink I dislike this idea a lot tbh. CSS needn’t try to appeal to „Programmers“, it’s beauty is that it appeals to other demographics. It should remain this beacon. CSS shouldn’t be more programmer friendly.

Thomas Michael SemmlerThomas Michael Semmler

@argyleink Is there something like JS doc for CSS?

Florian GeierstangerFlorian Geierstanger

@AmeliaBR would the `color()` function cover the color case?

Alvaro MontoroAlvaro Montoro