glimmerjs / glimmer-vm

MIT License
1.13k stars 191 forks source link

Glimmer is compiled incorrectly #1570

Closed NullVoxPopuli closed 8 months ago

NullVoxPopuli commented 8 months ago

in particular, type-imports are making it in to the dist-output as values, which then errors when checking under typescript (but not runtime) due to the import not existing.

For example, @glimmer/manager imports Reference from @glimmer/reference, but that import should not be present at all in the dist output, because in the source it is a type import.

NullVoxPopuli commented 8 months ago

or maybe something else is going on, it's so hard to tell

NullVoxPopuli commented 8 months ago

oh actually, this is true, the compiled output of @glimmer/reference doesn't include Reference

import { Nullable, Reference, ReferenceSymbol } from "@glimmer/interfaces";
declare const REFERENCE: ReferenceSymbol;
//////////
interface ReferenceEnvironment {
    getProp(obj: unknown, path: string): unknown;
    setProp(obj: unknown, path: string, value: unknown): unknown;
}
declare function createPrimitiveRef<T extends string | symbol | number | boolean | null | undefined>(value: T): Reference<T>;
declare const UNDEFINED_REFERENCE: Reference<any>;
declare const NULL_REFERENCE: Reference<any>;
declare const TRUE_REFERENCE: Reference<true>;
declare const FALSE_REFERENCE: Reference<false>;
declare function createConstRef<T>(value: T, debugLabel: false | string): Reference<T>;
declare function createUnboundRef<T>(value: T, debugLabel: false | string): Reference<T>;
declare function createComputeRef<T = unknown>(compute: () => T, update?: Nullable<(value: T) => void>, debugLabel?: false | string): Reference<T>;
declare function createReadOnlyRef(ref: Reference): Reference;
declare function isInvokableRef(ref: Reference): boolean;
declare function createInvokableRef(inner: Reference): Reference;
declare function isConstRef(_ref: Reference): boolean;
declare function isUpdatableRef(_ref: Reference): boolean;
declare function valueForRef<T>(_ref: Reference<T>): T;
declare function updateRef(_ref: Reference, value: unknown): void;
declare function childRefFor(_parentRef: Reference, path: string): Reference;
declare function childRefFromParts(root: Reference, parts: string[]): Reference;
declare let createDebugAliasRef: undefined | ((debugLabel: string, inner: Reference) => Reference);
interface IterationItem<T, U> {
    key: unknown;
    value: T;
    memo: U;
}
interface AbstractIterator<T, U, V extends IterationItem<T, U>> {
    isEmpty(): boolean;
    next(): Nullable<V>;
}
type OpaqueIterationItem = IterationItem<unknown, unknown>;
type OpaqueIterator = AbstractIterator<unknown, unknown, OpaqueIterationItem>;
interface IteratorDelegate {
    isEmpty(): boolean;
    next(): {
        value: unknown;
        memo: unknown;
    } | null;
}
type KeyFor = (item: unknown, index: unknown) => unknown;
declare function createIteratorRef(listRef: Reference, key: string): Reference<ArrayIterator | IteratorWrapper>;
declare function createIteratorItemRef(_value: unknown): Reference<unknown>;
declare class IteratorWrapper implements OpaqueIterator {
    private inner;
    private keyFor;
    constructor(inner: IteratorDelegate, keyFor: KeyFor);
    isEmpty(): boolean;
    next(): OpaqueIterationItem;
}
declare class ArrayIterator implements OpaqueIterator {
    private iterator;
    private keyFor;
    private current;
    private pos;
    constructor(iterator: unknown[] | readonly unknown[], keyFor: KeyFor);
    isEmpty(): boolean;
    next(): Nullable<IterationItem<unknown, number>>;
}
export { AbstractIterator, createIteratorItemRef, createIteratorRef, IterationItem, IteratorDelegate, OpaqueIterationItem, OpaqueIterator, childRefFor, childRefFromParts, createComputeRef, createConstRef, createDebugAliasRef, createInvokableRef, createPrimitiveRef, createReadOnlyRef, createUnboundRef, FALSE_REFERENCE, isConstRef, isInvokableRef, isUpdatableRef, NULL_REFERENCE, REFERENCE, Reference, ReferenceEnvironment, TRUE_REFERENCE, UNDEFINED_REFERENCE, updateRef, valueForRef };
//# sourceMappingURL=index.d.ts.map
NullVoxPopuli commented 8 months ago

looks like this is due to export { value, type AType } from .../

AType never makes it to the output

NullVoxPopuli commented 8 months ago

or no, it's just hidden in that super long line at the bottom. what is goin on in my consuming project then....