cengit / react-native-issue

react-native related issues found when I working on the RN project development
0 stars 0 forks source link

yarn install error: Failed to build definition files. bob build. Error: Failed to build definition files. #3

Open cengit opened 1 year ago

cengit commented 1 year ago

error like this

ℹ Generating type definitions with tsc
../../../../../../node_modules/@types/express-serve-static-core/index.d.ts:102:68 - error TS1110: Type expected.

102 type RemoveTail<S extends string, Tail extends string> = S extends `${infer P}${Tail}` ? P : S;
                                                                       ~~~

../../../../../../node_modules/@types/express-serve-static-core/index.d.ts:102:77 - error TS1005: '}' expected.

102 type RemoveTail<S extends string, Tail extends string> = S extends `${infer P}${Tail}` ? P : S;
                                                                                ~

../../../../../../node_modules/@types/express-serve-static-core/index.d.ts:102:78 - error TS1128: Declaration or statement expected.

102 type RemoveTail<S extends string, Tail extends string> = S extends `${infer P}${Tail}` ? P : S;
                                                                                 ~

../../../../../../node_modules/@types/express-serve-static-core/index.d.ts:102:80 - error TS1005: ';' expected.

102 type RemoveTail<S extends string, Tail extends string> = S extends `${infer P}${Tail}` ? P : S;
                                                                                   ~

../../../../../../node_modules/@types/express-serve-static-core/index.d.ts:104:33 - error TS1005: ';' expected.

104     RemoveTail<RemoveTail<S, `/${string}`>, `-${string}`>,

 -------

../../../../../../node_modules/@types/express-serve-static-core/index.d.ts:1200:33 - error TS1005: ';' expected.

1200      * application (which is a `Function`) as its
                                     ~~~~~~~~

../../../../../../node_modules/@types/express-serve-static-core/index.d.ts:1268:1 - error TS1160: Unterminated template literal.

1268 

Found 127 errors.

✖ Failed to build definition files.
bob build

build files for publishing

Error: Failed to build definition files.
    at build (/Users/cen/Library/Caches/Yarn/v6/.tmp/091f62b39b416fea18d958e1e47fa3bb.48ceed475233cc30f0b9d9f9cc4ad31181860ed6.prepare/node_modules/@react-native-community/bob/lib/targets/typescript.js:112:11)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Object.handler (/Users/cen/Library/Caches/Yarn/v6/.tmp/091f62b39b416fea18d958e1e47fa3bb.48ceed475233cc30f0b9d9f9cc4ad31181860ed6.prepare/node_modules/@react-native-community/bob/lib/cli.js:350:9)
error Command failed with exit code 1.
cengit commented 1 year ago

root cause is: there is lower typescript version dependency in the third party libs.

see this is my project package.json

"dependencies": {
    "@types/express-serve-static-core": "^4.17.33",
    "react": "16.13.1",
    "react-native": "0.63.4",
    "react-native-monorepo-tools": "^1.1.4",
    "typescript": "^4.9.5",
    "yarn-work-space-demo": "ssh://code.pruconnect.net:7999/~xiongbo.cen_prudential.com.cn/yarn-work-space-demo.git",
    "use-low-typescript-version": "ssh://git@github.com:cengit/use-low-typescript-version.git"
  }
"resolutions": {
    "typescript": "^4.9.5" // did not work here
  },
  "overrides": {
    "typescript": "^4.9.5" // did not work here either
  }

use-low-typescript-version project package.json

"devDependencies": {
    "@commitlint/config-conventional": "^8.3.4",
    "@react-native-community/bob": "^0.16.2",
    "@react-native-community/eslint-config": "^2.0.0",
    "@release-it/conventional-changelog": "^1.1.4",
    "@types/jest": "^26.0.0",
    "@types/react": "^16.9.19",
    "@types/react-native": "0.62.13",
    ...
    "typescript": "^3.8.3" // **** see the devil is here ****
  }

how to fix: just change the use-low-typescript-version project package.json "typescript": "^3.8.3" to "typescript": "^4.9.5"

fixing:

"devDependencies": {
    "@commitlint/config-conventional": "^8.3.4",
    "@react-native-community/bob": "^0.16.2",
    "@react-native-community/eslint-config": "^2.0.0",
    "@release-it/conventional-changelog": "^1.1.4",
    "@types/jest": "^26.0.0",
    "@types/react": "^16.9.19",
    "@types/react-native": "0.62.13",
    ...
    "typescript": "^4.9.5" // **** update the version fix the issue ****
  }
cengit commented 1 year ago

how to locate the lib which having the lower version of typescript?

see the error message:

Error: Failed to build definition files.
    at build (/Users/cen/Library/Caches/Yarn/v6/.tmp/091f62b39b416fea18d958e1e47fa3bb.48ceed475233cc30f0b9d9f9cc4ad31181860ed6.prepare/node_modules/@react-native-community/bob/lib/targets/typescript.js:112:11)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

go to node_modules path in above error message: /Users/cen/Library/Caches/Yarn/v6/.tmp/091f62b39b416fea18d958e1e47fa3bb.48ceed475233cc30f0b9d9f9cc4ad31181860ed6.prepare/node_modules/ and then open the typescript/package.json under this dir, it is:

/Users/cen/Library/Caches/Yarn/v6/.tmp/091f62b39b416fea18d958e1e47fa3bb.48ceed475233cc30f0b9d9f9cc4ad31181860ed6.prepare/node_modules/typescript/package.json

this is the typescript/package.json:

{
    "name": "typescript",
    "author": "Microsoft Corp.",
    "homepage": "https://www.typescriptlang.org/",
    "version": "3.9.7", // *** devil here ****
    "license": "Apache-2.0",
    "description": "TypeScript is a language for application scale JavaScript development",
    "keywords": [
        "TypeScript",
        "Microsoft",
        "compiler",
        "language",
        "javascript"
    ],
    "bugs": {
        "url": "https://github.com/Microsoft/TypeScript/issues"
    },
    "repository": {
        "type": "git",
        "url": "https://github.com/Microsoft/TypeScript.git"
    }

it only took me A-WHOLE-SINGLE-DAY to find out this shit....