Question:
Why is my TypeScript compiler trying to scan it’s own compiled code?
Product:
Wix Studio, using wix/cli or wix-IDE
What are you trying to achieve:
I am trying to create a template repository that would allow using TypeScript with Velo.
TypeScript compiles successfully, but then tries to scan its own compiled code and crashes
What have you already tried:
I am basing this repository on this article:
(Github repository Algiras/typescript-velo)
I have tried tweaking certain configurations in the various tsconfigs, but have not been able to produce a consistent result, nor do I understand why tsc is trying to scan its own output!
Additional information:
Hi there, as a disclaimer, though I love TypeScript, I still get a bit lost with all the options in tsconfig.json
I am currently making a template repository that would allow using TypeScript with Wix Velo.
Using the aforementioned article/repository as reference I successfully set up various tsconfig files that compile into the required file architecture Wix expects.
I also solved a few problems experienced within Algimantas’s repository, in which the $w types are not really recognized
The problem I am experiencing is as follows:
The IDE recognizes types correctly and the suggestion window is shown as should be.
tsc --build recognizes the types and builds the output directory correctly
BUT THEN it for some reason scans the output files themselves, and shows errors in the d.ts files!
The architecture is currently like so:
- .wix/
- tsconfig.json (For IDE IntelliSense)
- app/ (source)
- tsconfig.json (For build)
- pages/
- Home.c1dmp.ts
- masterPage.ts
- ts/
- conf/
- tsconfig.page.json (Base config for pages to extend)
- pages/
- tsconfig.c1dmp.json (Extends tsconfig.page, with page specific types)
- tsconfig.masterPage.json (^)
- build/ (The current output directory, will be replaced with src)
- pages/...
As I do tsc --build app, ./app is compiled into ./build, then I get this error:
build/pages/Home.c1dmp.d.ts:1:24 - error TS2503: Cannot find namespace '$w'.
1 declare const _w: <T = $w.Element>(selector: Selectors) => T;
Again, ./app/pages/Home.c1dmp.ts recognizes $w correctly
This is already rather long as it is, so instead of pasting my various tsconfig files, I’ll link the repository. I know this is a bit extra, and I don’t expect anyone to clone my repository, but if at all possible, I’d appreciate any guidance you could hand me in resolving this issue
If you do download the repository, make sure you’re on the correct branch ‘help’.
Then, simply run npm i and tsc --build app
Here’s my repository:
Thank you ![]()