Skip to content
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

fix: update ts and fix typing issues #9066

Merged
merged 2 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions build/vega-lite-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -12472,6 +12472,13 @@
},
"type": "array"
},
"fields": {
"description": "An array of field names whose values must match for a data tuple to fall within the selection.\n\n__See also:__ The [projection with `encodings` and `fields` section](https://vega.github.io/vega-lite/docs/selection.html#project) in the documentation.",
"items": {
"$ref": "#/definitions/FieldName"
},
"type": "array"
},
"mark": {
"$ref": "#/definitions/BrushConfig",
"description": "An interval selection also adds a rectangle mark to depict the extents of the interval. The `mark` property can be used to customize the appearance of the mark.\n\n__See also:__ [`mark` examples](https://vega.github.io/vega-lite/docs/selection.html#mark) in the documentation."
Expand Down Expand Up @@ -12540,6 +12547,13 @@
},
"type": "array"
},
"fields": {
"description": "An array of field names whose values must match for a data tuple to fall within the selection.\n\n__See also:__ The [projection with `encodings` and `fields` section](https://vega.github.io/vega-lite/docs/selection.html#project) in the documentation.",
"items": {
"$ref": "#/definitions/FieldName"
},
"type": "array"
},
"mark": {
"$ref": "#/definitions/BrushConfig",
"description": "An interval selection also adds a rectangle mark to depict the extents of the interval. The `mark` property can be used to customize the appearance of the mark.\n\n__See also:__ [`mark` examples](https://vega.github.io/vega-lite/docs/selection.html#mark) in the documentation."
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"terser": "^5.19.2",
"ts-jest": "^29.1.1",
"ts-json-schema-generator": "^1.3.0",
"typescript": "~4.9.5",
"typescript": "~5.1.6",
"vega-cli": "^5.25.0",
"vega-datasets": "^2.7.0",
"vega-embed": "^6.22.2",
Expand Down
2 changes: 1 addition & 1 deletion src/compile/buildmodel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignalRef} from 'vega';
import type {SignalRef} from 'vega';
import {Config} from '../config';
import * as log from '../log';
import {isAnyConcatSpec, isFacetSpec, isLayerSpec, isUnitSpec, LayoutSizeMixins, NormalizedSpec} from '../spec';
Expand Down
2 changes: 1 addition & 1 deletion src/compile/format.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignalRef} from 'vega';
import type {SignalRef} from 'vega';
import {isString} from 'vega-util';
import {isBinning} from '../bin';
import {
Expand Down
2 changes: 1 addition & 1 deletion src/compile/mark/encode/nonposition.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignalRef} from 'vega';
import type {SignalRef} from 'vega';
import {NonPositionScaleChannel} from '../../../channel';
import {Value} from '../../../channeldef';
import {VgEncodeChannel, VgEncodeEntry, VgValueRef} from '../../../vega.schema';
Expand Down
2 changes: 1 addition & 1 deletion src/compile/mark/encode/offset.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Utility files for producing Vega ValueRef for marks
*/
import {SignalRef} from 'vega';
import type {SignalRef} from 'vega';
import {PolarPositionChannel, PositionChannel} from '../../../channel';
import {Encoding} from '../../../encoding';
import {Mark, MarkDef} from '../../../mark';
Expand Down
2 changes: 1 addition & 1 deletion src/compile/mark/encode/position-range.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignalRef} from 'vega';
import type {SignalRef} from 'vega';
import {getMainRangeChannel, getSecondaryRangeChannel, getSizeChannel, getVgPositionChannel} from '../../../channel';
import {isFieldOrDatumDef} from '../../../channeldef';
import * as log from '../../../log';
Expand Down
2 changes: 1 addition & 1 deletion src/compile/mark/encode/position-rect.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignalRef} from 'vega';
import type {SignalRef} from 'vega';
import {isArray, isNumber} from 'vega-util';
import {isBinned, isBinning, isBinParams} from '../../../bin';
import {
Expand Down
4 changes: 2 additions & 2 deletions src/compile/mark/encode/valueref.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Utility files for producing Vega ValueRef for marks
*/
import {SignalRef} from 'vega';
import type {SignalRef} from 'vega';
import {isFunction, isString} from 'vega-util';
import {isCountingAggregateOp} from '../../../aggregate';
import {isBinned, isBinning} from '../../../bin';
Expand Down Expand Up @@ -176,7 +176,7 @@ export function interpolatedSignalRef({
offset: number | SignalRef | VgValueRef;
bandPosition: number | SignalRef;
}): VgValueRef {
const expr = 0 < bandPosition && bandPosition < 1 ? 'datum' : undefined;
const expr = !isSignalRef(bandPosition) && 0 < bandPosition && bandPosition < 1 ? 'datum' : undefined;
const start = vgField(fieldOrDatumDef, {expr, suffix: startSuffix});
const end =
fieldOrDatumDef2 !== undefined
Expand Down
2 changes: 1 addition & 1 deletion src/compile/mark/text.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignalRef} from 'vega';
import type {SignalRef} from 'vega';
import {Config} from '../../config';
import {Encoding} from '../../encoding';
import {MarkDef} from '../../mark';
Expand Down
2 changes: 1 addition & 1 deletion src/compile/mark/tick.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignalRef} from 'vega';
import type {SignalRef} from 'vega';
import {isNumber} from 'vega-util';
import {getViewConfigDiscreteStep} from '../../config';
import {isVgRangeStep} from '../../vega.schema';
Expand Down
2 changes: 1 addition & 1 deletion src/compile/projection/parse.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignalRef} from 'vega';
import type {SignalRef} from 'vega';
import {hasOwnProperty} from 'vega-util';
import {LATITUDE, LATITUDE2, LONGITUDE, LONGITUDE2, SHAPE} from '../../channel';
import {getFieldOrDatumDef} from '../../channeldef';
Expand Down
9 changes: 6 additions & 3 deletions src/compile/scale/component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {SignalRef} from 'vega';
import {isArray} from 'vega-util';
import type {SignalRef} from 'vega';
import {isArray, isNumber} from 'vega-util';
import {ScaleChannel} from '../../channel';
import {Scale, ScaleType} from '../../scale';
import {ParameterExtent} from '../../selection';
Expand Down Expand Up @@ -37,7 +37,10 @@ export class ScaleComponent extends Split<ScaleComponentProps> {
if (this.get('zero') !== false) {
return true;
}
return some(this.get('domains'), d => isArray(d) && d.length === 2 && d[0] <= 0 && d[1] >= 0);
return some(
this.get('domains'),
d => isArray(d) && d.length === 2 && isNumber(d[0]) && d[0] <= 0 && isNumber(d[1]) && d[1] >= 0
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/compile/scale/domain.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignalRef} from 'vega';
import type {SignalRef} from 'vega';
import {isObject, isString} from 'vega-util';
import {
Aggregate,
Expand Down
6 changes: 3 additions & 3 deletions src/compile/scale/properties.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {SignalRef, TimeInterval} from 'vega';
import {isArray} from 'vega-util';
import {isArray, isNumber} from 'vega-util';
import {isBinned, isBinning, isBinParams} from '../../bin';
import {
COLOR,
Expand Down Expand Up @@ -414,8 +414,8 @@ export function zero(
const first = specifiedDomain[0];
const last = specifiedDomain[specifiedDomain.length - 1];

if (first <= 0 && last >= 0) {
// if the domain includes zero, make zero remains true
if (isNumber(first) && first <= 0 && isNumber(last) && last >= 0) {
// if the domain includes zero, make zero remain true
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/compile/signal.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignalRef} from 'vega';
import type {SignalRef} from 'vega';

export type Rename = (oldSignalName: string) => string;

Expand Down
2 changes: 1 addition & 1 deletion src/normalize/base.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignalRef} from 'vega';
import type {SignalRef} from 'vega';
import {FieldName} from '../channeldef';
import {Config} from '../config';
import {Encoding} from '../encoding';
Expand Down
2 changes: 1 addition & 1 deletion src/normalize/core.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignalRef} from 'vega';
import type {SignalRef} from 'vega';
import {isArray} from 'vega-util';
import {COLUMN, FACET, ROW} from '../channel';
import {Field, FieldName, hasConditionalFieldOrDatumDef, isFieldOrDatumDef, isValueDef} from '../channeldef';
Expand Down
2 changes: 1 addition & 1 deletion src/normalize/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignalRef} from 'vega';
import type {SignalRef} from 'vega';
import {isString} from 'vega-util';
import {Field} from '../channeldef';
import {Config, initConfig} from '../config';
Expand Down
2 changes: 1 addition & 1 deletion src/normalize/pathoverlay.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignalRef} from 'vega';
import type {SignalRef} from 'vega';
import {isObject} from 'vega-util';
import {Config} from '../config';
import {Encoding, normalizeEncoding} from '../encoding';
Expand Down
2 changes: 1 addition & 1 deletion src/predicate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignalRef} from 'vega';
import type {SignalRef} from 'vega';
import {isArray} from 'vega-util';
import {FieldName, valueExpr, vgField} from './channeldef';
import {DateTime} from './datetime';
Expand Down
4 changes: 2 additions & 2 deletions src/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,17 @@ export interface BaseSelectionConfig<T extends SelectionType = SelectionType> {
* __See also:__ The [projection with `encodings` and `fields` section](https://vega.github.io/vega-lite/docs/selection.html#project) in the documentation.
*/
encodings?: SingleDefUnitChannel[];
}

export interface PointSelectionConfig extends BaseSelectionConfig<'point'> {
/**
* An array of field names whose values must match for a data tuple to
* fall within the selection.
*
* __See also:__ The [projection with `encodings` and `fields` section](https://vega.github.io/vega-lite/docs/selection.html#project) in the documentation.
*/
fields?: FieldName[];
}

export interface PointSelectionConfig extends BaseSelectionConfig<'point'> {
/**
* Controls whether data values should be toggled (inserted or removed from a point selection)
* or only ever inserted into point selections.
Expand Down
2 changes: 1 addition & 1 deletion test/channeldef.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignalRef} from 'vega';
import type {SignalRef} from 'vega';
import {COUNTING_OPS} from '../src/aggregate';
import {CHANNELS} from '../src/channel';
import {
Expand Down
2 changes: 1 addition & 1 deletion test/compile/facet.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignalRef} from 'vega';
import type {SignalRef} from 'vega';
import {ROW} from '../../src/channel';
import {FacetModel} from '../../src/compile/facet';
import {assembleLabelTitle} from '../../src/compile/header/assemble';
Expand Down
2 changes: 1 addition & 1 deletion test/compile/mark/encode/offset.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignalRef} from 'vega';
import type {SignalRef} from 'vega';
import {positionOffset} from '../../../../src/compile/mark/encode/offset';
import {Mark, MarkDef} from '../../../../src/mark';

Expand Down
2 changes: 1 addition & 1 deletion test/compile/scale/domain.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignalRef} from 'vega';
import type {SignalRef} from 'vega';
import {ScaleChannel} from '../../../src/channel';
import {PositionFieldDef} from '../../../src/channeldef';
import {domainSort, mergeDomains, parseDomainForChannel} from '../../../src/compile/scale/domain';
Expand Down
2 changes: 1 addition & 1 deletion test/config.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignalRef} from 'vega';
import type {SignalRef} from 'vega';
import {
Config,
defaultConfig,
Expand Down
2 changes: 1 addition & 1 deletion test/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {SignalRef} from 'vega';
import type {SignalRef} from 'vega';
import {Field} from '../src/channeldef';
import {buildModel} from '../src/compile/buildmodel';
import {ConcatModel} from '../src/compile/concat';
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"suppressImplicitAnyIndexErrors": true,
"isolatedModules": true,
"lib": ["ESNext.Array", "DOM", "DOM.Iterable", "ES2021.String"],
"ignoreDeprecations": "5.0",
"noEmit": true
},
"files": ["src/index.ts"],
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8469,11 +8469,6 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==

typescript@~4.9.5:
version "4.9.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a"
integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==

typescript@~5.1.6:
version "5.1.6"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.6.tgz#02f8ac202b6dad2c0dd5e0913745b47a37998274"
Expand Down