Vscode: Imports are updated for all my files with the wrong path

Created on 22 Jun 2018  路  14Comments  路  Source: microsoft/vscode


Since yesterday my vscode is trying to hard to update my imports but it ends up failing and puts a a path to a typescript cache.

I'll be glad to help provide useful information but the behavior seems quite random. It happened to me 3 times yesterday. It even gos as far to update require from my webpack files...

capture d ecran 2018-06-22 a 07 26 29

I did not change these 173 files.. only one or 2..

capture d ecran 2018-06-22 a 07 30 00

I also see a bunch of insider helpers running.. there might be a rogue one in there that does nasty stuff in the background.

capture d ecran 2018-06-22 a 07 34 38

Even though it should not try to update imports on file I haven't touched and certainly not on npm dependencies.

  • VSCode Version: Version 1.25.0-insider (1.25.0-insider) c5c7d43b65bcbbb3851fbd972fad077631c707e3
  • OS Version: OSX 10.13.4

Steps to Reproduce:
The first time I did.

  1. Open vscode play with files
  2. git pull from the command line
  3. All pulled files imports a rewritten with a path like this import React, { PureComponent } from '../../../../../../../Library/Caches/typescript/2.9/node_modules/@types/react';


Does this issue occur when all extensions are disabled?: Yes/No
It does not happen enough to be able to tell (enough is pretty relative here as 3 times last day)

bug javascript

Most helpful comment

Yeah, this just happened. Updated all my React imports everywhere in my project to

import React from "../../../../Library/Caches/typescript/2.9/node_modules/@types/react/../../Library/Caches/typescript/2.9/node_modules/@types/react";

And my lodash import to

import _ from "../../../../../Library/Caches/typescript/2.9/node_modules/@types/lodash../../../Library/Caches/typescript/2.9/node_modules/@types/lodash";

Had to manually go through and revert the changes. Was a super pain.

All 14 comments

It happened again after a complete new install no plugins just by renaming a file on my project, it did rename all my imports in the project with "'../../../../../../../Library/Caches/typescript/2.9/node_modules/@types/*"

I disabled auto import renaming for now.

Duplicate of https://github.com/Microsoft/TypeScript/issues/24914

Will add workaround to prevent this on the VS Code side

@mjbvz do you have a good set of verification steps?

This is happening for me since updateImportsOnFileMove with latest public release.

@JacksonKearl
Here is the closest thing to a repo which I know will cause import express from 'express' to become from '../../../../Library/Caches/typescript/2.9/node_modules/@types/express' when you move "http-server" in and out of "modules/server/lib" affecting "types.d.ts" and others under "modules/server".

sample-workspace-v0.0.0.zip

Keeps happening to me as well, horrible! I'll figure out how to downgrade.

@mjbvz is this expected?

Same behaviour since updating to 1.25.0 in macOS 10.12.6

This is the problem I have encountered.

tsconfig.json

{
    "compilerOptions": {
        "rootDir": ".",
        "outDir": "./dist",
        "target": "esnext",
        "module": "esnext",
        "moduleResolution": "node",
        "baseUrl": ".",
        "paths": {
            "src/*": ["./src/*"]
        },
        "sourceMap": true,
        "jsx": "preserve",
        "experimentalDecorators": true,
        "strict": true,
        "suppressImplicitAnyIndexErrors": true,
        "types": [],
    },
    "file": [
        "./node_modules/vue-router/types/vue.d.ts",
        "./node_modules/vuex/types/vue.d.ts",
    ],
    "include": [
        "./src/**/*",
    ],
}

image
image

I modified this file and it has nothing to do with them.
.\src\script\notify.ts

Duplicate of Microsoft/TypeScript#24914

Let me know if you see this in VSCode insiders when using TS 3.0

@mjbvz should we add another workaround/do we know why the previous one isn't catching these cases?

yeah this is making me crazy... how do we fix it?

Yeah, this just happened. Updated all my React imports everywhere in my project to

import React from "../../../../Library/Caches/typescript/2.9/node_modules/@types/react/../../Library/Caches/typescript/2.9/node_modules/@types/react";

And my lodash import to

import _ from "../../../../../Library/Caches/typescript/2.9/node_modules/@types/lodash../../../Library/Caches/typescript/2.9/node_modules/@types/lodash";

Had to manually go through and revert the changes. Was a super pain.

Seeing the same issue (I'm not even using typescript. (other than some obvious implicit thing with VSCode)) . Every few minutes, dozens of files (sometimes 100+) show up as opened and changed in VSCode. Most (oddly, not all) have this breaking change on the import statements.

Very frustrating, VSCode just about unusable with this behavior.

This should be fixed in VS Code insiders. You can also upgrade your workspace to use TypeScript 3.0 (or TS 2.9.1) by following these instructions

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sirius1024 picture sirius1024  路  3Comments

biij5698 picture biij5698  路  3Comments

villiv picture villiv  路  3Comments

DovydasNavickas picture DovydasNavickas  路  3Comments

shanalikhan picture shanalikhan  路  3Comments