I'm working on a component.
I have a thisPerson variable that has all props being optional props. I want to check if they're all "defined" before passing to a <person-card> tag.
When saving the file, the extension format the <if> tag like this and insert a comma at the end of the condition:
That doesn't seem to be a valid syntax because TypeScript checking now throwing errors for all the props I'm passing into <person-card>:
Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'
Removing the comma fixes the issue but then my prettier --check command fails! So this may be related to https://github.com/marko-js/prettier (prettier-plugin-marko package), too.
Marko VSCode 1.0.16
Details
I'm working on a component. I have a
thisPerson
variable that has all props being optional props. I want to check if they're all "defined" before passing to a<person-card>
tag.When saving the file, the extension format the
<if>
tag like this and insert a comma at the end of the condition:That doesn't seem to be a valid syntax because TypeScript checking now throwing errors for all the props I'm passing into
<person-card>
:Removing the comma fixes the issue but then my
prettier --check
command fails! So this may be related to https://github.com/marko-js/prettier (prettier-plugin-marko
package), too.Expected Behavior
The if block should look like this instead:
Possible Fix
Seems to be a linting issue.
Your Environment
Steps to Reproduce
npx @marko/create
src/routes/_index/types.ts
with this content:src/components/person-card.marko
with this content:+page.marko
to this:+page.marko
file to replicate the Marko extension linting behaviour.Stack Trace
Verbose Marko extension trace:
``` [Trace - 2:22:38 PM] Sending request 'textDocument/codeAction - (2194)'. Params: { "textDocument": { "uri": "file:///home/user/code/marko-replicate-problem/src/routes/_index/%2Bpage.marko" }, "range": { "start": { "line": 0, "character": 0 }, "end": { "line": 10, "character": 0 } }, "context": { "diagnostics": [], "only": [ "source.fixAll.eslint" ], "triggerKind": 2 } } [Trace - 2:22:38 PM] Received response 'textDocument/codeAction - (2194)' in 1ms. No result returned. [Trace - 2:22:38 PM] Sending request 'textDocument/formatting - (2195)'. Params: { "textDocument": { "uri": "file:///home/user/code/marko-replicate-problem/src/routes/_index/%2Bpage.marko" }, "options": { "tabSize": 2, "insertSpaces": true, "trimTrailingWhitespace": true } } [Trace - 2:22:38 PM] Received response 'textDocument/formatting - (2195)' in 31ms. Result: [ { "range": { "start": { "line": 0, "character": 0 }, "end": { "line": 10, "character": 0 } }, "newText": "import { person } from \"./types\";\n$ const thisPerson = person;\n\n