diff --git a/es2panda/ir/ts/tsAsExpression.cpp b/es2panda/ir/ts/tsAsExpression.cpp index c67d15b4211c4677049471ec18233776f96d78c1..f3589c22866dec09025271a8ad5433f088f2a41d 100644 --- a/es2panda/ir/ts/tsAsExpression.cpp +++ b/es2panda/ir/ts/tsAsExpression.cpp @@ -36,7 +36,10 @@ void TSAsExpression::Dump(ir::AstDumper *dumper) const dumper->Add({{"type", "TSAsExpression"}, {"expression", expression_}, {"typeAnnotation", typeAnnotation_}}); } -void TSAsExpression::Compile([[maybe_unused]] compiler::PandaGen *pg) const {} +void TSAsExpression::Compile(compiler::PandaGen *pg) const +{ + expression_->Compile(pg); +} static bool IsValidConstAssertionArgument(checker::Checker *checker, const ir::AstNode *arg) { diff --git a/es2panda/ir/ts/tsAsExpression.h b/es2panda/ir/ts/tsAsExpression.h index ceb6fc2fd1481c6eda690734f4febb0731554eb4..10a18df7d8040d1d6ef384a0bbba74b77ea18d57 100644 --- a/es2panda/ir/ts/tsAsExpression.h +++ b/es2panda/ir/ts/tsAsExpression.h @@ -57,7 +57,7 @@ public: void Iterate(const NodeTraverser &cb) const override; void Dump(ir::AstDumper *dumper) const override; - void Compile([[maybe_unused]] compiler::PandaGen *pg) const override; + void Compile(compiler::PandaGen *pg) const override; checker::Type *Check(checker::Checker *checker) const override; void UpdateSelf(const NodeUpdater &cb, [[maybe_unused]] binder::Binder *binder) override; diff --git a/es2panda/ir/ts/tsTypeAssertion.cpp b/es2panda/ir/ts/tsTypeAssertion.cpp index cc09c201032314625fce2587dfd5d3e055fba1d9..2b20a6e91507960e1161adcb1f6237280cfb1ee9 100644 --- a/es2panda/ir/ts/tsTypeAssertion.cpp +++ b/es2panda/ir/ts/tsTypeAssertion.cpp @@ -30,7 +30,10 @@ void TSTypeAssertion::Dump(ir::AstDumper *dumper) const dumper->Add({{"type", "TSTypeAssertion"}, {"typeAnnotation", typeAnnotation_}, {"expression", expression_}}); } -void TSTypeAssertion::Compile([[maybe_unused]] compiler::PandaGen *pg) const {} +void TSTypeAssertion::Compile(compiler::PandaGen *pg) const +{ + expression_->Compile(pg); +} checker::Type *TSTypeAssertion::Check([[maybe_unused]] checker::Checker *checker) const { diff --git a/es2panda/ir/ts/tsTypeAssertion.h b/es2panda/ir/ts/tsTypeAssertion.h index afc8ced7fba8da815921bd328f080eb057d44534..583af00c2891a4293b058a58811a18eb26cb5b93 100644 --- a/es2panda/ir/ts/tsTypeAssertion.h +++ b/es2panda/ir/ts/tsTypeAssertion.h @@ -48,7 +48,7 @@ public: void Iterate(const NodeTraverser &cb) const override; void Dump(ir::AstDumper *dumper) const override; - void Compile([[maybe_unused]] compiler::PandaGen *pg) const override; + void Compile(compiler::PandaGen *pg) const override; checker::Type *Check([[maybe_unused]] checker::Checker *checker) const override; void UpdateSelf(const NodeUpdater &cb, [[maybe_unused]] binder::Binder *binder) override; diff --git a/es2panda/test/compiler/ts/cases/conformance/expressions/ts-test-as-expression-1-expected.txt b/es2panda/test/compiler/ts/cases/conformance/expressions/ts-test-as-expression-1-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..3fb63f8f28646bba273d258b751ca13407f77639 --- /dev/null +++ b/es2panda/test/compiler/ts/cases/conformance/expressions/ts-test-as-expression-1-expected.txt @@ -0,0 +1,2 @@ +1 +ts-test-as-expression-1 diff --git a/es2panda/test/compiler/ts/cases/conformance/expressions/ts-test-as-expression-1.ts b/es2panda/test/compiler/ts/cases/conformance/expressions/ts-test-as-expression-1.ts new file mode 100644 index 0000000000000000000000000000000000000000..f74d146f76df2b511e6e590541e7d27f46fb7eb6 --- /dev/null +++ b/es2panda/test/compiler/ts/cases/conformance/expressions/ts-test-as-expression-1.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +print(1 as number); +print("ts-test-as-expression-1" as string); \ No newline at end of file diff --git a/es2panda/test/compiler/ts/cases/conformance/expressions/ts-test-type-assertions-1-expected.txt b/es2panda/test/compiler/ts/cases/conformance/expressions/ts-test-type-assertions-1-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..5a303be25c97d43f1a2e9b858fa1c53e032e738d --- /dev/null +++ b/es2panda/test/compiler/ts/cases/conformance/expressions/ts-test-type-assertions-1-expected.txt @@ -0,0 +1,2 @@ +1 +ts-test-type-assertions-1 diff --git a/es2panda/test/compiler/ts/cases/conformance/expressions/ts-test-type-assertions-1.ts b/es2panda/test/compiler/ts/cases/conformance/expressions/ts-test-type-assertions-1.ts new file mode 100644 index 0000000000000000000000000000000000000000..03c54de422f3b630faf0ca9b51fcc8eb517ead6a --- /dev/null +++ b/es2panda/test/compiler/ts/cases/conformance/expressions/ts-test-type-assertions-1.ts @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +print(1); +print("ts-test-type-assertions-1"); \ No newline at end of file