ts 编译报错问题处理 (#2612)

* chore: typescript 允许 import md 和 svg 文件,并解决 button-group-select 文档页打不开的问题

* 修复 gh-pages 编译报错
This commit is contained in:
liaoxuezhi 2021-09-24 13:20:27 +08:00 committed by GitHub
parent 9fbbc330f2
commit 57ee8220c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 14 deletions

View File

@ -30,16 +30,6 @@ cp examples/static/iconfont.css sdk/
cp examples/static/iconfont.eot sdk/ cp examples/static/iconfont.eot sdk/
# 生成 .d.ts 文件 # 生成 .d.ts 文件
./node_modules/.bin/tsc --allowJs --declaration ./node_modules/.bin/tsc --declaration --emitDeclarationOnly --outDir ./lib --project ./tsconfig-for-declaration.json
cd output
for f in $(find . -name "*.d.ts"); do
mkdir -p ../lib/$(dirname $f) && mv $f ../lib/$(dirname $f)
done
cd ..
rm -rf output
npm run build-schemas npm run build-schemas

View File

@ -0,0 +1,27 @@
{
"compilerOptions": {
"outDir": "output/",
"module": "commonjs",
"target": "es5",
"lib": ["es6", "dom", "ES2015"],
"sourceMap": true,
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"importHelpers": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceRoot": "src",
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictNullChecks": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"typeRoots": ["./node_modules/@types", "./types"],
"skipLibCheck": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "acceptance-tests", "webpack", "jest"],
"types": ["node", "typePatches"]
}

View File

@ -7,11 +7,11 @@
"sourceMap": true, "sourceMap": true,
"jsx": "react", "jsx": "react",
"moduleResolution": "node", "moduleResolution": "node",
"rootDir": "src", "rootDir": "",
"importHelpers": true, "importHelpers": true,
"esModuleInterop": true, "esModuleInterop": true,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"sourceRoot": "src", "sourceRoot": "",
"noImplicitReturns": true, "noImplicitReturns": true,
"noImplicitThis": true, "noImplicitThis": true,
"noImplicitAny": true, "noImplicitAny": true,
@ -21,7 +21,7 @@
"typeRoots": ["./node_modules/@types", "./types"], "typeRoots": ["./node_modules/@types", "./types"],
"skipLibCheck": true "skipLibCheck": true
}, },
"include": ["src/**/*", "src/custom.d.ts", "examples/**/*"], "include": ["src/**/*", "examples/**/*"],
"exclude": ["node_modules", "acceptance-tests", "webpack", "jest"], "exclude": ["node_modules", "acceptance-tests", "webpack", "jest"],
"types": ["node", "typePatches"] "types": ["node", "typePatches"]
} }

9
types/custom/index.d.ts vendored Normal file
View File

@ -0,0 +1,9 @@
declare module '*.svg' {
const content: any;
export default content;
}
declare module '*.md' {
const content: any;
export default content;
}