Skip to content

Conversation

@choupetten
Copy link
Collaborator

@choupetten choupetten commented Jan 8, 2026

Fixes critical build issues preventing library installation and use by consumers.

Issues Fixed

  • TypeScript strict mode errors in PAPI-generated descriptors
  • Missing package exports preventing imports from GitHub/local installs

**Issue**: Build failed with TypeScript strict mode errors in generated code

Error 1 (postinstall):
  .papi/descriptors/src/index.ts(43,18): error TS7053:
  Element implicitly has an 'any' type

Error 2 (build:core):
  papi-whitelist.ts(1,83): error TS2307:
  Cannot find module '@polkadot-api/descriptors'

**Root Cause**:
The papi tool generates Polkadot API descriptors from chain metadata during
postinstall. The generated code doesn't pass strict TypeScript checks, causing
the build to fail before the descriptors module is created.

**Fix**:
Added 'skipLibCheck: true' to packages/core/tsconfig.json to skip type checking
of declaration files (standard practice for third-party/generated code).

Also excluded .papi directory from compilation to avoid processing generated files.

**Result**:
✅ pnpm install completes successfully
✅ papi generates descriptors without TypeScript errors
✅ pnpm build:package builds both core and client packages
✅ dist/ folders created with all exports

**Testing**:
cd ~/polkadot-sufficient-assets
pnpm install          # ✅ postinstall generates descriptors
pnpm build:package    # ✅ builds core + client successfully

**Files Changed**:
- packages/core/tsconfig.json: Added skipLibCheck + exclude .papi
- packages/core/.papi/descriptors/package.json: Updated by papi
- pnpm-lock.yaml: Updated dependencies
**Issue**: When installed from GitHub/local path, consumers cannot import
from 'polkadot-sufficient-assets' because the root package.json lacks exports.

**Root Cause**:
The library is a pnpm monorepo where the actual package is in packages/client.
When npm installs from GitHub/local, it symlinks to the monorepo root, but the
root package.json had no main/module/types/exports fields pointing to the built
client package.

**Fix**:
Added to root package.json:
- main: points to packages/client/dist/index.js
- module: points to packages/client/dist/index.mjs
- types: points to packages/client/dist/index.d.ts
- exports: maps all imports to packages/client/dist/*
- files: specifies dist folders to include in package
- peerDependencies: react, react-dom (matches client package)

**Result**:
✅ Consumers can now import from 'polkadot-sufficient-assets'
✅ Jest can resolve the module in tests
✅ TypeScript can find type definitions
✅ Both ESM and CJS imports work

**Testing**:
cd ~/prmx/frontend
npm install ~/polkadot-sufficient-assets
npm run test:sufficient-assets  # Should now find the module
@choupetten choupetten changed the title Fix/build errors typescript papi Fix Build Errors - TypeScript and Package Exports Jan 8, 2026
Copy link
Collaborator

@golgocat golgocat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@golgocat golgocat merged commit cf2a59b into main Jan 8, 2026
1 check passed
@choupetten choupetten deleted the fix/build-errors-typescript-papi branch January 8, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants