This guide will walk you through the steps to reproduce the TypeScript compilation error when using the viem library.
Before starting, ensure that you have Node.js and npm installed on your system.
-
Create a new directory and navigate into it:
mkdir VIEM_TEST cd VIEM_TEST
-
Initialize a new npm project:
npm init -y
-
Install the viem library:
npm install viem@2.7.11
-
Create a TypeScript file named
index.ts
with the following content:// index.ts import { createPublicClient } from "viem/_types/clients/createPublicClient"; import { createWalletClient } from "viem/_types/clients/createWalletClient"; function greet(name: string): string { console.log( createPublicClient); console.log( createWalletClient); return `Hello, ${name}!`; } const personName: string = "John"; console.log(greet(personName));
-
Create a
tsconfig.json
file with the following configuration:{ "compilerOptions": { "forceConsistentCasingInFileNames": true, "newLine": "lf", "noFallthroughCasesInSwitch": true, "noImplicitReturns": true, "noUncheckedIndexedAccess": true, "noUnusedParameters": true, "strict": true, "target": "ES2019", "moduleResolution": "node", "esModuleInterop": true }, "include": [ "src/**/*.ts" ] }
-
Run the TypeScript compiler:
tsc --build
You should see the following error:
errors.txt