AnsweredAssumed Answered

TypeScript error when creating Search Widget (JS 4.8)

Question asked by PSLarkin_SpokaneCounty on Aug 29, 2018
Latest reply on Oct 9, 2018 by PSLarkin_SpokaneCounty

I'm getting an error when assigning a source to a searchWidget. It appears I might be using incorrect syntax for TypeScript.

 

(TS) Type '{ locator: Locator; name: string; placeholder: string; }[]' is not assignable to type 'Collection<FeatureLayerSource | LocatorSource>'. Property 'add' is missing in type '{ locator: Locator; name: string; placeholder: string; }[]'.

 

import Locator = require("esri/tasks/Locator");
import Search = require("esri/widgets/Search");

var sources = [{
    locator: new Locator({ url: "https://gis.spokanecounty.org/arcgis/rest/services/Locators/AddrComposite/GeocodeServer" }),
    name: "addrComposite",
    placeholder: "Search Addresses"
}];

var searchWidget = new Search({
    view: view,
    includeDefaultSources: false
});

searchWidget.sources = sources;

 

Similar issue here: typescript files error on search widget 

 

Definition file used: Small updates for version 4.8 (#27426) · DefinitelyTyped/DefinitelyTyped@0575e7d · GitHub 

Attachments

Outcomes