Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9097793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:12:15+00:00 2026-06-17T00:12:15+00:00

I have a typescript file like this… var obj = { /** Test comment

  • 0

I have a typescript file like this…

var obj = {
    /** Test comment */
    prop1: '',
    prop2: ''
};

And the javascript compiles as this…

var obj = {
    prop1: /** Test comment */
    '',
    prop2: ''
};

The problem with this is that JSDoc does not see the property of the object when generating documentation because the comment comes after the property.

My solution is this…

    var obj;
    obj = {};

    /** Test comment */
    obj.prop1 = '';

    obj.prop2 = '';

For some reason in this scenario I have to separate the declaration from the initialization, otherwise type script throws an error on the obj.propX = ''; lines of

The property ‘propX’ does not exist on value of type ‘{}’

My questions:

  1. Has anyone else run into this issue with the comment placement in objects?
  2. If so, how did you get around it if different than my own solution?
  3. If not, is there anything I can do to stop the error from happening so I can combine the variable declaration and the initialization.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T00:12:16+00:00Added an answer on June 17, 2026 at 12:12 am

    This is a bug. In a future release of TypeScript, the comments will be correctly preserved.

    In the meantime, for a workaround, you have two options:

    Either

    var obj: any = {}; // No type checking, anywhere, on obj
    

    Or

    var obj: { prop1: string; prop2: string; } = {}; // More work, but type checking will happen now
    

    After which you can do this and it should work as expected:

    /** Test comment */
    obj.prop1 = '';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a TypeScript class definition that starts like this; module Entities { export
If I have this TypeScript code: module Foo { var x : string =value;
I have a simple TypeScript (ts) which needs a function from a JavaScript file.
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:
I have a node app that has a string of require s, like this:
I have the following code: ///<reference path=../typescript/jquery.d.ts /> function addThemePrototypes() { var templateSetup =
I have a test project on TypeScript, code can found here . When I'm
I have this typoscript: page = PAGE page.10 = TEMPLATE page.10.template = FILE page.10.template.file
I have the following directory structure: /Admin/Grid abc.ts // this file contains the one
I have this typescript code: module MyPage { export class MyVm { ToDo :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.