Skip to content

Commit

Permalink
Merge branch 'canary' into zt/enable-verbatim-module-syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Oct 7, 2023
2 parents 1b0fccc + e75c366 commit f5f7ccc
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type DesiredCompilerOptionsShape = {

function getDesiredCompilerOptions(
ts: typeof import('typescript'),
userTsConfig?: { compilerOptions?: CompilerOptions }
tsOptions?: CompilerOptions
): DesiredCompilerOptionsShape {
const o: DesiredCompilerOptionsShape = {
// These are suggested values and will be set when not present in the
Expand Down Expand Up @@ -80,7 +80,7 @@ function getDesiredCompilerOptions(
reason: 'to match webpack resolution',
},
resolveJsonModule: { value: true, reason: 'to match webpack resolution' },
...(userTsConfig?.compilerOptions?.verbatimModuleSyntax === true
...(tsOptions?.verbatimModuleSyntax === true
? undefined
: {
isolatedModules: {
Expand Down Expand Up @@ -139,7 +139,7 @@ export async function writeConfigurationDefaults(
isFirstTimeSetup = true
}

const desiredCompilerOptions = getDesiredCompilerOptions(ts, userTsConfig)
const desiredCompilerOptions = getDesiredCompilerOptions(ts, tsOptions)

const suggestedActions: string[] = []
const requiredActions: string[] = []
Expand Down
57 changes: 57 additions & 0 deletions test/integration/tsconfig-verifier/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,63 @@ import path from 'path'
`)
})

it('allows you to set verbatimModuleSyntax true via extends without adding isolatedModules', async () => {
expect(await exists(tsConfig)).toBe(false)
expect(await exists(tsConfigBase)).toBe(false)

await writeFile(
tsConfigBase,
`{ "compilerOptions": { "verbatimModuleSyntax": true } }`
)
await writeFile(tsConfig, `{ "extends": "./tsconfig.base.json" }`)
await new Promise((resolve) => setTimeout(resolve, 500))
const { code, stderr, stdout } = await nextBuild(appDir, undefined, {
stderr: true,
stdout: true,
})
expect(stderr + stdout).not.toContain('isolatedModules')
expect(code).toBe(0)

expect(await readFile(tsConfig, 'utf8')).toMatchInlineSnapshot(`
"{
\\"extends\\": \\"./tsconfig.base.json\\",
\\"compilerOptions\\": {
\\"lib\\": [
\\"dom\\",
\\"dom.iterable\\",
\\"esnext\\"
],
\\"allowJs\\": true,
\\"skipLibCheck\\": true,
\\"strict\\": false,
\\"noEmit\\": true,
\\"incremental\\": true,
\\"esModuleInterop\\": true,
\\"module\\": \\"esnext\\",
\\"moduleResolution\\": \\"node\\",
\\"resolveJsonModule\\": true,
\\"jsx\\": \\"preserve\\",
\\"plugins\\": [
{
\\"name\\": \\"next\\"
}
],
\\"strictNullChecks\\": true
},
\\"include\\": [
\\"next-env.d.ts\\",
\\".next/types/**/*.ts\\",
\\"**/*.ts\\",
\\"**/*.tsx\\"
],
\\"exclude\\": [
\\"node_modules\\"
]
}
"
`)
})

it('allows you to extend another configuration file', async () => {
expect(await exists(tsConfig)).toBe(false)
expect(await exists(tsConfigBase)).toBe(false)
Expand Down

0 comments on commit f5f7ccc

Please sign in to comment.