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

fix(internal): Remove unused import #9946

Merged
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`generates global page imports source maps 1`] = `
{
"file": "web-routesPages.d.ts",
"mappings": ";;;;;;;;;;;;AAAA;ACQA;ACRA;ACKA;ACLA;ACAA;ACAA;ACAA",
"names": [],
"sources": [
"../../../web/src/pages/BarPage/BarPage.tsx",
"../../../web/src/pages/FatalErrorPage/FatalErrorPage.js",
"../../../web/src/pages/FooPage/FooPage.tsx",
"../../../web/src/pages/HomePage/HomePage.tsx",
"../../../web/src/pages/NotFoundPage/NotFoundPage.js",
"../../../web/src/pages/PrivatePage/PrivatePage.tsx",
"../../../web/src/pages/TypeScriptPage/TypeScriptPage.tsx",
"../../../web/src/pages/admin/EditUserPage/EditUserPage.jsx",
],
"version": 3,
}
`;

exports[`generates source maps for the router routes 1`] = `
{
"file": "web-routerRoutes.d.ts",
"mappings": ";;;;;;IAiBM;IACA;IACA;IAEE;IACA;IAGA",
"names": [],
"sources": [
"../../../web/src/Routes.js",
],
"version": 3,
}
`;

exports[`mirror path for directory named modules 1`] = `".redwood/types/mirror/web/src/graphql"`;

exports[`mirror path for directory named modules 2`] = `"../../packages/internal/index.d.ts"`;
16 changes: 16 additions & 0 deletions packages/internal/src/__tests__/typeDefinitions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ declare global {
}`)
})

test('generates global page imports source maps', () => {
const paths = generateTypeDefRouterPages()
const sourceMap = JSON.parse(fs.readFileSync(paths[0] + '.map', 'utf-8'))
sourceMap.sources = sourceMap.sources.map((source) => ensurePosixPath(source))
expect(sourceMap).toMatchSnapshot()
})

test('generate current user ', () => {
const paths = generateTypeDefCurrentUser()
const p = paths.map(cleanPaths)
Expand All @@ -157,6 +164,15 @@ test('generates the router routes', () => {
`)
})

test('generates source maps for the router routes', () => {
const paths = generateTypeDefRouterRoutes()
const sourceMap = JSON.parse(fs.readFileSync(paths[0] + '.map', 'utf-8'))
sourceMap.sources = sourceMap.sources.map((source: string) =>
ensurePosixPath(source)
)
expect(sourceMap).toMatchSnapshot()
})

test('generate glob imports', () => {
const paths = generateTypeDefGlobImports()
const p = paths.map(cleanPaths)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { RouteParams, QueryParams } from '@redwoodjs/router'
import { A } from 'ts-toolbelt'


declare module '@redwoodjs/router' {
interface AvailableRoutes {
Expand Down
6 changes: 4 additions & 2 deletions packages/internal/src/generate/typeDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,10 @@ export const generateTypeDefRouterRoutes = () => {
file: 'web-routerRoutes.d.ts',
})

// Start line is based on where in the template the ` ${name}: (params?: RouteParams<"${path}"> & QueryParams) => "${path}"` are defined
const startLine = 9
// Start line is based on where in the template the
// ` ${name}: (params?: RouteParams<"${path}"> & QueryParams) => "${path}"`
// line is defined
const startLine = 7

// Map the location of the default export for each page
for (let i = 0; i < routes.length; i++) {
Expand Down
Loading