ts-book icon indicating copy to clipboard operation
ts-book copied to clipboard

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

Open ldhbenecia opened this issue 1 year ago • 1 comments

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"}');

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

ldhbenecia avatar Sep 09 '23 07:09 ldhbenecia