Skip to content

Fix typescript objectOf prop generation. #2545

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

Merged
merged 5 commits into from
May 30, 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
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,15 @@ describe('Test Typescript component metadata generation', () => {
test(
`${componentName} tuple tuple`,
testTypeFactory('a_tuple', 'tuple')
)
);
test(
`${componentName} object of string`,
testTypeFactory('object_of_string', 'objectOf')
);
test(
`${componentName} object of components`,
testTypeFactory('object_of_components', 'objectOf')
);
});

describe('Test prop attributes', () => {
Expand Down Expand Up @@ -252,6 +260,17 @@ describe('Test Typescript component metadata generation', () => {
R.path(tuplePath.concat(1, 'name'), metadata)
).toBe('string');
}
);

test(
'objectOf node', () => {
const objectOfComponents = R.path(
propPath("TypeScriptComponent", "object_of_components")
.concat(["type", "value", "name"]),
metadata
);
expect(objectOfComponents).toBe("node");
}
)
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ export type TypescriptComponentProps = {
nested?: Nested;

a_tuple?: [number, string];

object_of_string?: {[k: string]: string};
object_of_components?: {[k: string]: JSX.Element};
};

export type WrappedHTMLProps = {
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
All notable changes to `dash` will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/).

## [UNRELEASED]

## Fixed

- [#2545](https://github.com/plotly/dash/pull/2545) Fix typescript objectOf generation.

## [2.10.0] - 2023-05-25

## Changed
Expand Down Expand Up @@ -71,6 +77,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
- [#2260](https://github.com/plotly/dash/pull/2260) Experimental support for React 18. The default is still React v16.14.0, but to use React 18 you can either set the environment variable `REACT_VERSION=18.2.0` before running your app, or inside the app call `dash._dash_renderer._set_react_version("18.2.0")`. THIS FEATURE IS EXPERIMENTAL. It has not been tested with component suites outside the Dash core, and we may add or remove available React versions in any future release.
- [#2414](https://github.com/plotly/dash/pull/2414) Add `dash.Patch`for partial update Output props without transferring the previous value in a State.
- [#2414](https://github.com/plotly/dash/pull/2414) Add `allow_duplicate` to `Output` arguments allowing duplicate callbacks to target the same prop.
- [#2349](https://github.com/plotly/dash/pull/2349) Added new `dcc.Geolocation` component

## Fixed

Expand Down Expand Up @@ -143,7 +150,6 @@ This project adheres to [Semantic Versioning](https://semver.org/).

### Added

- [#2349](https://github.com/plotly/dash/pull/2349) Added new `dcc.Geolocation` component
- [#2261](https://github.com/plotly/dash/pull/2261) Added new `placeholder_text` property to `filterOptions` for DataTable which allows overriding the default filter field placeholder.

### Updated
Expand Down
22 changes: 13 additions & 9 deletions dash/extract-meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,16 +361,20 @@ function gatherComponents(sources, components = {}) {
...getUnion(propType, propObj, newParentType),
raw
};
} else if (propType.indexInfos && propType.indexInfos.length) {
const {type} = propType.indexInfos[0];
name = 'objectOf';
value = getPropType(type, propObj, newParentType);
} else {
value = getProps(
checker.getPropertiesOfType(propType),
propObj,
[],
{},
true,
newParentType,
);
}

value = getProps(
checker.getPropertiesOfType(propType),
propObj,
[],
{},
true,
newParentType,
);
}
}

Expand Down
2 changes: 2 additions & 0 deletions tests/integration/callbacks/test_prevent_initial.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import pytest
from flaky import flaky

from dash import Dash, Input, Output, MATCH, html
from dash.exceptions import PreventUpdate
Expand Down Expand Up @@ -174,6 +175,7 @@ def d(_):
dash_duo.wait_for_text_to_equal("#a", "Click")


@flaky(max_runs=3)
@pytest.mark.parametrize("flavor", flavors)
def test_cbpi002_pattern_matching(flavor, dash_duo):
# a clone of cbpi001 just throwing it through the pattern-matching machinery
Expand Down