@@ -17,6 +17,7 @@ import (
1717 "github.com/microsoft/typescript-go/internal/binder"
1818 "github.com/microsoft/typescript-go/internal/collections"
1919 "github.com/microsoft/typescript-go/internal/core"
20+ "github.com/microsoft/typescript-go/internal/debug"
2021 "github.com/microsoft/typescript-go/internal/diagnostics"
2122 "github.com/microsoft/typescript-go/internal/evaluator"
2223 "github.com/microsoft/typescript-go/internal/jsnum"
@@ -1542,7 +1543,7 @@ func (c *Checker) checkAndReportErrorForUsingTypeAsNamespace(errorLocation *ast.
15421543 if symbol != nil {
15431544 parent := errorLocation.Parent
15441545 if ast.IsQualifiedName(parent) {
1545- // Debug.assert (parent.Left == errorLocation, "Should only be resolving left side of qualified name as a namespace")
1546+ debug.Assert (parent.AsQualifiedName() .Left == errorLocation, "Should only be resolving left side of qualified name as a namespace")
15461547 propName := parent.AsQualifiedName().Right.Text()
15471548 propType := c.getPropertyOfType(c.getDeclaredTypeOfSymbol(symbol), propName)
15481549 if propType != nil {
@@ -1787,7 +1788,7 @@ func (c *Checker) onSuccessfullyResolvedSymbol(errorLocation *ast.Node, result *
17871788}
17881789
17891790func (c *Checker) checkResolvedBlockScopedVariable(result *ast.Symbol, errorLocation *ast.Node) {
1790- // Debug.assert(!!( result.flags &ast.SymbolFlagsBlockScopedVariable || result.flags &ast.SymbolFlagsClass || result.flags &ast.SymbolFlagsEnum) )
1791+ debug.Assert( result.Flags &ast.SymbolFlagsBlockScopedVariable != 0 || result.Flags &ast.SymbolFlagsClass != 0 || result.Flags &ast.SymbolFlagsEnum != 0 )
17911792 if result.Flags&(ast.SymbolFlagsFunction|ast.SymbolFlagsFunctionScopedVariable|ast.SymbolFlagsAssignment) != 0 && result.Flags&ast.SymbolFlagsClass != 0 {
17921793 // constructor functions aren't block scoped
17931794 return
@@ -1809,7 +1810,7 @@ func (c *Checker) checkResolvedBlockScopedVariable(result *ast.Symbol, errorLoca
18091810 } else if result.Flags&ast.SymbolFlagsRegularEnum != 0 {
18101811 diagnostic = c.error(errorLocation, diagnostics.Enum_0_used_before_its_declaration, declarationName)
18111812 } else {
1812- // Debug.assert(!!( result.flags & ast.SymbolFlagsConstEnum) )
1813+ debug.Assert( result.Flags& ast.SymbolFlagsConstEnum != 0 )
18131814 if c.compilerOptions.GetIsolatedModules() {
18141815 diagnostic = c.error(errorLocation, diagnostics.Enum_0_used_before_its_declaration, declarationName)
18151816 }
@@ -2045,7 +2046,7 @@ func (c *Checker) getTypeOnlyAliasDeclarationEx(symbol *ast.Symbol, include ast.
20452046}
20462047
20472048func (c *Checker) getImmediateAliasedSymbol(symbol *ast.Symbol) *ast.Symbol {
2048- // Debug.assert(( symbol.flags& SymbolFlagsAlias) != 0, "Should only get Alias here.")
2049+ debug.Assert( symbol.Flags&ast. SymbolFlagsAlias != 0, "Should only get Alias here.")
20492050 links := c.aliasSymbolLinks.Get(symbol)
20502051 if links.immediateTarget == nil {
20512052 node := c.getDeclarationOfAliasSymbol(symbol)
@@ -6439,7 +6440,7 @@ func (c *Checker) checkAliasSymbol(node *ast.Node) {
64396440 switch node.Kind {
64406441 case ast.KindImportClause, ast.KindImportSpecifier, ast.KindImportEqualsDeclaration:
64416442 if c.compilerOptions.VerbatimModuleSyntax.IsTrue() {
6442- // Debug.assertIsDefined (node.Name, "An ImportClause with a symbol should have a name")
6443+ debug.AssertIsDefined (node.Name() , "An ImportClause with a symbol should have a name")
64436444 var message *diagnostics.Message
64446445 switch {
64456446 case c.compilerOptions.VerbatimModuleSyntax.IsTrue() && ast.IsInternalModuleImportEqualsDeclaration(node):
@@ -6934,7 +6935,7 @@ func (c *Checker) checkUnusedRenamedBindingElements() {
69346935 for _, node := range c.renamedBindingElementsInTypes {
69356936 if c.symbolReferenceLinks.Get(c.getSymbolOfDeclaration(node)).referenceKinds == 0 {
69366937 wrappingDeclaration := ast.WalkUpBindingElementsAndPatterns(node)
6937- // Debug.assert(isPartOfParameterDeclaration (wrappingDeclaration), "Only parameter declaration should be checked here")
6938+ debug.Assert(ast.IsPartOfParameterDeclaration (wrappingDeclaration), "Only parameter declaration should be checked here")
69386939 diagnostic := NewDiagnosticForNode(node.Name(), diagnostics.X_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation, scanner.DeclarationNameToString(node.Name()), scanner.DeclarationNameToString(node.PropertyName()))
69396940 if wrappingDeclaration.Type() == nil {
69406941 // entire parameter does not have type annotation, suggest adding an annotation
@@ -7201,7 +7202,7 @@ func (c *Checker) checkConstEnumAccess(node *ast.Node, t *Type) {
72017202 // resolve to an import, because imports of ambient const enums get checked
72027203 // separately in `checkAliasSymbol`.
72037204 if c.compilerOptions.IsolatedModules.IsTrue() || c.compilerOptions.VerbatimModuleSyntax.IsTrue() && ok && c.resolveName(node, ast.GetFirstIdentifier(node).Text(), ast.SymbolFlagsAlias, nil, false, true) == nil {
7204- // Debug.assert (t.symbol.Flags&ast.SymbolFlagsConstEnum != 0)
7205+ debug.Assert (t.symbol.Flags&ast.SymbolFlagsConstEnum != 0)
72057206 constEnumDeclaration := t.symbol.ValueDeclaration
72067207 redirect := c.program.GetSourceAndProjectReference(ast.GetSourceFileOfNode(constEnumDeclaration).Path())
72077208 if constEnumDeclaration.Flags&ast.NodeFlagsAmbient != 0 && !ast.IsValidTypeOnlyAliasUseSite(node) && (redirect == nil || !redirect.Resolved.CompilerOptions().ShouldPreserveConstEnums()) {
@@ -8926,7 +8927,7 @@ func (c *Checker) checkTypeArguments(signature *Signature, typeArgumentNodes []*
89268927 typeArgumentTypes := c.fillMissingTypeArguments(core.Map(typeArgumentNodes, c.getTypeFromTypeNode), typeParameters, c.getMinTypeArgumentCount(typeParameters), isJavaScript)
89278928 var mapper *TypeMapper
89288929 for i := range typeArgumentNodes {
8929- // Debug.assert (typeParameters[i] != nil, "Should not call checkTypeArguments with too many type arguments")
8930+ debug.Assert (typeParameters[i] != nil, "Should not call checkTypeArguments with too many type arguments")
89308931 constraint := c.getConstraintOfTypeParameter(typeParameters[i])
89318932 if constraint != nil {
89328933 typeArgumentHeadMessage := core.OrElse(headMessage, diagnostics.Type_0_does_not_satisfy_the_constraint_1)
@@ -10299,8 +10300,8 @@ func (c *Checker) checkImportMetaProperty(node *ast.Node) *Type {
1029910300 } else if c.moduleKind < core.ModuleKindES2020 && c.moduleKind != core.ModuleKindSystem {
1030010301 c.error(node, diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_node18_or_nodenext)
1030110302 }
10302- // file := ast.GetSourceFileOfNode(node)
10303- // Debug.assert (file.Flags&ast.NodeFlagsPossiblyContainsImportMeta != 0, "Containing file is missing import meta node flag.")
10303+ file := ast.GetSourceFileOfNode(node)
10304+ debug.Assert (file.Flags&ast.NodeFlagsPossiblyContainsImportMeta != 0, "Containing file is missing import meta node flag.")
1030410305 if node.Name().Text() == "meta" {
1030510306 return c.getGlobalImportMetaType()
1030610307 }
@@ -12720,7 +12721,7 @@ func (c *Checker) checkObjectLiteral(node *ast.Node, checkMode CheckMode) *Type
1272012721 // an ordinary function declaration(section 6.1) with no parameters.
1272112722 // A set accessor declaration is processed in the same manner
1272212723 // as an ordinary function declaration with a single parameter and a Void return type.
12723- // Debug.assert (memberDecl.kind == KindGetAccessor || memberDecl.kind == KindSetAccessor)
12724+ debug.Assert (memberDecl.Kind == ast. KindGetAccessor || memberDecl.Kind == ast. KindSetAccessor)
1272412725 c.checkNodeDeferred(memberDecl)
1272512726 }
1272612727 if computedNameType != nil && computedNameType.flags&TypeFlagsStringOrNumberLiteralOrUnique == 0 {
@@ -13856,7 +13857,7 @@ func (c *Checker) getSymbolOfPartOfRightHandSideOfImportEquals(entityName *ast.N
1385613857 }
1385713858 // Case 2 in above example
1385813859 // entityName.kind could be a QualifiedName or a Missing identifier
13859- // Debug.assert (entityName.parent.kind == ast.KindImportEqualsDeclaration)
13860+ debug.Assert (entityName.Parent.Kind == ast.KindImportEqualsDeclaration)
1386013861 return c.resolveEntityName(entityName, ast.SymbolFlagsValue|ast.SymbolFlagsType|ast.SymbolFlagsNamespace, false /*ignoreErrors*/, dontResolveAlias, nil /*location*/)
1386113862}
1386213863
@@ -14114,7 +14115,7 @@ func (c *Checker) combineValueAndTypeSymbols(valueSymbol *ast.Symbol, typeSymbol
1411414115 return valueSymbol
1411514116 }
1411614117 result := c.newSymbol(valueSymbol.Flags|typeSymbol.Flags, valueSymbol.Name)
14117- // Debug.assert( valueSymbol.declarations || typeSymbol.declarations )
14118+ debug.Assert(len( valueSymbol.Declarations) > 0 || len( typeSymbol.Declarations) > 0 )
1411814119 result.Declarations = slices.Compact(slices.Concat(valueSymbol.Declarations, typeSymbol.Declarations))
1411914120 result.Parent = valueSymbol.Parent
1412014121 if result.Parent == nil {
@@ -15271,7 +15272,7 @@ func (c *Checker) getResolvedMembersOrExportsOfSymbol(symbol *ast.Symbol, resolu
1527115272// @param lateSymbols The late-bound symbols of the parent.
1527215273// @param decl The member to bind.
1527315274func (c *Checker) lateBindMember(parent *ast.Symbol, earlySymbols ast.SymbolTable, lateSymbols ast.SymbolTable, decl *ast.Node) *ast.Symbol {
15274- // Debug.assert (decl.Symbol, "The member is expected to have a symbol.")
15275+ debug.AssertIsDefined (decl.Symbol() , "The member is expected to have a symbol.")
1527515276 links := c.symbolNodeLinks.Get(decl)
1527615277 if links.resolvedSymbol == nil {
1527715278 // In the event we attempt to resolve the late-bound name of this member recursively,
@@ -15358,7 +15359,7 @@ func (c *Checker) lateBindIndexSignature(parent *ast.Symbol, earlySymbols ast.Sy
1535815359// late-bound members that `addDeclarationToSymbol` in binder.ts performs for early-bound
1535915360// members.
1536015361func (c *Checker) addDeclarationToLateBoundSymbol(symbol *ast.Symbol, member *ast.Node, symbolFlags ast.SymbolFlags) {
15361- // Debug.assert(getCheckFlags( symbol) &ast.CheckFlagsLate != 0, "Expected a late-bound symbol.")
15362+ debug.Assert( symbol.CheckFlags &ast.CheckFlagsLate != 0, "Expected a late-bound symbol.")
1536215363 symbol.Flags |= symbolFlags
1536315364 c.lateBoundLinks.Get(member.Symbol()).lateSymbol = symbol
1536415365 if len(symbol.Declarations) == 0 || member.Symbol().Flags&ast.SymbolFlagsReplaceableByMethod == 0 {
@@ -15829,7 +15830,7 @@ func (c *Checker) getTypeOfVariableOrParameterOrPropertyWorker(symbol *ast.Symbo
1582915830 members["exports"] = fileSymbol
1583015831 return c.newAnonymousType(symbol, members, nil, nil, nil)
1583115832 }
15832- // Debug.assertIsDefined (symbol.valueDeclaration )
15833+ debug.AssertIsDefined (symbol.ValueDeclaration )
1583315834 declaration := symbol.ValueDeclaration
1583415835 if ast.IsSourceFile(declaration) && ast.IsJsonSourceFile(declaration.AsSourceFile()) {
1583515836 statements := declaration.AsSourceFile().Statements.Nodes
@@ -15960,7 +15961,7 @@ func (c *Checker) getTypeForVariableLikeDeclaration(declaration *ast.Node, inclu
1596015961 thisParameter := c.getAccessorThisParameter(fn)
1596115962 if thisParameter != nil && declaration == thisParameter {
1596215963 // Use the type from the *getter*
15963- // Debug.assert (thisParameter.Type_ == nil )
15964+ debug.AssertNil (thisParameter.Type() )
1596415965 return c.getTypeOfSymbol(getterSignature.thisParameter)
1596515966 }
1596615967 return c.getReturnTypeOfSignature(getterSignature)
@@ -17775,7 +17776,7 @@ func (c *Checker) addOptionalityEx(t *Type, isProperty bool, isOptional bool) *T
1777517776}
1777617777
1777717778func (c *Checker) getOptionalType(t *Type, isProperty bool) *Type {
17778- // Debug.assert (c.strictNullChecks)
17779+ // debug.Assert (c.strictNullChecks) // TODO: fix bug in isRequiredInitializedParameter
1777917780 missingOrUndefined := core.IfElse(isProperty, c.undefinedOrMissingType, c.undefinedType)
1778017781 if t == missingOrUndefined || t.flags&TypeFlagsUnion != 0 && t.Types()[0] == missingOrUndefined {
1778117782 return t
@@ -20271,7 +20272,7 @@ func (c *Checker) getUnionSignatures(signatureLists [][]*Signature) []*Signature
2027120272 for _, signatures := range signatureLists {
2027220273 if !core.Same(signatures, masterList) {
2027320274 signature := signatures[0]
20274- // Debug.assert (signature, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass")
20275+ debug.AssertIsDefined (signature, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass")
2027520276 if len(signature.typeParameters) != 0 && core.Some(results, func(s *Signature) bool {
2027620277 return len(s.typeParameters) != 0 && !c.compareTypeParametersIdentical(signature.typeParameters, s.typeParameters)
2027720278 }) {
@@ -22813,7 +22814,7 @@ func (c *Checker) getOuterTypeParametersOfClassOrInterface(symbol *ast.Symbol) [
2281322814 return initializer != nil && ast.IsFunctionExpressionOrArrowFunction(initializer)
2281422815 })
2281522816 }
22816- // Debug.assert(!! declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations")
22817+ debug.AssertIsDefined( declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations")
2281722818 return c.getOuterTypeParameters(declaration, false /*includeThisTypes*/)
2281822819}
2281922820
@@ -23124,7 +23125,7 @@ func (c *Checker) evaluateEntity(expr *ast.Node, location *ast.Node) evaluator.R
2312423125 name := expr.AsElementAccessExpression().ArgumentExpression.Text()
2312523126 member := rootSymbol.Exports[name]
2312623127 if member != nil {
23127- // Debug.assert (ast.GetSourceFileOfNode(member.valueDeclaration ) == ast.GetSourceFileOfNode(rootSymbol.valueDeclaration ))
23128+ debug.Assert (ast.GetSourceFileOfNode(member.ValueDeclaration ) == ast.GetSourceFileOfNode(rootSymbol.ValueDeclaration ))
2312823129 if location != nil {
2312923130 return c.evaluateEnumMember(expr, member, location)
2313023131 }
@@ -27584,7 +27585,7 @@ func (c *Checker) getPromisedTypeOfPromiseEx(t *Type, errorNode *ast.Node, thisT
2758427585 }
2758527586 }
2758627587 if len(candidates) == 0 {
27587- // Debug.assertIsDefined (thisTypeForError)
27588+ debug.AssertIsDefined (thisTypeForError)
2758827589 if thisTypeForErrorOut != nil {
2758927590 *thisTypeForErrorOut = thisTypeForError
2759027591 }
@@ -28780,7 +28781,7 @@ func (c *Checker) getLegacyDecoratorCallSignature(decorator *ast.Node) *Signatur
2878028781 break
2878128782 }
2878228783 index := slices.Index(node.Parent.Parameters(), node) - core.IfElse(ast.GetThisParameter(node.Parent) != nil, 1, 0)
28783- // Debug.assert (index >= 0)
28784+ debug.Assert (index >= 0)
2878428785 // A parameter declaration decorator will have three arguments (see `ParameterDecorator` in
2878528786 // core.d.ts).
2878628787 var targetType *Type
0 commit comments