Slide 12
Slide 12 text
TS 5.8以降にアップデートし module=nodenext
を指定すればOK
さらにTS5.9では module=node20
も追加(挙動は同じ)
module=node16
(TS 5.7以前の nodenext
) では依然として型エラー
error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls;
however, the referenced file is an ECMAScript module and cannot be imported with 'require'.
Consider writing a dynamic 'import("graphql-request")' call instead.
To convert this file to an ECMAScript module, change its file extension to '.mts'
or create a local package.json file with `{ "type": "module" }`.
1 import { GraphQLClient, ClientError } from "graphql-request";
~~~~~~~~~~~~~~~~~
TypeScript側の対応
12