diff --git a/es2panda/BUILD.gn b/es2panda/BUILD.gn index 17dff9d9cdd6d0bdd9092612e130d56cb8686b94..847457188e5dd7c19018a2b5d32d44417a9f41ca 100644 --- a/es2panda/BUILD.gn +++ b/es2panda/BUILD.gn @@ -157,13 +157,16 @@ es2panda_src = [ "ir/ts/tsNullKeyword.cpp", "ir/ts/tsNumberKeyword.cpp", "ir/ts/tsObjectKeyword.cpp", + "ir/ts/tsOptionalType.cpp", "ir/ts/tsParameterProperty.cpp", "ir/ts/tsParenthesizedType.cpp", "ir/ts/tsPrivateIdentifier.cpp", "ir/ts/tsPropertySignature.cpp", "ir/ts/tsQualifiedName.cpp", + "ir/ts/tsRestType.cpp", "ir/ts/tsSignatureDeclaration.cpp", "ir/ts/tsStringKeyword.cpp", + "ir/ts/tsSymbolKeyword.cpp", "ir/ts/tsTemplateLiteralType.cpp", "ir/ts/tsThisType.cpp", "ir/ts/tsTupleType.cpp", @@ -227,6 +230,7 @@ es2panda_src = [ "typescript/types/signature.cpp", "typescript/types/stringLiteralType.cpp", "typescript/types/stringType.cpp", + "typescript/types/symbolType.cpp", "typescript/types/tupleType.cpp", "typescript/types/type.cpp", "typescript/types/typeParameter.cpp", diff --git a/es2panda/CMakeLists.txt b/es2panda/CMakeLists.txt index 9a213084ed639501358bb18e51bac2756085c22f..80e619467f5f4ab45c16b5e7a51456022fad7a14 100644 --- a/es2panda/CMakeLists.txt +++ b/es2panda/CMakeLists.txt @@ -206,13 +206,16 @@ set(ES2PANDA_LIB_SRC ir/ts/tsNullKeyword.cpp ir/ts/tsNumberKeyword.cpp ir/ts/tsObjectKeyword.cpp + ir/ts/tsOptionalType.cpp ir/ts/tsParameterProperty.cpp ir/ts/tsParenthesizedType.cpp ir/ts/tsPrivateIdentifier.cpp ir/ts/tsPropertySignature.cpp ir/ts/tsQualifiedName.cpp + ir/ts/tsRestType.cpp ir/ts/tsSignatureDeclaration.cpp ir/ts/tsStringKeyword.cpp + ir/ts/tsSymbolKeyword.cpp ir/ts/tsTemplateLiteralType.cpp ir/ts/tsThisType.cpp ir/ts/tsTupleType.cpp @@ -274,6 +277,7 @@ set(ES2PANDA_LIB_SRC typescript/types/signature.cpp typescript/types/stringLiteralType.cpp typescript/types/stringType.cpp + typescript/types/symbolType.cpp typescript/types/tupleType.cpp typescript/types/type.cpp typescript/types/typeParameter.cpp diff --git a/es2panda/ir/astNodeMapping.h b/es2panda/ir/astNodeMapping.h index 33c87d44a7d00171c69723ece769594a244fc7e3..aa260c1c870fbc482bc8e2e6575de31fe8ab5f07 100644 --- a/es2panda/ir/astNodeMapping.h +++ b/es2panda/ir/astNodeMapping.h @@ -78,6 +78,7 @@ _(TS_NUMBER_KEYWORD, TSNumberKeyword) \ _(TS_ANY_KEYWORD, TSAnyKeyword) \ _(TS_STRING_KEYWORD, TSStringKeyword) \ + _(TS_SYMBOL_KEYWORD, TSSymbolKeyword) \ _(TS_BOOLEAN_KEYWORD, TSBooleanKeyword) \ _(TS_VOID_KEYWORD, TSVoidKeyword) \ _(TS_UNDEFINED_KEYWORD, TSUndefinedKeyword) \ @@ -87,6 +88,8 @@ _(TS_NEVER_KEYWORD, TSNeverKeyword) \ _(TS_NON_NULL_EXPRESSION, TSNonNullExpression) \ _(TS_NULL_KEYWORD, TSNullKeyword) \ + _(TS_OPTIONAL_TYPE, TSOptionalType) \ + _(TS_REST_TYPE, TSRestType) \ _(TS_ARRAY_TYPE, TSArrayType) \ _(TS_UNION_TYPE, TSUnionType) \ _(TS_TYPE_LITERAL, TSTypeLiteral) \ diff --git a/es2panda/ir/ts/tsMappedType.cpp b/es2panda/ir/ts/tsMappedType.cpp index 4d2a57b13596623d43889122573146b071635147..37178340cfd5a7a0eb33c92cf57a8fcd13dda81f 100644 --- a/es2panda/ir/ts/tsMappedType.cpp +++ b/es2panda/ir/ts/tsMappedType.cpp @@ -33,6 +33,7 @@ void TSMappedType::Dump(ir::AstDumper *dumper) const dumper->Add( {{"type", "TSMappedType"}, {"typeParameter", typeParameter_}, + {"nameKeyType", AstDumper::Optional(nameKeyType_)}, {"typeAnnotation", AstDumper::Optional(typeAnnotation_)}, {"readonly", readonly_ == MappedOption::NO_OPTS ? AstDumper::Optional(false) diff --git a/es2panda/ir/ts/tsMappedType.h b/es2panda/ir/ts/tsMappedType.h index 6e24cb4d3c2bf12b7d82719b15567001cfcc9814..f7d32a45749be03ea7af6e03506216bf9ec37a30 100644 --- a/es2panda/ir/ts/tsMappedType.h +++ b/es2panda/ir/ts/tsMappedType.h @@ -32,10 +32,11 @@ namespace panda::es2panda::ir { class TSMappedType : public TypeNode { public: - explicit TSMappedType(TSTypeParameter *typeParameter, Expression *typeAnnotation, MappedOption readonly, - MappedOption optional) + explicit TSMappedType(TSTypeParameter *typeParameter, Expression *nameKeyType, Expression *typeAnnotation, + MappedOption readonly, MappedOption optional) : TypeNode(AstNodeType::TS_MAPPED_TYPE), typeParameter_(typeParameter), + nameKeyType_(nameKeyType), typeAnnotation_(typeAnnotation), readonly_(readonly), optional_(optional) @@ -70,6 +71,7 @@ public: private: TSTypeParameter *typeParameter_; + Expression *nameKeyType_; Expression *typeAnnotation_; MappedOption readonly_; MappedOption optional_; diff --git a/es2panda/ir/ts/tsNamedTupleMember.cpp b/es2panda/ir/ts/tsNamedTupleMember.cpp index 1d70a26cac5d7d128315ecf3a3171575fc3f4e32..5c76fbeef42276723b283e2dd812e2ba7bd48a56 100644 --- a/es2panda/ir/ts/tsNamedTupleMember.cpp +++ b/es2panda/ir/ts/tsNamedTupleMember.cpp @@ -30,7 +30,8 @@ void TSNamedTupleMember::Dump(ir::AstDumper *dumper) const dumper->Add({{"type", "TSNamedTupleMember"}, {"elementType", elementType_}, {"label", label_}, - {"optional", AstDumper::Optional(optional_)}}); + {"optional", AstDumper::Optional(optional_)}, + {"rest", AstDumper::Optional(rest_)}}); } void TSNamedTupleMember::Compile([[maybe_unused]] compiler::PandaGen *pg) const {} diff --git a/es2panda/ir/ts/tsNamedTupleMember.h b/es2panda/ir/ts/tsNamedTupleMember.h index b4c57030313bfc612bb8a6d1f34f6aff0059b878..135d4ed88972ef78c3f0fe05377db81daf3ecbcc 100644 --- a/es2panda/ir/ts/tsNamedTupleMember.h +++ b/es2panda/ir/ts/tsNamedTupleMember.h @@ -31,11 +31,12 @@ namespace panda::es2panda::ir { class TSNamedTupleMember : public Expression { public: - explicit TSNamedTupleMember(Expression *label, Expression *elementType, bool optional) + explicit TSNamedTupleMember(Expression *label, Expression *elementType, bool optional, bool rest) : Expression(AstNodeType::TS_NAMED_TUPLE_MEMBER), label_(label), elementType_(elementType), - optional_(optional) + optional_(optional), + rest_(rest) { } @@ -54,6 +55,11 @@ public: return optional_; } + bool IsRest() const + { + return rest_; + } + void Iterate(const NodeTraverser &cb) const override; void Dump(ir::AstDumper *dumper) const override; void Compile([[maybe_unused]] compiler::PandaGen *pg) const override; @@ -63,6 +69,7 @@ private: Expression *label_; Expression *elementType_; bool optional_; + bool rest_; }; } // namespace panda::es2panda::ir diff --git a/es2panda/ir/ts/tsOptionalType.cpp b/es2panda/ir/ts/tsOptionalType.cpp new file mode 100644 index 0000000000000000000000000000000000000000..297e6641ed2cd815248831cf9e58e41881fd914c --- /dev/null +++ b/es2panda/ir/ts/tsOptionalType.cpp @@ -0,0 +1,53 @@ +/* + * 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. + */ + +#include "tsOptionalType.h" + +#include +#include + +namespace panda::es2panda::ir { + +void TSOptionalType::Iterate(const NodeTraverser &cb) const +{ + cb(type_); +} + +void TSOptionalType::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSOptionalType"}, {"typeAnnotation", type_}}); +} + +void TSOptionalType::Compile([[maybe_unused]] compiler::PandaGen *pg) const {} + +checker::Type *TSOptionalType::Check([[maybe_unused]] checker::Checker *checker) const +{ + // TODO(xucheng): Implement checker for ts optional type + return nullptr; +} + +checker::Type *TSOptionalType::GetType(checker::Checker *checker) const +{ + auto found = checker->NodeCache().find(this); + if (found != checker->NodeCache().end()) { + return found->second; + } + + checker::Type *type = type_->AsTypeNode()->GetType(checker); + checker->NodeCache().insert({this, type}); + return type; +} + +} // namespace panda::es2panda::ir diff --git a/es2panda/ir/ts/tsOptionalType.h b/es2panda/ir/ts/tsOptionalType.h new file mode 100644 index 0000000000000000000000000000000000000000..3d9af242b0adadda008d206ea47cd65ff8cb4285 --- /dev/null +++ b/es2panda/ir/ts/tsOptionalType.h @@ -0,0 +1,40 @@ +/* + * 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. + */ + +#ifndef ES2PANDA_IR_TS_TSOPTIONAL_TYPE_H +#define ES2PANDA_IR_TS_TSOPTIONAL_TYPE_H + +#include +#include +#include + +namespace panda::es2panda::ir { + +class TSOptionalType : public TypeNode { +public: + explicit TSOptionalType(Expression *type) : TypeNode(AstNodeType::TS_OPTIONAL_TYPE), type_(type) {} + + void Iterate(const NodeTraverser &cb) const override; + void Dump(ir::AstDumper *dumper) const override; + void Compile([[maybe_unused]] compiler::PandaGen *pg) const override; + checker::Type *Check([[maybe_unused]] checker::Checker *checker) const override; + checker::Type *GetType(checker::Checker *checker) const override; + +private: + Expression *type_; +}; +} // namespace panda::es2panda::ir + +#endif diff --git a/es2panda/ir/ts/tsRestType.cpp b/es2panda/ir/ts/tsRestType.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a3ec1e049c96f80bd90a86d67919d9128edb6c6d --- /dev/null +++ b/es2panda/ir/ts/tsRestType.cpp @@ -0,0 +1,53 @@ +/* + * 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. + */ + +#include "tsRestType.h" + +#include +#include + +namespace panda::es2panda::ir { + +void TSRestType::Iterate(const NodeTraverser &cb) const +{ + cb(type_); +} + +void TSRestType::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSRestType"}, {"typeAnnotation", type_}}); +} + +void TSRestType::Compile([[maybe_unused]] compiler::PandaGen *pg) const {} + +checker::Type *TSRestType::Check([[maybe_unused]] checker::Checker *checker) const +{ + // TODO(xucheng): Implement checker for ts rest type + return nullptr; +} + +checker::Type *TSRestType::GetType(checker::Checker *checker) const +{ + auto found = checker->NodeCache().find(this); + if (found != checker->NodeCache().end()) { + return found->second; + } + + checker::Type *type = type_->AsTypeNode()->GetType(checker); + checker->NodeCache().insert({this, type}); + return type; +} + +} // namespace panda::es2panda::ir diff --git a/es2panda/ir/ts/tsRestType.h b/es2panda/ir/ts/tsRestType.h new file mode 100644 index 0000000000000000000000000000000000000000..419333842fe69b0c873e4fafa3f873fbba2c9704 --- /dev/null +++ b/es2panda/ir/ts/tsRestType.h @@ -0,0 +1,40 @@ +/* + * 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. + */ + +#ifndef ES2PANDA_IR_TS_TSREST_TYPE_H +#define ES2PANDA_IR_TS_TSREST_TYPE_H + +#include +#include +#include + +namespace panda::es2panda::ir { + +class TSRestType : public TypeNode { +public: + explicit TSRestType(Expression *type) : TypeNode(AstNodeType::TS_REST_TYPE), type_(type) {} + + void Iterate(const NodeTraverser &cb) const override; + void Dump(ir::AstDumper *dumper) const override; + void Compile([[maybe_unused]] compiler::PandaGen *pg) const override; + checker::Type *Check([[maybe_unused]] checker::Checker *checker) const override; + checker::Type *GetType(checker::Checker *checker) const override; + +private: + Expression *type_; +}; +} // namespace panda::es2panda::ir + +#endif diff --git a/es2panda/ir/ts/tsSymbolKeyword.cpp b/es2panda/ir/ts/tsSymbolKeyword.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7234176e4f226d871fe73878d2ddc61e77a98ccc --- /dev/null +++ b/es2panda/ir/ts/tsSymbolKeyword.cpp @@ -0,0 +1,43 @@ +/* + * 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. + */ + +#include "tsSymbolKeyword.h" + +#include +#include + +namespace panda::es2panda::ir { + +void TSSymbolKeyword::Iterate([[maybe_unused]] const NodeTraverser &cb) const {} + +void TSSymbolKeyword::Dump(ir::AstDumper *dumper) const +{ + dumper->Add({{"type", "TSSymbolKeyword"}}); +} + +void TSSymbolKeyword::Compile([[maybe_unused]] compiler::PandaGen *pg) const {} + +checker::Type *TSSymbolKeyword::Check([[maybe_unused]] checker::Checker *checker) const +{ + // TODO(xucheng): Implement checker for ts symbol keyword + return nullptr; +} + +checker::Type *TSSymbolKeyword::GetType(checker::Checker *checker) const +{ + return checker->GlobalSymbolType(); +} + +} // namespace panda::es2panda::ir diff --git a/es2panda/ir/ts/tsSymbolKeyword.h b/es2panda/ir/ts/tsSymbolKeyword.h new file mode 100644 index 0000000000000000000000000000000000000000..27e20304e8d6135642428b37d58ffec8bf7d4cd6 --- /dev/null +++ b/es2panda/ir/ts/tsSymbolKeyword.h @@ -0,0 +1,37 @@ +/* + * 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. + */ + +#ifndef ES2PANDA_IR_TS_TSSYMBOL_KEYWORD_H +#define ES2PANDA_IR_TS_TSSYMBOL_KEYWORD_H + +#include +#include +#include + +namespace panda::es2panda::ir { + +class TSSymbolKeyword : public TypeNode { +public: + explicit TSSymbolKeyword() : TypeNode(AstNodeType::TS_SYMBOL_KEYWORD) {} + + void Iterate(const NodeTraverser &cb) const override; + void Dump(ir::AstDumper *dumper) const override; + void Compile([[maybe_unused]] compiler::PandaGen *pg) const override; + checker::Type *Check([[maybe_unused]] checker::Checker *checker) const override; + checker::Type *GetType(checker::Checker *checker) const override; +}; +} // namespace panda::es2panda::ir + +#endif diff --git a/es2panda/lexer/scripts/keywords.rb b/es2panda/lexer/scripts/keywords.rb index d3ae98705f3d2978a730be8d6c4d4e51669d5812..00183eca598516ac9d14a31a71cc49e37477def3 100644 --- a/es2panda/lexer/scripts/keywords.rb +++ b/es2panda/lexer/scripts/keywords.rb @@ -142,6 +142,7 @@ keywords = [ "string" => ["TokenType::LITERAL_IDENT", "TokenType::KEYW_STRING"], "super" => ["TokenType::KEYW_SUPER", "TokenType::KEYW_SUPER"], "switch" => ["TokenType::KEYW_SWITCH", "TokenType::KEYW_SWITCH"], + "symbol" => ["TokenType::LITERAL_IDENT", "TokenType::KEYW_SYMBOL"], }, # keywords start with 't' @@ -157,6 +158,7 @@ keywords = [ # keywords start with 'u' { "undefined" => ["TokenType::LITERAL_IDENT", "TokenType::KEYW_UNDEFINED"], + "unique" => ["TokenType::LITERAL_IDENT", "TokenType::KEYW_UNIQUE"], "unknown" => ["TokenType::LITERAL_IDENT", "TokenType::KEYW_UNKNOWN"], }, diff --git a/es2panda/lexer/token/tokenType.h b/es2panda/lexer/token/tokenType.h index 48f53a5099f3baa9fd044b41bcbbb764b60d9c7d..29ddcfe28d6f2e39002f3b8ecca4df17ef8d9293 100644 --- a/es2panda/lexer/token/tokenType.h +++ b/es2panda/lexer/token/tokenType.h @@ -140,6 +140,7 @@ enum class TokenType { KEYW_STRING, KEYW_SUPER, KEYW_SWITCH, + KEYW_SYMBOL, KEYW_THIS, KEYW_THROW, KEYW_TYPE, @@ -155,6 +156,7 @@ enum class TokenType { KEYW_ASYNC, KEYW_READONLY, KEYW_KEYOF, + KEYW_UNIQUE, KEYW_MODULE, KEYW_NAMESPACE, KEYW_INFER, diff --git a/es2panda/parser/expressionParser.cpp b/es2panda/parser/expressionParser.cpp index e66239d1893d2a2d1d6f74b61677e1ce24c94336..e0d85967de1c11bda4a81071240bed2534789890 100644 --- a/es2panda/parser/expressionParser.cpp +++ b/es2panda/parser/expressionParser.cpp @@ -1457,11 +1457,21 @@ bool ParserImpl::ParsePotentialTsGenericFunctionCall(ir::Expression **returnExpr const auto savedPos = lexer_->Save(); + bool isLeftShift = false; if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_LEFT_SHIFT) { lexer_->BackwardToken(lexer::TokenType::PUNCTUATOR_LESS_THAN, 1); + isLeftShift = true; } - ir::TSTypeParameterInstantiation *typeParams = ParseTsTypeParameterInstantiation(false); + ir::TSTypeParameterInstantiation *typeParams; + try { + typeParams = ParseTsTypeParameterInstantiation(false); + } catch (const Error &e) { + if (!isLeftShift) { + throw e; + } + typeParams = nullptr; + } if (!typeParams) { lexer_->Rewind(savedPos); diff --git a/es2panda/parser/parserImpl.cpp b/es2panda/parser/parserImpl.cpp index d3039e2a13f1e9f951552eec55d0d17801a936de..b94cd55f1b603e94c2112a7b3b3f76b78b3d4f9e 100644 --- a/es2panda/parser/parserImpl.cpp +++ b/es2panda/parser/parserImpl.cpp @@ -70,13 +70,16 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include +#include #include #include #include @@ -189,6 +192,7 @@ bool ParserImpl::CurrentLiteralIsBasicType() case lexer::TokenType::KEYW_BOOLEAN: case lexer::TokenType::KEYW_NUMBER: case lexer::TokenType::KEYW_STRING: + case lexer::TokenType::KEYW_SYMBOL: case lexer::TokenType::KEYW_UNKNOWN: case lexer::TokenType::KEYW_UNDEFINED: case lexer::TokenType::KEYW_NEVER: @@ -716,6 +720,7 @@ ir::Expression *ParserImpl::ParseTsTypeOperatorOrTypeReference() options |= TypeAnnotationParsingOptions::IN_MODIFIER; ir::Expression *type = ParseTsTypeAnnotation(&options); + ASSERT(type != nullptr); if (!type->IsTSArrayType() && !type->IsTSTupleType()) { ThrowSyntaxError( @@ -736,6 +741,7 @@ ir::Expression *ParserImpl::ParseTsTypeOperatorOrTypeReference() options |= TypeAnnotationParsingOptions::IN_MODIFIER; ir::Expression *type = ParseTsTypeAnnotation(&options); + ASSERT(type != nullptr); auto *typeOperator = AllocNode(type, ir::TSOperatorType::KEYOF); @@ -744,6 +750,20 @@ ir::Expression *ParserImpl::ParseTsTypeOperatorOrTypeReference() return typeOperator; } + if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_UNIQUE) { + lexer::SourcePosition typeOperatorStart = lexer_->GetToken().Start(); + lexer_->NextToken(); + + ir::Expression *type = ParseTsTypeAnnotation(&options); + ASSERT(type != nullptr); + + auto *typeOperator = AllocNode(type, ir::TSOperatorType::UNIQUE); + + typeOperator->SetRange({typeOperatorStart, type->End()}); + + return typeOperator; + } + if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_INFER) { if (!(context_.Status() & ParserStatus::IN_EXTENDS)) { ThrowSyntaxError( @@ -766,59 +786,84 @@ ir::Expression *ParserImpl::ParseTsTypeOperatorOrTypeReference() return ParseTsIdentifierReference(); } +bool ParserImpl::IsTSNamedTupleMember() +{ + if (lexer_->GetToken().Type() != lexer::TokenType::LITERAL_IDENT) { + return false; + } + const auto savePos = lexer_->Save(); + bool isNamedMember = false; + lexer_->NextToken(); + if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_COLON || + (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_QUESTION_MARK && + lexer_->Lookahead() == LEX_CHAR_COLON)) { + isNamedMember = true; + } + lexer_->Rewind(savePos); + return isNamedMember; +} + ir::Expression *ParserImpl::ParseTsTupleElement(ir::TSTupleKind *kind, bool *seenOptional) { - lexer::SourcePosition elementStart = lexer_->GetToken().Start(); + lexer::SourcePosition startPos = lexer_->GetToken().Start(); ir::Expression *element = nullptr; bool isOptional = false; + bool isRestType = false; TypeAnnotationParsingOptions options = TypeAnnotationParsingOptions::THROW_ERROR; - if (lexer_->GetToken().Type() == lexer::TokenType::LITERAL_IDENT && !CurrentLiteralIsBasicType()) { - auto *elementIdent = AllocNode(lexer_->GetToken().Ident(), Allocator()); - elementIdent->SetRange(lexer_->GetToken().Loc()); + if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_PERIOD_PERIOD_PERIOD) { + isRestType = true; + lexer_->NextToken(); // eat '...' + } - if (lexer_->Lookahead() == LEX_CHAR_COLON || lexer_->Lookahead() == LEX_CHAR_QUESTION) { - if (*kind == ir::TSTupleKind::DEFAULT) { - ThrowSyntaxError("Tuple members must all have names or all not have names"); - } + if (IsTSNamedTupleMember()) { + if (*kind == ir::TSTupleKind::DEFAULT) { + ThrowSyntaxError("Tuple members must all have or haven't names"); + } + *kind = ir::TSTupleKind::NAMED; - lexer_->NextToken(); // eat ident + auto *elementIdent = AllocNode(lexer_->GetToken().Ident(), Allocator()); + elementIdent->SetRange(lexer_->GetToken().Loc()); + lexer_->NextToken(); // eat identifier - if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_QUESTION_MARK) { - lexer_->NextToken(); // eat '?' - isOptional = true; - *seenOptional = true; - } else if (*seenOptional) { - ThrowSyntaxError("A required element cannot follow an optional element"); - } + if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_QUESTION_MARK) { + lexer_->NextToken(); // eat '?' + isOptional = true; + *seenOptional = true; + } else if (*seenOptional) { + ThrowSyntaxError("A required element cannot follow an optional element"); + } - if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_COLON) { - ThrowSyntaxError("':' expected"); - } + if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_COLON) { + ThrowSyntaxError("':' expected"); + } - lexer_->NextToken(); // eat ':' - auto *elementType = ParseTsTypeAnnotation(&options); - *kind = ir::TSTupleKind::NAMED; + lexer_->NextToken(); // eat ':' + auto *elementType = ParseTsTypeAnnotation(&options); + ASSERT(elementType != nullptr); - element = AllocNode(elementIdent, elementType, isOptional); - } else { - element = ParseTsTypeReferenceOrQuery(); - } - if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_COMMA && - lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_SQUARE_BRACKET) { - element = ParseTsTypeAnnotationElement(element, &options); - } + element = AllocNode(elementIdent, elementType, isOptional, isRestType); + element->SetRange({startPos, elementType->End()}); } else { if (*kind == ir::TSTupleKind::NAMED) { - ThrowSyntaxError("Tuple members must all have names or all not have names"); + ThrowSyntaxError("Tuple members must all have or haven't names"); } - *kind = ir::TSTupleKind::DEFAULT; + element = ParseTsTypeAnnotation(&options); - } + ASSERT(element != nullptr); + if (element && isRestType) { + lexer::SourcePosition endPos = element->End(); + element = AllocNode(std::move(element)); + element->SetRange({startPos, endPos}); + } - if (element) { - element->SetRange({elementStart, lexer_->GetToken().End()}); + if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_QUESTION_MARK) { + lexer::SourcePosition elementStartPos = element->Start(); + element = AllocNode(std::move(element)); + element->SetRange({elementStartPos, lexer_->GetToken().End()}); + lexer_->NextToken(); // eat '?' + } } return element; } @@ -835,6 +880,7 @@ ir::TSTupleType *ParserImpl::ParseTsTupleType() while (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_SQUARE_BRACKET) { ir::Expression *element = ParseTsTupleElement(&kind, &seenOptional); + elements.push_back(element); if (lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_RIGHT_SQUARE_BRACKET) { @@ -1037,6 +1083,14 @@ ir::TSMappedType *ParserImpl::ParseTsMappedType() ir::TSTypeParameter *typeParameter = ParseTsMappedTypeParameter(); + ir::Expression *nameKeyType = nullptr; + if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_AS) { + lexer_->NextToken(); // eat 'as' + TypeAnnotationParsingOptions options = TypeAnnotationParsingOptions::THROW_ERROR; + nameKeyType = ParseTsTypeAnnotation(&options); + ASSERT(nameKeyType != nullptr); + } + if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_SQUARE_BRACKET) { ThrowSyntaxError("']' expected"); } @@ -1065,7 +1119,7 @@ ir::TSMappedType *ParserImpl::ParseTsMappedType() ThrowSyntaxError("'}' expected"); } - auto *mappedType = AllocNode(typeParameter, typeAnnotation, readonly, optional); + auto *mappedType = AllocNode(typeParameter, nameKeyType, typeAnnotation, readonly, optional); mappedType->SetRange({startLoc, lexer_->GetToken().End()}); @@ -1706,6 +1760,8 @@ ir::Expression *ParserImpl::ParseTsBasicType() typeAnnotation = AllocNode(); } else if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_BIGINT) { typeAnnotation = AllocNode(); + } else if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_SYMBOL) { + typeAnnotation = AllocNode(); } else { ThrowSyntaxError("Unexpected type"); } @@ -2082,7 +2138,8 @@ ir::Expression *ParserImpl::ParseClassKey(ClassElmentDescriptor *desc, bool isDe desc->invalidComputedProperty = !propName->IsNumberLiteral() && !propName->IsStringLiteral() && !(propName->IsMemberExpression() && propName->AsMemberExpression()->Object()->IsIdentifier() && - propName->AsMemberExpression()->Object()->AsIdentifier()->Name().Is("Symbol")); + propName->AsMemberExpression()->Object()->AsIdentifier()->Name().Is("Symbol")) && + !propName->IsIdentifier(); } if (lexer_->GetToken().Type() != lexer::TokenType::PUNCTUATOR_RIGHT_SQUARE_BRACKET) { diff --git a/es2panda/parser/parserImpl.h b/es2panda/parser/parserImpl.h index ed541f881ccf5b7feb311e87864fc6f77f279228..3bc4cc2811c71fb447b37e7477fd1c6a24fa8dc6 100644 --- a/es2panda/parser/parserImpl.h +++ b/es2panda/parser/parserImpl.h @@ -251,6 +251,7 @@ private: ir::Expression *ParseTsIndexAccessType(ir::Expression *typeName); ir::Expression *ParseTsQualifiedReference(ir::Expression *typeName); ir::Expression *ParseTsTypeReferenceOrQuery(bool parseQuery = false); + bool IsTSNamedTupleMember(); ir::Expression *ParseTsTupleElement(ir::TSTupleKind *kind, bool *seenOptional); ir::TSTupleType *ParseTsTupleType(); ir::TSImportType *ParseTsImportType(const lexer::SourcePosition &startLoc, bool isTypeof = false); diff --git a/es2panda/test/parser/ts/test-enum-declaration6-expected.txt b/es2panda/test/parser/ts/test-enum-declaration6-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..a679aa60af1509a7690c94d05e458887c6930ff4 --- /dev/null +++ b/es2panda/test/parser/ts/test-enum-declaration6-expected.txt @@ -0,0 +1,374 @@ +{ + "type": "Program", + "statements": [ + { + "type": "TSEnumDeclaration", + "id": { + "type": "Identifier", + "name": "ShiftE", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 6 + }, + "end": { + "line": 17, + "column": 12 + } + } + }, + "members": [ + { + "type": "TSEnumMember", + "id": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 6 + } + } + }, + "initializer": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 18, + "column": 9 + }, + "end": { + "line": 18, + "column": 10 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 9 + }, + "end": { + "line": 18, + "column": 11 + } + } + }, + { + "type": "TSEnumMember", + "id": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 19, + "column": 6 + } + } + }, + "initializer": { + "type": "BinaryExpression", + "operator": "<<", + "left": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 10 + } + } + }, + "right": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 14 + }, + "end": { + "line": 19, + "column": 15 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 15 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 16 + } + } + }, + { + "type": "TSEnumMember", + "id": { + "type": "Identifier", + "name": "C", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 5 + }, + "end": { + "line": 20, + "column": 6 + } + } + }, + "initializer": { + "type": "BinaryExpression", + "operator": "<<", + "left": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 9 + }, + "end": { + "line": 20, + "column": 10 + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 20, + "column": 14 + }, + "end": { + "line": 20, + "column": 15 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 9 + }, + "end": { + "line": 20, + "column": 15 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 9 + }, + "end": { + "line": 20, + "column": 16 + } + } + }, + { + "type": "TSEnumMember", + "id": { + "type": "Identifier", + "name": "D", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 6 + } + } + }, + "initializer": { + "type": "BinaryExpression", + "operator": "<<", + "left": { + "type": "Identifier", + "name": "C", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 9 + }, + "end": { + "line": 21, + "column": 10 + } + } + }, + "right": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 14 + }, + "end": { + "line": 21, + "column": 15 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 9 + }, + "end": { + "line": 21, + "column": 15 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 9 + }, + "end": { + "line": 21, + "column": 16 + } + } + }, + { + "type": "TSEnumMember", + "id": { + "type": "Identifier", + "name": "E", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 5 + }, + "end": { + "line": 22, + "column": 6 + } + } + }, + "initializer": { + "type": "BinaryExpression", + "operator": "<<", + "left": { + "type": "Identifier", + "name": "D", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 9 + }, + "end": { + "line": 22, + "column": 10 + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 22, + "column": 14 + }, + "end": { + "line": 22, + "column": 15 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 9 + }, + "end": { + "line": 22, + "column": 15 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 9 + }, + "end": { + "line": 22, + "column": 16 + } + } + } + ], + "const": false, + "loc": { + "start": { + "line": 17, + "column": 1 + }, + "end": { + "line": 23, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 23, + "column": 2 + } + } +} diff --git a/es2panda/test/parser/ts/test-enum-declaration6.ts b/es2panda/test/parser/ts/test-enum-declaration6.ts new file mode 100644 index 0000000000000000000000000000000000000000..3fb14ee9947390d321df583b64d90925247a26c9 --- /dev/null +++ b/es2panda/test/parser/ts/test-enum-declaration6.ts @@ -0,0 +1,23 @@ +/* + * 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. + */ + + +enum ShiftE { + A = 1, + B = A << A, + C = B << 1, + D = C << B, + E = D << 2, +} \ No newline at end of file diff --git a/es2panda/test/parser/ts/test-func-param-expected.txt b/es2panda/test/parser/ts/test-func-param-expected.txt index 6a8699ea817851939714c3ebbcce6c70937ffef3..360ebf454c91f3f2d4d18c9c47109229aeec18d3 100644 --- a/es2panda/test/parser/ts/test-func-param-expected.txt +++ b/es2panda/test/parser/ts/test-func-param-expected.txt @@ -678,7 +678,7 @@ }, "end": { "line": 21, - "column": 32 + "column": 31 } } }, @@ -691,7 +691,7 @@ }, "end": { "line": 21, - "column": 40 + "column": 39 } } } @@ -1270,7 +1270,7 @@ }, "end": { "line": 23, - "column": 40 + "column": 39 } } }, @@ -1283,7 +1283,7 @@ }, "end": { "line": 23, - "column": 48 + "column": 47 } } } @@ -1662,7 +1662,7 @@ }, "end": { "line": 25, - "column": 41 + "column": 40 } } }, @@ -1675,7 +1675,7 @@ }, "end": { "line": 25, - "column": 49 + "column": 48 } } } diff --git a/es2panda/test/parser/ts/test-ts-key-remapping-via-as-expected.txt b/es2panda/test/parser/ts/test-ts-key-remapping-via-as-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..d93d9a732179ea2aec3cd5c1dd6366a67fe81d7a --- /dev/null +++ b/es2panda/test/parser/ts/test-ts-key-remapping-via-as-expected.txt @@ -0,0 +1,900 @@ +{ + "type": "Program", + "statements": [ + { + "type": "TSTypeAliasDeclaration", + "id": { + "type": "Identifier", + "name": "GetName", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 6 + }, + "end": { + "line": 17, + "column": 13 + } + } + }, + "typeAnnotation": { + "type": "TSMappedType", + "typeParameter": { + "type": "TSTypeParameter", + "name": { + "type": "Identifier", + "name": "p", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 6 + }, + "end": { + "line": 18, + "column": 7 + } + } + }, + "constraint": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "name": "Type", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 11 + }, + "end": { + "line": 18, + "column": 15 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 11 + }, + "end": { + "line": 18, + "column": 15 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 6 + }, + "end": { + "line": 18, + "column": 15 + } + } + }, + "nameKeyType": { + "type": "TSIndexedAccessType", + "objectType": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "name": "p", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 19 + }, + "end": { + "line": 18, + "column": 20 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 19 + }, + "end": { + "line": 18, + "column": 21 + } + } + }, + "indexType": { + "type": "TSLiteralType", + "literal": { + "type": "StringLiteral", + "value": "name", + "loc": { + "start": { + "line": 18, + "column": 21 + }, + "end": { + "line": 18, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 21 + }, + "end": { + "line": 18, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 19 + }, + "end": { + "line": 18, + "column": 29 + } + } + }, + "typeAnnotation": { + "type": "TSNumberKeyword", + "loc": { + "start": { + "line": 18, + "column": 32 + }, + "end": { + "line": 18, + "column": 38 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 45 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "params": [ + { + "type": "TSTypeParameter", + "name": { + "type": "Identifier", + "name": "Type", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 14 + }, + "end": { + "line": 17, + "column": 18 + } + } + }, + "constraint": { + "type": "TSTypeLiteral", + "members": [ + { + "type": "TSPropertySignature", + "computed": false, + "optional": false, + "readonly": false, + "key": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 28 + }, + "end": { + "line": 17, + "column": 32 + } + } + }, + "typeAnnotation": { + "type": "TSStringKeyword", + "loc": { + "start": { + "line": 17, + "column": 34 + }, + "end": { + "line": 17, + "column": 40 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 28 + }, + "end": { + "line": 17, + "column": 41 + } + } + } + ], + "loc": { + "start": { + "line": 17, + "column": 27 + }, + "end": { + "line": 17, + "column": 41 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 14 + }, + "end": { + "line": 17, + "column": 42 + } + } + } + ], + "loc": { + "start": { + "line": 17, + "column": 13 + }, + "end": { + "line": 17, + "column": 42 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 1 + }, + "end": { + "line": 20, + "column": 5 + } + } + }, + { + "type": "TSTypeAliasDeclaration", + "id": { + "type": "Identifier", + "name": "NameA", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 6 + }, + "end": { + "line": 20, + "column": 11 + } + } + }, + "typeAnnotation": { + "type": "TSTypeLiteral", + "members": [ + { + "type": "TSPropertySignature", + "computed": false, + "optional": false, + "readonly": false, + "key": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 15 + }, + "end": { + "line": 20, + "column": 19 + } + } + }, + "typeAnnotation": { + "type": "TSLiteralType", + "literal": { + "type": "StringLiteral", + "value": "A", + "loc": { + "start": { + "line": 20, + "column": 21 + }, + "end": { + "line": 20, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 21 + }, + "end": { + "line": 20, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 15 + }, + "end": { + "line": 20, + "column": 25 + } + } + }, + { + "type": "TSPropertySignature", + "computed": false, + "optional": false, + "readonly": false, + "key": { + "type": "Identifier", + "name": "kind", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 26 + }, + "end": { + "line": 20, + "column": 30 + } + } + }, + "typeAnnotation": { + "type": "TSStringKeyword", + "loc": { + "start": { + "line": 20, + "column": 32 + }, + "end": { + "line": 20, + "column": 38 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 26 + }, + "end": { + "line": 20, + "column": 39 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 14 + }, + "end": { + "line": 20, + "column": 39 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 21, + "column": 5 + } + } + }, + { + "type": "TSTypeAliasDeclaration", + "id": { + "type": "Identifier", + "name": "NameB", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 6 + }, + "end": { + "line": 21, + "column": 11 + } + } + }, + "typeAnnotation": { + "type": "TSTypeLiteral", + "members": [ + { + "type": "TSPropertySignature", + "computed": false, + "optional": false, + "readonly": false, + "key": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 15 + }, + "end": { + "line": 21, + "column": 19 + } + } + }, + "typeAnnotation": { + "type": "TSLiteralType", + "literal": { + "type": "StringLiteral", + "value": "B", + "loc": { + "start": { + "line": 21, + "column": 21 + }, + "end": { + "line": 21, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 21 + }, + "end": { + "line": 21, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 15 + }, + "end": { + "line": 21, + "column": 25 + } + } + }, + { + "type": "TSPropertySignature", + "computed": false, + "optional": false, + "readonly": false, + "key": { + "type": "Identifier", + "name": "kind", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 26 + }, + "end": { + "line": 21, + "column": 30 + } + } + }, + "typeAnnotation": { + "type": "TSStringKeyword", + "loc": { + "start": { + "line": 21, + "column": 32 + }, + "end": { + "line": 21, + "column": 38 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 26 + }, + "end": { + "line": 21, + "column": 39 + } + } + } + ], + "loc": { + "start": { + "line": 21, + "column": 14 + }, + "end": { + "line": 21, + "column": 39 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 1 + }, + "end": { + "line": 22, + "column": 5 + } + } + }, + { + "type": "TSTypeAliasDeclaration", + "id": { + "type": "Identifier", + "name": "NameC", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 6 + }, + "end": { + "line": 22, + "column": 11 + } + } + }, + "typeAnnotation": { + "type": "TSTypeLiteral", + "members": [ + { + "type": "TSPropertySignature", + "computed": false, + "optional": false, + "readonly": false, + "key": { + "type": "Identifier", + "name": "name", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 15 + }, + "end": { + "line": 22, + "column": 19 + } + } + }, + "typeAnnotation": { + "type": "TSLiteralType", + "literal": { + "type": "StringLiteral", + "value": "C", + "loc": { + "start": { + "line": 22, + "column": 21 + }, + "end": { + "line": 22, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 21 + }, + "end": { + "line": 22, + "column": 24 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 15 + }, + "end": { + "line": 22, + "column": 25 + } + } + }, + { + "type": "TSPropertySignature", + "computed": false, + "optional": false, + "readonly": false, + "key": { + "type": "Identifier", + "name": "kind", + "decorators": [], + "loc": { + "start": { + "line": 22, + "column": 26 + }, + "end": { + "line": 22, + "column": 30 + } + } + }, + "typeAnnotation": { + "type": "TSStringKeyword", + "loc": { + "start": { + "line": 22, + "column": 32 + }, + "end": { + "line": 22, + "column": 38 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 26 + }, + "end": { + "line": 22, + "column": 39 + } + } + } + ], + "loc": { + "start": { + "line": 22, + "column": 14 + }, + "end": { + "line": 22, + "column": 39 + } + } + }, + "loc": { + "start": { + "line": 22, + "column": 1 + }, + "end": { + "line": 23, + "column": 5 + } + } + }, + { + "type": "TSTypeAliasDeclaration", + "id": { + "type": "Identifier", + "name": "Name", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 6 + }, + "end": { + "line": 23, + "column": 10 + } + } + }, + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "name": "GetName", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 13 + }, + "end": { + "line": 23, + "column": 20 + } + } + }, + "typeParameters": { + "type": "TSTypeParameterInstantiation", + "params": [ + { + "type": "TSUnionType", + "types": [ + { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "name": "NameA", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 21 + }, + "end": { + "line": 23, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 21 + }, + "end": { + "line": 23, + "column": 26 + } + } + }, + { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "name": "NameB", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 29 + }, + "end": { + "line": 23, + "column": 34 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 29 + }, + "end": { + "line": 23, + "column": 34 + } + } + }, + { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "name": "NameC", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 37 + }, + "end": { + "line": 23, + "column": 42 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 37 + }, + "end": { + "line": 23, + "column": 42 + } + } + } + ], + "loc": { + "start": { + "line": 23, + "column": 21 + }, + "end": { + "line": 23, + "column": 42 + } + } + } + ], + "loc": { + "start": { + "line": 23, + "column": 13 + }, + "end": { + "line": 23, + "column": 43 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 13 + }, + "end": { + "line": 23, + "column": 20 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 1 + }, + "end": { + "line": 23, + "column": 43 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 23, + "column": 43 + } + } +} diff --git a/es2panda/test/parser/ts/test-ts-key-remapping-via-as.ts b/es2panda/test/parser/ts/test-ts-key-remapping-via-as.ts new file mode 100644 index 0000000000000000000000000000000000000000..432297669cf58356b45c69b0ac3c83d46713e989 --- /dev/null +++ b/es2panda/test/parser/ts/test-ts-key-remapping-via-as.ts @@ -0,0 +1,23 @@ +/* + * 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. + */ + + +type GetName = { + [p in Type as p["name"]] : number; +} +type NameA = {name: "A", kind: string} +type NameB = {name: "B", kind: string} +type NameC = {name: "C", kind: string} +type Name = GetName \ No newline at end of file diff --git a/es2panda/test/parser/ts/test-ts-symbol-type-expected.txt b/es2panda/test/parser/ts/test-ts-symbol-type-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..500309772e579ebd7cd8c69b1462a16d0bf3cb01 --- /dev/null +++ b/es2panda/test/parser/ts/test-ts-symbol-type-expected.txt @@ -0,0 +1,268 @@ +{ + "type": "Program", + "statements": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "s", + "typeAnnotation": { + "type": "TSSymbolKeyword", + "loc": { + "start": { + "line": 17, + "column": 9 + }, + "end": { + "line": 17, + "column": 15 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 6 + } + } + }, + "init": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "Symbol", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 18 + }, + "end": { + "line": 17, + "column": 24 + } + } + }, + "arguments": [ + { + "type": "StringLiteral", + "value": "foo", + "loc": { + "start": { + "line": 17, + "column": 25 + }, + "end": { + "line": 17, + "column": 30 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 17, + "column": 18 + }, + "end": { + "line": 17, + "column": 31 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 31 + } + } + } + ], + "kind": "var", + "loc": { + "start": { + "line": 17, + "column": 1 + }, + "end": { + "line": 17, + "column": 32 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "symbolVar", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 14 + } + } + }, + "init": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "method": false, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 19, + "column": 6 + } + } + }, + "value": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 10 + } + } + }, + "kind": "init", + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 19, + "column": 10 + } + } + }, + { + "type": "Property", + "method": false, + "shorthand": false, + "computed": true, + "key": { + "type": "Identifier", + "name": "s", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 6 + }, + "end": { + "line": 20, + "column": 7 + } + } + }, + "value": { + "type": "StringLiteral", + "value": "string", + "loc": { + "start": { + "line": 20, + "column": 11 + }, + "end": { + "line": 20, + "column": 19 + } + } + }, + "kind": "init", + "loc": { + "start": { + "line": 20, + "column": 5 + }, + "end": { + "line": 20, + "column": 19 + } + } + } + ], + "loc": { + "start": { + "line": 18, + "column": 17 + }, + "end": { + "line": 21, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 21, + "column": 2 + } + } + } + ], + "kind": "var", + "loc": { + "start": { + "line": 18, + "column": 1 + }, + "end": { + "line": 21, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 21, + "column": 2 + } + } +} diff --git a/es2panda/test/parser/ts/test-ts-symbol-type.ts b/es2panda/test/parser/ts/test-ts-symbol-type.ts new file mode 100644 index 0000000000000000000000000000000000000000..8b2e79d3b47b7d122067a754d80f0303130399dd --- /dev/null +++ b/es2panda/test/parser/ts/test-ts-symbol-type.ts @@ -0,0 +1,21 @@ +/* + * 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. + */ + + +var s : symbol = Symbol("foo"); +var symbolVar = { + a : 1, + [s] : "string", +} \ No newline at end of file diff --git a/es2panda/test/parser/ts/test-ts-unique-symbol-type-expected.txt b/es2panda/test/parser/ts/test-ts-unique-symbol-type-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c8f6a920d160e50bf9b1274759436bb60f7a60d7 --- /dev/null +++ b/es2panda/test/parser/ts/test-ts-unique-symbol-type-expected.txt @@ -0,0 +1,363 @@ +{ + "type": "Program", + "statements": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "s2", + "typeAnnotation": { + "type": "TSTypeOperator", + "operator": "unique", + "typeAnnotation": { + "type": "TSSymbolKeyword", + "loc": { + "start": { + "line": 17, + "column": 19 + }, + "end": { + "line": 17, + "column": 25 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 12 + }, + "end": { + "line": 17, + "column": 25 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 7 + }, + "end": { + "line": 17, + "column": 9 + } + } + }, + "init": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "Symbol", + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 28 + }, + "end": { + "line": 17, + "column": 34 + } + } + }, + "arguments": [], + "optional": false, + "loc": { + "start": { + "line": 17, + "column": 28 + }, + "end": { + "line": 17, + "column": 36 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 7 + }, + "end": { + "line": 17, + "column": 36 + } + } + } + ], + "kind": "const", + "loc": { + "start": { + "line": 17, + "column": 1 + }, + "end": { + "line": 17, + "column": 37 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "SymbolClass", + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 7 + }, + "end": { + "line": 18, + "column": 18 + } + } + }, + "superClass": null, + "implements": [], + "constructor": { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": null, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 1 + }, + "end": { + "line": 21, + "column": 2 + } + } + }, + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 19, + "column": 6 + } + } + }, + "value": { + "type": "StringLiteral", + "value": "a", + "loc": { + "start": { + "line": 19, + "column": 18 + }, + "end": { + "line": 19, + "column": 21 + } + } + }, + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "typeAnnotation": { + "type": "TSStringKeyword", + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 15 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 19, + "column": 21 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "s2", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 6 + }, + "end": { + "line": 20, + "column": 8 + } + } + }, + "value": { + "type": "NumberLiteral", + "value": 2, + "loc": { + "start": { + "line": 20, + "column": 21 + }, + "end": { + "line": 20, + "column": 22 + } + } + }, + "static": false, + "readonly": false, + "declare": false, + "optional": false, + "computed": true, + "typeAnnotation": { + "type": "TSNumberKeyword", + "loc": { + "start": { + "line": 20, + "column": 12 + }, + "end": { + "line": 20, + "column": 18 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 5 + }, + "end": { + "line": 20, + "column": 22 + } + } + } + ], + "indexSignatures": [], + "loc": { + "start": { + "line": 18, + "column": 18 + }, + "end": { + "line": 21, + "column": 2 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 1 + }, + "end": { + "line": 21, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 21, + "column": 2 + } + } +} diff --git a/es2panda/test/parser/ts/test-ts-unique-symbol-type.ts b/es2panda/test/parser/ts/test-ts-unique-symbol-type.ts new file mode 100644 index 0000000000000000000000000000000000000000..f445074c8fd30fba9c1191f2bcd179c45cfa0548 --- /dev/null +++ b/es2panda/test/parser/ts/test-ts-unique-symbol-type.ts @@ -0,0 +1,21 @@ +/* + * 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. + */ + + +const s2 : unique symbol = Symbol(); +class SymbolClass{ + a : string = "a"; + [s2] : number = 2; +} \ No newline at end of file diff --git a/es2panda/test/parser/ts/test-tuple-type-expected.txt b/es2panda/test/parser/ts/test-tuple-type-expected.txt index 8e576727c951ff0d75b1857f1ae5cf938fd10e66..474686f08a2e7565cc8875aed80dbd7cee223df5 100644 --- a/es2panda/test/parser/ts/test-tuple-type-expected.txt +++ b/es2panda/test/parser/ts/test-tuple-type-expected.txt @@ -49,7 +49,7 @@ }, "end": { "line": 17, - "column": 19 + "column": 18 } } }, @@ -90,7 +90,7 @@ }, "end": { "line": 17, - "column": 30 + "column": 29 } } }, @@ -185,7 +185,7 @@ }, "end": { "line": 17, - "column": 53 + "column": 52 } } } @@ -258,7 +258,7 @@ }, "end": { "line": 18, - "column": 16 + "column": 15 } } }, @@ -271,7 +271,7 @@ }, "end": { "line": 18, - "column": 24 + "column": 23 } } }, @@ -284,7 +284,7 @@ }, "end": { "line": 18, - "column": 32 + "column": 31 } } } @@ -388,7 +388,7 @@ }, "end": { "line": 19, - "column": 20 + "column": 19 } } }, @@ -429,7 +429,7 @@ }, "end": { "line": 19, - "column": 31 + "column": 30 } } } @@ -441,7 +441,7 @@ }, "end": { "line": 19, - "column": 32 + "column": 31 } } }, @@ -491,7 +491,7 @@ }, "end": { "line": 19, - "column": 55 + "column": 54 } } }, @@ -504,7 +504,7 @@ }, "end": { "line": 19, - "column": 64 + "column": 63 } } } @@ -553,7 +553,7 @@ }, "end": { "line": 19, - "column": 79 + "column": 78 } } } @@ -632,7 +632,7 @@ }, "end": { "line": 20, - "column": 18 + "column": 17 } } }, @@ -645,7 +645,7 @@ }, "end": { "line": 20, - "column": 26 + "column": 25 } } } @@ -657,7 +657,7 @@ }, "end": { "line": 20, - "column": 27 + "column": 26 } } }, @@ -670,7 +670,7 @@ }, "end": { "line": 20, - "column": 35 + "column": 34 } } }, @@ -683,7 +683,7 @@ }, "end": { "line": 20, - "column": 43 + "column": 42 } } } @@ -695,7 +695,7 @@ }, "end": { "line": 20, - "column": 44 + "column": 43 } } }, @@ -708,7 +708,7 @@ }, "end": { "line": 20, - "column": 52 + "column": 51 } } }, @@ -721,7 +721,7 @@ }, "end": { "line": 20, - "column": 60 + "column": 59 } } } @@ -852,7 +852,7 @@ }, "end": { "line": 21, - "column": 14 + "column": 10 } } } diff --git a/es2panda/test/parser/ts/test-tuple-type2-expected.txt b/es2panda/test/parser/ts/test-tuple-type2-expected.txt index 732997195100de77c70a546fe317291d404be3d8..e2affa9688d0b86ab1901f75e6cd1fd9be883b86 100644 --- a/es2panda/test/parser/ts/test-tuple-type2-expected.txt +++ b/es2panda/test/parser/ts/test-tuple-type2-expected.txt @@ -1 +1 @@ -SyntaxError: Tuple members must all have names or all not have names [test-tuple-type2.ts:17:17] +SyntaxError: Tuple members must all have or haven't names [test-tuple-type2.ts:17:17] diff --git a/es2panda/test/parser/ts/test-tuple-type5-expected.txt b/es2panda/test/parser/ts/test-tuple-type5-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..5454b9fc2b3cd26075a15894cd51567c931ab1d6 --- /dev/null +++ b/es2panda/test/parser/ts/test-tuple-type5-expected.txt @@ -0,0 +1,1691 @@ +{ + "type": "Program", + "statements": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "x1", + "typeAnnotation": { + "type": "TSTupleType", + "elementTypes": [ + { + "type": "TSNumberKeyword", + "loc": { + "start": { + "line": 17, + "column": 11 + }, + "end": { + "line": 17, + "column": 17 + } + } + }, + { + "type": "TSStringKeyword", + "loc": { + "start": { + "line": 17, + "column": 19 + }, + "end": { + "line": 17, + "column": 25 + } + } + } + ], + "loc": { + "start": { + "line": 17, + "column": 10 + }, + "end": { + "line": 17, + "column": 26 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 7 + } + } + }, + "init": null, + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 7 + } + } + } + ], + "kind": "var", + "loc": { + "start": { + "line": 17, + "column": 1 + }, + "end": { + "line": 17, + "column": 27 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "x2", + "typeAnnotation": { + "type": "TSTupleType", + "elementTypes": [ + { + "type": "TSStringKeyword", + "loc": { + "start": { + "line": 18, + "column": 11 + }, + "end": { + "line": 18, + "column": 17 + } + } + }, + { + "type": "TSRestType", + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "TSNumberKeyword", + "loc": { + "start": { + "line": 18, + "column": 22 + }, + "end": { + "line": 18, + "column": 28 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 22 + }, + "end": { + "line": 18, + "column": 30 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 19 + }, + "end": { + "line": 18, + "column": 30 + } + } + }, + { + "type": "TSStringKeyword", + "loc": { + "start": { + "line": 18, + "column": 32 + }, + "end": { + "line": 18, + "column": 38 + } + } + } + ], + "loc": { + "start": { + "line": 18, + "column": 10 + }, + "end": { + "line": 18, + "column": 39 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 7 + } + } + }, + "init": null, + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 7 + } + } + } + ], + "kind": "var", + "loc": { + "start": { + "line": 18, + "column": 1 + }, + "end": { + "line": 18, + "column": 40 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "x3", + "typeAnnotation": { + "type": "TSTupleType", + "elementTypes": [ + { + "type": "TSNamedTupleMember", + "elementType": { + "type": "TSBooleanKeyword", + "loc": { + "start": { + "line": 19, + "column": 15 + }, + "end": { + "line": 19, + "column": 22 + } + } + }, + "label": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 11 + }, + "end": { + "line": 19, + "column": 12 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 11 + }, + "end": { + "line": 19, + "column": 22 + } + } + }, + { + "type": "TSNamedTupleMember", + "elementType": { + "type": "TSArrayType", + "elementType": { + "type": "TSStringKeyword", + "loc": { + "start": { + "line": 19, + "column": 30 + }, + "end": { + "line": 19, + "column": 36 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 30 + }, + "end": { + "line": 19, + "column": 38 + } + } + }, + "label": { + "type": "Identifier", + "name": "b", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 27 + }, + "end": { + "line": 19, + "column": 28 + } + } + }, + "rest": true, + "loc": { + "start": { + "line": 19, + "column": 24 + }, + "end": { + "line": 19, + "column": 38 + } + } + }, + { + "type": "TSNamedTupleMember", + "elementType": { + "type": "TSNumberKeyword", + "loc": { + "start": { + "line": 19, + "column": 44 + }, + "end": { + "line": 19, + "column": 50 + } + } + }, + "label": { + "type": "Identifier", + "name": "c", + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 40 + }, + "end": { + "line": 19, + "column": 41 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 40 + }, + "end": { + "line": 19, + "column": 50 + } + } + } + ], + "loc": { + "start": { + "line": 19, + "column": 10 + }, + "end": { + "line": 19, + "column": 51 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 19, + "column": 7 + } + } + }, + "init": null, + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 19, + "column": 7 + } + } + } + ], + "kind": "var", + "loc": { + "start": { + "line": 19, + "column": 1 + }, + "end": { + "line": 19, + "column": 52 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "x4", + "typeAnnotation": { + "type": "TSTupleType", + "elementTypes": [ + { + "type": "TSStringKeyword", + "loc": { + "start": { + "line": 20, + "column": 11 + }, + "end": { + "line": 20, + "column": 17 + } + } + }, + { + "type": "TSOptionalType", + "typeAnnotation": { + "type": "TSNumberKeyword", + "loc": { + "start": { + "line": 20, + "column": 19 + }, + "end": { + "line": 20, + "column": 25 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 19 + }, + "end": { + "line": 20, + "column": 26 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 27 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 5 + }, + "end": { + "line": 20, + "column": 7 + } + } + }, + "init": null, + "loc": { + "start": { + "line": 20, + "column": 5 + }, + "end": { + "line": 20, + "column": 7 + } + } + } + ], + "kind": "var", + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 20, + "column": 28 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "x5", + "typeAnnotation": { + "type": "TSTupleType", + "elementTypes": [ + { + "type": "TSNamedTupleMember", + "elementType": { + "type": "TSNumberKeyword", + "loc": { + "start": { + "line": 21, + "column": 15 + }, + "end": { + "line": 21, + "column": 21 + } + } + }, + "label": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 11 + }, + "end": { + "line": 21, + "column": 12 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 11 + }, + "end": { + "line": 21, + "column": 21 + } + } + }, + { + "type": "TSNamedTupleMember", + "elementType": { + "type": "TSStringKeyword", + "loc": { + "start": { + "line": 21, + "column": 28 + }, + "end": { + "line": 21, + "column": 34 + } + } + }, + "label": { + "type": "Identifier", + "name": "b", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 23 + }, + "end": { + "line": 21, + "column": 24 + } + } + }, + "optional": true, + "loc": { + "start": { + "line": 21, + "column": 23 + }, + "end": { + "line": 21, + "column": 34 + } + } + } + ], + "loc": { + "start": { + "line": 21, + "column": 10 + }, + "end": { + "line": 21, + "column": 35 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 7 + } + } + }, + "init": null, + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 7 + } + } + } + ], + "kind": "var", + "loc": { + "start": { + "line": 21, + "column": 1 + }, + "end": { + "line": 21, + "column": 36 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ForTupleTest", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 7 + }, + "end": { + "line": 23, + "column": 19 + } + } + }, + "superClass": null, + "implements": [], + "constructor": { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": null, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 1 + }, + "end": { + "line": 24, + "column": 2 + } + } + }, + "body": [], + "indexSignatures": [], + "loc": { + "start": { + "line": 23, + "column": 20 + }, + "end": { + "line": 24, + "column": 2 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 1 + }, + "end": { + "line": 24, + "column": 2 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "x6", + "typeAnnotation": { + "type": "TSTupleType", + "elementTypes": [ + { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "name": "ForTupleTest", + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 11 + }, + "end": { + "line": 25, + "column": 23 + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 11 + }, + "end": { + "line": 25, + "column": 23 + } + } + }, + { + "type": "TSOptionalType", + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "name": "ForTupleTest", + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 25 + }, + "end": { + "line": 25, + "column": 37 + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 25 + }, + "end": { + "line": 25, + "column": 37 + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 25 + }, + "end": { + "line": 25, + "column": 38 + } + } + } + ], + "loc": { + "start": { + "line": 25, + "column": 10 + }, + "end": { + "line": 25, + "column": 39 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 5 + }, + "end": { + "line": 25, + "column": 7 + } + } + }, + "init": null, + "loc": { + "start": { + "line": 25, + "column": 5 + }, + "end": { + "line": 25, + "column": 7 + } + } + } + ], + "kind": "var", + "loc": { + "start": { + "line": 25, + "column": 1 + }, + "end": { + "line": 25, + "column": 40 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "x7", + "typeAnnotation": { + "type": "TSTupleType", + "elementTypes": [ + { + "type": "TSNamedTupleMember", + "elementType": { + "type": "TSNumberKeyword", + "loc": { + "start": { + "line": 26, + "column": 15 + }, + "end": { + "line": 26, + "column": 21 + } + } + }, + "label": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 11 + }, + "end": { + "line": 26, + "column": 12 + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 11 + }, + "end": { + "line": 26, + "column": 21 + } + } + }, + { + "type": "TSNamedTupleMember", + "elementType": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "name": "ForTupleTest", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 28 + }, + "end": { + "line": 26, + "column": 40 + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 28 + }, + "end": { + "line": 26, + "column": 40 + } + } + }, + "label": { + "type": "Identifier", + "name": "b", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 23 + }, + "end": { + "line": 26, + "column": 24 + } + } + }, + "optional": true, + "loc": { + "start": { + "line": 26, + "column": 23 + }, + "end": { + "line": 26, + "column": 40 + } + } + } + ], + "loc": { + "start": { + "line": 26, + "column": 10 + }, + "end": { + "line": 26, + "column": 41 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 5 + }, + "end": { + "line": 26, + "column": 7 + } + } + }, + "init": null, + "loc": { + "start": { + "line": 26, + "column": 5 + }, + "end": { + "line": 26, + "column": 7 + } + } + } + ], + "kind": "var", + "loc": { + "start": { + "line": 26, + "column": 1 + }, + "end": { + "line": 26, + "column": 42 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "x8", + "typeAnnotation": { + "type": "TSTupleType", + "elementTypes": [ + { + "type": "TSNumberKeyword", + "loc": { + "start": { + "line": 27, + "column": 11 + }, + "end": { + "line": 27, + "column": 17 + } + } + }, + { + "type": "TSRestType", + "typeAnnotation": { + "type": "TSArrayType", + "elementType": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "name": "ForTupleTest", + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 22 + }, + "end": { + "line": 27, + "column": 34 + } + } + }, + "loc": { + "start": { + "line": 27, + "column": 22 + }, + "end": { + "line": 27, + "column": 34 + } + } + }, + "loc": { + "start": { + "line": 27, + "column": 22 + }, + "end": { + "line": 27, + "column": 36 + } + } + }, + "loc": { + "start": { + "line": 27, + "column": 19 + }, + "end": { + "line": 27, + "column": 36 + } + } + }, + { + "type": "TSStringKeyword", + "loc": { + "start": { + "line": 27, + "column": 38 + }, + "end": { + "line": 27, + "column": 44 + } + } + } + ], + "loc": { + "start": { + "line": 27, + "column": 10 + }, + "end": { + "line": 27, + "column": 45 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 5 + }, + "end": { + "line": 27, + "column": 7 + } + } + }, + "init": null, + "loc": { + "start": { + "line": 27, + "column": 5 + }, + "end": { + "line": 27, + "column": 7 + } + } + } + ], + "kind": "var", + "loc": { + "start": { + "line": 27, + "column": 1 + }, + "end": { + "line": 27, + "column": 46 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "x9", + "typeAnnotation": { + "type": "TSTupleType", + "elementTypes": [ + { + "type": "TSNamedTupleMember", + "elementType": { + "type": "TSStringKeyword", + "loc": { + "start": { + "line": 28, + "column": 15 + }, + "end": { + "line": 28, + "column": 21 + } + } + }, + "label": { + "type": "Identifier", + "name": "a", + "decorators": [], + "loc": { + "start": { + "line": 28, + "column": 11 + }, + "end": { + "line": 28, + "column": 12 + } + } + }, + "loc": { + "start": { + "line": 28, + "column": 11 + }, + "end": { + "line": 28, + "column": 21 + } + } + }, + { + "type": "TSNamedTupleMember", + "elementType": { + "type": "TSArrayType", + "elementType": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "name": "C", + "decorators": [], + "loc": { + "start": { + "line": 28, + "column": 30 + }, + "end": { + "line": 28, + "column": 31 + } + } + }, + "loc": { + "start": { + "line": 28, + "column": 30 + }, + "end": { + "line": 28, + "column": 31 + } + } + }, + "loc": { + "start": { + "line": 28, + "column": 30 + }, + "end": { + "line": 28, + "column": 33 + } + } + }, + "label": { + "type": "Identifier", + "name": "b", + "decorators": [], + "loc": { + "start": { + "line": 28, + "column": 26 + }, + "end": { + "line": 28, + "column": 27 + } + } + }, + "rest": true, + "loc": { + "start": { + "line": 28, + "column": 23 + }, + "end": { + "line": 28, + "column": 33 + } + } + }, + { + "type": "TSNamedTupleMember", + "elementType": { + "type": "TSStringKeyword", + "loc": { + "start": { + "line": 28, + "column": 37 + }, + "end": { + "line": 28, + "column": 43 + } + } + }, + "label": { + "type": "Identifier", + "name": "c", + "decorators": [], + "loc": { + "start": { + "line": 28, + "column": 35 + }, + "end": { + "line": 28, + "column": 36 + } + } + }, + "loc": { + "start": { + "line": 28, + "column": 35 + }, + "end": { + "line": 28, + "column": 43 + } + } + } + ], + "loc": { + "start": { + "line": 28, + "column": 10 + }, + "end": { + "line": 28, + "column": 44 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 28, + "column": 5 + }, + "end": { + "line": 28, + "column": 7 + } + } + }, + "init": null, + "loc": { + "start": { + "line": 28, + "column": 5 + }, + "end": { + "line": 28, + "column": 7 + } + } + } + ], + "kind": "var", + "loc": { + "start": { + "line": 28, + "column": 1 + }, + "end": { + "line": 28, + "column": 45 + } + } + }, + { + "type": "TSTypeAliasDeclaration", + "id": { + "type": "Identifier", + "name": "StringsForTupleTest", + "decorators": [], + "loc": { + "start": { + "line": 30, + "column": 6 + }, + "end": { + "line": 30, + "column": 25 + } + } + }, + "typeAnnotation": { + "type": "TSTupleType", + "elementTypes": [ + { + "type": "TSStringKeyword", + "loc": { + "start": { + "line": 30, + "column": 29 + }, + "end": { + "line": 30, + "column": 35 + } + } + }, + { + "type": "TSStringKeyword", + "loc": { + "start": { + "line": 30, + "column": 37 + }, + "end": { + "line": 30, + "column": 43 + } + } + } + ], + "loc": { + "start": { + "line": 30, + "column": 28 + }, + "end": { + "line": 30, + "column": 44 + } + } + }, + "loc": { + "start": { + "line": 30, + "column": 1 + }, + "end": { + "line": 31, + "column": 5 + } + } + }, + { + "type": "TSTypeAliasDeclaration", + "id": { + "type": "Identifier", + "name": "NumbersForTupleTest", + "decorators": [], + "loc": { + "start": { + "line": 31, + "column": 6 + }, + "end": { + "line": 31, + "column": 25 + } + } + }, + "typeAnnotation": { + "type": "TSTupleType", + "elementTypes": [ + { + "type": "TSNumberKeyword", + "loc": { + "start": { + "line": 31, + "column": 29 + }, + "end": { + "line": 31, + "column": 35 + } + } + }, + { + "type": "TSNumberKeyword", + "loc": { + "start": { + "line": 31, + "column": 37 + }, + "end": { + "line": 31, + "column": 43 + } + } + } + ], + "loc": { + "start": { + "line": 31, + "column": 28 + }, + "end": { + "line": 31, + "column": 44 + } + } + }, + "loc": { + "start": { + "line": 31, + "column": 1 + }, + "end": { + "line": 32, + "column": 5 + } + } + }, + { + "type": "TSTypeAliasDeclaration", + "id": { + "type": "Identifier", + "name": "x10", + "decorators": [], + "loc": { + "start": { + "line": 32, + "column": 6 + }, + "end": { + "line": 32, + "column": 9 + } + } + }, + "typeAnnotation": { + "type": "TSTupleType", + "elementTypes": [ + { + "type": "TSRestType", + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "name": "StringsForTupleTest", + "decorators": [], + "loc": { + "start": { + "line": 32, + "column": 16 + }, + "end": { + "line": 32, + "column": 35 + } + } + }, + "loc": { + "start": { + "line": 32, + "column": 16 + }, + "end": { + "line": 32, + "column": 35 + } + } + }, + "loc": { + "start": { + "line": 32, + "column": 13 + }, + "end": { + "line": 32, + "column": 35 + } + } + }, + { + "type": "TSRestType", + "typeAnnotation": { + "type": "TSTypeReference", + "typeName": { + "type": "Identifier", + "name": "NumbersForTupleTest", + "decorators": [], + "loc": { + "start": { + "line": 32, + "column": 40 + }, + "end": { + "line": 32, + "column": 59 + } + } + }, + "loc": { + "start": { + "line": 32, + "column": 40 + }, + "end": { + "line": 32, + "column": 59 + } + } + }, + "loc": { + "start": { + "line": 32, + "column": 37 + }, + "end": { + "line": 32, + "column": 59 + } + } + } + ], + "loc": { + "start": { + "line": 32, + "column": 12 + }, + "end": { + "line": 32, + "column": 60 + } + } + }, + "loc": { + "start": { + "line": 32, + "column": 1 + }, + "end": { + "line": 33, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 33, + "column": 1 + } + } +} diff --git a/es2panda/test/parser/ts/test-tuple-type5.ts b/es2panda/test/parser/ts/test-tuple-type5.ts new file mode 100644 index 0000000000000000000000000000000000000000..9fa1dd44329366fcc2a4cf38abb8462c65be6129 --- /dev/null +++ b/es2panda/test/parser/ts/test-tuple-type5.ts @@ -0,0 +1,32 @@ +/* + * 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. + */ + + +var x1 : [number, string]; +var x2 : [string, ...number[], string]; +var x3 : [a : boolean, ...b :string[], c : number]; +var x4 : [string, number?]; +var x5 : [a : number, b ?: string]; + +class ForTupleTest { +} +var x6 : [ForTupleTest, ForTupleTest?]; +var x7 : [a : number, b ?: ForTupleTest]; +var x8 : [number, ...ForTupleTest[], string]; +var x9 : [a : string, ...b : C[], c:string]; + +type StringsForTupleTest = [string, string] +type NumbersForTupleTest = [number, number] +type x10 = [...StringsForTupleTest, ...NumbersForTupleTest] diff --git a/es2panda/test/parser/ts/test_generic-expected.txt b/es2panda/test/parser/ts/test_generic-expected.txt index 6618f07c9d98094cd7b4d46293f430e6e534b117..854d90421293ba84ff945344a43f570720a81e57 100644 --- a/es2panda/test/parser/ts/test_generic-expected.txt +++ b/es2panda/test/parser/ts/test_generic-expected.txt @@ -833,7 +833,7 @@ }, "end": { "line": 23, - "column": 75 + "column": 74 } } }, @@ -846,7 +846,7 @@ }, "end": { "line": 23, - "column": 83 + "column": 82 } } } @@ -1633,7 +1633,7 @@ }, "end": { "line": 29, - "column": 31 + "column": 30 } } }, @@ -1646,7 +1646,7 @@ }, "end": { "line": 29, - "column": 39 + "column": 38 } } } @@ -1900,7 +1900,7 @@ }, "end": { "line": 36, - "column": 44 + "column": 43 } } }, @@ -1926,7 +1926,7 @@ }, "end": { "line": 36, - "column": 54 + "column": 53 } } } @@ -2015,7 +2015,7 @@ }, "end": { "line": 34, - "column": 107 + "column": 106 } } }, @@ -2028,7 +2028,7 @@ }, "end": { "line": 34, - "column": 115 + "column": 114 } } } @@ -2114,7 +2114,7 @@ }, "end": { "line": 34, - "column": 40 + "column": 39 } } }, @@ -2127,7 +2127,7 @@ }, "end": { "line": 34, - "column": 48 + "column": 47 } } }, @@ -2230,7 +2230,7 @@ }, "end": { "line": 34, - "column": 74 + "column": 73 } } } @@ -2408,7 +2408,7 @@ }, "end": { "line": 39, - "column": 26 + "column": 25 } } }, @@ -2435,7 +2435,7 @@ }, "end": { "line": 39, - "column": 29 + "column": 28 } } }, @@ -2462,7 +2462,7 @@ }, "end": { "line": 39, - "column": 32 + "column": 31 } } } @@ -4072,7 +4072,7 @@ }, "end": { "line": 53, - "column": 54 + "column": 53 } } } @@ -4513,7 +4513,7 @@ }, "end": { "line": 57, - "column": 75 + "column": 74 } } } @@ -5680,7 +5680,7 @@ }, "end": { "line": 65, - "column": 52 + "column": 51 } } }, @@ -5693,7 +5693,7 @@ }, "end": { "line": 65, - "column": 60 + "column": 59 } } } @@ -6391,7 +6391,7 @@ }, "end": { "line": 69, - "column": 23 + "column": 22 } } }, @@ -6404,7 +6404,7 @@ }, "end": { "line": 69, - "column": 31 + "column": 30 } } }, @@ -6417,7 +6417,7 @@ }, "end": { "line": 69, - "column": 39 + "column": 38 } } } @@ -6906,7 +6906,7 @@ }, "end": { "line": 74, - "column": 34 + "column": 33 } } }, @@ -6919,7 +6919,7 @@ }, "end": { "line": 74, - "column": 42 + "column": 41 } } } diff --git a/es2panda/test/parser/ts/test_import_type-expected.txt b/es2panda/test/parser/ts/test_import_type-expected.txt index 1f19c1b27a3fbef5b4def9bda16a29f8560caee6..7edda133f483c6583b8714888f3256af1609134e 100644 --- a/es2panda/test/parser/ts/test_import_type-expected.txt +++ b/es2panda/test/parser/ts/test_import_type-expected.txt @@ -605,7 +605,7 @@ }, "end": { "line": 24, - "column": 104 + "column": 103 } } }, @@ -618,7 +618,7 @@ }, "end": { "line": 24, - "column": 112 + "column": 111 } } } diff --git a/es2panda/test/parser/ts/test_this_type-expected.txt b/es2panda/test/parser/ts/test_this_type-expected.txt index df31b0ada70d299794b1f6e22b4cef182b07825e..86ddf76c31e2c9340e59b11b7d79dea2beda2992 100644 --- a/es2panda/test/parser/ts/test_this_type-expected.txt +++ b/es2panda/test/parser/ts/test_this_type-expected.txt @@ -313,7 +313,7 @@ }, "end": { "line": 22, - "column": 40 + "column": 39 } } }, @@ -327,7 +327,7 @@ }, "end": { "line": 22, - "column": 44 + "column": 43 } } } diff --git a/es2panda/test/parser/ts/type_checker/arrayDestructuring-expected.txt b/es2panda/test/parser/ts/type_checker/arrayDestructuring-expected.txt index ae094194a0514e2b7967485383ad2a6b92196bad..7bc3d54070cc676d47ba214ce4336e1c66dfbde4 100644 --- a/es2panda/test/parser/ts/type_checker/arrayDestructuring-expected.txt +++ b/es2panda/test/parser/ts/type_checker/arrayDestructuring-expected.txt @@ -2607,7 +2607,7 @@ }, "end": { "line": 45, - "column": 40 + "column": 39 } } }, @@ -2620,7 +2620,7 @@ }, "end": { "line": 45, - "column": 48 + "column": 47 } } } @@ -2766,7 +2766,7 @@ }, "end": { "line": 47, - "column": 40 + "column": 39 } } }, @@ -2807,7 +2807,7 @@ }, "end": { "line": 47, - "column": 57 + "column": 56 } } }, @@ -2833,7 +2833,7 @@ }, "end": { "line": 47, - "column": 68 + "column": 67 } } } @@ -3063,7 +3063,7 @@ }, "end": { "line": 48, - "column": 42 + "column": 41 } } }, @@ -3076,7 +3076,7 @@ }, "end": { "line": 48, - "column": 50 + "column": 49 } } }, @@ -3089,7 +3089,7 @@ }, "end": { "line": 48, - "column": 58 + "column": 57 } } } @@ -3410,7 +3410,7 @@ }, "end": { "line": 49, - "column": 77 + "column": 76 } } }, @@ -3567,7 +3567,7 @@ }, "end": { "line": 49, - "column": 117 + "column": 116 } } } @@ -4048,7 +4048,7 @@ }, "end": { "line": 50, - "column": 81 + "column": 80 } } }, @@ -4062,7 +4062,7 @@ }, "end": { "line": 50, - "column": 85 + "column": 84 } } } @@ -4074,7 +4074,7 @@ }, "end": { "line": 50, - "column": 86 + "column": 85 } } }, @@ -4093,7 +4093,7 @@ }, "end": { "line": 50, - "column": 96 + "column": 95 } } } @@ -4105,7 +4105,7 @@ }, "end": { "line": 50, - "column": 97 + "column": 96 } } } @@ -4117,7 +4117,7 @@ }, "end": { "line": 50, - "column": 98 + "column": 97 } } } @@ -4436,7 +4436,7 @@ }, "end": { "line": 51, - "column": 44 + "column": 43 } } }, @@ -4495,7 +4495,7 @@ }, "end": { "line": 51, - "column": 63 + "column": 62 } } }, @@ -4508,7 +4508,7 @@ }, "end": { "line": 51, - "column": 71 + "column": 70 } } }, @@ -4521,7 +4521,7 @@ }, "end": { "line": 51, - "column": 79 + "column": 78 } } } diff --git a/es2panda/test/parser/ts/type_checker/arrayDestructuring12-expected.txt b/es2panda/test/parser/ts/type_checker/arrayDestructuring12-expected.txt index 17ef89fd5cd3ec4f4b329fc19de0dd0b9689de1f..d34db2bbe1fdd35daab79bd756cac319721599fe 100644 --- a/es2panda/test/parser/ts/type_checker/arrayDestructuring12-expected.txt +++ b/es2panda/test/parser/ts/type_checker/arrayDestructuring12-expected.txt @@ -95,7 +95,7 @@ }, "end": { "line": 17, - "column": 28 + "column": 27 } } }, @@ -108,7 +108,7 @@ }, "end": { "line": 17, - "column": 36 + "column": 35 } } }, @@ -121,7 +121,7 @@ }, "end": { "line": 17, - "column": 45 + "column": 44 } } } diff --git a/es2panda/test/parser/ts/type_checker/arrayDestructuring13-expected.txt b/es2panda/test/parser/ts/type_checker/arrayDestructuring13-expected.txt index c61888739323e4c91f2c3fb475c74c48db4f9e06..0761baa416f98735300dd047700e32e8a2f88740 100644 --- a/es2panda/test/parser/ts/type_checker/arrayDestructuring13-expected.txt +++ b/es2panda/test/parser/ts/type_checker/arrayDestructuring13-expected.txt @@ -21,7 +21,7 @@ }, "end": { "line": 17, - "column": 16 + "column": 15 } } }, @@ -34,7 +34,7 @@ }, "end": { "line": 17, - "column": 24 + "column": 23 } } }, @@ -47,7 +47,7 @@ }, "end": { "line": 17, - "column": 32 + "column": 31 } } } diff --git a/es2panda/test/parser/ts/type_checker/arrayDestructuring15-expected.txt b/es2panda/test/parser/ts/type_checker/arrayDestructuring15-expected.txt index cb1ccc7a9219221d46e997821b936ec2fa7df878..941bcf4a45b4112f6abd3ba5decab961ab141a46 100644 --- a/es2panda/test/parser/ts/type_checker/arrayDestructuring15-expected.txt +++ b/es2panda/test/parser/ts/type_checker/arrayDestructuring15-expected.txt @@ -21,7 +21,7 @@ }, "end": { "line": 17, - "column": 16 + "column": 15 } } } diff --git a/es2panda/test/parser/ts/type_checker/arrayDestructuring16-expected.txt b/es2panda/test/parser/ts/type_checker/arrayDestructuring16-expected.txt index 0a708c25c2f485d112e9f20dbb2f9c8aeecb084e..261780eec287687e7480ab817041676deb4c0f8a 100644 --- a/es2panda/test/parser/ts/type_checker/arrayDestructuring16-expected.txt +++ b/es2panda/test/parser/ts/type_checker/arrayDestructuring16-expected.txt @@ -21,7 +21,7 @@ }, "end": { "line": 17, - "column": 16 + "column": 15 } } } diff --git a/es2panda/test/parser/ts/type_checker/arrayDestructuring17-expected.txt b/es2panda/test/parser/ts/type_checker/arrayDestructuring17-expected.txt index 20dec895eb665f7b8e63f7862322dff9c2742c42..a345589dbbc5918909bd2778fd34f7ee57c1c16c 100644 --- a/es2panda/test/parser/ts/type_checker/arrayDestructuring17-expected.txt +++ b/es2panda/test/parser/ts/type_checker/arrayDestructuring17-expected.txt @@ -93,7 +93,7 @@ }, "end": { "line": 17, - "column": 43 + "column": 42 } } }, @@ -106,7 +106,7 @@ }, "end": { "line": 17, - "column": 51 + "column": 50 } } } diff --git a/es2panda/test/parser/ts/type_checker/arrayDestructuring18-expected.txt b/es2panda/test/parser/ts/type_checker/arrayDestructuring18-expected.txt index 77f68693131a40fbf3efe970e271f722b78e513a..0ec15d22da473f1a2dd4e2f61d1dfb188d8707db 100644 --- a/es2panda/test/parser/ts/type_checker/arrayDestructuring18-expected.txt +++ b/es2panda/test/parser/ts/type_checker/arrayDestructuring18-expected.txt @@ -53,7 +53,7 @@ }, "end": { "line": 17, - "column": 21 + "column": 20 } } }, @@ -66,7 +66,7 @@ }, "end": { "line": 17, - "column": 29 + "column": 28 } } } @@ -120,7 +120,7 @@ }, "end": { "line": 17, - "column": 52 + "column": 51 } } }, @@ -133,7 +133,7 @@ }, "end": { "line": 17, - "column": 58 + "column": 57 } } }, @@ -147,7 +147,7 @@ }, "end": { "line": 17, - "column": 62 + "column": 61 } } } diff --git a/es2panda/test/parser/ts/type_checker/arrayDestructuring19-expected.txt b/es2panda/test/parser/ts/type_checker/arrayDestructuring19-expected.txt index 206661a32475bbaa46632d74e19eb47958df32e8..0fd5d2daa30a785018341477edff5be8b10d25aa 100644 --- a/es2panda/test/parser/ts/type_checker/arrayDestructuring19-expected.txt +++ b/es2panda/test/parser/ts/type_checker/arrayDestructuring19-expected.txt @@ -68,7 +68,7 @@ }, "end": { "line": 17, - "column": 24 + "column": 23 } } }, @@ -81,7 +81,7 @@ }, "end": { "line": 17, - "column": 32 + "column": 31 } } } @@ -135,7 +135,7 @@ }, "end": { "line": 17, - "column": 55 + "column": 54 } } }, @@ -148,7 +148,7 @@ }, "end": { "line": 17, - "column": 61 + "column": 60 } } }, @@ -162,7 +162,7 @@ }, "end": { "line": 17, - "column": 65 + "column": 64 } } } diff --git a/es2panda/test/parser/ts/type_checker/arrayDestructuring27-expected.txt b/es2panda/test/parser/ts/type_checker/arrayDestructuring27-expected.txt index 34f429253fff2294882de7c33940cbe84313e6aa..1ca9df943fff85b25f3b8ee0f6b308b0acd9cc70 100644 --- a/es2panda/test/parser/ts/type_checker/arrayDestructuring27-expected.txt +++ b/es2panda/test/parser/ts/type_checker/arrayDestructuring27-expected.txt @@ -149,7 +149,7 @@ }, "end": { "line": 17, - "column": 41 + "column": 40 } } }, @@ -190,7 +190,7 @@ }, "end": { "line": 17, - "column": 58 + "column": 57 } } } diff --git a/es2panda/test/parser/ts/type_checker/arrayDestructuring4-expected.txt b/es2panda/test/parser/ts/type_checker/arrayDestructuring4-expected.txt index fd2657f8e50b0ce7a51c60da1c3ce9167f29f1c4..4573dc6ff5833da74cf643f303642e2af9331291 100644 --- a/es2panda/test/parser/ts/type_checker/arrayDestructuring4-expected.txt +++ b/es2panda/test/parser/ts/type_checker/arrayDestructuring4-expected.txt @@ -37,7 +37,7 @@ }, "end": { "line": 17, - "column": 18 + "column": 17 } } }, @@ -50,7 +50,7 @@ }, "end": { "line": 17, - "column": 26 + "column": 25 } } } diff --git a/es2panda/test/parser/ts/type_checker/arrayDestructuring5-expected.txt b/es2panda/test/parser/ts/type_checker/arrayDestructuring5-expected.txt index d16b14b9938ea85e33c703c83ad1a9bf7718890e..93433e43a4407361399f1f9643cb8c4dddec9e8e 100644 --- a/es2panda/test/parser/ts/type_checker/arrayDestructuring5-expected.txt +++ b/es2panda/test/parser/ts/type_checker/arrayDestructuring5-expected.txt @@ -106,7 +106,7 @@ }, "end": { "line": 17, - "column": 33 + "column": 32 } } }, @@ -119,7 +119,7 @@ }, "end": { "line": 17, - "column": 41 + "column": 40 } } } diff --git a/es2panda/test/parser/ts/type_checker/arrayDestructuring6-expected.txt b/es2panda/test/parser/ts/type_checker/arrayDestructuring6-expected.txt index 90445bd028f8f35b5c12b598921c0fbbdca916cf..574169bfdd98fd766711bada32af30f590d946ac 100644 --- a/es2panda/test/parser/ts/type_checker/arrayDestructuring6-expected.txt +++ b/es2panda/test/parser/ts/type_checker/arrayDestructuring6-expected.txt @@ -81,7 +81,7 @@ }, "end": { "line": 17, - "column": 32 + "column": 31 } } }, @@ -94,7 +94,7 @@ }, "end": { "line": 17, - "column": 40 + "column": 39 } } } diff --git a/es2panda/test/parser/ts/type_checker/functionOverload2-expected.txt b/es2panda/test/parser/ts/type_checker/functionOverload2-expected.txt index e0e28b97757929e2c68253e9f326a31a51a758cf..90dcd0e40c89ca9d155b1ba653331db066dec226 100644 --- a/es2panda/test/parser/ts/type_checker/functionOverload2-expected.txt +++ b/es2panda/test/parser/ts/type_checker/functionOverload2-expected.txt @@ -93,7 +93,7 @@ }, "end": { "line": 17, - "column": 45 + "column": 44 } } }, @@ -106,7 +106,7 @@ }, "end": { "line": 17, - "column": 53 + "column": 52 } } } @@ -236,7 +236,7 @@ }, "end": { "line": 18, - "column": 46 + "column": 45 } } }, @@ -249,7 +249,7 @@ }, "end": { "line": 18, - "column": 54 + "column": 53 } } } @@ -379,7 +379,7 @@ }, "end": { "line": 19, - "column": 46 + "column": 45 } } }, @@ -392,7 +392,7 @@ }, "end": { "line": 19, - "column": 54 + "column": 53 } } } @@ -591,7 +591,7 @@ }, "end": { "line": 20, - "column": 73 + "column": 72 } } }, @@ -604,7 +604,7 @@ }, "end": { "line": 20, - "column": 81 + "column": 80 } } } diff --git a/es2panda/test/parser/ts/type_checker/interfaceAssignment-expected.txt b/es2panda/test/parser/ts/type_checker/interfaceAssignment-expected.txt index 8aa74554e232735624da7cc6a6e1e48188a9132f..b07a12296941679f8bb31ee0fa21fb93db761f92 100644 --- a/es2panda/test/parser/ts/type_checker/interfaceAssignment-expected.txt +++ b/es2panda/test/parser/ts/type_checker/interfaceAssignment-expected.txt @@ -2369,7 +2369,7 @@ }, "end": { "line": 71, - "column": 16 + "column": 15 } } }, @@ -2382,7 +2382,7 @@ }, "end": { "line": 71, - "column": 24 + "column": 23 } } } diff --git a/es2panda/test/parser/ts/type_checker/interfaceAssignment3-expected.txt b/es2panda/test/parser/ts/type_checker/interfaceAssignment3-expected.txt index 5df9b64a64d6c90b91ffcd2ecdafbc5d943f3b84..689b9ebbe4a28201cb48e0ea12c74e8cc4b8a2a3 100644 --- a/es2panda/test/parser/ts/type_checker/interfaceAssignment3-expected.txt +++ b/es2panda/test/parser/ts/type_checker/interfaceAssignment3-expected.txt @@ -386,7 +386,7 @@ }, "end": { "line": 30, - "column": 16 + "column": 15 } } }, @@ -399,7 +399,7 @@ }, "end": { "line": 30, - "column": 24 + "column": 23 } } } diff --git a/es2panda/test/parser/ts/type_checker/memberExpTests-expected.txt b/es2panda/test/parser/ts/type_checker/memberExpTests-expected.txt index 6f0b1ce2ed7f789fb82cb415d2b4d713bd0880bb..03d7b8e97afd53239d1450e4f16922a95af2896a 100644 --- a/es2panda/test/parser/ts/type_checker/memberExpTests-expected.txt +++ b/es2panda/test/parser/ts/type_checker/memberExpTests-expected.txt @@ -4677,7 +4677,7 @@ }, "end": { "line": 96, - "column": 36 + "column": 35 } } }, @@ -4690,7 +4690,7 @@ }, "end": { "line": 96, - "column": 44 + "column": 43 } } }, @@ -4703,7 +4703,7 @@ }, "end": { "line": 96, - "column": 52 + "column": 51 } } } diff --git a/es2panda/test/parser/ts/type_checker/objectDestructuring23-expected.txt b/es2panda/test/parser/ts/type_checker/objectDestructuring23-expected.txt index 571f0454aa6c7dbd9d0a4cb66508091ce056f0d8..4c94ce5b0cd11846ca35cc7189e94776569ef027 100644 --- a/es2panda/test/parser/ts/type_checker/objectDestructuring23-expected.txt +++ b/es2panda/test/parser/ts/type_checker/objectDestructuring23-expected.txt @@ -67,7 +67,7 @@ }, "end": { "line": 17, - "column": 26 + "column": 25 } } }, @@ -80,7 +80,7 @@ }, "end": { "line": 17, - "column": 34 + "column": 33 } } } diff --git a/es2panda/test/parser/ts/type_checker/objectDestructuring24-expected.txt b/es2panda/test/parser/ts/type_checker/objectDestructuring24-expected.txt index 927c614e6857825bdc5bd78c0c989ef46c45a18d..876eff359832cf21efcaa665269dc6bd8a182ba6 100644 --- a/es2panda/test/parser/ts/type_checker/objectDestructuring24-expected.txt +++ b/es2panda/test/parser/ts/type_checker/objectDestructuring24-expected.txt @@ -139,7 +139,7 @@ }, "end": { "line": 17, - "column": 46 + "column": 45 } } }, @@ -165,7 +165,7 @@ }, "end": { "line": 17, - "column": 57 + "column": 56 } } } diff --git a/es2panda/test/parser/ts/type_checker/objectDestructuring25-expected.txt b/es2panda/test/parser/ts/type_checker/objectDestructuring25-expected.txt index 6d2874ba302342d728736f74901b0b4939c1739a..bb41fbdf514d1e2a6c3d98aec0040d3e3499fb45 100644 --- a/es2panda/test/parser/ts/type_checker/objectDestructuring25-expected.txt +++ b/es2panda/test/parser/ts/type_checker/objectDestructuring25-expected.txt @@ -145,7 +145,7 @@ }, "end": { "line": 17, - "column": 50 + "column": 49 } } }, @@ -158,7 +158,7 @@ }, "end": { "line": 17, - "column": 58 + "column": 57 } } } diff --git a/es2panda/test/parser/ts/type_checker/objectLiteralAssignability-expected.txt b/es2panda/test/parser/ts/type_checker/objectLiteralAssignability-expected.txt index 9d55aed3b35b78648c053fb470fcf2dd021ae471..eeb880e0da144f5c724d3546696d3d9043a2cddd 100644 --- a/es2panda/test/parser/ts/type_checker/objectLiteralAssignability-expected.txt +++ b/es2panda/test/parser/ts/type_checker/objectLiteralAssignability-expected.txt @@ -6675,7 +6675,7 @@ }, "end": { "line": 69, - "column": 36 + "column": 35 } } }, @@ -6688,7 +6688,7 @@ }, "end": { "line": 69, - "column": 44 + "column": 43 } } }, @@ -6701,7 +6701,7 @@ }, "end": { "line": 69, - "column": 52 + "column": 51 } } } diff --git a/es2panda/test/parser/ts/type_checker/test-type-literal-expected.txt b/es2panda/test/parser/ts/type_checker/test-type-literal-expected.txt index b982eec2613d7de90e10c4a768c6206c2d61bc76..84cd0798c97d65bd9cd5c05a403c04c709435ff6 100644 --- a/es2panda/test/parser/ts/type_checker/test-type-literal-expected.txt +++ b/es2panda/test/parser/ts/type_checker/test-type-literal-expected.txt @@ -699,7 +699,7 @@ }, "end": { "line": 19, - "column": 66 + "column": 65 } } } diff --git a/es2panda/test/parser/ts/type_checker/tupleAssignability-expected.txt b/es2panda/test/parser/ts/type_checker/tupleAssignability-expected.txt index 8225600c82f737858e3cef46afb0abd883df0160..1dde88edcbba3cfb7f447bff450da8c3090cd090 100644 --- a/es2panda/test/parser/ts/type_checker/tupleAssignability-expected.txt +++ b/es2panda/test/parser/ts/type_checker/tupleAssignability-expected.txt @@ -97,7 +97,7 @@ }, "end": { "line": 18, - "column": 18 + "column": 17 } } } @@ -109,7 +109,7 @@ }, "end": { "line": 18, - "column": 19 + "column": 18 } } } @@ -225,7 +225,7 @@ }, "end": { "line": 19, - "column": 21 + "column": 20 } } }, @@ -238,7 +238,7 @@ }, "end": { "line": 19, - "column": 29 + "column": 28 } } }, @@ -251,7 +251,7 @@ }, "end": { "line": 19, - "column": 37 + "column": 36 } } } @@ -395,7 +395,7 @@ }, "end": { "line": 20, - "column": 28 + "column": 27 } } }, @@ -408,7 +408,7 @@ }, "end": { "line": 20, - "column": 36 + "column": 35 } } } @@ -554,7 +554,7 @@ }, "end": { "line": 21, - "column": 25 + "column": 24 } } }, @@ -596,7 +596,7 @@ }, "end": { "line": 21, - "column": 37 + "column": 36 } } } @@ -608,7 +608,7 @@ }, "end": { "line": 21, - "column": 38 + "column": 37 } } }, @@ -652,7 +652,7 @@ }, "end": { "line": 21, - "column": 57 + "column": 56 } } }, @@ -678,7 +678,7 @@ }, "end": { "line": 21, - "column": 67 + "column": 66 } } } @@ -690,7 +690,7 @@ }, "end": { "line": 21, - "column": 68 + "column": 67 } } } @@ -895,7 +895,7 @@ }, "end": { "line": 23, - "column": 21 + "column": 20 } } } @@ -923,7 +923,7 @@ }, "end": { "line": 23, - "column": 32 + "column": 31 } } } @@ -1039,7 +1039,7 @@ }, "end": { "line": 24, - "column": 21 + "column": 20 } } }, @@ -1052,7 +1052,7 @@ }, "end": { "line": 24, - "column": 29 + "column": 28 } } } @@ -1365,7 +1365,7 @@ }, "end": { "line": 25, - "column": 62 + "column": 61 } } }, @@ -1406,7 +1406,7 @@ }, "end": { "line": 25, - "column": 79 + "column": 78 } } } @@ -1626,7 +1626,7 @@ }, "end": { "line": 27, - "column": 21 + "column": 20 } } }, @@ -1667,7 +1667,7 @@ }, "end": { "line": 27, - "column": 38 + "column": 37 } } }, @@ -1708,7 +1708,7 @@ }, "end": { "line": 27, - "column": 56 + "column": 55 } } } @@ -1781,7 +1781,7 @@ }, "end": { "line": 28, - "column": 22 + "column": 21 } } }, @@ -1794,7 +1794,7 @@ }, "end": { "line": 28, - "column": 30 + "column": 29 } } }, @@ -1807,7 +1807,7 @@ }, "end": { "line": 28, - "column": 38 + "column": 37 } } } @@ -1908,7 +1908,7 @@ }, "end": { "line": 29, - "column": 25 + "column": 24 } } }, @@ -1977,7 +1977,7 @@ }, "end": { "line": 29, - "column": 45 + "column": 44 } } }, @@ -2018,7 +2018,7 @@ }, "end": { "line": 29, - "column": 57 + "column": 56 } } } @@ -2119,7 +2119,7 @@ }, "end": { "line": 30, - "column": 25 + "column": 24 } } }, @@ -2160,7 +2160,7 @@ }, "end": { "line": 30, - "column": 36 + "column": 35 } } }, @@ -2201,7 +2201,7 @@ }, "end": { "line": 30, - "column": 48 + "column": 47 } } }, @@ -2243,7 +2243,7 @@ }, "end": { "line": 30, - "column": 57 + "column": 56 } } } @@ -2345,7 +2345,7 @@ }, "end": { "line": 31, - "column": 26 + "column": 25 } } }, @@ -2387,7 +2387,7 @@ }, "end": { "line": 31, - "column": 38 + "column": 37 } } }, @@ -2429,7 +2429,7 @@ }, "end": { "line": 31, - "column": 50 + "column": 49 } } } @@ -2994,7 +2994,7 @@ }, "end": { "line": 40, - "column": 63 + "column": 62 } } }, @@ -3007,7 +3007,7 @@ }, "end": { "line": 40, - "column": 71 + "column": 70 } } } @@ -3046,7 +3046,7 @@ }, "end": { "line": 40, - "column": 72 + "column": 71 } } }, @@ -3092,7 +3092,7 @@ }, "end": { "line": 40, - "column": 88 + "column": 87 } } }, @@ -3147,7 +3147,7 @@ }, "end": { "line": 40, - "column": 103 + "column": 102 } } } @@ -3186,7 +3186,7 @@ }, "end": { "line": 40, - "column": 104 + "column": 103 } } }, @@ -3228,7 +3228,7 @@ }, "end": { "line": 40, - "column": 117 + "column": 116 } } } @@ -4042,7 +4042,7 @@ }, "end": { "line": 47, - "column": 50 + "column": 49 } } }, @@ -4097,7 +4097,7 @@ }, "end": { "line": 47, - "column": 65 + "column": 64 } } } @@ -4136,7 +4136,7 @@ }, "end": { "line": 48, - "column": 26 + "column": 25 } } } @@ -4357,7 +4357,7 @@ }, "end": { "line": 53, - "column": 30 + "column": 29 } } }, @@ -4385,7 +4385,7 @@ }, "end": { "line": 53, - "column": 45 + "column": 44 } } }, @@ -4398,7 +4398,7 @@ }, "end": { "line": 53, - "column": 53 + "column": 52 } } } @@ -4532,7 +4532,7 @@ }, "end": { "line": 55, - "column": 47 + "column": 46 } } }, @@ -4545,7 +4545,7 @@ }, "end": { "line": 55, - "column": 56 + "column": 55 } } } @@ -4602,7 +4602,7 @@ }, "end": { "line": 55, - "column": 73 + "column": 72 } } }, @@ -4615,7 +4615,7 @@ }, "end": { "line": 55, - "column": 81 + "column": 80 } } } @@ -5502,7 +5502,7 @@ }, "end": { "line": 66, - "column": 22 + "column": 21 } } }, @@ -5515,7 +5515,7 @@ }, "end": { "line": 66, - "column": 30 + "column": 29 } } } @@ -5543,7 +5543,7 @@ }, "end": { "line": 66, - "column": 41 + "column": 40 } } }, @@ -5556,7 +5556,7 @@ }, "end": { "line": 66, - "column": 49 + "column": 48 } } } @@ -5669,7 +5669,7 @@ }, "end": { "line": 67, - "column": 25 + "column": 24 } } }, @@ -5710,7 +5710,7 @@ }, "end": { "line": 67, - "column": 36 + "column": 35 } } }, @@ -5752,7 +5752,7 @@ }, "end": { "line": 67, - "column": 49 + "column": 48 } } } @@ -5897,7 +5897,7 @@ }, "end": { "line": 68, - "column": 51 + "column": 50 } } }, @@ -5938,7 +5938,7 @@ }, "end": { "line": 68, - "column": 62 + "column": 61 } } } @@ -6023,7 +6023,7 @@ }, "end": { "line": 69, - "column": 22 + "column": 21 } } }, @@ -6036,7 +6036,7 @@ }, "end": { "line": 69, - "column": 30 + "column": 29 } } } @@ -6226,7 +6226,7 @@ }, "end": { "line": 73, - "column": 22 + "column": 21 } } }, @@ -6239,7 +6239,7 @@ }, "end": { "line": 73, - "column": 30 + "column": 29 } } }, @@ -6252,7 +6252,7 @@ }, "end": { "line": 73, - "column": 38 + "column": 37 } } } @@ -6280,7 +6280,7 @@ }, "end": { "line": 73, - "column": 49 + "column": 48 } } }, @@ -6293,7 +6293,7 @@ }, "end": { "line": 73, - "column": 57 + "column": 56 } } }, @@ -6306,7 +6306,7 @@ }, "end": { "line": 73, - "column": 65 + "column": 64 } } }, @@ -6319,7 +6319,7 @@ }, "end": { "line": 73, - "column": 73 + "column": 72 } } } @@ -6700,7 +6700,7 @@ }, "end": { "line": 77, - "column": 49 + "column": 48 } } }, @@ -6713,7 +6713,7 @@ }, "end": { "line": 77, - "column": 57 + "column": 56 } } } @@ -6725,7 +6725,7 @@ }, "end": { "line": 77, - "column": 58 + "column": 57 } } }, @@ -6741,7 +6741,7 @@ }, "end": { "line": 77, - "column": 67 + "column": 66 } } }, @@ -6754,7 +6754,7 @@ }, "end": { "line": 77, - "column": 75 + "column": 74 } } } @@ -6766,7 +6766,7 @@ }, "end": { "line": 77, - "column": 76 + "column": 75 } } } @@ -7251,7 +7251,7 @@ }, "end": { "line": 82, - "column": 33 + "column": 32 } } }, @@ -7264,7 +7264,7 @@ }, "end": { "line": 82, - "column": 41 + "column": 40 } } } diff --git a/es2panda/test/parser/ts/type_checker/tupleAssignability10-expected.txt b/es2panda/test/parser/ts/type_checker/tupleAssignability10-expected.txt index fab701bc9e661dd2c7b7281bd07e242f24c645a2..8e0a7ec1e53b247f37645ead84cb737d8223488f 100644 --- a/es2panda/test/parser/ts/type_checker/tupleAssignability10-expected.txt +++ b/es2panda/test/parser/ts/type_checker/tupleAssignability10-expected.txt @@ -36,7 +36,7 @@ }, "end": { "line": 17, - "column": 23 + "column": 22 } } }, @@ -49,7 +49,7 @@ }, "end": { "line": 17, - "column": 31 + "column": 30 } } } diff --git a/es2panda/test/parser/ts/type_checker/tupleAssignability11-expected.txt b/es2panda/test/parser/ts/type_checker/tupleAssignability11-expected.txt index 2a4a99e04d640bdad037729da644ed0121a5247a..232430f4426c4882218f7e8d98d3b602b9216e3c 100644 --- a/es2panda/test/parser/ts/type_checker/tupleAssignability11-expected.txt +++ b/es2panda/test/parser/ts/type_checker/tupleAssignability11-expected.txt @@ -81,7 +81,7 @@ }, "end": { "line": 18, - "column": 12 + "column": 11 } } } diff --git a/es2panda/test/parser/ts/type_checker/tupleAssignability12-expected.txt b/es2panda/test/parser/ts/type_checker/tupleAssignability12-expected.txt index e930d5c202f2f552b1f4ee1dff11761680a0a516..d3e876743b14d39f6feeb7839b330716ba9a3750 100644 --- a/es2panda/test/parser/ts/type_checker/tupleAssignability12-expected.txt +++ b/es2panda/test/parser/ts/type_checker/tupleAssignability12-expected.txt @@ -49,7 +49,7 @@ }, "end": { "line": 17, - "column": 19 + "column": 18 } } }, @@ -90,7 +90,7 @@ }, "end": { "line": 17, - "column": 30 + "column": 29 } } }, @@ -132,7 +132,7 @@ }, "end": { "line": 17, - "column": 42 + "column": 41 } } } @@ -233,7 +233,7 @@ }, "end": { "line": 18, - "column": 19 + "column": 18 } } }, @@ -274,7 +274,7 @@ }, "end": { "line": 18, - "column": 30 + "column": 29 } } }, @@ -315,7 +315,7 @@ }, "end": { "line": 18, - "column": 41 + "column": 40 } } }, @@ -356,7 +356,7 @@ }, "end": { "line": 18, - "column": 52 + "column": 51 } } } diff --git a/es2panda/test/parser/ts/type_checker/tupleAssignability13-expected.txt b/es2panda/test/parser/ts/type_checker/tupleAssignability13-expected.txt index 229790ab7a1f84d2c1bff2bd602ef89b547011b6..5a43e0365cbf4b227504823029e238a2c2baf772 100644 --- a/es2panda/test/parser/ts/type_checker/tupleAssignability13-expected.txt +++ b/es2panda/test/parser/ts/type_checker/tupleAssignability13-expected.txt @@ -21,7 +21,7 @@ }, "end": { "line": 17, - "column": 16 + "column": 15 } } }, @@ -34,7 +34,7 @@ }, "end": { "line": 17, - "column": 24 + "column": 23 } } }, @@ -47,7 +47,7 @@ }, "end": { "line": 17, - "column": 32 + "column": 31 } } } diff --git a/es2panda/test/parser/ts/type_checker/tupleAssignability15-expected.txt b/es2panda/test/parser/ts/type_checker/tupleAssignability15-expected.txt index d58442c37c8c80b536a18146d87809ff65a757f3..b9946ff2a9f3ce1fed3c93862da98c151932f12e 100644 --- a/es2panda/test/parser/ts/type_checker/tupleAssignability15-expected.txt +++ b/es2panda/test/parser/ts/type_checker/tupleAssignability15-expected.txt @@ -21,7 +21,7 @@ }, "end": { "line": 17, - "column": 16 + "column": 15 } } }, @@ -34,7 +34,7 @@ }, "end": { "line": 17, - "column": 24 + "column": 23 } } }, @@ -47,7 +47,7 @@ }, "end": { "line": 17, - "column": 32 + "column": 31 } } } diff --git a/es2panda/test/parser/ts/type_checker/tupleAssignability16-expected.txt b/es2panda/test/parser/ts/type_checker/tupleAssignability16-expected.txt index 9c79280695fb52e19f63755efef97e53cf2eb4e2..c6e240b9bf2504ee7d379c6d16b5fc3cabfdb620 100644 --- a/es2panda/test/parser/ts/type_checker/tupleAssignability16-expected.txt +++ b/es2panda/test/parser/ts/type_checker/tupleAssignability16-expected.txt @@ -34,7 +34,7 @@ }, "end": { "line": 17, - "column": 18 + "column": 17 } } }, @@ -60,7 +60,7 @@ }, "end": { "line": 17, - "column": 28 + "column": 27 } } } diff --git a/es2panda/test/parser/ts/type_checker/tupleAssignability17-expected.txt b/es2panda/test/parser/ts/type_checker/tupleAssignability17-expected.txt index 7bfefd46a3e73930fd72533c828b9ffead9a4b48..ecb4531cdbc3d71cb4db99971a90df415242d0ed 100644 --- a/es2panda/test/parser/ts/type_checker/tupleAssignability17-expected.txt +++ b/es2panda/test/parser/ts/type_checker/tupleAssignability17-expected.txt @@ -21,7 +21,7 @@ }, "end": { "line": 17, - "column": 16 + "column": 15 } } }, @@ -34,7 +34,7 @@ }, "end": { "line": 17, - "column": 24 + "column": 23 } } } @@ -237,7 +237,7 @@ }, "end": { "line": 19, - "column": 26 + "column": 25 } } }, @@ -250,7 +250,7 @@ }, "end": { "line": 19, - "column": 34 + "column": 33 } } }, @@ -263,7 +263,7 @@ }, "end": { "line": 19, - "column": 42 + "column": 41 } } } diff --git a/es2panda/test/parser/ts/type_checker/tupleAssignability18-expected.txt b/es2panda/test/parser/ts/type_checker/tupleAssignability18-expected.txt index a5cbc53f9a964a03357d4d070548ae06fa595d28..6b78712229a3b0d8456f02514d7cd3d067a3e2e0 100644 --- a/es2panda/test/parser/ts/type_checker/tupleAssignability18-expected.txt +++ b/es2panda/test/parser/ts/type_checker/tupleAssignability18-expected.txt @@ -54,7 +54,7 @@ }, "end": { "line": 16, - "column": 24 + "column": 23 } } }, @@ -96,7 +96,7 @@ }, "end": { "line": 16, - "column": 36 + "column": 35 } } } @@ -135,7 +135,7 @@ }, "end": { "line": 16, - "column": 37 + "column": 36 } } }, @@ -181,7 +181,7 @@ }, "end": { "line": 16, - "column": 59 + "column": 58 } } } @@ -220,7 +220,7 @@ }, "end": { "line": 16, - "column": 60 + "column": 59 } } }, @@ -277,7 +277,7 @@ }, "end": { "line": 16, - "column": 74 + "column": 73 } } } @@ -502,7 +502,7 @@ }, "end": { "line": 17, - "column": 18 + "column": 17 } } } @@ -514,7 +514,7 @@ }, "end": { "line": 17, - "column": 19 + "column": 18 } } } @@ -526,7 +526,7 @@ }, "end": { "line": 17, - "column": 20 + "column": 19 } } } @@ -671,7 +671,7 @@ }, "end": { "line": 19, - "column": 46 + "column": 45 } } } diff --git a/es2panda/test/parser/ts/type_checker/tupleAssignability19-expected.txt b/es2panda/test/parser/ts/type_checker/tupleAssignability19-expected.txt index e9d768f19e4171e766d7c07a083e90a94bff3d82..f3148406478eba04436b4411b35f186ba214e315 100644 --- a/es2panda/test/parser/ts/type_checker/tupleAssignability19-expected.txt +++ b/es2panda/test/parser/ts/type_checker/tupleAssignability19-expected.txt @@ -24,7 +24,7 @@ }, "end": { "line": 17, - "column": 16 + "column": 15 } } } @@ -52,7 +52,7 @@ }, "end": { "line": 17, - "column": 27 + "column": 26 } } } diff --git a/es2panda/test/parser/ts/type_checker/tupleAssignability2-expected.txt b/es2panda/test/parser/ts/type_checker/tupleAssignability2-expected.txt index 899583652869cfd8ea882351c6a4d212fadf4323..88719da8e34a4aeed622a80ee7c3160510ff2288 100644 --- a/es2panda/test/parser/ts/type_checker/tupleAssignability2-expected.txt +++ b/es2panda/test/parser/ts/type_checker/tupleAssignability2-expected.txt @@ -21,7 +21,7 @@ }, "end": { "line": 17, - "column": 16 + "column": 15 } } }, @@ -34,7 +34,7 @@ }, "end": { "line": 17, - "column": 24 + "column": 23 } } } diff --git a/es2panda/test/parser/ts/type_checker/tupleAssignability20-expected.txt b/es2panda/test/parser/ts/type_checker/tupleAssignability20-expected.txt index 7ff77df58704ef7f19ab5c7410967c71b030c740..d04b61cf30519733495cfa0e2f9aa5dbe8e91b66 100644 --- a/es2panda/test/parser/ts/type_checker/tupleAssignability20-expected.txt +++ b/es2panda/test/parser/ts/type_checker/tupleAssignability20-expected.txt @@ -50,7 +50,7 @@ }, "end": { "line": 17, - "column": 27 + "column": 26 } } }, @@ -63,7 +63,7 @@ }, "end": { "line": 17, - "column": 35 + "column": 34 } } } diff --git a/es2panda/test/parser/ts/type_checker/tupleAssignability21-expected.txt b/es2panda/test/parser/ts/type_checker/tupleAssignability21-expected.txt index 06397b7a4dc47df9cfee9689713fbba1635d5326..31da01698230f760a8eab09ffe15153c83e3efa3 100644 --- a/es2panda/test/parser/ts/type_checker/tupleAssignability21-expected.txt +++ b/es2panda/test/parser/ts/type_checker/tupleAssignability21-expected.txt @@ -24,7 +24,7 @@ }, "end": { "line": 17, - "column": 16 + "column": 15 } } }, @@ -37,7 +37,7 @@ }, "end": { "line": 17, - "column": 24 + "column": 23 } } } @@ -65,7 +65,7 @@ }, "end": { "line": 17, - "column": 35 + "column": 34 } } }, @@ -78,7 +78,7 @@ }, "end": { "line": 17, - "column": 43 + "column": 42 } } }, @@ -91,7 +91,7 @@ }, "end": { "line": 17, - "column": 51 + "column": 50 } } } diff --git a/es2panda/test/parser/ts/type_checker/tupleAssignability22-expected.txt b/es2panda/test/parser/ts/type_checker/tupleAssignability22-expected.txt index 5b2bb31018fe4bd0125a716be2fd5e400ae73e9a..d20f35f39f776fe78b309274294d67042b8c661a 100644 --- a/es2panda/test/parser/ts/type_checker/tupleAssignability22-expected.txt +++ b/es2panda/test/parser/ts/type_checker/tupleAssignability22-expected.txt @@ -24,7 +24,7 @@ }, "end": { "line": 17, - "column": 16 + "column": 15 } } }, @@ -37,7 +37,7 @@ }, "end": { "line": 17, - "column": 24 + "column": 23 } } } diff --git a/es2panda/test/parser/ts/type_checker/tupleAssignability23-expected.txt b/es2panda/test/parser/ts/type_checker/tupleAssignability23-expected.txt index 376f24f06be5cecc1ceb6db19e270e6b81731833..ffbdad77cbff243b237ac3e0d38a2be7a77e988c 100644 --- a/es2panda/test/parser/ts/type_checker/tupleAssignability23-expected.txt +++ b/es2panda/test/parser/ts/type_checker/tupleAssignability23-expected.txt @@ -24,7 +24,7 @@ }, "end": { "line": 17, - "column": 17 + "column": 16 } } }, @@ -37,7 +37,7 @@ }, "end": { "line": 17, - "column": 25 + "column": 24 } } } @@ -49,7 +49,7 @@ }, "end": { "line": 17, - "column": 26 + "column": 25 } } }, @@ -65,7 +65,7 @@ }, "end": { "line": 17, - "column": 35 + "column": 34 } } }, @@ -78,7 +78,7 @@ }, "end": { "line": 17, - "column": 43 + "column": 42 } } } @@ -90,7 +90,7 @@ }, "end": { "line": 17, - "column": 44 + "column": 43 } } } diff --git a/es2panda/test/parser/ts/type_checker/tupleAssignability24-expected.txt b/es2panda/test/parser/ts/type_checker/tupleAssignability24-expected.txt index b048ecbd219761d72e2f456d2f4ff81c6e26c553..10a93bc586dfc685192c5e7076f3978b5a3a197a 100644 --- a/es2panda/test/parser/ts/type_checker/tupleAssignability24-expected.txt +++ b/es2panda/test/parser/ts/type_checker/tupleAssignability24-expected.txt @@ -24,7 +24,7 @@ }, "end": { "line": 17, - "column": 16 + "column": 15 } } }, @@ -37,7 +37,7 @@ }, "end": { "line": 17, - "column": 24 + "column": 23 } } }, @@ -50,7 +50,7 @@ }, "end": { "line": 17, - "column": 32 + "column": 31 } } } @@ -164,7 +164,7 @@ }, "end": { "line": 18, - "column": 16 + "column": 15 } } }, @@ -177,7 +177,7 @@ }, "end": { "line": 18, - "column": 24 + "column": 23 } } }, @@ -190,7 +190,7 @@ }, "end": { "line": 18, - "column": 32 + "column": 31 } } }, @@ -203,7 +203,7 @@ }, "end": { "line": 18, - "column": 40 + "column": 39 } } } diff --git a/es2panda/test/parser/ts/type_checker/tupleAssignability3-expected.txt b/es2panda/test/parser/ts/type_checker/tupleAssignability3-expected.txt index 90960da60e9b83fdfa2db0e89bb1ea96993fafef..a1b5c6b9e0c090cc4fcad463e9c36a7324cc7d20 100644 --- a/es2panda/test/parser/ts/type_checker/tupleAssignability3-expected.txt +++ b/es2panda/test/parser/ts/type_checker/tupleAssignability3-expected.txt @@ -21,7 +21,7 @@ }, "end": { "line": 17, - "column": 16 + "column": 15 } } }, @@ -34,7 +34,7 @@ }, "end": { "line": 17, - "column": 24 + "column": 23 } } }, @@ -47,7 +47,7 @@ }, "end": { "line": 17, - "column": 32 + "column": 31 } } } diff --git a/es2panda/test/parser/ts/type_checker/tupleAssignability4-expected.txt b/es2panda/test/parser/ts/type_checker/tupleAssignability4-expected.txt index 5bb14fc852ce56a12cbea8946480d4c63eee1a28..eefbe2fc77cd7cb2b3dee1332f93843731dd43b1 100644 --- a/es2panda/test/parser/ts/type_checker/tupleAssignability4-expected.txt +++ b/es2panda/test/parser/ts/type_checker/tupleAssignability4-expected.txt @@ -21,7 +21,7 @@ }, "end": { "line": 17, - "column": 16 + "column": 15 } } }, @@ -34,7 +34,7 @@ }, "end": { "line": 17, - "column": 24 + "column": 23 } } } @@ -107,7 +107,7 @@ }, "end": { "line": 18, - "column": 16 + "column": 15 } } }, @@ -120,7 +120,7 @@ }, "end": { "line": 18, - "column": 24 + "column": 23 } } } diff --git a/es2panda/test/parser/ts/type_checker/tupleAssignability5-expected.txt b/es2panda/test/parser/ts/type_checker/tupleAssignability5-expected.txt index 519b07fa0dee4621c6ea931ccedca27e818e86fa..7e72bd6578b5864e69364a868df4474f45c86a4b 100644 --- a/es2panda/test/parser/ts/type_checker/tupleAssignability5-expected.txt +++ b/es2panda/test/parser/ts/type_checker/tupleAssignability5-expected.txt @@ -21,7 +21,7 @@ }, "end": { "line": 17, - "column": 16 + "column": 15 } } }, @@ -34,7 +34,7 @@ }, "end": { "line": 17, - "column": 24 + "column": 23 } } } diff --git a/es2panda/test/parser/ts/type_checker/tupleAssignability6-expected.txt b/es2panda/test/parser/ts/type_checker/tupleAssignability6-expected.txt index 3bc4258f376c304a16bd6a471a174f1a5ff7dd4d..bb5579aac66e072c0125360d605346fa28af34a8 100644 --- a/es2panda/test/parser/ts/type_checker/tupleAssignability6-expected.txt +++ b/es2panda/test/parser/ts/type_checker/tupleAssignability6-expected.txt @@ -52,7 +52,7 @@ }, "end": { "line": 17, - "column": 20 + "column": 19 } } }, @@ -94,7 +94,7 @@ }, "end": { "line": 17, - "column": 32 + "column": 31 } } } @@ -106,7 +106,7 @@ }, "end": { "line": 17, - "column": 33 + "column": 32 } } }, @@ -150,7 +150,7 @@ }, "end": { "line": 17, - "column": 52 + "column": 51 } } }, @@ -176,7 +176,7 @@ }, "end": { "line": 17, - "column": 62 + "column": 61 } } } @@ -188,7 +188,7 @@ }, "end": { "line": 17, - "column": 63 + "column": 62 } } } diff --git a/es2panda/test/parser/ts/type_checker/tupleAssignability7-expected.txt b/es2panda/test/parser/ts/type_checker/tupleAssignability7-expected.txt index 25e8e2aad47cb5e0f4d6856e02b2792a77c75ff4..efcfc4bcf18f4f2d44ef035894d6cde65da9aa23 100644 --- a/es2panda/test/parser/ts/type_checker/tupleAssignability7-expected.txt +++ b/es2panda/test/parser/ts/type_checker/tupleAssignability7-expected.txt @@ -52,7 +52,7 @@ }, "end": { "line": 17, - "column": 20 + "column": 19 } } }, @@ -94,7 +94,7 @@ }, "end": { "line": 17, - "column": 32 + "column": 31 } } } @@ -106,7 +106,7 @@ }, "end": { "line": 17, - "column": 33 + "column": 32 } } }, @@ -150,7 +150,7 @@ }, "end": { "line": 17, - "column": 52 + "column": 51 } } }, @@ -176,7 +176,7 @@ }, "end": { "line": 17, - "column": 62 + "column": 61 } } } @@ -188,7 +188,7 @@ }, "end": { "line": 17, - "column": 63 + "column": 62 } } } diff --git a/es2panda/test/parser/ts/type_checker/tupleAssignability8-expected.txt b/es2panda/test/parser/ts/type_checker/tupleAssignability8-expected.txt index dc38074f3127318071f7902c6913703f784335c9..635194598fbc720b8834cd8d91ccf493519eac5a 100644 --- a/es2panda/test/parser/ts/type_checker/tupleAssignability8-expected.txt +++ b/es2panda/test/parser/ts/type_checker/tupleAssignability8-expected.txt @@ -21,7 +21,7 @@ }, "end": { "line": 17, - "column": 16 + "column": 15 } } }, @@ -34,7 +34,7 @@ }, "end": { "line": 17, - "column": 24 + "column": 23 } } }, @@ -47,7 +47,7 @@ }, "end": { "line": 17, - "column": 33 + "column": 32 } } }, @@ -60,7 +60,7 @@ }, "end": { "line": 17, - "column": 41 + "column": 40 } } }, @@ -73,7 +73,7 @@ }, "end": { "line": 17, - "column": 49 + "column": 48 } } } diff --git a/es2panda/test/parser/ts/type_checker/tupleAssignability9-expected.txt b/es2panda/test/parser/ts/type_checker/tupleAssignability9-expected.txt index 7cc4abea32371a4f9df0052308394fcf397d0ab8..de9f2473eb87cbaa96bc6ff0273a148c04701324 100644 --- a/es2panda/test/parser/ts/type_checker/tupleAssignability9-expected.txt +++ b/es2panda/test/parser/ts/type_checker/tupleAssignability9-expected.txt @@ -21,7 +21,7 @@ }, "end": { "line": 17, - "column": 16 + "column": 15 } } }, @@ -34,7 +34,7 @@ }, "end": { "line": 17, - "column": 24 + "column": 23 } } } @@ -122,7 +122,7 @@ }, "end": { "line": 19, - "column": 23 + "column": 22 } } }, @@ -135,7 +135,7 @@ }, "end": { "line": 19, - "column": 31 + "column": 30 } } } diff --git a/es2panda/test/parser/ts/type_checker/typeAliasUsedAsValue-expected.txt b/es2panda/test/parser/ts/type_checker/typeAliasUsedAsValue-expected.txt index 1e0d42f3ffbabc4f01f5239aa034a1a7ce1dd4c0..641a5c0e37e11cec47532953edce46da68c64381 100644 --- a/es2panda/test/parser/ts/type_checker/typeAliasUsedAsValue-expected.txt +++ b/es2panda/test/parser/ts/type_checker/typeAliasUsedAsValue-expected.txt @@ -149,7 +149,7 @@ }, "end": { "line": 17, - "column": 55 + "column": 54 } } }, @@ -162,7 +162,7 @@ }, "end": { "line": 17, - "column": 63 + "column": 62 } } }, @@ -175,7 +175,7 @@ }, "end": { "line": 17, - "column": 71 + "column": 70 } } } diff --git a/es2panda/test/parser/ts/type_checker/varRedeclaration-expected.txt b/es2panda/test/parser/ts/type_checker/varRedeclaration-expected.txt index a18fe84cd5730f08d335e22cf8a7f1ed51e09dcd..9f3c7ef5c29029c93fb8f60531920bbc01fd74ac 100644 --- a/es2panda/test/parser/ts/type_checker/varRedeclaration-expected.txt +++ b/es2panda/test/parser/ts/type_checker/varRedeclaration-expected.txt @@ -5575,7 +5575,7 @@ }, "end": { "line": 94, - "column": 19 + "column": 18 } } }, @@ -5616,7 +5616,7 @@ }, "end": { "line": 94, - "column": 30 + "column": 29 } } }, @@ -5657,7 +5657,7 @@ }, "end": { "line": 94, - "column": 42 + "column": 41 } } } @@ -5730,7 +5730,7 @@ }, "end": { "line": 95, - "column": 16 + "column": 15 } } }, @@ -5743,7 +5743,7 @@ }, "end": { "line": 95, - "column": 24 + "column": 23 } } }, @@ -5756,7 +5756,7 @@ }, "end": { "line": 95, - "column": 33 + "column": 32 } } } @@ -5872,7 +5872,7 @@ }, "end": { "line": 97, - "column": 22 + "column": 21 } } }, @@ -5899,7 +5899,7 @@ }, "end": { "line": 97, - "column": 25 + "column": 24 } } }, @@ -5926,7 +5926,7 @@ }, "end": { "line": 97, - "column": 28 + "column": 27 } } } @@ -6028,7 +6028,7 @@ }, "end": { "line": 98, - "column": 11 + "column": 10 } } }, @@ -6055,7 +6055,7 @@ }, "end": { "line": 98, - "column": 14 + "column": 13 } } }, @@ -6082,7 +6082,7 @@ }, "end": { "line": 98, - "column": 17 + "column": 16 } } } diff --git a/es2panda/test/parser/ts/type_checker/varRedeclaration6-expected.txt b/es2panda/test/parser/ts/type_checker/varRedeclaration6-expected.txt index 9619ac59c8d18942ead585c4fdfcc7f40fd62aff..99b307b72ed7c76b29c0d560be462da35f6d4670 100644 --- a/es2panda/test/parser/ts/type_checker/varRedeclaration6-expected.txt +++ b/es2panda/test/parser/ts/type_checker/varRedeclaration6-expected.txt @@ -21,7 +21,7 @@ }, "end": { "line": 17, - "column": 16 + "column": 15 } } }, @@ -34,7 +34,7 @@ }, "end": { "line": 17, - "column": 24 + "column": 23 } } }, @@ -47,7 +47,7 @@ }, "end": { "line": 17, - "column": 32 + "column": 31 } } } @@ -148,7 +148,7 @@ }, "end": { "line": 18, - "column": 19 + "column": 18 } } }, @@ -189,7 +189,7 @@ }, "end": { "line": 18, - "column": 30 + "column": 29 } } }, @@ -231,7 +231,7 @@ }, "end": { "line": 18, - "column": 42 + "column": 41 } } } diff --git a/es2panda/typescript/checker.h b/es2panda/typescript/checker.h index 734017f290593134a57825da034bb06921a14ca2..b2da9878e9f1365827531a15e029fa2553b1326c 100644 --- a/es2panda/typescript/checker.h +++ b/es2panda/typescript/checker.h @@ -152,6 +152,11 @@ public: return globalTypes_->GlobalStringType(); } + Type *GlobalSymbolType() + { + return globalTypes_->GlobalSymbolType(); + } + Type *GlobalBooleanType() { return globalTypes_->GlobalBooleanType(); diff --git a/es2panda/typescript/types/globalTypesHolder.cpp b/es2panda/typescript/types/globalTypesHolder.cpp index b3078e90bc9df86c3859e3964d926d9e4b3e42c5..3092855603b0f363beefd3df3d8afa2e230d4d5e 100644 --- a/es2panda/typescript/types/globalTypesHolder.cpp +++ b/es2panda/typescript/types/globalTypesHolder.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -41,6 +42,7 @@ GlobalTypesHolder::GlobalTypesHolder(ArenaAllocator *allocator) globalTypes_[static_cast(GlobalTypeId::NUMBER)] = allocator->New(); globalTypes_[static_cast(GlobalTypeId::ANY)] = allocator->New(); globalTypes_[static_cast(GlobalTypeId::STRING)] = allocator->New(); + globalTypes_[static_cast(GlobalTypeId::SYMBOL)] = allocator->New(); globalTypes_[static_cast(GlobalTypeId::BOOLEAN)] = allocator->New(); globalTypes_[static_cast(GlobalTypeId::VOID)] = allocator->New(); globalTypes_[static_cast(GlobalTypeId::NULL_ID)] = allocator->New(); @@ -61,7 +63,7 @@ GlobalTypesHolder::GlobalTypesHolder(ArenaAllocator *allocator) globalTypes_[static_cast(GlobalTypeId::PRIMITIVE)] = allocator->New( allocator, std::initializer_list {GlobalNumberType(), GlobalStringType(), GlobalBigintType(), GlobalBooleanType(), - GlobalVoidType(), GlobalUndefinedType(), GlobalNullType()}); + GlobalVoidType(), GlobalUndefinedType(), GlobalNullType(), GlobalSymbolType()}); globalTypes_[static_cast(GlobalTypeId::EMPTY_TUPLE)] = allocator->New(allocator); globalTypes_[static_cast(GlobalTypeId::EMPTY_OBJECT)] = allocator->New(); globalTypes_[static_cast(GlobalTypeId::RESOLVING_RETURN_TYPE)] = allocator->New(); @@ -83,6 +85,11 @@ Type *GlobalTypesHolder::GlobalStringType() return globalTypes_.at(static_cast(GlobalTypeId::STRING)); } +Type *GlobalTypesHolder::GlobalSymbolType() +{ + return globalTypes_.at(static_cast(GlobalTypeId::SYMBOL)); +} + Type *GlobalTypesHolder::GlobalBooleanType() { return globalTypes_.at(static_cast(GlobalTypeId::BOOLEAN)); diff --git a/es2panda/typescript/types/globalTypesHolder.h b/es2panda/typescript/types/globalTypesHolder.h index fefecfa2e571170cbbf8b1ca16278a4f4855cc5b..68b13c3537a9bfabc1f3496ec481a0398f884430 100644 --- a/es2panda/typescript/types/globalTypesHolder.h +++ b/es2panda/typescript/types/globalTypesHolder.h @@ -24,6 +24,7 @@ enum class GlobalTypeId { NUMBER, ANY, STRING, + SYMBOL, BOOLEAN, VOID, NULL_ID, @@ -57,6 +58,7 @@ public: Type *GlobalNumberType(); Type *GlobalAnyType(); Type *GlobalStringType(); + Type *GlobalSymbolType(); Type *GlobalBooleanType(); Type *GlobalVoidType(); Type *GlobalNullType(); diff --git a/es2panda/typescript/types/symbolType.cpp b/es2panda/typescript/types/symbolType.cpp new file mode 100644 index 0000000000000000000000000000000000000000..65d1ce5fe309b90e4e186cad3c906a700786b2a8 --- /dev/null +++ b/es2panda/typescript/types/symbolType.cpp @@ -0,0 +1,50 @@ +/* + * 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. + */ + +#include "symbolType.h" + +namespace panda::es2panda::checker { + +void SymbolType::ToString(std::stringstream &ss) const +{ + ss << "symbol"; +} + +void SymbolType::Identical(TypeRelation *relation, Type *other) +{ + if (other->IsSymbolType()) { + relation->Result(true); + } +} + +void SymbolType::AssignmentTarget(TypeRelation *relation, Type *source) +{ + if (source->IsSymbolType()) { + relation->Result(true); + } +} + +TypeFacts SymbolType::GetTypeFacts() const +{ + return TypeFacts::SYMBOL_FACTS; +} + +Type *SymbolType::Instantiate([[maybe_unused]] ArenaAllocator *allocator, [[maybe_unused]] TypeRelation *relation, + [[maybe_unused]] GlobalTypesHolder *globalTypes) +{ + return this; +} + +} // namespace panda::es2panda::checker diff --git a/es2panda/typescript/types/symbolType.h b/es2panda/typescript/types/symbolType.h new file mode 100644 index 0000000000000000000000000000000000000000..8ee6484e3c9c6a82e8db1a543fcaaf043d791bb7 --- /dev/null +++ b/es2panda/typescript/types/symbolType.h @@ -0,0 +1,36 @@ +/* + * 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. + */ + +#ifndef ES2PANDA_COMPILER_TYPESCRIPT_TYPES_SYMBOL_TYPE_H +#define ES2PANDA_COMPILER_TYPESCRIPT_TYPES_SYMBOL_TYPE_H + +#include "type.h" + +namespace panda::es2panda::checker { + +class SymbolType : public Type { +public: + SymbolType() : Type(TypeFlag::SYMBOL) {} + + void ToString(std::stringstream &ss) const override; + void Identical(TypeRelation *relation, Type *other) override; + void AssignmentTarget(TypeRelation *relation, Type *source) override; + TypeFacts GetTypeFacts() const override; + Type *Instantiate(ArenaAllocator *allocator, TypeRelation *relation, GlobalTypesHolder *globalTypes) override; +}; + +} // namespace panda::es2panda::checker + +#endif /* TYPESCRIPT_TYPES_STRING_TYPE_H */ diff --git a/es2panda/typescript/types/typeFacts.h b/es2panda/typescript/types/typeFacts.h index 1988b6a09ce69c96b3daa6275a00f81a245c24fb..165c03fa9b0a08f3a3b4e98ad9597bb16b0746f0 100644 --- a/es2panda/typescript/types/typeFacts.h +++ b/es2panda/typescript/types/typeFacts.h @@ -68,6 +68,13 @@ enum class TypeFacts { EMPTY_STRING_FACTS = BASE_STRING_FACTS, NON_EMPTY_STRING_FACTS = BASE_STRING_FACTS | TRUTHY, + // Symbol facts + BASE_SYMBOL_STRICT_FACTS = TYPEOF_EQ_SYMBOL | TYPEOF_NE_NUMBER | TYPEOF_NE_BIGINT | TYPEOF_NE_BOOLEAN | + TYPEOF_NE_STRING | TYPEOF_NE_OBJECT | TYPEOF_NE_FUNCTION | TYPEOF_NE_HOST_OBJECT | + NE_UNDEFINED | NE_NULL | NE_UNDEFINED_OR_NULL, + BASE_SYMBOL_FACTS = BASE_SYMBOL_STRICT_FACTS | EQ_UNDEFINED | EQ_NULL | EQ_UNDEFINED_OR_NULL | FALSY, + SYMBOL_FACTS = BASE_SYMBOL_FACTS | TRUTHY, + // Bigint facts BASE_BIGINT_STRICT_FACTS = TYPEOF_EQ_BIGINT | TYPEOF_NE_STRING | TYPEOF_NE_NUMBER | TYPEOF_NE_BOOLEAN | TYPEOF_NE_SYMBOL | TYPEOF_NE_OBJECT | TYPEOF_NE_FUNCTION | TYPEOF_NE_HOST_OBJECT | diff --git a/es2panda/typescript/types/typeMapping.h b/es2panda/typescript/types/typeMapping.h index 85383ee2ae894b89901ceec217cea3f08dd4c0e1..3ad47aadec77cea976629d24c984238099d9c84e 100644 --- a/es2panda/typescript/types/typeMapping.h +++ b/es2panda/typescript/types/typeMapping.h @@ -24,6 +24,7 @@ _(TypeFlag::BIGINT_LITERAL, BigintLiteralType) \ _(TypeFlag::NUMBER, NumberType) \ _(TypeFlag::STRING, StringType) \ + _(TypeFlag::SYMBOL, SymbolType) \ _(TypeFlag::BOOLEAN, BooleanType) \ _(TypeFlag::VOID, VoidType) \ _(TypeFlag::NULL_TYPE, NullType) \ diff --git a/es2panda/typescript/types/types.h b/es2panda/typescript/types/types.h index 7b3d9810067b7606d298e2e23db021488b202cf8..939919f94a5daee2dbbaa615128e02aa0daf1253 100644 --- a/es2panda/typescript/types/types.h +++ b/es2panda/typescript/types/types.h @@ -36,6 +36,7 @@ #include "objectType.h" #include "stringLiteralType.h" #include "stringType.h" +#include "symbolType.h" #include "tupleType.h" #include "undefinedType.h" #include "unionType.h"