我在React项目中使用打字稿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'.
答案 0 :(得分:0)
您可以使用2星标记来排除目录及其子目录中的所有文件:
"exclude": [
"build",
"node_modules",
"src/app/components/Demo/**/*.tsx"
]
如果您只想排除目录中的直接子文件,只需加一个星号即可:
"exclude": [
"build",
"node_modules",
"src/app/components/Demo/*.tsx"
]