paulmillr / noble-hashes

Audited & minimal JS implementation of hash functions, MACs and KDFs.
https://paulmillr.com/noble
MIT License
545 stars 46 forks source link

Lots of imports required to type a hash #49

Closed sublimator closed 1 year ago

sublimator commented 1 year ago

From some code I was working on recently

import { sha512, SHA512 } from '@noble/hashes/sha512'
import { Hash } from '@noble/hashes/utils'

export default class Sha512 {
  hash: Hash<SHA512>

In this case could simply do hash = sha512.create() but Maybe it's fine, but it seems a bit involved?

Thoughts?

paulmillr commented 1 year ago

I think ReturnType<Type> should work here and would be less code

sublimator commented 1 year ago

Fair, I was using ReturnType but it felt a bit naff somehow