79642240

Date: 2025-05-28 12:49:30
Score: 1
Natty:
Report link

The problem was that the file exposed in the browser and loaded into the monaco.language.typescript.typescriptDefaults.addExtraLib(...) was obviously the already precompiled .js file and no longer the .ts file.

This meant that there was no way for typescript to know that the argument was optional anymore, since all typescript annotations had been removed.

I fixed this by copying all the files added to Monacos typescript library to the public folder via a script everytime I run the devserver.

"scripts": {
    "predev": "cp -r ./src/1_datastructures/**/*.ts ./public/datastructures",
    "dev": "npm run predev && vite",
  }

This is not very pretty but it works.

If anyone has a nicer solution please let me know :).

Reasons:
  • Whitelisted phrase (-2): I fixed
  • RegEx Blacklisted phrase (2.5): please let me know
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Carlo Simoni