avatarKASATA

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

1261

Abstract

g the following properties from type ‘{ id: number; priceTitle1: string; price1: string; }’: priceTitle1, price1</p></blockquote><blockquote id="e008"><p>dynamicValidateForm.priceItems.push({ id: nextId, [priceTitle${nextId}]: ‘’, [price${nextId}]: ‘’ });</p></blockquote><blockquote id="8ebe"><p><b>^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</b></p></blockquote><h1 id="ca2f"><Solution></h1><p id="54dc">Press <b>Cmd + Shift + P</b></p><p id="ea47">Enter <b>setting</b></p><figure id="e99a"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*RQsfqEsIfv12MEQhiOHxVw.png"><figcaption></figcaption></figure><p id="3a46">Click Open Settings</p><p id="7cac">Change the contents of eslint.validate</p><figure id="6146"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*VP7eqtv0PDwsMgjkmsNGMw.png"><figcaption></figcaption></figure><ul><li>Before</li></ul><div id="0bf4"><pre>{ ~</pre></div><div id="ae21"><pre> <span class="hljs-attr">"eslint.validate"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span></pre></div><div id="df2d"><pre> <span class="hljs-string">"javascript"</span>,</pre></div><div id="106c"><pre> <span class="hljs-string">"javascriptreact"<

Options

/span>,</pre></div><div id="ee2a"><pre> ],</pre></div><div id="7a92"><pre> ~ }</pre></div><ul><li>After</li></ul><div id="7c2a"><pre>{ ~</pre></div><div id="3d7d"><pre> <span class="hljs-attr">"eslint.validate"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span></pre></div><div id="f700"><pre> <span class="hljs-string">"javascript"</span>,</pre></div><div id="1aef"><pre> <span class="hljs-string">"javascriptreact"</span>,</pre></div><div id="5315"><pre> <span class="hljs-string">"typescript"</span>,</pre></div><div id="4296"><pre> <span class="hljs-string">"typescriptreact"</span></pre></div><div id="4d19"><pre> ],</pre></div><div id="6340"><pre> ~ }</pre></div><p id="6664">Errors will be displayed at the time of editing, so errors can be identified in advance, increasing development efficiency!</p><figure id="7896"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*znetTJ-lolbxbdDjqUvTkA.png"><figcaption></figcaption></figure><p id="5610">I hope that this article will be of some help to you!</p><p id="a63e"><b>Happy Developing!</b></p><p id="caa2">KASATA</p><p id="f15d"><a href="https://twitter.com/IT_makesUsHappy">https://twitter.com/IT_makesUsHappy</a></p></article></body>

[2022]How to show Typescript error with ESLint and VScode.

ESLint is a very powerful and useful tool that notifies you of errors and other problems as you are editing code. However, the default settings of VScode do not notify us of errors regarding TypeScript, and there are problems such as a large number of errors only when we do a build. In this article, I will share the solution to this problem.

<Problem>

There are no apparent errors when editing Code.

But if I build the project

npm run build

TS2345: Argument of type ‘{ [x: string]: string | number; id: number; }’ is not assignable to parameter of type ‘{ id: number; priceTitle1: string; price1: string; }’.

Type ‘{ [x: string]: string | number; id: number; }’ is missing the following properties from type ‘{ id: number; priceTitle1: string; price1: string; }’: priceTitle1, price1

dynamicValidateForm.priceItems.push({ id: nextId, [`priceTitle${nextId}`]: ‘’, [`price${nextId}`]: ‘’ });

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

<Solution>

Press Cmd + Shift + P

Enter setting

Click Open Settings

Change the contents of eslint.validate

  • Before
{
  ~
  "eslint.validate": [
    "javascript",
    "javascriptreact",
  ],
  ~
}
  • After
{
  ~
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "typescript",
    "typescriptreact"
  ],
  ~
}

Errors will be displayed at the time of editing, so errors can be identified in advance, increasing development efficiency!

I hope that this article will be of some help to you!

Happy Developing!

KASATA

https://twitter.com/IT_makesUsHappy

Typescript
Eslint
Vscode
Visual Studio Code
JavaScript
Recommended from ReadMedium