Skip to content

RyoMa99/typescript-type-practice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

TypeScriptの組み込み型関数 Recordの使いどころ

これがもっときれいに書けるんじゃないかと思ってやってみた

const usersAgeFn1 = (users:{[key:string] : {age:number}}) => {
    let ages : {[key:string]:number} = {}
    for( let [key,value] of Object.entries(users) ){
        ages[key] = value.age
    }
    return ages
}

const usersAge1 = usersAgeFn1(users)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published