Add types to compileTime modules
This commit is contained in:
parent
2a78515acd
commit
389ec700b8
5 changed files with 30 additions and 29 deletions
|
@ -28,12 +28,16 @@ const sanitizeBasename = (path: string | undefined = ''): string => {
|
|||
return `/${trim(path, '/')}`;
|
||||
};
|
||||
|
||||
const env = {
|
||||
NODE_ENV: NODE_ENV || 'development',
|
||||
BACKEND_URL: sanitizeURL(BACKEND_URL),
|
||||
FE_SUBDIRECTORY: sanitizeBasename(FE_SUBDIRECTORY),
|
||||
FE_INSTANCE_SOURCE_DIR: FE_INSTANCE_SOURCE_DIR || 'instance',
|
||||
SENTRY_DSN,
|
||||
};
|
||||
|
||||
export type SoapboxEnv = typeof env;
|
||||
|
||||
export default () => ({
|
||||
data: {
|
||||
NODE_ENV: NODE_ENV || 'development',
|
||||
BACKEND_URL: sanitizeURL(BACKEND_URL),
|
||||
FE_SUBDIRECTORY: sanitizeBasename(FE_SUBDIRECTORY),
|
||||
FE_INSTANCE_SOURCE_DIR: FE_INSTANCE_SOURCE_DIR || 'instance',
|
||||
SENTRY_DSN,
|
||||
},
|
||||
data: env,
|
||||
});
|
||||
|
|
|
@ -1,16 +1,9 @@
|
|||
// @ts-nocheck
|
||||
const {
|
||||
NODE_ENV,
|
||||
BACKEND_URL,
|
||||
FE_SUBDIRECTORY,
|
||||
FE_INSTANCE_SOURCE_DIR,
|
||||
SENTRY_DSN,
|
||||
} = import.meta.compileTime('./build-config-compiletime.ts');
|
||||
import type { SoapboxEnv } from './build-config-compiletime';
|
||||
|
||||
export {
|
||||
export const {
|
||||
NODE_ENV,
|
||||
BACKEND_URL,
|
||||
FE_SUBDIRECTORY,
|
||||
FE_INSTANCE_SOURCE_DIR,
|
||||
SENTRY_DSN,
|
||||
};
|
||||
} = import.meta.compileTime<SoapboxEnv>('./build-config-compiletime.ts');
|
||||
|
|
|
@ -9,7 +9,7 @@ import type {
|
|||
Status as StatusEntity,
|
||||
} from 'soapbox/types/entities';
|
||||
|
||||
const locales = import.meta.compileTime('./web-push-locales.ts');
|
||||
const locales = import.meta.compileTime<Record<string, Record<string, string>>>('./web-push-locales.ts');
|
||||
|
||||
/** Limit before we start grouping device notifications into a single notification. */
|
||||
const MAX_NOTIFICATIONS = 5;
|
||||
|
|
|
@ -35,14 +35,18 @@ const version = (pkg: Record<string, any>) => {
|
|||
return pkg.version;
|
||||
};
|
||||
|
||||
const code = {
|
||||
name: pkg.name,
|
||||
displayName: pkg.displayName,
|
||||
url: pkg.repository.url,
|
||||
repository: shortRepoName(pkg.repository.url),
|
||||
version: version(pkg),
|
||||
homepage: pkg.homepage,
|
||||
ref: CI_COMMIT_TAG || CI_COMMIT_SHA || tryGit('git rev-parse HEAD'),
|
||||
};
|
||||
|
||||
export type Code = typeof code;
|
||||
|
||||
export default () => ({
|
||||
data: {
|
||||
name: pkg.name,
|
||||
displayName: pkg.displayName,
|
||||
url: pkg.repository.url,
|
||||
repository: shortRepoName(pkg.repository.url),
|
||||
version: version(pkg),
|
||||
homepage: pkg.homepage,
|
||||
ref: CI_COMMIT_TAG || CI_COMMIT_SHA || tryGit('git rev-parse HEAD'),
|
||||
},
|
||||
data: code,
|
||||
});
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
const data: any = import.meta.compileTime('./code-compiletime.ts');
|
||||
import type { Code } from './code-compiletime';
|
||||
|
||||
export default data;
|
||||
export default import.meta.compileTime<Code>('./code-compiletime.ts');
|
Loading…
Reference in a new issue