TypeScript
Yup
TypeScript | Yup | |
---|---|---|
1,353 | 119 | |
100,022 | 22,682 | |
0.6% | - | |
9.9 | 5.7 | |
4 days ago | 15 days ago | |
TypeScript | TypeScript | |
Apache License 2.0 | 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.
TypeScript
-
createStore in Zustand's source code explained.
const createStoreImpl: CreateStoreImpl = (createState) => { type TState = ReturnType type Listener = (state: TState, prevState: TState) => void let state: TState const listeners: Set = new Set() const setState: StoreApi['setState'] = (partial, replace) => { // TODO: Remove type assertion once https://github.com/microsoft/TypeScript/issues/37663 is resolved // https://github.com/microsoft/TypeScript/issues/37663#issuecomment-759728342 const nextState = typeof partial === 'function' ? (partial as (state: TState) => TState)(state) : partial if (!Object.is(nextState, state)) { const previousState = state state = (replace ?? (typeof nextState !== 'object' || nextState === null)) ? (nextState as TState) : Object.assign({}, state, nextState) listeners.forEach((listener) => listener(state, previousState)) } } const getState: StoreApi['getState'] = () => state const getInitialState: StoreApi['getInitialState'] = () => initialState const subscribe: StoreApi['subscribe'] = (listener) => { listeners.add(listener) // Unsubscribe return () => listeners.delete(listener) } const api = { setState, getState, getInitialState, subscribe } const initialState = (state = createState(setState, getState, api)) return api as any }
-
Building a Personal Finance App with Arcjet
Our application will be built using TypeScript and the technical stack will be:
-
What is your way declare types for objects in TypeScript?
TypeScript is a great "onbuild" for JavaScript that adds static types and helps us catch errors early during development, and even though, sometimes you need to break your brain to type some function it is still wonderful.
-
Object.is() usage in Zustand’s source code.
const setState: StoreApi['setState'] = (partial, replace) => { // TODO: Remove type assertion once https://github.com/microsoft/TypeScript/issues/37663 is resolved // https://github.com/microsoft/TypeScript/issues/37663#issuecomment-759728342 const nextState = typeof partial === 'function' ? (partial as (state: TState) => TState)(state) : partial if (!Object.is(nextState, state)) { const previousState = state state = (replace ?? (typeof nextState !== 'object' || nextState === null)) ? (nextState as TState) : Object.assign({}, state, nextState) listeners.forEach((listener) => listener(state, previousState)) } }
- 10 Reasons TypeScript is Transforming How We Build Web Apps
-
Casual Clothes App Using Next.js 14, TypeScript, Prisma & Next-Auth
TypeScript
-
Modern Web Development with Turborepo, Next.js, TailwindCSS, NestJS, and More…
Each package/app is 100% TypeScript.
-
Interesting TypeScript issue
As we can see, it has a typing issue as the comment. I quickly searched for solution, then I ended up following up this issue which was open long ago https://github.com/microsoft/TypeScript/issues/30581.
-
LogTape: Zero-Dependency Logging for JavaScript That Just Works
LogTape is a shiny new logging library for JavaScript and TypeScript that's designed with one goal in mind: to make logging simple, flexible, and hassle-free across all your JavaScript environments. Whether you're building applications for Deno, Node.js, Bun, edge functions, or browsers, LogTape has got you covered.
- Allow type annotations in .js files in preparation for Type Annotations proposal
Yup
-
Building Forms in React.js : A beginners guide
For ease of work, you must use Yup package to smoothly Validate the form data. It is a very popular package used with Form Libraries like React-Hook-Form or Formik. Yup Docs: https://www.npmjs.com/package/yup
-
How To Verify Forms Using Formik in React js
You can study more about Formik here and Yup here.
-
How to Validate Array of Strings using Yup
Hello! In this tutorial, you'll learn how to validate an array of strings using Yup validation library. First, you'll learn how to validate a string and then apply it to an array. I recently had this problem where the form requires each input field to not be empty. I'll share in this tutorial how I did it.
-
How To Use Formik & Yup For Form Validations
*Yup: https://www.npmjs.com/package/yup
-
Validation With Yup!. Did You Know This Method ?
As we are only learning the validation method here, I am not going for a detailed explanation of Yup. if you are new to the Yup, here is docs for Yup.
-
Vue 3 Forms and Validations with VueFormify and yup
Let’s make our first form! We will create a simple login form with yup schema validator. With yup we can easily define nested object rules which make client-side validation much more easier. Check yup documentation for more details.
-
Converting React Forms to Formik and Yup
Formik and Yup empower you to build robust and user-friendly forms in React. By leveraging their capabilities, you can streamline form management, reduce boilerplate code, and ensure a smooth user experience with clear and effective validation. Refer to the official documentation of Formik https://formik.org/ and Yup https://github.com/jquense/yup for in-depth exploration and advanced use cases.
-
Crafting Forms in React: Vanilla vs. React Hook Form vs. Formik
On the other hand, Formik gives you components that you can mix and match to have fully working forms. Formik has builtin support for Yup for data validation.
-
Using React Select with Formik
I was recently building an application that, among other features, allows a user to submit chess players and chess games to a database. I was utilizing Yup for form schema and Formik for error handling, validation, and form submission.
-
A simple Vue form validation composable with Zod
Sometimes our use case might not require a full-blown form validation library though and we might already have a schema validation library installed in our project such as Zod or Yup. In that case, a simple Vue composable is all that is needed to provide a great form validation UX.
What are some alternatives?
zod - TypeScript-first schema validation with static type inference
joi - The most powerful data validation library for JS [Moved to: https://github.com/hapijs/joi]
Flutter - Flutter makes it easy and fast to build beautiful apps for mobile and beyond
joi - The most powerful data validation library for JS [Moved to: https://github.com/sideway/joi]
Tailwind CSS - A utility-first CSS framework for rapid UI development.
zx - A tool for writing better scripts
ajv - The fastest JSON schema Validator. Supports JSON Schema draft-04/06/07/2019-09/2020-12 and JSON Type Definition (RFC8927)
esbuild - An extremely fast bundler for the web
Superstruct - A simple and composable way to validate data in JavaScript (and TypeScript).
gray-matter - Smarter YAML front matter parser, used by metalsmith, Gatsby, Netlify, Assemble, mapbox-gl, phenomic, vuejs vitepress, TinaCMS, Shopify Polaris, Ant Design, Astro, hashicorp, garden, slidev, saber, sourcegraph, and many others. Simple to use, and battle tested. Parses YAML by default but can also parse JSON Front Matter, Coffee Front Matter, TOML Front Matter, and has support for custom parsers. Please follow gray-matter's author: https://github.com/jonschlinkert
jest - Delightful JavaScript Testing.