Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
103 views
in Technique[技术] by (71.8m points)

javascript - Accidentally enabled some error checking, cannot undo

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

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

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...