typed-ember / ember-cli-typescript

Use TypeScript in your Ember.js apps!
https://docs.ember-cli-typescript.com
MIT License
363 stars 99 forks source link

[discussion] How should we handle templates? #242

Closed mike-north closed 5 years ago

mike-north commented 6 years ago

Currently, importing a template (i.e., in an addon's component) includes a

lib/my-addon/addon/components/x-foo.ts
// @ts-ignore: Ignore import of compiled template
import layout from '../templates/components/x-foo';

to get around the issue of typescript being unable to resolve the module. Since we're already maintaining a lot of bookkeeping for addons (in particular, tsconfig.json paths/includes for in-repo addons/engines), have we considered

lib/my-addon/addon/components/x-foo.ts
import layout from 'my-addon/templates/components/x-foo';

along with

(A) types/my-addon.d.ts
declare module 'my-addon/templates/*' {
  import { TemplateFactory } from "htmlbars-inline-precompile";
  export default TemplateFactory
}

or

(B) types/my-addon.d.ts
declare module 'my-addon/templates/*' {
  export default any
}

or

(C) types/my-addon.d.ts
declare module 'my-addon/templates/*' {
  export default any
}
chriskrycho commented 6 years ago

Relevant: #192.