Comments (2)
docs/examples
is a temporary folder used by docs-ts
to run all the examples (which are supposed to be valid, including the necessary imports). If there are no errors, it will be deleted by docs-ts
, and it is not supposed to be committed.
The error you're receiving is due to the fact that type: "module"
is not supported.
As a workaround, you could add the following two files to the /docs
folder:
package.json
{
"name": "examples"
}
tsconfig.json
{
"compilerOptions": {
"module": "CommonJS"
// your other options
}
}
from docs-ts.
@gcanti That doesn't appear to work for me with ESM imports:
// https://www.typescriptlang.org/docs/handbook/esm-node.html
import x from './y.js'
// https://nodejs.org/api/packages.html#subpath-imports
import x from '#self/y'
TSError: ⨯ Unable to compile TypeScript:
docs/examples/src-Alternative.ts-function-pureIf-0.ts(2,24): 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("../../src/Alternative")' call instead.
To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `"type": "module"` to '/path/to/repo/docs/package.json'.
Repro (slightly different files in :/docs/
but easy to adjust): https://github.com/samhh/fp-ts-std/tree/esm (Edit: out of date, but the issue can be repro'd in the repo generally)
Edit: Built a workaround script: samhh/fp-ts-std@4d679d6#diff-11acf79cfa31caef7478b768e28dffb6d7272c308c98f666c529f68bc9685871
from docs-ts.
Related Issues (20)
- [discussion] Why use ts-morph over tsc? HOT 3
- Error when compiling docs HOT 2
- `@types/node` is needed HOT 2
- Horizontal scrolling in rendered code blocks HOT 4
- @example imports still buggy HOT 1
- Incorrect return type for `toNullable` and `toUndefined` HOT 1
- "Missing examples" when examples are enforced in fp-ts-std HOT 10
- View rendered docs locally HOT 4
- Omit `.ts` in sidebar HOT 2
- Can't ignore private methods from being generated HOT 1
- Enforcement exclusions HOT 4
- Modules with only exports from other modules result in empty ToC
- Feature request: Forward options to ts-morph
- ts-morph needs updating
- tsx support
- "Why" section of the readme seems incomplete HOT 1
- Consider migrating to vitepress
- Bug: getter documentation is skipped
- Prettier as peer dependency prevents upgrading it in consumers projects HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docs-ts.