Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ impl DerefMut for JsDocTypeModel {
}

#[derive(Default)]
struct JsDocTypeCollectorVisitior {
struct JsDocTypeCollectorVisitor {
jsdoc_types: JsDocTypeModel,
}

declare_node_union! {
pub AnyJsWithTypeReferencingJsDoc = AnyJsDeclaration | AnyJsClassMember | AnyTsTypeMember | TsEnumMember | JsExport | JsStaticMemberAssignment
}

impl Visitor for JsDocTypeCollectorVisitior {
impl Visitor for JsDocTypeCollectorVisitor {
type Language = JsLanguage;
fn visit(
&mut self,
Expand Down Expand Up @@ -247,7 +247,7 @@ impl Queryable for NoUnusedImportsQuery {
root: &<Self::Language as Language>::Root,
) {
analyzer.add_visitor(Phases::Syntax, || SemanticModelBuilderVisitor::new(root));
analyzer.add_visitor(Phases::Syntax, JsDocTypeCollectorVisitior::default);
analyzer.add_visitor(Phases::Syntax, JsDocTypeCollectorVisitor::default);
analyzer.add_visitor(Phases::Semantic, SyntaxVisitor::default);
}

Expand Down
23 changes: 18 additions & 5 deletions crates/biome_js_analyze/tests/quick_test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use biome_analyze::{AnalysisFilter, AnalyzerOptions, ControlFlow, Never, RuleFilter};
use biome_analyze::options::JsxRuntime;
use biome_analyze::{
AnalysisFilter, AnalyzerConfiguration, AnalyzerOptions, ControlFlow, Never, RuleFilter,
};
use biome_deserialize::TextRange;
use biome_diagnostics::{Diagnostic, DiagnosticExt, Severity, print_diagnostic_to_string};
use biome_fs::TemporaryFs;
Expand Down Expand Up @@ -26,8 +29,14 @@ fn project_layout_with_top_level_dependencies(dependencies: Dependencies) -> Arc
#[test]
fn quick_test() {
const FILENAME: &str = "dummyFile.ts";
const SOURCE: &str = r#"import { sleep as alias } from "./sleep.ts";
alias(100);"#;
const SOURCE: &str = r#"import * as postcssModules from "postcss-modules"

type PostcssOptions = Parameters<postcssModules>[0]

export function f(options: PostcssOptions) {
console.log(options)
}
"#;

let parsed = parse(SOURCE, JsFileSource::tsx(), JsParserOptions::default());

Expand All @@ -38,8 +47,12 @@ alias(100);"#;
let file_path = Utf8PathBuf::from(format!("{}/{FILENAME}", fs.cli_path()));

let mut error_ranges: Vec<TextRange> = Vec::new();
let options = AnalyzerOptions::default().with_file_path(file_path.clone());
let rule_filter = RuleFilter::Rule("nursery", "noFloatingPromises");
let options = AnalyzerOptions::default()
.with_file_path(file_path.clone())
.with_configuration(
AnalyzerConfiguration::default().with_jsx_runtime(JsxRuntime::ReactClassic),
);
let rule_filter = RuleFilter::Rule("correctness", "noUnusedImports");

let dependencies = Dependencies(Box::new([("buffer".into(), "latest".into())]));

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as postcssModules from "postcss-modules"

type PostcssOptions = Parameters<postcssModules>[0]

export function f(options: PostcssOptions) {
console.log(options)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
source: crates/biome_js_analyze/tests/spec_tests.rs
expression: issue_6835.tsx
---
# Input
```tsx
import * as postcssModules from "postcss-modules"

type PostcssOptions = Parameters<postcssModules>[0]

export function f(options: PostcssOptions) {
console.log(options)
}

```
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// should not generate diagnostics
import * as Ns1 from ""
export type T1 = Ns1;

import type * as Ns2 from ""
export type T2 = Ns2;
export type T2 = Ns2;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
source: crates/biome_js_analyze/tests/spec_tests.rs
expression: valid-import-namespace.ts
---
# Input
```ts
// should not generate diagnostics
import * as Ns1 from ""
export type T1 = Ns1;

import type * as Ns2 from ""
export type T2 = Ns2;

```
2 changes: 1 addition & 1 deletion crates/biome_js_semantic/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ impl SemanticEventExtractor {
.and_then(|clause| clause.type_token());
if type_token.is_none() {
self.push_binding(None, BindingName::Value(name.clone()), info.clone());
self.push_binding(None, BindingName::Type(name.clone()), info.clone());
} else {
self.push_binding(None, BindingName::Type(name), info);
}
Expand Down Expand Up @@ -1012,7 +1013,6 @@ impl SemanticEventExtractor {
is_read: !reference.is_write(),
range: reference.range(),
});
continue;
}
// Handle edge case where a parameter has the same name that a parameter type name
// For example `(stream: stream.T) => {}`
Expand Down
Loading