Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
Mobx - Object literal may only specify known properties

I recently started to learn how to use Mobx to manage my application's state and recently I came across the following error:

Object literal may only specify known properties, and "data" does not exist in type "AnnotatiosMap<this, never>".

This happens whenever I want to make a property of my class private. However, if it is public or protected, the problem does not occur.

This is a small snippet of my code:

import { makeObservable, observable } from "mobx";

class Base {
  private data: string[];

  constructor() {
    this.data = [];

    makeObservable(this, {
      data: observable,
    });
  }

  public getData = (): string[] => {
    return this.data;
  };

}

export default new Base();

What should I do to make my property private but still being watched?

Have a great day!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

From the docs:

By default TypeScript will not allow you to annotate private fields. This can be overcome by explicitly passing the relevant private fields as generic argument, like this: makeObservable<MyStore, "privateField" | "privateField2">(this, { privateField: observable, privateField2: observable })

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!