Skip to content

Commit d2a095a

Browse files
committed
convert to typescript
1 parent df0fe5c commit d2a095a

14 files changed

Lines changed: 304 additions & 147 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ node_modules/
22
lib/
33
dist/
44
coverage/
5+
types/
56
.vscode/

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ src/
22
rollup.config.js
33
test/
44
coverage/
5+
types/tsconfig.tsbuildinfo
56
.travis.yml
67
*.config.js

package-lock.json

Lines changed: 81 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "dom-expressions",
33
"description": "A Fine-Grained Runtime for Performant DOM Rendering",
4-
"version": "0.7.1",
4+
"version": "0.7.2",
55
"author": "Ryan Carniato",
66
"license": "MIT",
77
"repository": {
@@ -11,19 +11,23 @@
1111
"readmeFilename": "README.md",
1212
"module": "dist/dom-expressions.js",
1313
"main": "lib/dom-expressions.js",
14+
"types": "types/index.d.ts",
1415
"sideEffects": false,
1516
"scripts": {
16-
"build": "rollup -c",
17+
"build": "rollup -c && tsc",
1718
"test": "npm run build && jest --coverage",
1819
"prepublishOnly": "npm run build"
1920
},
2021
"devDependencies": {
2122
"@babel/core": "7.4.3",
23+
"@babel/preset-typescript": "7.3.3",
2224
"babel-plugin-jsx-dom-expressions": "*",
2325
"coveralls": "3.0.3",
24-
"jest": "^24.7.0",
25-
"rollup": "^1.8.0",
26-
"rollup-plugin-node-resolve": "^4.0.1",
27-
"s-js": "0.4.9"
26+
"jest": "24.7.1",
27+
"rollup": "1.10.1",
28+
"rollup-plugin-babel": "^4.3.2",
29+
"rollup-plugin-node-resolve": "4.2.3",
30+
"s-js": "0.4.9",
31+
"typescript": "3.4.4"
2832
}
2933
}

rollup.config.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1+
import babel from 'rollup-plugin-babel';
12
import nodeResolve from 'rollup-plugin-node-resolve';
23

3-
const plugins = [nodeResolve()]
4+
const plugins = [
5+
nodeResolve({
6+
extensions: ['.js', '.ts']
7+
}),
8+
babel({
9+
extensions: ['.js', '.ts'],
10+
presets: ["@babel/preset-typescript"],
11+
exclude: 'node_modules/**',
12+
retainLines: true
13+
})
14+
]
415

516
export default {
6-
input: 'src/index.js',
17+
input: 'src/index.ts',
718
output: [{
819
file: 'lib/dom-expressions.js',
920
format: 'cjs',

src/Attributes.js

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/Attributes.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
type AttributeInfo = {
2+
[key: string]: {
3+
type: string,
4+
alias?: string
5+
}
6+
}
7+
8+
const Types = {
9+
ATTRIBUTE: 'attribute',
10+
PROPERTY: 'property'
11+
},
12+
Attributes: AttributeInfo = {
13+
href: {
14+
type: Types.ATTRIBUTE
15+
},
16+
style: {
17+
type: Types.PROPERTY,
18+
alias: 'style.cssText'
19+
},
20+
for: {
21+
type: Types.PROPERTY,
22+
alias: 'htmlFor'
23+
},
24+
class: {
25+
type: Types.PROPERTY,
26+
alias: 'className'
27+
},
28+
// React compat
29+
spellCheck: {
30+
type: Types.PROPERTY,
31+
alias: 'spellcheck'
32+
},
33+
allowFullScreen: {
34+
type: Types.PROPERTY,
35+
alias: 'allowFullscreen'
36+
},
37+
autoCapitalize: {
38+
type: Types.PROPERTY,
39+
alias: 'autocapitalize'
40+
},
41+
autoFocus: {
42+
type: Types.PROPERTY,
43+
alias: 'autofocus'
44+
},
45+
autoPlay: {
46+
type: Types.PROPERTY,
47+
alias: 'autoplay'
48+
}
49+
};
50+
51+
export default Attributes;

0 commit comments

Comments
 (0)