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

Remove unused target: es5 from tsconfig.json #44567

Merged
merged 3 commits into from
Jan 4, 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
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ function getDesiredCompilerOptions(
const o: DesiredCompilerOptionsShape = {
// These are suggested values and will be set when not present in the
// tsconfig.json
target: { suggested: 'es5' },
lib: { suggested: ['dom', 'dom.iterable', 'esnext'] },
allowJs: { suggested: true },
skipLibCheck: { suggested: true },
Expand Down
55 changes: 47 additions & 8 deletions test/integration/tsconfig-verifier/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ describe('tsconfig.json verifier', () => {
expect(await readFile(tsConfig, 'utf8')).toMatchInlineSnapshot(`
"{
\\"compilerOptions\\": {
\\"target\\": \\"es5\\",
\\"lib\\": [
\\"dom\\",
\\"dom.iterable\\",
Expand Down Expand Up @@ -75,7 +74,6 @@ describe('tsconfig.json verifier', () => {
expect(await readFile(tsConfig, 'utf8')).toMatchInlineSnapshot(`
"{
\\"compilerOptions\\": {
\\"target\\": \\"es5\\",
\\"lib\\": [
\\"dom\\",
\\"dom.iterable\\",
Expand Down Expand Up @@ -143,7 +141,6 @@ describe('tsconfig.json verifier', () => {
\\"module\\": \\"esnext\\" // should not be umd
// end-object comment
,
\\"target\\": \\"es5\\",
\\"lib\\": [
\\"dom\\",
\\"dom.iterable\\",
Expand Down Expand Up @@ -192,7 +189,6 @@ describe('tsconfig.json verifier', () => {
\\"compilerOptions\\": {
\\"esModuleInterop\\": true,
\\"module\\": \\"commonjs\\",
\\"target\\": \\"es5\\",
\\"lib\\": [
\\"dom\\",
\\"dom.iterable\\",
Expand Down Expand Up @@ -238,7 +234,6 @@ describe('tsconfig.json verifier', () => {
\\"compilerOptions\\": {
\\"esModuleInterop\\": true,
\\"module\\": \\"es2020\\",
\\"target\\": \\"es5\\",
\\"lib\\": [
\\"dom\\",
\\"dom.iterable\\",
Expand Down Expand Up @@ -288,7 +283,6 @@ describe('tsconfig.json verifier', () => {
\\"compilerOptions\\": {
\\"esModuleInterop\\": true,
\\"moduleResolution\\": \\"node16\\",
\\"target\\": \\"es5\\",
\\"lib\\": [
\\"dom\\",
\\"dom.iterable\\",
Expand Down Expand Up @@ -318,6 +312,53 @@ describe('tsconfig.json verifier', () => {
`)
})

it('allows you to set target mode', async () => {
expect(await exists(tsConfig)).toBe(false)

await writeFile(tsConfig, `{ "compilerOptions": { "target": "es2022" } }`)
await new Promise((resolve) => setTimeout(resolve, 500))
const { code, stderr, stdout } = await nextBuild(appDir, undefined, {
stderr: true,
stdout: true,
})
expect(stderr + stdout).not.toContain('target')
expect(code).toBe(0)

expect(await readFile(tsConfig, 'utf8')).toMatchInlineSnapshot(`
"{
\\"compilerOptions\\": {
\\"target\\": \\"es2022\\",
\\"lib\\": [
\\"dom\\",
\\"dom.iterable\\",
\\"esnext\\"
],
\\"allowJs\\": true,
\\"skipLibCheck\\": true,
\\"strict\\": false,
\\"forceConsistentCasingInFileNames\\": true,
\\"noEmit\\": true,
\\"incremental\\": true,
\\"esModuleInterop\\": true,
\\"module\\": \\"esnext\\",
\\"moduleResolution\\": \\"node\\",
\\"resolveJsonModule\\": true,
\\"isolatedModules\\": true,
\\"jsx\\": \\"preserve\\"
},
\\"include\\": [
\\"next-env.d.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 All @@ -327,7 +368,6 @@ describe('tsconfig.json verifier', () => {
`
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
Expand Down Expand Up @@ -383,7 +423,6 @@ describe('tsconfig.json verifier', () => {
`
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
Expand Down