Skip to content

Commit 5933d89

Browse files
authored
Merge pull request #8387 from QwikDev/fix-valid-scope-sig
fix(eslint valid scope): check only value of signals
2 parents e345a21 + 7408cf2 commit 5933d89

File tree

6 files changed

+26
-7
lines changed

6 files changed

+26
-7
lines changed

packages/docs/src/routes/api/qwik/api.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@
11841184
}
11851185
],
11861186
"kind": "Function",
1187-
"content": "Returned type of the `noSerialize()` function. It will be TYPE or undefined.\n\n\n```typescript\nexport type NoSerialize<T> = (T & {\n __no_serialize__: true;\n}) | undefined;\n```",
1187+
"content": "Returned type of the `noSerialize()` function. It will be TYPE or undefined.\n\n\n```typescript\nexport type NoSerialize<T> = (T & {\n __no_serialize__?: true;\n}) | undefined;\n```",
11881188
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/shared/serdes/verify.ts",
11891189
"mdFile": "core.noserialize.md"
11901190
},
@@ -1198,7 +1198,7 @@
11981198
}
11991199
],
12001200
"kind": "TypeAlias",
1201-
"content": "Returned type of the `noSerialize()` function. It will be TYPE or undefined.\n\n\n```typescript\nexport type NoSerialize<T> = (T & {\n __no_serialize__: true;\n}) | undefined;\n```",
1201+
"content": "Returned type of the `noSerialize()` function. It will be TYPE or undefined.\n\n\n```typescript\nexport type NoSerialize<T> = (T & {\n __no_serialize__?: true;\n}) | undefined;\n```",
12021202
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/core/shared/serdes/verify.ts",
12031203
"mdFile": "core.noserialize.md"
12041204
},

packages/docs/src/routes/api/qwik/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2671,7 +2671,7 @@ Returned type of the `noSerialize()` function. It will be TYPE or undefined.
26712671
```typescript
26722672
export type NoSerialize<T> =
26732673
| (T & {
2674-
__no_serialize__: true;
2674+
__no_serialize__?: true;
26752675
})
26762676
| undefined;
26772677
```
@@ -2685,7 +2685,7 @@ Returned type of the `noSerialize()` function. It will be TYPE or undefined.
26852685
```typescript
26862686
export type NoSerialize<T> =
26872687
| (T & {
2688-
__no_serialize__: true;
2688+
__no_serialize__?: true;
26892689
})
26902690
| undefined;
26912691
```

packages/eslint-plugin-qwik/src/validLexicalScope.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,11 @@ function _isTypeCapturable(
436436
};
437437
}
438438

439-
for (const symbol of type.getProperties()) {
439+
const props =
440+
(type.symbol.escapedName as string).endsWith('Signal') && type.getProperty('value')
441+
? [type.getProperty('value')!]
442+
: type.getProperties();
443+
for (const symbol of props) {
440444
const result = isSymbolCapturable(context, checker, symbol, node, opts, level + 1, seen);
441445
if (result) {
442446
const loc = result.location;

packages/qwik/src/core/qwik.core.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ export const _noopQrlDEV: <T>(symbolName: string, opts: QRLDev, lexicalScopeCapt
639639

640640
// @public
641641
export type NoSerialize<T> = (T & {
642-
__no_serialize__: true;
642+
__no_serialize__?: true;
643643
}) | undefined;
644644

645645
// @public

packages/qwik/src/core/reactive-primitives/impl/signal.unit.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
type ComputedSignal,
2323
type SerializerSignal,
2424
type Signal,
25+
type AsyncSignal,
2526
} from '../signal.public';
2627
import { getSubscriber } from '../subscriber';
2728
import { vnode_newVirtual, vnode_setProp } from '../../client/vnode-utils';
@@ -111,6 +112,20 @@ describe('signal types', () => {
111112
expectTypeOf(signal.value).toEqualTypeOf<Foo>();
112113
}
113114
});
115+
it('AsyncSignal<T>', () => async () => {
116+
const signal = createAsync$(() => Promise.resolve(42));
117+
expectTypeOf(signal).toEqualTypeOf<AsyncSignal<number>>();
118+
expectTypeOf(signal).toExtend<Signal<number>>();
119+
expectTypeOf(signal.trigger()).toEqualTypeOf<void>();
120+
expectTypeOf(await signal.promise()).toEqualTypeOf<void>();
121+
expectTypeOf(signal.value).toEqualTypeOf<number>();
122+
expectTypeOf(signal.loading).toEqualTypeOf<boolean>();
123+
expectTypeOf(signal.error).toEqualTypeOf<Error | undefined>();
124+
expectTypeOf(signal.interval).toEqualTypeOf<number>();
125+
expectTypeOf(signal.untrackedValue).toEqualTypeOf<number>();
126+
expectTypeOf(signal.abort()).toEqualTypeOf<void>();
127+
expectTypeOf(signal.invalidate()).toEqualTypeOf<void>();
128+
});
114129
});
115130

116131
describe('signal', () => {

packages/qwik/src/core/shared/serdes/verify.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export const fastSkipSerialize = (obj: unknown): boolean => {
114114
* @public
115115
* @see noSerialize
116116
*/
117-
export type NoSerialize<T> = (T & { __no_serialize__: true }) | undefined;
117+
export type NoSerialize<T> = (T & { __no_serialize__?: true }) | undefined;
118118

119119
// <docs markdown="../../readme.md#noSerialize">
120120
// !!DO NOT EDIT THIS COMMENT DIRECTLY!!!

0 commit comments

Comments
 (0)