Skip to content

Commit d47f190

Browse files
authored
feat: move to typescript (#36)
1 parent 14b9947 commit d47f190

File tree

93 files changed

+4360
-10895
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+4360
-10895
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ node_modules/
77
# Tests
88
coverage/
99

10+
# Typescript
11+
.ts/
12+
1013
# Publish
1114
dist/packages-dist/
1215
site/

config/build.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ const stream = require("stream");
88
const conventionalChangelog = require("conventional-changelog");
99

1010
const PACKAGES = [
11-
// "loki",
12-
// "partitioning-adapter",
13-
// "local-storage",
14-
// "indexed-storage",
15-
// "fs-storage",
11+
"loki",
12+
"partitioning-adapter",
13+
"local-storage",
14+
"indexed-storage",
15+
"fs-storage",
1616
"full-text-search"
1717
];
1818

config/eslintrc.js

-28
This file was deleted.

config/jasmine.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"spec_dir": "packages/*/spec",
33
"spec_files": [
4-
"generic/**/*.spec.js",
5-
"node/**/*.spec.js"
4+
"generic/**/*.spec.[jt]s",
5+
"node/**/*.spec.[jt]s"
66
],
77
"helpers": [
88
"helpers/**/*.js",
9+
"../../../node_modules/ts-node/register.js",
910
"../../../node_modules/babel-register/lib/node.js",
1011
"../../../node_modules/jasmine-expect/index.js"
1112
],

config/karma.config.js

+28-17
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ module.exports = function (config) {
66
frameworks: ["jasmine", "jasmine-matchers"],
77
browsers: ["Chrome"],
88
files: [
9-
{pattern: "../packages/*/spec/generic/**/*.spec.js", watched: false},
10-
{pattern: "../packages/*/spec/web/**/*.spec.js", watched: false},
9+
{pattern: "../packages/*/spec/generic/**/*.spec.ts", watched: false},
10+
{pattern: "../packages/*/spec/web/**/*.spec.ts", watched: false}
1111
],
1212
preprocessors: {
13-
"../packages/*/spec/generic/**/*.spec.js": ["webpack"],
14-
"../packages/*/spec/web/**/*.spec.js": ["webpack"],
13+
"../packages/*/spec/generic/**/*.spec.ts": ["webpack"],
14+
"../packages/*/spec/web/**/*.spec.ts": ["webpack"]
1515
},
1616

1717
// coverage reporter generates the coverage
@@ -21,25 +21,36 @@ module.exports = function (config) {
2121
reports: ["text-summary", "lcov", "html", "json"],
2222
fixWebpackSourcePaths: false
2323
},
24-
24+
mime: {
25+
'text/x-typescript': ['ts']
26+
},
2527
webpack: {
2628
externals: {
2729
"fs": "fs"
2830
},
29-
devtool: "source-map",
31+
resolve: {
32+
extensions: ['.ts', '.js'],
33+
},
34+
devtool: "inline-source-map",
3035
module: {
31-
rules: [
36+
// rules: [
37+
// {
38+
// test: /\.js$/,
39+
// use: [
40+
// {
41+
// loader: "istanbul-instrumenter-loader",
42+
// options: {
43+
// esModules: true
44+
// }
45+
// },
46+
// ]
47+
// }
48+
// ],
49+
loaders: [
3250
{
33-
test: /\.js$/,
34-
use: [
35-
{
36-
loader: "istanbul-instrumenter-loader",
37-
options: {
38-
esModules: true
39-
}
40-
},
41-
]
42-
}
51+
test: /\.ts$/,
52+
loader: "ts-loader"
53+
},
4354
]
4455
}
4556
},

config/tsconfig.webpack.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"compileOnSave": false,
3+
"compilerOptions": {
4+
"outDir": "../types/",
5+
"sourceMap": true,
6+
"declaration": true,
7+
"moduleResolution": "node",
8+
"emitDecoratorMetadata": true,
9+
"experimentalDecorators": true,
10+
"noImplicitAny": true,
11+
"suppressImplicitAnyIndexErrors": true,
12+
"target": "es6",
13+
"lib": [
14+
"es2017",
15+
"dom"
16+
]
17+
},
18+
"include": [
19+
"../packages/*/src/**/*.ts"
20+
]
21+
}

config/tslint.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"rulesDirectory": [
3+
"../node_modules/vrsource-tslint-rules/rules",
4+
"../node_modules/tslint-eslint-rules/dist/rules"
5+
],
6+
"extends": [
7+
"tslint-eslint-rules"
8+
],
9+
"rules": {
10+
"no-console": [true, "log"],
11+
"no-duplicate-imports": true,
12+
"no-duplicate-variable": true,
13+
"no-jasmine-focus": true,
14+
"no-var-keyword": true,
15+
"semicolon": [true],
16+
"variable-name": [true, "ban-keywords"],
17+
"no-inner-declarations": [true, "function"],
18+
"quotemark": [true, "double"]
19+
},
20+
"jsRules": {
21+
"no-console": [true, "log"],
22+
"no-duplicate-imports": true,
23+
"no-duplicate-variable": true,
24+
"no-jasmine-focus": true,
25+
"require-internal-with-underscore": true,
26+
"semicolon": [true],
27+
"variable-name": [true, "ban-keywords"],
28+
"no-inner-declarations": [true, "function"],
29+
"quotemark": [true, "double"]
30+
}
31+
}

config/webpack-config-creator.js

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/* global __dirname, module, require */
2+
const path = require("path");
3+
4+
module.exports = (options) => {
5+
if (options.entry === undefined) {
6+
throw Error("options.entry must be specified.")
7+
}
8+
if (options.filename === undefined) {
9+
throw Error("options.Filename must be specified.")
10+
}
11+
if (options.library === undefined) {
12+
throw Error("options.library must be specified.")
13+
}
14+
15+
return {
16+
entry: options.entry,
17+
output: {
18+
filename: options.filename,
19+
library: options.library,
20+
libraryTarget: "umd2",
21+
umdNamedDefine: false
22+
},
23+
externals: options.externals,
24+
resolve: {
25+
extensions: [".ts", ".js"]
26+
},
27+
devtool: "source-map",
28+
module: {
29+
loaders: [
30+
{
31+
enforce: 'pre',
32+
test: /\.ts$/,
33+
loader: 'tslint-loader',
34+
exclude: /node_modules/,
35+
options: {
36+
failOnHint: true,
37+
configFile: path.join("config", "tslint.json"),
38+
}
39+
},
40+
{
41+
test: /\.ts$/,
42+
loader: "ts-loader",
43+
options: {
44+
configFile: path.join("config", "tsconfig.webpack.json")
45+
}
46+
}
47+
]
48+
},
49+
};
50+
};

0 commit comments

Comments
 (0)