xojs/xo

xo --fix: Multiple fails with TypeError: Cannot read properties of undefined (reading 'get')

Closed this issue · 2 comments

When trying to run xo --fix on my Fastify project the CLI crashes at multiple point with the error

TypeError: Cannot read properties of undefined (reading 'get')
Occurred while linting /Users/sinedied/projects/moaw-search/packages/search-api-node/src/plugins/cache.ts:9
Rule: "@typescript-eslint/no-unsafe-call"
    at getTypeAliasInstantiation (/Users/sinedied/projects/moaw-search/node_modules/typescript/lib/typescript.js:57409:48)
    at createMarkerType (/Users/sinedied/projects/moaw-search/node_modules/typescript/lib/typescript.js:64258:62)
    at getVariancesWorker (/Users/sinedied/projects/moaw-search/node_modules/typescript/lib/typescript.js:64225:35)
    at getVariances (/Users/sinedied/projects/moaw-search/node_modules/typescript/lib/typescript.js:64200:130)
    at inferFromTypes (/Users/sinedied/projects/moaw-search/node_modules/typescript/lib/typescript.js:65567:86)
    at inferFromContravariantTypes (/Users/sinedied/projects/moaw-search/node_modules/typescript/lib/typescript.js:65684:9)
    at inferFromContravariantTypesIfStrictFunctionTypes (/Users/sinedied/projects/moaw-search/node_modules/typescript/lib/typescript.js:65689:11)
    at applyToParameterTypes (/Users/sinedied/projects/moaw-search/node_modules/typescript/lib/typescript.js:65054:9)
    at inferFromSignature (/Users/sinedied/projects/moaw-search/node_modules/typescript/lib/typescript.js:65996:11)
    at inferFromSignatures (/Users/sinedied/projects/moaw-search/node_modules/typescript/lib/typescript.js:65988:11)

Even if I turn off that specific rule, if fails with the same error for another rule.

Using xo@0.55.0.

Steps to reproduce

I created a minimal repo to reproduce the issue here: https://github.com/sinedied/xo-fix-issue

git clone https://github.com/sinedied/xo-fix-issue
npm install
npx xo --fix

Seems like what it doesn't like is the fact that is the FastifyInstance interface is augmented multiple times: https://github.com/sinedied/xo-fix-issue/blob/main/src/plugins/cache.ts#L12-L16

There's no issue to build the project though.

You need to open this issue on the @typescript-eslint package.