Skip to content

Commit

Permalink
exclude observable properties from inputsType
Browse files Browse the repository at this point in the history
  • Loading branch information
electrovir committed Jul 19, 2023
1 parent 8b42757 commit 6ec6679
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "element-vir",
"version": "14.2.0",
"version": "14.2.1",
"keywords": [
"custom",
"web",
Expand Down
2 changes: 1 addition & 1 deletion src/declarative-element/declarative-element.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ describe('StaticDeclarativeElementProperties', () => {
any,
any
>['inputsType']
>().toEqualTypeOf<Readonly<{hi: number}>>();
>().toEqualTypeOf<{hi: number}>();
});
});
3 changes: 1 addition & 2 deletions src/declarative-element/declarative-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {HostClassNamesMap} from './properties/host-classes';
import {
AllowObservablePropertySetter,
FlattenObservablePropertyGetters,
FlattenObservablePropertySetters,
ObservablePropertyHandlerMap,
} from './properties/observable-property/observable-property-handler';
import {RenderCallback, RenderParams, UpdateStateCallback} from './render-callback';
Expand Down Expand Up @@ -284,7 +283,7 @@ export interface StaticDeclarativeElementProperties<
>,
'stateInitStatic' | 'events'
>;
readonly inputsType: Readonly<FlattenObservablePropertySetters<Inputs, Inputs>>;
readonly inputsType: Inputs;
readonly stateType: Readonly<FlattenObservablePropertyGetters<StateInit>>;
readonly updateStateType: UpdateStateCallback<StateInit>;
readonly isStrictInstance: (
Expand Down
27 changes: 27 additions & 0 deletions src/declarative-element/define-element.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,33 @@ describe(defineElement.name, () => {
},
});
});
it('allows partial inputs', () => {
const MyElement = defineElement<{
maybeInput?: string;
maybeUndefined?: string | undefined;
}>()({
tagName: `some-tag-${randomString()}`,
cleanupCallback({host}) {},
// render callback must return something
// @ts-expect-error
renderCallback() {},
});

MyElement.assign({
maybeInput: '',
maybeUndefined: undefined,
});

MyElement.assign({
maybeUndefined: undefined,
});

MyElement.assign({
maybeUndefined: '',
});

MyElement.assign({});
});

it('blocks render callbacks that are async', () => {
defineElement<{}>()({
Expand Down

0 comments on commit 6ec6679

Please sign in to comment.