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 props as optional in ts when no typings given #370

Merged

Conversation

dummdidumm
Copy link
Member

Before this, export let a = '' would not be marked as optional because it had no type.
#347

Also fixes a bug where file type was incorrectly inferred as jsx which occurs when user uses the default languages feature of svelte-preprocess. Instead of computing the file type inside svelte2tsx, it is now passed as an option.

Before this, `export let a = ''` would not be marked as optional because it had no type.
sveltejs#347

Also fixes a bug where file type was incorrectly inferred as jsx which occurs when user uses the default languages feature of svelte-preprocess. Instead of computing the file type inside svelte2tsx, it is now passed as an option.
@@ -614,11 +614,7 @@ function processInstanceScriptContent(str: MagicString, script: Node): InstanceS
ts.forEachChild(list, (node) => {
if (ts.isVariableDeclaration(node)) {
if (ts.isIdentifier(node.name)) {
if (node.type) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@halfnelson do you remember why you made this distinction? I removed it to enable optional props, but I fear I may have overlooked something else.

Copy link
Member

@jasonlyu123 jasonlyu123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good for me. Still needed to be improved or discuss would be the type of false thing and whether to have optional props in non-strict mode.

@dummdidumm dummdidumm merged commit ad623c3 into sveltejs:master Jul 28, 2020
@dummdidumm dummdidumm deleted the fix-optionalprops-in-svelte2tsx branch July 28, 2020 08:02
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.

2 participants