Our great sponsors
-
Short comment about the 'unknown' type: TypeScript 4.4 had me learning about it very recently, because 'unknown' has been made the default type in 'catch (error)' clauses [0]. So most of our code in 'catch' blocks suddenly didn't compile any more after an unsuspecting update of the TS version.
Which is a good thing, because in reviewing those I found several places where incorrect assumptions were being made about the type of error that would be caught.
(side note: TypeScript does not follow SemVer; they just promise to avoid breaking changes in Patch updates, but don't promise anything won't break in Minor updates [1])
[0]: https://devblogs.microsoft.com/typescript/announcing-typescr...
[1]: https://github.com/microsoft/TypeScript/issues/14116#issueco...
-
Probably best to just lift one off of a major library like Lodash, they're well tested and efficient (no need to actually use the library):
https://github.com/lodash/lodash/blob/master/isObject.js
But depends on your needs, and you can also attach a typeguard to it.
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
-
I really like this package, because it not only uses the method you mentioned for checking types, but is written in TS, so you get the type checking feedback.
-
-
> I have only seen null vs undefined lead to 2 things in my experience: mistakes and bikeshedding.
I disagree, though I think the implementation leaves something to be desired. Primarily, I think there is fundamentally a difference between the value of obj.bar in the following examples that is useful to differentiate between:
{ foo: 'hello' }
{ foo: 'hello', bar: null }
For example, GraphQL makes specific use of this when dealing with input types for mutations: null essentially means "delete this field" while unset means "don't change it".
There is a very good discussion on this topic here, https://github.com/graphql/graphql-js/issues/133 , which goes into the rationale behind it, how it's supported in languages that do NOT differentiate between null and undefined, and how some folks changed their minds on the issue.
-
milewski-ctfp-pdf
Bartosz Milewski's 'Category Theory for Programmers' unofficial PDF and LaTeX source
You don't need a PhD, you just need the first few chapters of [Category Theory for Programmers](https://github.com/hmemcpy/milewski-ctfp-pdf) :)
-
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
json-parser-in-typescript-very-bad-idea-please-dont-use
JSON Parser written entirely in TypeScript's type system
-
-
Related posts
- Hegel – An advanced static type checker for JavaScript
- Ways to validate environment configuration in a forFeature Config in NestJs
- How to scrape Amazon products
- Deep Cloning Objects in JavaScript, the Modern Way
- Enhancing Redwood: A Guide to Implementing Zod for Data Validation and Schema Sharing Between the API and Web Layers