/** * Variable declaration type checking helpers and static field type resolution. * * Provides predicates for type emittability, structural assertion detection, * nullish initializer detection, explicit cast checking, and static field * type resolution. */ import { IrExpression, IrType, NumericKind } from "@tsonic/frontend"; import { EmitterContext } from "../../types.js"; import type { CSharpTypeAst, CSharpExpressionAst } from "../../core/format/backend-ast/types.js"; import type { IrStatement } from "@tsonic/frontend"; /** * Types that require explicit LHS type because C# has no literal suffix for them. * For these types, `var x = 200;` would infer `int`, not the intended type. */ export declare const TYPES_NEEDING_EXPLICIT_DECL: Set; /** * Check if a type can be explicitly emitted as a C# type. * Returns false for types that cannot be named in C# (any, unknown, anonymous). */ export declare const canEmitTypeExplicitly: (type: IrType) => boolean; export declare const isStructuralTypeAssertionInitializer: (initializer: ({ readonly kind: string; readonly targetType?: IrType; readonly inferredType?: IrType; } & Record) | undefined, context: EmitterContext) => boolean; export declare const shouldTreatStructuralAssertionAsErased: (decl: { readonly type?: IrType; readonly initializer?: { readonly kind: string; readonly targetType?: IrType; readonly inferredType?: IrType; }; }, context: EmitterContext) => boolean; /** * Check if a type requires explicit local variable declaration. * Returns true for types like byte, sbyte, short, ushort that have no C# suffix. * Resolves type aliases to get the underlying type. */ export declare const needsExplicitLocalType: (type: IrType, context: EmitterContext) => boolean; export declare const isExplicitCastLikeAst: (ast: CSharpExpressionAst) => boolean; export declare const shouldForceDeclaredInitializerCast: (initializer: IrExpression | undefined, declaredType: IrType | undefined, context: EmitterContext) => boolean; /** * Helper: check if an initializer is a nullish expression (undefined/null literal or identifier). */ export declare const isNullishInitializer: (init: { kind: string; value?: unknown; name?: string; }) => boolean; export declare const isNullableValueUnion: (type: IrType | undefined) => boolean; export declare const shouldEmitReadonlyStaticField: (stmt: Extract, decl: { readonly name: { readonly kind: string; readonly name?: string; }; }, context: EmitterContext) => boolean; /** * Resolve the C# type AST for a static field declaration. * * Priority: * 1) numericNarrowing initializer (e.g., `1000 as int`) - use CLR type * 2) typeAssertion initializer (e.g., `obj as Person`) - use target type * 3) asinterface initializer (e.g., `asinterface>(db.Events)`) - use target type * 4) Explicit/inferred IR type * 5) Infer from initializer (new, literal, inferredType) * 6) Fallback to object * * Arrow function types are handled separately in emitStaticArrowFieldMembers. */ export declare const resolveStaticFieldType: (decl: { readonly type?: IrType; readonly initializer?: { readonly kind: string; readonly targetKind?: NumericKind; readonly targetType?: IrType; readonly callee?: unknown; readonly typeArguments?: readonly IrType[]; readonly value?: unknown; readonly numericIntent?: NumericKind; readonly inferredType?: IrType; }; }, context: EmitterContext) => [CSharpTypeAst, EmitterContext]; //# sourceMappingURL=variable-type-helpers.d.ts.map