From ae52b9c264aba1d3a8ee94fb002148dcd4760dc0 Mon Sep 17 00:00:00 2001 From: "James C. Davis" Date: Sun, 25 Feb 2018 03:15:16 -0500 Subject: [PATCH 1/3] Add layout = layout; for addon components --- .../component/files/__root__/__path__/__name__.ts | 2 +- blueprints/component/index.js | 2 +- node-tests/blueprints/component-test.js | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/blueprints/component/files/__root__/__path__/__name__.ts b/blueprints/component/files/__root__/__path__/__name__.ts index aeb05539d..c9a1b45af 100644 --- a/blueprints/component/files/__root__/__path__/__name__.ts +++ b/blueprints/component/files/__root__/__path__/__name__.ts @@ -2,6 +2,6 @@ import Component from '@ember/component'; <%= importTemplate %> export default class <%= classifiedModuleName %> extends Component.extend({ // anything which *must* be merged to prototype here -}) { +}) {<%= contents %> // normal class body definition here }; diff --git a/blueprints/component/index.js b/blueprints/component/index.js index ae70a1cdb..98ff16b0e 100644 --- a/blueprints/component/index.js +++ b/blueprints/component/index.js @@ -63,7 +63,7 @@ module.exports = { 'templates/components/' + stringUtil.dasherize(options.entity.name); } importTemplate = 'import layout from \'' + templatePath + '\';\n'; - contents = '\n layout'; + contents = '\n layout = layout;'; } return { diff --git a/node-tests/blueprints/component-test.js b/node-tests/blueprints/component-test.js index 1f2a1ce82..34d0c9a4b 100644 --- a/node-tests/blueprints/component-test.js +++ b/node-tests/blueprints/component-test.js @@ -19,4 +19,14 @@ describe('Acceptance: ember generate and destroy component', function() { expect(file('app/components/foo-bar.ts')).to.contain('export default class FooBar extends Component.extend'); })); }); + + it('addon component foo-bar', function() { + let args = ['component', 'foo-bar']; + + return emberNew({ target: 'addon' }) + .then(() => emberGenerateDestroy(args, (file) => { + expect(file('addon/components/foo-bar.ts')) + .to.contain('layout = layout;'); + })); + }); }); From 504215b3282d8e69f6d70702dc1b98ea5512b14d Mon Sep 17 00:00:00 2001 From: "James C. Davis" Date: Sun, 25 Feb 2018 03:16:32 -0500 Subject: [PATCH 2/3] Add @ts-ignore for import of compiled template --- blueprints/component/index.js | 2 +- node-tests/blueprints/component-test.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/blueprints/component/index.js b/blueprints/component/index.js index 98ff16b0e..0b1ec4a9a 100644 --- a/blueprints/component/index.js +++ b/blueprints/component/index.js @@ -62,7 +62,7 @@ module.exports = { templatePath = pathUtil.getRelativeParentPath(options.entity.name) + 'templates/components/' + stringUtil.dasherize(options.entity.name); } - importTemplate = 'import layout from \'' + templatePath + '\';\n'; + importTemplate = '// @ts-ignore: Ignore import of compiled template\nimport layout from \'' + templatePath + '\';\n'; contents = '\n layout = layout;'; } diff --git a/node-tests/blueprints/component-test.js b/node-tests/blueprints/component-test.js index 34d0c9a4b..eb8496335 100644 --- a/node-tests/blueprints/component-test.js +++ b/node-tests/blueprints/component-test.js @@ -25,6 +25,8 @@ describe('Acceptance: ember generate and destroy component', function() { return emberNew({ target: 'addon' }) .then(() => emberGenerateDestroy(args, (file) => { + expect(file('addon/components/foo-bar.ts')) + .to.contain('// @ts-ignore: Ignore import of compiled template\nimport layout from \'../templates/components/foo-bar\';\n'); expect(file('addon/components/foo-bar.ts')) .to.contain('layout = layout;'); })); From 4cec874ec33db6cc6b6e74ecc5a2c138916647a7 Mon Sep 17 00:00:00 2001 From: "James C. Davis" Date: Mon, 26 Feb 2018 12:13:01 -0500 Subject: [PATCH 3/3] Add CHANGELOG entries --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 910b9c401..25df87bcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a ## [Unreleased] +### Added + +* @ts-ignore component template import. + ### Changed * Improve instructions for setting up [Linked Addons](README.md#linking-addons) and [In-repo Addons](README.md#in-repo-addons). +### Fixed + +* Addon components need to manually set their layout property to the imported compiled template. + ## [1.1.6] - 2018-02-23 ### Fixed