1

See simple example search for THREE.Screen call from index.html which is defined in ThreeJS_aux.js.

enter image description here enter image description here

My javascript project is here https://github.com/ProkopHapala/LearnWeb

Prokop Hapala
  • 2,424
  • 2
  • 30
  • 59
  • there is no solution available for this concern yet sadly. btw no python extension installed in my extensions as many people suggest that might be reason of problem. – CodeWorld Mar 15 '22 at 04:50

2 Answers2

2

did you tried adding a tsconfig.json file and set allowJs: true checkJs: true ? This way vscode will start a tsserver and you will have all its features / refactors. Remember that JavaScript IS TypeScript so you don't have to use anything strange just good old JavaScript. Typescript compiler supports that refactor and many others (or you could develop / install third party plugins with more). And if you want to start using Types,you could still do that using plain old JavaScript with jsdocs. My two cents. More info: https://www.typescriptlang.org/docs/handbook/migrating-from-javascript.html

cancerbero
  • 6,799
  • 1
  • 32
  • 24
1

From the way you have your code laid out I would assume that you're going with a walkthrough or some kind of tutorial. Meaning, instead of splitting your JS into a separate file you're embedding it within the actual script tag in the HTML. Not a common practice is all unless someone is trying to maximize the development area, like a tutorial/walkthrough.

I think what you're really looking for here is design patterns. There is really no short answer to give you. There is also no single way to accomplish this. These design patterns are what puts JS together in a more readable fashion.

Try reading through this online book on design patterns Learning JS Design Patterns

This is a quick summary of your common design patterns AMD, commonJS, and Require. I recommend going through the book to get a more in depth understanding. Relation between CommonJS, AMD and RequireJS?

Dylan Wright
  • 1,118
  • 12
  • 19
  • I hope this helps, I looked at your repo and you seem to be invested in learning JS which is why I took the path of the book. If you can understand this it will make working with JS a lot easier. Good luck to you. – Dylan Wright Jun 15 '18 at 18:47
  • Thanks, I'm perhaps missing something basic. I don't get how web page can load `*.js` file if it is not included as ` – Prokop Hapala Jun 15 '18 at 19:38
  • I also don't get the connection? Does this AMD, commonJS, and Require help vscode `got to definition` to work better? – Prokop Hapala Jun 15 '18 at 19:40
  • Answer 1, the script tag still loads the JS, i.e. instead of embedding all your JS. As far as connecting your files has nothing really to do with VS Code you need the mapping to be defined in order for VS Code to work properly. This is where the design patterns (AMD/Common) come in. – Dylan Wright Jun 15 '18 at 19:46