Skip to content

Commit 9b4a484

Browse files
committed
fix(typescript): create type declarations during build
Requires additional tsconfig.json as otherwise VS Code will only check files part of the tree (no tests). release-npm
1 parent 9ef702c commit 9b4a484

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

customize.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const files = [
1111
'package.json',
1212
'README.md',
1313
'tsconfig.json',
14+
'tsconfig-build.json',
1415
]
1516

1617
// Replace template values with plugin name.

template/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@
44
"license": "MIT",
55
"main": "dist/index.js",
66
"type": "module",
7+
"types": "dist/index.d.ts",
78
"exports": {
89
".": "./dist/index.js",
910
"./package.json": "./package.json"
1011
},
1112
"scripts": {
1213
"app": "node create-app.js",
13-
"build": "esbuild index.tsx --outdir=dist --bundle --minify --format=esm --sourcemap --external:react-native --external:react",
14+
"build": "esbuild index.tsx --outdir=dist --bundle --minify --format=esm --sourcemap --external:react-native --external:react && npm run build:types",
1415
"watch": "concurrently --kill-others \"npm run build:watch\" \"npm run copy\"",
1516
"copy": "cpx 'dist/**/*' app/node_modules/<%= name %>/dist --watch",
17+
"build:types": "tsc --project tsconfig-build.json",
1618
"build:watch": "esbuild index.tsx --watch --outdir=dist --bundle --format=esm --sourcemap --external:react-native --external:react",
1719
"test": "jest",
1820
"test:watch": "jest --watchAll",

template/tsconfig-build.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"noEmit": false,
5+
"emitDeclarationOnly": true,
6+
},
7+
"include": ["index.tsx"]
8+
}

template/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
"lib": ["es2017"],
66
"allowJs": true,
77
"jsx": "react-native",
8-
"noEmit": true,
98
"isolatedModules": true,
109
"strict": true,
1110
"moduleResolution": "node",
1211
"allowSyntheticDefaultImports": true,
1312
"esModuleInterop": true,
1413
"skipLibCheck": true,
1514
"resolveJsonModule": true,
15+
"declaration": true,
16+
"noEmit": true,
17+
"outDir": "dist",
1618
"paths": {
1719
"<%= name %>": ["."]
1820
}

0 commit comments

Comments
 (0)