Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: sveltejs/language-tools
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: svelte-check-3.6.7
Choose a base ref
...
head repository: sveltejs/language-tools
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: svelte-check-3.6.8
Choose a head ref
  • 2 commits
  • 15 files changed
  • 2 contributors

Commits on Mar 19, 2024

  1. feat: TypeScript 5.4 support for svelte-check (#2313)

    * bump ts to 5.4.2
    
    * assign to bound variable for ts 5.4 to widen to control flow
    
    * format
    
    * oops this doesn't work in 5.3
    
    * revert bumping but keeps compatibility fixes
    
    * lock
    
    * Update packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Binding.ts
    jasonlyu123 authored Mar 19, 2024
    Copy the full SHA
    15a41f3 View commit details
  2. fix: allow falsy values for render tags

    dummdidumm committed Mar 19, 2024
    Copy the full SHA
    09aec03 View commit details
Original file line number Diff line number Diff line change
@@ -543,11 +543,17 @@ function expectedTransitionThirdArgument(
return false;
}

const callExpression = findNodeAtSpan(
node,
{ start: node.getStart(), length: node.getWidth() },
ts.isCallExpression
);
// in TypeScript 5.4 the error is on the function name
// in earlier versions it's on the whole call expression
const callExpression =
ts.isIdentifier(node) && ts.isCallExpression(node.parent)
? node.parent
: findNodeAtSpan(
node,
{ start: node.getStart(), length: node.getWidth() },
ts.isCallExpression
);

const signature =
callExpression && lang.getProgram()?.getTypeChecker().getResolvedSignature(callExpression);

Original file line number Diff line number Diff line change
@@ -102,7 +102,8 @@ class ImpliedNodeFormatResolver {
let mode = undefined;
if (sourceFile) {
this.cacheImpliedNodeFormat(sourceFile, compilerOptions);
mode = ts.getModeForResolutionAtIndex(sourceFile, importIdxInFile);
// @ts-expect-error remove when bumping to TS 5.4
mode = ts.getModeForResolutionAtIndex(sourceFile, importIdxInFile, compilerOptions);
}
return mode;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script lang="ts">
export let value: 'foo' | 'bar';
</script>

<button on:click={() => value = 'foo'}>foo</button>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<script lang="ts">
import Component from './Component.svelte';
let checked = false;
let value: 'foo' | 'bar' = 'foo';
</script>

<input type="checkbox" bind:checked>

{#if checked === true}
checked
{/if}

{#if value === 'bar'}
bar
{/if}

<Component bind:value></Component>
6 changes: 6 additions & 0 deletions packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Binding.ts
Original file line number Diff line number Diff line change
@@ -94,6 +94,12 @@ export function handleBinding(
return;
}

// add reassignment to force TS to widen the type of the declaration (in case it's never reassigned anywhere else)
const expressionStr = str.original.substring(attr.expression.start, getEnd(attr.expression));
element.appendToStartEnd([
surroundWithIgnoreComments(`() => ${expressionStr} = __sveltets_2_any(null);`)
]);

// other bindings which are transformed to normal attributes/props
const isShorthand = attr.expression.start === attr.start + 'bind:'.length;
const name: TransformationArray =
2 changes: 1 addition & 1 deletion packages/svelte2tsx/svelte-shims-v4.d.ts
Original file line number Diff line number Diff line change
@@ -146,7 +146,7 @@ declare function __sveltets_2_nonNullable<T>(type: T): NonNullable<T>;
declare function __sveltets_2_cssProp(prop: Record<string, any>): {};

// @ts-ignore Svelte v3/v4 don't have this
declare function __sveltets_2_ensureSnippet(val: ReturnType<import('svelte').Snippet>): any;
declare function __sveltets_2_ensureSnippet(val: ReturnType<import('svelte').Snippet> | undefined | null): any;
// @ts-ignore Svelte v3/v4 don't have this
declare function __sveltets_2_snippet(): import('svelte').Snippet;
declare function __sveltets_2_snippet<T>(t: T): import('svelte').Snippet<[T]>;

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

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

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

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

Original file line number Diff line number Diff line change
@@ -54,25 +54,25 @@ async•()•=>•{••{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureCom
{/**
------------------------------------------------------------------------------------------------------------------------------------------------------ */}
{ const $$_tnenopmoC0C = __sveltets_2_ensureComponent(Component); new $$_tnenopmoC0C({ target: __sveltets_2_any(), props: { foo:bar,}});} {/**
•{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureComponent(Component);•new•$$_tnenopmoC0C({•target:•__sveltets_2_any(),•props:•{•••foo:bar,}});}↲ [generated] line 11
•{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureComponent(Component);•new•$$_tnenopmoC0C({•target:•__sveltets_2_any(),•props:•{ [generated] subset
< Component
<Component
<Component↲ [original] line 11
•{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureComponent(Component);•new•$$_tnenopmoC0C({•target:•__sveltets_2_any(),•props:•{•••foo:bar,}});}↲ [generated] line 11
•• foo:bar,}});} [generated] subset
b{ foo=bar}
#= Order-breaking mappings
b foo={bar}
╚bind:foo={bar}↲ [original] line 12
•{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureComponent(Component);•new•$$_tnenopmoC0C({•target:•__sveltets_2_any(),•props:•{•••foo:bar,}});}↲ [generated] line 11
• ↲ [generated] subset
/
/ ↲
/>↲ [original] line 13
{ const $$_tnenopmoC0C = __sveltets_2_ensureComponent(Component); new $$_tnenopmoC0C({ target: __sveltets_2_any(), props: { foo:bar,}});/*Ωignore_startΩ*/() => bar = __sveltets_2_any(null);/*Ωignore_endΩ*/}{/**
•{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureComponent(Component);•new•$$_tnenopmoC0C({•target:•__sveltets_2_any(),•props:•{•••foo:bar,}});/*Ωignore_startΩ*/()=>•bar•=•__sveltets_2_any(null);/*Ωignore_endΩ*/} [generated] line 11
{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureComponent(Component);•new•$$_tnenopmoC0C({•target:•__sveltets_2_any(),•props:{ [generated] subset
< Component
<Component
<Component↲ [original] line 11
{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureComponent(Component);•new•$$_tnenopmoC0C({•target:•__sveltets_2_any(),•props:{•••foo:bar,}});/*Ωignore_startΩ*/()=>bar=__sveltets_2_any(null);/*Ωignore_endΩ*/} [generated] line 11
•• foo:bar,}});/*Ωignore_startΩ*/()=>bar=__sveltets_2_any(null);/*Ωignore_endΩ*/} [generated] subset
b{ foo=bar}
#= Order-breaking mappings
b foo={bar}
╚bind:foo={bar} [original] line 12
{•const•$$_tnenopmoC0C•=•__sveltets_2_ensureComponent(Component);•new•$$_tnenopmoC0C({•target:•__sveltets_2_any(),•props:{•••foo:bar,}});/*Ωignore_startΩ*/()=>bar=__sveltets_2_any(null);/*Ωignore_endΩ*/} [generated] line 11
[generated] subset
/
/
/> [original] line 13
------------------------------------------------------------------------------------------------------------------------------------------------------ */}
{/**
Loading