Giter Club home page Giter Club logo

Comments (5)

pmneo avatar pmneo commented on July 29, 2024

This should be part of a refactoring extension ... so i am sorry, no ;)

from ts-importer.

frederikschubert avatar frederikschubert commented on July 29, 2024

I understand. But would it be possible to create a command that adjusts the import paths for the imports that are selected?

Currently, when I move a file, I have to delete all relative imports, go trough each imported Symbol and add the import back via the quickfix functionality of this plugin.

Say I have these imports.

import * as s from "some-npm-module";

import { foo } from "../foo/foo";
import { bar } from "../bar/bar";
...

Now I move the containing file one directory down. The relative imports now contain invalid paths.

What I want now is to select the lines containing the now invalid imports and execute a vscode command that looks at the imported symbols in the selection, resolves their location and updates their paths.

from ts-importer.

frederikschubert avatar frederikschubert commented on July 29, 2024

I had a further look at the code and I think this could be accomplished by matching this regex against the selected text, lookup the matched symbols against the ImportIndexand then use the Importer to rewrite the import statement.
I can also work on a PR but have to make myself familiar with the vscode extension API.

from ts-importer.

pmneo avatar pmneo commented on July 29, 2024

First you have to build a reverse index and you have to resolve the relative import to a absolute path.
You must implement a import remove or replace ...

Feel free to create a PR ;)

from ts-importer.

frederikschubert avatar frederikschubert commented on July 29, 2024

Great!! I will try my luck :)

from ts-importer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.