Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

207
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda