Skip to content

Commit

Permalink
chore(uts): 默认开启tsc的narrowType
Browse files Browse the repository at this point in the history
  • Loading branch information
fxy060608 committed Jan 13, 2025
1 parent 38ae52e commit 1dc4bd6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions packages/uni-uts-v1/src/kotlin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
isColorSupported,
isEnableGenericsParameterDefaults,
isEnableInlineReified,
isEnableNarrowType,
isEnableUTSNumber,
moveRootIndexSourceMap,
normalizeUTSResult,
Expand Down Expand Up @@ -639,7 +638,7 @@ export async function compile(
uniExtApiNamespaces: extApis,
uniExtApiDefaultParameters: parseExtApiDefaultParameters(),
enableUtsNumber: isEnableUTSNumber(),
enableNarrowType: isEnableNarrowType(),
enableNarrowType: false, // 这里的启用是把部分typeof转换成instanceof,这样确实好一点,但会引发一些kotlin之类的警告,暂不开启
enableGenericsParameterDefaults: isEnableGenericsParameterDefaults(),
enableInlineReified: isEnableInlineReified(),
...transform,
Expand Down
4 changes: 2 additions & 2 deletions packages/uni-uts-v1/src/tsc/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ export function createUniXCompiler(
watchFile,
incremental: mode === 'development',
transformOptions: {
enableUTSNumber: isEnableUTSNumber(),
enableNarrowType: isEnableNarrowType(),
enableUTSNumber: false,
enableNarrowType: true, // 默认开启
enableGenericsParameterDefaults: isEnableGenericsParameterDefaults(),
},
...options,
Expand Down
4 changes: 2 additions & 2 deletions packages/uni-uts-v1/src/uvue/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ export async function compileApp(entry: string, options: CompileAppOptions) {
uniCloudObjectInfo: options.uniCloudObjectInfo,
autoImports,
uniModulesArtifacts: options.uniModulesArtifacts,
enableUtsNumber: isEnableUTSNumber(),
enableNarrowType: isEnableNarrowType(),
enableUtsNumber: false,
enableNarrowType: false, // 这里的启用是把部分typeof转换成instanceof,这样确实好一点,但会引发一些kotlin之类的警告,暂不开启
enableInlineReified: isEnableInlineReified(),
...options.transform,
},
Expand Down

0 comments on commit 1dc4bd6

Please sign in to comment.