10000 swc_ecma_codegen not rendering ArrowExpr return_type · Issue #4305 · swc-project/swc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

swc_ecma_codegen not rendering ArrowExpr return_type #4305

New issue 8000

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

Closed
Dionysusnu opened this issue Apr 11, 2022 · 1 comment · Fixed by #4306
Closed

swc_ecma_codegen not rendering ArrowExpr return_type #4305

Dionysusnu opened this issue Apr 11, 2022 · 1 comment · Fixed by #4306
Labels
Milestone

Comments

@Dionysusnu
Copy link
Contributor

Describe the bug

swc_ecma_codegen does not render the return_type property of ArrowExpr

Input code

let cm = Lrc::new(SourceMap::default());
let code = {
	let mut buf = vec![];

	{
		let mut emitter = Emitter {
			cfg: swc_ecma_codegen::Config {
				..Default::default()
			},
			cm: cm.clone(),
			comments: None,
			wr: JsWriter::new(cm.clone(), "\n", &mut buf, None),
		};

		emitter
			.emit_module(&Module {
				body: vec![ModuleItem::Stmt(Stmt::Expr(ExprStmt {
					span: Default::default(),
					expr: boxed(Expr::Arrow(ArrowExpr {
						span: Default::default(),
						params: vec![],
						type_params: None,
						is_async: false,
						is_generator: false,
						body: BlockStmtOrExpr::Expr(boxed(Expr::Lit(Lit::Bool(Bool {
							span: Default::default(),
							value: true,
						})))),
						return_type: Some(TsTypeAnn {
							span: Default::default(),
							type_ann: boxed(TsType::TsLitType(TsLitType {
								span: Default::default(),
								lit: TsLit::Bool(Bool {
									span: Default::default(),
									value: true,
								}),
							})),
						}),
					})),
				}))],
				span: Default::default(),
				shebang: None,
			})
			.unwrap();
	}

	String::from_utf8_lossy(&buf).to_string()
};

Config

N/A

Playground link

No response

Expected behavior

The return type should be rendered if given, like it is for normal functions.

Actual behavior

The return type is not rendered.

Version

0.96.0 local, but issue also exists on the source of main branch

Additional context

No response

@swc-bot
Copy link
Collaborator
swc-bot commented Oct 16, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Oct 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants
0