Select to view content in your preferred language

Typescript error with definitionExpression

5903
2
Jump to solution
12-08-2020 03:06 PM
KenBuja
MVP Esteemed Contributor

I want to apply a definitionExpression to a feature layer after it's been created in my TypeScript project with this code.

const exp = 'OBJECTID = 1';
regionLayer.definitionExpression(exp);

but I am getting the error

Error TS2349 (TS) This expression is not callable.
Type 'String' has no call signatures

 

If I add the property when I create the feature layer, I don't get this error

const test = 'OBJECTID = 1';
const regionLayer = new FeatureLayer({
  url: url,
  definitionExpression: test,
  outFields: ['*']
});

 but I have the change the definitionExpression when the user makes certain choices.

What is causing this error?

0 Kudos
1 Solution

Accepted Solutions
JohnGrayson
Esri Regular Contributor

Ken, I believe this is a String property and not a method; maybe try this:

const exp = 'OBJECTID = 1';
regionLayer.definitionExpression = exp;

 

View solution in original post

2 Replies
JohnGrayson
Esri Regular Contributor

Ken, I believe this is a String property and not a method; maybe try this:

const exp = 'OBJECTID = 1';
regionLayer.definitionExpression = exp;

 

KenBuja
MVP Esteemed Contributor

Thanks John! What a silly mistake...

0 Kudos