mirror of https://github.com/vuejs/core.git
Revert "fix(compiler-sfc): infer correct type for enums"
This reverts commit 2e074a7009
.
This commit is contained in:
parent
2e074a7009
commit
6f5698c932
|
@ -1677,8 +1677,6 @@ interface Test {}
|
||||||
|
|
||||||
type Alias = number[]
|
type Alias = number[]
|
||||||
|
|
||||||
enum Enum { one = '1', two = '2' }
|
|
||||||
|
|
||||||
|
|
||||||
export default /*#__PURE__*/_defineComponent({
|
export default /*#__PURE__*/_defineComponent({
|
||||||
props: {
|
props: {
|
||||||
|
@ -1704,7 +1702,6 @@ export default /*#__PURE__*/_defineComponent({
|
||||||
symbol: { type: Symbol, required: true },
|
symbol: { type: Symbol, required: true },
|
||||||
extract: { type: Number, required: true },
|
extract: { type: Number, required: true },
|
||||||
exclude: { type: [Number, Boolean], required: true },
|
exclude: { type: [Number, Boolean], required: true },
|
||||||
enum: { type: Object, required: true },
|
|
||||||
uppercase: { type: String, required: true },
|
uppercase: { type: String, required: true },
|
||||||
params: { type: Array, required: true },
|
params: { type: Array, required: true },
|
||||||
nonNull: { type: String, required: true },
|
nonNull: { type: String, required: true },
|
||||||
|
@ -1722,7 +1719,7 @@ export default /*#__PURE__*/_defineComponent({
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return { Enum }
|
return { }
|
||||||
}
|
}
|
||||||
|
|
||||||
})"
|
})"
|
||||||
|
|
|
@ -998,8 +998,6 @@ const emit = defineEmits(['a', 'b'])
|
||||||
|
|
||||||
type Alias = number[]
|
type Alias = number[]
|
||||||
|
|
||||||
enum Enum { one = '1', two = '2' }
|
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
string: string
|
string: string
|
||||||
number: number
|
number: number
|
||||||
|
@ -1023,7 +1021,6 @@ const emit = defineEmits(['a', 'b'])
|
||||||
symbol: symbol
|
symbol: symbol
|
||||||
extract: Extract<1 | 2 | boolean, 2>
|
extract: Extract<1 | 2 | boolean, 2>
|
||||||
exclude: Exclude<1 | 2 | boolean, 2>
|
exclude: Exclude<1 | 2 | boolean, 2>
|
||||||
enum: Enum
|
|
||||||
uppercase: Uppercase<'foo'>
|
uppercase: Uppercase<'foo'>
|
||||||
params: Parameters<(foo: any) => void>
|
params: Parameters<(foo: any) => void>
|
||||||
nonNull: NonNullable<string | null>
|
nonNull: NonNullable<string | null>
|
||||||
|
@ -1069,7 +1066,6 @@ const emit = defineEmits(['a', 'b'])
|
||||||
expect(content).toMatch(
|
expect(content).toMatch(
|
||||||
`exclude: { type: [Number, Boolean], required: true }`
|
`exclude: { type: [Number, Boolean], required: true }`
|
||||||
)
|
)
|
||||||
expect(content).toMatch(`enum: { type: Object, required: true }`)
|
|
||||||
expect(content).toMatch(`uppercase: { type: String, required: true }`)
|
expect(content).toMatch(`uppercase: { type: String, required: true }`)
|
||||||
expect(content).toMatch(`params: { type: Array, required: true }`)
|
expect(content).toMatch(`params: { type: Array, required: true }`)
|
||||||
expect(content).toMatch(`nonNull: { type: String, required: true }`)
|
expect(content).toMatch(`nonNull: { type: String, required: true }`)
|
||||||
|
@ -1119,9 +1115,7 @@ const emit = defineEmits(['a', 'b'])
|
||||||
foo: BindingTypes.PROPS,
|
foo: BindingTypes.PROPS,
|
||||||
uppercase: BindingTypes.PROPS,
|
uppercase: BindingTypes.PROPS,
|
||||||
params: BindingTypes.PROPS,
|
params: BindingTypes.PROPS,
|
||||||
nonNull: BindingTypes.PROPS,
|
nonNull: BindingTypes.PROPS
|
||||||
enum: BindingTypes.PROPS,
|
|
||||||
Enum: BindingTypes.LITERAL_CONST
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1369,15 +1369,14 @@ export function compileScript(
|
||||||
if (isTS) {
|
if (isTS) {
|
||||||
// move all Type declarations to outer scope
|
// move all Type declarations to outer scope
|
||||||
if (
|
if (
|
||||||
node.type.startsWith('TS') ||
|
(node.type.startsWith('TS') ||
|
||||||
(node.type === 'ExportNamedDeclaration' &&
|
(node.type === 'ExportNamedDeclaration' &&
|
||||||
node.exportKind === 'type') ||
|
node.exportKind === 'type') ||
|
||||||
(node.type === 'VariableDeclaration' && node.declare)
|
(node.type === 'VariableDeclaration' && node.declare)) &&
|
||||||
|
node.type !== 'TSEnumDeclaration'
|
||||||
) {
|
) {
|
||||||
recordType(node, declaredTypes)
|
recordType(node, declaredTypes)
|
||||||
if (node.type !== 'TSEnumDeclaration') {
|
hoistNode(node)
|
||||||
hoistNode(node)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1958,10 +1957,7 @@ interface PropTypeData {
|
||||||
}
|
}
|
||||||
|
|
||||||
function recordType(node: Node, declaredTypes: Record<string, string[]>) {
|
function recordType(node: Node, declaredTypes: Record<string, string[]>) {
|
||||||
if (
|
if (node.type === 'TSInterfaceDeclaration') {
|
||||||
node.type === 'TSInterfaceDeclaration' ||
|
|
||||||
node.type === 'TSEnumDeclaration'
|
|
||||||
) {
|
|
||||||
declaredTypes[node.id.name] = [`Object`]
|
declaredTypes[node.id.name] = [`Object`]
|
||||||
} else if (node.type === 'TSTypeAliasDeclaration') {
|
} else if (node.type === 'TSTypeAliasDeclaration') {
|
||||||
declaredTypes[node.id.name] = inferRuntimeType(
|
declaredTypes[node.id.name] = inferRuntimeType(
|
||||||
|
|
Loading…
Reference in New Issue