This is a bug in at least @turf/envelope@6.5.0 and potentially other packages.
Typescript has recently released a new moduleResolution option that when set to node16 or nodenext will use new ESM resolution logic. This includes an understanding of the new "exports" package.json field.
Any module in this monorepo that currently uses the exports field (like @turf/envelope) must now specify the types in the export config as well, otherwise Typescript will complain that it can't find the types file if you turn on moduleResolution: "node16".
E.g. Turn this:
{
"main": "dist/js/index.js",
"module": "dist/es/index.js",
"exports": {
"./package.json": "./package.json",
".": {
"import": "./dist/es/index.js",
"require": "./dist/js/index.js"
}
},
"types": "index.d.ts",
}
Into this:
{
"main": "dist/js/index.js",
"module": "dist/es/index.js",
"exports": {
"./package.json": "./package.json",
".": {
"types": "./index.d.ts",
"import": "./dist/es/index.js",
"require": "./dist/js/index.js"
}
},
"types": "index.d.ts",
}
Until then, using this package in Typescript with the new module resolution scheme results in the error TS7016: Could not find a declaration file for module '@turf/envelope'.
This is a bug in at least
@turf/envelope@6.5.0and potentially other packages.Typescript has recently released a new
moduleResolutionoption that when set tonode16ornodenextwill use new ESM resolution logic. This includes an understanding of the new "exports" package.json field.Any module in this monorepo that currently uses the exports field (like @turf/envelope) must now specify the types in the export config as well, otherwise Typescript will complain that it can't find the types file if you turn on
moduleResolution: "node16".E.g. Turn this:
{ "main": "dist/js/index.js", "module": "dist/es/index.js", "exports": { "./package.json": "./package.json", ".": { "import": "./dist/es/index.js", "require": "./dist/js/index.js" } }, "types": "index.d.ts", }Into this:
{ "main": "dist/js/index.js", "module": "dist/es/index.js", "exports": { "./package.json": "./package.json", ".": { "types": "./index.d.ts", "import": "./dist/es/index.js", "require": "./dist/js/index.js" } }, "types": "index.d.ts", }Until then, using this package in Typescript with the new module resolution scheme results in the error
TS7016: Could not find a declaration file for module '@turf/envelope'.