thingworx-field-work / ThingworxVSCodeProject

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

JSON vs TWJSON type in Resources #40

Closed carlo-quinonez closed 2 years ago

carlo-quinonez commented 2 years ago

I was getting tsc errors when building a project with a call to Resources.SpotlightSearch.

DeviceConnectionStats/src/TF_GSS_DeviceConnectionStatus_Monitor_Thing.ts(72,16): error TS2322: Type '{ items: string[]; }' is not assignable to type 'JSON'.
  Object literal may only specify known properties, and 'items' does not exist in type 'JSON'.
DeviceConnectionStats/src/TF_GSS_DeviceConnectionStatus_Monitor_Thing.ts(73,18): error TS2322: Type '{ isSystemObject: false; }' is not assignable to type 'JSON'.
  Object literal may only specify known properties, and 'isSystemObject' does not exist in type 'JSON'.
DeviceConnectionStats/src/TF_GSS_DeviceConnectionStatus_Monitor_Thing.ts(75,22): error TS2322: Type '{ items: string[]; }' is not assignable to type 'JSON'.
  Object literal may only specify known properties, and 'items' does not exist in type 'JSON'.
DeviceConnectionStats/src/TF_GSS_DeviceConnectionStatus_Monitor_Thing.ts(100,16): error TS2322: Type '{ items: string[]; }' is not assignable to type 'JSON'.
  Object literal may only specify known properties, and 'items' does not exist in type 'JSON'.
DeviceConnectionStats/src/TF_GSS_DeviceConnectionStatus_Monitor_Thing.ts(101,18): error TS2322: Type '{ isSystemObject: false; }' is not assignable to type 'JSON'.
  Object literal may only specify known properties, and 'isSystemObject' does not exist in type 'JSON'.
DeviceConnectionStats/src/TF_GSS_DeviceConnectionStatus_Monitor_Thing.ts(103,22): error TS2322: Type '{ items: string[]; }' is not assignable to type 'JSON'.
  Object literal may only specify known properties, and 'items' does not exist in type 'JSON'.
DeviceConnectionStats/src/TF_GSS_DeviceConnectionStatus_Monitor_Thing.ts(571,18): error TS2322: Type '{ items: string[]; }' is not assignable to type 'JSON'.
  Object literal may only specify known properties, and 'items' does not exist in type 'JSON'.
DeviceConnectionStats/src/TF_GSS_DeviceConnectionStatus_Monitor_Thing.ts(572,20): error TS2322: Type '{ isSystemObject: false; }' is not assignable to type 'JSON'.
  Object literal may only specify known properties, and 'isSystemObject' does not exist in type 'JSON'.
DeviceConnectionStats/src/TF_GSS_DeviceConnectionStatus_Monitor_Thing.ts(575,11): error TS2322: Type '{ items: string[]; }' is not assignable to type 'JSON'.
  Object literal may only specify known properties, and 'items' does not exist in type 'JSON'.

I noticed the JSON type was defined in core TS libs and it looked like it was the interface for the global JSON object.

SpotlightSearch( args?: {
  maxItems?: NUMBER,
  searchExpression?: STRING,
  types?: JSON,
  withPermissions?: BOOLEAN,
  endDate?: DATETIME,
  aspects?: JSON,
  excludedAspects?: JSON,
  tags?: TAGS,
  thingTemplates?: JSON,
  searchDescriptions?: BOOLEAN,
  thingShapes?: JSON,
  sortBy?: STRING,
  isAscending?: BOOLEAN,
  projectName?: PROJECTNAME,
  maxSearchItems?: NUMBER,
  startDate?: DATETIME
}): INFOTABLE<SpotlightSearch>

When I changed JSON to TWJSON, all of the errors went away and the extensions was loaded just fine by ThingWorx.

BogdanMihaiciuc commented 2 years ago

Resolved in 1.7.1