Skip to content

Commit 1e2cfa4

Browse files
chore: upgrade to TypeScript 5 (#8488)
- upgrade to TypeScript 5 - upgrade @ampproject/remapping - remove obsolete workarounds --------- Co-authored-by: Simon Holthausen <[email protected]>
1 parent abd760d commit 1e2cfa4

File tree

11 files changed

+113
-85
lines changed

11 files changed

+113
-85
lines changed

generate-type-definitions.js

-23
This file was deleted.

package-lock.json

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

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"dev": "rollup -cw",
100100
"posttest": "agadoo internal/index.mjs",
101101
"prepublishOnly": "node check_publish_env.js && npm run lint && npm run build && npm test",
102-
"tsd": "node ./generate-type-definitions.js",
102+
"tsd": "tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emitDeclarationOnly",
103103
"lint": "eslint \"{src,test}/**/*.{ts,js}\" --cache"
104104
},
105105
"repository": {
@@ -119,7 +119,7 @@
119119
},
120120
"homepage": "https://svelte.dev",
121121
"devDependencies": {
122-
"@ampproject/remapping": "^0.3.0",
122+
"@ampproject/remapping": "^2.2.1",
123123
"@jridgewell/sourcemap-codec": "^1.4.15",
124124
"@rollup/plugin-commonjs": "^11.0.0",
125125
"@rollup/plugin-json": "^6.0.0",
@@ -157,7 +157,7 @@
157157
"source-map-support": "^0.5.21",
158158
"tiny-glob": "^0.2.9",
159159
"tslib": "^2.5.0",
160-
"typescript": "^3.7.5",
160+
"typescript": "^5.0.4",
161161
"util": "^0.12.5"
162162
}
163163
}

src/compiler/compile/Component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { DecodedSourceMap, RawSourceMap } from '@ampproject/remapping';
12
import { walk } from 'estree-walker';
23
import { getLocator } from 'locate-character';
34
import Stats from '../Stats';
@@ -32,7 +33,6 @@ import { print, b } from 'code-red';
3233
import { is_reserved_keyword } from './utils/reserved_keywords';
3334
import { apply_preprocessor_sourcemap } from '../utils/mapped_code';
3435
import Element from './nodes/Element';
35-
import { DecodedSourceMap, RawSourceMap } from '@ampproject/remapping/dist/types/types';
3636
import { clone } from '../utils/clone';
3737
import compiler_warnings from './compiler_warnings';
3838
import compiler_errors from './compiler_errors';

src/compiler/compile/render_dom/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { RawSourceMap, DecodedSourceMap } from '@ampproject/remapping';
12
import { b, x, p } from 'code-red';
23
import Component from '../Component';
34
import Renderer from './Renderer';
@@ -8,7 +9,6 @@ import { invalidate } from './invalidate';
89
import Block from './Block';
910
import { ImportDeclaration, ClassDeclaration, FunctionExpression, Node, Statement, ObjectExpression, Expression } from 'estree';
1011
import { apply_preprocessor_sourcemap } from '../../utils/mapped_code';
11-
import { RawSourceMap, DecodedSourceMap } from '@ampproject/remapping/dist/types/types';
1212
import { flatten } from '../../utils/flatten';
1313
import check_enable_sourcemap from '../utils/check_enable_sourcemap';
1414
import { push_array } from '../../utils/push_array';

src/compiler/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ export { default as compile } from './compile/index';
22
export { default as parse } from './parse/index';
33
export { default as preprocess } from './preprocess/index';
44
export { walk } from 'estree-walker';
5+
export type { CompileOptions, ModuleFormat, EnableSourcemap, CssHashGetter } from './interfaces';
56

67
export const VERSION = '__VERSION__';
7-
// additional exports added through generate-type-definitions.js

src/compiler/preprocess/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RawSourceMap, DecodedSourceMap } from '@ampproject/remapping/dist/types/types';
1+
import type { RawSourceMap, DecodedSourceMap } from '@ampproject/remapping';
22
import { getLocator } from 'locate-character';
33
import { MappedCode, SourceLocation, parse_attached_sourcemap, sourcemap_add_offset, combine_sourcemaps } from '../utils/mapped_code';
44
import { decode_map } from './decode_sourcemap';
@@ -57,7 +57,7 @@ class PreprocessResult implements Source {
5757

5858
to_processed(): Processed {
5959
// Combine all the source maps for each preprocessor function into one
60-
const map: RawSourceMap = combine_sourcemaps(this.file_basename, this.sourcemap_list);
60+
const map = combine_sourcemaps(this.file_basename, this.sourcemap_list);
6161

6262
return {
6363
// TODO return separated output, in future version where svelte.compile supports it:

src/compiler/utils/mapped_code.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DecodedSourceMap, RawSourceMap, SourceMapLoader } from '@ampproject/remapping/dist/types/types';
1+
import type { DecodedSourceMap, RawSourceMap, SourceMapLoader } from '@ampproject/remapping';
22
import remapping from '@ampproject/remapping';
33
import { SourceMap } from 'magic-string';
44
import { Source, Processed } from '../preprocess/types';
@@ -216,11 +216,11 @@ export class MappedCode {
216216
export function combine_sourcemaps(
217217
filename: string,
218218
sourcemap_list: Array<DecodedSourceMap | RawSourceMap>
219-
): RawSourceMap {
219+
) {
220220
if (sourcemap_list.length == 0) return null;
221221

222222
let map_idx = 1;
223-
const map: RawSourceMap =
223+
const map =
224224
sourcemap_list.slice(0, -1)
225225
.find(m => m.sources.length !== 1) === undefined
226226

src/runtime/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ export {
1313
createEventDispatcher,
1414
SvelteComponentDev as SvelteComponent,
1515
SvelteComponentTyped
16-
// additional exports added through generate-type-definitions.js
1716
} from 'svelte/internal';
17+
export type { ComponentType, ComponentConstructorOptions, ComponentProps, ComponentEvents } from 'svelte/internal';

src/runtime/motion/tweened.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export function tweened<T>(value?: T, defaults: Options<T> = {}): Tweened<T> {
122122

123123
const elapsed = now - start;
124124

125-
if (elapsed > duration) {
125+
if (elapsed > <number> duration) {
126126
store.set(value = new_value);
127127
return false;
128128
}

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
// target node v8+ (https://node.green/)
88
// the only missing feature is Array.prototype.values
9-
"lib": ["es2017"],
9+
"lib": ["es2017", "DOM"],
1010
"target": "es2017",
1111

1212
"declaration": true,

0 commit comments

Comments
 (0)