We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b58dbcf commit 80f3335Copy full SHA for 80f3335
README.md
@@ -37,6 +37,19 @@ const CustomError = createError('ERROR_CODE', 'Hello %s')
37
console.log(new CustomError('world')) // error.message => 'Hello world'
38
```
39
40
+### TypeScript
41
+
42
+It is possible to limit your error constructor with a generic type using TypeScript:
43
44
+```ts
45
+const CustomError = createError<[string]>('ERROR_CODE', 'Hello %s')
46
+new CustomError('world')
47
+//@ts-expect-error
48
+new CustomError(1)
49
50
51
+```
52
53
## License
54
55
Licensed under [MIT](./LICENSE).
0 commit comments