GithubHelp home page GithubHelp logo

Comments (11)

cybertim avatar cybertim commented on September 15, 2024

It should work with different directories relevant to the current file within the same workspace, for me, at least :-)
import {Test} from '../../Test' for instance if it is in a 'lower' directory or import {Test} from './test/Test' if it is higher up.
Do you have an example structure of the workspace in which it is not working?

from vscode-gengetset.

Aranir avatar Aranir commented on September 15, 2024

I created quickly a repo where it fails:
link to github repo

As can be seen if the import command is used it doesn't resolve the directory in a correct way.

This might have something to do with me working on a Mac.

Let me know if you need further input

from vscode-gengetset.

cybertim avatar cybertim commented on September 15, 2024

If I import in the app.ts the non-wildcard imports resolve like:

import {router} from './routes/index';
import {user} from './routes/users';
import {Simple} from './commonsimplenesteddeep/Simple';

Basically the first two are correct (one deep is working fine) but deeper has a bug which is simple to fix (will update the extension probably today).

But based on your first comment, importing should not resolve paths at all and always use ./?

from vscode-gengetset.

Aranir avatar Aranir commented on September 15, 2024

Yes, I don't know if the two problems are linked, my real project is a bit more complex and uses webpack.

Not sure if that might be a cause of the issue.

from vscode-gengetset.

cybertim avatar cybertim commented on September 15, 2024

Is it possible to make or alter a project so it has the same issue? So I can fix all the problems at once :-)

Also, when you add an 'un'-imported but exported item you get intellisense completion.
If you do this for an item that has an incomplete import line you can see the path it lists.
If this path is higher or lower it should create the import-line accordingly. If it is the same, the path is indeed ./, this is one way to see if it is related to the project/webpack.

from vscode-gengetset.

cybertim avatar cybertim commented on September 15, 2024

Tonight for some reason I suddenly realised that there is a bug in the way I process paths. If the files are in the same path-depth the extension will think they are in the same directory.
This is probably what is happening:
/path/to/first/file and /path/to/second/file
should resolve toimport {Test} from '../second/file' but this will resolve to './file'

I'm going to re-implement the 'path' system in a whole to solve this.

from vscode-gengetset.

Aranir avatar Aranir commented on September 15, 2024

I nearly have finished working on prototype where I used the path library of node for the path resolution.

Would it be ok if I push it on a separate branch and you can inspect it?

from vscode-gengetset.

cybertim avatar cybertim commented on September 15, 2024

Nice, would ike to take a look at it, I was also working on a (custom) different approach, since I was not sure if it's possible to include node libraries other than the vscode library.

BTW you can just push it to the main, since the real release is done through the vscode marketplace.

from vscode-gengetset.

Aranir avatar Aranir commented on September 15, 2024

I couldn't push to the main (access rights), but I forked your repo and pushed on the fork.

Please have a look and let me know what you think.

from vscode-gengetset.

cybertim avatar cybertim commented on September 15, 2024

Thanks for the update. I merged it and fixed an issue when matching import lines, now it seems to work on all path structures I can think of.

I thought the path lib was a third party thing, but it's integrated in node, I should have done this from the beginning :-) this will prevent lots of other weird things in the future.

I will push the new version to the market later this day.

from vscode-gengetset.

Aranir avatar Aranir commented on September 15, 2024

Great, thank you for accepting the pull request.

So this should be resolved now :)

from vscode-gengetset.

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.