fix(codegen): missing const keyword in TSTypeParamter (#4022)

close: #4017
This commit is contained in:
Dunqing 2024-07-02 13:47:24 +00:00
parent 243c9f35b0
commit 7844734856
2 changed files with 4 additions and 0 deletions

View file

@ -2994,6 +2994,9 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for TSLiteral<'a> {
impl<'a, const MINIFY: bool> Gen<MINIFY> for TSTypeParameter<'a> {
fn gen(&self, p: &mut Codegen<{ MINIFY }>, ctx: Context) {
if self.r#const {
p.print_str(b"const ");
}
self.name.gen(p, ctx);
if let Some(constraint) = &self.constraint {
p.print_str(b" extends ");

View file

@ -200,6 +200,7 @@ fn typescript() {
false,
);
test_ts("let foo: { <T>(t: T): void }", "let foo: {<T>(t: T): void};\n", false);
test_ts("function <const T>(){}", "function<const T>() {}\n", false);
}
fn test_comment_helper(source_text: &str, expected: &str) {