mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-14 10:35:11 +00:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user