Skip to content

Commit

Permalink
Add types
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Oct 22, 2024
1 parent 0f59c9f commit 102ccfa
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
dest/
node_modules/
*.d.ts
*.log
*.map
*.tsbuildinfo
.DS_Store
yarn.lock
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"strip-markdown": "^6.0.0",
"stylelint": "^16.0.0",
"stylelint-config-standard": "^36.0.0",
"type-coverage": "^2.0.0",
"typescript": "^5.0.0",
"unified": "^11.0.0",
"xo": "^0.59.0"
},
Expand Down Expand Up @@ -53,16 +55,21 @@
]
},
"repository": "remarkjs/strip-markdown",
"typeCoverage": {
"atLeast": 100,
"strict": true
},
"type": "module",
"scripts": {
"build": "tsc --build --clean && tsc --build && type-coverage",
"format": "remark --frail --output --quiet -- . && prettier --log-level warn --write -- . && xo && stylelint src/index.css --fix",
"generate:css": "postcss --output dest/index.css -- src/index.css",
"generate:html": "rehype --output dest/ --use rehype-preset-minify --use rehype-prevent-favicon-request -- src/",
"generate:js:module": "esbuild src/index.js --bundle --conditions=browser,production --define:process.env.NODE_ENV=\\\"production\\\" --format=esm --loader:.js=jsx --log-level=warning --minify --outfile=dest/index.module.js --target=es2020",
"generate:js:nomodule": "esbuild src/index.js --bundle --conditions=browser,production --define:process.env.NODE_ENV=\\\"production\\\" --loader:.js=jsx --log-level=warning --minify --outfile=dest/index.nomodule.js --target=es6",
"generate:js": "npm run generate:js:module && npm run generate:js:nomodule",
"generate": "npm run generate:css && npm run generate:html && npm run generate:js",
"test": "npm run format && npm run generate"
"test": "npm run build && npm run format && npm run generate"
},
"stylelint": {
"extends": "stylelint-config-standard"
Expand Down
10 changes: 7 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ const processor = unified()
.use(remarkStringify)
.use(stripMarkdown)

const $input = document.querySelector('[autofocus]')
const $output = document.querySelector('[readonly]')
const $input = /** @type {HTMLTextAreaElement} */ (
document.querySelector('[autofocus]')
)
const $output = /** @type {HTMLTextAreaElement} */ (
document.querySelector('[readonly]')
)

$input.addEventListener('input', oninputchange)

oninputchange()

function oninputchange() {
$output.textContent = processor.processSync($input.value).toString()
$output.textContent = String(processor.processSync($input.value))
}
16 changes: 16 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"checkJs": true,
"customConditions": ["development"],
"declarationMap": true,
"declaration": true,
"emitDeclarationOnly": true,
"exactOptionalPropertyTypes": true,
"lib": ["dom", "es2023"],
"module": "node16",
"strict": true,
"target": "es2023"
},
"exclude": ["dest/", "node_modules/"],
"include": ["**/*.js"]
}

0 comments on commit 102ccfa

Please sign in to comment.