ember-cli / ember-cli/ember-cli-htmlbars

TemplateFactory type incompatible with setComponentTemplate type from @types/ember__component

未关闭
#787 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
JavaScript
星标
77
派生
65
PR 合并指标
30 天内没有已合并 PR

描述

With ember-cli-htmlbars 6.3.0 and latest version 4.0.22 of `@types/ember__component`, for this type of code...

```
import { hbs } from 'ember-cli-htmlbars';
import { setComponentTemplate } from '@ember/component';

export const Button = setComponentTemplate(
hbs`
{{yield}}`,
templateOnly(),
);
```

I am getting this type error:

```
Argument of type 'import("/[...]/node_modules/ember-cli-htmlbars/lib/index").TemplateFactory' is not assignable to parameter of type 'TemplateFactory'.
Property '__htmlbars_inline_precompile_template_factory' is missing in type 'import("/[...]/node_modules/ember-cli-htmlbars/lib/index").TemplateFactory' but required in type 'TemplateFactory'.ts(2345)
index.d.ts(14, 5): '__htmlbars_inline_precompile_template_factory' is declared here.
```

`@types/ember__component` is still defining `TemplateFactory` like this:

```
interface TemplateFactory {
__htmlbars_inline_precompile_template_factory: any;
}
```

But https://github.com/ember-cli/ember-cli-htmlbars/pull/764 removed that `__htmlbars_inline_precompile_template_factory` property (used as a way of type branding I guess?), so I am indeed wondering how this is supposed to work now? Maybe just working with Ember's native types?

/cc @chriskrycho

贡献指南

这个仓库没有索引到贡献指南

调研方向

Start with the provided TypeScript example and inspect the TemplateFactory declarations in ember-cli-htmlbars and @types/ember__component, including the definition referenced by index.d.ts. Review ember-cli-htmlbars PR 764 for the branding-property change, then verify that the example type-checks with compatible declarations.

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, typescript
领域
tooling
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。