Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am assigning an Error object to a variable, and adding some custom properties to it.

VS Code error checking highlighted the new property, saying its not part of the Error object, which is true, but it works anyway.

So I clicked "quick fix" and accidenntally clicked an option, but no idea what it was.

The error highlighting has gone, but now if i add other custom properties, they all get checked against being the same type as the first custom property.

eg first custom property was a number, if i add a string, it now highlights that saying its not of type number.

what setting did i enable, and how do i disable it?

question from:https://stackoverflow.com/questions/66068165/accidentally-enabled-some-error-checking-cannot-undo

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
104 views
Welcome To Ask or Share your Answers For Others

1 Answer

If I declare a Error.mycustom = 1 VS Code offers two fixes:

  • Declare property 'custom'
  • Add index signature for property 'custom'

Both seem to modify the ErrorConstructor interface. The first option simply adds a mycustom: number to it, while the second one adds [x: string]: number. To find the modification, right click on Error an select "Go to Definition". Then you simply have to look for the ErrorConstructor interface in that file (typically directly below the definition of Error) and remove the custom declaration.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...