oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.27k stars 2.77k forks source link

Installing outdated non-`latest` version of package #1993

Closed chebread closed 1 year ago

chebread commented 1 year ago

What version of Bun is running?

0.5.5

What platform is your computer?

Darwin 22.3.0 arm64 arm

Bug

I am developing a React project based on Typescript using Bun. I switched from JavaScript-based to Typescript. I imported useState, but a Typescript error occurs in VSCode. I don't get any errors even when I connect from localhost. It's just VSCode's React Import Typescript error.

I have this bug.

스크린샷 2023-02-06 오후 11 24 22

My environment setup is like this:

tsconfig.json

{
  "compilerOptions": {
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "allowSyntheticDefaultImports": true,
    "lib": ["DOM", "DOM.Iterable", "ESNext"],
    "module": "ESNext",
    "target": "ESNext",
    "moduleResolution": "node",
    "baseUrl": "app",
    "paths": {
      "~/*": ["./app/*"]
    },
    "jsx": "react-jsxdev",
    "types": ["bun-types"]
  },
  "include": ["app", "**/*.ts", "**/*.tsx", "app/react-app-env.d.ts"]
}

package.json

{
  "scripts": {
    "dev": "bun dev --hot --port=8080",
    "build": "react-scripts build"
  },
  "name": "thisishaneum",
  "version": "0.1.61",
  "dependencies": {
    "@types/node": "^14.18.36",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-helmet-async": "^1.3.0",
    "react-router-dom": "^6.8.0",
    "styled-components": "^5.3.6",
    "web-vitals": "^3.1.1"
  },
  "eslintConfig": {
    "extends": [
      "react-app"
    ]
  },
  "devDependencies": {
    "@types/react": "^15.7.12",
    "@types/react-dom": "^18.0.10",
    "@types/react-router-dom": "^5.3.3",
    "@types/styled-components": "^5.1.26",
    "bun-types": "^0.5.0",
    "react-refresh": "0.10.0",
    "react-scripts": "^5.0.1",
    "typescript": "latest"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Does anyone know about this bug?

colinhacks commented 1 year ago

I'll look into this. Different libraries provide various global types, some of which conflict with bun-types in unexpected ways. It would be more useful to paste your package.json in a codeblock instead of screenshots, ffr.

colinhacks commented 1 year ago

Seems there's been a regression in how we resolve npm versions. We're accidentally installing an outdated version of @types/react.

For now, running bun add @types/react@latest will fix the issue.

chebread commented 1 year ago

@colinhacks, React import error fixed. However, this error has not been resolved yet. The error seems to be that tsconfig can't read lib or bun-types doesn't work well as mentioned above. It is right?

스크린샷 2023-02-08 오후 2 00 53