This is the source for published cdk libraries
#!/bin/bash
mkdir packages/$1 && cd $_
cdk init lib --language=typescript
sh scripts/mk_package.sh test
Consider adding these lines to the scripts section of package.json
document typescript with typedoc
"doc": "typedoc",
comments can have the form of:
/**
* The Product description.
* @attribute
*/
description: string;
format your code with prettier
"format": "prettier --write \"lib/*.ts\" \"test/*.ts\"",
lint your code with tslint
"lint": "tslint -p tsconfig.json",
contents of tslint.json
{
"extends": ["tslint:recommended", "tslint-config-prettier"]
}
use jest to test your typescript code
"test": "jest",
install jest, types and ts preprocessor as dev dependency:
npm i jest @types/jest ts-jest -D
contents of jest.config.js
module.exports = {
"roots": [
"<rootDir>/test"
],
testMatch: [ '**/*.test.ts'],
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
}
may look something like:
"scripts": {
"build": "tsc",
"doc": "typedoc",
"format": "prettier --write \"lib/*.ts\" \"test/*.ts\"",
"lint": "tslint -p tsconfig.json",
"test": "jest",
"watch": "tsc -w"
},