Skip to content

Commit

Permalink
feat: add TypeScript types and tests (#116)
Browse files Browse the repository at this point in the history
Closes #96
  • Loading branch information
iamandrewluca authored Jun 3, 2021
1 parent 5e9b68f commit 9b9da32
Show file tree
Hide file tree
Showing 6 changed files with 1,711 additions and 14 deletions.
3 changes: 3 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
key: dependency-cache-{{ checksum "yarn.lock" }}
paths:
- ./node_modules
- run:
name: types
command: yarn types
- run:
name: test
command: yarn test
Expand Down
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
},
"main": "dist/vue-client-only.common.js",
"unpkg": "dist/vue-client-only.min.js",
"types": "types/index.d.ts",
"files": [
"dist"
"dist",
"types/index.d.ts"
],
"scripts": {
"types": "dtslint --localTs node_modules/typescript/lib types",
"test": "echo 'no tests!' && npm run lint",
"lint": "xo",
"build": "npm run build:cjs && npm run build:umd",
Expand All @@ -29,8 +32,12 @@
"dependencies": {},
"devDependencies": {
"bili": "^0.16.0-rc.1",
"dtslint": "^4.1.0",
"eslint-config-rem": "^3.0.0",
"poi": "^9.3.1",
"tsd": "^0.16.0",
"typescript": "^4.3.2",
"vue": "^2.6.13",
"xo": "^0.18.0"
},
"xo": {
Expand Down
10 changes: 10 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { FunctionalComponentOptions } from 'vue';

export interface ClientOnlyProps {
placeholder?: string;
placeholderTag?: string;
}

declare const ClientOnly: FunctionalComponentOptions<ClientOnlyProps>;

export default ClientOnly;
11 changes: 11 additions & 0 deletions types/index.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { expectType } from 'tsd';
import { CreateElement, Component, FunctionalComponentOptions } from 'vue';
import ClientOnly, { ClientOnlyProps } from 'vue-client-only';

const createElement: CreateElement = null as unknown as CreateElement;

createElement(ClientOnly);

expectType<Component>(ClientOnly);
expectType<FunctionalComponentOptions>(ClientOnly);
expectType<FunctionalComponentOptions<ClientOnlyProps>>(ClientOnly);
19 changes: 19 additions & 0 deletions types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"skipLibCheck": true,
"strict": true,
"noEmit": true,
// If the library is an external module (uses `export`), this allows your test file to import "mylib" instead of "./index".
// If the library is global (cannot be imported via `import` or `require`), leave this out.
"baseUrl": ".",
"paths": {
"vue-client-only": [
"."
]
}
}
}
Loading

0 comments on commit 9b9da32

Please sign in to comment.