Module '"@bonfida/spl-name-service"' has no exported member...
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
Hi @drewstaylor, thanks for bringing this to our attention. We'll investigate and update you based on our findings.
Hi @drewstaylor Can you please help me with the package versions you're using?
@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.
Hey @drewstaylor, apologies I'm having trouble recreating this. Can you share with me your tsconfig.json for me to compare?
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"]
}
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 🙏
Fixed in #110.