Skip to content

Commit

Permalink
feat: add types
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Mar 31, 2023
1 parent 8a440e6 commit 862b41b
Show file tree
Hide file tree
Showing 22 changed files with 4,308 additions and 10,976 deletions.
5 changes: 5 additions & 0 deletions .changeset/gentle-swans-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@marko/tags-api-preview": patch
---

Add typescript types.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node: [14, 16, 18]
node: [16, 18]
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down
15,178 changes: 4,231 additions & 10,947 deletions package-lock.json

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,44 @@
"magic-string": "^0.26.7"
},
"devDependencies": {
"@changesets/cli": "^2.25.0",
"@marko/compiler": "^5.23.0",
"@changesets/cli": "^2.26.1",
"@marko/compiler": "^5.27.4",
"@marko/fixture-snapshots": "^2.1.7",
"@marko/testing-library": "^6.1.2",
"@testing-library/user-event": "^13.5.0",
"@types/babel__code-frame": "^7.0.3",
"@types/chai": "^4.3.3",
"@types/chai": "^4.3.4",
"@types/chai-as-promised": "^7.1.5",
"@types/chai-dom": "0.0.13",
"@types/jsdom": "^20.0.0",
"@types/mocha": "^10.0.0",
"@types/node": "^18.11.5",
"@types/sinon-chai": "^3.2.8",
"@typescript-eslint/eslint-plugin": "^5.41.0",
"@typescript-eslint/parser": "^5.41.0",
"chai": "^4.3.6",
"@types/chai-dom": "1.11.0",
"@types/jsdom": "^21.1.1",
"@types/mocha": "^10.0.1",
"@types/node": "^18.15.11",
"@types/sinon-chai": "^3.2.9",
"@typescript-eslint/eslint-plugin": "^5.57.0",
"@typescript-eslint/parser": "^5.57.0",
"chai": "^4.3.7",
"chai-as-promised": "^7.1.1",
"chai-dom": "^1.11.0",
"cross-env": "^7.0.3",
"esbuild": "^0.15.12",
"eslint": "^8.26.0",
"eslint-config-prettier": "^8.5.0",
"esbuild": "^0.17.14",
"eslint": "^8.37.0",
"eslint-config-prettier": "^8.8.0",
"fast-glob": "^3.2.12",
"fixpack": "^4.0.0",
"fs-monkey": "^1.0.3",
"husky": "^8.0.1",
"jsdom": "^20.0.1",
"jsdom-context-require": "^4.0.6",
"lint-staged": "^13.0.3",
"marko": "^5.22.0",
"memfs": "^3.4.7",
"mocha": "^10.1.0",
"husky": "^8.0.3",
"jsdom": "^21.1.1",
"jsdom-context-require": "^4.0.7",
"lint-staged": "^13.2.0",
"marko": "^5.25.4",
"memfs": "^3.4.13",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"prettier": "^2.7.1",
"sinon": "^14.0.1",
"prettier": "^2.8.7",
"sinon": "^15.0.3",
"sinon-chai": "^3.7.0",
"tsx": "^3.11.0",
"typescript": "^4.8.4",
"tsx": "^3.12.6",
"typescript": "^4.9.5",
"unionfs": "^4.4.0"
},
"files": [
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/fire-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ export default {
return [k, v];
})
) as unknown as {
[Key in keyof typeof userEvent]: Promisify<typeof userEvent[Key]>;
[Key in keyof typeof userEvent]: Promisify<(typeof userEvent)[Key]>;
}),
};
7 changes: 7 additions & 0 deletions src/components/const/index.d.marko
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface Input<T> {
value: T;
}

return ...(1 as any as {
value: T;
});
1 change: 1 addition & 0 deletions src/components/const/marko-tag.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"types": "./index.d.marko",
"translate": "./translate",
"@value": {
"type": "expression",
Expand Down
3 changes: 3 additions & 0 deletions src/components/effect/index.d.marko
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface Input {
value?(): void | (() => void)
}
1 change: 1 addition & 0 deletions src/components/effect/marko-tag.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"types": "./index.d.marko",
"translate": "./translate",
"@value": {
"type": "expression",
Expand Down
2 changes: 1 addition & 1 deletion src/components/for/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export = function transform(tag: t.NodePath<t.MarkoTag>) {
const body = tag.get("body");
const { scope } = body;
const idId = scope.generateUidIdentifier("id");
const params = body.get("params");
const params = body.get("params") as any;

if (byAttr.get("value").isIdentifier()) {
byId = byAttr.node.value;
Expand Down
2 changes: 2 additions & 0 deletions src/components/get/index.d.marko
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// TODO: this could be better.
return = 1 as unknown;
1 change: 1 addition & 0 deletions src/components/id/index.d.marko
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
return = "" as string;
1 change: 1 addition & 0 deletions src/components/id/marko-tag.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"types": "./index.d.marko",
"translate": "./translate",
"attributes": {},
"autocomplete": [
Expand Down
6 changes: 6 additions & 0 deletions src/components/let/index.d.marko
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface Input<T> {
value: T
valueChange?: (newValue: T) => void
}

return=input.value valueChange=(input.valueChange!);
1 change: 1 addition & 0 deletions src/components/let/marko-tag.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"types": "./index.d.marko",
"translate": "./translate",
"@value": {
"type": "expression",
Expand Down
5 changes: 5 additions & 0 deletions src/components/lifecycle/index.d.marko
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export type Input<T extends {
onMount?(): unknown;
onUpdate?(): unknown;
onDestroy?(): unknown;
}> = T
1 change: 1 addition & 0 deletions src/components/lifecycle/marko-tag.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"types": "./index.d.marko",
"translate": "./translate",
"@onMount": {
"type": "expression",
Expand Down
4 changes: 4 additions & 0 deletions src/components/set/index.d.marko
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface Input<T> {
value: T
valueChange?: (newValue: T) => void
}
7 changes: 7 additions & 0 deletions src/components/tag/index.d.marko
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface Input<TagInput, TagReturn> {
renderBody: Marko.Body<[TagInput], TagReturn>;
}

static declare abstract class Tag<TagInput, TagReturn> extends Marko.Template<TagInput, TagReturn> {}

return = (1 as any as Tag<TagInput, TagReturn>);
1 change: 1 addition & 0 deletions src/components/tag/marko-tag.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"types": "./index.d.marko",
"translate": "./translate",
"attributes": {},
"autocomplete": [
Expand Down
2 changes: 1 addition & 1 deletion src/transform/tag-body-parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import isApi from "../util/is-api";
export default {
MarkoTag(tag) {
const body = tag.get("body");
const params = body.get("params");
const params = body.get("params") as any;
const tagDef = getTagDef(tag);

if (isApi(tag, "class") || !params.length || tagDef?.translator) {
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"declaration": true,
"incremental": true,
"module": "CommonJS",
"skipLibCheck": true,
"stripInternal": true,
"noUnusedLocals": true,
"isolatedModules": true,
Expand All @@ -21,6 +22,7 @@
"noImplicitReturns": false,
"noImplicitOverride": true,
"emitDeclarationOnly": true,
"skipDefaultLibCheck": true,
"allowUnreachableCode": false,
"importsNotUsedAsValues": "error",
"noFallthroughCasesInSwitch": true,
Expand Down

0 comments on commit 862b41b

Please sign in to comment.