mkdir my-project
cd my-project
yarn init -2
yarn set version stable
yarn install
yarn add -D eslint @eslint/js typescript typescript-eslint @types/node tsx prettier
Add the following properties to it. Check the version of nodejs you are using first
{
"engines": {
"node": "22.14.0"
},
"scripts": {
"build": "tsc -p .",
"watch": "tsx watch --include 'src/**/*.ts' src/index.ts",
"lint": "eslint ."
},
"type": "module"
}
{
"compilerOptions": {
"strict": true,
"declaration": true,
"module": "NodeNext",
"moduleResolution": "nodenext",
"sourceMap": true,
"noImplicitAny": true,
"removeComments": true,
"useUnknownInCatchVariables": false,
"noEmitOnError": true,
"baseUrl": "./src",
"outDir": "./dist",
"target": "ES2022"
},
"include": ["src/**/*"]
}
{
"singleQuote": true,
"tabWidth": 2,
"printWidth": 100
}
// @ts-check
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
export default tseslint.config(
{ ignores: ['node_modules/**', '.yarn/**', '.pnp.*', 'dist/**'] },
eslint.configs.recommended,
tseslint.configs.recommended,
{
languageOptions: {
globals: {
console: 'readonly',
process: 'readonly',
},
parserOptions: {
ecmaVersion: 'latest',
},
},
files: ['src/**'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
},
},
);
VSCode requires special configuration for TypeScript to work when using Plug'n'Play installs. Open the project in VS Code
- ZipFS (arcanis.vscode-zipfs) VS Code extension is needed
- run
yarn dlx @yarnpkg/sdks vscode
which creates a .vscode folder - VSCode requires you to explicitly activate the custom TS settings
- Press
ctrl+shift+p
in a TypeScript file - Choose "Select TypeScript Version"
- Pick "Use Workspace Version"
- Press
Other recommended extensions for VS Code
- ESLint (dbaeumer.vscode-eslint)
- Prettier (esbenp.prettier-vscode)