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: Use tsconfig from build if exists (closes #23673) #23696

Merged
merged 1 commit into from
Sep 13, 2022
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
2 changes: 1 addition & 1 deletion npm/webpack-dev-server/src/helpers/angularHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export async function generateTsConfig (devServerConfig: AngularWebpackDevServer
includePaths.push(cypressTypes)

const tsConfigContent = JSON.stringify({
extends: getProjectFilePath('tsconfig.json'),
extends: getProjectFilePath(buildOptions.tsConfig ?? 'tsconfig.json'),
compilerOptions: {
outDir: getProjectFilePath('out-tsc/cy'),
allowSyntheticDefaultImports: true,
Expand Down
23 changes: 17 additions & 6 deletions npm/webpack-dev-server/test/handlers/angularHandler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ const expectGeneratesTsConfig = async (devServerConfig: AngularWebpackDevServerC
let tsConfig = JSON.parse(await fs.readFile(tsConfigPath, 'utf8'))

expect(tsConfig).to.deep.eq({
extends: toPosix(path.join(projectRoot, 'tsconfig.json')),
// verifies the default `tsconfig.app.json` is extended
extends: toPosix(path.join(projectRoot, 'tsconfig.app.json')),
compilerOptions: {
outDir: toPosix(path.join(projectRoot, 'out-tsc/cy')),
allowSyntheticDefaultImports: true,
Expand All @@ -211,6 +212,7 @@ const expectGeneratesTsConfig = async (devServerConfig: AngularWebpackDevServerC
const modifiedBuildOptions = cloneDeep(buildOptions)

delete modifiedBuildOptions.polyfills
modifiedBuildOptions.tsConfig = 'tsconfig.cy.json'

const modifiedDevServerConfig = cloneDeep(devServerConfig)
const supportFile = path.join(projectRoot, 'cypress', 'support', 'component.ts')
Expand All @@ -220,9 +222,18 @@ const expectGeneratesTsConfig = async (devServerConfig: AngularWebpackDevServerC
tsConfigPath = await generateTsConfig(modifiedDevServerConfig, modifiedBuildOptions)
tsConfig = JSON.parse(await fs.readFile(tsConfigPath, 'utf8'))

expect(tsConfig.include).to.deep.equal([
toPosix(path.join(projectRoot, 'src/**/*.cy.ts')),
toPosix(supportFile),
toPosix(path.join(projectRoot, 'node_modules/cypress/types/index.d.ts')),
])
expect(tsConfig).to.deep.eq({
// verifies the custom `tsconfig.cy.json` is extended
extends: toPosix(path.join(projectRoot, 'tsconfig.cy.json')),
compilerOptions: {
outDir: toPosix(path.join(projectRoot, 'out-tsc/cy')),
allowSyntheticDefaultImports: true,
skipLibCheck: true,
},
include: [
toPosix(path.join(projectRoot, 'src/**/*.cy.ts')),
toPosix(supportFile),
toPosix(path.join(projectRoot, 'node_modules/cypress/types/index.d.ts')),
],
})
}