Symfony AssetMapper and TypeScript - How can I fix "Cannot find module" linting error?

42 Views Asked by At

I have created a Symfony project using the AssetMapper component alongside the AssetMapperTypeScriptBundle, as per the Symfony documentation.

I can successfully build and run my TypeScript Stimulus controllers as the AssetMapper is configured correctly, however I am getting a linting error I cannot solve.

Linting error

This is frustrating as it prevents type hinting and I want to fix it.

I have tried a few things, including:

  • Changing the import to point directly at the file installed by the AssetMapper (in this case to ../vendor/@hotwired/stimulus/stimulus.index.js). This technically removes the not found error, but still does not work as expected as there are no type hints.

  • Creating a tsconfig.json file and specifying the path to the file, which does not work. (I tried a handful of variations on this path, none worked.)

tsconfig layout

  • Installing @types/stimulus via the importmap:require command, but this results in an error.

Stimulus types error message

Is there something obvious (or not so much) that I'm missing?

Thanks.

0

There are 0 best solutions below