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] mark css/instance/module Ast properties as optional #7204

Merged
merged 1 commit into from
Feb 2, 2022

Conversation

metonym
Copy link
Contributor

@metonym metonym commented Jan 30, 2022

Description

Parsing a Svelte component with only markup will return undefined for css, instance, and module.

Currently, all properties in the Ast interface are required, which can cause type errors.

export interface Ast {
html: TemplateNode;
css: Style;
instance: Script;
module: Script;
}

Repro

// parser.ts
import { parse } from "svelte/compiler";

const ast = parse("");

console.log(ast.instance.start);

// TypeError: Cannot read properties of undefined (reading 'start')

@metonym metonym changed the title [fix] type css/instance/module properties in Ast as optional [fix] mark css/instance/module Ast properties as optional Jan 30, 2022
@dummdidumm dummdidumm merged commit b9325ed into sveltejs:master Feb 2, 2022
@Conduitry
Copy link
Member

Type fix released in 3.46.4 - thanks!

himanshiLt pushed a commit to himanshiLt/svelte that referenced this pull request Mar 3, 2022
nevilm-lt pushed a commit to nevilm-lt/svelte that referenced this pull request Mar 14, 2022
nevilm-lt pushed a commit to nevilm-lt/svelte that referenced this pull request Apr 21, 2022
nevilm-lt pushed a commit to nevilm-lt/svelte that referenced this pull request Apr 21, 2022
nevilm-lt pushed a commit to nevilm-lt/svelte that referenced this pull request Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants