Skip to content

Commit 387c77f

Browse files
committed
feat: TypeScript support
1 parent 98b677d commit 387c77f

File tree

11 files changed

+660
-17
lines changed

11 files changed

+660
-17
lines changed

.eslintignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@
1818
/.node_modules.ember-try/
1919
/bower.json.ember-try
2020
/package.json.ember-try
21-
/assets/**/*
21+
/assets/**/*
22+
/types

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module.exports = {
22
root: true,
3+
parser: 'typescript-eslint-parser',
34
parserOptions: {
45
ecmaVersion: 2017,
56
sourceType: 'module'

app/components/x-textarea.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Component from '@ember/component';
2+
3+
export default class XTextarea extends Component.extend({
4+
// anything which *must* be merged to prototype here
5+
}) {
6+
// normal class body definition here
7+
}

app/config/environment.d.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export default config;
2+
3+
/**
4+
* Type declarations for
5+
* import config from './config/environment'
6+
*
7+
* For now these need to be managed by the developer
8+
* since different ember addons can materialize new entries.
9+
*/
10+
declare const config: {
11+
environment: any;
12+
modulePrefix: string;
13+
podModulePrefix: string;
14+
locationType: string;
15+
rootURL: string;
16+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{yield}}

package.json

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"scripts": {
1414
"build": "ember build",
1515
"lint:hbs": "ember-template-lint .",
16-
"lint:js": "eslint .",
16+
"lint:js": "eslint . --ext js,ts",
1717
"lint:md": "remark .",
1818
"start": "ember serve",
1919
"test": "ember test",
@@ -24,13 +24,22 @@
2424
"@commitlint/cli": "7.2.1",
2525
"@commitlint/config-conventional": "7.1.2",
2626
"@commitlint/travis-cli": "7.2.1",
27+
"@ember-decorators/babel-transforms": "^3.1.0",
2728
"@ember/jquery": "0.5.2",
2829
"@ember/optional-features": "0.6.4",
2930
"@mike-north/js-lib-renovate-config": "1.2.0",
3031
"@mike-north/js-lib-semantic-release-config": "1.0.1",
3132
"@semantic-release/exec": "3.3.1",
3233
"@semantic-release/git": "7.0.6",
3334
"@semantic-release/github": "5.2.6",
35+
"@types/ember": "^3.0.26",
36+
"@types/ember-data": "^3.1.3",
37+
"@types/ember-qunit": "^3.4.4",
38+
"@types/ember-test-helpers": "^1.0.4",
39+
"@types/ember-testing-helpers": "^0.0.3",
40+
"@types/ember__test-helpers": "^0.7.6",
41+
"@types/qunit": "^2.5.3",
42+
"@types/rsvp": "^4.0.2",
3443
"broccoli-asset-rev": "2.7.0",
3544
"ember-ajax": "3.1.3",
3645
"ember-cli": "3.6.0",
@@ -43,6 +52,7 @@
4352
"ember-cli-inject-live-reload": "1.10.2",
4453
"ember-cli-sri": "2.1.1",
4554
"ember-cli-template-lint": "1.0.0-beta.2",
55+
"ember-cli-typescript-blueprints": "^2.0.0-beta.1",
4656
"ember-cli-uglify": "2.1.0",
4757
"ember-data": "3.6.0",
4858
"ember-export-application-global": "2.0.0",
@@ -62,7 +72,9 @@
6272
"remark-lint-no-dead-urls": "0.4.1",
6373
"remark-preset-lint-markdown-style-guide": "2.1.2",
6474
"remark-preset-lint-recommended": "3.0.2",
65-
"semantic-release": "15.13.1"
75+
"semantic-release": "15.13.1",
76+
"typescript": "^3.2.2",
77+
"typescript-eslint-parser": "^21.0.2"
6678
},
6779
"engines": {
6880
"node": "6.* || 8.* || >= 10.*"
@@ -107,7 +119,9 @@
107119
},
108120
"dependencies": {
109121
"@code-to-json/core": "0.6.18",
110-
"@code-to-json/formatter": "0.5.18"
122+
"@code-to-json/formatter": "0.5.18",
123+
"ember-cli-typescript": "^2.0.0-beta.3",
124+
"ember-decorators": "^3.1.5"
111125
},
112126
"husky": {
113127
"hooks": {
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { module, test } from 'qunit';
2+
import { setupRenderingTest } from 'ember-qunit';
3+
import { render } from '@ember/test-helpers';
4+
import hbs from 'htmlbars-inline-precompile';
5+
6+
module('Integration | Component | x-textarea', function(hooks) {
7+
setupRenderingTest(hooks);
8+
9+
test('it renders', async function(assert) {
10+
// Set any properties with this.set('myProperty', 'value');
11+
// Handle any actions with this.set('myAction', function(val) { ... });
12+
13+
await render(hbs`{{x-textarea}}`);
14+
15+
assert.equal(this.element.textContent.trim(), '');
16+
17+
// Template block usage:
18+
await render(hbs`
19+
{{#x-textarea}}
20+
template block text
21+
{{/x-textarea}}
22+
`);
23+
24+
assert.equal(this.element.textContent.trim(), 'template block text');
25+
});
26+
});

tsconfig.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2017",
4+
"allowJs": true,
5+
"moduleResolution": "node",
6+
"allowSyntheticDefaultImports": true,
7+
"noImplicitAny": true,
8+
"noImplicitThis": true,
9+
"alwaysStrict": true,
10+
"strictNullChecks": true,
11+
"strictPropertyInitialization": true,
12+
"noFallthroughCasesInSwitch": true,
13+
"noUnusedLocals": true,
14+
"noUnusedParameters": true,
15+
"noImplicitReturns": true,
16+
"noEmitOnError": false,
17+
"noEmit": true,
18+
"inlineSourceMap": true,
19+
"inlineSources": true,
20+
"baseUrl": ".",
21+
"module": "es6",
22+
"paths": {
23+
"c2jweb/tests/*": [
24+
"tests/*"
25+
],
26+
"c2jweb/*": [
27+
"app/*"
28+
],
29+
"*": [
30+
"types/*"
31+
]
32+
},
33+
"experimentalDecorators": true
34+
},
35+
"include": [
36+
"app/**/*",
37+
"tests/**/*",
38+
"types/**/*"
39+
]
40+
}

types/c2jweb/index.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
import Ember from 'ember';
3+
4+
declare global {
5+
interface Array<T> extends Ember.ArrayPrototypeExtensions<T> {}
6+
// interface Function extends Ember.FunctionPrototypeExtensions {}
7+
}
8+
9+
export {};
10+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* Catch-all for ember-data.
3+
*/
4+
export default interface ModelRegistry {
5+
[key: string]: any;
6+
}

0 commit comments

Comments
 (0)