Skip to content

fix: disallow TODO errors #10326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/lemon-geese-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: replace TODO errors
6 changes: 4 additions & 2 deletions packages/svelte/src/compiler/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ const parse = {
'illegal-subscription': () => `Cannot reference store value inside <script context="module">`,
'duplicate-style-element': () => `A component can have a single top-level <style> element`,
'duplicate-script-element': () =>
`A component can have a single top-level <script> element and/or a single top-level <script context="module"> element`
`A component can have a single top-level <script> element and/or a single top-level <script context="module"> element`,
'invalid-render-expression': () => 'expected an identifier followed by (...)',
'invalid-render-arguments': () => 'expected at most one argument'
};

/** @satisfies {Errors} */
Expand Down Expand Up @@ -508,7 +510,7 @@ export class CompileError extends Error {
}

/**
* @template {keyof typeof errors} T
* @template {Exclude<keyof typeof errors, 'TODO'>} T
* @param {NodeLike | number | null} node
* @param {T} code
* @param {Parameters<typeof errors[T]>} args
Expand Down
4 changes: 2 additions & 2 deletions packages/svelte/src/compiler/phases/1-parse/state/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,11 +586,11 @@ function special(parser) {
const expression = read_expression(parser);

if (expression.type !== 'CallExpression' || expression.callee.type !== 'Identifier') {
error(expression, 'TODO', 'expected an identifier followed by (...)');
error(expression, 'invalid-render-expression');
}

if (expression.arguments.length > 1) {
error(expression.arguments[1], 'TODO', 'expected at most one argument');
error(expression.arguments[1], 'invalid-render-arguments');
}

parser.allow_whitespace();
Expand Down