Skip to content

Commit 5caa2c4

Browse files
Rationale: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-9.html#ts-ignore-or-ts-expect-error There were a few unnecessary @ts-ignore which this change pointed out (which is why the diff has more removals than insertions).
1 parent f360a9f commit 5caa2c4

File tree

22 files changed

+54
-57
lines changed

22 files changed

+54
-57
lines changed

packages/kit/src/core/adapt/test/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ suite('copy files', () => {
3030
/** @type {import('types/config').ValidatedConfig} */
3131
const config = {
3232
kit: {
33-
// @ts-ignore
33+
// @ts-expect-error
3434
files: {
3535
assets: join(__dirname, 'fixtures/basic/static')
3636
},
@@ -76,13 +76,13 @@ suite('prerender', async () => {
7676
const config = {
7777
extensions: ['.svelte'],
7878
kit: {
79-
// @ts-ignore
79+
// @ts-expect-error
8080
files: {
8181
assets: join(__dirname, 'fixtures/prerender/static'),
8282
routes: join(__dirname, 'fixtures/prerender/src/routes')
8383
},
8484
appDir: '_app',
85-
// @ts-ignore
85+
// @ts-expect-error
8686
prerender: {
8787
pages: ['*'],
8888
enabled: true

packages/kit/src/core/build/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,6 @@ async function build_server(
468468
// this API is marked as @alpha https://github.com./vitejs/vite/blob/27785f7fcc5b45987b5f0bf308137ddbdd9f79ea/packages/vite/src/node/config.ts#L129
469469
// it's not exposed in the typescript definitions as a result
470470
// so we need to ignore the fact that it's missing
471-
// @ts-ignore
472471
ssr: {
473472
// note to self: this _might_ need to be ['svelte', '@sveltejs/kit', ...get_no_external()]
474473
// but I'm honestly not sure. roll with this for now and see if it's ok

packages/kit/src/core/config/index.spec.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { deep_merge, validate_config } from './index.js';
55
test('fills in defaults', () => {
66
const validated = validate_config({});
77

8-
// @ts-ignore
8+
// @ts-expect-error
99
delete validated.kit.vite;
1010

1111
assert.equal(validated, {
@@ -66,7 +66,7 @@ test('errors on invalid values', () => {
6666
assert.throws(() => {
6767
validate_config({
6868
kit: {
69-
// @ts-ignore
69+
// @ts-expect-error
7070
target: 42
7171
}
7272
});
@@ -78,7 +78,7 @@ test('errors on invalid nested values', () => {
7878
validate_config({
7979
kit: {
8080
files: {
81-
// @ts-ignore
81+
// @ts-expect-error
8282
potato: 'blah'
8383
}
8484
}
@@ -105,7 +105,7 @@ test('fills in partial blanks', () => {
105105

106106
assert.equal(validated.kit.vite(), {});
107107

108-
// @ts-ignore
108+
// @ts-expect-error
109109
delete validated.kit.vite;
110110

111111
assert.equal(validated, {
@@ -248,7 +248,6 @@ function validate_paths(name, input, output) {
248248
assert.equal(
249249
validate_config({
250250
kit: {
251-
// @ts-ignore
252251
paths: input
253252
}
254253
}).kit.paths,

packages/kit/src/core/config/test/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async function testLoadDefaultConfig(path) {
1515

1616
const config = await load_config({ cwd });
1717

18-
// @ts-ignore
18+
// @ts-expect-error
1919
delete config.kit.vite; // can't test equality of a function
2020

2121
assert.equal(config, {

packages/kit/src/core/create_manifest_data/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,11 @@ export default function create_manifest_data({ config, output, cwd = process.cwd
247247
type: 'page',
248248
pattern,
249249
params,
250-
// @ts-ignore
250+
// @ts-expect-error
251251
path,
252-
// @ts-ignore
252+
// @ts-expect-error
253253
a,
254-
// @ts-ignore
254+
// @ts-expect-error
255255
b
256256
});
257257
} else {

packages/kit/src/core/create_manifest_data/index.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const create = (dir, extensions = ['.svelte']) => {
1616
config: {
1717
extensions,
1818
kit: {
19-
// @ts-ignore
19+
// @ts-expect-error
2020
files: {
2121
assets: path.resolve(cwd, 'static'),
2222
routes: path.resolve(cwd, dir)

packages/kit/src/core/server/cert.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// @ts-ignore
1+
// @ts-expect-error
22
import { generate } from 'selfsigned';
33

44
/**

packages/kit/src/runtime/app/navigation.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const prefetchRoutes = import.meta.env.SSR ? guard('prefetchRoutes') : pr
1919
* @type {import('$app/navigation').goto}
2020
*/
2121
async function goto_(href, opts) {
22-
// @ts-ignore
22+
// @ts-expect-error
2323
return router.goto(href, opts, []);
2424
}
2525

@@ -28,15 +28,15 @@ async function goto_(href, opts) {
2828
*/
2929
async function invalidate_(resource) {
3030
const { href } = new URL(resource, location.href);
31-
// @ts-ignore
31+
// @ts-expect-error
3232
return router.renderer.invalidate(href);
3333
}
3434

3535
/**
3636
* @type {import('$app/navigation').prefetch}
3737
*/
3838
function prefetch_(href) {
39-
// @ts-ignore
39+
// @ts-expect-error
4040
return router.prefetch(new URL(href, get_base_uri(document)));
4141
}
4242

@@ -45,14 +45,14 @@ function prefetch_(href) {
4545
*/
4646
async function prefetchRoutes_(pathnames) {
4747
const matching = pathnames
48-
? // @ts-ignore
48+
? // @ts-expect-error
4949
router.routes.filter((route) => pathnames.some((pathname) => route[0].test(pathname)))
50-
: // @ts-ignore
50+
: // @ts-expect-error
5151
router.routes;
5252

5353
const promises = matching
5454
.filter((r) => r && r.length > 1)
55-
// @ts-ignore
55+
// @ts-expect-error
5656
.map((r) => Promise.all(r[1].map((load) => load())));
5757

5858
await Promise.all(promises);

packages/kit/src/runtime/app/stores.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const getStores = () => {
2626
navigating: {
2727
subscribe: stores.navigating.subscribe
2828
},
29-
// @ts-ignore - deprecated, not part of type definitions, but still callable
29+
// @ts-expect-error - deprecated, not part of type definitions, but still callable
3030
get preloading() {
3131
console.error('stores.preloading is deprecated; use stores.navigating instead');
3232
return {

packages/kit/src/runtime/client/renderer.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ export class Renderer {
8282

8383
/** @type {import('./types').NavigationState} */
8484
this.current = {
85-
// @ts-ignore
85+
// @ts-expect-error
8686
page: null,
87-
// @ts-ignore
87+
// @ts-expect-error
8888
session_id: null,
8989
branch: []
9090
};
@@ -198,7 +198,7 @@ export class Renderer {
198198
dispatchEvent(new CustomEvent('sveltekit:navigation-start'));
199199

200200
if (this.started) {
201-
// @ts-ignore
201+
// @ts-expect-error
202202
this.stores.navigating.set({
203203
from: {
204204
path: this.current.page.path,
@@ -327,7 +327,7 @@ export class Renderer {
327327
*/
328328
async _get_navigation_result(info, no_cache) {
329329
if (this.loading.id === info.id) {
330-
// @ts-ignore if the id is defined then the promise is too
330+
// @ts-expect-error if the id is defined then the promise is too
331331
return this.loading.promise;
332332
}
333333

@@ -544,7 +544,7 @@ export class Renderer {
544544
}
545545

546546
const [pattern, a, b, get_params] = route;
547-
// @ts-ignore - the pattern is for the route which we've already matched to this path
547+
// @ts-expect-error - the pattern is for the route which we've already matched to this path
548548
const params = get_params ? get_params(pattern.exec(path)) : {};
549549

550550
const changed = this.current.page && {

packages/kit/src/runtime/client/router.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export class Router {
221221
throw new Error('Attempted to prefetch a URL that does not belong to this app');
222222
}
223223

224-
// @ts-ignore
224+
// @ts-expect-error
225225
return this.renderer.load(info);
226226
}
227227

@@ -255,13 +255,13 @@ export class Router {
255255
}
256256
}
257257

258-
// @ts-ignore6
258+
// @ts-expect-error
259259
this.renderer.notify({
260260
path: info.path,
261261
query: info.query
262262
});
263263

264-
// @ts-ignore
264+
// @ts-expect-error
265265
await this.renderer.update(info, chain, false);
266266

267267
if (!keepfocus) {

packages/kit/src/runtime/client/start.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// @ts-ignore
1+
// @ts-expect-error
22
import Root from 'ROOT'; // eslint-disable-line import/no-unresolved
3-
// @ts-ignore
3+
// @ts-expect-error
44
import { routes, fallback } from 'MANIFEST'; // eslint-disable-line import/no-unresolved
55
import { Router } from './router.js';
66
import { Renderer } from './renderer.js';

packages/kit/src/runtime/server/page/respond.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { coalesce_to_error } from '../utils.js';
1717
*/
1818
export async function respond({ request, options, state, $session, route }) {
1919
const match = route.pattern.exec(request.path);
20-
// @ts-ignore we already know there's a match
20+
// @ts-expect-error we already know there's a match
2121
const params = route.params(match);
2222

2323
const page = {

packages/kit/test/apps/basics/src/routes/caching/private/uses-fetch.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/** @type {import('@sveltejs/kit').Load} */
33
export async function load({ page, fetch }) {
44
const res = await fetch('/caching/private/uses-fetch.json', {
5-
// @ts-ignore
5+
// @ts-expect-error
66
credentials: page.query.get('credentials')
77
});
88

packages/kit/test/apps/basics/src/routes/errors/load-error-malformed-client.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/** @type {import('@sveltejs/kit').Load} */
33
export async function load() {
44
if (typeof window !== 'undefined') {
5-
// @ts-ignore
5+
// @ts-expect-error
66
return { status: 555, error: {} };
77
}
88
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script context="module">
22
/** @type {import('@sveltejs/kit').Load} */
33
export async function load() {
4-
// @ts-ignore
4+
// @ts-expect-error
55
return { status: 555, error: {} };
66
}
77
</script>

packages/kit/test/apps/basics/src/routes/load/fetch-request.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// this is contrived, but saves us faffing about with node-fetch here
99
const resource = browser ? new Request(url) : { url };
1010
11-
// @ts-ignore
11+
// @ts-expect-error
1212
const res = await fetch(resource);
1313
const { answer } = await res.json();
1414
@@ -23,4 +23,4 @@
2323
export let answer;
2424
</script>
2525

26-
<h1>the answer is {answer}</h1>
26+
<h1>the answer is {answer}</h1>

packages/kit/test/apps/basics/src/routes/load/server-fetch-request.svelte

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
export async function load({ page, fetch }) {
44
const url = `http://localhost:${page.query.get('port')}/server-fetch-request.json`;
55
6-
// @ts-ignore
76
const res = await fetch(url);
87
const { answer } = await res.json();
98
return {

packages/kit/test/apps/basics/src/routes/routing/shadow/action.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ let random = 0;
22

33
/** @type {import('@sveltejs/kit').RequestHandler} */
44
export function post({ body }) {
5-
// @ts-ignore (TODO make the types work somehow)
5+
// @ts-expect-error (TODO make the types work somehow)
66
random = body.get('random');
77
}
88

packages/kit/test/apps/basics/src/routes/xss/_tests.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default function (test) {
99
);
1010

1111
if (!js) {
12-
// @ts-ignore
12+
// @ts-expect-error
1313
assert.ok(!(await page.evaluate(() => window.pnwed)), 'pwned');
1414
}
1515
});

packages/kit/test/apps/basics/src/service-worker.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { timestamp, build } from '$service-worker';
33
const name = `cache-${timestamp}`;
44

55
self.addEventListener('install', (event) => {
6-
// @ts-ignore
6+
// @ts-expect-error
77
event.waitUntil(caches.open(name).then((cache) => cache.addAll(build)));
88
});
99

1010
self.addEventListener('activate', (event) => {
11-
// @ts-ignore
11+
// @ts-expect-error
1212
event.waitUntil(
1313
caches.keys().then(async (keys) => {
1414
for (const key of keys) {
@@ -19,7 +19,7 @@ self.addEventListener('activate', (event) => {
1919
});
2020

2121
self.addEventListener('fetch', (event) => {
22-
// @ts-ignore
22+
// @ts-expect-error
2323
const { request } = event;
2424

2525
if (request.method !== 'GET' || request.headers.has('range')) return;
@@ -29,7 +29,7 @@ self.addEventListener('fetch', (event) => {
2929

3030
if (url.origin === location.origin && build.includes(url.pathname)) {
3131
// always return build files from cache
32-
// @ts-ignore
32+
// @ts-expect-error
3333
event.respondWith(cached);
3434
} else if (url.protocol === 'https:' || location.hostname === 'localhost') {
3535
// hit the network for everything else...
@@ -47,7 +47,7 @@ self.addEventListener('fetch', (event) => {
4747
});
4848

4949
// ...but if it fails, fall back to cache if available
50-
// @ts-ignore
50+
// @ts-expect-error
5151
event.respondWith(promise.catch(() => cached || promise));
5252
}
5353
});

0 commit comments

Comments
 (0)