Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typescript 常用技巧 #44

Open
hardfist opened this issue Nov 11, 2019 · 0 comments
Open

typescript 常用技巧 #44

hardfist opened this issue Nov 11, 2019 · 0 comments

Comments

@hardfist
Copy link
Owner

hardfist commented Nov 11, 2019

  • useRef避免null判断
  const ref1 = useRef<HTMLDivElement>(null!);// ref1.current就非空了
  • makeTuple
function makeTuple<T extends any[]>(...elements:T){
  return elements;
}

const x = makeTuple(1,'s','ss') // 推断为[number,string,string]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant