Skip to content

Commit 25cec73

Browse files
jfuchscolebemis
andauthored
Separate typechecking and building type declarations (#1588)
* Separate typechecking and building type declarations * Update .github/workflows/ci.yml Co-authored-by: Cole Bemis <[email protected]> Co-authored-by: Cole Bemis <[email protected]>
1 parent 76ea50f commit 25cec73

File tree

6 files changed

+34
-23
lines changed

6 files changed

+34
-23
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ jobs:
2424
- name: Lint
2525
run: npm run lint
2626

27-
- name: Build
28-
run: npm run build
27+
- name: Type check
28+
run: npm run typecheck
2929

3030
- name: Test
3131
run: npm run test
32+
33+
- name: Build
34+
run: npm run build

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"test": "jest",
2121
"test:update": "npm run test -- --updateSnapshot",
2222
"release": "npm run build && changeset publish",
23-
"size": "size-limit"
23+
"size": "size-limit",
24+
"typecheck": "npx tsc --project tsconfig.json"
2425
},
2526
"repository": "primer/react",
2627
"keywords": [

script/build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ npx cross-env NODE_ENV=production rollup -c
1414
npx cross-env BABEL_MODULE=commonjs babel src --out-dir lib --extensions ".js,.ts,.jsx,.tsx"
1515
npx babel src --out-dir lib-esm --extensions ".js,.ts,.jsx,.tsx"
1616

17-
# Type check
17+
# Build type declarations
1818
npx tsc --project tsconfig.build.json
1919

2020
# Copy type declarations

tsconfig.base.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"target": "esnext",
4+
"module": "commonjs",
5+
"allowJs": true,
6+
"checkJs": false,
7+
"jsx": "preserve",
8+
"declaration": true,
9+
"outDir": "./lib",
10+
"emitDeclarationOnly": false,
11+
"strict": true,
12+
"moduleResolution": "node",
13+
"rootDirs": ["src"],
14+
"esModuleInterop": true,
15+
"skipLibCheck": true,
16+
"forceConsistentCasingInFileNames": true,
17+
"typeRoots": ["./node_modules/@types", "./@types"]
18+
},
19+
"include": ["@types/**/*.ts", "src/**/*.js", "src/**/*.ts", "src/**/*.tsx"]
20+
}

tsconfig.build.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"extends": "./tsconfig.json",
2+
"extends": "./tsconfig.base.json",
33
// NOTE: We exclude Storybook stories — in part because we don't want their type definitions
44
// included in our build, but also because _something_ in Storybook mucks with the type definitions
55
// of Primer components. See also https://github.com/primer/react/issues/1163.
6-
"exclude": ["**/*.stories.tsx"]
6+
"exclude": ["**/*.stories.tsx"],
77
}

tsconfig.json

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
11
{
2+
"extends": "./tsconfig.base.json",
23
"compilerOptions": {
3-
"target": "esnext",
4-
"module": "commonjs",
5-
"allowJs": true,
6-
"checkJs": false,
7-
"jsx": "preserve",
8-
"declaration": true,
9-
"outDir": "./lib",
10-
"emitDeclarationOnly": true,
11-
"strict": true,
12-
"moduleResolution": "node",
13-
"rootDirs": ["src"],
14-
"esModuleInterop": true,
15-
"skipLibCheck": true,
16-
"forceConsistentCasingInFileNames": true,
17-
"typeRoots": ["./node_modules/@types", "./@types"]
4+
"noEmit": true,
5+
"emitDeclarationOnly": false
186
},
19-
"include": ["@types/**/*.ts", "src/**/*.js", "src/**/*.ts", "src/**/*.tsx"]
20-
}
7+
}

0 commit comments

Comments
 (0)