vuejs / language-tools

⚡ High-performance Vue language tooling based-on Volar.js
https://marketplace.visualstudio.com/items?itemName=Vue.volar
MIT License
5.79k stars 390 forks source link

RangeError: Maximum call stack size exceeded (vue-tsc) #4635

Closed mityaua closed 1 month ago

mityaua commented 2 months ago

Vue - Official extension or vue-tsc version

2.0.29

VSCode version

1.91.1

Vue version

3.4.35

TypeScript version

5.5.4

System Info

System:
    OS: Windows 11 10.0.22000
    CPU: (4) x64 Intel(R) Core(TM) i5-4200M CPU @ 2.50GHz
    Memory: 6.57 GB / 15.91 GB
  Binaries:
    Node: 20.16.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 10.8.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (127.0.2651.74)
    Internet Explorer: 11.0.22000.120

Steps to reproduce

Add "target": "ESNext", "lib": ["ESNext", "DOM"] to tsconfig.app.json: and use anywhere .replaceAll() method

{
    "extends": "@vue/tsconfig/tsconfig.dom.json",
    "include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
    "exclude": ["src/**/__tests__/*"],
    "compilerOptions": {
        "composite": true,
        "baseUrl": ".",
        "paths": {
            "@/*": ["./src/*"]
        },
        "noImplicitAny": false,
        "target": "ESNext",
        "lib": ["ESNext", "DOM"]
    }
}

Rest of the TS configuration:

tsconfig.json:

{
    "files": [],
    "references": [
        {
            "path": "./tsconfig.node.json"
        },
        {
            "path": "./tsconfig.app.json"
        },
        {
            "path": "./tsconfig.vitest.json"
        }
    ]
}

tsconfig.node.json

{
    "extends": "@tsconfig/node20/tsconfig.json",
    "include": ["vite.config.*", "vitest.config.*", "cypress.config.*", "nightwatch.conf.*", "playwright.config.*"],
    "compilerOptions": {
        "composite": true,
        "module": "ESNext",
        "moduleResolution": "Bundler",
        "types": ["node"]
    }
}

tsconfig.vitest.json

{
    "extends": "./tsconfig.app.json",
    "exclude": [],
    "compilerOptions": {
        "composite": true,
        "types": ["node", "jsdom"]
    }
}

What is expected?

image

What is actually happening?

npm run type-check (vue-tsc --noEmit -p tsconfig.vitest.json --composite false) and also app build fails with:

...\node_modules\vue-tsc\index.js:39
            throw err;
            ^
RangeError: Maximum call stack size exceeded
    at getApparentTypeOfContextualType ...\node_modules\typescript\lib\tsc.js:71160:43)
    at getContextualTypeForObjectLiteralElement ...\node_modules\typescript\lib\tsc.js:70953:18)
    at getContextualType ...\node_modules\typescript\lib\tsc.js:71242:16)
    at pushCachedContextualType ...\node_modules\typescript\lib\tsc.js:71291:7)
    at checkObjectLiteral ...\node_modules\typescript\lib\tsc.js:71822:5)
    at checkExpressionWorker ...\node_modules\typescript\lib\tsc.js:78504:16)
    at checkExpression ...\node_modules\typescript\lib\tsc.js:78426:32)
    at checkExpressionForMutableLocation ...\node_modules\typescript\lib\tsc.js:78185:18)
    at checkPropertyAssignment ...\node_modules\typescript\lib\tsc.js:78201:12)
    at checkObjectLiteral ...\node_modules\typescript\lib\tsc.js:71849:71)

Node.js v20.16.0

Link to minimal reproduction

No response

Any additional comments?

BUT sometimes it happens without that target and lib options. I open the project, run npm run type-check, and see RangeError. Then I run type-check again and there are no errors. Maybe this problem is related to TS version https://github.com/microsoft/TypeScript/issues?q=is%3Aissue+Maximum+call+stack+size+exceeded+is%3Aopen cuz seems TS 5.4.5 works much better.

Screenshot 2024-08-01 123812

Unfortunately my repo is private.

{
    "dependencies": {
        "@babel/runtime": "^7.25.0",
        "@microsoft/signalr": "^8.0.7",
        "@quasar/extras": "^1.16.12",
        "axios": "^1.6.8",
        "http-server": "^14.1.1",
        "qrcode.vue": "^3.4.1",
        "quasar": "^2.16.6",
        "vue": "^3.4.35",
        "vue-avatar-cropper": "^6.1.1",
        "vue-draggable-next": "^2.2.1",
        "vue-gtag": "^2.0.1",
        "vue-i18n": "^9.13.1",
        "vue-router": "^4.4.2",
        "vuex": "^4.1.0"
    },
    "devDependencies": {
        "@intlify/unplugin-vue-i18n": "^4.0.0",
        "@quasar/quasar-app-extension-testing-unit-vitest": "^1.0.0",
        "@quasar/vite-plugin": "^1.7.0",
        "@rushstack/eslint-patch": "^1.10.4",
        "@tsconfig/node20": "^20.1.4",
        "@types/jsdom": "^21.1.7",
        "@types/node": "^22.0.2",
        "@vitejs/plugin-vue": "^5.1.1",
        "@vitest/coverage-v8": "^2.0.5",
        "@vue/eslint-config-prettier": "^9.0.0",
        "@vue/eslint-config-typescript": "^13.0.0",
        "@vue/test-utils": "^2.4.6",
        "@vue/tsconfig": "^0.5.1",
        "eslint": "^8.57.0",
        "eslint-plugin-vue": "^9.27.0",
        "husky": "^9.1.4",
        "jsdom": "^24.1.1",
        "lint-staged": "^15.2.7",
        "npm-run-all2": "^6.2.2",
        "prettier": "^3.3.3",
        "sass": "1.77.8",
        "typescript": "~5.5.4",
        "vite": "^5.3.5",
        "vitest": "^2.0.5",
        "vue-cli-plugin-i18n": "~2.3.2",
        "vue-cli-plugin-quasar": "~5.1.0",
        "vue-tsc": "^2.0.29"
    },
    "overrides": {
        "vitest": "^2.0.5"
    }
}

Maybe related to https://github.com/vuejs/language-tools/issues/2689

davidmatter commented 1 month ago

Please try to execute your type-checks using -p tsconfig.app.json. Does that help?

mityaua commented 1 month ago

Please try to execute your type-checks using -p tsconfig.app.json. Does that help?

You are right. With "typescript": "~5.5.4" and tsconfig.app everything is fine. But also with "typescript": "~5.4.5" and tsconfig.vitest all checks are fine too.

image
davidmatter commented 1 month ago

Check pnpm create vue@latest for a well-defined tsconfig setup.