Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapped types do not respect @public jsdoc #15

Closed
chrisd08 opened this issue Aug 29, 2020 · 4 comments
Closed

Mapped types do not respect @public jsdoc #15

chrisd08 opened this issue Aug 29, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@chrisd08
Copy link

chrisd08 commented Aug 29, 2020

Mapped types do not appear to respect @public jsdoc

/** @public */
export type TestKey = "a" | "b";
/** @public */
export type TestMappedType = {
  /** @public */
  [P in TestKey]?: {};
};

class TestMappedClass {
  /** @public */
  private testMapped: TestMappedType = {};
  public constructor() {
    this.testMapped.a = {};
  }
}

Results in

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var TestMappedClass = /** @class */ (function () {
    function TestMappedClass() {
        /** @public */
        this._private_testMapped = {};
        this._private_testMapped._internal_a = {};
    }
    return TestMappedClass;
}());

Note: I tried it using Record as well and it has the same issue

@timocov
Copy link
Owner

timocov commented Sep 14, 2020

@chrisd08 expected output here is:

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var TestMappedClass = /** @class */ (function () {
    function TestMappedClass() {
        this._private_testMapped = {};
        this._private_testMapped.a = {};
    }
    return TestMappedClass;
}());

am I right (don't rename a)?

@timocov timocov added the bug Something isn't working label Sep 14, 2020
@chrisd08
Copy link
Author

@timocov Yes that's correct

@timocov
Copy link
Owner

timocov commented Sep 14, 2020

Fixed in 74ed470. If a mapped type is exported, you don't need to mark it as public now. But anyway, if a mapped type isn't exported, you can mark the whole type as public in this case (instead of indexer or property keys) (see added test cases for the reference).

@timocov
Copy link
Owner

timocov commented Sep 14, 2020

The fix is just published in 0.8.0 version. Let me know if you have any further issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants