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

fix(verbatim-module-syntax): do not flag declaration identifiers as being type only #1262

Merged
Merged
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
25 changes: 23 additions & 2 deletions src/rules/verbatim_module_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,9 @@ impl Visit for IdCollector {
self.id_usage.insert(n.to_id());
}

fn visit_binding_ident(&mut self, _: &BindingIdent) {
// skip
fn visit_binding_ident(&mut self, id: &BindingIdent) {
// mark declarations as usages for export declarations
self.id_usage.insert(id.id.to_id());
}

fn visit_import_decl(&mut self, n: &ImportDecl) {
Expand Down Expand Up @@ -392,6 +393,8 @@ mod tests {
"import { value, type Type } from 'module'; console.log(value); export type { Type };",
"import { value, type Type } from 'module'; export { value, type Type };",
"export { value } from './value.ts';",
"const logger = { setItems }; export { logger };",
"class Test {} export { Test };",
};
}

Expand Down Expand Up @@ -567,6 +570,24 @@ mod tests {
fix: (FIX_DESC, "import { value, type Type } from 'module'; export { value, type Type };"),
}
],
"interface Test {}\nexport { Test };": [
{
line: 2,
col: 0,
message: Message::AllExportIdentsUsedInTypes,
hint: Hint::ChangeExportToExportType,
fix: (FIX_DESC, "interface Test {}\nexport type { Test };"),
}
],
"type Test = 'test';\nexport { Test };": [
{
line: 2,
col: 0,
message: Message::AllExportIdentsUsedInTypes,
hint: Hint::ChangeExportToExportType,
fix: (FIX_DESC, "type Test = 'test';\nexport type { Test };"),
}
],
};
}
}
Loading