mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:58:07 +08:00
ts 编译报错问题处理 (#2612)
* chore: typescript 允许 import md 和 svg 文件,并解决 button-group-select 文档页打不开的问题 * 修复 gh-pages 编译报错
This commit is contained in:
parent
9fbbc330f2
commit
57ee8220c1
12
build.sh
12
build.sh
@ -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
|
||||||
|
27
tsconfig-for-declaration.json
Normal file
27
tsconfig-for-declaration.json
Normal 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"]
|
||||||
|
}
|
@ -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
9
types/custom/index.d.ts
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
declare module '*.svg' {
|
||||||
|
const content: any;
|
||||||
|
export default content;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '*.md' {
|
||||||
|
const content: any;
|
||||||
|
export default content;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user