utils/customError: narrow type of name property

The name property is inherited from Error and has a type of string.
But our CustomError ensures that the name is restricted to the type
of T. This causes compiler errors, so we had to enable a babel plugin
to support it.
This commit is contained in:
David Lechner
2022-05-20 16:46:17 -05:00
parent 348d6e90d9
commit 4e88605b16
3 changed files with 10 additions and 1 deletions
+2
View File
@@ -2,6 +2,8 @@
// Copyright (c) 2022 The Pybricks Authors
export class CustomError<T extends string> extends Error {
declare name: T;
public constructor(name: T, message: string, cause?: Error) {
super(message, { cause });
this.name = name;