当前位置: 首页 > 软件库 > 程序开发 > >

els-addon-typed-templates

授权协议 Readme
开发语言 JavaScript
所属分类 程序开发
软件类型 开源软件
地区 不详
投 递 者 詹亮
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

els-addon-typed-templates

Ember Language Server Typed Templates Addon

How to use?

Install this addon as dev-dependency inside your ember project.

How typed template looks under the hood?issue-351282903

  • route templates not supported (yet);

Template-lint integration (CI)

install ember-template-lint-typed-templates plugin to get if working

Autocomplete

Warn Each

Unknown Property

Features

  • Component context autocomplete {{this.}}
  • Component arguments autocomplete {{@}}
  • Warn on undefined properties (on complete)
  • Warn on incorrect each arguments (not an array)

NPM

npm install els-addon-typed-templates --save-dev

Yarn

yarn add els-addon-typed-templates --dev

VSCode

For els-addon-typed-templates >= v3.0.0, required Unstable Ember Language Server >= v1.4.2

For els-addon-typed-templates <= v2.2.18, required Unstable Ember Language Server >= v0.2.57

Install: Unstable Ember Language Server

  • Restart VSCode.

Usage

Try type {{this.}} or {{@}} inside component template.

Typescript Components

A component.ts file will work with no changes needed.

Template Only Components

A template only component needs some additional information.

Note: This is also how Javascript/ JSDoc template only components work.

{{!-- 
    interface Args {
        foo: {
            bar: string
        }
    }
--}}
{{@foo.bar}}

or

{{!--
  <script @typedef>
    interface Args {
      foo: {
        bar: string
      }
    }
  </script>
--}}
{{@foo.bar}}

Javsacript Component (JSDoc)

A component.js file needs some additional information in the js file to work.

components/cart.js

/**
 * @typedef {import('./../services/cart').default} CartService
 * 
 * @typedef {Object} Args
 * @property {string} foo
 * @property {import('./../models/bar'} bar
 * @extends Component<Args>

 */
export default class CartComponent extends Component {
    /**
     * CartService
     * @type {CartService}
     */
    @service('cart') cart;
}

components/cart.hbs

{{#each this.cart.items as |item|}}
    {{item.name}} 
    // ^ will support autocomplete and linting
{{/each}}

{{@bar.price}}
// ^ will support autocomplete and linting

FAQ

How can I ignore lines?

  • use handlebars comments
{{!-- @ts-ignore --}} 
{{this.line.to.ignore}}

How can I ignore a file?

{{!-- @ts-nocheck --}}

How can I override/ extend global typings?

// + project/types/index.d.ts
declare module "ember-typed-templates" {
    interface GlobalRegistry {
		// helper, component, modifier name -> result
        'unknown-helper': (params: string[], hash?)=> string,
        'block': (params?, hash?) => [ { someFirstBlockParamProperty: 42 } ]
    }
}

Errors and possible fixes:

https://github.com/lifeart/els-addon-typed-templates/pull/20

Is it supposed to support Object.extend notation?

Nope

Would it be possible to add these as dependencies to the language server or something similar?

Nope, because it's "experimental" and "heavy" functionality, adding it into language server itself may decrease DX for other users. UELS has addon API, using this addon API you able add functionality into langserver. All addons scoped inside projects (to allow users have multple addon versions for different ember projects and versions).

Is it stable?

Sometimes it may crash your language server, don't worry it will awake automatically.

 相关资料
  • Addon Domains是您帐户中托管的附加域,存储在子文件夹中。 系统将这些域视为系统的子域。 如果您想在同一主机方案下运行完全不同的网站,则可以使用cPanel的此功能。 这是在单个cPanel帐户上运行多个网站的最佳选择。 例如,您有一个托管博客网站,并且您想要一个不同的网站为您的简历,您不需要购买不同的托管帐户,但您可以使用相同的托管为您的简历网站。 要使用此功能,您需要从cPanel

  • flow-typed is a repository of third-partylibrary interface definitionsfor use with Flow. You can grab definitions directly from this GitHub repo, or you can use the CLI (currently in beta) to install

  • Typed Clojure 保留了 Clojure 的优势,是 Clojure 的可选类型系统,也可以说是 Clojure 的一个库,改善了大量的静态类型安全检测。 主要特性: 从 Java 中保护你的 Clojure 程序,进行安全的互操作,正确的使用外部 Java 库。 Typed Clojure 支持关键字映射的使用,类型检测器中包含有用的映射操作,包括关键字查找,添加或者移除关键字,合并映

  • Addon-sdk 即 Add-on SDK 开发包。使用它的话,你可以使用标准的网络技术(如:JavaScript, HTML, CSS)来创建火狐加载组件。这个 SDK 包括了 JavaScript APIs,允许你创建插件和工具用来运行、测试和加载开发工具。  

  • An instance map browser for World of Warcraft

  • Community Hass.io Add-ons: Homebridge This add-on provides the installation, configuration, and integration forHomebridge. Deprecation warning This add-on is in a deprecated state! At this point it is