Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renaming files imported with alias/absolute paths does not update the path #59119

Open
simplenotezy opened this issue Jul 2, 2024 · 3 comments
Labels
Needs More Info The issue still hasn't been fully clarified

Comments

@simplenotezy
Copy link

simplenotezy commented Jul 2, 2024

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.90.2
  • OS Version: macOS 14.1.1 (23B81)

Steps to Reproduce:

  1. Create a project with alias imports (e.g. setting up a new Nextjs project and configure to use @/ alias imports)
  2. Create a new typescript file
  3. Import this file, and ensure to import it using your @/ alias
  4. Rename the created typescript file
  5. The error is that the reference in the import is not updated, and now vscode is complaining it cannot find the file

See this short video:

Untitled.mov

tsconfig:

{
  "compilerOptions": {
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "bundler",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "plugins": [
      {
        "name": "next"
      }
    ],
    "baseUrl": "./src",
    "paths": {
      "@/*": [
        "./*"
      ]
    },
  },
  "include": [
    "next-env.d.ts",
    "**/*.ts",
    "**/*.tsx",
    ".next/types/**/*.ts"
  ],
  "exclude": [
    "node_modules"
  ]
}

Possibly related:

@simplenotezy
Copy link
Author

Update:

  • Renaming the src/shared/features/auth/presentation/IsAuthenticated.tsx to src/shared/features/auth/presentation/IsAuthenticated2.tsx file does not update the imports
  • If you rename the folder from src/shared to src/goat-cheese VSCode will update the imports
  • If you rename file src/lib/common/presentation/layouts/AppLayout/AppLayout.tsx to src/lib/common/presentation/layouts/AppLayout/AppLayout2.tsx it will correctly update the aliased imports

Very odd situation. Reproducible on two different machines/setups running vscode.

@mjbvz mjbvz transferred this issue from microsoft/vscode Jul 2, 2024
@mjbvz mjbvz removed their assignment Jul 2, 2024
@andrewbranch andrewbranch added the Needs More Info The issue still hasn't been fully clarified label Jul 5, 2024
@andrewbranch
Copy link
Member

I noticed you invoked the rename via a third-party extension called File Utils. If you rename using only VS Code's built-in functionality, do you still experience the issue?

@JJBocanegra
Copy link

@andrewbranch I can confirm that it happens also using VS Code's built-in functionality to rename

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs More Info The issue still hasn't been fully clarified
Projects
None yet
Development

No branches or pull requests

4 participants