Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Autocomplete NS #16

Open
sbliven opened this issue Feb 17, 2022 · 5 comments
Open

Autocomplete NS #16

sbliven opened this issue Feb 17, 2022 · 5 comments

Comments

@sbliven
Copy link

sbliven commented Feb 17, 2022

Is there a way to add the NS type to vscode so that autocompletion works like it does in the game? The ideal would be if this were done automatically by the extension.

@sbliven
Copy link
Author

sbliven commented Feb 17, 2022

I'm aware of the workaround here, which consists of

This workaround isn't great because

  1. It's not documented well or easy to use
  2. It clashes with the NS type used in the in-game editor, so tab completion only works in one place at a time.

@OxSon
Copy link

OxSon commented Jun 29, 2022

you can also do import { NS } from "../bitburner/src/ScriptEditor/NetscriptDefinitions";, changing the import path to whatever's correct for your chosen setup. In the example, my bitburner repo has the whole bitburner repo cloned as a submodule, but there are other ways to do it besides what you've mentioned, I think.

@wallind
Copy link

wallind commented Jun 29, 2022

here's my Typescript implementation if it helps you brother https://github.com/wallind/bitburner-scripts

@DanielWeiner
Copy link

A workaround I've used:
Step 1: Add NetscriptDefinitions.d.ts to the project.
Step 2: Replace export directives in that file with declare directives in NetscriptDefinitions.d.ts.
Step 3: Include /// <reference path="NetscriptDefinitions.d.ts" /> at the top of your js files.

Then you can use the NS type as you would in the in-game editor.

@trepudox
Copy link

the solution proposed by @DanielWeiner works like a charm! saved my day

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants