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

FIX: import resolution in code editor #1661

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

lucebac
Copy link
Contributor

@lucebac lucebac commented Sep 21, 2024

After switching to the dev build to be able to use Typescript, I noticed that import resolution fails most of the time. Not always, though. This is what it looks like:
image

As you can see in the screenshot, it doesn't matter whether or not a file extension is provided. Additionally, I noticed that if an imported file is opened before the 'importee' file, the import resolution does seem to work fine. Unfortunately, I've not come around with why this happens and what the underlying problem is. I believe it's related to the virtual filesystem which Bitburner implements and that monaco doesn't know how to find source files automatically in there.

As a workaround, I opted to implement a callback which loads all imported files into the typescript worker in the background whenever a model changes. The callback does not reload scripts which are already open, so dirty files which are currently open will not be overwritten.

With the fix in place, import resolution and type annotations for imported types/functions now works correctly:
image
image

Since I did not find any callback where we could just load imports
on-demand, I opted for just loading all scripts from the server where
a given script was opened from command line. This does not include
scripts which are already open, only files which are not yet opened
will be loaded.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant