thingworx-field-work / ThingworxVSCodeProject

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

Gulp Build Fail #8

Closed thomas-thomas-tfs closed 3 years ago

thomas-thomas-tfs commented 3 years ago

Getting error while gulp build

src\MyThing.ts(137,82): error TS2322: Type '"LinkedList"' is not assignable to type '"LicenseGroupUsageDataShape" | "DTAuditShape" | "DesignTimePermissions" | "EntityReferenceWithDescription" | "UserProvisioningUserExclusionList" | "AnalyticsSignalsResult" | ... 324 more ... | undefined'.

BogdanMihaiciuc commented 3 years ago

The provided example doesn't compile directly because the only declarations that are actually included in the project are those that are part of an empty installation of Thingworx, so none of the classes under src are there, which means you can't reference them via their collections (e.g. DataShapes.LinkedList) or other type checked methods that take DATASHAPENAME parameters.

You should be able to reference it via the class name (e.g. writing INFOTABLE<LinkedList>), however TypeScript is not normally aware that classes can be referenced via collections (writing DataShapes.LinkedList) so there is a separate process that creates this linking.

This is why it's important to run gulp and leave it running. This is a watch process that will generate those declarations whenever you save a file. It will generate the static/gen/Generated.d.ts file which will look like this for the example entities:

declare interface DataShapes { MyDataShape: DataShapeEntity<MyDataShape> }

declare interface ThingShapes { MyThingShape: ThingShapeEntity<MyThingShape> }
...

An annoyance with this right now is that you need to actually save a file in order to get these declarations. Just running gulp will not create it directly.

carlo-quinonez commented 3 years ago

What's the gulp task that generates the declarations?

BogdanMihaiciuc commented 3 years ago

It’s the default task that you can start by simply running gulp with no arguments. This starts a watch process that regenerates the declarations whenever you save a file. Keep this running to make sure the declarations don’t become stale.