1.4.4 β’ Published 1 month ago
jswt v1.4.4
JS with Types
Turn on transpile-free type hinting for your vanilla JS projects #JSWithTypes
- Create a plain JavaScript project
npm init
- Turn on type linting πͺ
# Create a properly configured `jsconfig.json` npx jswt init
- Profit!
Works with VS Code out-of-the-box, and Vim + ale.
Watch the Presentation!
Layout
Your project will look something like this:
.
βββ bin/
βββ jsconfig.json
βββ node_modules/
β βββ @types/
β βββ node/
βββ package-lock.json
βββ package.json
βββ README.md
βββ types.js
βββ typings/
βββ overrides/
βββ index.d.ts
Inner Workings
- Runs
tsc --init
with these options:npx -p typescript@4 -- \ tsc --init \ --allowJs --alwaysStrict --checkJs \ --moduleResolution node \ --noEmit --noImplicitAny --target es2022 \ --typeRoots './typings,./node_modules/@types'
- Adds the following keys:
"include": ["*.js", "bin/**/*.js", "lib/**/*.js", "src/**/*.js"]` "exclude": ["node_modules"]
- Renames
tsconfig.json
tojsconfig.json
\ (and creates some placeholder files and dirs)
Bonus: npm run lint
You may wish to add common script commands for fmt
and lint
:
npm pkg set scripts.lint="npx -p typescript@4 -- tsc -p ./jsconfig.json"
npm pkg set scripts.fmt="npx -p prettier@2 -- prettier -w '**/*.{js,md}'"
Bonus: Vim Config
It should Just Workβ’, but if your vim setup is a little custom, you may want to add or modify a line like this:
~/.vimrc
:
let g:ale_linters = {
\ 'javascript': ['tsserver', 'jshint'],
\ 'json': ['fixjson']
\}
1.4.4
1 month ago
1.4.3
1 month ago
1.4.2
3 months ago
1.4.1
3 months ago
1.4.0
3 months ago
1.2.0
3 months ago
1.1.7
3 months ago
1.3.1
3 months ago
1.2.1
3 months ago
1.1.6
4 months ago
1.1.5
2 years ago
1.1.4
2 years ago
1.1.3
2 years ago
1.1.2
2 years ago
1.1.1
2 years ago
1.1.0
2 years ago
1.1.0-1
2 years ago
1.1.0-0
2 years ago