From 502f83029da3798244fa1ff9cda4577bde114039 Mon Sep 17 00:00:00 2001 From: Askar Yusupov Date: Thu, 24 Sep 2020 19:36:42 +0500 Subject: [PATCH] fix(lib/helpers.ts): isSvelteComponent --- packages/app/package.json | 2 +- packages/app/tsconfig.json | 2 +- packages/lib/src/helpers.ts | 7 ++++--- pnpm-lock.yaml | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/app/package.json b/packages/app/package.json index e37c7e3..6211184 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -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" }, diff --git a/packages/app/tsconfig.json b/packages/app/tsconfig.json index 30286bc..96289cf 100644 --- a/packages/app/tsconfig.json +++ b/packages/app/tsconfig.json @@ -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", diff --git a/packages/lib/src/helpers.ts b/packages/lib/src/helpers.ts index 97eea69..d07f09f 100644 --- a/packages/lib/src/helpers.ts +++ b/packages/lib/src/helpers.ts @@ -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"; @@ -13,7 +14,6 @@ import type { FuncProps, FuncComponent, } from "./types"; -import { SvelteComponentDev } from "svelte/internal"; export function createProps( value: T | null = null @@ -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( diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5f941b6..b146ebe 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -35,7 +35,7 @@ importers: sirv-cli: 0.4.6 svelte: 3.23.2 specifiers: - '@pyoner/svelte-form': 'workspace:^0.2.0' + '@pyoner/svelte-form': 'workspace:^1.0.0' '@pyoner/svelte-form-ajv': 'workspace:^0.1.0' '@pyoner/svelte-ts-preprocess': ^1.3.0 '@rollup/plugin-commonjs': ^13.0.0