Do you want to request a _feature_ or report a _bug_?
Bug
What is the current behaviour?
I'm trying to import a JSON file in a class component in a project that I created using the CLI's TypeScript template like this: import pupils from "./../../data/pupils.json";.
My VSCode throws an error saying:
Cannot find module './../../data/pupils.json'. Consider using '--resolveJsonModule' to import module with '.json' extensionts(2732)
However I can use the imported JSON file as expected (e.g. by logging it's contents to the console in my component's render function) and the build throws no errors.
If the current behaviour is a bug, please provide the steps to reproduce.
Import a JSON file in a TSX component using import <name> from <path to JSON file>.
My preact.config.js and my tsconfig.json, both should be unchanged from what the CLI generated.
What is the expected behaviour?
No error messages in VSCode.
If this is a feature request, what is motivation or use case for changing the behaviour?
Please mention other relevant information.
Result of preact info:
Environment Info:
System:
OS: Windows 10 10.0.18363
CPU: (4) x64 Intel(R) Core(TM) i5-7400 CPU @ 3.00GHz
Binaries:
Node: 13.7.0 - ~\scoop\apps\nodejs\current\node.EXE
npm: 6.13.6 - ~\scoop\apps\nodejs\current\npm.CMD
Browsers:
Edge: 44.18362.449.0
npmPackages:
preact: ^10.2.0 => 10.2.1
preact-cli: ^3.0.0-next.19 => 3.0.0-rc.7
preact-render-to-string: ^5.0.6 => 5.1.3
preact-router: ^3.2.0 => 3.2.0
Thanks in advance for the help :).
resolveJsonModule should be available as an option in tsconfig.json as well?
Set it there, typescript checking in preact-cli is async and the errors oftentimes doesn't prevent compiling in dev mode because it's actually done by babel
@ForsakenHarmony For some reason this did not work when I (at least I thought) did exactly that for previously but now it does. I probably made some small mistake 馃 . Thanks for the help! :)