Skip to content

Commit 5faa35a

Browse files
committed
chore(ts): improvements
1 parent 1340041 commit 5faa35a

File tree

5 files changed

+92
-13
lines changed

5 files changed

+92
-13
lines changed

package-lock.json

+69
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,12 @@
7373
"@nuxt/module-builder": "0.8.4",
7474
"@nuxt/webpack-builder": "3.15.4",
7575
"@types/consola": "^2.2.8",
76+
"@types/finalhandler": "^1.2.3",
77+
"@types/jsdom": "^21.1.7",
7678
"@types/mime-types": "^2.1.4",
7779
"@types/node": "22.13.5",
7880
"@types/rimraf": "^4.0.5",
81+
"@types/serve-static": "^1.15.7",
7982
"@types/vimeo": "^2.1.8",
8083
"@types/vue": "2.0.0",
8184
"@types/webpack": "^5.28.5",

playground/nuxt.config.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import * as postcssFunctions from './postcss/functions';
88
const isDev = process.env.NODE_ENV === 'development';
99

1010
function getBuilder() {
11-
return (process.env.npm_config_builder ||
12-
process.env.BUILDER ||
11+
return (process.env.npm_config_builder ??
12+
process.env.BUILDER ??
1313
'vite') as NuxtConfig['builder'];
1414
}
1515

@@ -404,23 +404,23 @@ export default defineNuxtConfig({
404404
]
405405
},
406406

407-
modules: ['@nuxt/eslint', '../src/module']
407+
modules: ['@nuxt/eslint', '../src/module'],
408408

409-
// eslint: {
410-
// config: {
411-
// // typescript: false
412-
// }
413-
// }
409+
typescript: {
410+
tsConfig: {
411+
include: ['../../test/**/*.ts']
412+
}
413+
}
414414
});
415415

416416
function getBaseUrl() {
417-
return process.env.npm_config_base_url || process.env.BASE_URL || '/';
417+
return process.env.npm_config_base_url ?? process.env.BASE_URL ?? '/';
418418
}
419419

420420
function getHost() {
421-
return process.env.npm_config_host || process.env.HOST || 'localhost';
421+
return process.env.npm_config_host ?? process.env.HOST ?? 'localhost';
422422
}
423423

424424
function getPort() {
425-
return Number(process.env.npm_config_port || process.env.PORT || 3000);
425+
return Number(process.env.npm_config_port ?? process.env.PORT ?? 3000);
426426
}

test/nuxt.config.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1+
// import type { ModuleOptions } from '../src/types/module';
12
import { defineNuxtConfig, type NuxtConfig } from 'nuxt/config';
23
import { createResolver } from '@nuxt/kit';
34

45
import { join, resolve } from 'pathe';
56
import nuxtConfig from '../playground/nuxt.config.js';
67

8+
interface ExtendedNuxtConfig extends NuxtConfig {
9+
booster?: {
10+
targetFormats?: string[];
11+
};
12+
}
13+
714
const resolver = createResolver(import.meta.url);
815

916
const rootDir = resolver.resolve('.');
@@ -13,7 +20,7 @@ export const distDir = join(rootDir, 'dist');
1320
export default defineNuxtConfig(
1421
await (async () => {
1522
const defaultConfig =
16-
(await (nuxtConfig as CallableFunction)) as NuxtConfig;
23+
(await (nuxtConfig as CallableFunction)) as ExtendedNuxtConfig;
1724
if (defaultConfig.runtimeConfig?.public) {
1825
defaultConfig.runtimeConfig.public.isTest = true;
1926
defaultConfig.runtimeConfig.public.disableInfoLayer = true;

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
"youtube",
99
"vimeo"
1010
]
11-
},
11+
}
1212
}

0 commit comments

Comments
 (0)