Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Entwicklung
    4. The left-hand side of an arithmetic .... type.ts(2362)

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    The left-hand side of an arithmetic .... type.ts(2362)

    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      foxthefox Developer last edited by

      ich versuche meinen den Fritzbox Adapter auf die Klassenbasierte Variante umzusetzen und mit den typecheckings.
      bekomme den Fehler nicht weg

      The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.ts(2362)

      Das passiert bei so einfachen Sachen wie hier

      Math.floor(state.val / 100 * 255)

      Was kann man da machen?

      Gruß
      Klaus

      UncleSam 1 Reply Last reply Reply Quote 0
      • UncleSam
        UncleSam Developer @foxthefox last edited by

        @foxthefox state.val kann ganz verschiedene Typen sein. Wenn du sicher bist, dass es eine Nummer ist, dann schreibe: Math.floor((state.val as number) / 100 * 255)

        F 1 Reply Last reply Reply Quote 0
        • F
          foxthefox Developer @UncleSam last edited by foxthefox

          @UncleSam

          Danke für die Idee.

          Leider ist es Javascript und kein Typescript.
          bekomme den Fehler

          Type assertion expressions can only be used in TypeScript files.ts(8016)

          EDIT: Number(state.val) scheint es zu mögen

          1 Reply Last reply Reply Quote 0
          • First post
            Last post

          Support us

          ioBroker
          Community Adapters
          Donate

          807
          Online

          31.9k
          Users

          80.2k
          Topics

          1.3m
          Posts

          typecheck javascript
          2
          3
          566
          Loading More Posts
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes
          Reply
          • Reply as topic
          Log in to reply
          Community
          Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
          The ioBroker Community 2014-2023
          logo