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

feat: add "or undefined" explicitly to support exactOptionalPropertyTypes #129

Merged
merged 5 commits into from
Jul 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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: 1 addition & 2 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import type { Config } from '@jest/types'
const config: Config.InitialOptions = {
preset: 'ts-jest',
testEnvironment: 'node',
testPathIgnorePatterns: ['pages'],
coveragePathIgnorePatterns: ['pages', 'dist']
testPathIgnorePatterns: ['pages']
}

export default config
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"bin": "bin/index.js",
"scripts": {
"dev": "npm run build && ts-node projects/build.ts",
"build": "npm run rimraf && tsc",
"build": "npm run rimraf && tsc -p tsconfig.build.json",
"rimraf": "node -e \"require('fs').existsSync('dist') && require('fs').rmSync('dist', { recursive: true, force: true })\"",
"lint": "eslint --ext .ts . && prettier --check \"./**/*.ts\"",
"lint:fix": "eslint --ext .ts . --fix && prettier --write \"./**/*.ts\"",
Expand Down
24 changes: 12 additions & 12 deletions projects/nextjs-appdir/lib/$path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,53 +58,53 @@ export const pagesPath = {
$url: (url: { query: Query0, hash?: string }) => ({ pathname: '/' as const, query: url.query, hash: url.hash, path: `/${buildSuffix(url)}` }),
"children": {
"%E6%97%A5%E6%9C%AC%E8%AA%9E": {
$url: (url?: { hash?: string }) => ({ pathname: '/children/%E6%97%A5%E6%9C%AC%E8%AA%9E' as const, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/%E6%97%A5%E6%9C%AC%E8%AA%9E' as const, hash: url?.hash })
},
"_ignore": {
$url: (url?: { hash?: string }) => ({ pathname: '/children/.ignore' as const, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/.ignore' as const, hash: url?.hash })
},
_a: (a: string | number) => ({
"b": {
_c: (c: string[]) => ({
$url: (url?: { hash?: string }) => ({ pathname: '/children/[a]/b/[...c]' as const, query: { a, c }, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/[a]/b/[...c]' as const, query: { a, c }, hash: url?.hash })
})
}
}),
_pid: (pid: string | number) => ({
$url: (url?: { query?: OptionalQuery3, hash?: string }) => ({ pathname: '/children/[pid]' as const, query: { pid, ...url?.query }, hash: url?.hash })
$url: (url?: { query?: OptionalQuery3 | undefined, hash?: string | undefined } | undefined) => ({ pathname: '/children/[pid]' as const, query: { pid, ...url?.query }, hash: url?.hash })
}),
"aaa": {
_bbb: (bbb: string[]) => ({
"ccc": {
$url: (url?: { hash?: string }) => ({ pathname: '/children/aaa/[...bbb]/ccc' as const, query: { bbb }, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/aaa/[...bbb]/ccc' as const, query: { bbb }, hash: url?.hash })
}
}),
"api": {
"samples": {
$url: (url?: { hash?: string }) => ({ pathname: '/children/aaa/api/samples' as const, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/aaa/api/samples' as const, hash: url?.hash })
}
}
},
"api": {
"users": {
$url: (url?: { hash?: string }) => ({ pathname: '/children/api/users' as const, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/api/users' as const, hash: url?.hash })
}
},
"blog": {
_slug: (slug: string[]) => ({
$url: (url: { query: Query4, hash?: string }) => ({ pathname: '/children/blog/[...slug]' as const, query: { slug, ...url.query }, hash: url.hash })
$url: (url: { query: Query4, hash?: string | undefined }) => ({ pathname: '/children/blog/[...slug]' as const, query: { slug, ...url.query }, hash: url.hash })
}),
"hoge": {
_fuga: (fuga?: string[]) => ({
$url: (url?: { hash?: string }) => ({ pathname: '/children/blog/hoge/[[...fuga]]' as const, query: { fuga }, hash: url?.hash })
_fuga: (fuga?: string[] | undefined) => ({
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/blog/hoge/[[...fuga]]' as const, query: { fuga }, hash: url?.hash })
})
}
},
"x": {
_y: (y: string | number) => ({
$url: (url?: { hash?: string }) => ({ pathname: '/children/x/[y]' as const, query: { y }, hash: url?.hash }),
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/x/[y]' as const, query: { y }, hash: url?.hash }),
"z": {
$url: (url?: { hash?: string }) => ({ pathname: '/children/x/[y]/z' as const, query: { y }, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/x/[y]/z' as const, query: { y }, hash: url?.hash })
}
})
}
Expand Down
22 changes: 11 additions & 11 deletions projects/nextjs-appdir/out/lib/basic/$path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,50 +55,50 @@ export const pagesPath = {
$url: (url: { query: Query0, hash?: string }) => ({ pathname: '/' as const, query: url.query, hash: url.hash, path: `/${buildSuffix(url)}` }),
"children": {
"%E6%97%A5%E6%9C%AC%E8%AA%9E": {
$url: (url?: { hash?: string }) => ({ pathname: '/children/%E6%97%A5%E6%9C%AC%E8%AA%9E' as const, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/%E6%97%A5%E6%9C%AC%E8%AA%9E' as const, hash: url?.hash })
},
_a: (a: string | number) => ({
"b": {
_c: (c: string[]) => ({
$url: (url?: { hash?: string }) => ({ pathname: '/children/[a]/b/[...c]' as const, query: { a, c }, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/[a]/b/[...c]' as const, query: { a, c }, hash: url?.hash })
})
}
}),
_pid: (pid: string | number) => ({
$url: (url?: { query?: OptionalQuery3, hash?: string }) => ({ pathname: '/children/[pid]' as const, query: { pid, ...url?.query }, hash: url?.hash })
$url: (url?: { query?: OptionalQuery3 | undefined, hash?: string | undefined } | undefined) => ({ pathname: '/children/[pid]' as const, query: { pid, ...url?.query }, hash: url?.hash })
}),
"aaa": {
_bbb: (bbb: string[]) => ({
"ccc": {
$url: (url?: { hash?: string }) => ({ pathname: '/children/aaa/[...bbb]/ccc' as const, query: { bbb }, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/aaa/[...bbb]/ccc' as const, query: { bbb }, hash: url?.hash })
}
}),
"api": {
"samples": {
$url: (url?: { hash?: string }) => ({ pathname: '/children/aaa/api/samples' as const, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/aaa/api/samples' as const, hash: url?.hash })
}
}
},
"api": {
"users": {
$url: (url?: { hash?: string }) => ({ pathname: '/children/api/users' as const, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/api/users' as const, hash: url?.hash })
}
},
"blog": {
_slug: (slug: string[]) => ({
$url: (url: { query: Query4, hash?: string }) => ({ pathname: '/children/blog/[...slug]' as const, query: { slug, ...url.query }, hash: url.hash })
$url: (url: { query: Query4, hash?: string | undefined }) => ({ pathname: '/children/blog/[...slug]' as const, query: { slug, ...url.query }, hash: url.hash })
}),
"hoge": {
_fuga: (fuga?: string[]) => ({
$url: (url?: { hash?: string }) => ({ pathname: '/children/blog/hoge/[[...fuga]]' as const, query: { fuga }, hash: url?.hash })
_fuga: (fuga?: string[] | undefined) => ({
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/blog/hoge/[[...fuga]]' as const, query: { fuga }, hash: url?.hash })
})
}
},
"x": {
_y: (y: string | number) => ({
$url: (url?: { hash?: string }) => ({ pathname: '/children/x/[y]' as const, query: { y }, hash: url?.hash }),
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/x/[y]' as const, query: { y }, hash: url?.hash }),
"z": {
$url: (url?: { hash?: string }) => ({ pathname: '/children/x/[y]/z' as const, query: { y }, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/x/[y]/z' as const, query: { y }, hash: url?.hash })
}
})
}
Expand Down
22 changes: 11 additions & 11 deletions projects/nextjs-appdir/out/lib/ignore/$path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,50 +55,50 @@ export const pagesPath = {
$url: (url: { query: Query0, hash?: string }) => ({ pathname: '/' as const, query: url.query, hash: url.hash, path: `/${buildSuffix(url)}` }),
"children": {
"%E6%97%A5%E6%9C%AC%E8%AA%9E": {
$url: (url?: { hash?: string }) => ({ pathname: '/children/%E6%97%A5%E6%9C%AC%E8%AA%9E' as const, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/%E6%97%A5%E6%9C%AC%E8%AA%9E' as const, hash: url?.hash })
},
_a: (a: string | number) => ({
"b": {
_c: (c: string[]) => ({
$url: (url?: { hash?: string }) => ({ pathname: '/children/[a]/b/[...c]' as const, query: { a, c }, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/[a]/b/[...c]' as const, query: { a, c }, hash: url?.hash })
})
}
}),
_pid: (pid: string | number) => ({
$url: (url?: { query?: OptionalQuery3, hash?: string }) => ({ pathname: '/children/[pid]' as const, query: { pid, ...url?.query }, hash: url?.hash })
$url: (url?: { query?: OptionalQuery3 | undefined, hash?: string | undefined } | undefined) => ({ pathname: '/children/[pid]' as const, query: { pid, ...url?.query }, hash: url?.hash })
}),
"aaa": {
_bbb: (bbb: string[]) => ({
"ccc": {
$url: (url?: { hash?: string }) => ({ pathname: '/children/aaa/[...bbb]/ccc' as const, query: { bbb }, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/aaa/[...bbb]/ccc' as const, query: { bbb }, hash: url?.hash })
}
}),
"api": {
"samples": {
$url: (url?: { hash?: string }) => ({ pathname: '/children/aaa/api/samples' as const, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/aaa/api/samples' as const, hash: url?.hash })
}
}
},
"api": {
"users": {
$url: (url?: { hash?: string }) => ({ pathname: '/children/api/users' as const, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/api/users' as const, hash: url?.hash })
}
},
"blog": {
_slug: (slug: string[]) => ({
$url: (url: { query: Query4, hash?: string }) => ({ pathname: '/children/blog/[...slug]' as const, query: { slug, ...url.query }, hash: url.hash })
$url: (url: { query: Query4, hash?: string | undefined }) => ({ pathname: '/children/blog/[...slug]' as const, query: { slug, ...url.query }, hash: url.hash })
}),
"hoge": {
_fuga: (fuga?: string[]) => ({
$url: (url?: { hash?: string }) => ({ pathname: '/children/blog/hoge/[[...fuga]]' as const, query: { fuga }, hash: url?.hash })
_fuga: (fuga?: string[] | undefined) => ({
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/blog/hoge/[[...fuga]]' as const, query: { fuga }, hash: url?.hash })
})
}
},
"x": {
_y: (y: string | number) => ({
$url: (url?: { hash?: string }) => ({ pathname: '/children/x/[y]' as const, query: { y }, hash: url?.hash }),
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/x/[y]' as const, query: { y }, hash: url?.hash }),
"z": {
$url: (url?: { hash?: string }) => ({ pathname: '/children/x/[y]/z' as const, query: { y }, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/x/[y]/z' as const, query: { y }, hash: url?.hash })
}
})
}
Expand Down
24 changes: 12 additions & 12 deletions projects/nextjs-appdir/out/lib/static/$path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,53 +58,53 @@ export const pagesPath = {
$url: (url: { query: Query0, hash?: string }) => ({ pathname: '/' as const, query: url.query, hash: url.hash, path: `/${buildSuffix(url)}` }),
"children": {
"%E6%97%A5%E6%9C%AC%E8%AA%9E": {
$url: (url?: { hash?: string }) => ({ pathname: '/children/%E6%97%A5%E6%9C%AC%E8%AA%9E' as const, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/%E6%97%A5%E6%9C%AC%E8%AA%9E' as const, hash: url?.hash })
},
"_ignore": {
$url: (url?: { hash?: string }) => ({ pathname: '/children/.ignore' as const, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/.ignore' as const, hash: url?.hash })
},
_a: (a: string | number) => ({
"b": {
_c: (c: string[]) => ({
$url: (url?: { hash?: string }) => ({ pathname: '/children/[a]/b/[...c]' as const, query: { a, c }, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/[a]/b/[...c]' as const, query: { a, c }, hash: url?.hash })
})
}
}),
_pid: (pid: string | number) => ({
$url: (url?: { query?: OptionalQuery3, hash?: string }) => ({ pathname: '/children/[pid]' as const, query: { pid, ...url?.query }, hash: url?.hash })
$url: (url?: { query?: OptionalQuery3 | undefined, hash?: string | undefined } | undefined) => ({ pathname: '/children/[pid]' as const, query: { pid, ...url?.query }, hash: url?.hash })
}),
"aaa": {
_bbb: (bbb: string[]) => ({
"ccc": {
$url: (url?: { hash?: string }) => ({ pathname: '/children/aaa/[...bbb]/ccc' as const, query: { bbb }, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/aaa/[...bbb]/ccc' as const, query: { bbb }, hash: url?.hash })
}
}),
"api": {
"samples": {
$url: (url?: { hash?: string }) => ({ pathname: '/children/aaa/api/samples' as const, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/aaa/api/samples' as const, hash: url?.hash })
}
}
},
"api": {
"users": {
$url: (url?: { hash?: string }) => ({ pathname: '/children/api/users' as const, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/api/users' as const, hash: url?.hash })
}
},
"blog": {
_slug: (slug: string[]) => ({
$url: (url: { query: Query4, hash?: string }) => ({ pathname: '/children/blog/[...slug]' as const, query: { slug, ...url.query }, hash: url.hash })
$url: (url: { query: Query4, hash?: string | undefined }) => ({ pathname: '/children/blog/[...slug]' as const, query: { slug, ...url.query }, hash: url.hash })
}),
"hoge": {
_fuga: (fuga?: string[]) => ({
$url: (url?: { hash?: string }) => ({ pathname: '/children/blog/hoge/[[...fuga]]' as const, query: { fuga }, hash: url?.hash })
_fuga: (fuga?: string[] | undefined) => ({
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/blog/hoge/[[...fuga]]' as const, query: { fuga }, hash: url?.hash })
})
}
},
"x": {
_y: (y: string | number) => ({
$url: (url?: { hash?: string }) => ({ pathname: '/children/x/[y]' as const, query: { y }, hash: url?.hash }),
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/x/[y]' as const, query: { y }, hash: url?.hash }),
"z": {
$url: (url?: { hash?: string }) => ({ pathname: '/children/x/[y]/z' as const, query: { y }, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/children/x/[y]/z' as const, query: { y }, hash: url?.hash })
}
})
}
Expand Down
16 changes: 8 additions & 8 deletions projects/nextjs-basepath/out/lib/basic/$path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,36 @@ export const pagesPath = {
_a: (a: string | number) => ({
"b": {
_c: (c: string[]) => ({
$url: (url?: { hash?: string }) => ({ pathname: '/[a]/b/[...c]' as const, query: { a, c }, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/[a]/b/[...c]' as const, query: { a, c }, hash: url?.hash })
})
}
}),
_pid: (pid: string | number) => ({
$url: (url?: { query?: OptionalQuery1, hash?: string }) => ({ pathname: '/[pid]' as const, query: { pid, ...url?.query }, hash: url?.hash })
$url: (url?: { query?: OptionalQuery1 | undefined, hash?: string | undefined } | undefined) => ({ pathname: '/[pid]' as const, query: { pid, ...url?.query }, hash: url?.hash })
}),
"aaa": {
_bbb: (bbb: string[]) => ({
"ccc": {
$url: (url?: { hash?: string }) => ({ pathname: '/aaa/[...bbb]/ccc' as const, query: { bbb }, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/aaa/[...bbb]/ccc' as const, query: { bbb }, hash: url?.hash })
}
}),
"api": {
"samples": {
$url: (url?: { hash?: string }) => ({ pathname: '/aaa/api/samples' as const, hash: url?.hash })
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/aaa/api/samples' as const, hash: url?.hash })
}
}
},
"blog": {
_slug: (slug: string[]) => ({
$url: (url: { query: Query2, hash?: string }) => ({ pathname: '/blog/[...slug]' as const, query: { slug, ...url.query }, hash: url.hash })
$url: (url: { query: Query2, hash?: string | undefined }) => ({ pathname: '/blog/[...slug]' as const, query: { slug, ...url.query }, hash: url.hash })
}),
"hoge": {
_fuga: (fuga?: string[]) => ({
$url: (url?: { hash?: string }) => ({ pathname: '/blog/hoge/[[...fuga]]' as const, query: { fuga }, hash: url?.hash })
_fuga: (fuga?: string[] | undefined) => ({
$url: (url?: { hash?: string | undefined } | undefined) => ({ pathname: '/blog/hoge/[[...fuga]]' as const, query: { fuga }, hash: url?.hash })
})
}
},
$url: (url: { query: Query0, hash?: string }) => ({ pathname: '/' as const, query: url.query, hash: url.hash })
$url: (url: { query: Query0, hash?: string | undefined }) => ({ pathname: '/' as const, query: url.query, hash: url.hash })
}

export type PagesPath = typeof pagesPath
Loading
Loading