-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Different Declaration output for same code from js and ts file #51622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think I understand why this is happening, but it seems super undesirable. |
Why is TS changing the import specifier? That should never happen. |
Is there anything we can do to help? is the reproduction good enough? in the meantime we found a "worse" example //
// input (simplified)
//
import { Constructor } from '@open-wc/dedupe-mixin';
import { LitElement } from 'lit';
import { LocalizeMixinHost } from '@lion/ui/types/localize.js';
export declare class IngFieldHost { /* ... */ }
declare function IngFieldMixinImplementation<T extends Constructor<LitElement>>(
superclass: T,
): T &
Constructor<IngFieldHost> &
Pick<typeof IngFieldHost, keyof typeof IngFieldHost> &
Constructor<LocalizeMixinHost> &
Pick<typeof LocalizeMixinHost, keyof typeof LocalizeMixinHost> &
Pick<typeof LitElement, keyof typeof LitElement>;
export type IngFieldMixin = typeof IngFieldMixinImplementation;
//
// output (simplified)
//
export type IngFieldMixin = import('./types/IngFieldMixinTypes.js').IngFieldMixin;
export const IngFieldMixin: <
T extends import('@open-wc/dedupe-mixin').Constructor<import('lit').LitElement>,
>(
superclass: T,
) => T &
import('@open-wc/dedupe-mixin').Constructor<
import('./types/IngFieldMixinTypes.js').IngFieldHost
> &
Pick<typeof import('./types/IngFieldMixinTypes.js').IngFieldHost, 'prototype' | 'properties'> &
import('@open-wc/dedupe-mixin').Constructor<
import('../../../../node_modules/@lion/ui/dist-types/exports/types/localize.js').LocalizeMixinHost
> &
Pick<
typeof import('../../../../node_modules/@lion/ui/dist-types/exports/types/localize.js').LocalizeMixinHost,
'prototype' | 'localizeNamespaces' | 'waitForLocalizeNamespaces'
> &
Pick<
typeof import('lit').LitElement,
| 'prototype'
// [...]
>; seems potentially related as its resolving a path again... but as it's a monorepo it does go pretty badly π e.g. to highlight the issue // input
Constructor<LocalizeMixinHost>
// expected
import('@open-wc/dedupe-mixin').Constructor<
import('@lion/ui/types/localize.js').LocalizeMixinHost
>
// actual
import('@open-wc/dedupe-mixin').Constructor<
import('../../../../node_modules/@lion/ui/dist-types/exports/types/localize.js').LocalizeMixinHost
> we currently "postprocess" the generated again if there is anything we can do to prepare this more please let us know π€ |
Bug Report
π Search Terms
declaration import rewrite
declaration import change
π Version & Regression Information
β― Playground Link
Sadly not possible as it's about importing of "nested" dependencies.
So I created a reproduction repository
npm install
npm run types
dist-types
π» Code
When creating types from a
ts
source file it keeps the import pathes as is. (which is expected)π Source:
src/ElementA.ts
π Output:
dist-types/src/ElementA.d.ts
When creating types from "the exact same file" but as a
js
it changes the import pathes by "resolving" them.π Source:
src/ElementB.js
π Actual behavior
π Output:
dist-types/src/ElementB.d.ts
π Expected behavior
Consequences
Because of the miss match between the "location" of
LitElement
TS believes those are different LitElement types.The text was updated successfully, but these errors were encountered: