Skip to content
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

fix: resolve type definition error in svelte/compiler #11283

Merged
merged 2 commits into from
Apr 22, 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/lucky-colts-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"svelte": patch
---

fix: resolve type definition error in `svelte/compiler`
8 changes: 3 additions & 5 deletions packages/svelte/src/compiler/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getLocator } from 'locate-character';
import { walk } from 'zimmerframe';
import { walk as zimmerframe_walk } from 'zimmerframe';
import { CompileError } from './errors.js';
import { convert } from './legacy.js';
import { parse as parse_acorn } from './phases/1-parse/acorn.js';
Expand Down Expand Up @@ -133,7 +133,7 @@ export function parse(source, options = {}) {
function to_public_ast(source, ast, modern) {
if (modern) {
// remove things that we don't want to treat as public API
return walk(ast, null, {
return zimmerframe_walk(ast, null, {
_(node, { next }) {
// @ts-ignore
delete node.parent;
Expand All @@ -151,14 +151,12 @@ function to_public_ast(source, ast, modern) {
* @deprecated Replace this with `import { walk } from 'estree-walker'`
* @returns {never}
*/
function _walk() {
export function walk() {
throw new Error(
`'svelte/compiler' no longer exports a \`walk\` utility — please import it directly from 'estree-walker' instead`
);
}

export { _walk as walk };

export { CompileError } from './errors.js';

export { VERSION } from '../version.js';
4 changes: 1 addition & 3 deletions packages/svelte/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ declare module 'svelte/compiler' {
/**
* @deprecated Replace this with `import { walk } from 'estree-walker'`
* */
function walk(): never;
export function walk(): never;
/** The return value of `compile` from `svelte/compiler` */
interface CompileResult {
/** The compiled JavaScript */
Expand Down Expand Up @@ -1762,8 +1762,6 @@ declare module 'svelte/compiler' {
style?: Preprocessor;
script?: Preprocessor;
}

export { walk };
}

declare module 'svelte/easing' {
Expand Down
Loading