Skip to content

Breaks newer typebox (export * behaviour?) #269

Open

Description

@FauxFaux

I believe something is mishandling the extensive use of export * in https://github.com/sinclairzx81/typebox/blob/0c31e10b1d080ed95c2a58e52aaf8c517b7aaf18/src/type/types/index.ts , but don't understand enough about either project to provide a better guess.

echo '{"type":"module"}' > package.json
npm i import-in-the-middle typebox

repro.js

import * as Type from 'typebox/type';
import { Value } from 'typebox/value';
import { Type as T } from 'typebox';

console.log('IsTemplateLiteral:', typeof Type.IsTemplateLiteral);
console.log('IsString:', typeof Type.IsString);
console.log('IsObject:', typeof Type.IsObject);

try {
  const unionSchema = T.Object({ level: T.Union([T.Literal('a'), T.Literal('b')]) });
  console.log('Convert union OK:', JSON.stringify(Value.Convert(unionSchema, { level: 'a' })));
} catch (e) {
  console.log('CONVERT union ERROR:', (e).message);
}
$ node repro.js
IsTemplateLiteral: function
IsString: function
IsObject: function
Convert union OK: {"level":"a"}
$ node --loader=import-in-the-middle/hook.mjs repro.js
...
IsTemplateLiteral: undefined
...
CONVERT union ERROR: Type.IsTemplateLiteral is not a function
├── import-in-the-middle@3.3.1
└── typebox@1.3.6

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions