Skip to content

Problem with native TypeScript when use enum type #4536

Closed
@ChacaraKairo

Description

@ChacaraKairo

Node.js Version

v23.6.0

NPM Version

10.9.2

Subsystem

TypeScript

Description

In this version we can use TypeScript native, but when I was using a enum type for my variable happend a problem with the native case

Minimal Reproduction

// enum

enum Cores {
  'VERMELHO',
  'AZUL',
  'AMARELO',
  'BRANCO',
  'PRETO',
}
console.log(Cores);

enum Cores1 {
  vermelho = 'VERMELHO',
  azul = 'AZUL',
  amarelo = 'AMARELO',
  branco = 'BRANCO',
  preto = 'PRETO',
}
console.log(Cores1);

enum Numbers {
  zero = 0,
  um = 1,
  dois = 2,
  tres = 3,
  quatro = 4,
  cinco = 5,
  seis = 6,
  sete = 7,
  oito = 8,
  nove = 9,
  dez = 10,
}

// console.log(Cores);

Output

node 'enumType.ts'
node:internal/modules/typescript:52
    throw new ERR_INVALID_TYPESCRIPT_SYNTAX(error);
    ^

SyntaxError [ERR_INVALID_TYPESCRIPT_SYNTAX]:   x TypeScript enum is not supported in strip-only mode
    ,-[3:1]
  1 |     // enum
  2 |
  3 | ,-> enum Cores {
  4 | |     'VERMELHO',
  5 | |     'AZUL',
  6 | |     'AMARELO',
  7 | |     'BRANCO',
  8 | |     'PRETO',
  9 | `-> }
 10 |     console.log(Cores);
 11 |
 11 |     enum Cores1 {
    `----
  x TypeScript enum is not supported in strip-only mode
    ,-[12:1]
  9 |     }
 10 |     console.log(Cores);
 11 |
 12 | ,-> enum Cores1 {
 13 | |     vermelho = 'VERMELHO',
 14 | |     azul = 'AZUL',
 15 | |     amarelo = 'AMARELO',
 16 | |     branco = 'BRANCO',
 17 | |     preto = 'PRETO',
 18 | `-> }
 19 |     console.log(Cores1);
 20 |
 20 |     enum Numbers {
    `----
  x TypeScript enum is not supported in strip-only mode
    ,-[21:1]
 18 |     }
 19 |     console.log(Cores1);
 20 |
 21 | ,-> enum Numbers {
 22 | |     zero = 0,
 23 | |     um = 1,
 24 | |     dois = 2,
 25 | |     tres = 3,
 26 | |     quatro = 4,
 27 | |     cinco = 5,
 28 | |     seis = 6,
 29 | |     sete = 7,
 30 | |     oito = 8,
 31 | |     nove = 9,
 32 | |     dez = 10,
 33 | `-> }
 34 |
 35 |     // console.log(Cores);
    `----

    at parseTypeScript (node:internal/modules/typescript:52:11)
    at processTypeScriptCode (node:internal/modules/typescript:98:42)
    at stripTypeScriptModuleTypes (node:internal/modules/typescript:132:10)
    at Module._compile (node:internal/modules/cjs/loader:1691:15)
    at Object.loadTS [as .ts] (node:internal/modules/cjs/loader:1831:10)
    at Module.load (node:internal/modules/cjs/loader:1473:32)
    at Function._load (node:internal/modules/cjs/loader:1285:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:234:24)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:151:5) {
  code: 'ERR_INVALID_TYPESCRIPT_SYNTAX'
}

Before You Submit

  • I have looked for issues that already exist before submitting this
  • My issue follows the guidelines in the README file, and follows the 'How to ask a good question' guide at https://stackoverflow.com/help/how-to-ask

Metadata

Metadata

Assignees

No one assigned

    Labels

    answered🎉 Yay! The issue has been resolved, or the question has been answered.typescriptIssues regarding the usage / support of TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions