XeroAPI / xero-node-oauth2-app

NodeJS app for demonstrating the xero-node v4 SDK
MIT License
38 stars 43 forks source link

TypeScript errors on fresh install #64

Closed larrybotha closed 3 years ago

larrybotha commented 3 years ago

Not sure how this is happening on my machine when there's active development on the project, but I'm getting errors for everything referencing properties on req.session:

src/app.ts:XXXX:XX - error TS2339: Property 'activeTenant' does not exist on type 'Session & Partial<SessionData>'.

5109           req.session.activeTenant.tenantId,

Node version: 12.12.0 Cloned at: https://github.com/XeroAPI/xero-node-oauth2-app/commit/7fc4517566fc6c41a88cbb89467d6f8b0963a51b

Workaround

Add an ambient declaration for express and set ts-node to read declarations:

// src/typings/express.d.ts
import 'express'

declare module 'express' {
    export interface Request {
        session: Record<any, any>
    }
}
// tsconfig.json
{
 //...
  "ts-node": {
    "files": true
  }
}
RettBehrens commented 3 years ago

Hey @larrybotha this looks like a probable dependency issue with either express and/or request. Could you link or post your package lock file of your cloned repo? On first attempts we could not replicate - have you tried deleting node modules and doing a fresh install?

larrybotha commented 3 years ago

Hey @RettBehrens,

Here's my package lock: https://file.io/2hpFWSaWnGvw

This was after a fresh clone / install - I had to rimraf node_modules and package-lock.json a couple times before npm install would complete.

Thanks!

EDIT: I see file.io will delete the file after the first download... and now my computer's died, so I'll upload my package-lock in the morning to somewhere that'll persist it.

larrybotha commented 3 years ago

@RettBehrens here's my package-lock.json: https://anonymousfiles.io/ycivEHxY/ (6m expiry)

Apologies for the delay!

RettBehrens commented 3 years ago

@larrybotha this might have been caused by my mistake - in your package.lock there's a reference to xero-node as a local tgz file on my computer. This has been corrected so fresh installs won't have this problem again. For clones that occured during the small window of time with the faulty reference, delete node modules -> npm install -> npm update xero-node will ensure it's pointing to the latest on npmjs. Apologies for any inconvenience. Please reopen if this issue is experienced again for developers without the faulty reference.

larrybotha commented 3 years ago

@RettBehrens confirmed - the latest release works without issue. Thanks!