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

Switch from namespace syntax to declare module syntax #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk
/.idea
6 changes: 1 addition & 5 deletions src/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@

pub(crate) struct EmitCtx<'ctx> {
w: &'ctx mut dyn io::Write,
root_namespace: Option<&'ctx str>,

Check failure on line 156 in src/emit.rs

View workflow job for this annotation

GitHub Actions / Test

field `root_namespace` is never read

Check failure on line 156 in src/emit.rs

View workflow job for this annotation

GitHub Actions / Lint

field `root_namespace` is never read
indent: usize,
stats: Stats,
}
Expand Down Expand Up @@ -520,9 +520,6 @@
},
generic_args,
}) => {
if let Some(root_namespace) = self.root_namespace {
write!(self.w, "{}.", root_namespace)?;
}
for path_part in *path {
path_part.emit(self)?;
write!(self.w, ".")?;
Expand Down Expand Up @@ -614,8 +611,7 @@
writeln!(&mut ctx.w, "{}", header)?;
}
if let Some(root_namespace) = options.root_namespace {
writeln!(&mut ctx.w, "export default {};", root_namespace)?;
writeln!(&mut ctx.w, "export namespace {} {{", root_namespace)?;
writeln!(&mut ctx.w, r#"declare module "{}" {{"#, root_namespace)?;
ctx.indent();
}
ctx.emit_type_def(type_infos)?;
Expand Down
Loading