├── .gitattributes ├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .npmrc ├── .prettierignore ├── .vscode ├── extensions.json ├── launch.json ├── settings.json └── tasks.json ├── .vscodeignore ├── LICENSE ├── README.md ├── assets └── logo.png ├── package.json ├── pnpm-lock.yaml ├── scripts ├── esbuild.ts └── tsconfig.json ├── src ├── extension.ts └── tsconfig.json ├── test-workspace ├── .vscode │ └── settings.json ├── app │ └── page.ts ├── package.json ├── pages │ └── index.ts └── pnpm-lock.yaml ├── test ├── index.ts ├── runTests.ts ├── sample.test.ts └── tsconfig.json ├── tsconfig.base.json ├── yarn-error.log └── yarn.lock /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | permissions: 4 | contents: write 5 | 6 | on: 7 | push: 8 | branches: 9 | - main 10 | 11 | jobs: 12 | test: 13 | strategy: 14 | matrix: 15 | os: [macos-latest, ubuntu-latest, windows-latest] 16 | runs-on: ${{ matrix.os }} 17 | outputs: 18 | GIT_TAG: ${{ steps.set-tag.outputs.GIT_TAG }} 19 | steps: 20 | - name: Checkout 21 | uses: actions/checkout@v4 22 | 23 | - name: Install Node.js 24 | uses: actions/setup-node@v4 25 | with: 26 | node-version: 20.x 27 | 28 | - name: Install pnpm 29 | uses: pnpm/action-setup@v3 30 | id: pnpm-install 31 | with: 32 | version: 8 33 | run_install: false 34 | 35 | - name: Get pnpm store directory 36 | id: pnpm-cache 37 | shell: bash 38 | run: | 39 | echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT 40 | 41 | - name: Setup pnpm cache 42 | uses: actions/cache@v4 43 | with: 44 | path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} 45 | key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} 46 | restore-keys: ${{ runner.os }}-pnpm-store- 47 | 48 | - name: Install dependencies 49 | run: pnpm install --frozen-lockfile --no-optional 50 | 51 | - name: Get the date on Ubuntu/MacOS 52 | id: date_unix 53 | if: runner.os != 'Windows' 54 | run: echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT 55 | 56 | - name: Get the date on Windows 57 | id: date_windows 58 | if: runner.os == 'Windows' 59 | run: echo "DATE=$(Get-Date -Format 'yyyyMMdd')" >> $GITHUB_OUTPUT 60 | 61 | - name: Cache .vscode-test 62 | uses: actions/cache@v4 63 | env: 64 | # we use date as part of key because the vscode insiders updated daily 65 | CACHE_PREFIX: ${{ runner.os }}-vscode-test-${{ steps.date_unix.outputs.DATE || steps.date_windows.outputs.DATE }} 66 | with: 67 | path: .vscode-test 68 | key: ${{ env.CACHE_PREFIX }}-${{ hashFiles('test/runTests.ts') }} 69 | restore-keys: ${{ env.CACHE_PREFIX }} 70 | 71 | - run: xvfb-run -a pnpm test 72 | if: runner.os == 'Linux' 73 | - run: pnpm test 74 | if: runner.os != 'Linux' 75 | 76 | - name: Set GIT_TAG 77 | id: set-tag 78 | if: runner.os == 'Linux' 79 | run: | 80 | git fetch --tags origin 81 | GIT_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") 82 | if [ -n "$GIT_TAG" ] && [ "$(git rev-list -n 1 $GIT_TAG 2>/dev/null || echo "")" = "$(git rev-parse HEAD)" ]; then 83 | echo "GIT_TAG=${GIT_TAG}" >> $GITHUB_OUTPUT 84 | else 85 | echo "GIT_TAG=''" >> $GITHUB_OUTPUT 86 | fi 87 | 88 | publish: 89 | needs: test 90 | if: startsWith(needs.test.outputs.GIT_TAG, 'v') 91 | runs-on: ubuntu-latest 92 | steps: 93 | - name: Checkout 94 | uses: actions/checkout@v4 95 | with: 96 | fetch-depth: 0 97 | 98 | - name: Install Node.js 99 | uses: actions/setup-node@v4 100 | with: 101 | node-version: 20.x 102 | 103 | - name: Install pnpm 104 | uses: pnpm/action-setup@v3 105 | id: pnpm-install 106 | with: 107 | version: 8 108 | run_install: false 109 | 110 | - name: Get pnpm store directory 111 | id: pnpm-cache 112 | shell: bash 113 | run: | 114 | echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT 115 | 116 | - name: Setup pnpm cache 117 | uses: actions/cache@v4 118 | with: 119 | path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} 120 | key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} 121 | restore-keys: | 122 | ${{ runner.os }}-pnpm-store- 123 | 124 | - name: Install dependencies 125 | run: pnpm install --frozen-lockfile --no-optional 126 | 127 | - name: Publish to Visual Studio Marketplace 128 | run: pnpm run publish:vs-marketplace 129 | env: 130 | VSCE_PAT: ${{ secrets.VS_MARKETPLACE_TOKEN }} 131 | 132 | - name: Publish to Open VSX Registry 133 | run: pnpm run publish:open-vsx -p ${{ secrets.OPEN_VSX_TOKEN }} 134 | 135 | - name: Github Release 136 | run: npx changelogithub 137 | env: 138 | GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} 139 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | out 2 | node_modules 3 | .vscode-test/ 4 | *.vsix 5 | 6 | # esbuild-visualizer 7 | meta.json 8 | stats.html 9 | 10 | .DS_Store -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | registry="https://registry.npmmirror.com/" 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | test-workspace -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 3 | // for the documentation about the extensions.json format 4 | "recommendations": [ 5 | "dbaeumer.vscode-eslint", 6 | "esbenp.prettier-vscode", 7 | "connor4312.esbuild-problem-matchers", 8 | "github.vscode-github-actions", 9 | "YuTengjing.vscode-archive" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that compiles the extension and then opens it inside a new window 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | { 6 | "version": "0.2.0", 7 | "configurations": [ 8 | { 9 | "name": "Dev", 10 | "type": "extensionHost", 11 | "request": "launch", 12 | "args": [ 13 | "--disable-extensions", 14 | "--extensionDevelopmentPath=${workspaceFolder}", 15 | "${workspaceFolder}/test-workspace" 16 | ], 17 | "outFiles": ["${workspaceFolder}/out/**/*.js"], 18 | "skipFiles": [ 19 | "/**", 20 | "**/node_modules/**", 21 | "**/resources/app/out/vs/**", 22 | "**/.vscode-insiders/extensions/", 23 | "**/.vscode/extensions/" 24 | ], 25 | "sourceMaps": true, 26 | "env": { 27 | "VSCODE_DEBUG_MODE": "true" 28 | }, 29 | "preLaunchTask": "${defaultBuildTask}" 30 | }, 31 | { 32 | "name": "Test", 33 | "type": "extensionHost", 34 | "request": "launch", 35 | "outFiles": ["${workspaceFolder}/out/test/**/*.js"], 36 | "skipFiles": [ 37 | "/**", 38 | "**/node_modules/**", 39 | "**/resources/app/out/vs/**", 40 | "**/.vscode-insiders/extensions/", 41 | "**/.vscode/extensions/" 42 | ], 43 | "sourceMaps": true, 44 | "args": [ 45 | "--extensionDevelopmentPath=${workspaceFolder}", 46 | "--extensionTestsPath=${workspaceFolder}/out/test/" 47 | ], 48 | "env": { 49 | "VSCODE_DEBUG_MODE": "true" 50 | }, 51 | "preLaunchTask": "compile:test" 52 | } 53 | ] 54 | } 55 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "eslint.validate": ["typescript", "json", "jsonc", "markdown"] 3 | } 4 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // See https://go.microsoft.com/fwlink/?LinkId=733558 2 | // for the documentation about the tasks.json format 3 | { 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "type": "npm", 8 | "script": "esbuild:watch", 9 | "problemMatcher": "$esbuild-watch", 10 | "isBackground": true, 11 | "group": { 12 | "kind": "build", 13 | "isDefault": true 14 | } 15 | }, 16 | { 17 | "label": "compile:test", 18 | "type": "npm", 19 | "script": "compile:test", 20 | "problemMatcher": "$tsc" 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | # source 2 | src 3 | scripts 4 | assets 5 | !assets/logo.png 6 | 7 | node_modules/**/caniuse-lite 8 | node_modules/**/*.md 9 | node_modules/**/.github/**/* 10 | node_modules/**/*.d.ts 11 | node_modules/**/*.js.map 12 | node_modules/@next/**/*.node 13 | node_modules/@swc/helpers/esm 14 | node_modules/next/**/*.wasm 15 | node_modules/@vercel/og 16 | node_modules/next/dist/compiled/**/*.production.js 17 | node_modules/next/dist/compiled/**/*.production.min.js 18 | node_modules/next/dist/esm 19 | node_modules/next/dist/compiled/react-experimental 20 | node_modules/next/dist/compiled/react-dom-experimental 21 | node_modules/next/dist/compiled/react-server-dom-webpack-experimental 22 | node_modules/next/dist/compiled/react-server-dom-turbopack 23 | node_modules/next/dist/compiled/react-server-dom-turbopack-experimental 24 | 25 | # output 26 | out 27 | !out/src/extension.js 28 | *.map 29 | *.vsix 30 | 31 | # test 32 | test 33 | test-workspace 34 | .vscode-test 35 | 36 | # configs 37 | .github 38 | .vscode 39 | tsconfig.* 40 | .eslintrc* 41 | .prettier* 42 | .gitignore 43 | pnpm-lock.yaml 44 | 45 | # esbuild-visualizer 46 | meta.json 47 | stats.html 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 YuTengjing 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Always-On Next.js TypeScript Plugin 2 | 3 | [**Install the extension**](https://marketplace.visualstudio.com/items?itemName=shuding.next-ts-plugin-vscode) 4 | 5 | When this VS Code extension is enabled, it will automatically use the [built-in TypeScript plugin](https://nextjs.org/docs/app/building-your-application/configuring/typescript#typescript-plugin) for all your Next.js projects. 6 | 7 | Learn more about the Next.js TypeScript Plugin: https://www.youtube.com/watch?v=pqMqn9fKEf8. 8 | 9 | ## Note 10 | 11 | This is not an official Next.js extension. Without it, you can manually switch to use the Workspace TypeScript version when you open a new Next.js project to start using the official Next.js plugin. This is due to a current VS Code limitation. 12 | 13 | The extension only automates this process, without any other changes. 14 | -------------------------------------------------------------------------------- /assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shuding/next-ts-plugin-vscode/499cb6c540930113854cd74344806ca8e15070cc/assets/logo.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "next-ts-plugin-vscode", 3 | "displayName": "Always-on Next.js TypeScript Plugin", 4 | "version": "0.0.5", 5 | "description": "Always-on Next.js TypeScript Plugin in VSCode", 6 | "publisher": "shuding", 7 | "private": true, 8 | "preview": false, 9 | "author": { 10 | "name": "shuding", 11 | "email": "g@shud.in", 12 | "url": "https://github.com/shuding" 13 | }, 14 | "license": "SEE LICENSE IN LICENSE", 15 | "homepage": "https://github.com/shuding/next-ts-plugin-vscode", 16 | "repository": { 17 | "type": "git", 18 | "url": "https://github.com/shuding/next-ts-plugin-vscode" 19 | }, 20 | "bugs": { 21 | "url": "https://github.com/shuding/next-ts-plugin-vscode/issues", 22 | "email": "g@shud.in" 23 | }, 24 | "keywords": ["next.js"], 25 | "categories": ["Other"], 26 | "main": "./out/src/extension.js", 27 | "icon": "assets/logo.png", 28 | "engines": { 29 | "vscode": "^1.45.0" 30 | }, 31 | "badges": [], 32 | "activationEvents": [], 33 | "contributes": { 34 | "typescriptServerPlugins": [ 35 | { 36 | "name": "next" 37 | } 38 | ] 39 | }, 40 | "eslintConfig": { 41 | "extends": "@yutengjing/eslint-config-typescript", 42 | "ignorePatterns": ["test-workspace"] 43 | }, 44 | "lint-staged": { 45 | "*.{ts,json,md}": ["eslint --fix", "prettier --write"] 46 | }, 47 | "simple-git-hooks": { 48 | "pre-commit": "pnpx lint-staged" 49 | }, 50 | "scripts": { 51 | "vscode:prepublish": "pnpm esbuild:base --minify", 52 | "preinstall": "pnpx only-allow pnpm", 53 | "postinstall": "stale-dep -u", 54 | "prepare": "simple-git-hooks", 55 | "clean": "pnpx rimraf -rf ./out", 56 | "esbuild:base": "stale-dep && tsx scripts/esbuild.ts", 57 | "esbuild:watch": "pnpm esbuild:base --sourcemap --watch", 58 | "esbuild:analyze": "pnpm esbuild:base --minify --metafile --analyze && esbuild-visualizer --metadata ./meta.json --open", 59 | "compile:test": "pnpm clean && tsc -b ./test/tsconfig.json", 60 | "lint": "eslint src --ext ts", 61 | "test": "stale-dep && pnpm compile:test && node ./out/test/runTests.js", 62 | "package": "vsce package --yarn", 63 | "release": "pnpx @yutengjing/release", 64 | "publish:vs-marketplace": "vsce publish --yarn", 65 | "publish:open-vsx": "ovsx publish --no-dependencies" 66 | }, 67 | "devDependencies": { 68 | "@types/glob": "^8.1.0", 69 | "@types/mocha": "^10.0.6", 70 | "@types/node": "^20.11.20", 71 | "@types/vscode": "^1.45.0", 72 | "@vscode/test-electron": "^2.3.9", 73 | "@vscode/vsce": "^2.24.0", 74 | "@yutengjing/eslint-config-typescript": "^0.5.2", 75 | "@yutengjing/prettier-config": "^1.1.2", 76 | "@yutengjing/release": "^0.2.0", 77 | "@yutengjing/tsconfig-node": "^0.0.5", 78 | "esbuild": "^0.20.1", 79 | "esbuild-visualizer": "^0.6.0", 80 | "eslint": "^8.57.0", 81 | "glob": "^10.3.10", 82 | "lint-staged": "^15.2.2", 83 | "mocha": "^10.3.0", 84 | "ovsx": "^0.8.3", 85 | "prettier": "^3.2.5", 86 | "rimraf": "^5.0.5", 87 | "simple-git-hooks": "^2.9.0", 88 | "stale-dep": "^0.7.0", 89 | "tsx": "^4.7.1", 90 | "typescript": "^5.3.3" 91 | }, 92 | "dependencies": { 93 | "next": "canary" 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /scripts/esbuild.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env tsx 2 | 3 | import fs from 'node:fs/promises'; 4 | import path from 'node:path'; 5 | 6 | import type { BuildContext, BuildOptions } from 'esbuild'; 7 | import esbuild from 'esbuild'; 8 | 9 | const isWatchMode = process.argv.includes('--watch'); 10 | const options: BuildOptions = { 11 | color: true, 12 | logLevel: 'info', 13 | entryPoints: ['src/extension.ts'], 14 | bundle: true, 15 | metafile: process.argv.includes('--metafile'), 16 | outdir: './out/src', 17 | external: [ 18 | 'vscode', 19 | 'typescript', // vue-component-meta 20 | ], 21 | format: 'cjs', 22 | platform: 'node', 23 | target: 'ESNext', 24 | tsconfig: './src/tsconfig.json', 25 | sourcemap: process.argv.includes('--sourcemap'), 26 | minify: process.argv.includes('--minify'), 27 | plugins: [ 28 | { 29 | name: 'umd2esm', 30 | setup(build) { 31 | build.onResolve({ filter: /^(vscode-.*|estree-walker|jsonc-parser)/ }, (args) => { 32 | const pathUmdMay = require.resolve(args.path, { 33 | paths: [args.resolveDir], 34 | }); 35 | // Call twice the replace is to solve the problem of the path in Windows 36 | const pathEsm = pathUmdMay 37 | .replace('/umd/', '/esm/') 38 | .replace('\\umd\\', '\\esm\\'); 39 | return { path: pathEsm }; 40 | }); 41 | }, 42 | }, 43 | { 44 | name: 'meta', 45 | setup(build) { 46 | build.onEnd(async (result) => { 47 | if (result.metafile && result.errors.length === 0) { 48 | return fs.writeFile( 49 | path.resolve(__dirname, '../meta.json'), 50 | JSON.stringify(result.metafile), 51 | ); 52 | } 53 | }); 54 | }, 55 | }, 56 | ], 57 | }; 58 | 59 | async function main() { 60 | let ctx: BuildContext | undefined; 61 | try { 62 | if (isWatchMode) { 63 | ctx = await esbuild.context(options); 64 | await ctx.watch(); 65 | } else { 66 | const result = await esbuild.build(options); 67 | if (process.argv.includes('--analyze')) { 68 | const chunksTree = await esbuild.analyzeMetafile(result.metafile!, { color: true }); 69 | console.log(chunksTree); 70 | } 71 | } 72 | } catch (error) { 73 | console.error(error); 74 | ctx?.dispose(); 75 | process.exit(1); 76 | } 77 | } 78 | 79 | main(); 80 | -------------------------------------------------------------------------------- /scripts/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "include": ["**/*.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /src/extension.ts: -------------------------------------------------------------------------------- 1 | export function activate() {} 2 | export function deactivate() {} 3 | -------------------------------------------------------------------------------- /src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "outDir": "../out/src" 5 | }, 6 | "include": ["**/*.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /test-workspace/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "typescript.tsdk": "node_modules/typescript/lib" 3 | } -------------------------------------------------------------------------------- /test-workspace/app/page.ts: -------------------------------------------------------------------------------- 1 | import { useState } from 'react' 2 | 3 | export default function Page () { 4 | const [state] = useState(0) 5 | return 'hello' 6 | } 7 | -------------------------------------------------------------------------------- /test-workspace/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test-workspace", 3 | "devDependencies": { 4 | "typescript": "^5.4.2" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test-workspace/pages/index.ts: -------------------------------------------------------------------------------- 1 | import { useState } from 'react' 2 | 3 | export default function Page () { 4 | const [state] = useState(0) 5 | return 'hello' 6 | } 7 | -------------------------------------------------------------------------------- /test-workspace/pnpm-lock.yaml: -------------------------------------------------------------------------------- 1 | lockfileVersion: '6.0' 2 | 3 | settings: 4 | autoInstallPeers: true 5 | excludeLinksFromLockfile: false 6 | 7 | devDependencies: 8 | typescript: 9 | specifier: ^5.4.2 10 | version: 5.4.2 11 | 12 | packages: 13 | 14 | /typescript@5.4.2: 15 | resolution: {integrity: sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==} 16 | engines: {node: '>=14.17'} 17 | hasBin: true 18 | dev: true 19 | -------------------------------------------------------------------------------- /test/index.ts: -------------------------------------------------------------------------------- 1 | import path from 'node:path'; 2 | 3 | import { glob } from 'glob'; 4 | import Mocha from 'mocha'; 5 | 6 | /** 7 | * !: must be synchronized 8 | */ 9 | export function run(testsRoot: string, cb: (error: any, failures?: number) => void): void { 10 | const mocha = new Mocha({ color: true }); 11 | 12 | glob('**/**.test.js', { cwd: testsRoot }) 13 | .then((files) => { 14 | for (const f of files) mocha.addFile(path.resolve(testsRoot, f)); 15 | 16 | try { 17 | mocha.run((failures) => { 18 | cb(null, failures); 19 | }); 20 | } catch (error) { 21 | cb(error); 22 | } 23 | }) 24 | .catch((error) => cb(error)); 25 | } 26 | -------------------------------------------------------------------------------- /test/runTests.ts: -------------------------------------------------------------------------------- 1 | import { resolve } from 'node:path'; 2 | 3 | import { runTests } from '@vscode/test-electron'; 4 | 5 | (async function go() { 6 | const projectPath = resolve(__dirname, '../../'); 7 | const extensionDevelopmentPath = projectPath; 8 | const extensionTestsPath = resolve(projectPath, './out/test'); 9 | const testWorkspace = resolve(projectPath, './test-workspace'); 10 | 11 | await runTests({ 12 | version: 'insiders', 13 | extensionDevelopmentPath, 14 | extensionTestsPath, 15 | launchArgs: ['--disable-extensions', testWorkspace], 16 | }); 17 | })(); 18 | -------------------------------------------------------------------------------- /test/sample.test.ts: -------------------------------------------------------------------------------- 1 | import { strictEqual } from 'node:assert'; 2 | 3 | import vscode from 'vscode'; 4 | 5 | describe('#test sample', () => { 6 | before(() => { 7 | vscode.window.showInformationMessage('Test begin!'); 8 | }); 9 | 10 | it('one plus one equals two', () => { 11 | strictEqual(2, 1 + 1); 12 | }); 13 | 14 | after(() => { 15 | vscode.window.showInformationMessage('Test end!'); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "outDir": "../out/test" 5 | }, 6 | "include": ["**/*.ts"], 7 | "references": [ 8 | { 9 | "path": "../src/tsconfig.json" 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "sourceMap": true, 5 | 6 | /* Basic Options */ 7 | "target": "ES2022", 8 | "module": "commonjs", 9 | 10 | /* Strict Type-Checking Options */ 11 | "strict": true, 12 | 13 | /* Additional Checks */ 14 | "noImplicitReturns": true, 15 | "noFallthroughCasesInSwitch": true, 16 | 17 | /* Module Resolution Options */ 18 | "moduleResolution": "node", 19 | "esModuleInterop": true, 20 | "resolveJsonModule": true, 21 | 22 | /* Experimental Options */ 23 | "experimentalDecorators": true, 24 | "emitDecoratorMetadata": true, 25 | 26 | /* Advanced Options */ 27 | "forceConsistentCasingInFileNames": true, 28 | "skipLibCheck": true 29 | } 30 | } 31 | --------------------------------------------------------------------------------