#1940·jsdoc

enums are not recognized at all when used in combination with checkJS

Author: KokujouCreated Oct 5, 2021Updated Aug 1, 2026

I'm using JSDoc to make javascript type-safe without all the disadvantages coming with typescript. works pretty well but the problem is now with enums.

a enum we would like to have has some criteria:

  1. if you enter any value which is not in the range of it, an error is generated
  2. auto-complete directly offers only the members of the enum
  3. no raw string input should be supported

but adding the @enum attribute is doing none of this. it's completely useless. the type in the end is still string (if using a string enum), so by now the @enum attribute is completely useless

Input code

javascript
/** @enum {string} */
export const enumType = {
  member1: 'value1',
  member2 'value2'
}

Expected behavior

  1. if you enter any value which is not in the range of it, an error is generated
  2. auto-complete directly offers only the members of the enum
  3. no raw string input should be supported

Current behavior

the instances behave exactly like normal strings - no IDE support at all

PS: i'm not sure if this is the right place to post this issue, because you guys might not be just adding the standard and some plugin or VSCode itself is responsible for using it in combination with checkJS if so i would appreciate it if you tell me where this issue should be filed