Export types for TS inference
jasonkuhrt opened this issue · comments
Screenshot
Getting this TS error in Molt Command:
src/ParameterSpec/validate.ts:6:14 - error TS2742: The inferred type of 'Result' cannot be named without a reference to '../../node_modules/alge/dist/esm/core/types.js'. This is likely not portable. A type annotation is necessary.
6 export const Result = Alge.data(`Result`, {
~~~~~~
src/ParameterSpec/validate.ts:6:14 - error TS2742: The inferred type of 'Result' cannot be named without a reference to '../../node_modules/alge/dist/esm/data/types/Controller.js'. This is likely not portable. A type annotation is necessary.
6 export const Result = Alge.data(`Result`, {
~~~~~~
src/ParameterSpec/validate.ts:6:14 - error TS2742: The inferred type of 'Result' cannot be named without a reference to '../../node_modules/alge/dist/esm/record/types/StoredRecord.js'. This is likely not portable. A type annotation is necessary.
6 export const Result = Alge.data(`Result`, {
~~~~~~
Found 3 errors in the same file, starting at: src/ParameterSpec/validate.ts:6
Description
Try fixing this by exporting types from Alge...
See if having another exported entrypoint of alge/types
solves this for the consumer.
Repro Steps/Link
The solution sort of worked, however, consumers still need to do at least this:
import type * as _ from 'alge/types'
Maybe there could be a way to export the types onto the Alge
namespace so that the inference works without the still confusing workaround? ... We could take them away at Alge.Types.*
...?
Closed by 504f4de
Yep that fixed it! At least this case.