Error whenever I use Omit

Asked

Viewed 22 times

0

I always have a mistake that covers the Omit. It doesn’t stop running the code, but it keeps dialing the vscode and it bothers me.

constructor( {
        buyPrice,
        code,
        description,
        lovers,
        sellPrice,
        tags
      }: Omit<Product, 'id'> ){//digo os campos obrigatorios;
          this.buyPrice = buyPrice,
          this.code = code;
          this.sellPrice = sellPrice;
          this.tags = tags;
          this.lovers = lovers;
          this.description = description;
          this.id = uuid();
      }

Error that vscode points to when passing the mouse:

Cannot find name 'Omit'. ts(2304)

1 answer

0

I assume you’re running the server with ts-node-dev or the nodemon next to the ts-node or maybe sucrase, there are several options. But I imagine you are using the ts-node-dev and passing the argument --transpile-only this causes ts-Node to just transpose the code into javascript, that is, it will not check your typescript code, so your code keeps running even if there is this error.

I think there are two possibilities for this problem to be occurring:

  • Your vscode version is outdated
  • Or the version of typescript that you installed is old and still does not contain this type.

I hope I’ve helped!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.