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

206
Views
Javascript Intellisense no longer working for object properties assigned after initial object creation in Visual Studio 2022

In VS2022 there seems to have been some major revision in the Javascript Intellisense Service in comparison to VS2019.

Javascript Intellisense no longer seems to recognize object properties assigned outside of the initial creation context.

var r = { a: 1, b: 2 };
r.c = 3;
//"r.a" and "r.b" will here be identified by Intellisense, but not "r.c".

This is some highly frustrating behaviour when there are scopes and dependency injected objects like in an AngularJs project since these no longer offer intellisense autocomplete or navigation using "go to definition".

This has previously worked very well without JSDoc headers in VS2019.

Visual Studio 2019

a,b,c,d,e are all available here.

Intellisense correctly working in VS2019

Visual Studio 2022

Only a,b,d are available here.

VS2022 no longer recognizes properties assigned outside of the creation context

Is there any known setting or package to alter/correct this new behaviour?

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

0

This happens because in javascript you don't have type declarations and since you're delaring just two properties it supposes taht your object contains only those. You can avoid this by adding comments, no changes in the code/logic but intellisense will recognize them

/** @type { {a: number, b: number, c?: number} } */
const obj = { a: 1, b: 2 };

// Now you can access every property your object has (not only the declared) and intellisense will recognize those declared

image

In the same way you can declare:

/** @type {string} */
const num = 12;

// Now intellisense will recognize it as a string even if it's a number
// and because in JS it's not an error to assign a number or a string to
// a variable it will throw an error at runtime if you try thing like
// num.trim();

Make sure of what you're declaring

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!