Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable noPropertyAccessFromIndexSignature and noUncheckedIndexedAccess #216

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"scripts": {
"lint": "eslint . --ext .ts,.js",
"test": "jest",
"build": "node tools/build.js"
"build": "node tools/build.js",
"tsc": "tsc --noEmit"
}
}
2 changes: 1 addition & 1 deletion src/UniversalRouter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ test('respects baseUrl', async () => {
expect(action.mock.calls[0][0]).toHaveProperty('pathname', '/base/a/b/c')
expect(action.mock.calls[0][0]).toHaveProperty('path', '/c')
expect(action.mock.calls[0][0]).toHaveProperty('baseUrl', '/base/a/b')
expect(action.mock.calls[0][0]).toHaveProperty('route', routes.children[0].children[0])
expect(action.mock.calls[0][0]).toHaveProperty('route', routes.children[0]?.children[0])
expect(action.mock.calls[0][0]).toHaveProperty('router', router)

let err
Expand Down
4 changes: 2 additions & 2 deletions src/UniversalRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
if (matchResult && route.children) {
while (childIndex < route.children.length) {
if (!childMatches) {
const childRoute = route.children[childIndex]
const childRoute = route.children[childIndex]!

Check warning on line 193 in src/UniversalRouter.ts

View workflow job for this annotation

GitHub Actions / build (14.x)

Forbidden non-null assertion
childRoute.parent = route

childMatches = matchRoute<R, C>(
Expand Down Expand Up @@ -320,7 +320,7 @@
})
}

context.next = next
context['next'] = next

Check failure on line 323 in src/UniversalRouter.ts

View workflow job for this annotation

GitHub Actions / build (14.x)

["next"] is better written in dot notation

return Promise.resolve()
.then(() => next(true, this.root))
Expand Down
2 changes: 1 addition & 1 deletion src/UniversalRouterSync.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ test('respects baseUrl', () => {
expect(action.mock.calls[0][0]).toHaveProperty('pathname', '/base/a/b/c')
expect(action.mock.calls[0][0]).toHaveProperty('path', '/c')
expect(action.mock.calls[0][0]).toHaveProperty('baseUrl', '/base/a/b')
expect(action.mock.calls[0][0]).toHaveProperty('route', routes.children[0].children[0])
expect(action.mock.calls[0][0]).toHaveProperty('route', routes.children[0]?.children[0])
expect(action.mock.calls[0][0]).toHaveProperty('router', router)

let err
Expand Down
4 changes: 2 additions & 2 deletions src/UniversalRouterSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
if (matchResult && route.children) {
while (childIndex < route.children.length) {
if (!childMatches) {
const childRoute = route.children[childIndex]
const childRoute = route.children[childIndex]!

Check warning on line 194 in src/UniversalRouterSync.ts

View workflow job for this annotation

GitHub Actions / build (14.x)

Forbidden non-null assertion
childRoute.parent = route

childMatches = matchRoute<R, C>(
Expand Down Expand Up @@ -318,7 +318,7 @@
return next(resume, parent, result)
}

context.next = next
context['next'] = next

Check failure on line 321 in src/UniversalRouterSync.ts

View workflow job for this annotation

GitHub Actions / build (14.x)

["next"] is better written in dot notation

try {
return next(true, this.root)
Expand Down
8 changes: 4 additions & 4 deletions src/generateUrls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

if (routes) {
for (let i = 0; i < routes.length; i++) {
const childRoute = routes[i]
const childRoute = routes[i]!

Check warning on line 60 in src/generateUrls.ts

View workflow job for this annotation

GitHub Actions / build (14.x)

Forbidden non-null assertion
const childName = childRoute.name
childRoute.parent = route
cacheRoutes(
Expand Down Expand Up @@ -117,7 +117,7 @@
const keys: Keys = Object.create(null)
for (let i = 0; i < tokens.length; i++) {
const token = tokens[i]
if (typeof token !== 'string') {
if (token && typeof token !== 'string') {
keys[token.name] = true
}
}
Expand All @@ -132,8 +132,8 @@
const keys = Object.keys(params)
for (let i = 0; i < keys.length; i++) {
const key = keys[i]
if (!regexp.keys[key]) {
queryParams[key] = params[key]
if (key && !regexp.keys[key]) {
queryParams[key] = params[key] ?? ''
}
}
const query = opts.stringifyQueryParams(queryParams)
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"strict": true,
"declaration": true,
"noEmitOnError": true,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"sourceMap": true,
Expand Down
Loading