Skip to content

Commit 288e1f7

Browse files
committed
Add an example project that uses ttypescript
Signed-off-by: moznion <moznion@mail.moznion.net>
1 parent de8de38 commit 288e1f7

File tree

6 files changed

+71
-0
lines changed

6 files changed

+71
-0
lines changed

examples/ttypescript/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.d.ts
2+
*.js

examples/ttypescript/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Using [ttypescript](https://github.com/cevek/ttypescript) example
2+
3+
## How to run
4+
5+
```
6+
npm run run
7+
```
8+
9+
Please see also [package.json](./package.json) and [tsconfig.json](./tsconfig.json).
10+

examples/ttypescript/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { dynamodbRecord } from '../../index';
2+
import { AttributeValue } from '@aws-sdk/client-dynamodb';
3+
4+
interface User {
5+
readonly id: number;
6+
readonly name: string;
7+
readonly tags: Map<string, string>;
8+
}
9+
10+
const record: Record<string, AttributeValue> = dynamodbRecord<User>({
11+
id: 12345,
12+
name: 'John Doe',
13+
tags: new Map<string, string>([
14+
['foo', 'bar'],
15+
['buz', 'qux'],
16+
]),
17+
});
18+
19+
console.log(JSON.stringify(record));

examples/ttypescript/package-lock.json

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

examples/ttypescript/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "ttypescript",
3+
"version": "0.0.0",
4+
"main": "index.js",
5+
"scripts": {
6+
"run": "ttsc ./index.ts && node ./index.js",
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"license": "MIT"
10+
}

examples/ttypescript/tsconfig.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"compileOnSave": true,
3+
"compilerOptions": {
4+
"target": "es2016",
5+
"lib": [],
6+
"module": "commonjs",
7+
"moduleResolution": "node",
8+
"strict": true,
9+
10+
"plugins": [
11+
{
12+
"transform": "../../transformer.ts"
13+
}
14+
]
15+
}
16+
}
17+

0 commit comments

Comments
 (0)