From 97c10fbee53e72ffef5ce1ee2d51795f7418e2d9 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 31 Jan 2022 15:01:08 +0100 Subject: [PATCH] (fix) better error message for missing type definition #1352 --- .../features/CodeActionsProvider.ts | 36 ++++++++++--------- .../features/DiagnosticsProvider.ts | 12 +++---- .../fixtures/component-invalid/expected.json | 13 +++++++ .../component-invalid/expectedv2.json | 13 +++++++ .../component-invalid/imported.svelte | 1 + .../fixtures/component-invalid/input.svelte | 14 ++++++++ .../expected.json | 0 .../expectedv2.json | 0 .../input.svelte | 0 .../htmlxtojsx_v2/nodes/InlineComponent.ts | 36 +++++++++---------- packages/svelte2tsx/svelte-shims.d.ts | 2 +- .../samples/attribute-bare/expectedv2.js | 2 +- .../attribute-foreign-ns/expectedv2.js | 2 +- .../attribute-invalid-jsx-name/expectedv2.js | 2 +- .../samples/attribute-multiple/expectedv2.js | 2 +- .../expectedv2.js | 2 +- .../samples/attribute-number/expectedv2.js | 2 +- .../attribute-optional-chaining/expectedv2.js | 2 +- .../samples/attribute-quoted/expectedv2.js | 4 +-- .../samples/attribute-shorthand/expectedv2.js | 2 +- .../samples/attribute-text/expectedv2.js | 2 +- .../binding-this-component/expectedv2.js | 2 +- .../expectedv2.js | 2 +- .../expectedv2.js | 2 +- .../expectedv2.js | 2 +- .../component-default-slot-let/expectedv2.js | 2 +- .../component-default-slot/expectedv2.js | 2 +- .../component-multi-slot/expectedv2.js | 2 +- .../component-named-slot/expectedv2.js | 6 ++-- .../samples/component-no-slots/expectedv2.js | 4 +-- .../component-slot-infer-props/expectedv2.js | 4 +-- .../expectedv2.js | 6 ++-- .../custom-css-properties/expectedv2.js | 2 +- .../samples/directive-quoted/expectedv2.js | 2 +- .../samples/editing-mustache/expectedv2.js | 2 +- .../expectedv2.js | 2 +- .../expectedv2.js | 2 +- .../event-handler-component/expectedv2.js | 2 +- .../expectedv2.js | 2 +- .../if-nested-slot-let-shadowed/expectedv2.js | 20 +++++------ .../samples/if-nested-slot-let/expectedv2.js | 8 ++--- .../quotes-inside-quotes/expectedv2.js | 4 +-- .../samples/svelte-fragment/expectedv2.js | 4 +-- .../attributes-foreign-ns/expectedv2.ts | 2 +- .../expectedv2.ts | 2 +- .../expectedv2.ts | 2 +- .../component-slot-let-forward/expectedv2.ts | 2 +- .../component-slot-nest-scope/expectedv2.ts | 2 +- .../component-slot-no-space/expectedv2.ts | 2 +- .../samples/const-tag-component/expectedv2.ts | 6 ++-- .../expectedv2.ts | 2 +- .../expectedv2.ts | 4 +-- .../expectedv2.ts | 2 +- .../event-bubble-component/expectedv2.ts | 2 +- .../samples/import-single-quote/expectedv2.ts | 2 +- .../script-style-like-component/expectedv2.ts | 4 +-- .../self-closing-component/expectedv2.ts | 2 +- .../samples/stores-mustache/expectedv2.ts | 2 +- .../expectedv2.ts | 2 +- .../expectedv2.ts | 2 +- .../uses-svelte-components/expectedv2.ts | 2 +- 61 files changed, 161 insertions(+), 116 deletions(-) create mode 100644 packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/component-invalid/expected.json create mode 100644 packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/component-invalid/expectedv2.json create mode 100644 packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/component-invalid/imported.svelte create mode 100644 packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/component-invalid/input.svelte rename packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/{element-attributes.only => element-attributes}/expected.json (100%) rename packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/{element-attributes.only => element-attributes}/expectedv2.json (100%) rename packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/{element-attributes.only => element-attributes}/input.svelte (100%) diff --git a/packages/language-server/src/plugins/typescript/features/CodeActionsProvider.ts b/packages/language-server/src/plugins/typescript/features/CodeActionsProvider.ts index 5a683ecdb..32326817c 100644 --- a/packages/language-server/src/plugins/typescript/features/CodeActionsProvider.ts +++ b/packages/language-server/src/plugins/typescript/features/CodeActionsProvider.ts @@ -194,24 +194,25 @@ export class CodeActionsProviderImpl implements CodeActionsProvider { const start = fragment.offsetAt(fragment.getGeneratedPosition(range.start)); const end = fragment.offsetAt(fragment.getGeneratedPosition(range.end)); const errorCodes: number[] = context.diagnostics.map((diag) => Number(diag.code)); - const codeFixes = lang.getCodeFixesAtPosition( - tsDoc.filePath, - start, - end, - errorCodes, - {}, - userPreferences - ); - - const componentQuickFix = errorCodes.includes(2304) // "Cannot find name '...'." - ? this.getComponentImportQuickFix(start, end, lang, tsDoc.filePath, userPreferences) ?? - [] - : []; + let codeFixes = errorCodes.includes(2304) // "Cannot find name '...'." + ? this.getComponentImportQuickFix(start, end, lang, tsDoc.filePath, userPreferences) + : undefined; + codeFixes = + // either-or situation + codeFixes || + lang.getCodeFixesAtPosition( + tsDoc.filePath, + start, + end, + errorCodes, + {}, + userPreferences + ); const docs = new SnapshotFragmentMap(this.lsAndTsDocResolver); docs.set(tsDoc.filePath, { fragment, snapshot: tsDoc }); - const codeActionsPromises = codeFixes.concat(componentQuickFix).map(async (fix) => { + const codeActionsPromises = codeFixes.map(async (fix) => { const documentChangesPromises = fix.changes.map(async (change) => { const { snapshot, fragment } = await docs.retrieve(change.fileName); return TextDocumentEdit.create( @@ -311,7 +312,7 @@ export class CodeActionsProviderImpl implements CodeActionsProvider { lang: ts.LanguageService, filePath: string, userPreferences: ts.UserPreferences - ): ts.CodeFixAction[] | undefined { + ): readonly ts.CodeFixAction[] | undefined { const sourceFile = lang.getProgram()?.getSourceFile(filePath); if (!sourceFile) { @@ -326,7 +327,10 @@ export class CodeActionsProviderImpl implements CodeActionsProvider { }, (node): node is ts.JsxOpeningLikeElement | ts.JsxClosingElement | ts.Identifier => this.configManager.getConfig().svelte.useNewTransformation - ? ts.isNewExpression(node.parent) && ts.isIdentifier(node) + ? ts.isCallExpression(node.parent) && + ts.isIdentifier(node.parent.expression) && + node.parent.expression.text === '__sveltets_2_ensureComponent' && + ts.isIdentifier(node) : ts.isJsxClosingElement(node) || ts.isJsxOpeningLikeElement(node) ); diff --git a/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts b/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts index aab37273a..5a4175cf3 100644 --- a/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts +++ b/packages/language-server/src/plugins/typescript/features/DiagnosticsProvider.ts @@ -267,16 +267,16 @@ function isNoJsxCannotHaveMultipleAttrsError(diagnostic: Diagnostic) { * Some diagnostics have JSX-specific nomenclature. Enhance them for more clarity. */ function enhanceIfNecessary(diagnostic: Diagnostic): Diagnostic { - if (diagnostic.code === DiagnosticCode.CANNOT_BE_USED_AS_JSX_COMPONENT) { + if ( + diagnostic.code === DiagnosticCode.CANNOT_BE_USED_AS_JSX_COMPONENT || + (diagnostic.code === DiagnosticCode.TYPE_X_NOT_ASSIGNABLE_TO_TYPE_Y && + diagnostic.message.includes('Svelte2TsxComponent')) + ) { return { ...diagnostic, message: 'Type definitions are missing for this Svelte Component. ' + - // eslint-disable-next-line max-len - "It needs a class definition with at least the property '$$prop_def' which should contain a map of input property definitions.\n" + - 'Example:\n' + - ' class ComponentName { $$prop_def: { propertyName: string; } }\n' + - 'If you are using Svelte 3.31+, use SvelteComponentTyped:\n' + + 'If you are using Svelte 3.31+, use SvelteComponentTyped to add a definition:\n' + ' import type { SvelteComponentTyped } from "svelte";\n' + ' class ComponentName extends SvelteComponentTyped<{propertyName: string;}> {}\n\n' + 'Underlying error:\n' + diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/component-invalid/expected.json b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/component-invalid/expected.json new file mode 100644 index 000000000..4034fa6cb --- /dev/null +++ b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/component-invalid/expected.json @@ -0,0 +1,13 @@ +[ + { + "range": { + "start": { "line": 13, "character": 1 }, + "end": { "line": 13, "character": 11 } + }, + "severity": 1, + "source": "ts", + "message": "Type definitions are missing for this Svelte Component. If you are using Svelte 3.31+, use SvelteComponentTyped to add a definition:\n import type { SvelteComponentTyped } from \"svelte\";\n class ComponentName extends SvelteComponentTyped<{propertyName: string;}> {}\n\nUnderlying error:\n'DoesntWork' cannot be used as a JSX component.\n Its instance type 'DoesntWork' is not a valid JSX element.\n Property '$$prop_def' is missing in type 'DoesntWork' but required in type 'ElementClass'.", + "code": 2786, + "tags": [] + } +] diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/component-invalid/expectedv2.json b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/component-invalid/expectedv2.json new file mode 100644 index 000000000..9f49e1b82 --- /dev/null +++ b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/component-invalid/expectedv2.json @@ -0,0 +1,13 @@ +[ + { + "range": { + "start": { "line": 13, "character": 1 }, + "end": { "line": 13, "character": 11 } + }, + "severity": 1, + "source": "ts", + "message": "Type definitions are missing for this Svelte Component. If you are using Svelte 3.31+, use SvelteComponentTyped to add a definition:\n import type { SvelteComponentTyped } from \"svelte\";\n class ComponentName extends SvelteComponentTyped<{propertyName: string;}> {}\n\nUnderlying error:\nArgument of type 'typeof DoesntWork' is not assignable to parameter of type 'new (args: { target: any; props?: any; }) => Svelte2TsxComponent'.\n Type 'DoesntWork' is missing the following properties from type 'Svelte2TsxComponent': $$prop_def, $$events_def, $$slot_def, $on, and 5 more.", + "code": 2345, + "tags": [] + } +] diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/component-invalid/imported.svelte b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/component-invalid/imported.svelte new file mode 100644 index 000000000..d07225ee4 --- /dev/null +++ b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/component-invalid/imported.svelte @@ -0,0 +1 @@ +

hi

diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/component-invalid/input.svelte b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/component-invalid/input.svelte new file mode 100644 index 000000000..8fd5465da --- /dev/null +++ b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/component-invalid/input.svelte @@ -0,0 +1,14 @@ + + + + + + + + diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/element-attributes.only/expected.json b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/element-attributes/expected.json similarity index 100% rename from packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/element-attributes.only/expected.json rename to packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/element-attributes/expected.json diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/element-attributes.only/expectedv2.json b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/element-attributes/expectedv2.json similarity index 100% rename from packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/element-attributes.only/expectedv2.json rename to packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/element-attributes/expectedv2.json diff --git a/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/element-attributes.only/input.svelte b/packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/element-attributes/input.svelte similarity index 100% rename from packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/element-attributes.only/input.svelte rename to packages/language-server/test/plugins/typescript/features/diagnostics/fixtures/element-attributes/input.svelte diff --git a/packages/svelte2tsx/src/htmlxtojsx_v2/nodes/InlineComponent.ts b/packages/svelte2tsx/src/htmlxtojsx_v2/nodes/InlineComponent.ts index 37504ffab..574223a8a 100644 --- a/packages/svelte2tsx/src/htmlxtojsx_v2/nodes/InlineComponent.ts +++ b/packages/svelte2tsx/src/htmlxtojsx_v2/nodes/InlineComponent.ts @@ -72,32 +72,32 @@ export class InlineComponent { this.addNameConstDeclaration = () => (this.startTransformation[0] = `{ const ${this._name} = __sveltets_2_createComponentAny({`); this.startEndTransformation.push('});'); - } else if (this.node.name === 'svelte:component') { - this._name = '$$_sveltecomponent' + this.computeDepth(); - this.startTransformation.push( - `{ const ${this._name}_ = new `, - [this.node.expression.start, this.node.expression.end], - '({ target: __sveltets_2_any(), props: {' - ); + } else { + const isSvelteComponentTag = this.node.name === 'svelte:component'; // We don't know if the thing we use to create the Svelte component with // is actually a proper Svelte component, which would lead to errors // when accessing things like $$prop_def. Therefore widen the type // here, falling back to a any-typed component to ensure the user doesn't // get weird follup-errors all over the place. The diagnostic error - // should still error on the new X() part. - this.startEndTransformation.push(`}});${this._name}_;`); - this.addNameConstDeclaration = () => - (this.startEndTransformation[0] = `}});const ${this._name} = __sveltets_2_typeAsComponent(${this._name}_);`); - } else { - this._name = '$$_' + this.node.name + this.computeDepth(); - const nodeNameStart = this.str.original.indexOf(this.node.name, this.node.start); + // will be on the __sveltets_2_ensureComponent part, giving a more helpful message + this._name = + '$$_' + + (isSvelteComponentTag ? 'sveltecomponent' : this.node.name) + + this.computeDepth(); + const constructorName = this._name + 'C'; + const nodeNameStart = isSvelteComponentTag + ? this.node.expression.start + : this.str.original.indexOf(this.node.name, this.node.start); + const nodeNameEnd = isSvelteComponentTag + ? this.node.expression.end + : nodeNameStart + this.node.name.length; this.startTransformation.push( - '{ new ', - [nodeNameStart, nodeNameStart + this.node.name.length], - '({ target: __sveltets_2_any(), props: {' + `{ const ${constructorName} = __sveltets_2_ensureComponent(`, + [nodeNameStart, nodeNameEnd], + `); new ${constructorName}({ target: __sveltets_2_any(), props: {` ); this.addNameConstDeclaration = () => - (this.startTransformation[0] = `{ const ${this._name} = new `); + (this.startTransformation[2] = `); const ${this._name} = new ${constructorName}({ target: __sveltets_2_any(), props: {`); this.startEndTransformation.push('}});'); } } diff --git a/packages/svelte2tsx/svelte-shims.d.ts b/packages/svelte2tsx/svelte-shims.d.ts index e7320188c..348810bb0 100644 --- a/packages/svelte2tsx/svelte-shims.d.ts +++ b/packages/svelte2tsx/svelte-shims.d.ts @@ -254,6 +254,6 @@ declare function __sveltets_2_ensureTransition(transitionCall: __sveltets_2_Svel declare function __sveltets_2_ensureType(type: AConstructorTypeOf, el: T): {}; -declare function __sveltets_2_typeAsComponent(c: Component): Component extends Svelte2TsxComponent ? Component : Svelte2TsxComponent; +declare function __sveltets_2_ensureComponent Svelte2TsxComponent>(type: T): T extends never ? Svelte2TsxComponent : T; declare function __sveltets_2_ensureArray>(array: T): T extends ArrayLike ? U[] : any[]; diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-bare/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-bare/expectedv2.js index a357b643d..2418099cc 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-bare/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-bare/expectedv2.js @@ -1 +1 @@ - { new SomeComponent({ target: __sveltets_2_any(), props: {"relaxed":true,}});} \ No newline at end of file + { const $$_SomeComponent0C = __sveltets_2_ensureComponent(SomeComponent); new $$_SomeComponent0C({ target: __sveltets_2_any(), props: {"relaxed":true,}});} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-foreign-ns/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-foreign-ns/expectedv2.js index 022ae41da..4c723071f 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-foreign-ns/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-foreign-ns/expectedv2.js @@ -1,2 +1,2 @@ - { new SomeComponent({ target: __sveltets_2_any(), props: { "attrName":"text","attrCase":"text",}});} + { const $$_SomeComponent0C = __sveltets_2_ensureComponent(SomeComponent); new $$_SomeComponent0C({ target: __sveltets_2_any(), props: { "attrName":"text","attrCase":"text",}});} { svelteHTML.createElement("someelement", { "attrName":"text","attrCase":true,});} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-invalid-jsx-name/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-invalid-jsx-name/expectedv2.js index 0a95e884a..b7a3d2885 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-invalid-jsx-name/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-invalid-jsx-name/expectedv2.js @@ -1,2 +1,2 @@ - { new Hello({ target: __sveltets_2_any(), props: { "|-wtf":"foo",}}); Hello} + { const $$_Hello0C = __sveltets_2_ensureComponent(Hello); new $$_Hello0C({ target: __sveltets_2_any(), props: { "|-wtf":"foo",}}); Hello} { svelteHTML.createElement("div", { "--custom-prop":"foo",}); } \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-multiple/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-multiple/expectedv2.js index 2b70d39b9..66f59b449 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-multiple/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-multiple/expectedv2.js @@ -1 +1 @@ - { new SomeComponent({ target: __sveltets_2_any(), props: { "attr":`text ${value}`,"attrd":`t${thing}`,"attrdd":`t${thing}`,}});} \ No newline at end of file + { const $$_SomeComponent0C = __sveltets_2_ensureComponent(SomeComponent); new $$_SomeComponent0C({ target: __sveltets_2_any(), props: { "attr":`text ${value}`,"attrd":`t${thing}`,"attrdd":`t${thing}`,}});} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-nullish-coalescing/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-nullish-coalescing/expectedv2.js index 3306115aa..6619d1348 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-nullish-coalescing/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-nullish-coalescing/expectedv2.js @@ -1 +1 @@ - { new SomeComponent({ target: __sveltets_2_any(), props: { "attr":obj ?? 'shorthand',}});} \ No newline at end of file + { const $$_SomeComponent0C = __sveltets_2_ensureComponent(SomeComponent); new $$_SomeComponent0C({ target: __sveltets_2_any(), props: { "attr":obj ?? 'shorthand',}});} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-number/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-number/expectedv2.js index 509532e82..1df385a55 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-number/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-number/expectedv2.js @@ -1,2 +1,2 @@ - { new SomeComponent({ target: __sveltets_2_any(), props: { "tabindex":"1",}});} + { const $$_SomeComponent0C = __sveltets_2_ensureComponent(SomeComponent); new $$_SomeComponent0C({ target: __sveltets_2_any(), props: { "tabindex":"1",}});} { svelteHTML.createElement("div", { "tabindex":1,"maxlength":1,"minlength":1,"span":1,"role":"none",}); } \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-optional-chaining/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-optional-chaining/expectedv2.js index e9e465858..6f58ad688 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-optional-chaining/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-optional-chaining/expectedv2.js @@ -1 +1 @@ - { new SomeComponent({ target: __sveltets_2_any(), props: { "attr":obj?.shorthand,}});} \ No newline at end of file + { const $$_SomeComponent0C = __sveltets_2_ensureComponent(SomeComponent); new $$_SomeComponent0C({ target: __sveltets_2_any(), props: { "attr":obj?.shorthand,}});} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-quoted/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-quoted/expectedv2.js index 2696a6ba7..07256c8bb 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-quoted/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-quoted/expectedv2.js @@ -1,2 +1,2 @@ - { new SomeComponent({ target: __sveltets_2_any(), props: { "attr":shorthand,}});} - { new SomeComponent({ target: __sveltets_2_any(), props: { "attr":shorthand,}});} \ No newline at end of file + { const $$_SomeComponent0C = __sveltets_2_ensureComponent(SomeComponent); new $$_SomeComponent0C({ target: __sveltets_2_any(), props: { "attr":shorthand,}});} + { const $$_SomeComponent0C = __sveltets_2_ensureComponent(SomeComponent); new $$_SomeComponent0C({ target: __sveltets_2_any(), props: { "attr":shorthand,}});} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-shorthand/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-shorthand/expectedv2.js index 9219f5d8e..bf3691d4f 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-shorthand/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-shorthand/expectedv2.js @@ -1 +1 @@ - { new SomeComponent({ target: __sveltets_2_any(), props: { shorthand,}});} \ No newline at end of file + { const $$_SomeComponent0C = __sveltets_2_ensureComponent(SomeComponent); new $$_SomeComponent0C({ target: __sveltets_2_any(), props: { shorthand,}});} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-text/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-text/expectedv2.js index 54322c2e5..540aca913 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-text/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/attribute-text/expectedv2.js @@ -1 +1 @@ - { new SomeComponent({ target: __sveltets_2_any(), props: { "attr":"text","attrtwo":"text",}});} \ No newline at end of file + { const $$_SomeComponent0C = __sveltets_2_ensureComponent(SomeComponent); new $$_SomeComponent0C({ target: __sveltets_2_any(), props: { "attr":"text","attrtwo":"text",}});} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/binding-this-component/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/binding-this-component/expectedv2.js index e1d879be0..6fe1a8d64 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/binding-this-component/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/binding-this-component/expectedv2.js @@ -1 +1 @@ - { const $$_Component0 = new Component({ target: __sveltets_2_any(), props: { "type":"radio","value":"Plain",}});element = $$_Component0;} \ No newline at end of file + { const $$_Component0C = __sveltets_2_ensureComponent(Component); const $$_Component0 = new $$_Component0C({ target: __sveltets_2_any(), props: { "type":"radio","value":"Plain",}});element = $$_Component0;} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/binding-this-svelte-component/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/binding-this-svelte-component/expectedv2.js index 997257ab7..69f7a484f 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/binding-this-svelte-component/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/binding-this-svelte-component/expectedv2.js @@ -1 +1 @@ - { const $$_sveltecomponent0_ = new A({ target: __sveltets_2_any(), props: { }});const $$_sveltecomponent0 = __sveltets_2_typeAsComponent($$_sveltecomponent0_);element = $$_sveltecomponent0;} \ No newline at end of file + { const $$_sveltecomponent0C = __sveltets_2_ensureComponent(A); const $$_sveltecomponent0 = new $$_sveltecomponent0C({ target: __sveltets_2_any(), props: { }});element = $$_sveltecomponent0;} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/component-default-slot-empty/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/component-default-slot-empty/expectedv2.js index f9108c5a7..0bec02503 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/component-default-slot-empty/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/component-default-slot-empty/expectedv2.js @@ -1 +1 @@ - { const $$_Component0 = new Component({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,var:new_var,other_var,} = $$_Component0.$$slot_def.default;$$_$$; }Component} \ No newline at end of file + { const $$_Component0C = __sveltets_2_ensureComponent(Component); const $$_Component0 = new $$_Component0C({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,var:new_var,other_var,} = $$_Component0.$$slot_def.default;$$_$$; }Component} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/component-default-slot-let-destructure/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/component-default-slot-let-destructure/expectedv2.js index a329bc234..81612fd1f 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/component-default-slot-let-destructure/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/component-default-slot-let-destructure/expectedv2.js @@ -1,3 +1,3 @@ - { const $$_Component0 = new Component({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,thing:{ a },} = $$_Component0.$$slot_def.default;$$_$$; + { const $$_Component0C = __sveltets_2_ensureComponent(Component); const $$_Component0 = new $$_Component0C({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,thing:{ a },} = $$_Component0.$$slot_def.default;$$_$$; { svelteHTML.createElement("h1", {}); a ; } }Component} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/component-default-slot-let/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/component-default-slot-let/expectedv2.js index 96c3970c0..1d8af41cc 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/component-default-slot-let/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/component-default-slot-let/expectedv2.js @@ -1,3 +1,3 @@ - { const $$_Component0 = new Component({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,name:n,thing,} = $$_Component0.$$slot_def.default;$$_$$; + { const $$_Component0C = __sveltets_2_ensureComponent(Component); const $$_Component0 = new $$_Component0C({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,name:n,thing,} = $$_Component0.$$slot_def.default;$$_$$; { svelteHTML.createElement("h1", {}); thing; n; } }Component} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/component-default-slot/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/component-default-slot/expectedv2.js index 52d8df9ea..cdbe8c76a 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/component-default-slot/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/component-default-slot/expectedv2.js @@ -1,3 +1,3 @@ - { new Component({ target: __sveltets_2_any(), props: {}}); + { const $$_Component0C = __sveltets_2_ensureComponent(Component); new $$_Component0C({ target: __sveltets_2_any(), props: {}}); { svelteHTML.createElement("h1", {}); } Component} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/component-multi-slot/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/component-multi-slot/expectedv2.js index 781b52bd0..d0a63856c 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/component-multi-slot/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/component-multi-slot/expectedv2.js @@ -1,4 +1,4 @@ - { const $$_Component0 = new Component({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,var:new_var,} = $$_Component0.$$slot_def.default;$$_$$; + { const $$_Component0C = __sveltets_2_ensureComponent(Component); const $$_Component0 = new $$_Component0C({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,var:new_var,} = $$_Component0.$$slot_def.default;$$_$$; { svelteHTML.createElement("h1", {}); new_var; } {const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,slotvar:newvar,} = $$_Component0.$$slot_def["someslot"];$$_$$;{ svelteHTML.createElement("div", { });newvar; { svelteHTML.createElement("h2", {}); newvar; } diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/component-named-slot/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/component-named-slot/expectedv2.js index 070f1306b..3618214b1 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/component-named-slot/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/component-named-slot/expectedv2.js @@ -1,8 +1,8 @@ - { const $$_Parent0 = new Parent({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,foo,bar:baz,} = $$_Parent0.$$slot_def.default;$$_$$; - {const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,bla,} = $$_Parent0.$$slot_def["named"];$$_$$;{ new Component({ target: __sveltets_2_any(), props: { }}); + { const $$_Parent0C = __sveltets_2_ensureComponent(Parent); const $$_Parent0 = new $$_Parent0C({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,foo,bar:baz,} = $$_Parent0.$$slot_def.default;$$_$$; + {const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,bla,} = $$_Parent0.$$slot_def["named"];$$_$$;{ const $$_Component1C = __sveltets_2_ensureComponent(Component); new $$_Component1C({ target: __sveltets_2_any(), props: { }}); foo; baz; bla; }Component} - { const $$_Component1 = new Component({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,blubb,} = $$_Component1.$$slot_def.default;$$_$$; + { const $$_Component1C = __sveltets_2_ensureComponent(Component); const $$_Component1 = new $$_Component1C({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,blubb,} = $$_Component1.$$slot_def.default;$$_$$; blubb; }Component} }Parent} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/component-no-slots/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/component-no-slots/expectedv2.js index 62594861a..4f01626cf 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/component-no-slots/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/component-no-slots/expectedv2.js @@ -1,2 +1,2 @@ - { new Component({ target: __sveltets_2_any(), props: { "someProp":true,}}); Component} - { new Component({ target: __sveltets_2_any(), props: { "someProp":true,}});} \ No newline at end of file + { const $$_Component0C = __sveltets_2_ensureComponent(Component); new $$_Component0C({ target: __sveltets_2_any(), props: { "someProp":true,}}); Component} + { const $$_Component0C = __sveltets_2_ensureComponent(Component); new $$_Component0C({ target: __sveltets_2_any(), props: { "someProp":true,}});} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/component-slot-infer-props/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/component-slot-infer-props/expectedv2.js index 4be14d038..c5b3e2b2e 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/component-slot-infer-props/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/component-slot-infer-props/expectedv2.js @@ -1,5 +1,5 @@ - { const $$_Parent0 = new Parent({ target: __sveltets_2_any(), props: { "bare":true,shorthand,"text1":"val1","text2":"val2","text3":`a${a}b${b}`,"textEmpty":"","literal":true,"strLiteral":'foo',"complex":{a},"a-dashed-complex":{a},...__sveltets_2_cssProp({"--custom-cssprop":"foo"}),}});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,foo,} = $$_Parent0.$$slot_def.default;$$_$$; - {const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,bar,} = $$_Parent0.$$slot_def["named"];$$_$$;{ new Component({ target: __sveltets_2_any(), props: { }}); + { const $$_Parent0C = __sveltets_2_ensureComponent(Parent); const $$_Parent0 = new $$_Parent0C({ target: __sveltets_2_any(), props: { "bare":true,shorthand,"text1":"val1","text2":"val2","text3":`a${a}b${b}`,"textEmpty":"","literal":true,"strLiteral":'foo',"complex":{a},"a-dashed-complex":{a},...__sveltets_2_cssProp({"--custom-cssprop":"foo"}),}});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,foo,} = $$_Parent0.$$slot_def.default;$$_$$; + {const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,bar,} = $$_Parent0.$$slot_def["named"];$$_$$;{ const $$_Component1C = __sveltets_2_ensureComponent(Component); new $$_Component1C({ target: __sveltets_2_any(), props: { }}); foo; bar; }Component} { svelteHTML.createElement("div", {}); diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/component-slot-shadowed-prop/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/component-slot-shadowed-prop/expectedv2.js index f0da6f1c0..89d8de744 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/component-slot-shadowed-prop/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/component-slot-shadowed-prop/expectedv2.js @@ -1,7 +1,7 @@ - { const $$_Component0 = new Component({ target: __sveltets_2_any(), props: { unshadowed1,"foo":unshadowed2,subthing,shadowed1,"shadowed-2":shadowed2,"templateString":` ${complex} `,"complex":{complex},}});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,name:n,shadowed1,shadowed2,subthing,} = $$_Component0.$$slot_def.default;$$_$$; + { const $$_Component0C = __sveltets_2_ensureComponent(Component); const $$_Component0 = new $$_Component0C({ target: __sveltets_2_any(), props: { unshadowed1,"foo":unshadowed2,subthing,shadowed1,"shadowed-2":shadowed2,"templateString":` ${complex} `,"complex":{complex},}});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,name:n,shadowed1,shadowed2,subthing,} = $$_Component0.$$slot_def.default;$$_$$; {const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,subthing,} = $$_Component0.$$slot_def["sub1"];$$_$$;{ svelteHTML.createElement("p", { });thing;subthing; }} - {const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,subthing,othersubthing,} = $$_Component0.$$slot_def["sub2"];$$_$$;{ new Sub({ target: __sveltets_2_any(), props: { subthing,}});thing;subthing; }Sub} + {const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,subthing,othersubthing,} = $$_Component0.$$slot_def["sub2"];$$_$$;{ const $$_Sub1C = __sveltets_2_ensureComponent(Sub); new $$_Sub1C({ target: __sveltets_2_any(), props: { subthing,}});thing;subthing; }Sub} - { const $$_Sub1 = new Sub({ target: __sveltets_2_any(), props: { subthing,}});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,subthing,othersubthing,} = $$_Sub1.$$slot_def.default;$$_$$;thing;subthing; }Sub} + { const $$_Sub1C = __sveltets_2_ensureComponent(Sub); const $$_Sub1 = new $$_Sub1C({ target: __sveltets_2_any(), props: { subthing,}});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,subthing,othersubthing,} = $$_Sub1.$$slot_def.default;$$_$$;thing;subthing; }Sub} }Component} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/custom-css-properties/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/custom-css-properties/expectedv2.js index c70e7e3ec..d609b1b68 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/custom-css-properties/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/custom-css-properties/expectedv2.js @@ -1 +1 @@ - { new Component({ target: __sveltets_2_any(), props: { ...__sveltets_2_cssProp({"--custom-css-property1":'hi'}),...__sveltets_2_cssProp({"--custom-css-property2":"hi"}),"betweenprop":true,...__sveltets_2_cssProp({"--custom-css-property3":`hi${jo}hi`}),...__sveltets_2_cssProp({"--custom-css-property4":`hi${jo}hi`}),...__sveltets_2_cssProp({"--custom-css-property5":`hi${jo}hi`}),}});} \ No newline at end of file + { const $$_Component0C = __sveltets_2_ensureComponent(Component); new $$_Component0C({ target: __sveltets_2_any(), props: { ...__sveltets_2_cssProp({"--custom-css-property1":'hi'}),...__sveltets_2_cssProp({"--custom-css-property2":"hi"}),"betweenprop":true,...__sveltets_2_cssProp({"--custom-css-property3":`hi${jo}hi`}),...__sveltets_2_cssProp({"--custom-css-property4":`hi${jo}hi`}),...__sveltets_2_cssProp({"--custom-css-property5":`hi${jo}hi`}),}});} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/directive-quoted/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/directive-quoted/expectedv2.js index 47627b9ae..6b1b60b5a 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/directive-quoted/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/directive-quoted/expectedv2.js @@ -1,5 +1,5 @@ { svelteHTML.createElement("h1", { "onclick":()=>console.log("click"),}); } - { const $$_Component0 = new Component({ target: __sveltets_2_any(), props: { }});$$_Component0.$on("click", test);} + { const $$_Component0C = __sveltets_2_ensureComponent(Component); const $$_Component0 = new $$_Component0C({ target: __sveltets_2_any(), props: { }});$$_Component0.$on("click", test);} { svelteHTML.createElement("img", { });__sveltets_2_ensureAction(action(svelteHTML.mapElementTag('img'),(thing)));} { svelteHTML.createElement("img", { });__sveltets_2_ensureTransition(fade(svelteHTML.mapElementTag('img'),(params)));} { svelteHTML.createElement("img", { });classthing;} diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/editing-mustache/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/editing-mustache/expectedv2.js index 9dfae7a2c..9184d4519 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/editing-mustache/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/editing-mustache/expectedv2.js @@ -2,5 +2,5 @@ abc. ; abc?. ; abc ?; a+; - { new Component({ target: __sveltets_2_any(), props: { "regex":/.*/,}});} + { const $$_Component0C = __sveltets_2_ensureComponent(Component); new $$_Component0C({ target: __sveltets_2_any(), props: { "regex":/.*/,}});} { svelteHTML.createElement("span", {}); } \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/event-handler-component-bare/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/event-handler-component-bare/expectedv2.js index 9dbfd77c9..e03ae5176 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/event-handler-component-bare/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/event-handler-component-bare/expectedv2.js @@ -1 +1 @@ - { const $$_Component0 = new Component({ target: __sveltets_2_any(), props: { }});$$_Component0.$on("click", () => {});} \ No newline at end of file + { const $$_Component0C = __sveltets_2_ensureComponent(Component); const $$_Component0 = new $$_Component0C({ target: __sveltets_2_any(), props: { }});$$_Component0.$on("click", () => {});} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/event-handler-component-infer-props/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/event-handler-component-infer-props/expectedv2.js index b1393ec98..fb1e8cd0c 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/event-handler-component-infer-props/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/event-handler-component-infer-props/expectedv2.js @@ -1 +1 @@ - { const $$_Component0 = new Component({ target: __sveltets_2_any(), props: { "bare":true,shorthand,"text1":"val1","text2":"val2","text3":`a${a}b${b}`,"textEmpty":"","literal":true,"strLiteral":'foo',"complex":{a},"a-dashed-complex":{a},...__sveltets_2_cssProp({"--custom-cssprop":"foo"}),}});$$_Component0.$on("click", e => e);} \ No newline at end of file + { const $$_Component0C = __sveltets_2_ensureComponent(Component); const $$_Component0 = new $$_Component0C({ target: __sveltets_2_any(), props: { "bare":true,shorthand,"text1":"val1","text2":"val2","text3":`a${a}b${b}`,"textEmpty":"","literal":true,"strLiteral":'foo',"complex":{a},"a-dashed-complex":{a},...__sveltets_2_cssProp({"--custom-cssprop":"foo"}),}});$$_Component0.$on("click", e => e);} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/event-handler-component/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/event-handler-component/expectedv2.js index e3fa11784..a44ea3ff9 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/event-handler-component/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/event-handler-component/expectedv2.js @@ -1 +1 @@ - { const $$_Component0 = new Component({ target: __sveltets_2_any(), props: { }});$$_Component0.$on("event", () => click());$$_Component0.$on("UpperCaseEvent", () => log('hi'));} \ No newline at end of file + { const $$_Component0C = __sveltets_2_ensureComponent(Component); const $$_Component0 = new $$_Component0C({ target: __sveltets_2_any(), props: { }});$$_Component0.$on("event", () => click());$$_Component0.$on("UpperCaseEvent", () => log('hi'));} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/event-handler-svelte-component/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/event-handler-svelte-component/expectedv2.js index 1e5b708d1..3f4e4257a 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/event-handler-svelte-component/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/event-handler-svelte-component/expectedv2.js @@ -1 +1 @@ - { const $$_sveltecomponent0_ = new Whatever({ target: __sveltets_2_any(), props: { }});const $$_sveltecomponent0 = __sveltets_2_typeAsComponent($$_sveltecomponent0_);$$_sveltecomponent0.$on("submit", handleSubmit);} \ No newline at end of file + { const $$_sveltecomponent0C = __sveltets_2_ensureComponent(Whatever); const $$_sveltecomponent0 = new $$_sveltecomponent0C({ target: __sveltets_2_any(), props: { }});$$_sveltecomponent0.$on("submit", handleSubmit);} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/if-nested-slot-let-shadowed/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/if-nested-slot-let-shadowed/expectedv2.js index e5fa4bd5e..c74d61293 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/if-nested-slot-let-shadowed/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/if-nested-slot-let-shadowed/expectedv2.js @@ -1,12 +1,12 @@ if(hello && hello1){ - { const $$_Comp0 = new Comp({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,hello,} = $$_Comp0.$$slot_def.default;$$_$$; + { const $$_Comp0C = __sveltets_2_ensureComponent(Comp); const $$_Comp0 = new $$_Comp0C({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,hello,} = $$_Comp0.$$slot_def.default;$$_$$; hello; - { const $$_Comp1 = new Comp({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,hello,} = $$_Comp1.$$slot_def.default;$$_$$; + { const $$_Comp1C = __sveltets_2_ensureComponent(Comp); const $$_Comp1 = new $$_Comp1C({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,hello,} = $$_Comp1.$$slot_def.default;$$_$$; if(hello){ hello; } }Comp} - { const $$_Comp1 = new Comp({ target: __sveltets_2_any(), props: { hello,}});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,hello,} = $$_Comp1.$$slot_def.default;$$_$$; + { const $$_Comp1C = __sveltets_2_ensureComponent(Comp); const $$_Comp1 = new $$_Comp1C({ target: __sveltets_2_any(), props: { hello,}});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,hello,} = $$_Comp1.$$slot_def.default;$$_$$; if(hello){ hello; } @@ -21,18 +21,18 @@ if(hello && hello1){ hello; } }} - {const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,hello,} = $$_Comp0.$$slot_def["named3"];$$_$$;{ new Comp({ target: __sveltets_2_any(), props: { }}); + {const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,hello,} = $$_Comp0.$$slot_def["named3"];$$_$$;{ const $$_Comp1C = __sveltets_2_ensureComponent(Comp); new $$_Comp1C({ target: __sveltets_2_any(), props: { }}); if(hello){ hello; } }Comp} if(hello){ - { const $$_Comp1 = new Comp({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,hello,} = $$_Comp1.$$slot_def.default;$$_$$; + { const $$_Comp1C = __sveltets_2_ensureComponent(Comp); const $$_Comp1 = new $$_Comp1C({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,hello,} = $$_Comp1.$$slot_def.default;$$_$$; if(hello){ hello; } }Comp} - { const $$_Comp1 = new Comp({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,foo,} = $$_Comp1.$$slot_def.default;$$_$$; + { const $$_Comp1C = __sveltets_2_ensureComponent(Comp); const $$_Comp1 = new $$_Comp1C({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,foo,} = $$_Comp1.$$slot_def.default;$$_$$; const hello = foo; if(hello){ hello; @@ -41,17 +41,17 @@ if(hello && hello1){ } }Comp} if(hi && bye){ - { const $$_Comp0 = new Comp({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,foo:bye,} = $$_Comp0.$$slot_def.default;$$_$$; + { const $$_Comp0C = __sveltets_2_ensureComponent(Comp); const $$_Comp0 = new $$_Comp0C({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,foo:bye,} = $$_Comp0.$$slot_def.default;$$_$$; bye; }Comp} } else if (cool){ - { const $$_Comp0 = new Comp({ target: __sveltets_2_any(), props: {}}); + { const $$_Comp0C = __sveltets_2_ensureComponent(Comp); const $$_Comp0 = new $$_Comp0C({ target: __sveltets_2_any(), props: {}}); {const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,cool,hello,} = $$_Comp0.$$slot_def["named"];$$_$$;{ svelteHTML.createElement("div", { }); hello; }} Comp} }else{ - { const $$_Comp0 = new Comp({ target: __sveltets_2_any(), props: {}}); + { const $$_Comp0C = __sveltets_2_ensureComponent(Comp); const $$_Comp0 = new $$_Comp0C({ target: __sveltets_2_any(), props: {}}); {const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,foo:hello,hello1:other,} = $$_Comp0.$$slot_def["named"];$$_$$;{ svelteHTML.createElement("div", { }); hello; }} @@ -59,7 +59,7 @@ if(hello && hello1){ } } - { const $$_Comp0 = new Comp({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,hello,} = $$_Comp0.$$slot_def.default;$$_$$; + { const $$_Comp0C = __sveltets_2_ensureComponent(Comp); const $$_Comp0 = new $$_Comp0C({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,hello,} = $$_Comp0.$$slot_def.default;$$_$$; if(hello && bye){ hello; bye; } else if (hello && bye){ diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/if-nested-slot-let/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/if-nested-slot-let/expectedv2.js index f96f6bd52..64bd6d2fa 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/if-nested-slot-let/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/if-nested-slot-let/expectedv2.js @@ -1,19 +1,19 @@ if(hello){ - { const $$_Comp0 = new Comp({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,foo,} = $$_Comp0.$$slot_def.default;$$_$$; + { const $$_Comp0C = __sveltets_2_ensureComponent(Comp); const $$_Comp0 = new $$_Comp0C({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,foo,} = $$_Comp0.$$slot_def.default;$$_$$; foo; }Comp} if(hi && bye){ - { const $$_Comp0 = new Comp({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,foo:bar,} = $$_Comp0.$$slot_def.default;$$_$$; + { const $$_Comp0C = __sveltets_2_ensureComponent(Comp); const $$_Comp0 = new $$_Comp0C({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,foo:bar,} = $$_Comp0.$$slot_def.default;$$_$$; bar; }Comp} } else if (cool){ - { const $$_Comp0 = new Comp({ target: __sveltets_2_any(), props: {}}); + { const $$_Comp0C = __sveltets_2_ensureComponent(Comp); const $$_Comp0 = new $$_Comp0C({ target: __sveltets_2_any(), props: {}}); {const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,foo,foo1,} = $$_Comp0.$$slot_def["named"];$$_$$;{ svelteHTML.createElement("div", { }); foo; }} Comp} }else{ - { const $$_Comp0 = new Comp({ target: __sveltets_2_any(), props: {}}); + { const $$_Comp0C = __sveltets_2_ensureComponent(Comp); const $$_Comp0 = new $$_Comp0C({ target: __sveltets_2_any(), props: {}}); {const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,foo:bar,} = $$_Comp0.$$slot_def["named"];$$_$$;{ svelteHTML.createElement("div", { }); bar; }} diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/quotes-inside-quotes/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/quotes-inside-quotes/expectedv2.js index 19ee26e8b..5dfce594e 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/quotes-inside-quotes/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/quotes-inside-quotes/expectedv2.js @@ -1,2 +1,2 @@ - { const $$_Component0 = new Component({ target: __sveltets_2_any(), props: { "placeholder":"'",}});$$_Component0.$on("keydown", () => {});} - { const $$_Component0 = new Component({ target: __sveltets_2_any(), props: { "placeholder":'"',}});$$_Component0.$on("keydown", () => {});} \ No newline at end of file + { const $$_Component0C = __sveltets_2_ensureComponent(Component); const $$_Component0 = new $$_Component0C({ target: __sveltets_2_any(), props: { "placeholder":"'",}});$$_Component0.$on("keydown", () => {});} + { const $$_Component0C = __sveltets_2_ensureComponent(Component); const $$_Component0 = new $$_Component0C({ target: __sveltets_2_any(), props: { "placeholder":'"',}});$$_Component0.$on("keydown", () => {});} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/svelte-fragment/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/svelte-fragment/expectedv2.js index 09a9bdc61..abf40a1c5 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/svelte-fragment/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/svelte-fragment/expectedv2.js @@ -1,4 +1,4 @@ - { const $$_Component0 = new Component({ target: __sveltets_2_any(), props: {}}); + { const $$_Component0C = __sveltets_2_ensureComponent(Component); const $$_Component0 = new $$_Component0C({ target: __sveltets_2_any(), props: {}}); { svelteHTML.createElement("sveltefragment", {}); { svelteHTML.createElement("p", {}); } } @@ -8,7 +8,7 @@ }} Component} - { const $$_Component0 = new Component({ target: __sveltets_2_any(), props: {}}); + { const $$_Component0C = __sveltets_2_ensureComponent(Component); const $$_Component0 = new $$_Component0C({ target: __sveltets_2_any(), props: {}}); {const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,foo,bar:baz,} = $$_Component0.$$slot_def.default;$$_$$;{ svelteHTML.createElement("sveltefragment", { }); { svelteHTML.createElement("p", {});foo; baz; } }} diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/attributes-foreign-ns/expectedv2.ts b/packages/svelte2tsx/test/svelte2tsx/samples/attributes-foreign-ns/expectedv2.ts index ce28e9889..034c48d6a 100644 --- a/packages/svelte2tsx/test/svelte2tsx/samples/attributes-foreign-ns/expectedv2.ts +++ b/packages/svelte2tsx/test/svelte2tsx/samples/attributes-foreign-ns/expectedv2.ts @@ -1,7 +1,7 @@ /// ;function render() { async () => { { svelteHTML.createElement("element", { "someAttr":"hi","someOtherAttribute":"there",}); } - { new Component({ target: __sveltets_2_any(), props: { "someAttr":"5","otherAttr":6,}});}}; + { const $$_Component0C = __sveltets_2_ensureComponent(Component); new $$_Component0C({ target: __sveltets_2_any(), props: { "someAttr":"5","otherAttr":6,}});}}; return { props: {}, slots: {}, getters: {}, events: {} }} export default class Input__SvelteComponent_ extends __sveltets_1_createSvelte2TsxComponent(__sveltets_1_partial(__sveltets_1_with_any_event(render()))) { diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/component-slot-forward-with-props/expectedv2.ts b/packages/svelte2tsx/test/svelte2tsx/samples/component-slot-forward-with-props/expectedv2.ts index e1109db30..32d7eb6eb 100644 --- a/packages/svelte2tsx/test/svelte2tsx/samples/component-slot-forward-with-props/expectedv2.ts +++ b/packages/svelte2tsx/test/svelte2tsx/samples/component-slot-forward-with-props/expectedv2.ts @@ -1,7 +1,7 @@ /// ;function render() { /*Ωignore_startΩ*/;const __sveltets_createSlot = __sveltets_2_createCreateSlot();/*Ωignore_endΩ*/ -async () => { { const $$_Parent0 = new Parent({ target: __sveltets_2_any(), props: { "propA":true,propB,"propC":"val1","propD":"val2","propE":`a${a}b${b}`,}});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,foo,} = $$_Parent0.$$slot_def.default;$$_$$; +async () => { { const $$_Parent0C = __sveltets_2_ensureComponent(Parent); const $$_Parent0 = new $$_Parent0C({ target: __sveltets_2_any(), props: { "propA":true,propB,"propC":"val1","propD":"val2","propE":`a${a}b${b}`,}});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,foo,} = $$_Parent0.$$slot_def.default;$$_$$; { __sveltets_createSlot("default", { foo,});} }Parent}}; return { props: {}, slots: {'default': {foo:__sveltets_1_instanceOf(Parent).$$slot_def['default'].foo}}, getters: {}, events: {} }} diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/component-slot-let-forward-named-slot/expectedv2.ts b/packages/svelte2tsx/test/svelte2tsx/samples/component-slot-let-forward-named-slot/expectedv2.ts index ca10cee5b..8d627fea5 100644 --- a/packages/svelte2tsx/test/svelte2tsx/samples/component-slot-let-forward-named-slot/expectedv2.ts +++ b/packages/svelte2tsx/test/svelte2tsx/samples/component-slot-let-forward-named-slot/expectedv2.ts @@ -1,7 +1,7 @@ /// ;function render() { /*Ωignore_startΩ*/;const __sveltets_createSlot = __sveltets_2_createCreateSlot();/*Ωignore_endΩ*/ -async () => { { const $$_Component0 = new Component({ target: __sveltets_2_any(), props: {}}); +async () => { { const $$_Component0C = __sveltets_2_ensureComponent(Component); const $$_Component0 = new $$_Component0C({ target: __sveltets_2_any(), props: {}}); {const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,a,} = $$_Component0.$$slot_def["b"];$$_$$;{ svelteHTML.createElement("div", { }); { __sveltets_createSlot("default", { a,}); } }} diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/component-slot-let-forward/expectedv2.ts b/packages/svelte2tsx/test/svelte2tsx/samples/component-slot-let-forward/expectedv2.ts index 64bda9a39..81546cabe 100644 --- a/packages/svelte2tsx/test/svelte2tsx/samples/component-slot-let-forward/expectedv2.ts +++ b/packages/svelte2tsx/test/svelte2tsx/samples/component-slot-let-forward/expectedv2.ts @@ -1,7 +1,7 @@ /// ;function render() { /*Ωignore_startΩ*/;const __sveltets_createSlot = __sveltets_2_createCreateSlot();/*Ωignore_endΩ*/ -async () => { { const $$_Component0 = new Component({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,name:n,thing,whatever:{ bla },} = $$_Component0.$$slot_def.default;$$_$$; +async () => { { const $$_Component0C = __sveltets_2_ensureComponent(Component); const $$_Component0 = new $$_Component0C({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,name:n,thing,whatever:{ bla },} = $$_Component0.$$slot_def.default;$$_$$; { __sveltets_createSlot("default", { n,thing,bla,});} }Component}}; return { props: {}, slots: {'default': {n:__sveltets_1_instanceOf(Component).$$slot_def['default'].name, thing:__sveltets_1_instanceOf(Component).$$slot_def['default'].thing, bla:(({ bla }) => bla)(__sveltets_1_instanceOf(Component).$$slot_def['default'].whatever)}}, getters: {}, events: {} }} diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/component-slot-nest-scope/expectedv2.ts b/packages/svelte2tsx/test/svelte2tsx/samples/component-slot-nest-scope/expectedv2.ts index 0078e2956..ee31dc262 100644 --- a/packages/svelte2tsx/test/svelte2tsx/samples/component-slot-nest-scope/expectedv2.ts +++ b/packages/svelte2tsx/test/svelte2tsx/samples/component-slot-nest-scope/expectedv2.ts @@ -7,7 +7,7 @@ async () => { for(const item of __sveltets_2_ensureArray(items)){ } { __sveltets_createSlot("second", { a,}); } } - { const $$_Component0 = new Component({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,c,} = $$_Component0.$$slot_def.default;$$_$$; c ; }Component} + { const $$_Component0C = __sveltets_2_ensureComponent(Component); const $$_Component0 = new $$_Component0C({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,c,} = $$_Component0.$$slot_def.default;$$_$$; c ; }Component} { const $$_value = await (promise); { const d = $$_value; d; }} diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/component-slot-no-space/expectedv2.ts b/packages/svelte2tsx/test/svelte2tsx/samples/component-slot-no-space/expectedv2.ts index cfee08220..8122ab022 100644 --- a/packages/svelte2tsx/test/svelte2tsx/samples/component-slot-no-space/expectedv2.ts +++ b/packages/svelte2tsx/test/svelte2tsx/samples/component-slot-no-space/expectedv2.ts @@ -7,7 +7,7 @@ function render() { ; async () => { - { svelteHTML.createElement("div", {}); { const $$_Test1 = new Test({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,t,} = $$_Test1.$$slot_def.default;$$_$$; }Test} }}; + { svelteHTML.createElement("div", {}); { const $$_Test1C = __sveltets_2_ensureComponent(Test); const $$_Test1 = new $$_Test1C({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,t,} = $$_Test1.$$slot_def.default;$$_$$; }Test} }}; return { props: {}, slots: {}, getters: {}, events: {} }} export default class Input__SvelteComponent_ extends __sveltets_1_createSvelte2TsxComponent(__sveltets_1_partial(__sveltets_1_with_any_event(render()))) { diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/const-tag-component/expectedv2.ts b/packages/svelte2tsx/test/svelte2tsx/samples/const-tag-component/expectedv2.ts index 69786993f..ec490a57e 100644 --- a/packages/svelte2tsx/test/svelte2tsx/samples/const-tag-component/expectedv2.ts +++ b/packages/svelte2tsx/test/svelte2tsx/samples/const-tag-component/expectedv2.ts @@ -13,7 +13,7 @@ function render() { ; async () => { - { const $$_Component0 = new Component({ target: __sveltets_2_any(), props: { box,}}); + { const $$_Component0C = __sveltets_2_ensureComponent(Component); const $$_Component0 = new $$_Component0C({ target: __sveltets_2_any(), props: { box,}}); {const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,box,} = $$_Component0.$$slot_def["box1"];$$_$$;{ svelteHTML.createElement("sveltefragment", { }); const {area, volume} = calculate(box.width, box.height, constant); const perimeter = (box.width + box.height) * constant; @@ -36,7 +36,7 @@ async () => { }} Component} - { const $$_Component0 = new Component({ target: __sveltets_2_any(), props: { box,}});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,box,} = $$_Component0.$$slot_def.default;$$_$$; + { const $$_Component0C = __sveltets_2_ensureComponent(Component); const $$_Component0 = new $$_Component0C({ target: __sveltets_2_any(), props: { box,}});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,box,} = $$_Component0.$$slot_def.default;$$_$$; {const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,box,} = $$_Component0.$$slot_def["box1"];$$_$$;{ svelteHTML.createElement("div", { }); const {area, volume} = calculate(box.width, box.height, constant); const perimeter = (box.width + box.height) * constant; @@ -57,7 +57,7 @@ async () => { { svelteHTML.createElement("div", {});area; volume; perimeter; width; height; sum; } }Component} - { const $$_Component0 = new Component({ target: __sveltets_2_any(), props: { box,}});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,box:{width, height},} = $$_Component0.$$slot_def.default;$$_$$; + { const $$_Component0C = __sveltets_2_ensureComponent(Component); const $$_Component0 = new $$_Component0C({ target: __sveltets_2_any(), props: { box,}});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,box:{width, height},} = $$_Component0.$$slot_def.default;$$_$$; const {area, volume} = calculate(width, height, constant); const perimeter = (width + height) * constant; const [_width, _height, sum] = [width * constant, height, width * constant + height]; diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/custom-css-properties-with-$store/expectedv2.ts b/packages/svelte2tsx/test/svelte2tsx/samples/custom-css-properties-with-$store/expectedv2.ts index fec6a52e4..b85558277 100644 --- a/packages/svelte2tsx/test/svelte2tsx/samples/custom-css-properties-with-$store/expectedv2.ts +++ b/packages/svelte2tsx/test/svelte2tsx/samples/custom-css-properties-with-$store/expectedv2.ts @@ -1,6 +1,6 @@ /// ;function render() { -async () => { { new Component({ target: __sveltets_2_any(), props: { ...__sveltets_2_cssProp({"--custom-css-property1":(__sveltets_1_store_get(jo), $jo)}),...__sveltets_2_cssProp({"--custom-css-property2":`hi${(__sveltets_1_store_get(jo), $jo)}hi`}),...__sveltets_2_cssProp({"--custom-css-property3":`hi${(__sveltets_1_store_get(jo), $jo)}hi`}),...__sveltets_2_cssProp({"--custom-css-property4":`hi${(__sveltets_1_store_get(jo), $jo)}hi`}),}});}}; +async () => { { const $$_Component0C = __sveltets_2_ensureComponent(Component); new $$_Component0C({ target: __sveltets_2_any(), props: { ...__sveltets_2_cssProp({"--custom-css-property1":(__sveltets_1_store_get(jo), $jo)}),...__sveltets_2_cssProp({"--custom-css-property2":`hi${(__sveltets_1_store_get(jo), $jo)}hi`}),...__sveltets_2_cssProp({"--custom-css-property3":`hi${(__sveltets_1_store_get(jo), $jo)}hi`}),...__sveltets_2_cssProp({"--custom-css-property4":`hi${(__sveltets_1_store_get(jo), $jo)}hi`}),}});}}; return { props: {}, slots: {}, getters: {}, events: {} }} export default class Input__SvelteComponent_ extends __sveltets_1_createSvelte2TsxComponent(__sveltets_1_partial(__sveltets_1_with_any_event(render()))) { diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/event-bubble-component-multi/expectedv2.ts b/packages/svelte2tsx/test/svelte2tsx/samples/event-bubble-component-multi/expectedv2.ts index 3e4d5e4ca..3c1f90107 100644 --- a/packages/svelte2tsx/test/svelte2tsx/samples/event-bubble-component-multi/expectedv2.ts +++ b/packages/svelte2tsx/test/svelte2tsx/samples/event-bubble-component-multi/expectedv2.ts @@ -1,7 +1,7 @@ /// ;function render() { -async () => { { const $$_Button0 = new Button({ target: __sveltets_2_any(), props: { }});$$_Button0.$on("click", () => {}); Button} - { const $$_Radio0 = new Radio({ target: __sveltets_2_any(), props: { }});$$_Radio0.$on("click", () => {}); Radio}}; +async () => { { const $$_Button0C = __sveltets_2_ensureComponent(Button); const $$_Button0 = new $$_Button0C({ target: __sveltets_2_any(), props: { }});$$_Button0.$on("click", () => {}); Button} + { const $$_Radio0C = __sveltets_2_ensureComponent(Radio); const $$_Radio0 = new $$_Radio0C({ target: __sveltets_2_any(), props: { }});$$_Radio0.$on("click", () => {}); Radio}}; return { props: {}, slots: {}, getters: {}, events: {'click':__sveltets_1_unionType(__sveltets_1_bubbleEventDef(__sveltets_1_instanceOf(Button).$$events_def, 'click'),__sveltets_1_bubbleEventDef(__sveltets_1_instanceOf(Radio).$$events_def, 'click'))} }} export default class Input__SvelteComponent_ extends __sveltets_1_createSvelte2TsxComponent(__sveltets_1_partial(__sveltets_1_with_any_event(render()))) { diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/event-bubble-component-with-props/expectedv2.ts b/packages/svelte2tsx/test/svelte2tsx/samples/event-bubble-component-with-props/expectedv2.ts index bc3aa9acb..88118db17 100644 --- a/packages/svelte2tsx/test/svelte2tsx/samples/event-bubble-component-with-props/expectedv2.ts +++ b/packages/svelte2tsx/test/svelte2tsx/samples/event-bubble-component-with-props/expectedv2.ts @@ -1,6 +1,6 @@ /// ;function render() { -async () => { { const $$_Component0 = new Component({ target: __sveltets_2_any(), props: { "propA":true,propB,"propC":"val1","propD":"val2","propE":`a${a}b${b}`,}});$$_Component0.$on("click", () => {});}}; +async () => { { const $$_Component0C = __sveltets_2_ensureComponent(Component); const $$_Component0 = new $$_Component0C({ target: __sveltets_2_any(), props: { "propA":true,propB,"propC":"val1","propD":"val2","propE":`a${a}b${b}`,}});$$_Component0.$on("click", () => {});}}; return { props: {}, slots: {}, getters: {}, events: {'click':__sveltets_1_bubbleEventDef(__sveltets_1_instanceOf(Component).$$events_def, 'click')} }} export default class Input__SvelteComponent_ extends __sveltets_1_createSvelte2TsxComponent(__sveltets_1_partial(__sveltets_1_with_any_event(render()))) { diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/event-bubble-component/expectedv2.ts b/packages/svelte2tsx/test/svelte2tsx/samples/event-bubble-component/expectedv2.ts index 8b0a1e277..3141ff8ce 100644 --- a/packages/svelte2tsx/test/svelte2tsx/samples/event-bubble-component/expectedv2.ts +++ b/packages/svelte2tsx/test/svelte2tsx/samples/event-bubble-component/expectedv2.ts @@ -1,6 +1,6 @@ /// ;function render() { -async () => { { const $$_Button0 = new Button({ target: __sveltets_2_any(), props: { }});$$_Button0.$on("click", () => {}); Button}}; +async () => { { const $$_Button0C = __sveltets_2_ensureComponent(Button); const $$_Button0 = new $$_Button0C({ target: __sveltets_2_any(), props: { }});$$_Button0.$on("click", () => {}); Button}}; return { props: {}, slots: {}, getters: {}, events: {'click':__sveltets_1_bubbleEventDef(__sveltets_1_instanceOf(Button).$$events_def, 'click')} }} export default class Input__SvelteComponent_ extends __sveltets_1_createSvelte2TsxComponent(__sveltets_1_partial(__sveltets_1_with_any_event(render()))) { diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/import-single-quote/expectedv2.ts b/packages/svelte2tsx/test/svelte2tsx/samples/import-single-quote/expectedv2.ts index 8d14d92e4..9285455a1 100644 --- a/packages/svelte2tsx/test/svelte2tsx/samples/import-single-quote/expectedv2.ts +++ b/packages/svelte2tsx/test/svelte2tsx/samples/import-single-quote/expectedv2.ts @@ -5,7 +5,7 @@ function render() { ; -async () => { { new Test({ target: __sveltets_2_any(), props: { "b":"6",}}); Test} +async () => { { const $$_Test0C = __sveltets_2_ensureComponent(Test); new $$_Test0C({ target: __sveltets_2_any(), props: { "b":"6",}}); Test} }; return { props: {}, slots: {}, getters: {}, events: {} }} diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/script-style-like-component/expectedv2.ts b/packages/svelte2tsx/test/svelte2tsx/samples/script-style-like-component/expectedv2.ts index 09a0348e9..f93a8d7d0 100644 --- a/packages/svelte2tsx/test/svelte2tsx/samples/script-style-like-component/expectedv2.ts +++ b/packages/svelte2tsx/test/svelte2tsx/samples/script-style-like-component/expectedv2.ts @@ -5,10 +5,10 @@ ; async () => { - { new Script({ target: __sveltets_2_any(), props: {}}); + { const $$_Script0C = __sveltets_2_ensureComponent(Script); new $$_Script0C({ target: __sveltets_2_any(), props: {}}); { svelteHTML.createElement("p", {}); } Script} - { new Style({ target: __sveltets_2_any(), props: {}});}}; + { const $$_Style0C = __sveltets_2_ensureComponent(Style); new $$_Style0C({ target: __sveltets_2_any(), props: {}});}}; return { props: {}, slots: {}, getters: {}, events: {} }} export default class Input__SvelteComponent_ extends __sveltets_1_createSvelte2TsxComponent(__sveltets_1_partial(__sveltets_1_with_any_event(render()))) { diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/self-closing-component/expectedv2.ts b/packages/svelte2tsx/test/svelte2tsx/samples/self-closing-component/expectedv2.ts index 5f99b00d0..8d350800f 100644 --- a/packages/svelte2tsx/test/svelte2tsx/samples/self-closing-component/expectedv2.ts +++ b/packages/svelte2tsx/test/svelte2tsx/samples/self-closing-component/expectedv2.ts @@ -6,7 +6,7 @@ function render() { let a = 'b'; ; -async () => { { new Test({ target: __sveltets_2_any(), props: { "b":"6",}});} +async () => { { const $$_Test0C = __sveltets_2_ensureComponent(Test); new $$_Test0C({ target: __sveltets_2_any(), props: { "b":"6",}});} }; return { props: {}, slots: {}, getters: {}, events: {} }} diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/stores-mustache/expectedv2.ts b/packages/svelte2tsx/test/svelte2tsx/samples/stores-mustache/expectedv2.ts index 4d5be4a05..e6e9f76b0 100644 --- a/packages/svelte2tsx/test/svelte2tsx/samples/stores-mustache/expectedv2.ts +++ b/packages/svelte2tsx/test/svelte2tsx/samples/stores-mustache/expectedv2.ts @@ -1,6 +1,6 @@ /// ;function render() { -async () => { { new Me({ target: __sveltets_2_any(), props: { "f":`${(__sveltets_1_store_get(s), $s)} `,}});}}; +async () => { { const $$_Me0C = __sveltets_2_ensureComponent(Me); new $$_Me0C({ target: __sveltets_2_any(), props: { "f":`${(__sveltets_1_store_get(s), $s)} `,}});}}; return { props: {}, slots: {}, getters: {}, events: {} }} export default class Input__SvelteComponent_ extends __sveltets_1_createSvelte2TsxComponent(__sveltets_1_partial(__sveltets_1_with_any_event(render()))) { diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/uses-$store-in-event-binding/expectedv2.ts b/packages/svelte2tsx/test/svelte2tsx/samples/uses-$store-in-event-binding/expectedv2.ts index 02faacc47..c8ebd932b 100644 --- a/packages/svelte2tsx/test/svelte2tsx/samples/uses-$store-in-event-binding/expectedv2.ts +++ b/packages/svelte2tsx/test/svelte2tsx/samples/uses-$store-in-event-binding/expectedv2.ts @@ -1,6 +1,6 @@ /// ;function render() { -async () => { { const $$_Component0 = new Component({ target: __sveltets_2_any(), props: { }});$$_Component0.$on("click", (__sveltets_1_store_get(check), $check) ? method1 : method2);} +async () => { { const $$_Component0C = __sveltets_2_ensureComponent(Component); const $$_Component0 = new $$_Component0C({ target: __sveltets_2_any(), props: { }});$$_Component0.$on("click", (__sveltets_1_store_get(check), $check) ? method1 : method2);} { svelteHTML.createElement("button", { "onclick":(__sveltets_1_store_get(check), $check) ? method1 : method2,}); }}; return { props: {}, slots: {}, getters: {}, events: {} }} diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/uses-svelte-components-let-forward/expectedv2.ts b/packages/svelte2tsx/test/svelte2tsx/samples/uses-svelte-components-let-forward/expectedv2.ts index 8d05247be..e30f18319 100644 --- a/packages/svelte2tsx/test/svelte2tsx/samples/uses-svelte-components-let-forward/expectedv2.ts +++ b/packages/svelte2tsx/test/svelte2tsx/samples/uses-svelte-components-let-forward/expectedv2.ts @@ -6,7 +6,7 @@ async () => {if(true){ { __sveltets_createSlot("default", { prop,});} }} } - { const $$_sveltecomponent0_ = new testComponent({ target: __sveltets_2_any(), props: { }});const $$_sveltecomponent0 = __sveltets_2_typeAsComponent($$_sveltecomponent0_);{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,prop,} = $$_sveltecomponent0.$$slot_def.default;$$_$$; + { const $$_sveltecomponent0C = __sveltets_2_ensureComponent(testComponent); const $$_sveltecomponent0 = new $$_sveltecomponent0C({ target: __sveltets_2_any(), props: { }});{const {/*Ωignore_startΩ*/$$_$$/*Ωignore_endΩ*/,prop,} = $$_sveltecomponent0.$$slot_def.default;$$_$$; { __sveltets_createSlot("default", { prop,});} }}}; return { props: {}, slots: {'default': {prop:__sveltets_1_instanceOf(__sveltets_1_componentType()).$$slot_def['default'].prop}}, getters: {}, events: {} }} diff --git a/packages/svelte2tsx/test/svelte2tsx/samples/uses-svelte-components/expectedv2.ts b/packages/svelte2tsx/test/svelte2tsx/samples/uses-svelte-components/expectedv2.ts index 5600024ca..afb1afb15 100644 --- a/packages/svelte2tsx/test/svelte2tsx/samples/uses-svelte-components/expectedv2.ts +++ b/packages/svelte2tsx/test/svelte2tsx/samples/uses-svelte-components/expectedv2.ts @@ -3,7 +3,7 @@ async () => {if(true){ { __sveltets_2_createComponentAny({ "prop1":1,});} } - { const $$_sveltecomponent0_ = new testComponent({ target: __sveltets_2_any(), props: { "propa":5,}});$$_sveltecomponent0_; + { const $$_sveltecomponent0C = __sveltets_2_ensureComponent(testComponent); new $$_sveltecomponent0C({ target: __sveltets_2_any(), props: { "propa":5,}}); { svelteHTML.createElement("h1", {}); } } { svelteHTML.createElement("sveltewindow", { "onclick":e => {},});}