11
11
]
12
12
13
13
# mod.ts
14
- export function a() {
15
- var x = "";
16
- return {} as typeof x;
17
- };
14
+ // export function a() {
15
+ // var x = "";
16
+ // return {} as typeof x;
17
+ // };
18
18
19
- export function a (b: string): typeof b {
19
+ export const a = (b: string, c = {} as typeof b) => {
20
20
};
21
21
22
22
# output
@@ -27,7 +27,7 @@ export function a(b: string): typeof b {
27
27
"modules": [
28
28
{
29
29
"kind": "esm",
30
- "size": 65 ,
30
+ "size": 144 ,
31
31
"mediaType": "TypeScript",
32
32
"specifier": "file:///mod.ts"
33
33
}
@@ -36,19 +36,18 @@ export function a(b: string): typeof b {
36
36
}
37
37
38
38
Fast check file:///mod.ts:
39
- error[unknown-return-type]: unknown return type for function in the public API
40
- --> /mod.ts:1:17
41
- |
42
- 1 | export function a () {
43
- | - this function's return type could not be inferred
39
+ error[unknown-var-type]: unknown type for variable in the public API
40
+ --> /mod.ts:6:14
44
41
|
45
- 3 | return {} as typeof x;
46
- | ------ because the value returned here
47
- | - contains this reference to a local variable or type
42
+ 6 | export const a = (b: string, c = {} as typeof b): typeof b => {
43
+ | ^ this variable's type could not be inferred because its initializer
44
+ | - contains this arrow expression
45
+ | - which has this parameter, which is missing an explicit type annotation
46
+ | - contains this reference to a local variable or type
48
47
|
49
- = hint: add an explicit return type to the function
48
+ = hint: add an explicit type annotation to the arrow expression parameter in the variable declaration initializer
50
49
51
- info: all functions in the public API must have an known return type
52
- info: local variables or types can not be referenced because they are not visible at the top level of the module
53
- docs: https://jsr.io/go/slow-type-unknown-return -type
50
+ info: all variables in the public API must have a known type
51
+ info: local variables or types can not be referenced in the public API because they are not visible at the top level of the module
52
+ docs: https://jsr.io/go/slow-type-unknown-var -type
54
53
0 commit comments