Skip to content

Commit

Permalink
fix(types): add types for Chart interface (#5425)
Browse files Browse the repository at this point in the history
* fix(types): add types for Chart interface

* chore: update to 5.0.20
  • Loading branch information
pearmini authored Aug 17, 2023
1 parent f6570d2 commit ab88de0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# G2 - Changelog

## [5.0.20](https://github.com/antvis/g2/compare/5.0.19...5.0.20) (2023-08-17)

### Bug Fixes

- **interaction:** multi interaction ([#5419](https://github.com/antvis/g2/issues/5419)) ([328aeea](https://github.com/antvis/g2/commit/328aeeac34e770ff2c28f5b1a8ad704ab00af0a5))
- **types:** add types for Chart interface ([acd81b9](https://github.com/antvis/g2/commit/acd81b93facc110015a38922e766a1fe5d7f9069))

## [5.0.19](https://github.com/antvis/g2/compare/5.0.18...5.0.19) (2023-08-15)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g2",
"version": "5.0.19",
"version": "5.0.20",
"description": "the Grammar of Graphics in Javascript",
"license": "MIT",
"main": "lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion site/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "5.0.19",
"version": "5.0.20",
"scripts": {
"start": "dumi dev",
"build": "dumi build",
Expand Down
6 changes: 3 additions & 3 deletions src/api/chart.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { extend } from './extend';
import { G2Spec } from '../spec';
import { extend, API } from './extend';
import { library } from './library';
import { Runtime } from './runtime';

// Use a empty interface to mark Chart both a value and a class type.
export interface Chart {}
export interface Chart extends API<G2Spec, typeof library> {}

export const Chart = extend(Runtime, library);
8 changes: 5 additions & 3 deletions src/api/extend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ type CompositionOf<Library> = Of<
CompositionOf<Library>
>;

export type API<Spec, Library> = Runtime<Spec> &
MarkOf<Library, (composite?) => MarkNode> &
CompositionOf<Library>;

export function extend<
Spec extends G2Spec = G2Spec,
Library extends G2Library = G2Library,
>(
Runtime: new (options: RuntimeOptions) => Runtime<Spec>,
library: Library,
): new (options?: RuntimeOptions) => Runtime<Spec> &
MarkOf<Library, (composite?) => MarkNode> &
CompositionOf<Library> {
): new (options?: RuntimeOptions) => API<Spec, Library> {
class Chart extends Runtime {
constructor(options: Omit<RuntimeOptions, 'lib'>) {
super({ ...options, lib: library });
Expand Down

0 comments on commit ab88de0

Please sign in to comment.