sns-sdk icon indicating copy to clipboard operation
sns-sdk copied to clipboard

Module '"@bonfida/spl-name-service"' has no exported member...

Open drewstaylor opened this issue 1 year ago • 5 comments

As it stands now, it's not possible to use @bonfida/spl-name-service or @bonfida/sns-records in TypeScript projects due to misconfiguration of exports.

While I'm able to access the exported functions using JavaScript, trying to build a TypeScript project with these modules fails.

Example:

$ npm run build
> [email protected] build
> tsc
src/helpers/solana/snsRecord.ts:8:10 - error TS2305: Module '"@bonfida/spl-name-service"' has no exported member 'getDomainKeySync'.
8 import { getDomainKeySync, NameRegistryState  } from "@bonfida/spl-name-service";
           ~~~~~~~~~~~~~~~~
src/helpers/solana/snsRecord.ts:8:28 - error TS2305: Module '"@bonfida/spl-name-service"' has no exported member 'NameRegistryState'.
8 import { getDomainKeySync, NameRegistryState  } from "@bonfida/spl-name-service";
                             ~~~~~~~~~~~~~~~~~
src/helpers/solana/snsRecord.ts:9:10 - error TS2305: Module '"@bonfida/sns-records"' has no exported member 'CENTRAL_STATE_SNS_RECORDS'.
9 import { CENTRAL_STATE_SNS_RECORDS } from "@bonfida/sns-records";
           ~~~~~~~~~~~~~~~~~~~~~~~~~
src/helpers/solana/snsResolver.ts:1:10 - error TS2305: Module '"@bonfida/spl-name-service"' has no exported member 'getDomainKeySync'.
1 import { getDomainKeySync, NameRegistryState  } from '@bonfida/spl-name-service';
           ~~~~~~~~~~~~~~~~
src/helpers/solana/snsResolver.ts:1:28 - error TS2305: Module '"@bonfida/spl-name-service"' has no exported member 'NameRegistryState'.
1 import { getDomainKeySync, NameRegistryState  } from '@bonfida/spl-name-service';
                             ~~~~~~~~~~~~~~~~~
src/helpers/solana/snsResolver.ts:2:10 - error TS2305: Module '"@bonfida/sns-records"' has no exported member 'Record'.
2 import { Record as SnsRecord, Validation } from "@bonfida/sns-records";
           ~~~~~~
src/helpers/solana/snsResolver.ts:2:31 - error TS2305: Module '"@bonfida/sns-records"' has no exported member 'Validation'.
2 import { Record as SnsRecord, Validation } from "@bonfida/sns-records";
                                ~~~~~~~~~~

Found 7 errors in 2 files.
Errors  Files
     3  src/helpers/solana/snsRecord.ts:8
     4  src/helpers/solana/snsResolver.ts:1

I've looked things over and there's no clear indicator for why their failing, but clearly the entire npm package needs to be overhauled. I've seen another user with the same issue in the comments on this Solana SO thread

drewstaylor avatar Mar 17 '25 15:03 drewstaylor

Hi @drewstaylor, thanks for bringing this to our attention. We'll investigate and update you based on our findings.

akashrdev avatar Mar 17 '25 16:03 akashrdev

Hi @drewstaylor Can you please help me with the package versions you're using?

akashrdev avatar Mar 19 '25 02:03 akashrdev

@bonfida/spl-name-service v3.0.10, but I tried using older versions of the package and the result is the same

In my package.json I have:

"dependencies": {
    // ...
    "@bonfida/sns-records": "^0.1.0",
    "@bonfida/spl-name-service": "^3.0.10",
    // ... 
  },

As a note, my unit tests using these packages do work in Jest, but I cannot build the project for production deployment.

drewstaylor avatar Mar 19 '25 12:03 drewstaylor

Hey @drewstaylor, apologies I'm having trouble recreating this. Can you share with me your tsconfig.json for me to compare?

akashrdev avatar Mar 24 '25 20:03 akashrdev

Yep, here you go @akashrdev

{
  "extends": "@tsconfig/recommended",
  "compilerOptions": {
    "target": "ES2021",
    "lib": ["ES2021", "ES2022.Object", "DOM"],
    "module": "NodeNext",
    "moduleResolution": "nodenext",
    "esModuleInterop": true,
    "noImplicitReturns": false,
    "noFallthroughCasesInSwitch": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "useDefineForClassFields": true,
    "strictPropertyInitialization": false,
    "allowJs": true,
    "strict": true,
    "strictFunctionTypes": false,
    "outDir": "dist",
    "types": ["jest", "node"],
    "resolveJsonModule": true,
    "baseUrl": "./",
    "paths": { "~/*": ["./src/*"] }
  },
  "include": ["**/*.ts", "**/*.js"],
  "exclude": ["node_modules", "dist"]
}

drewstaylor avatar Mar 26 '25 02:03 drewstaylor

We encountered the same issue after migrating from the deprecated moduleResolution: classic to the recommended moduleResolution: nodenext. I proposed a fix here: https://github.com/SolanaNameService/sns-sdk/pull/110 🙏

alexandre-abrioux avatar Jun 06 '25 19:06 alexandre-abrioux

Fixed in #110.

fm2055 avatar Aug 21 '25 09:08 fm2055