Comments (4)
Opened a PR for this issue in #1211
from superstruct.
Duplicates #1160
Would be nice to get a resolution to this / #1160 - just ran into this today 🤞
from superstruct.
Same here, cannot integrate Superstruct in Superforms v2 due to this.
from superstruct.
I am testing version 1.0.5-0 which, as I understand it, is a pre-release for the fix to this issue.
It works OK if I put "moduleResolution":"node16"
in my tsconfig.json
.
However it seems to fail for me when I also use "module": "node16"
along with it.
This is what is recommended for node 20 by https://www.npmjs.com/package/@tsconfig/node20 so I would expect superstruct to work with this common configuration. But maybe I am misunderstanding something.
My index.ts
file is like this:
import { object, string } from 'superstruct';
const User = object({ foo: string() });
and I get this error:
index.ts:1:32 - 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("superstruct")' call instead.
To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `"type": "module"` to '/home/ugo/superstructure-test/package.json'.
1 import { object, string } from 'superstruct';
Am I missing something or should this work too ?
from superstruct.
Related Issues (20)
- [Feature] `one of` or `or` type HOT 2
- [Feature] Discriminated unions (fast lookup) HOT 1
- `size` on `array` uses a permissive type
- Defaulted optional to undefined does not fill field with default value
- Never type creates a typescript issue
- Dynamic context property access
- Unexpected behaviour when combining `assign` + `refine`
- pattern (regex) does not return consistent output when using the global modifier
- Source maps seem broken HOT 4
- `instance` causes a TypeScript error with abstract classes
- Unions of instances produce unhelpful error message
- Mask fails on `interface aaa { foo: string; [key: string]: any }` interface with any key.
- Move tests to Vitest
- Describe does not work well with union types
- Does "create" supports "passthrough"
- How can I generate declaration file from superstruct HOT 2
- Intersection of type schema and record with enums as keys HOT 1
- [Docs] Document pass-by-reference pitfall for `defaulted` values HOT 2
- Defaulted values are not correctly copied for `record` type data.
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 superstruct.