Skip to content

Instantly share code, notes, and snippets.

View caprica's full-sized avatar
🇬🇧
Saros

Mark Lee caprica

🇬🇧
Saros
View GitHub Profile
@caprica
caprica / generic-react-component.ts
Created November 20, 2022 07:38
Example of a React component using Typescript with generics
/*
* An outline example of how to create a generic component using Typescript and
* React.
*
* This is NOT the only way to do something like this.
*/
// === Generic component ===
/**
@caprica
caprica / tsconfig-node-error-constructor.md
Created December 2, 2024 09:52
Tweak tsconfig.json if needed to enable newer features in Node (custom Error constructor)

When using nx to generate a Javascript library, the tsconfig it generates does not allow to use newer language/platform versions, for examle the Error constructor:

export class SomeCustomError extends Error {
    constructor(message: string, err?: Error) {
        super(message, { cause: err })           // <--- it will complain about 'cause' here
        this.name = this.constructor.name
    }
}