Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,40 @@ describe('Test Typescript component metadata generation', () => {
expect(propType.value[1].value).toBe('small');
}
)

test(
'union of boolean and literal values', () => {
const propType = R.path(
propPath('TypeScriptComponent', 'boolean_enum').concat(
'type'
),
metadata
);
expect(propType.name).toBe('union');
expect(propType.value.length).toBe(3);
expect(propType.value[0].name).toBe('bool');
expect(propType.value[1].name).toBe('literal');
expect(propType.value[2].name).toBe('literal');
expect(propType.value[0].value).toBe(undefined);
expect(propType.value[1].value).toBe('small');
expect(propType.value[2].value).toBe('large');
}
)

test(
'union of duplicated types', () => {
const propType = R.path(
propPath('TypeScriptComponent', 'duplicated_enum').concat(
'type'
),
metadata
);
expect(propType.name).toBe('union');
expect(propType.value.length).toBe(2);
expect(propType.value[0].name).toBe('number');
expect(propType.value[1].name).toBe('bool');
}
)
});

describe('Test component comments', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export type TypescriptComponentProps = {
object_of_string?: {[k: string]: string};
object_of_components?: {[k: string]: JSX.Element};
ignored_prop?: {ignore: {me: string}};
union_enum?: number | 'small' | 'large'
union_enum?: number | 'small' | 'large';
boolean_enum?: boolean | 'small' | 'large';
duplicated_enum?: boolean | number | number;
};

export type WrappedHTMLProps = {
Expand Down
13 changes: 13 additions & 0 deletions components/dash-core-components/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@
"jasmine": true,
"node": true
},
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": [
"plugin:@typescript-eslint/recommended"
],
"rules": {
// You can add TypeScript-specific rules here
}
}
],
"plugins": [
"react",
"import"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@
"namespace": "dash",
"dynamic": True,
},
{
"dev_package_path": "dcc/proptypes.js",
"dev_only": True,
"namespace": "dash",
},
]
)

Expand Down
Loading