diff --git a/build/vega-lite-schema.json b/build/vega-lite-schema.json index 1e1ec754eb..8532a959ee 100644 --- a/build/vega-lite-schema.json +++ b/build/vega-lite-schema.json @@ -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." @@ -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." diff --git a/package.json b/package.json index e27e4dc2e2..c153bc0a2a 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/compile/buildmodel.ts b/src/compile/buildmodel.ts index 339db553ea..7bbc17726b 100644 --- a/src/compile/buildmodel.ts +++ b/src/compile/buildmodel.ts @@ -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'; diff --git a/src/compile/format.ts b/src/compile/format.ts index 5d6f34734e..be42af2cdb 100644 --- a/src/compile/format.ts +++ b/src/compile/format.ts @@ -1,4 +1,4 @@ -import {SignalRef} from 'vega'; +import type {SignalRef} from 'vega'; import {isString} from 'vega-util'; import {isBinning} from '../bin'; import { diff --git a/src/compile/mark/encode/nonposition.ts b/src/compile/mark/encode/nonposition.ts index e6c5d58a37..df56da2fb2 100644 --- a/src/compile/mark/encode/nonposition.ts +++ b/src/compile/mark/encode/nonposition.ts @@ -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'; diff --git a/src/compile/mark/encode/offset.ts b/src/compile/mark/encode/offset.ts index 5888345445..0ee51be1d2 100644 --- a/src/compile/mark/encode/offset.ts +++ b/src/compile/mark/encode/offset.ts @@ -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'; diff --git a/src/compile/mark/encode/position-range.ts b/src/compile/mark/encode/position-range.ts index 28ca2e89e6..d0287ac511 100644 --- a/src/compile/mark/encode/position-range.ts +++ b/src/compile/mark/encode/position-range.ts @@ -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'; diff --git a/src/compile/mark/encode/position-rect.ts b/src/compile/mark/encode/position-rect.ts index 72cc2188ed..c6908012f7 100644 --- a/src/compile/mark/encode/position-rect.ts +++ b/src/compile/mark/encode/position-rect.ts @@ -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 { diff --git a/src/compile/mark/encode/valueref.ts b/src/compile/mark/encode/valueref.ts index 3fb30c4ac2..4e203451fb 100644 --- a/src/compile/mark/encode/valueref.ts +++ b/src/compile/mark/encode/valueref.ts @@ -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'; @@ -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 diff --git a/src/compile/mark/text.ts b/src/compile/mark/text.ts index cf1b2265ce..5c651c6bf6 100644 --- a/src/compile/mark/text.ts +++ b/src/compile/mark/text.ts @@ -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'; diff --git a/src/compile/mark/tick.ts b/src/compile/mark/tick.ts index 782b229afa..c24fb48f4a 100644 --- a/src/compile/mark/tick.ts +++ b/src/compile/mark/tick.ts @@ -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'; diff --git a/src/compile/projection/parse.ts b/src/compile/projection/parse.ts index 21c41693e1..4245025e8d 100644 --- a/src/compile/projection/parse.ts +++ b/src/compile/projection/parse.ts @@ -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'; diff --git a/src/compile/scale/component.ts b/src/compile/scale/component.ts index 78ee720d63..ba0e305c0c 100644 --- a/src/compile/scale/component.ts +++ b/src/compile/scale/component.ts @@ -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'; @@ -37,7 +37,10 @@ export class ScaleComponent extends Split { 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 + ); } } diff --git a/src/compile/scale/domain.ts b/src/compile/scale/domain.ts index e793afd0e8..dd92b60cd3 100644 --- a/src/compile/scale/domain.ts +++ b/src/compile/scale/domain.ts @@ -1,4 +1,4 @@ -import {SignalRef} from 'vega'; +import type {SignalRef} from 'vega'; import {isObject, isString} from 'vega-util'; import { Aggregate, diff --git a/src/compile/scale/properties.ts b/src/compile/scale/properties.ts index e4463fdd34..ca73775106 100644 --- a/src/compile/scale/properties.ts +++ b/src/compile/scale/properties.ts @@ -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, @@ -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; } } diff --git a/src/compile/signal.ts b/src/compile/signal.ts index 80c20710aa..c0f04efe1c 100644 --- a/src/compile/signal.ts +++ b/src/compile/signal.ts @@ -1,4 +1,4 @@ -import {SignalRef} from 'vega'; +import type {SignalRef} from 'vega'; export type Rename = (oldSignalName: string) => string; diff --git a/src/normalize/base.ts b/src/normalize/base.ts index 31d70eb314..779998a0e1 100644 --- a/src/normalize/base.ts +++ b/src/normalize/base.ts @@ -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'; diff --git a/src/normalize/core.ts b/src/normalize/core.ts index f48acde593..545e24ff8a 100644 --- a/src/normalize/core.ts +++ b/src/normalize/core.ts @@ -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'; diff --git a/src/normalize/index.ts b/src/normalize/index.ts index f038a30612..439c59a6e8 100644 --- a/src/normalize/index.ts +++ b/src/normalize/index.ts @@ -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'; diff --git a/src/normalize/pathoverlay.ts b/src/normalize/pathoverlay.ts index 92172f5684..980f13aa5e 100644 --- a/src/normalize/pathoverlay.ts +++ b/src/normalize/pathoverlay.ts @@ -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'; diff --git a/src/predicate.ts b/src/predicate.ts index c3924363b8..b981099e60 100644 --- a/src/predicate.ts +++ b/src/predicate.ts @@ -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'; diff --git a/src/selection.ts b/src/selection.ts index f0f8590522..4bd56525cb 100644 --- a/src/selection.ts +++ b/src/selection.ts @@ -73,9 +73,7 @@ export interface BaseSelectionConfig { * __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. @@ -83,7 +81,9 @@ export interface PointSelectionConfig extends BaseSelectionConfig<'point'> { * __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. diff --git a/test/channeldef.test.ts b/test/channeldef.test.ts index bfd7a136ce..c25574932c 100644 --- a/test/channeldef.test.ts +++ b/test/channeldef.test.ts @@ -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 { diff --git a/test/compile/facet.test.ts b/test/compile/facet.test.ts index e750861e70..41b5393dc8 100644 --- a/test/compile/facet.test.ts +++ b/test/compile/facet.test.ts @@ -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'; diff --git a/test/compile/mark/encode/offset.test.ts b/test/compile/mark/encode/offset.test.ts index 2eee4c22ed..5cb7fe6a2a 100644 --- a/test/compile/mark/encode/offset.test.ts +++ b/test/compile/mark/encode/offset.test.ts @@ -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'; diff --git a/test/compile/scale/domain.test.ts b/test/compile/scale/domain.test.ts index 23a7d0e276..4e06805636 100644 --- a/test/compile/scale/domain.test.ts +++ b/test/compile/scale/domain.test.ts @@ -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'; diff --git a/test/config.test.ts b/test/config.test.ts index 1c743380ec..fa9cb2dfd0 100644 --- a/test/config.test.ts +++ b/test/config.test.ts @@ -1,4 +1,4 @@ -import {SignalRef} from 'vega'; +import type {SignalRef} from 'vega'; import { Config, defaultConfig, diff --git a/test/util.ts b/test/util.ts index 884c3aa8bc..d510daf980 100644 --- a/test/util.ts +++ b/test/util.ts @@ -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'; diff --git a/tsconfig.json b/tsconfig.json index 60bbcda2c7..d6d2f78743 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -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"], diff --git a/yarn.lock b/yarn.lock index 3de14cccda..f786abb8dc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"