Skip to content

Commit

Permalink
Merge pull request #2 from RebeccaStevens/type-tests
Browse files Browse the repository at this point in the history
BREAKING CHANGE: drop product function
  • Loading branch information
RebeccaStevens committed Jul 8, 2023
2 parents b3210dd + 1fac1c8 commit 4b590d3
Show file tree
Hide file tree
Showing 52 changed files with 691 additions and 66 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off"
}
},
{
"files": ["**/*.test-d.ts"],
"rules": {
"import/no-useless-path-segments": "off"
}
}
]
}
7 changes: 5 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ jobs:
uses: ./.github/workflows/lint-spelling.yml
lint_prettier:
uses: ./.github/workflows/lint-prettier.yml
test:
test_js:
uses: ./.github/workflows/test-js.yml
test_types:
uses: ./.github/workflows/test-types.yml
type_check:
uses: ./.github/workflows/type-check.yml

Expand All @@ -37,7 +39,8 @@ jobs:
- lint_markdown
- lint_spelling
- lint_prettier
- test
- test_js
- test_types
- type_check
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-js.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: Test JS

on:
pull_request:
Expand All @@ -11,5 +11,5 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/prepare
- run: pnpm run test
- run: pnpm run test:js
- uses: codecov/codecov-action@v3
16 changes: 16 additions & 0 deletions .github/workflows/test-types.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Test Types

on:
pull_request:
workflow_dispatch:
workflow_call:

jobs:
test_js:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/prepare
- run: BUILD_TYPES_ONLY=1 pnpm run build
- run: pnpm run test:types
- uses: codecov/codecov-action@v3
2 changes: 1 addition & 1 deletion knip.jsonc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://unpkg.com/knip@next/schema.json",
"entry": ["src/*/index.ts!", "tests/**/*.test.ts"],
"entry": ["src/*/index.ts!", "tests/**/*.test.ts", "tests/**/*.test-d.ts"],
"project": ["src/**/*.ts!", "tests/**/*.ts"]
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@
"prepare": "husky install",
"release": "pnpm run release:semantic",
"release:semantic": "semantic-release",
"test": "pnpm run test:js",
"test": "pnpm run test:js && pnpm run test:types",
"test:js": "c8 ava",
"test:types": "tsd -t './dist/index.d.mts' -f 'tests/**/*.test-d.ts'",
"type-check": "tsc --noEmit"
},
"devDependencies": {
Expand Down Expand Up @@ -138,6 +139,7 @@
"ts-node": "10.9.1",
"ts-paths-esm-loader": "1.4.3",
"tsconfig-paths": "4.2.0",
"tsd": "0.28.1",
"typescript": "5.1.6"
},
"packageManager": "pnpm@8.6.6",
Expand Down
122 changes: 121 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion scripts/post-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ const filePaths = Object.values(pkg.exports).flatMap((pkgExports) => {
for (const filePath of filePaths) {
const ext = path.extname(filePath);
const importStyle = getImportStyle(ext);
const fileContent = await fs.readFile(filePath, { encoding: "utf8" });
const fileContent = await fs
.readFile(filePath, { encoding: "utf8" })
.catch(() => null);
if (fileContent === null) {
continue;
}
const updatedFileContent = [...filePathToReplacement.entries()].reduce(
(content, [toReplace, importOptions]) => {
const relFilePath = importOptions[importStyle];
Expand Down
4 changes: 2 additions & 2 deletions src/base/exponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export type NegativeExponent<T extends Exponent> = T extends -6
: T extends -2
? 2
: T extends -1
? 0
: T extends 0
? 1
: T extends 0
? 0
: T extends 1
? -1
: T extends 2
Expand Down
1 change: 1 addition & 0 deletions src/base/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export type {
MultiplyExponents,
DivideExponents,
} from "./exponents";
export { MultiplyUnitExponents, DivideUnitExponents } from "./unit-exponents";
export type { Multiply, Divide, Inverse } from "./units";

0 comments on commit 4b590d3

Please sign in to comment.