Skip to content

Commit fa486be

Browse files
authored
Merge pull request #2545 from plotly/fix/ts-object-of
Fix typescript objectOf prop generation.
2 parents 9920da8 + 909bab7 commit fa486be

File tree

5 files changed

+45
-11
lines changed

5 files changed

+45
-11
lines changed

@plotly/dash-generator-test-component-typescript/generator.test.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,15 @@ describe('Test Typescript component metadata generation', () => {
106106
test(
107107
`${componentName} tuple tuple`,
108108
testTypeFactory('a_tuple', 'tuple')
109-
)
109+
);
110+
test(
111+
`${componentName} object of string`,
112+
testTypeFactory('object_of_string', 'objectOf')
113+
);
114+
test(
115+
`${componentName} object of components`,
116+
testTypeFactory('object_of_components', 'objectOf')
117+
);
110118
});
111119

112120
describe('Test prop attributes', () => {
@@ -252,6 +260,17 @@ describe('Test Typescript component metadata generation', () => {
252260
R.path(tuplePath.concat(1, 'name'), metadata)
253261
).toBe('string');
254262
}
263+
);
264+
265+
test(
266+
'objectOf node', () => {
267+
const objectOfComponents = R.path(
268+
propPath("TypeScriptComponent", "object_of_components")
269+
.concat(["type", "value", "name"]),
270+
metadata
271+
);
272+
expect(objectOfComponents).toBe("node");
273+
}
255274
)
256275
});
257276

@plotly/dash-generator-test-component-typescript/src/props.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ export type TypescriptComponentProps = {
4343
nested?: Nested;
4444

4545
a_tuple?: [number, string];
46+
47+
object_of_string?: {[k: string]: string};
48+
object_of_components?: {[k: string]: JSX.Element};
4649
};
4750

4851
export type WrappedHTMLProps = {

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
All notable changes to `dash` will be documented in this file.
33
This project adheres to [Semantic Versioning](https://semver.org/).
44

5+
## [UNRELEASED]
6+
7+
## Fixed
8+
9+
- [#2545](https://github.com/plotly/dash/pull/2545) Fix typescript objectOf generation.
10+
511
## [2.10.0] - 2023-05-25
612

713
## Changed
@@ -71,6 +77,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
7177
- [#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.
7278
- [#2414](https://github.com/plotly/dash/pull/2414) Add `dash.Patch`for partial update Output props without transferring the previous value in a State.
7379
- [#2414](https://github.com/plotly/dash/pull/2414) Add `allow_duplicate` to `Output` arguments allowing duplicate callbacks to target the same prop.
80+
- [#2349](https://github.com/plotly/dash/pull/2349) Added new `dcc.Geolocation` component
7481

7582
## Fixed
7683

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

144151
### Added
145152

146-
- [#2349](https://github.com/plotly/dash/pull/2349) Added new `dcc.Geolocation` component
147153
- [#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.
148154

149155
### Updated

dash/extract-meta.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -361,16 +361,20 @@ function gatherComponents(sources, components = {}) {
361361
...getUnion(propType, propObj, newParentType),
362362
raw
363363
};
364+
} else if (propType.indexInfos && propType.indexInfos.length) {
365+
const {type} = propType.indexInfos[0];
366+
name = 'objectOf';
367+
value = getPropType(type, propObj, newParentType);
368+
} else {
369+
value = getProps(
370+
checker.getPropertiesOfType(propType),
371+
propObj,
372+
[],
373+
{},
374+
true,
375+
newParentType,
376+
);
364377
}
365-
366-
value = getProps(
367-
checker.getPropertiesOfType(propType),
368-
propObj,
369-
[],
370-
{},
371-
true,
372-
newParentType,
373-
);
374378
}
375379
}
376380

tests/integration/callbacks/test_prevent_initial.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import pytest
3+
from flaky import flaky
34

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

176177

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

0 commit comments

Comments
 (0)