fix: literal infers type when any

This commit is contained in:
cha0s 2020-06-23 20:01:16 -05:00
parent b797657361
commit 4a7afab0df

View File

@ -1,3 +1,4 @@
import {fromLiteral} from '@avocado/behavior';
import {compose} from '@avocado/core'; import {compose} from '@avocado/core';
import contempo from 'contempo'; import contempo from 'contempo';
import React from 'react'; import React from 'react';
@ -15,11 +16,12 @@ const Literal = ({
context, context,
onChange = () => {}, onChange = () => {},
type, type,
value, value: {value},
}) => { }) => {
const typeRenderers = useTypeRenderers(); const typeRenderers = useTypeRenderers();
const Component = typeRenderers[type]; const actualType = 'any' === type ? fromLiteral(value) : type;
const [options] = opsOptions(context, [], type); const Component = typeRenderers[actualType];
const [options] = opsOptions(context, [], actualType);
options.push('<literal>'); options.push('<literal>');
return ( return (
<div className="literal"> <div className="literal">
@ -40,7 +42,7 @@ const Literal = ({
.map((option) => <option key={option}>{option}</option>) .map((option) => <option key={option}>{option}</option>)
} }
</select> </select>
{Component ? <Component onChange={onChange} type={type} value={value.value} /> : null} {Component ? <Component onChange={onChange} type={actualType} value={value} /> : null}
</div> </div>
); );
}; };