question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using an `index.ts` file to export multiple types that would be deserialized causes silent failures

See original GitHub issue

If you have multiple files like bellow:

data/stat-weight-unit.ts

export type StatWeightUnit = 'lbs' | 'kg';

data/stat-engine-power-unit.ts

export type StatEnginePowerUnit = 'hp';

data/index.ts

export { StatWeightUnit } from './stat-weight-unit';
export { StatEnginePowerUnit } from './stat-engine-power-unit';

test.ts

import { StatEnginePowerUnit } from './data';

console.log(cast<StatEnginePowerUnit>('kg'));

The serializer will return undefined always, and it will not emit the value, no matter if the serialized value is valid or not.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
marcjcommented, Jul 23, 2022

@danfma ok, cool! You might be interested in https://github.com/hanayashiki/deepkit-openapi

1reaction
marcjcommented, Jul 22, 2022

ah, I see, thanks for the explanation. I think we have to adjust export statements in the compiler to fix that, so that

export { StatWeightUnit } from './stat-weight-unit';
export { StatEnginePowerUnit } from './stat-engine-power-unit';

becomes

export { StatWeightUnit, __ΩStatWeightUnit } from './stat-weight-unit';
export { StatEnginePowerUnit, __ΩStatEnginePowerUnit } from './stat-engine-power-unit';

seems straightforward and easy

Read more comments on GitHub >

github_iconTop Results From Across the Web

Export all files in `index.ts` - Stack Overflow
In this case, you need to create an index.ts file in your components directory. ... Note 1: Using this type of imports/exports will...
Read more >
Imports in index.ts file are not getting correctly resolved. #29171
When I try to import, Engine class in another file using import {Engine} from '../engine'; engine is not defined.
Read more >
Node.js v19.3.0 Documentation
Indicates the failure of an assertion. All errors thrown by the node:assert module will be instances of the AssertionError class. new assert.AssertionError( ...
Read more >
Firebase JavaScript SDK Release Notes - Google
Added types fields to exports object in package.json files for all published ... Fixed some typings issues that caused compile errors for TypeScript...
Read more >
IO tools (text, CSV, HDF5, …) — pandas 1.5.2 documentation
index_col=False can be used to force pandas to not use the first column as the index, e.g. when you have a malformed file...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found