tsafe
tss-react
Our great sponsors
tsafe | tss-react | |
---|---|---|
11 | 9 | |
384 | 558 | |
- | - | |
6.7 | 8.1 | |
3 months ago | about 1 month ago | |
TypeScript | TypeScript | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
tsafe
-
Ensure you never forget a case in a switch
Hello, This is a use case for tsafe, a utility that let you make assertions on types.
- tsafe enables to unit test your types.
-
Ensure a Zod validator actually valid given type.
Zod is a solution for generating validators. I used to be reluctant to use it because I like to declare my types with the TypeScript syntax. I am not satisfied by getting the type inferred from the validator. The solution I found is to use tsafe, a utility that enables to make sure that two types are equals. With this solution you'll have to declare your type twice, once with the TypeScript syntax and once when declaring your zod parser but you are garentied that if you update your type and forget to update the corresponding zod parser your app won't build.
-
GitLanding: A beautiful landing page for your Github project in a matter of minutes.
tsafe.dev
-
How to Troubleshoot Types?
Hi, Checkout tsafe. It enables to test types definition. Checkout this GIF in particular. Let's say for example that we have an objectFromEntries function and we want to test it typewise, we can do: ```typescript import { objectEntries } from "../myObjectFromEntries"; import { assert } from "tsafe";
-
Object.fromEntries() with a return type more precise than just { [k: sting]: any; } 🥳
`Object.fromEntries()`, `Object.entries()` and `Object.keys()` are barely usable when in a TypeScript codebase because their return type are very vague. [tsafe](https://github.com/garronej/tsafe) features three new utilities: [objectFromEntries()](https://docs.tsafe.dev/objectfromentries), [objectEntries()](https://docs.tsafe.dev/objectentries) and [objectKeys()](https://docs.tsafe.dev/objectkeys), functionally equivalent to their built-in counterpart but featuring much better return types.
- tsafe: The missing TypeScript builtins
- tsafe: A powerful TypeScript assertion function
-
tsafe: A new assertion function for TypeScript
Three GIFs to convince you that you need tsafe in your life:
tss-react
-
The french government's design system
What I meant is that the lib provides the tooling to do CSS-in-JS if you so choose. But it's not at all mandatory. There is a fully type safe class system you can rely on. Internally no CSS-in-JS is used. I personally do love CSS-in-JS (I'm the author of TSS) but I understand the case against it.
-
A Type-safe i18n library
I'm not big on splitting things in neat little modules. Before we had logic.js structure.htm, styles.css then React suggested that logic and structure should be in the same file, it was the right move. Styles, in my oppignion, should be done in JS as well as well. I think that queries shouldn't be mangled with the UI stuffs.
-
How to Troubleshoot Types?
Real-life examples: 1, 2, 3
-
Gatsby JS — How to solve FOUC when using tss-react and Material UI v5
Material UI v5 brought some amazing updates, but switching from JSS to Emotion had an arguably nasty side-effect: it was no longer as straightforward to group your component styles in classes. Fortunately, a fantastic library emerged that allowed developers to not only reduce the extreme pain from migrating all their classes from v4's makeStyles to emotion, but to also to continue to writing classes in practically the same syntax, with wonderful TS type-safety. This library was tss-react, and it was one of my favorite open source discoveries of 2021.
-
What is everyone's go-to style framework/library right now?
You can still use makeStyles with tss-react, as documented here: https://mui.com/guides/migration-v4/#2-use-tss-react. I've used it and it seemed to work quite well.
- ✨ makeStyles is dead, long live makeStyles! ✨
- tss-react will be promoted as the new makeStyles API in material-ui v5
-
tss-react: Like JSS but with better typing. (integrates with MaterialUI)
tss-react
What are some alternatives?
type-fest - A collection of essential TypeScript types
Material UI - Ready-to-use foundational React components, free forever. It includes Material UI, which implements Google's Material Design.
eslint-plugin-total-functions - An ESLint plugin to enforce the use of total functions (and prevent the use of partial functions) in TypeScript.
JSS - JSS is an authoring tool for CSS which uses JavaScript as a host language.
TypeScript - TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
clean-architecture - 📐 A clean architecture framework
ts-ast-viewer - TypeScript AST viewer.
gitlanding - ✒️ React components for creating landingpages
gatsby-plugin-material-ui - Gatsby plugin for Material-UI with built-in server-side rendering support
starter-workflows - Accelerating new GitHub Actions workflows
styled - Minimal CSS-in-JS styled components solution for React.