Skip to content

Commit 5cc97fb

Browse files
committed
chore: add tools for including typescript declarations
1 parent 38da137 commit 5cc97fb

File tree

5 files changed

+79
-4
lines changed

5 files changed

+79
-4
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ node_modules
66
.eslintcache
77
*.js
88
*.js.flow
9+
*.ts
910
!/src/**/*.js
11+
!/src/**/*.ts
1012
!/test/**/*.js
1113
!/.babelrc.js

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"prettier:check": "prettier --list-different *.json *.md *.js '{src,test}/**/*.js'",
1212
"flow": "flow",
1313
"flow:coverage": "for file in src/**.js test/**.js; do echo $file; flow coverage $file; done",
14-
"clean": "rimraf es lib $(cd src; ls) *.js.flow",
15-
"build": "npm run clean && babel src --out-dir es && flow-copy-source -v src/ es && cross-env BABEL_ENV=es5 babel src --out-dir . && flow-copy-source -v src/ .",
14+
"clean": "rimraf es lib $(cd src; ls) *.js.flow *.d.ts",
15+
"build": "npm run clean && babel src --out-dir es && flow-copy-source -v src/ es && copy src/**/*.d.ts es && cross-env BABEL_ENV=es5 babel src --out-dir . && flow-copy-source -v src/ . && copy src/**/*.d.ts .",
1616
"test": "cross-env NODE_ENV=test BABEL_ENV=es5 mocha $npm_package_config_mocha && cross-env NODE_ENV=test BABEL_ENV=coverage nyc --reporter=lcov --reporter=text mocha $npm_package_config_mocha",
1717
"test:watch": "cross-env NODE_ENV=test BABEL_ENV=test mocha --watch $npm_package_config_mocha",
1818
"test:debug": "cross-env NODE_ENV=test BABEL_ENV=test mocha --inspect-brk $npm_package_config_mocha",
@@ -29,7 +29,7 @@
2929
}
3030
},
3131
"lint-staged": {
32-
"*.{js,json,css,md}": [
32+
"*.{js,json,css,md,ts}": [
3333
"prettier --write"
3434
]
3535
},
@@ -45,6 +45,7 @@
4545
},
4646
"config": {
4747
"mocha": "-r @babel/register test/configure.js 'test/**/*.js'",
48+
"prettier": "*.{json,md,js} '{src,test}/**/*.{js,ts}'",
4849
"commitizen": {
4950
"path": "cz-conventional-changelog"
5051
}
@@ -108,7 +109,8 @@
108109
"prettier": "^2.2.1",
109110
"prettier-eslint": "^12.0.0",
110111
"rimraf": "^3.0.2",
111-
"semantic-release": "^17.3.7"
112+
"semantic-release": "^17.3.7",
113+
"typescript": "^4.1.3"
112114
},
113115
"dependencies": {
114116
"@babel/runtime": "^7.12.5"

src/index.d.ts

Whitespace-only changes.

tsconfig.json

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"include": ["./src/**/*.ts"],
3+
"exclude": ["node_modules"],
4+
"compilerOptions": {
5+
/* Basic Options */
6+
"target": "es2019" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
7+
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
8+
"lib": [
9+
"es2019"
10+
] /* Specify library files to be included in the compilation. */,
11+
// "allowJs": true, /* Allow javascript files to be compiled. */
12+
// "checkJs": true, /* Report errors in .js files. */
13+
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
14+
// "declaration": true /* Generates corresponding '.d.ts' file. */,
15+
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
16+
// "sourceMap": true, /* Generates corresponding '.map' file. */
17+
// "outFile": "./", /* Concatenate and emit output to single file. */
18+
"outDir": "./" /* Redirect output structure to the directory. */,
19+
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
20+
// "composite": true, /* Enable project compilation */
21+
// "removeComments": true, /* Do not emit comments to output. */
22+
"noEmit": true /* Do not emit outputs. */,
23+
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
24+
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
25+
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
26+
27+
/* Strict Type-Checking Options */
28+
"strict": true /* Enable all strict type-checking options. */,
29+
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
30+
// "strictNullChecks": true, /* Enable strict null checks. */
31+
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
32+
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
33+
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
34+
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
35+
36+
/* Additional Checks */
37+
// "noUnusedLocals": true, /* Report errors on unused locals. */
38+
// "noUnusedParameters": true, /* Report errors on unused parameters. */
39+
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
40+
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
41+
42+
/* Module Resolution Options */
43+
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
44+
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
45+
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
46+
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
47+
// "typeRoots": [], /* List of folders to include type definitions from. */
48+
// "types": [], /* Type declaration files to be included in compilation. */
49+
"allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */,
50+
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
51+
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
52+
53+
/* Source Map Options */
54+
// "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
55+
// "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
56+
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
57+
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
58+
59+
/* Experimental Options */
60+
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
61+
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
62+
63+
/* Advanced Options */
64+
// "declarationDir": "lib" /* Output directory for generated declaration files. */
65+
}
66+
}

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8056,6 +8056,11 @@ typescript@^3.9.3:
80568056
resolved "https://registry.npmjs.org/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa"
80578057
integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==
80588058

8059+
typescript@^4.1.3:
8060+
version "4.1.3"
8061+
resolved "https://registry.npmjs.org/typescript/-/typescript-4.1.3.tgz#519d582bd94cba0cf8934c7d8e8467e473f53bb7"
8062+
integrity sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg==
8063+
80598064
uglify-js@^3.1.4:
80608065
version "3.12.5"
80618066
resolved "https://registry.npmjs.org/uglify-js/-/uglify-js-3.12.5.tgz#83241496087c640efe9dfc934832e71725aba008"

0 commit comments

Comments
 (0)