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

On Windows, diagnostics are show at the incorrect position after a custom tag #240

Open
AngusMorton opened this issue Dec 14, 2023 · 2 comments

Comments

@AngusMorton
Copy link

AngusMorton commented Dec 14, 2023

On Windows, after a custom tag is used, the diagnostics are shown at the incorrect positions or not shown at all. marko-type-check still shows the correct errors in the correct positions.

Given the following template, every instance of input.name++ should have an error underline.

export interface Input {
    name?: string;
}
<my-title name=input.name/>
<div>${input.name++}</div>
$ input.name++;
<div>${input.name++}</div>

The error is shown in the wrong position and only once:

export interface Input {
    name?: string;
}
<my-title name=input.name/>
<div>${input.name++}</div>
$ input.name++;
<div>${input.name++}</div>
 ^ 'input.name' is possibly 'undefined'.

Moving the use of <my-title> below the errors will cause the diagnostics above to be correctly rendered and the diagnostics below to be ignored.

export interface Input {
    name?: string;
}
<div>${input.name++}</div>
       ^^^^^^^^^^ 'input.name' is possibly 'undefined'.
<my-title name=input.name/>
$ input.name++;
<div>${input.name++}</div>

Removing the use of <my-title> shows all of the diagnostics in the right places as expected:

export interface Input {
    name?: string;
}
<div>${input.name++}</div>
       ^^^^^^^^^^ 'input.name' is possibly 'undefined'.
$ input.name++;
  ^^^^^^^^^^ 'input.name' is possibly 'undefined'.
<div>${input.name++}</div>
       ^^^^^^^^^^ 'input.name' is possibly 'undefined'.

Environment

Windows :(
Marko VSCode v1.1.15
VSCode 1.85.1

    "marko": "^5.32.2",
    "@marko/run": "^0.4.0",
    "@marko/type-check": "^1.0.7",
    "typescript": "^5.3.3"
@AngusMorton
Copy link
Author

AngusMorton commented Jan 30, 2024

This issue seems related to the auto import, or the way the typescript gets generated for the auto imports. Doing a manual import of the tag works as-expected:

import titleComponent from "./my-title.marko";
export interface Input {
    name?: string;
}
<div>${input.name++}</div>
       ^^^^^^^^^^ 'input.name' is possibly 'undefined'.
$ input.name++;
  ^^^^^^^^^^ 'input.name' is possibly 'undefined'.
<titleComponent/>
<div>${input.name++}</div>
       ^^^^^^^^^^ 'input.name' is possibly 'undefined'.

@AngusMorton
Copy link
Author

I've got a reproduction here that is just the basic-ts example with most of the code removed.

Interestingly, doing import titleComponent from "<my-title>" also causes the bug while doing the import path ourselves doesn't. The extracted script is identical between <my-title> and ./my-title.marko...

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

No branches or pull requests

1 participant