Default typescript app doesn't compile
Hello there :)
Description
When I run the default create-landscape-app command with --typescript and without any code changes, I get this compile error (and a few other errors downstream of it).
src/app.tsx:3:59 - error TS7016: Could not find a declaration file for module '@urbit/api'. '/Users/mischief/my-app/ui/node_modules/@urbit/api/dist/cjs/index.cjs' implicitly has an 'any' type.
Try `npm i --save-dev @types/urbit__api` if it exists or add a new declaration (.d.ts) file containing `declare module '@urbit/api';`
3 import { Charges, ChargeUpdateInitial, scryCharges } from '@urbit/api';
~~~~~~~~~~~~
Steps to Reproduce
npx @urbit/create-landscape-app --typescript
cd my-app/ui
npm i
npm i typescript
npm run build
Also tried using yarn and got the same thing.
Specifications
- npm 9.8.1
- node v18.18.2
- npx 9.8.1
Hi @mischief-codes! I think I see the issue, but I could be wrong.
In the upstream package @urbit/api it defines types in package.json as existing in "dist/index.d.ts", when that doesn't exist — that folder does exist in dist/api/index.d.ts.
It looks like Tlon themselves still use this package, and I'd be curious how they went around the type resolution here. The easiest thing I can advise for now is changing @urbit/api to @urbit/api/dist/api to import those types in both app.tsx and in AppTile.tsx, change skipLibCheck to true in tsconfig.json and finally coerce the mount a little in main.tsx:
const container = document.getElementById('app') as HTMLElement;
I no longer have access to maintain this package, but these are simple changes.
cc @arthyn for relevant advice Tlon-side
@urbit/api I believe was compiled incorrectly in 2.3, you can downgrade to 2.2 to solve your issue I believe. It's actually deprecated at this point which may not be clear in it's docs. We don't have an equivalent for current day Landscape APIs yet, but all the formatting/helper functions should be available in @urbit/aura
I tried downgrading and still hit the resolution issue in my testing. I thought that would work too! Not sure.