Skip to content

Commit

Permalink
fix(node): set tsconfig target to es2015 for nest apps
Browse files Browse the repository at this point in the history
ISSUES CLOSED: #1283
  • Loading branch information
Cammisuli authored and vsavkin committed Feb 25, 2020
1 parent f2c47cf commit cbd5d4c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions e2e/node.test.ts
Expand Up @@ -160,6 +160,7 @@ forEachCli(currentCLIName => {
); // respects "extends" inside tsconfigs

expect(config.options.emitDecoratorMetadata).toEqual(true); // required by nest to function properly
expect(config.options.target).toEqual(ts.ScriptTarget.ES2015); // required by nest swagger to function properly
cleanup();
}, 120000);

Expand Down
7 changes: 7 additions & 0 deletions packages/nest/src/schematics/application/application.spec.ts
@@ -1,6 +1,7 @@
import { Tree } from '@angular-devkit/schematics';
import { createEmptyWorkspace } from '@nrwl/workspace/testing';
import { runSchematic } from '../../utils/testing';
import { readJsonInTree } from '@nrwl/workspace';

describe('app', () => {
let appTree: Tree;
Expand All @@ -17,4 +18,10 @@ describe('app', () => {
);
expect(tree.exists('apps/my-node-app/src/app/app.module.ts')).toBeTruthy();
});

it('should have es2015 as the tsconfig target', async () => {
const tree = await runSchematic('app', { name: 'myNodeApp' }, appTree);
const tsconfig = readJsonInTree(tree, 'apps/my-node-app/tsconfig.json');
expect(tsconfig.compilerOptions.target).toBe('es2015');
});
});
1 change: 1 addition & 0 deletions packages/nest/src/schematics/application/application.ts
Expand Up @@ -73,6 +73,7 @@ export default function(schema: Schema): Rule {
addAppFiles(options),
updateJsonInTree(join(options.appProjectRoot, 'tsconfig.json'), json => {
json.compilerOptions.emitDecoratorMetadata = true;
json.compilerOptions.target = 'es2015';
return json;
}),
formatFiles(options)
Expand Down

0 comments on commit cbd5d4c

Please sign in to comment.