From a8bd927ee19d105984db5f1608c296b7554e3c86 Mon Sep 17 00:00:00 2001 From: Gustavo Perdomo Date: Thu, 22 Jun 2023 17:38:54 -0400 Subject: [PATCH] feat(nest): added es2021 support for nest generators (#17726) Co-authored-by: Caleb Ukle --- docs/generated/packages/nest/generators/library.json | 7 ++++--- .../nest/src/generators/application/application.spec.ts | 2 +- .../nest/src/generators/application/lib/update-tsconfig.ts | 2 +- packages/nest/src/generators/library/library.spec.ts | 6 +++--- packages/nest/src/generators/library/schema.d.ts | 3 ++- packages/nest/src/generators/library/schema.json | 7 ++++--- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/docs/generated/packages/nest/generators/library.json b/docs/generated/packages/nest/generators/library.json index 25d83cb3e92bdf..d2132961017dc5 100644 --- a/docs/generated/packages/nest/generators/library.json +++ b/docs/generated/packages/nest/generators/library.json @@ -92,9 +92,9 @@ "default": "node" }, "target": { - "description": "The ES target, Nest suggest using es6 or higher.", + "description": "The ES target, Nest suggest using es2021 or higher.", "type": "string", - "default": "es6", + "default": "es2021", "enum": [ "es5", "es6", @@ -104,7 +104,8 @@ "es2017", "es2018", "es2019", - "es2020" + "es2020", + "es2021" ] }, "strict": { diff --git a/packages/nest/src/generators/application/application.spec.ts b/packages/nest/src/generators/application/application.spec.ts index c3a722bcb7e9f3..de5103edabc826 100644 --- a/packages/nest/src/generators/application/application.spec.ts +++ b/packages/nest/src/generators/application/application.spec.ts @@ -51,7 +51,7 @@ describe('application generator', () => { `apps/${appDirectory}/tsconfig.app.json` ); expect(tsConfig.compilerOptions.emitDecoratorMetadata).toBe(true); - expect(tsConfig.compilerOptions.target).toBe('es2015'); + expect(tsConfig.compilerOptions.target).toBe('es2021'); expect(tsConfig.exclude).toEqual([ 'jest.config.ts', 'src/**/*.spec.ts', diff --git a/packages/nest/src/generators/application/lib/update-tsconfig.ts b/packages/nest/src/generators/application/lib/update-tsconfig.ts index 232f605f6b0486..0e93a25a8d77e9 100644 --- a/packages/nest/src/generators/application/lib/update-tsconfig.ts +++ b/packages/nest/src/generators/application/lib/update-tsconfig.ts @@ -8,7 +8,7 @@ export function updateTsConfig(tree: Tree, options: NormalizedOptions): void { joinPathFragments(options.appProjectRoot, 'tsconfig.app.json'), (json) => { json.compilerOptions.emitDecoratorMetadata = true; - json.compilerOptions.target = 'es2015'; + json.compilerOptions.target = 'es2021'; if (options.strict) { json.compilerOptions = { ...json.compilerOptions, diff --git a/packages/nest/src/generators/library/library.spec.ts b/packages/nest/src/generators/library/library.spec.ts index 08ca082f548c3a..08d9bd8d65f8a9 100644 --- a/packages/nest/src/generators/library/library.spec.ts +++ b/packages/nest/src/generators/library/library.spec.ts @@ -302,14 +302,14 @@ describe('lib', () => { expect(tsconfigJson.compilerOptions.target).toEqual('es6'); }); - it('should set target to es2020 in tsconfig.lib.json', async () => { - await libraryGenerator(tree, { name: libName, target: 'es2020' }); + it('should set target to es2021 in tsconfig.lib.json', async () => { + await libraryGenerator(tree, { name: libName, target: 'es2021' }); const tsconfigJson = readJson( tree, `libs/${libFileName}/tsconfig.lib.json` ); - expect(tsconfigJson.compilerOptions.target).toEqual('es2020'); + expect(tsconfigJson.compilerOptions.target).toEqual('es2021'); }); }); diff --git a/packages/nest/src/generators/library/schema.d.ts b/packages/nest/src/generators/library/schema.d.ts index 82c4d1609665ad..85e076df98b261 100644 --- a/packages/nest/src/generators/library/schema.d.ts +++ b/packages/nest/src/generators/library/schema.d.ts @@ -24,7 +24,8 @@ export interface LibraryGeneratorOptions { | 'es2017' | 'es2018' | 'es2019' - | 'es2020'; + | 'es2020' + | 'es2021'; testEnvironment?: 'jsdom' | 'node'; unitTestRunner?: UnitTestRunner; standaloneConfig?: boolean; diff --git a/packages/nest/src/generators/library/schema.json b/packages/nest/src/generators/library/schema.json index 33842e91879ff8..70b465046cf6e8 100644 --- a/packages/nest/src/generators/library/schema.json +++ b/packages/nest/src/generators/library/schema.json @@ -92,9 +92,9 @@ "default": "node" }, "target": { - "description": "The ES target, Nest suggest using es6 or higher.", + "description": "The ES target, Nest suggest using es2021 or higher.", "type": "string", - "default": "es6", + "default": "es2021", "enum": [ "es5", "es6", @@ -104,7 +104,8 @@ "es2017", "es2018", "es2019", - "es2020" + "es2020", + "es2021" ] }, "strict": {