我正在使用React项目中的TypeScript 3.2.4
。我在src/app/components/Demo/*.tsx
中有一些演示代码,我不想编译它们。如何将其排除在编译之外?我尝试了以下tsconfig.jsin
文件中的设置,但它们都无法使用。我仍然从src/app/components/Demo
目录
"exclude": ["build", "node_modules", "**/Demo/*"]
"exclude": ["build", "node_modules", "src/app/components/Demo/*"]
"exclude": ["build", "node_modules", "**/Demo"]
"exclude": ["build", "node_modules", "**/Demo/**/*"]
"exclude": ["build", "node_modules", "src/app/components/Demo/**/*.tsx"]
"exclude": ["build", "node_modules", "src/app/components/Demo/*.tsx"]
以下是编译错误,您会看到所有错误均在app/components/Demo/index.tsx
文件中。
[tsl] ERROR in /Users/joeyzhao/dev/mpost/endstate/material-ui-es/src/app/components/Demo/index.tsx(401,16)
TS2322: Type '{ children: (string | Element)[]; align: string; }' is not assignable to type 'DetailedHTMLProps<HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>'.
Property 'align' does not exist on type 'DetailedHTMLProps<HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>'.
ERROR in /Users/joeyzhao/dev/mpost/endstate/material-ui-es/src/app/components/Demo/index.tsx
./app/components/Demo/index.tsx
[tsl] ERROR in /Users/joeyzhao/dev/mpost/endstate/material-ui-es/src/app/components/Demo/index.tsx(412,16)
TS2322: Type '{ children: (string | Element)[]; align: string; }' is not assignable to type 'DetailedHTMLProps<HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>'.
Property 'align' does not exist on type 'DetailedHTMLProps<HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>'.
ERROR in /Users/joeyzhao/dev/mpost/endstate/material-ui-es/src/app/components/Demo/index.tsx
./app/components/Demo/index.tsx
[tsl] ERROR in /Users/joeyzhao/dev/mpost/endstate/material-ui-es/src/app/components/Demo/index.tsx(516,20)
TS2339: Property 'propTypes' does not exist on type 'typeof OutlinedTextFields'.
您可以使用2-Star Glob在目录及其子目录中排除所有文件:
"exclude": [
"build",
"node_modules",
"src/app/components/Demo/**/*.tsx"
]
如果您只想在目录中排除直接的儿童文件,只需包括一个星:
"exclude": [
"build",
"node_modules",
"src/app/components/Demo/*.tsx"
]