Skip to content

Commit

Permalink
example(transform-typescript): add example.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Aug 2, 2021
1 parent 2994ca2 commit e98a687
Show file tree
Hide file tree
Showing 8 changed files with 200 additions and 0 deletions.
5 changes: 5 additions & 0 deletions example/transform-typescript/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": [
"@babel/preset-typescript"
]
}
113 changes: 113 additions & 0 deletions example/transform-typescript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Created by https://www.gitignore.io/api/node
# Edit at https://www.gitignore.io/?templates=node

lib
package-lock.json
__snapshots__

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# End of https://www.gitignore.io/api/node

.DS_Store
.cache
.vscode
.idea
.env

*.bak
*.tem
*.temp
#.swp
*.*~
~*.*

# IDEA
*.iml
*.ipr
*.iws
.idea/
4 changes: 4 additions & 0 deletions example/transform-typescript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Transform Typescript Example
---

Feature: Just delete the typescript type.
27 changes: 27 additions & 0 deletions example/transform-typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "@template/transform-typescript",
"private": true,
"version": "2.2.1",
"description": "Transform Typescript Example.",
"scripts": {
"start": "node lib/index.js",
"watch": "npm run watch:ts",
"watch:ts": "tsbb watch --babel-option=none & npm run build:types -- --watch",
"build": "npm run build:ts && npm run build:types",
"build:ts": "tsbb build --babel-option=none",
"build:types": "tsbb types",
"test": "tsbb test",
"coverage": "tsbb test --coverage"
},
"repository": {
"type": "git",
"url": "https://github.com/jaywcjlove/tsbb/tree/master/example/transform-typescript"
},
"jest": {},
"keywords": [],
"license": "MIT",
"devDependencies": {
"tsbb": "2.2.1"
},
"author": ""
}
25 changes: 25 additions & 0 deletions example/transform-typescript/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { sum } from './utils/sum';

class Test {
constructor() {}
count() {
return 10;
}
}

async function testHandle() {
console.log('>>>');
}

(() => {
const { sum } = require('./utils/sum');
const data = { a: 1 };
const result = { ...data };
console.log('>>>', sum(1, result.a));
})();

export default async () => {
const test = new Test();
await testHandle();
return sum(1, test.count());
};
8 changes: 8 additions & 0 deletions example/transform-typescript/src/utils/a/a.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* 这里是注释
* @param a
* @param b
*/
export function abs(a: number, b: number) {
return a + b;
}
3 changes: 3 additions & 0 deletions example/transform-typescript/src/utils/sum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function sum(a: number, b: number) {
return a + b;
}
15 changes: 15 additions & 0 deletions example/transform-typescript/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"declaration": true,
"target": "ES2017",
"noImplicitAny": true,
"resolveJsonModule": true,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "lib",
"baseUrl": "."
},
"include": ["src/**/*"]
}

0 comments on commit e98a687

Please sign in to comment.