-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* implemented deref types * fix crazy typescript build times * fix skip rust script
- Loading branch information
Showing
16 changed files
with
901 additions
and
765 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@preact-signals/utils": minor | ||
--- | ||
|
||
Disallow reexports from macro lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@preact-signals/utils": minor | ||
--- | ||
|
||
Added `$deref` feature for state macroses to get actual state macro reference |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { describe, expectTypeOf, it } from "vitest"; | ||
import * as macro from "../lib/macro"; | ||
import { ReadonlySignal } from "@preact/signals-core"; | ||
|
||
describe("macros types", () => { | ||
it("$deref state types", () => { | ||
() => { | ||
expectTypeOf(() => { | ||
let a = macro.$state(10); | ||
|
||
return macro.$deref(a); | ||
}).returns.toEqualTypeOf<ReadonlySignal<10>>(); | ||
|
||
expectTypeOf(() => { | ||
let a = macro.$useState(10); | ||
|
||
return macro.$deref(a); | ||
}).returns.toEqualTypeOf<ReadonlySignal<10>>(); | ||
}; | ||
}); | ||
|
||
it("$deref readonly state types", () => { | ||
() => { | ||
expectTypeOf(() => { | ||
let a = macro.$derived(10); | ||
|
||
return macro.$deref(a); | ||
}).returns.toEqualTypeOf<ReadonlySignal<10>>(); | ||
|
||
expectTypeOf(() => { | ||
let a = macro.$useLinkedState(10); | ||
|
||
return macro.$deref(a); | ||
}).returns.toEqualTypeOf<ReadonlySignal<10>>(); | ||
|
||
expectTypeOf(() => { | ||
let a = macro.$useDerived(10); | ||
|
||
return macro.$deref(a); | ||
}).returns.toEqualTypeOf<ReadonlySignal<10>>(); | ||
}; | ||
}); | ||
|
||
it("$deref shouldn't work with incorrect types", () => { | ||
() => { | ||
{ | ||
const a = 10; | ||
|
||
// @ts-expect-error | ||
return macro.$deref(a); | ||
} | ||
}; | ||
}); | ||
}); |
Oops, something went wrong.