Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test and prevent looping #691

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
5 changes: 4 additions & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,10 @@ impl<'a> DocParser<'a> {

let original_range = &export_symbol.decls().first().unwrap().range;

if let Some(first_def) = definitions.first() {
if let Some(first_def) = definitions
.iter()
.find(|def| definition_location(def) == reference_def.target)
{
use deno_graph::symbols::DefinitionKind;
match first_def.kind {
DefinitionKind::ExportStar(_) => {}
Expand Down
98 changes: 98 additions & 0 deletions tests/specs/export_symbol_with_same_name_as_import.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# mod.ts
import type { Foo } from "./foo.ts";
export function Foo() {}

# foo.ts
export interface Foo {}

# diagnostics
error[missing-jsdoc]: exported symbol is missing JSDoc documentation
--> /foo.ts:1:1
|
1 | export interface Foo {}
| ^


error[missing-jsdoc]: exported symbol is missing JSDoc documentation
--> /mod.ts:2:1
|
2 | export function Foo() {}
| ^

# output.txt
Defined in file:///mod.ts:2:1

function Foo(): void

Defined in file:///foo.ts:1:1

interface Foo


Defined in file:///mod.ts:1:1



# output.json
[
{
"name": "Foo",
"isDefault": false,
"location": {
"filename": "file:///foo.ts",
"line": 1,
"col": 0,
"byteIndex": 0
},
"declarationKind": "export",
"kind": "interface",
"interfaceDef": {
"extends": [],
"constructors": [],
"methods": [],
"properties": [],
"callSignatures": [],
"indexSignatures": [],
"typeParams": []
}
},
{
"name": "Foo",
"isDefault": false,
"location": {
"filename": "file:///mod.ts",
"line": 2,
"col": 0,
"byteIndex": 37
},
"declarationKind": "export",
"kind": "function",
"functionDef": {
"params": [],
"returnType": {
"repr": "void",
"kind": "keyword",
"keyword": "void"
},
"hasBody": true,
"isAsync": false,
"isGenerator": false,
"typeParams": []
}
},
{
"name": "Foo",
"location": {
"filename": "file:///mod.ts",
"line": 1,
"col": 0,
"byteIndex": 0
},
"declarationKind": "private",
"kind": "import",
"importDef": {
"src": "file:///foo.ts",
"imported": "Foo"
}
}
]
Loading