-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flow 0.69 #6594
Flow 0.69 #6594
Conversation
@@ -172,7 +172,7 @@ CompoundExpression.register(expressions, { | |||
'feature-state': [ | |||
ValueType, | |||
[StringType], | |||
(ctx, [key]) => get(key.evaluate(ctx), ctx.state()) | |||
(ctx, [key]) => get(key.evaluate(ctx), ctx.featureState || {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be a check for feature
when using featureState
? Feature state is only valid if there is a current feature. As it stands, it's possible to call Expression#evaluate
with a null
feature, but non-null featureState.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to fix it this way:
diff --git a/src/style-spec/expression/index.js b/src/style-spec/expression/index.js
index 1310db3f2..269f718ec 100644
--- a/src/style-spec/expression/index.js
+++ b/src/style-spec/expression/index.js
@@ -179,18 +179,18 @@ export class ZoomDependentExpression<Kind> {
export type ConstantExpression = {
kind: 'constant',
- +evaluate: (globals: GlobalProperties, feature?: Feature) => any,
+ +evaluate: (globals: GlobalProperties) => any,
}
export type SourceExpression = {
kind: 'source',
isStateDependent: boolean,
- +evaluate: (globals: GlobalProperties, feature?: Feature, featureState?: FeatureState) => any,
+ +evaluate: (globals: GlobalProperties, feature: Feature, featureState?: FeatureState) => any,
};
export type CameraExpression = {
kind: 'camera',
- +evaluate: (globals: GlobalProperties, feature?: Feature, featureState?: FeatureState) => any,
+ +evaluate: (globals: GlobalProperties, feature: Feature, featureState?: FeatureState) => any,
+interpolationFactor: (input: number, lower: number, upper: number) => number,
zoomStops: Array<number>
};
@@ -198,7 +198,7 @@ export type CameraExpression = {
export type CompositeExpression = {
kind: 'composite',
isStateDependent: boolean,
- +evaluate: (globals: GlobalProperties, feature?: Feature, featureState?: FeatureState) => any,
+ +evaluate: (globals: GlobalProperties, feature: Feature, featureState?: FeatureState) => any,
+interpolationFactor: (input: number, lower: number, upper: number) => number,
zoomStops: Array<number>
};
But this requires #6255 (comment), so I'd like to defer it.
However, in looking at this, I noticed that I'd failed to update ZoomDependentExpression#evaluate[WithoutErrorHandling]
-- I've added additional render tests to cover that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems reasonable. #6255 is needed soon, and I don't see an actual code path at this time where this issue would come up.
Not upgrading past that due to facebook/flow#6151.
Upgrade flow to 0.69. Not upgrading past that due to facebook/flow#6151.
One of the nice features in 0.68 is:
I remember finding a few bugs that would have been caught by this.