Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Add initial Glint types #345

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .glintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
environment: ember-loose
include:
- 'addon/**'
- 'tests/**'
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ except: ['camelize'] // imports all helpers except `camelize`
only: ['camelize'] // imports only `camelize`
```

## Glint types
To enable Glint template typechecking for the addon, add:
```js
import 'ember-cli-string-helpers/glint';
```
anywhere you put your app's global types into, e.g. `types/global.d.ts`.
See also [Glint documentation](https://typed-ember.gitbook.io/glint/using-glint/ember/using-addons)

## Available helpers

* [`camelize`](#camelize)
Expand Down
58 changes: 58 additions & 0 deletions glint.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { HelperLike } from '@glint/template';

declare module '@glint/environment-ember-loose/registry' {
export default interface Registry {
camelize: HelperLike<{
Args: { Positional: [str: string] };
Return: string;
}>;
capitalize: HelperLike<{
Args: { Positional: [str: string] };
Return: string;
}>;
classify: HelperLike<{
Args: { Positional: [str: string] };
Return: string;
}>;
dasherize: HelperLike<{
Args: { Positional: [str: string] };
Return: string;
}>;
'html-safe': HelperLike<{
Args: { Positional: [str: string] };
Return: string;
}>;
humanize: HelperLike<{
Args: { Positional: [str: string] };
Return: string;
}>;
lowercase: HelperLike<{
Args: { Positional: [str: string] };
Return: string;
}>;
titleize: HelperLike<{
Args: { Positional: [str: string] };
Return: string;
}>;
trim: HelperLike<{
Args: { Positional: [str: string] };
Return: string;
}>;
truncate: HelperLike<{
Args: { Positional: [str: string | undefined, characterLimit?: number, useEllipsis?: boolean] };
Return: string;
}>;
underscore: HelperLike<{
Args: { Positional: [str: string] };
Return: string;
}>;
uppercase: HelperLike<{
Args: { Positional: [str: string] };
Return: string;
}>;
w: HelperLike<{
Args: { Positional: [str: string | string[]] };
Return: string[];
}>;
}
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "String helpers for Ember",
"scripts": {
"build": "ember build",
"glint": "node node_modules/@glint/core/bin/glint.js",
"lint:hbs": "ember-template-lint .",
"lint:js": "eslint .",
"start": "ember serve",
Expand All @@ -16,6 +17,8 @@
"devDependencies": {
"@ember/optional-features": "^2.0.0",
"@embroider/test-setup": "^0.37.0",
"@glint/core": "^0.9.7",
"@glint/environment-ember-loose": "^0.9.7",
"broccoli-asset-rev": "^3.0.0",
"chai": "^4.2.0",
"ember-ajax": "^5.0.0",
Expand Down