@vue/tsconfig
Advanced tools
Comparing version 0.1.3 to 0.2.0
{ | ||
"name": "@vue/tsconfig", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"description": "A base TSConfig for working with Vue.js", | ||
@@ -14,3 +14,3 @@ "main": "tsconfig.json", | ||
], | ||
"author": "Haoqun Jiang <haoqunjiang+npm@gmail.com>", | ||
"author": "Haoqun Jiang <npm@haoqun.me>", | ||
"license": "MIT", | ||
@@ -21,10 +21,2 @@ "bugs": { | ||
"homepage": "https://github.com/vuejs/tsconfig#readme", | ||
"peerDependencies": { | ||
"@types/node": "*" | ||
}, | ||
"peerDependenciesMeta": { | ||
"@types/node": { | ||
"optional": true | ||
} | ||
}, | ||
"publishConfig": { | ||
@@ -35,4 +27,3 @@ "access": "public" | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"readme": "# `@vue/tsconfig`\n\nTSConfigs for Vue projects to extend.\n\nRequires TypeScript >= 4.5.\n\nInstall:\n\n```sh\nnpm add -D @vue/tsconfig\n```\n\nAdd one of the available configurations to your `tsconfig.json`:\n\nThe base configuration (runtime-agnostic):\n\n```json\n\"extends\": \"@vue/tsconfig/tsconfig.json\"\n```\n\nConfiguration for Browser environment:\n\n```json\n\"extends\": \"@vue/tsconfig/tsconfig.web.json\"\n```\n\nConfiguration for Node environment:\n\n```json\n\"extends\": \"@vue/tsconfig/tsconfig.node.json\"\n```\n" | ||
} | ||
} |
@@ -5,6 +5,8 @@ # `@vue/tsconfig` | ||
Requires TypeScript >= 4.5. | ||
Requires TypeScript >= 5.0. For TypeScript v4.5 to v4.9, please use [v0.1.x](https://www.npmjs.com/package/@vue/tsconfig/v/0.1.3). | ||
Install: | ||
[See below for the changes in v0.2.x.](#migrating-from-typescript--50) | ||
## Installation | ||
```sh | ||
@@ -14,5 +16,7 @@ npm add -D @vue/tsconfig | ||
## Usage | ||
Add one of the available configurations to your `tsconfig.json`: | ||
The base configuration (runtime-agnostic): | ||
### The Base Configuration (Runtime-agnostic) | ||
@@ -23,12 +27,65 @@ ```json | ||
Configuration for Browser environment: | ||
### Configuration for Browser Environment | ||
```json | ||
"extends": "@vue/tsconfig/tsconfig.web.json" | ||
"extends": [ | ||
"@vue/tsconfig/tsconfig.json", | ||
"@vue/tsconfig/tsconfig.dom.json" | ||
] | ||
``` | ||
Configuration for Node environment: | ||
### Configuration for Node Environments | ||
First install the base tsconfig and types for the Node.js version you are targeting, for example: | ||
```sh | ||
npm add -D @tsconfig/node18 @types/node@18 | ||
``` | ||
Then extend the Node.js tsconfig and the Vue tsconfig in your `tsconfig.json`: | ||
```json | ||
"extends": "@vue/tsconfig/tsconfig.node.json" | ||
"extends": [ | ||
"@tsconfig/node18/tsconfig.json", | ||
"@vue/tsconfig/tsconfig.json" | ||
], | ||
"compilerOptions": [ | ||
"types": ["node"] | ||
] | ||
``` | ||
Make sure to place `@vue/tsconfig/tsconfig.json` *after* `@tsconfig/node18/tsconfig.json` so that it takes precedence. | ||
## Migrating from TypeScript < 5.0 | ||
- The usage of base `tsconfig.json` is unchanged. | ||
- `tsconfig.web.json` is now renamed to `tsconfig.dom.json`, to align with `@vue/runtime-dom` and `@vue/compiler-dom`, and it only contains dom-specific options, you need to use it in conjunction with the base `tsconfig.json`: | ||
```json | ||
"extends": [ | ||
"@vue/tsconfig/tsconfig.json", | ||
"@vue/tsconfig/tsconfig.dom.json" | ||
] | ||
``` | ||
- `tsconfig.node.json` is removed, please read the [Node.js section](#configuration-for-node-environments) above for Node.js usage. | ||
Some configurations have been updated, which might affect your projects: | ||
- `moduleResolution` changed from `node` to [`bundler`](https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#moduleresolution-bundler) | ||
- The `lib` option in `tsconfig.dom.json` now includes `ES2020` by default. | ||
- Previously it was ES2016, which was the lowest ES version that Vue 3 supports. | ||
- Vite 4 transpiles down to ES2020 by default, this new default is to align with the build tool. | ||
- This change won't throw any new errors on your existing code, but if you are targeting old browsers and want TypeScript to throw errors on newer features used, you can override the `lib` option in your `tsconfig.json`: | ||
```json | ||
{ | ||
"extends": [ | ||
"@vue/tsconfig/tsconfig.json", | ||
"@vue/tsconfig/tsconfig.dom.json" | ||
], | ||
"compilerOptions": { | ||
"lib": ["ES2016", "DOM", "DOM.Iterable"] | ||
} | ||
} | ||
``` |
{ | ||
"compilerOptions": { | ||
// As long as you are using a build tool, we recommend you to author and ship in ES modules. | ||
// Even if you are targeting Node.js, because | ||
// - `CommonJS` is too outdated | ||
// - the ecosystem hasn't fully caught up with `Node16`/`NodeNext` | ||
// This recommendation includes environments like Vitest, Vite Config File, Vite SSR, etc. | ||
"module": "ESNext", | ||
"moduleResolution": "Node", | ||
"moduleResolution": "bundler", | ||
"resolveJsonModule": true, | ||
"allowImportingTsExtensions": true, | ||
"useDefineForClassFields": true, | ||
@@ -19,8 +26,8 @@ | ||
"isolatedModules": true, | ||
// For `<script setup>` | ||
// See <https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-beta/#preserve-value-imports> | ||
"preserveValueImports": true, | ||
// Enforce using `import type` instead of `import` for types | ||
"importsNotUsedAsValues": "error", | ||
// <https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#verbatimmodulesyntax> | ||
// Any imports or exports without a type modifier are left around. This is important for `<script setup>`. | ||
// Anything that uses the type modifier is dropped entirely. | ||
"verbatimModuleSyntax": true, | ||
// A few notes: | ||
@@ -27,0 +34,0 @@ // - Vue 3 supports ES2016+ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6803
0
89
58
1