Skip to content

Commit f7c2d87

Browse files
authored
Merge pull request #1248 from basics/feature/improve-typescript
Typescript improvements
2 parents 1ee8ba5 + d4eacf0 commit f7c2d87

File tree

12 files changed

+141
-157
lines changed

12 files changed

+141
-157
lines changed

package-lock.json

Lines changed: 94 additions & 95 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
"stylelint-config-recess-order": "6.0.0",
110110
"stylelint-config-standard": "37.0.0",
111111
"typescript-eslint": "8.26.0",
112+
"vite-plugin-checker": "^0.9.0",
112113
"vite-svg-loader": "5.1.0",
113114
"vitepress": "1.6.3",
114115
"vitest": "3.0.8",

src/runtime/classes/FontCollection.ts

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@ import {
44
getStyleDescription
55
} from '../utils/description';
66
import type Font from './Font';
7-
import type {
8-
Link,
9-
Noscript,
10-
Style,
11-
TagUserProperties,
12-
UserTagConfigWithoutInnerContent
13-
} from '@unhead/schema';
7+
// import type { RawInput } from 'unhead/types';
8+
// import type { Link, Noscript, Style } from '@unhead/vue';
149
import type { ModulePublicRuntimeConfig } from '../../module';
1510

11+
// TagUserProperties,
12+
// UserTagConfigWithoutInnerContent
13+
1614
export default class FontCollection {
1715
list: Font[];
1816
constructor() {
@@ -38,10 +36,7 @@ export default class FontCollection {
3836
return rootSelector;
3937
}
4038

41-
getPreloadDescriptions(
42-
critical: boolean,
43-
crossorigin = 'anonymous'
44-
): Link<UserTagConfigWithoutInnerContent>[] {
39+
getPreloadDescriptions(critical: boolean, crossorigin = 'anonymous') {
4540
return Array.from(
4641
this.list
4742
.reduce((result, font) => {
@@ -60,19 +55,17 @@ export default class FontCollection {
6055
);
6156
}
6257

63-
getStyleDescriptions(
64-
options: ModulePublicRuntimeConfig
65-
): Link<TagUserProperties>[] {
58+
getStyleDescriptions(options: ModulePublicRuntimeConfig) {
6659
return getRelevantDescriptions([
6760
getStyleDescription(
6861
this.list.map(font => font.getCSSText(options)).join(' '),
6962
false,
7063
this.getKey()
7164
)
72-
]) as Link<TagUserProperties>[];
65+
]);
7366
}
7467

75-
getNoScriptStyleDescriptions(): TagUserProperties[] {
68+
getNoScriptStyleDescriptions() {
7669
return getRelevantDescriptions([
7770
getStyleDescription(
7871
this.list.map(font => font.getNoScriptCSSText()).join(' '),
@@ -97,6 +90,6 @@ function toFontHex(value: string) {
9790
return toHashHex(value).padStart(9, '-');
9891
}
9992

100-
function getRelevantDescriptions(descriptions: (Style | Noscript)[]) {
93+
function getRelevantDescriptions(descriptions: Partial<{ key: string }>[]) {
10194
return descriptions.filter(item => item.key !== '0');
10295
}

src/runtime/classes/lighthouse/Stats.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
enum State {
1+
export enum State {
22
READY,
33
FAIL,
44
PENDING

src/runtime/components/BoosterImage/classes/Source.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type {
77
HTMLCrossOriginAttribute,
88
ISource
99
} from '../../../../module';
10-
import type { Link, TagUserProperties } from '@unhead/schema';
10+
import type { Link } from '@unhead/vue';
1111

1212
export default class Source implements ISource {
1313
src: string;
@@ -90,12 +90,8 @@ export default class Source implements ISource {
9090
);
9191
}
9292

93-
getPreload(
94-
srcset: string,
95-
sizes?: string,
96-
crossorigin?: CrossOrigin
97-
): Link<TagUserProperties> {
98-
const preload: Link<TagUserProperties> = {
93+
getPreload(srcset: string, sizes?: string, crossorigin?: CrossOrigin): Link {
94+
const preload: Link = {
9995
rel: 'preload',
10096
as: 'image',
10197
imagesrcset: srcset,

src/runtime/components/BoosterVimeo/Base.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import {
3838
onMounted,
3939
onUnmounted
4040
} from 'vue';
41-
import type { Script } from '@unhead/schema';
41+
import type { Script } from '@unhead/vue';
4242
4343
import DefaultButton from '../Button.vue';
4444
import {

0 commit comments

Comments
 (0)