From dbb1aa4d0e46970f5a39fea7baf5b010d535cad1 Mon Sep 17 00:00:00 2001 From: David Joy Date: Wed, 31 Jul 2024 13:16:31 -0400 Subject: [PATCH] fix: getting rid of d.ts linting errors, exporting properly At least I think this exports it properly; seems to work in apps! --- .eslintrc.js | 1 + Makefile | 2 +- frontend-base.d.ts | 12 +++++ index.d.ts | 119 --------------------------------------------- index.ts | 9 ++++ package.json | 3 +- tsconfig.json | 3 +- 7 files changed, 25 insertions(+), 124 deletions(-) create mode 100644 frontend-base.d.ts delete mode 100644 index.d.ts diff --git a/.eslintrc.js b/.eslintrc.js index e50d3c32..27ba428e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,6 +7,7 @@ module.exports = createConfig('eslint', { 'test-app', 'docs', '.eslintrc.js', + 'frontend-base.d.ts', ], parserOptions: { project: path.resolve(__dirname, './tsconfig.json'), diff --git a/Makefile b/Makefile index 8828e1d6..d662cf2c 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ cat_docs_command = cat ./docs/_API-header.md ./docs/_API-body.md > ./docs/API.md build: rm -rf ./dist tsc - cp index.d.ts dist/index.d.ts + cp frontend-base.d.ts dist/frontend-base.d.ts mkdir -p ./scss/header/studio-header cp shell/index.scss dist/shell/index.scss diff --git a/frontend-base.d.ts b/frontend-base.d.ts new file mode 100644 index 00000000..b2db15f7 --- /dev/null +++ b/frontend-base.d.ts @@ -0,0 +1,12 @@ +/// + +import { OpenedXConfig } from "./dist"; + +declare module 'env.config' { + export default OpenedXConfig; +} + +declare module '*.svg' { + const content: string; + export default content; +} diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 7b5ce813..00000000 --- a/index.d.ts +++ /dev/null @@ -1,119 +0,0 @@ -export { - APP_ANALYTICS_INITIALIZED, - APP_AUTH_INITIALIZED, - APP_CONFIG_INITIALIZED, - APP_I18N_INITIALIZED, - APP_INIT_ERROR, - APP_LOGGING_INITIALIZED, - APP_PUBSUB_INITIALIZED, - APP_READY, - APP_TOPIC, - AUTHENTICATED_USER_CHANGED, - AUTHENTICATED_USER_TOPIC, - AppContext, - AppProvider, - AuthenticatedPageRoute, - AxiosJwtAuthService, - CONFIG_CHANGED, - CONFIG_TOPIC, - ErrorBoundary, - ErrorPage, - FormattedDate, - FormattedMessage, - FormattedNumber, - FormattedPlural, - FormattedRelativeTime, - FormattedTime, - IntlProvider, - LOCALE_CHANGED, - LOCALE_TOPIC, - LoginRedirect, - MockAnalyticsService, - MockAuthService, - MockLoggingService, - NewRelicLoggingService, - PageWrap, - SegmentAnalyticsService, - auth, - camelCaseObject, - configureAnalytics, - configureAuth, - configureI18n, - configureLogging, - convertKeyNames, - createIntl, - defineMessages, - ensureAuthenticatedUser, - ensureConfig, - ensureDefinedConfig, - fetchAuthenticatedUser, - getAnalyticsService, - getAuthService, - getAuthenticatedHttpClient, - getAuthenticatedUser, - getConfig, - getCountryList, - getCountryMessages, - getHttpClient, - getLanguageList, - getLanguageMessages, - getLocale, - getLoggingService, - getLoginRedirectUrl, - getLogoutRedirectUrl, - getMessages, - getPath, - getPrimaryLanguageSubtag, - getQueryParameters, - handleRtl, - history, - hydrateAuthenticatedUser, - identifyAnonymousUser, - identifyAuthenticatedUser, - initError, - initialize, - initializeMockApp, - injectIntl, - intlShape, - isRtl, - logError, - logInfo, - mergeConfig, - mergeMessages, - mockMessages, - modifyObjectKeys, - parseURL, - publish, - redirectToLogin, - redirectToLogout, - resetAnalyticsService, - resetLoggingService, - sendPageEvent, - sendTrackEvent, - sendTrackingLogEvent, - setAuthenticatedUser, - setConfig, - snakeCaseObject, - subscribe, - unsubscribe, - useAppEvent, - useIntl -} from './runtime'; - -declare module 'env.config' { - export default OpenedXConfig; -} - -declare module '*.svg' { - const content: string; - export default content; -} - -export interface OpenedXConfig { - /** - * The application content for the shell. This is a temporary configuration option while we - * convert micro-frontends to plugins. It must be a React functional component that takes no - * arguments and returns JSX. - */ - app?: () => JSX.Element -} diff --git a/index.ts b/index.ts index b85804d5..701c8cec 100644 --- a/index.ts +++ b/index.ts @@ -99,3 +99,12 @@ export { useAppEvent, useIntl } from './runtime'; + +export interface OpenedXConfig { + /** + * The application content for the shell. This is a temporary configuration option while we + * convert micro-frontends to plugins. It must be a React functional component that takes no + * arguments and returns JSX. + */ + app?: () => JSX.Element +} diff --git a/package.json b/package.json index 5fb424ab..a200d699 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ }, "main": "dist/index.js", "module": "dist/index.js", - "types": "dist/index.d.ts", + "types": "dist/frontend-base.d.ts", "files": [ "/dist", "/config", @@ -21,7 +21,6 @@ }, "scripts": { "build": "make build", - "build:watch": "tsc --watch", "clean": "rm -rf dist", "docs": "jsdoc -c jsdoc.json", "docs:watch": "nodemon -w runtime -w docs/template -w README.md -e js,jsx,ts,tsx --exec npm run docs", diff --git a/tsconfig.json b/tsconfig.json index ae1228ed..1c23ce1e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,7 @@ "rootDir": ".", "outDir": "dist", "noEmit": false, - "declaration": false, + "declaration": true, }, "include": [ "bin/**/*", @@ -13,7 +13,6 @@ "runtime/**/*", "shell/**/*", "index.ts", - "index.d.ts", "jest.config.js", "babel.config.js", ],