napi-rs / napi-rs/node-rs

Consider using not-const enums to be compatible with `isolatedModules`

Open
#809 0 comments 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
1.5k
Forks
52
Avg merge
13h 37m
Merged PRs (30d)
19

Description

import { Algorithm } from '@node-rs/argon2';
console.log(Algorithm.Argon2d);

when I'm running tsc, it fails with

src/index.ts:2:13 - error TS2748: Cannot access ambient const enums when 'isolatedModules' is enabled.

I have isolatedModules switched on because I'm using Babel to compile my project.

To fix this problem would be best to export usual enums instead of const enum. Related articles:

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the TypeScript declarations behind the @node-rs/argon2 export and identify where Algorithm is defined as a const enum. Reproduce the failure with tsc and isolatedModules enabled, then verify that the exported enum can be consumed without TS2748.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.