Skip to content

Commit 6923628

Browse files
committed
chore: introduce api-extractor
1 parent 65ff62c commit 6923628

File tree

8 files changed

+232
-25
lines changed

8 files changed

+232
-25
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ node_modules
22
example/build.js
33
example/build.js.map
44
docs/.vuepress/dist
5-
test/test.build.js
65
lib

api-extractor.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* Config file for API Extractor. For more info, please visit: https://api-extractor.com
3+
*/
4+
{
5+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
6+
"mainEntryPointFilePath": "<projectFolder>/lib/index.d.ts",
7+
8+
"apiReport": {
9+
"enabled": false
10+
},
11+
12+
"docModel": {
13+
"enabled": false
14+
},
15+
16+
"dtsRollup": {
17+
"enabled": true,
18+
"untrimmedFilePath": "",
19+
"publicTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>.d.ts"
20+
},
21+
22+
"tsdocMetadata": {
23+
"enabled": false
24+
},
25+
26+
"newlineKind": "lf",
27+
28+
/**
29+
* Configures how API Extractor reports error and warning messages produced during analysis.
30+
*
31+
* There are three sources of messages: compiler messages, API Extractor messages, and TSDoc messages.
32+
*/
33+
"messages": {
34+
"compilerMessageReporting": {
35+
"default": {
36+
"logLevel": "warning"
37+
}
38+
},
39+
40+
"extractorMessageReporting": {
41+
"default": {
42+
"logLevel": "warning"
43+
},
44+
45+
"ae-missing-release-tag": {
46+
"logLevel": "none"
47+
}
48+
},
49+
50+
"tsdocMessageReporting": {
51+
"default": {
52+
"logLevel": "warning"
53+
}
54+
}
55+
}
56+
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "dist/vue-class-component.common.js",
66
"module": "dist/vue-class-component.esm.js",
77
"unpkg": "dist/vue-class-component.js",
8-
"typings": "lib/index.d.ts",
8+
"typings": "dist/vue-class-component.d.ts",
99
"files": [
1010
"dist",
1111
"lib",
@@ -53,6 +53,7 @@
5353
"@babel/plugin-proposal-decorators": "^7.7.4",
5454
"@babel/preset-env": "^7.7.7",
5555
"@babel/preset-typescript": "^7.8.3",
56+
"@microsoft/api-extractor": "^7.7.13",
5657
"@types/jest": "^25.1.3",
5758
"@types/node": "^13.1.6",
5859
"@vue/compiler-sfc": "^3.0.0-beta.4",

src/helpers.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,21 @@ export function createDecorator(
3737
}
3838
}
3939

40-
interface PropsMixin {
40+
export interface PropsMixin {
4141
new <Props = unknown>(...args: any[]): {
4242
$props: Props
4343
}
4444
}
4545

46-
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
46+
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
4747
k: infer I
4848
) => void
4949
? I
5050
: never
5151

52-
type ExtractInstance<T> = T extends VueMixin<infer V> ? V : never
52+
export type ExtractInstance<T> = T extends VueMixin<infer V> ? V : never
5353

54-
type MixedVueBase<Mixins extends VueMixin[]> = Mixins extends (infer T)[]
54+
export type MixedVueBase<Mixins extends VueMixin[]> = Mixins extends (infer T)[]
5555
? VueBase<UnionToIntersection<ExtractInstance<T>> & Vue> & PropsMixin
5656
: never
5757

src/index.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1-
export { Vue } from './vue'
1+
/**
2+
* Public APIs
3+
*/
4+
5+
export { Vue, ClassComponentHooks } from './vue'
6+
7+
export { Options, createDecorator, mixins, setup } from './helpers'
8+
9+
/**
10+
* Other types
11+
*/
12+
13+
export { VueBase, VueMixin, VueStatic } from './vue'
14+
215
export {
3-
Options,
416
VueDecorator,
5-
createDecorator,
6-
mixins,
7-
setup,
17+
MixedVueBase,
18+
UnionToIntersection,
19+
ExtractInstance,
20+
PropsMixin,
821
} from './helpers'

src/vue.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ function getSuperOptions(Ctor: Function): ComponentOptions | undefined {
3939
return Super.__vccOpts
4040
}
4141

42-
interface ClassComponentHooks {
42+
export interface ClassComponentHooks {
4343
/* To be extended on user land */
4444
}
4545

46-
type VueStatic = {
46+
export type VueStatic = {
4747
[K in keyof typeof Vue]: typeof Vue[K]
4848
}
4949

tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
"moduleResolution": "node",
1010
"outDir": "lib",
1111
"declaration": true,
12+
"sourceMap": true,
13+
"declarationMap": true,
1214
"strict": true,
1315
"noUnusedLocals": true,
1416
"noUnusedParameters": true
1517
},
1618
"include": [
1719
"src/**/*.ts"
18-
],
19-
"compileOnSave": false
20+
]
2021
}

0 commit comments

Comments
 (0)