huan / sidecar

Easily hook/call binary functions using ES6 class with TypeScript annotation (Powered by Frida)
https://npmjs.com/package/sidecar
Apache License 2.0
47 stars 7 forks source link

error TS2345: Argument of type 'typeof INIT_SYMBOL' is not assignable to parameter of type 'string | number'. #18

Closed huan closed 3 years ago

huan commented 3 years ago

The Problem

We got a strange error in our CI as the following messages:

Error: src/sidecar-body/operations.spec.ts(32,52): error TS2345: Argument of type 'typeof INIT_SYMBOL' is not assignable to parameter of type 'string | number'.

This is caused that the TypeScript version is below 4.4.

However, we are clearly depending on version 4.4:

  npm ls typescript
  ./node_modules/.bin/tsc --version
  ls -l node_modules/.bin/tsc
  cat node_modules/typescript/package.json
  ./scripts/npm-pack-testing.sh
  shell: /usr/bin/bash -e {0}
sidecar@0.15.15 /home/runner/work/sidecar/sidecar
├─┬ @chatie/eslint-config@0.13.5
│ ├─┬ @typescript-eslint/eslint-plugin-tslint@4.30.0
│ │ └── typescript@4.4.2 deduped
│ ├─┬ @typescript-eslint/eslint-plugin@4.30.0
│ │ └─┬ tsutils@3.21.0
│ │   └── typescript@4.4.2 deduped
│ ├─┬ tslint-config-standard@9.0.0
│ │ └─┬ tslint-eslint-rules@5.4.0
│ │   ├─┬ tslint@5.20.1
│ │   │ ├─┬ tsutils@2.29.0
│ │   │ │ └── typescript@3.9.10 deduped
│ │   │ └── typescript@3.9.10 deduped
│ │   └── typescript@3.9.10
│ └─┬ tslint@6.1.3
│   ├─┬ tsutils@2.29.0
│   │ └── typescript@4.4.2 deduped
│   └── typescript@4.4.2 deduped
├─┬ @chatie/tsconfig@0.19.6
│ ├─┬ ts-node@10.2.1
│ │ └── typescript@4.4.2 deduped
│ └── typescript@4.4.2 deduped
├─┬ frida-compile@10.2.4
│ ├─┬ tsify@5.0.4
│ │ └── typescript@4.4.2 deduped
│ └── typescript@4.4.2 deduped
├─┬ tstest@0.5.16
│ └─┬ tap@15.0.9
│   └── typescript@4.4.2 deduped
└── typescript@4.4.2

The Reason

At the same time, we got a TypeScript 4.3:

$ npm ls typescript
Version 4.3.5

And we found that it is linked by @tsc/typescript:

$ ls -l node_modules/.bin/tsc
lrwxrwxrwx 1 runner docker 37 Sep  4 20:26 node_modules/.bin/tsc -> ../@tsd/typescript/typescript/bin/tsc

It clearly shows that the tsc has been overwritten by the @tsd/typescript module

The Solution

  1. Remove the tsd package
  2. Use Testing static types in TypeScript for type unit testing

Related issues