MasatoDev / boostest

14 stars 0 forks source link

Support several ts signature types #20

Closed MasatoDev closed 1 month ago

MasatoDev commented 2 months ago
pub enum TSSignature<'a> {
    TSIndexSignature(Box<'a, TSIndexSignature<'a>>),
    TSPropertySignature(Box<'a, TSPropertySignature<'a>>),
    TSCallSignatureDeclaration(Box<'a, TSCallSignatureDeclaration<'a>>),
    TSConstructSignatureDeclaration(Box<'a, TSConstructSignatureDeclaration<'a>>),
    TSMethodSignature(Box<'a, TSMethodSignature<'a>>),
}

✅TSPropertySignature

this signature is already supported.

type Person = {
    name: string;
    age: number;
};

const person: Person = { name: "hoge", age: 30 };

✅TSIndexSignature

type StringDictionary = { [index: string]: string };

const myDict: StringDictionary = {
    name: "hoge",
};

https://github.com/MasatoDev/boostest/pull/23

☑️TSCallSignatureDeclaration

type MyFunc = (name: string, age: number) => string;

const greet: MyFunc = (name, age) => `Hello, ${name}! You are ${age} years old.`;

Basic Call Signature cases have been handled in the following PR. https://github.com/MasatoDev/boostest/pull/24

TSConstructSignatureDeclaration

new (parameter1: Type1, parameter2: Type2, ...) => InstanceType;

☑️TSMethodSignature

methodName(parameter1: Type1, parameter2: Type2, ...): ReturnType;

Basic TSMethod Signature cases have been handled in the following PR. https://github.com/MasatoDev/boostest/pull/24

MasatoDev commented 1 month ago

Supported items are displayed in tabular form. Almost all listed items are supported without TSConstructSignatureDeclaration.