Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: turn on noEmit by default and add tsconfig.lib.json #26

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ Otherwise, if you are trying to use Vue components in Node.js environments (e.g.

Make sure to place `@vue/tsconfig/tsconfig.json` *after* `@tsconfig/node18/tsconfig.json` so that it takes precedence.

## Emitting Declaration Files

As most Vue projects are built with bundlers, the default Vue TSConfig does not emit declaration files. If you are building a library or a component library, you can enable declaration file emitting by also extending `@vue/tsconfig/tsconfig.lib.json` in your `tsconfig.json`:

```json
"extends": [
"@vue/tsconfig/tsconfig.dom.json",
"@vue/tsconfig/tsconfig.lib.json"
]
```

## Migrating from TypeScript < 5.0

- The usage of base `tsconfig.json` is unchanged.
Expand Down
11 changes: 11 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
{
"compilerOptions": {
// Most non-library projects don't need to emit declarations.
// So we add this option by default to make the config more friendly to most users.
"noEmit": true,
// When type-checking with solution-style tsconfigs, though with `noEmit: true`, there won't
// be any `.d.ts` files emitted, but tsc still writes a `.tsbuildinfo` file to the `outDir`
// for each project. If we don't explicitly set the `outDir`, it will be in the same folder
// as the `tsconfig.json` file, which would look messy.
// Setting it to `./dist/` isn't ideal either, because it would pollute the `dist` folder.
// So we set it to a hidden folder in `node_modules` to avoid polluting the project root.
"outDir": "./node_modules/.cache/vue-tsbuildinfo",

// 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
Expand Down
8 changes: 8 additions & 0 deletions tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"noEmit": false,
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "./dist/"
}
}