vuejs / tsconfig Goto Github PK
View Code? Open in Web Editor NEWBase tsconfig for Vue 3 projects.
License: MIT License
Base tsconfig for Vue 3 projects.
License: MIT License
Adopt TypeScript 5+ "moduleResolution": "bundler"
. This should result in more correct module resolution for Vite projects that use this config. We should also any other props https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html#resolution-customization-flags to match Vite behavior.
The current config gives the following schema error:
Option 'allowImportingTsExtensions' can only be used when either 'noEmit' or 'emitDeclarationOnly' is set
.
Setting "noEmit": true,
in compilerOptions
seems to resolve it, as Vite is doing the actual transpiling this seems to work fine.
Running the command npm i @vue/[email protected]
returns the following error:
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@vue%2ftsconfig - Not found
npm ERR! 404
npm ERR! 404 '@vue/[email protected]' is not in this registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
When i try to install vue-i18n@9 it says:
Could not find a declaration file for module 'vue-i18n'. '/home/user/repo/node_modules/vue-i18n/dist/vue-i18n.esm-bundler.js' implicitly has an 'any' type.
There are types at '/home/user/repo/node_modules/vue-i18n/dist/vue-i18n.d.ts', but this result could not be resolved when respecting package.json "exports". The 'vue-i18n' library may need to update its package.json or typings.ts(7016)
Works fine with 0.2.0. Fails with every version greater than that.
References:
Note that don't use node12
because as said in microsoft/TypeScript#46452
Node 14.8 added top-level
await
, but Node 12 doesn't have it. I think this omission is enough of a wart that starting at Node 12 is the wrong move.
Is this config suitable for vue2 project?
use es2018 some time ago,why use es2016 now? @sodatea
Currently these two options are set: importsNotUsedAsValues
and preserveValueImports
:
Lines 19 to 23 in 5b93351
which result with TypeScript 5.0-beta in an error.
error TS5101: Flag 'importsNotUsedAsValues' is deprecated and will stop functioning in TypeScript 5.5. Specify 'ignoreDeprecations: "5.0"' to silence this error.
Use 'verbatimModuleSyntax' instead.
error TS5101: Flag 'preserveValueImports' is deprecated and will stop functioning in TypeScript 5.5. Specify 'ignoreDeprecations: "5.0"' to silence this error.
Use 'verbatimModuleSyntax' instead.
{
"compilerOptions": {
"ignoreDeprecations": "5.0"
}
}
in your config.
Should have skipLibCheck: false
in that config.
But let's wait till microsoft/TypeScript#29118 lands in TypeScript so that the configuration won't be too complex.
"extends": [
"@tsconfig/node18/tsconfig.json",
"@vue/tsconfig/tsconfig.json"
],
"compilerOptions": {
"types": ["node"]
}
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Array
I upgraded from 0.1.3 to 0.3.2 and am now seeing the error "Cannot find base config file @vue/tsconfig/tsconfig.web.json"
Full stacktrace is below:
> vue-tsc --noEmit --skipLibCheck
▲ [WARNING] Cannot find base config file "@vue/tsconfig/tsconfig.web.json" [tsconfig.json]
tsconfig.json:2:13:
2 │ "extends": "@vue/tsconfig/tsconfig.web.json",
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vite v4.3.2 building for production...
✓ 2 modules transformed.
✓ built in 785ms
[vite:esbuild] failed to resolve "extends":"@vue/tsconfig/tsconfig.web.json" in /<my-path>/tsconfig.json
file: /<my-path>/main.ts
error during build:
TSConfckParseError: failed to resolve "extends":"@vue/tsconfig/tsconfig.web.json" in /<my-path>/tsconfig.json
at resolveExtends (file:////<my-path>/node_modules/vite/dist/node/chunks/dep-7efa13d7.js:13544:9)
at parseExtends (file:////<my-path>/node_modules/vite/dist/node/chunks/dep-7efa13d7.js:13498:28)
at parse$f (file:////<my-path>/node_modules/vite/dist/node/chunks/dep-7efa13d7.js:13436:24)
at async loadTsconfigJsonForFile (file:////<my-path>/node_modules/vite/dist/node/chunks/dep-7efa13d7.js:14057:24)
at async transformWithEsbuild (file:////<my-path>/node_modules/vite/dist/node/chunks/dep-7efa13d7.js:13742:36)
at async Object.transform (file:////<my-path>/node_modules/vite/dist/node/chunks/dep-7efa13d7.js:13867:32)
at async transform (file:////<my-path>/node_modules/rollup/dist/es/shared/node-entry.js:23499:16)
at async ModuleLoader.addModuleSource (file:////<my-path>/node_modules/rollup/dist/es/shared/node-entry.js:23705:30)
ERROR: "build-only" exited with 1.
Let's say a file contains a JSON import:
import en from '@/locales/en.json';
then the type-check
throws with:
src/i18n.ts:2:16 - error TS6307: File '/home/projects/github-nzwcnu/src/locales/en.json' is not listed within the file list of project '/home/projects/github-nzwcnu/tsconfig.vitest.json'. Projects must list all files or use an 'include' pattern.
2 import en from '@/locales/en.json';
Reverting to v0.4 makes the error go away.
See https://stackblitz.com/edit/github-nzwcnu?file=src%2Fi18n.ts for a small repro
Run npm i
and npm run type-check
Repo: https://stackblitz.com/edit/vitejs-vite-zfat4q?file=src%2Fcomponents%2FHelloWorld.vue
The declaration of '*.vue' has gone and router type check has been broken.
I'm guessing originally the reset of "types" was put in place when the tsconfig.dom.json
still used the tsconfig.node.json
import. Now, however, this reset has become redundant; the field is not set within the base tsconfig.json
.
Due to this reset, I ran into an issue where none of my @types imports were loaded in. The empty array does not let TypeScript revert to the default configuration.
It should be safe to remove the line "types": []
, so people may use their installed @types again.
I have seen that the ts.*.json has been changed for several times in succession. For the purposes and scenarios of ts.config.app.json and tsconfig.node.json and tsconfig.json, could you please mark them in the document for better experience
Adding noEmit: true
in #26 should be considered a breaking change and bump the major version.
The comment added with the change, shown below, makes too many assumptions on when the tsconfig is extended and the behavior of the host application.
// 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.
Even in the component libraries where we extend @vue/tsconfig/tsconfig.json
, we have our own settings for exporting/generating types, etc. via flags that should not be overridden by this extendable configuration.
IMO this change should be reverted as it is too opinionated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.