remark: remark-parse/lib/index.d.ts imports a module that cannot be referenced
Initial checklist
- I read the support docs
- I read the contributing guide
- I agree to follow the code of conduct
- I searched issues and couldn’t find anything (or linked relevant results below)
Affected packages and versions
remark-parse 10.0.1
Link to runnable example
No response
Steps to reproduce
https://github.com/yamachu/remark-types-broken-repro
- Create a typescript project with strict type checking ( like this https://github.com/yamachu/remark-types-broken-repro/blob/699e5a1ef6963c6f0c6d06d503b962543ffb8945/tsconfig.json )
- add dependencies unified 10.1.2 and remark-parse 10.0.1
- write code as below (code: REPRO)
- execute
npx tsc --noEmit
for running type check
REPRO
import { unified } from "unified";
import markdown from "remark-parse";
const processor = unified().use(markdown);
const _ = processor.parse("**This is Markdown**");
Expected behavior
Pass type check without error
Actual behavior
Fail type check with error
Runtime
Node v16
Package manager
yarn 1
OS
macOS
Build and bundle tools
Other (please specify in steps to reproduce)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (10 by maintainers)
related? https://github.com/microsoft/TypeScript/issues/38111
You are using the TypeScript compiler options"module": "node16"
and"moduleResolution": "node16"
(the latter is redundant if the former is specified). Those are the correct TypeScript options to use since TypeScript 4.7, but not all packages are using / supporting this yet, including remark apparently.remark-parse
is doing this correctly:https://github.com/remarkjs/remark/blob/99179c6745a2173d07d5c3b46bad7df767e1989d/packages/remark-parse/lib/index.js#L3
However, TypeScript generates:
If we use
"module": "node16"
, it’s even worse.This appears to be a TypeScript bug (causing bugs in our output. This is definitely a bug in remark’s published packages).
I then solved this problem with the following settings.
tsconfig.json
@yamachu unfortunately the only workaround / solution I see so far is to use
"skipLibCheck": true
.thanks @JounQin
here is error log