-
-
Notifications
You must be signed in to change notification settings - Fork 214
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
Aliasing an exported type as the default export hides needed types #354
Comments
@shellscape We better get rid of introducing breaking change. I already have a plan to release v3 by the end of this year, by simplifying the logic, and have better API design. What we can do for now is to export something like // index.ts
import IdentityProvider, { IdentityProvider as IdentityProviderInstance } from './src/entity-idp';
import ServiceProvider, { ServiceProvider as ServiceProviderInstance } from './src/entity-sp';
// ...
export {
IdentityProvider,
IdentityProviderInstance,
ServiceProvider,
ServiceProviderInstance
}
// samlify.IdentityProvider won't break with this approach, it's still calling the default function For the cache, it can be something like as follow. type Cache = {
[issuer: string]: IdentityProviderInstance | ServiceProviderInstance
};
let cache: Cache; Any better idea? |
Any update on this issue? This is actually preventing me from migrating to Samlify from another lib |
@shellscape @FreifeldRoyi How's the above mentioned proposal? This wouldn't break the current typing definition. |
Sounds good |
@FreifeldRoyi as a work around you can use import { IdentityProvider, ServiceProvider } from 'samlify';
let idp: ReturnType<typeof IdentityProvider>;
let sp: ReturnType<typeof ServiceProvider>; |
@FreifeldRoyi @shellscape Feel free to check the release of 2.7.4. |
Referencing the way that this project exports the public members here:
samlify/index.ts
Line 2 in 728fde8
By using
IdentityProvider
as the default export alias, the actualIdentityProvider
class (https://github.com/tngan/samlify/blob/master/src/entity-idp.ts#L30) is being hidden from resolution by consuming code.If we're trying to build say, a cache that contains one or more
IdentityProvider
class instances, and type that cache properly, there's no way to reference that type.We'd be forced to use a module file path:
and that's really really bad since that approach is well known to be prone to breaking between patch versions.
A better solution here would be to export such like:
and export a named function in entity-idp.ts:
Or, at the very least, export the types for
IdentityProvider
andServiceProvider
in a minor version without breaking changes.The text was updated successfully, but these errors were encountered: