3.0.0-rc.10
Node 10.8.0 / npm 6.2.0 / Windows 10
<script lang="ts">-tag.(<Type>object) anywhere in the script tag.npm run lint.Example code that produces the error:
<script lang="js">
import { Component, Prop, Vue } from "vue-property-decorator";
@Component
export default class Navigation extends Vue {
@Prop(String) private scrollTarget!: string;
mounted(): void {
if (!this.scrollTarget) {
return;
}
window.addEventListener("scroll", ev => {
if (window.scrollY > ((<HTMLElement>document.querySelector(this.scrollTarget)).offsetTop + (<HTMLElement>document.querySelector(this.scrollTarget)).offsetHeight)) {
console.log("Scrolled past!");
}
});
}
}
</script>
ESLint should have no complaints and everything should work fine.
ESLint determines the cast operator as an opening tag of HTML and thus declares the whole code to JSX.
When including the line with the console.log call, ESLint demands a closing curly bracket after the closing quotemark.
When commenting the same line, ESLint states
JSX element 'HTMLElement' has no corresponding closing tag
As far as I can tell, that's expected behaviour of TypeScript and documented here:
https://www.typescriptlang.org/docs/handbook/jsx.html
The proposed solution is to use the as operator instead.
Most helpful comment
As far as I can tell, that's expected behaviour of TypeScript and documented here:
https://www.typescriptlang.org/docs/handbook/jsx.html
The proposed solution is to use the
asoperator instead.