From d74067622c02de3125d2ef340068790ebaed076f Mon Sep 17 00:00:00 2001 From: Poroburu Date: Wed, 20 Aug 2025 16:48:02 -0400 Subject: [PATCH] Update TypeScript configuration and import statements for module compatibility for nodejs 23+ --- basics/checking-accounts/anchor/package.json | 1 + basics/checking-accounts/anchor/tests/bankrun.test.ts | 6 +++--- basics/checking-accounts/anchor/tests/test.ts | 2 +- basics/checking-accounts/anchor/tsconfig.json | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/basics/checking-accounts/anchor/package.json b/basics/checking-accounts/anchor/package.json index 439798a07..f2011fc2a 100644 --- a/basics/checking-accounts/anchor/package.json +++ b/basics/checking-accounts/anchor/package.json @@ -1,4 +1,5 @@ { + "type": "module", "dependencies": { "@coral-xyz/anchor": "^0.30.0", "@solana/web3.js": "^1.95.2" diff --git a/basics/checking-accounts/anchor/tests/bankrun.test.ts b/basics/checking-accounts/anchor/tests/bankrun.test.ts index 77dc95805..8a6c92f66 100644 --- a/basics/checking-accounts/anchor/tests/bankrun.test.ts +++ b/basics/checking-accounts/anchor/tests/bankrun.test.ts @@ -4,9 +4,9 @@ import { Keypair, SystemProgram, Transaction, sendAndConfirmTransaction } from ' import { PublicKey } from '@solana/web3.js'; import { BankrunProvider } from 'anchor-bankrun'; import { startAnchor } from 'solana-bankrun'; -import type { AnchorProgramExample } from '../target/types/anchor_program_example'; +import type { AnchorProgramExample } from '../target/types/anchor_program_example.ts'; -const IDL = require('../target/idl/anchor_program_example.json'); +import IDL from '../target/idl/anchor_program_example.json' with { type: 'json' }; const PROGRAM_ID = new PublicKey(IDL.address); describe('Bankrun example', async () => { @@ -14,7 +14,7 @@ describe('Bankrun example', async () => { const provider = new BankrunProvider(context); const wallet = provider.wallet as anchor.Wallet; - const program = new anchor.Program(IDL, provider); + const program = new anchor.Program(IDL as AnchorProgramExample, provider); const client = context.banksClient; // We'll create this ahead of time. diff --git a/basics/checking-accounts/anchor/tests/test.ts b/basics/checking-accounts/anchor/tests/test.ts index a9c9dcafb..5d46d9aa3 100644 --- a/basics/checking-accounts/anchor/tests/test.ts +++ b/basics/checking-accounts/anchor/tests/test.ts @@ -1,6 +1,6 @@ import * as anchor from '@coral-xyz/anchor'; import { Keypair, SystemProgram, Transaction, sendAndConfirmTransaction } from '@solana/web3.js'; -import type { AnchorProgramExample } from '../target/types/anchor_program_example'; +import type { AnchorProgramExample } from '../target/types/anchor_program_example.ts'; describe('Anchor example', () => { const provider = anchor.AnchorProvider.env(); diff --git a/basics/checking-accounts/anchor/tsconfig.json b/basics/checking-accounts/anchor/tsconfig.json index cd5d2e3d0..d42e1827a 100644 --- a/basics/checking-accounts/anchor/tsconfig.json +++ b/basics/checking-accounts/anchor/tsconfig.json @@ -3,8 +3,8 @@ "types": ["mocha", "chai"], "typeRoots": ["./node_modules/@types"], "lib": ["es2015"], - "module": "commonjs", + "module": "nodenext", "target": "es6", - "esModuleInterop": true + "resolveJsonModule": true } }