You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.
If the "files" and "include" are both left unspecified, the compiler defaults to including all TypeScript (.ts, .d.ts and .tsx) files in the containing directory and subdirectories except those excluded using the "exclude" property. JS files (.js and .jsx) are also included if allowJs is set to true. If the "files" or "include" properties are specified, the compiler will instead include the union of the files included by those two properties. Files in the directory specified using the "outDir" compiler option are excluded as long as "exclude" property is not specified.
进而导致 VSCode 提示包含文件过多的 warning(issue),所以 include 或 exclude如果有 node_modules 的话一定要指定。
rootDir 的作用:就是控制生成的 JS 的层级目录
There is rootDir compiler option, which is not used to specify input to a compiler. It’s used to control the output directory structure alongside with outDir.
根据官方对 rootDir 的默认值的解释:
(common root directory is computed from the list of input files)
typeK='foo'|'bar'// ❌interfaceSomeInterface1{[prop: K]: any}// An index signature parameter type cannot be a union type. Consider using a mapped object type instead.// ❌typeSomeType1={[prop: K]: any}// An index signature parameter type cannot be a union type. Consider using a mapped object type instead.// ❌interfaceSomeInterface2{[propinK]: any}// A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type.// A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type.// Cannot find name 'prop'.// ✅typeSomeType2={[propinK]: any}// ✅typeWorkaround=Record<K,any>
TypeScript: Restart TS server
重启即可(要在 TS/TSX 的文件中唤起控制台才会有对应的 command)。进而导致 VSCode 提示包含文件过多的 warning(issue),所以 include 或 exclude如果有 node_modules 的话一定要指定。
根据官方对 rootDir 的默认值的解释:
如果不指定 rootDir 的话,自动计算的 rootDir 可能会是包含了所有 TS 文件的的顶层文件夹
比如 es 文件夹指定的 rootDir 为
src
,es2 指定的 rootDir 为./
参考:https://stackoverflow.com/questions/41007001/output-and-directory-structure-in-typescript
遇到 @types 包之间类型重复导致冲突的时候,可以简单粗暴的通过 yarn autoclean 来将不需要的 @types 包干掉解决冲突。https://yarnpkg.com/lang/zh-hans/docs/cli/autoclean/
magic TypeScript
microsoft/TypeScript#24220
https://stackoverflow.com/a/51114250
https://devblogs.microsoft.com/typescript/announcing-typescript-2-9-rc/
The text was updated successfully, but these errors were encountered: