Skip to content

jsdoc @enum with import/export #33575

Closed
@art-in

Description

@art-in

TypeScript Version: 3.6.3

Code

This works:

/** @enum {number} */
const MyEnum = {
  a: 1,
  b: 2
};

/** @type {MyEnum} */
const v = MyEnum.b;

This doesn't work (MyEnum imported from separate file):

// my-enum.js

/** @enum {number} */
const MyEnum = {
  a: 1,
  b: 2
};

export default MyEnum;

// main.js

import MyEnum from './my-enum.js';

/** @type {MyEnum} */ // ERROR: 'MyEnum' refers to a value, but is being used as a type here. ts(2749)
const v = MyEnum.b;

Expected behavior:

No type errors.

It did work fine in v2.8.3

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: JSDocRelates to JSDoc parsing and type generationFix AvailableA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions