Skip to content

Commit

Permalink
Export relevant interfaces alongside init function type
Browse files Browse the repository at this point in the history
This adds a new `client-entry-type.ts` file in order to avoid exporting
interfaces from `client-entry.ts` directly, which a) causes warnings at
build time (see webpack/webpack#7378) and also
makes the exported interfaces appear in the js dist file, which we don't
want. The only purpose of this file is to export the type of the init
function from `client-entry.ts` and other interfaces that may be useful
for consumers.

Bug: T342235
Change-Id: I71fb071bcd7dafa817e22ff04d8bfcefcd9a26e1
  • Loading branch information
jakobw committed Aug 2, 2023
1 parent 1cf7716 commit b11d12e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
15 changes: 14 additions & 1 deletion dist/wikibase.termbox.init.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,17 @@ type ConfigurableServices = {
};
declare const _default: (consumerDefinedServices: ConfigurableServices, isEditable: boolean) => Promise<App>;

export { _default as default };
interface LoggableError {
getContext(): object;
}

declare class ContextError extends Error implements LoggableError {
private context;
constructor(message: string, context?: object);
getContext(): object;
}

declare class TechnicalProblem extends ContextError {
}

export { EntityRepository, TechnicalProblem, WritingEntityRepository, _default as default };
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const alias = require( '@rollup/plugin-alias' ).default;

module.exports = [
{
input: './dist/client-entry.d.ts',
input: './dist/client-entry-type.d.ts',
output: [ { file: 'dist/wikibase.termbox.init.d.ts', format: 'es' } ],
plugins: [
dts(),
Expand Down
7 changes: 7 additions & 0 deletions src/client-entry-type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This file only exists to export types that may be useful to consumers without
// exporting interfaces from client-entry.ts itself.

export { default } from './client-entry';
export { default as EntityRepository } from '@/common/data-access/EntityRepository';
export { default as WritingEntityRepository } from '@/common/data-access/WritingEntityRepository';
export { default as TechnicalProblem } from '@/common/data-access/error/TechnicalProblem';

0 comments on commit b11d12e

Please sign in to comment.