Skip to content

error TS2365: Operator '+' cannot be applied to types 'string | number' and 'string | number'. #49661

Closed as not planned
@borisovg

Description

@borisovg

Bug Report

Code does not compile.

🔎 Search Terms

"Operator '+' cannot be applied to types".

🕗 Version & Regression Information

4.7.4

💻 Code

const foo = { foo: 123, bar: 'bar' };

for (const k of ['foo', 'bar'] as const) {
  const val = foo[k];
  console.log(val + val);
}

🙁 Actual behavior

src/test.ts:5:15 - error TS2365: Operator '+' cannot be applied to types 'string | number' and 'string | number'.

🙂 Expected behavior

No error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design LimitationConstraints of the existing architecture prevent this from being fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions