ZeroCho / ts-book

타입스크립트 교과서 소스 코드
36 stars 5 forks source link

[p.52, 오타] fetch any 타입 정의 오타 #31

Open ldhbenecia opened 10 months ago

ldhbenecia commented 10 months ago
fetch("url").then((response) => {
    return response.json();
}).them((result) => { // (parameter) result: any
});

const result = JSON.parse('{"hello":"json"'); // const result: any
fetch("url").then<{ data: string }>((response) => {
    return response.json();
}).them((result) => { // (parameter) result: { data: string; }
});

const result: { hello: string } = JSON.parse('{"hello":"json"');

두 구문 모두 밑의

const result: { hello: string } = JSON.parse('{"hello":"json"}');

중괄호가 누락된 것 같습니다.

ZeroCho commented 10 months ago

앗 감사합니다!