From e1a1c7fa87aca46d5cf5ac68596df01631da585d Mon Sep 17 00:00:00 2001 From: Yuichiro Yamashita Date: Mon, 2 Jan 2023 15:55:14 +0900 Subject: [PATCH] [chore] Fix CI (#8160) * ci build * fix test * add test for #7938 --- generate-type-definitions.js | 8 +++- src/runtime/transition/index.ts | 2 +- .../svelte-element-event-handlers/expected.js | 25 ++++++----- .../input.svelte | 11 +++-- .../samples/svelte-element-static/expected.js | 41 +++++++++++++++++++ .../svelte-element-static/input.svelte | 3 ++ 6 files changed, 73 insertions(+), 17 deletions(-) create mode 100644 test/js/samples/svelte-element-static/expected.js create mode 100644 test/js/samples/svelte-element-static/input.svelte diff --git a/generate-type-definitions.js b/generate-type-definitions.js index d8f6e9f826..6ec2f313c3 100644 --- a/generate-type-definitions.js +++ b/generate-type-definitions.js @@ -3,8 +3,12 @@ const { execSync } = require('child_process'); const { readFileSync, writeFileSync } = require('fs'); -execSync('tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emitDeclarationOnly'); - +try { + execSync('tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emitDeclarationOnly'); +} catch (err) { + console.error(err.stderr.toString()); + throw err; +} // We need to add these types to the .d.ts files here because if we add them before building, the build will fail, // because the TS->JS transformation doesn't know these exports are types and produces code that fails at runtime. // We can't use `export type` syntax either because the TS version we're on doesn't have this feature yet. diff --git a/src/runtime/transition/index.ts b/src/runtime/transition/index.ts index 5940d054d3..c6d9dbc97a 100644 --- a/src/runtime/transition/index.ts +++ b/src/runtime/transition/index.ts @@ -198,7 +198,7 @@ export function draw(node: SVGElement & { getTotalLength(): number }, { delay, duration, easing, - css: (t, u) => ` + css: (_, u) => ` stroke-dasharray: ${len}; stroke-dashoffset: ${u * len}; ` diff --git a/test/js/samples/svelte-element-event-handlers/expected.js b/test/js/samples/svelte-element-event-handlers/expected.js index b9e648aadc..ab24f2e924 100644 --- a/test/js/samples/svelte-element-event-handlers/expected.js +++ b/test/js/samples/svelte-element-event-handlers/expected.js @@ -39,16 +39,16 @@ function create_dynamic_element(ctx) { return { c() { - svelte_element1 = element("a"); - svelte_element0 = element("span"); + svelte_element1 = element(a); + svelte_element0 = element(span); - if ((/-/).test("span")) { + if ((/-/).test(span)) { set_custom_element_data_map(svelte_element0, svelte_element0_data); } else { set_attributes(svelte_element0, svelte_element0_data); } - if ((/-/).test("a")) { + if ((/-/).test(a)) { set_custom_element_data_map(svelte_element1, svelte_element1_data); } else { set_attributes(svelte_element1, svelte_element1_data); @@ -72,7 +72,7 @@ function create_dynamic_element(ctx) { p(ctx, dirty) { svelte_element0_data = get_spread_update(svelte_element0_levels, [{ class: "inner" }]); - if ((/-/).test("span")) { + if ((/-/).test(span)) { set_custom_element_data_map(svelte_element0, svelte_element0_data); } else { set_attributes(svelte_element0, svelte_element0_data); @@ -80,7 +80,7 @@ function create_dynamic_element(ctx) { svelte_element1_data = get_spread_update(svelte_element1_levels, [{ class: "outer" }]); - if ((/-/).test("a")) { + if ((/-/).test(a)) { set_custom_element_data_map(svelte_element1, svelte_element1_data); } else { set_attributes(svelte_element1, svelte_element1_data); @@ -95,9 +95,9 @@ function create_dynamic_element(ctx) { } function create_fragment(ctx) { - let previous_tag = "a"; + let previous_tag = a; let svelte_element_anchor; - let svelte_element = "a" && create_dynamic_element(ctx); + let svelte_element = a && create_dynamic_element(ctx); return { c() { @@ -109,12 +109,12 @@ function create_fragment(ctx) { insert(target, svelte_element_anchor, anchor); }, p(ctx, [dirty]) { - if ("a") { + if (a) { if (!previous_tag) { svelte_element = create_dynamic_element(ctx); svelte_element.c(); svelte_element.m(svelte_element_anchor.parentNode, svelte_element_anchor); - } else if (safe_not_equal(previous_tag, "a")) { + } else if (safe_not_equal(previous_tag, a)) { svelte_element.d(1); svelte_element = create_dynamic_element(ctx); svelte_element.c(); @@ -127,7 +127,7 @@ function create_fragment(ctx) { svelte_element = null; } - previous_tag = "a"; + previous_tag = a; }, i: noop, o: noop, @@ -138,6 +138,9 @@ function create_fragment(ctx) { }; } +const a = 'a'; +const span = 'span'; + function instance($$self) { function keydown_handler(event) { bubble.call(this, $$self, event); diff --git a/test/js/samples/svelte-element-event-handlers/input.svelte b/test/js/samples/svelte-element-event-handlers/input.svelte index bb0b7b57a9..3a7b0f9800 100644 --- a/test/js/samples/svelte-element-event-handlers/input.svelte +++ b/test/js/samples/svelte-element-event-handlers/input.svelte @@ -1,3 +1,8 @@ - - - \ No newline at end of file + + + + + diff --git a/test/js/samples/svelte-element-static/expected.js b/test/js/samples/svelte-element-static/expected.js new file mode 100644 index 0000000000..68d895db3c --- /dev/null +++ b/test/js/samples/svelte-element-static/expected.js @@ -0,0 +1,41 @@ +/* generated by Svelte vX.Y.Z */ +import { + SvelteComponent, + attr, + detach, + element, + init, + insert, + noop, + safe_not_equal +} from "svelte/internal"; + +function create_fragment(ctx) { + let a; + + return { + c() { + a = element("a"); + a.innerHTML = ``; + attr(a, "class", "outer"); + }, + m(target, anchor) { + insert(target, a, anchor); + }, + p: noop, + i: noop, + o: noop, + d(detaching) { + if (detaching) detach(a); + } + }; +} + +class Component extends SvelteComponent { + constructor(options) { + super(); + init(this, options, null, create_fragment, safe_not_equal, {}); + } +} + +export default Component; \ No newline at end of file diff --git a/test/js/samples/svelte-element-static/input.svelte b/test/js/samples/svelte-element-static/input.svelte new file mode 100644 index 0000000000..4893d49847 --- /dev/null +++ b/test/js/samples/svelte-element-static/input.svelte @@ -0,0 +1,3 @@ + + +