Compare commits

...

4 Commits

Author SHA1 Message Date
chenjiahan
1b08f84ac6 docs(changelog): @vant/cli 4.0.4 2022-09-06 00:03:50 +08:00
chenjiahan
f0d3e04fba release: @vant/cli 4.0.4 2022-09-06 00:03:00 +08:00
neverland
830a1eb5cf
fix(@vant/cli): failed to build types of sfc (#11012) 2022-09-06 00:00:28 +08:00
Fengyuan Chen
cd439c04f3 fix(utils): avoid getting unexpected value (#11010)
For example, when calling `get({}, 'button.small')`, it expects to return an empty string, but return a function (`''.small` is a native function, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/small).
2022-09-05 23:42:11 +08:00
4 changed files with 15 additions and 7 deletions

View File

@ -31,6 +31,12 @@ yarn add stylelint@13 @vant/stylelint-config
现在会默认生成 WebStorm 所需的 web-types.json 文件到 `lib/web-types.json` 目录下。
## v4.0.4
`2022-07-02`
- 修复构建 sfc 文件的类型定义时报错的问题
## v4.0.3
`2022-07-02`

View File

@ -1,6 +1,6 @@
{
"name": "@vant/cli",
"version": "4.0.3",
"version": "4.0.4",
"type": "module",
"main": "lib/index.js",
"typings": "lib/index.d.ts",

View File

@ -87,11 +87,6 @@ export async function compileSfc(filePath: string): Promise<any> {
new Promise((resolve) => {
let script = '';
// the generated render fn lacks type definitions
if (lang === 'ts') {
script += '// @ts-nocheck\n';
}
let bindingMetadata;
if (descriptor.scriptSetup) {
const { bindings, content } = compileScript(descriptor, {
@ -125,6 +120,12 @@ export async function compileSfc(filePath: string): Promise<any> {
script += `\n${EXPORT} ${VUEIDS}`;
// ts-nocheck should be placed on the first line
// the generated render fn lacks type definitions
if (lang === 'ts') {
script = '// @ts-nocheck\n' + script;
}
outputFile(scriptFilePath, script).then(resolve);
})
);

View File

@ -1,3 +1,4 @@
import { isObject } from './validate';
import type { ComponentPublicInstance } from 'vue';
export function noop() {}
@ -16,7 +17,7 @@ export function get(object: any, path: string): any {
let result = object;
keys.forEach((key) => {
result = result[key] ?? '';
result = isObject(result) ? result[key] ?? '' : '';
});
return result;