-
-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(js_semantic): type value schism (#495)
- Loading branch information
Showing
26 changed files
with
770 additions
and
685 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
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
2 changes: 2 additions & 0 deletions
2
..._js_analyze/tests/specs/correctness/noUndeclaredVariables/invalidTypeValueWithSameName.ts
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,2 @@ | ||
const a = 0; | ||
export type { a } |
24 changes: 24 additions & 0 deletions
24
...nalyze/tests/specs/correctness/noUndeclaredVariables/invalidTypeValueWithSameName.ts.snap
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,24 @@ | ||
--- | ||
source: crates/biome_js_analyze/tests/spec_tests.rs | ||
expression: invalidTypeValueWithSameName.ts | ||
--- | ||
# Input | ||
```js | ||
const a = 0; | ||
export type { a } | ||
``` | ||
|
||
# Diagnostics | ||
``` | ||
invalidTypeValueWithSameName.ts:2:15 lint/correctness/noUndeclaredVariables ━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! The a variable is undeclared | ||
1 │ const a = 0; | ||
> 2 │ export type { a } | ||
│ ^ | ||
``` | ||
|
||
|
10 changes: 10 additions & 0 deletions
10
...s/biome_js_analyze/tests/specs/correctness/noUnusedVariables/invalidTypeValueSameNames.ts
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,10 @@ | ||
|
||
type a = number | ||
export const a = 5; | ||
|
||
function f() {} | ||
export type f = () => {} | ||
|
||
const b = true | ||
type b = boolean | ||
export { type b } |
79 changes: 79 additions & 0 deletions
79
...me_js_analyze/tests/specs/correctness/noUnusedVariables/invalidTypeValueSameNames.ts.snap
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,79 @@ | ||
--- | ||
source: crates/biome_js_analyze/tests/spec_tests.rs | ||
expression: invalidTypeValueSameNames.ts | ||
--- | ||
# Input | ||
```js | ||
|
||
type a = number | ||
export const a = 5; | ||
|
||
function f() {} | ||
export type f = () => {} | ||
|
||
const b = true | ||
type b = boolean | ||
export { type b } | ||
|
||
``` | ||
|
||
# Diagnostics | ||
``` | ||
invalidTypeValueSameNames.ts:2:6 lint/correctness/noUnusedVariables ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! This type alias is unused. | ||
> 2 │ type a = number | ||
│ ^ | ||
3 │ export const a = 5; | ||
4 │ | ||
i Unused variables usually are result of incomplete refactoring, typos and other source of bugs. | ||
``` | ||
|
||
``` | ||
invalidTypeValueSameNames.ts:5:10 lint/correctness/noUnusedVariables ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
! This function is unused. | ||
3 │ export const a = 5; | ||
4 │ | ||
> 5 │ function f() {} | ||
│ ^ | ||
6 │ export type f = () => {} | ||
7 │ | ||
i Unused variables usually are result of incomplete refactoring, typos and other source of bugs. | ||
``` | ||
|
||
``` | ||
invalidTypeValueSameNames.ts:8:7 lint/correctness/noUnusedVariables FIXABLE ━━━━━━━━━━━━━━━━━━━━━━ | ||
! This variable is unused. | ||
6 │ export type f = () => {} | ||
7 │ | ||
> 8 │ const b = true | ||
│ ^ | ||
9 │ type b = boolean | ||
10 │ export { type b } | ||
i Unused variables usually are result of incomplete refactoring, typos and other source of bugs. | ||
i Unsafe fix: If this is intentional, prepend b with an underscore. | ||
6 6 │ export type f = () => {} | ||
7 7 │ | ||
8 │ - const·b·=·true | ||
8 │ + const·_b·=·true | ||
9 9 │ type b = boolean | ||
10 10 │ export { type b } | ||
``` | ||
|
||
|
6 changes: 6 additions & 0 deletions
6
crates/biome_js_analyze/tests/specs/correctness/noUnusedVariables/issue104.ts
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,6 @@ | ||
// See https://github.com/biomejs/biome/issues/104 | ||
|
||
import { X } from "mod" | ||
export function f(X: X): X { | ||
return X; | ||
} |
16 changes: 16 additions & 0 deletions
16
crates/biome_js_analyze/tests/specs/correctness/noUnusedVariables/issue104.ts.snap
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,16 @@ | ||
--- | ||
source: crates/biome_js_analyze/tests/spec_tests.rs | ||
expression: issue104.ts | ||
--- | ||
# Input | ||
```js | ||
// See https://github.com/biomejs/biome/issues/104 | ||
|
||
import { X } from "mod" | ||
export function f(X: X): X { | ||
return X; | ||
} | ||
|
||
``` | ||
|
||
|
5 changes: 5 additions & 0 deletions
5
crates/biome_js_analyze/tests/specs/correctness/noUnusedVariables/validValueExportType.ts
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 @@ | ||
class C {} | ||
enum E {} | ||
|
||
export type { C } | ||
export { type E } |
14 changes: 14 additions & 0 deletions
14
...s/biome_js_analyze/tests/specs/correctness/noUnusedVariables/validValueExportType.ts.snap
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,14 @@ | ||
--- | ||
source: crates/biome_js_analyze/tests/spec_tests.rs | ||
expression: validValueExportType.ts | ||
--- | ||
# Input | ||
```js | ||
class C {} | ||
enum E {} | ||
|
||
export type { C } | ||
export { type E } | ||
``` | ||
|
||
|
Oops, something went wrong.