Skip to content

Commit fb16240

Browse files
chore(typescript): update typescript to version 5.9.2 (#6397)
* chore(typescript): update typescript to version 5.9.2 Fix new type errors. Add types array to tsconfig.json to fix a new issue with dts-bundle-generator + babel. (timocov/dts-bundle-generator#347) * chore(typescript): run prettier and fix lodash import * chore(typescript): override autocorrect type in HTMLStencilElement for typescript 5.9 compatibility Omit autocorrect from HTMLElement and redefine it as 'on' | 'off'. Update node version to address breaking change with typed arrays in new typescript version. * chore(typescript): improve type information for MockDocument location Window.location's setter now takes a string, so update MockDocument.location's setter to match. * chore(typescript): add TODO note to remove autocorrect override Co-authored-by: John Jenkins <[email protected]> * chore(typescript): update node types and typescript versions Add ~ to typescript version to accept patch updates. Update Node types version to match necessary version update in bundler test. --------- Co-authored-by: John Jenkins <[email protected]>
1 parent 06a2375 commit fb16240

File tree

16 files changed

+117
-88
lines changed

16 files changed

+117
-88
lines changed

package-lock.json

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

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
"@types/graceful-fs": "^4.1.5",
147147
"@types/jest": "^27.0.3",
148148
"@types/listr": "^0.14.4",
149-
"@types/node": "^20.12.11",
149+
"@types/node": "^24.6.2",
150150
"@types/pixelmatch": "^5.2.4",
151151
"@types/pngjs": "^6.0.1",
152152
"@types/prompts": "^2.0.9",
@@ -197,19 +197,19 @@
197197
"semver": "^7.3.7",
198198
"terser": "5.37.0",
199199
"tsx": "^4.19.2",
200-
"typescript": "~5.5.4",
200+
"typescript": "~5.9.2",
201201
"webpack": "^5.75.0",
202202
"ws": "8.17.1"
203203
},
204204
"optionalDependencies": {
205-
"@rollup/rollup-linux-x64-gnu": "4.34.9",
206-
"@rollup/rollup-linux-x64-musl": "4.34.9",
207-
"@rollup/rollup-linux-arm64-gnu": "4.34.9",
208-
"@rollup/rollup-linux-arm64-musl": "4.34.9",
209205
"@rollup/rollup-darwin-arm64": "4.34.9",
210206
"@rollup/rollup-darwin-x64": "4.34.9",
211-
"@rollup/rollup-win32-x64-msvc": "4.34.9",
212-
"@rollup/rollup-win32-arm64-msvc": "4.34.9"
207+
"@rollup/rollup-linux-arm64-gnu": "4.34.9",
208+
"@rollup/rollup-linux-arm64-musl": "4.34.9",
209+
"@rollup/rollup-linux-x64-gnu": "4.34.9",
210+
"@rollup/rollup-linux-x64-musl": "4.34.9",
211+
"@rollup/rollup-win32-arm64-msvc": "4.34.9",
212+
"@rollup/rollup-win32-x64-msvc": "4.34.9"
213213
},
214214
"engines": {
215215
"node": ">=16.0.0",

scripts/utils/release-utils.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ export const isPrereleaseVersion = (version: string): boolean =>
5555
* @returns new version's string
5656
*/
5757
export function getNewVersion(oldVersion: string, input: any): string {
58-
if (!isValidVersionInput(input)) {
59-
throw new Error(`Version should be either ${SEMVER_INCREMENTS.join(', ')} or a valid semver version.`);
60-
}
58+
const isValidSemverName = SEMVER_INCREMENTS.indexOf(input) === -1;
59+
const incrementedSemverString = semver.inc(oldVersion, input);
6160

62-
return SEMVER_INCREMENTS.indexOf(input) === -1 ? input : semver.inc(oldVersion, input);
61+
if (isValidSemverName) return input;
62+
if (incrementedSemverString !== null) return incrementedSemverString;
63+
throw new Error(`Version should be either ${SEMVER_INCREMENTS.join(', ')} or a valid semver version.`);
6364
}
6465

6566
/**

src/compiler/docs/generate-doc-data.ts

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -216,24 +216,26 @@ const getRealProperties = (properties: d.ComponentCompilerProperty[]): d.JsonDoc
216216
* @returns the derived metadata
217217
*/
218218
const getVirtualProperties = (virtualProps: d.ComponentCompilerVirtualProperty[]): d.JsonDocsProp[] => {
219-
return virtualProps.map((member) => ({
220-
name: member.name,
221-
type: member.type,
222-
mutable: false,
223-
attr: member.name,
224-
reflectToAttr: false,
225-
docs: member.docs,
226-
docsTags: [],
227-
default: undefined,
228-
deprecation: undefined,
229-
values: parseTypeIntoValues(member.type),
230-
231-
optional: true,
232-
required: false,
233-
234-
getter: undefined,
235-
setter: undefined,
236-
}));
219+
return virtualProps.map(
220+
(member): d.JsonDocsProp => ({
221+
name: member.name,
222+
type: member.type,
223+
mutable: false,
224+
attr: member.name,
225+
reflectToAttr: false,
226+
docs: member.docs,
227+
docsTags: [],
228+
default: undefined,
229+
deprecation: undefined,
230+
values: parseTypeIntoValues(member.type),
231+
232+
optional: true,
233+
required: false,
234+
235+
getter: undefined,
236+
setter: undefined,
237+
}),
238+
);
237239
};
238240

239241
const parseTypeIntoValues = (type: string): d.JsonDocsValue[] => {

src/compiler/types/tests/generate-component-types.spec.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ComponentCompilerMeta } from '../../../declarations';
1+
import { ComponentCompilerMeta, ComponentCompilerMethod } from '../../../declarations';
22
import { generateComponentTypes } from '../generate-component-types';
33
import { stubComponentCompilerMeta } from './ComponentCompilerMeta.stub';
44
import { stubComponentCompilerMethod } from './ComponentCompilerMethod.stub';
@@ -212,16 +212,18 @@ describe('generateComponentTypes', () => {
212212
const cmpMeta: ComponentCompilerMeta = {
213213
...stubComponentCompilerMeta(),
214214
tagName: 'comprehensive-test',
215-
methods: htmlElementMethods.slice(0, 5).map((methodName) => ({
216-
...stubComponentCompilerMethod(),
217-
name: methodName,
218-
complexType: {
219-
signature: '() => Promise<void>',
220-
parameters: [],
221-
references: {},
222-
return: 'Promise<void>',
223-
},
224-
})),
215+
methods: htmlElementMethods.slice(0, 5).map(
216+
(methodName): ComponentCompilerMethod => ({
217+
...stubComponentCompilerMethod(),
218+
name: methodName,
219+
complexType: {
220+
signature: '() => Promise<void>',
221+
parameters: [],
222+
references: {},
223+
return: 'Promise<void>',
224+
},
225+
}),
226+
),
225227
};
226228

227229
const result = generateComponentTypes(cmpMeta, {}, false);

src/declarations/stencil-public-runtime.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,10 @@ export declare function forceUpdate(ref: any): void;
393393
*/
394394
export declare function getRenderingRef(): any;
395395

396-
export interface HTMLStencilElement extends HTMLElement {
396+
export interface HTMLStencilElement extends Omit<HTMLElement, 'autocorrect'> {
397397
componentOnReady(): Promise<this>;
398+
// TODO: remove this when [added to typescript](https://github.com/microsoft/typescript/issues/62083)
399+
autocorrect: 'on' | 'off';
398400
}
399401

400402
/**

src/mock-doc/document.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ export class MockDocument extends MockHTMLElement {
5353
throw new Error('Unimplemented');
5454
}
5555

56-
get location() {
56+
get location(): Location | null {
5757
if (this.defaultView != null) {
5858
return (this.defaultView as Window).location;
5959
}
6060
return null;
6161
}
62-
set location(val: Location) {
62+
set location(val: string) {
6363
if (this.defaultView != null) {
64-
(this.defaultView as Window).location = val;
64+
(this.defaultView as Window).location.href = val;
6565
}
6666
}
6767

src/mock-doc/parse-util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ function getParser(ownerDocument: MockDocument) {
167167
},
168168

169169
getAttrList(element: MockElement) {
170-
const attrs: Token.Attribute[] = element.attributes.__items.map((attr) => {
170+
const attrs: Token.Attribute[] = element.attributes.__items.map((attr): Token.Attribute => {
171171
return {
172172
name: attr.name,
173173
value: attr.value,

test/bundler/karma-stencil-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as path from 'path';
1+
const path = require('path');
22

33
// we must use a relative path here instead of tsconfig#paths
44
// see https://github.com/monounity/karma-typescript/issues/315

test/bundler/package-lock.json

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

0 commit comments

Comments
 (0)