mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 01:23:52 +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:
@@ -16,7 +16,11 @@ const hasJsxRuntime = (() => {
|
||||
})();
|
||||
|
||||
module.exports = babelJest.createTransformer({
|
||||
plugins: ['@shopify/react-i18n/babel'],
|
||||
plugins: [
|
||||
['@babel/plugin-transform-typescript', {
|
||||
allowDeclareFields: true
|
||||
}],
|
||||
'@shopify/react-i18n/babel'],
|
||||
presets: [
|
||||
[
|
||||
require.resolve('babel-preset-react-app'),
|
||||
|
||||
@@ -427,6 +427,9 @@ module.exports = function (webpackEnv) {
|
||||
],
|
||||
|
||||
plugins: [
|
||||
[require.resolve('@babel/plugin-transform-typescript'), {
|
||||
allowDeclareFields: true
|
||||
}],
|
||||
require.resolve('@shopify/react-i18n/babel'),
|
||||
isEnvDevelopment &&
|
||||
shouldUseReactRefresh &&
|
||||
|
||||
@@ -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