Skip to content

1. 常用类型标注 #1

@wuyuedefeng

Description

@wuyuedefeng
  1. vue useRef
import { ref } from 'vue'
export function useRef<T extends abstract new(...args: any) => any>(_component: T) {
  return ref<InstanceType<T>>()
}
  1. Omit, Partial, Pick的使用
interface Article {
  author: string,
  date: Date,
  readCount: number,
}
type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
type CreateArticle = Optional<Article, 'author' | 'date' | 'readCount'>;

function createArticle(article: CreateArticle) {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions