Skip to content

Commit

Permalink
test: assert types for Svelte 3, 4, 5
Browse files Browse the repository at this point in the history
  • Loading branch information
metonym committed Dec 27, 2024
1 parent 3d470e6 commit cc3270b
Show file tree
Hide file tree
Showing 16 changed files with 174 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ jobs:
- name: Build package
run: bun run prepack

- name: Test types
run: bun run test:types

- name: Trigger deploy
if: github.ref == 'refs/heads/master'
env:
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
}
},
"scripts": {
"prepack": "bun test"
"prepack": "bun test",
"test:types": "bun tests/test-types.ts"
},
"devDependencies": {
"@carbon/icon-helpers": "latest",
Expand Down
35 changes: 35 additions & 0 deletions tests/svelte@3/Icons.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<script lang="ts">
import {
Add,
Assembly,
Beta,
BookmarkAdd,
BreakingChange,
LogoSvelte,
Plan,
ZSystems,
BatchJob,
} from "carbon-icons-svelte";
import type { CarbonIconProps } from "carbon-icons-svelte";
import Icon from "carbon-icons-svelte/lib/Accessibility.svelte";
const props: CarbonIconProps = {
size: 32,
fill: "red",
};
const icon = new Icon({ target: document.body, props });
$: console.log(icon.$$prop_def);
$: console.log(typeof Assembly);
</script>

<Add size={20} fill="red" title="title" data-test="id" />
<Icon style={null} />
<BookmarkAdd />
<BreakingChange />
<LogoSvelte />
<Plan />
<ZSystems />
<BatchJob />
<svelte:component this={Beta} />
Binary file added tests/svelte@3/bun.lockb
Binary file not shown.
15 changes: 15 additions & 0 deletions tests/svelte@3/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"private": true,
"type": "module",
"scripts": {
"test:types": "svelte-check"
},
"dependencies": {
"carbon-icons-svelte": "link:carbon-icons-svelte"
},
"devDependencies": {
"svelte": "^3.59.2",
"svelte-check": "^3.8.6",
"typescript": "^5.7.2"
}
}
15 changes: 15 additions & 0 deletions tests/svelte@3/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"verbatimModuleSyntax": true,
"isolatedModules": true,
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true,
"skipLibCheck": true
}
}
35 changes: 35 additions & 0 deletions tests/svelte@4/Icons.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<script lang="ts">
import {
Add,
Assembly,
Beta,
BookmarkAdd,
BreakingChange,
LogoSvelte,
Plan,
ZSystems,
BatchJob,
} from "carbon-icons-svelte";
import type { CarbonIconProps } from "carbon-icons-svelte";
import Icon from "carbon-icons-svelte/lib/Accessibility.svelte";
const props: CarbonIconProps = {
size: 32,
fill: "red",
};
const icon = new Icon({ target: document.body, props });
$: console.log(icon.$$prop_def);
$: console.log(typeof Assembly);
</script>

<Add size={20} fill="red" title="title" data-test="id" />
<Icon style={null} />
<BookmarkAdd />
<BreakingChange />
<LogoSvelte />
<Plan />
<ZSystems />
<BatchJob />
<svelte:component this={Beta} />
Binary file added tests/svelte@4/bun.lockb
Binary file not shown.
15 changes: 15 additions & 0 deletions tests/svelte@4/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"private": true,
"type": "module",
"scripts": {
"test:types": "svelte-check"
},
"dependencies": {
"carbon-icons-svelte": "link:carbon-icons-svelte"
},
"devDependencies": {
"svelte": "^4.2.19",
"svelte-check": "^4.1.1",
"typescript": "^5.7.2"
}
}
15 changes: 15 additions & 0 deletions tests/svelte@4/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"verbatimModuleSyntax": true,
"isolatedModules": true,
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true,
"skipLibCheck": true
}
}
File renamed without changes.
Binary file added tests/svelte@5/bun.lockb
Binary file not shown.
15 changes: 15 additions & 0 deletions tests/svelte@5/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"private": true,
"type": "module",
"scripts": {
"test:types": "svelte-check"
},
"dependencies": {
"carbon-icons-svelte": "link:carbon-icons-svelte"
},
"devDependencies": {
"svelte": "^5.16.0",
"svelte-check": "^4.1.1",
"typescript": "^5.7.2"
}
}
15 changes: 15 additions & 0 deletions tests/svelte@5/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"verbatimModuleSyntax": true,
"isolatedModules": true,
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true,
"skipLibCheck": true
}
}
8 changes: 8 additions & 0 deletions tests/test-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { $ } from "bun";

for await (const dir of $`find tests -maxdepth 1 -mindepth 1 -type d`.lines()) {
if (dir && /svelte/.test(dir)) {
await $`cd ${dir} && bun install`;
await $`cd ${dir} && bun run test:types`;
}
}
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"compilerOptions": {
"esModuleInterop": true,
"lib": ["esnext", "DOM"],
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
Expand Down

0 comments on commit cc3270b

Please sign in to comment.