Skip to content

Commit

Permalink
Update valid/invalid specs
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarhussain committed Oct 29, 2024
1 parent 4116291 commit ea270a5
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,20 @@ function fn() {
};
}

const x = { prop: () => {} }
const x = { bar: { prop: () => {} } }
const x = { namedFunctions: function alpha () => {}, unNamedFunctions: function () => {} }
const x = { bar: { namedFunctions: function alpha () => {}, unNamedFunctions: function () => {} } }


// Returning object from function
interface Behavior {
attribute: string;
namedFunc: () => string;
arrowFunc: () => string;
}

function getObjectWithFunction(): Behavior {
return {
namedFunc: function myFunc() { return "value" },
arrowFunc: () => {},
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
source: crates/biome_js_analyze/tests/spec_tests.rs
assertion_line: 86
expression: invalid.ts
---
# Input
Expand Down Expand Up @@ -97,8 +98,23 @@ function fn() {
};
}

const x = { prop: () => {} }
const x = { bar: { prop: () => {} } }
const x = { namedFunctions: function alpha () => {}, unNamedFunctions: function () => {} }
const x = { bar: { namedFunctions: function alpha () => {}, unNamedFunctions: function () => {} } }


// Returning object from function
interface Behavior {
attribute: string;
namedFunc: () => string;
arrowFunc: () => string;
}

function getObjectWithFunction(): Behavior {
return {
namedFunc: function myFunc() { return "value" },
arrowFunc: () => {},
}
}
```
# Diagnostics
Expand Down Expand Up @@ -532,15 +548,69 @@ invalid.ts:85:2 lint/nursery/useExplicitType ━━━━━━━━━━━
```
```
invalid.ts:94:19 lint/nursery/useExplicitType ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
invalid.ts:94:29 lint/nursery/useExplicitType ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

! Missing return type on function.

92 │ }
93
> 94const x = { namedFunctions: function alpha () => {}, unNamedFunctions: function () => {} }
^^^^^^^^^^^^^^^
95const x = { bar: { namedFunctions: function alpha () => {}, unNamedFunctions: function () => {} } }
96

i Declaring the return type makes the code self-documenting and can speed up TypeScript type checking.

i Add a return type annotation.


```
```
invalid.ts:94:81 lint/nursery/useExplicitType ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

! Missing return type on function.

92 │ }
93
> 94 │ const x = { prop: () => {} }
│ ^^^^^^^^^
95 │ const x = { bar: { prop: () => {} } }
> 94const x = { namedFunctions: function alpha () => {}, unNamedFunctions: function () => {} }
^^^^^^^^^
95const x = { bar: { namedFunctions: function alpha () => {}, unNamedFunctions: function () => {} } }
96

i Declaring the return type makes the code self-documenting and can speed up TypeScript type checking.

i Add a return type annotation.


```
```
invalid.ts:95:36 lint/nursery/useExplicitType ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

! Missing return type on function.

94 │ const x = { namedFunctions: function alpha () => {}, unNamedFunctions: function () => {} }
> 95const x = { bar: { namedFunctions: function alpha () => {}, unNamedFunctions: function () => {} } }
^^^^^^^^^^^^^^^
96

i Declaring the return type makes the code self-documenting and can speed up TypeScript type checking.

i Add a return type annotation.


```
```
invalid.ts:95:79 lint/nursery/useExplicitType ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

! Missing return type on function.

94 │ const x = { namedFunctions: function alpha () => {}, unNamedFunctions: function () => {} }
> 95const x = { bar: { namedFunctions: function alpha () => {}, unNamedFunctions: function () => {} } }
^^^^^^^^^^^^
96

i Declaring the return type makes the code self-documenting and can speed up TypeScript type checking.

Expand All @@ -550,13 +620,16 @@ invalid.ts:94:19 lint/nursery/useExplicitType ━━━━━━━━━━━
```
```
invalid.ts:95:26 lint/nursery/useExplicitType ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
invalid.ts:107:16 lint/nursery/useExplicitType ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

! Missing return type on function.

94 │ const x = { prop: () => {} }
> 95 │ const x = { bar: { prop: () => {} } }
│ ^^^^^^^^^
105 │ function getObjectWithFunction(): Behavior {
106return {
> 107 │ namedFunc: function myFunc() { return "value" },
│ ^^^^^^^^^^^^^^^
108 │ arrowFunc: () => {},
109 │ }

i Declaring the return type makes the code self-documenting and can speed up TypeScript type checking.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,17 @@ class Accumulator {
this.count += fn();
}
}
new Accumulator().accumulate(() => 1);
new Accumulator().accumulate(() => 1);

// Returning object from function
interface Behavior {
namedFunc: () => string;
arrowFunc: () => string;
}

function getObjectWithFunction(): Behavior {
return {
namedFunc: function myFunc(): string { return "value" },
arrowFunc: () => {},
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
source: crates/biome_js_analyze/tests/spec_tests.rs
assertion_line: 86
expression: valid.ts
---
# Input
Expand Down Expand Up @@ -109,4 +110,18 @@ class Accumulator {
}
}
new Accumulator().accumulate(() => 1);

// Returning object from function
interface Behavior {
namedFunc: () => string;
arrowFunc: () => string;
}

function getObjectWithFunction(): Behavior {
return {
namedFunc: function myFunc(): string { return "value" },
arrowFunc: () => {},
}
}

```

0 comments on commit ea270a5

Please sign in to comment.