thingworx-field-work / ThingworxVSCodeProject

Develop thingworx models using a real IDE
MIT License
33 stars 17 forks source link

Build fails without "skipLibCheck": true in tsconfig.json #71

Open kklorenzotesta opened 6 months ago

kklorenzotesta commented 6 months ago

When I try to compile without the "skipLibCheck": true in the compilerOptions of tsconfig.json the build fails with:

> bm-thingworx-vscode@3.0.2 build
> twc build

Running build (v2.0.2)
✔ Built declarations
✖ Failed building ExampleProject
node_modules/bm-thing-transformer/ui/types/UIBaseTypes.d.ts:150:81 - error TS2552: Cannot find name 'MashupController'. Did you mean 'ToMashupController'?

150 declare type MashupControllerExtendedKeys<T> = {[K in keyof T]: K extends keyof MashupController ? never : K}[keyof T];
                                                                                    ~~~~~~~~~~~~~~~~
node_modules/bm-thing-transformer/ui/types/UIBaseTypes.d.ts:150:81 - error TS2552: Cannot find name 'MashupController'. Did you mean 'ToMashupController'?

150 declare type MashupControllerExtendedKeys<T> = {[K in keyof T]: K extends keyof MashupController ? never : K}[keyof T];

Unfortunately in my project I can't just enable skipLibCheck otherwise some top level functions are not correctly copied in the services that uses them, leading to runtime errors. I can't find a way to reproduce the other issue in a scale small enough to open a bug report.

BogdanMihaiciuc commented 6 months ago

Does this happen without importing the UI types? You can keep the UI entities in a sub-project with its own tsconfig, via the add-project command (with skipLibCheck) and leave your previous tsconfig for the backend entities that need skipLibCheck to be disabled.

I didn't want to complicate this template with sub-projects, but that's the ideal way to use the mashup support since it comes with a number of types that don't work at all on the backend and it's practically a requirement if you use it with core ui/code host support as that requires the compiler to output es6 code.

kklorenzotesta commented 6 months ago

Does this happen without importing the UI types?

No, it compiles correclty if I don't add my .tsx files in the include of the tsconfig.json.

You can keep the UI entities in a sub-project with its own tsconfig

Thats a good idea, thank you, I'll probably go that way, I'm just trying out the new mashup support so I can easily make changes. For now I've added a declare abstract class MashupController {} in my code to let it compile, so it was not a big problem for me and I can split it in a subproject later.

BogdanMihaiciuc commented 6 months ago

I'll resolve this eventually and I'm surprised that having that declare statement is enough to clear the typing errors. I settled on skipLibCheck because I couldn't get the behaviour I was going for in the mashup files without introducing them and had already spent too much time trying to solve them.

I'll look into it some more and if it's as easy as just adding an empty mashup controller class/interface I'll add it in to the next release.