VSCode can't find modules

292 views
Skip to first unread message

Felipe S. Borsato

unread,
Dec 12, 2022, 5:59:50 PM12/12/22
to Chromium-dev
Visual Studio Code display many errors on imports indicating that modules couldn't be found. I'm pretty sure those modules are actually present, since I could build and run Chromium with no problems. Am I missing something? Thanks for your help.

I'm attaching a screenshot sampling such errors.

import {CrMenuSelector} from 'chrome://resources/cr_elements/cr_menu_selector/cr_menu_selector.js';

Cannot find module 'chrome://resources/cr_elements/cr_menu_selector/cr_menu_selector.js' or its corresponding type declarations.ts(2307)

chromium_imports.png

K. Moon

unread,
Dec 12, 2022, 6:08:37 PM12/12/22
to felis...@gmail.com, Chromium-dev
These resources are served from a special chrome:// URL, and Visual Studio Code (and more specifically, the TypeScript compiler) has no way to figure out how to find them. Furthermore, some of these resources only exist after a Chromium build.

If you want to try and work around this, you could try passing some options to tsc:

I'm not aware of any existing configuration for this, though.

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/8698512b-d6e9-447f-b0ee-6674e58d41b1n%40chromium.org.

Luciano Pacheco

unread,
Dec 12, 2022, 7:48:50 PM12/12/22
to km...@chromium.org, felis...@gmail.com, Chromium-dev
You can try to generate the tsconfig.json for the area of the code that you're working on.

I work mostly on //ui/file_manager/ and I generate like this:
$ ash/webui/personalization_app/tools/gen_tsconfig.py --root_out_dir out/dbg-cros/  --gn_target ui/file_manager:test_build_ts

For your screenshot probably something like:
$  ash/webui/personalization_app/tools/gen_tsconfig.py --root_out_dir out/Default --gn_target chrome/browser/resources/settings:build_ts

After that we might need to git ignore that generate tsconfig.json.

Reply all
Reply to author
Forward
0 new messages