Skip to content

Commit

Permalink
feat: add support
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Feb 5, 2024
1 parent 7580d1d commit 4a90968
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/hot-buses-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@marko/language-tools": patch
---

Add typeings for $signal variable in tags api.
3 changes: 0 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Hovers
### Ln 2, Col 4
```marko
1 | <effect() {
> 2 | $signal.onabort = () => {
| ^ const $signal: AbortSignal
3 | // ^?
4 | console.log('aborted');
5 | };
```

## Diagnostics
### Ln 1, Col 2
```marko
> 1 | <effect() {
| ^^^^^^ Cannot find name 'effect'.
2 | $signal.onabort = () => {
3 | // ^?
4 | console.log('aborted');
```

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<effect() {
$signal.onabort = () => {
// ^?
console.log('aborted');
};
}/>
1 change: 1 addition & 0 deletions packages/language-tools/src/extractors/script/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ function ${templateName}() {\n`);
const input = ${this.#getCastedType(`Input${typeArgsStr}`)};
const component = ${this.#getCastedType(`Component${typeArgsStr}`)};
const state = ${varShared("state")}(component);
const $signal = ${this.#getCastedType("AbortSignal")};
const $global = ${varShared("getGlobal")}(
// @ts-expect-error We expect the compiler to error because we are checking if the MarkoRun.Context is defined.
(${varShared("error")}, ${this.#getCastedType("MarkoRun.Context")})
Expand Down

0 comments on commit 4a90968

Please sign in to comment.