Skip to content

Commit

Permalink
fix(lib/helpers.ts): isSvelteComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
pyoner committed Sep 24, 2020
1 parent 0189b53 commit 502f830
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"format": "prettier --write 'src/**/*' 'test/**/*'"
},
"dependencies": {
"@pyoner/svelte-form": "workspace:^0.2.0",
"@pyoner/svelte-form": "workspace:^1.0.0",
"@pyoner/svelte-form-ajv": "workspace:^0.1.0",
"ajv": "^6.12.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/app/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"resolveJsonModule": true,
/* Basic Options */
"target": "ESNEXT" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
"target": "ES2018" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
"module": "ESNEXT" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
"lib": [
"esnext",
Expand Down
7 changes: 4 additions & 3 deletions packages/lib/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { isObject } from "is-what";
import { SvelteComponent } from "svelte";
import { SvelteComponent as InternalSvelteComponent } from "svelte/internal";

import type { JSONObject, JSONSchema } from "@pyoner/svelte-form-common";

Expand All @@ -13,7 +14,6 @@ import type {
FuncProps,
FuncComponent,
} from "./types";
import { SvelteComponentDev } from "svelte/internal";

export function createProps<T extends any, E extends Errors = Error[]>(
value: T | null = null
Expand Down Expand Up @@ -127,8 +127,9 @@ export function getProps(
return getPropsFromContainer(container);
}

export function isSvelteComponent(obj: any): obj is typeof SvelteComponentDev {
return Object.getPrototypeOf(obj) === SvelteComponentDev;
export function isSvelteComponent(obj: any): obj is typeof SvelteComponent {
const cls = Object.getPrototypeOf(obj);
return cls === SvelteComponent || cls === InternalSvelteComponent;
}

export function getComponent(
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

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

0 comments on commit 502f830

Please sign in to comment.