Giter Site home page Giter Site logo

Comments (4)

ciscoheat avatar ciscoheat commented on June 3, 2024 1

Opened a PR for this issue in #1211

from superstruct.

mnahkies avatar mnahkies commented on June 3, 2024

Duplicates #1160

Would be nice to get a resolution to this / #1160 - just ran into this today 🤞

from superstruct.

ciscoheat avatar ciscoheat commented on June 3, 2024

Same here, cannot integrate Superstruct in Superforms v2 due to this.

from superstruct.

nerochiaro avatar nerochiaro commented on June 3, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.