import { Ast } from "@syuilo/aiscript/index.js"; import { SourceLocation } from "../parser/SourceRange.js"; export declare const primitiveTypeNames: readonly ["str", "num", "bool", "null"]; export type PrimitiveTypeName = (typeof primitiveTypeNames)[number]; export declare const objectTypeName: readonly ["obj", "arr"]; export type ObjectTypeName = (typeof objectTypeName)[number]; export declare const typeNames: readonly ["str", "num", "bool", "null", "obj", "arr", "error"]; export type TypeName = (typeof typeNames)[number]; export interface PrimitiveType { type: "PrimitiveType"; name: PrimitiveTypeName; } export interface ObjectType { type: "ObjectType"; items: Map | TypeValue; } export interface ArrayType { type: "ArrayType"; item: TypeValue; } export interface AnyType { type: "AnyType"; } export interface ErrorType { type: "ErrorType"; name: PrimitiveType & { name: "str"; }; info?: TypeValue; } /** * まだ推論できていない型情報 */ export interface NothingType { type: "NothingType"; } export interface FunctionType { type: "FunctionType"; params: { isOptional: boolean; type: TypeValue; }[]; returnType: TypeValue; } export interface UnionType { type: "UnionType"; contents: TypeValue[]; } export type TypeValue = FunctionType | AnyType | NothingType | UnionType | PrimitiveType | ObjectType | ArrayType | ErrorType; export declare function loc(line?: number, column?: number): SourceLocation; export declare function ident(name: string, location?: SourceLocation): Ast.Identifier; export declare function primitiveType(name: PrimitiveTypeName): PrimitiveType; export declare function objectType(items: TypeValue): ObjectType; export declare function arrayType(item: TypeValue): ArrayType; export declare function errorType(info: TypeValue): ErrorType; export declare function fnType(params: FunctionType["params"], returnType: TypeValue): FunctionType; export declare function union(...types: TypeValue[]): UnionType; export declare const anyType: AnyType;