File tree 15 files changed +20
-29
lines changed
compiler-sfc/src/template
15 files changed +20
-29
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,8 @@ module.exports = {
43
43
] ,
44
44
// Enforce the use of top-level import type qualifier when an import only has specifiers with inline type qualifiers
45
45
'@typescript-eslint/no-import-type-side-effects' : 'error' ,
46
+ // Ensure consistent usage of indexed object access style in TypeScript code.
47
+ '@typescript-eslint/consistent-indexed-object-style' : 'error' ,
46
48
} ,
47
49
overrides : [
48
50
// tests, no restrictions (runs in Node / jest with jsdom)
Original file line number Diff line number Diff line change @@ -2157,13 +2157,14 @@ foo
2157
2157
} )
2158
2158
2159
2159
describe ( 'Errors' , ( ) => {
2160
- const patterns : {
2161
- [ key : string ] : Array < {
2160
+ const patterns : Record <
2161
+ string ,
2162
+ Array < {
2162
2163
code : string
2163
2164
errors : Array < { type : ErrorCodes ; loc : Position } >
2164
2165
options ?: Partial < ParserOptions >
2165
2166
} >
2166
- } = {
2167
+ > = {
2167
2168
ABRUPT_CLOSING_OF_EMPTY_COMMENT : [
2168
2169
{
2169
2170
code : '<template><!--></template>' ,
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ export function createElementWithCodegen(
78
78
type Flags = PatchFlags | ShapeFlags
79
79
export function genFlagText (
80
80
flag : Flags | Flags [ ] ,
81
- names : { [ k : number ] : string } = PatchFlagNames ,
81
+ names : Record < number , string > = PatchFlagNames ,
82
82
) {
83
83
if ( isArray ( flag ) ) {
84
84
let f = 0
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ type InferCompilerError<T> = T extends ErrorCodes
24
24
export function createCompilerError < T extends number > (
25
25
code : T ,
26
26
loc ?: SourceLocation ,
27
- messages ?: { [ code : number ] : string } ,
27
+ messages ?: Record < number , string > ,
28
28
additionalMessage ?: string ,
29
29
) : InferCompilerError < T > {
30
30
const msg =
Original file line number Diff line number Diff line change @@ -124,9 +124,7 @@ export const enum BindingTypes {
124
124
LITERAL_CONST = 'literal-const' ,
125
125
}
126
126
127
- export type BindingMetadata = {
128
- [ key : string ] : BindingTypes | undefined
129
- } & {
127
+ export type BindingMetadata = Record < string , BindingTypes | undefined > & {
130
128
__isScriptSetup ?: boolean
131
129
__propsAliases ?: Record < string , string >
132
130
}
Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ export interface TransformContext
96
96
imports : ImportItem [ ]
97
97
temps : number
98
98
cached : number
99
- identifiers : { [ name : string ] : number | undefined }
99
+ identifiers : Record < string , number | undefined >
100
100
scopes : {
101
101
vFor : number
102
102
vSlot : number
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ if (__TEST__) {
48
48
}
49
49
}
50
50
51
- export const DOMErrorMessages : { [ code : number ] : string } = {
51
+ export const DOMErrorMessages : Record < number , string > = {
52
52
[ DOMErrorCodes . X_V_HTML_NO_EXPRESSION ] : `v-html is missing expression.` ,
53
53
[ DOMErrorCodes . X_V_HTML_WITH_CHILDREN ] : `v-html will override element children.` ,
54
54
[ DOMErrorCodes . X_V_TEXT_NO_EXPRESSION ] : `v-text is missing expression.` ,
Original file line number Diff line number Diff line change @@ -17,9 +17,7 @@ import {
17
17
} from './templateUtils'
18
18
import { isArray } from '@vue/shared'
19
19
20
- export interface AssetURLTagConfig {
21
- [ name : string ] : string [ ]
22
- }
20
+ export type AssetURLTagConfig = Record < string , string [ ] >
23
21
24
22
export interface AssetURLOptions {
25
23
/**
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ if (__TEST__) {
35
35
}
36
36
}
37
37
38
- export const SSRErrorMessages : { [ code : number ] : string } = {
38
+ export const SSRErrorMessages : Record < number , string > = {
39
39
[ SSRErrorCodes . X_SSR_UNSAFE_ATTR_NAME ] : `Unsafe attribute name for SSR.` ,
40
40
[ SSRErrorCodes . X_SSR_NO_TELEPORT_TARGET ] : `Missing the 'to' prop on teleport element.` ,
41
41
[ SSRErrorCodes . X_SSR_INVALID_AST_NODE ] : `Invalid AST node during SSR transform.` ,
Original file line number Diff line number Diff line change @@ -3,9 +3,7 @@ import type { ComponentInternalInstance } from '../component'
3
3
import { callWithAsyncErrorHandling , ErrorCodes } from '../errorHandling'
4
4
import { assertCompatEnabled , DeprecationTypes } from './compatConfig'
5
5
6
- interface EventRegistry {
7
- [ event : string ] : Function [ ] | undefined
8
- }
6
+ type EventRegistry = Record < string , Function [ ] | undefined >
9
7
10
8
const eventRegistryMap = /*#__PURE__*/ new WeakMap <
11
9
ComponentInternalInstance ,
Original file line number Diff line number Diff line change @@ -411,9 +411,7 @@ export type ComputedOptions = Record<
411
411
ComputedGetter < any > | WritableComputedOptions < any >
412
412
>
413
413
414
- export interface MethodOptions {
415
- [ key : string ] : Function
416
- }
414
+ export type MethodOptions = Record < string , Function >
417
415
418
416
export type ExtractComputedReturns < T extends any > = {
419
417
[ key in keyof T ] : T [ key ] extends { get : ( ...args : any [ ] ) => infer TReturn }
Original file line number Diff line number Diff line change @@ -30,9 +30,7 @@ export type Slot<T extends any = any> = (
30
30
...args : IfAny < T , any [ ] , [ T ] | ( T extends undefined ? [ ] : never ) >
31
31
) => VNode [ ]
32
32
33
- export type InternalSlots = {
34
- [ name : string ] : Slot | undefined
35
- }
33
+ export type InternalSlots = Record < string , Slot | undefined >
36
34
37
35
export type Slots = Readonly < InternalSlots >
38
36
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ export interface RendererOptions<
109
109
type : string ,
110
110
isSVG ?: boolean ,
111
111
isCustomizedBuiltIn ?: string ,
112
- vnodeProps ?: ( VNodeProps & { [ key : string ] : any } ) | null ,
112
+ vnodeProps ?: ( VNodeProps & Record < string , any > ) | null ,
113
113
) : HostElement
114
114
createText ( text : string ) : HostNode
115
115
createComment ( text : string ) : HostNode
@@ -134,9 +134,7 @@ export interface RendererOptions<
134
134
// logic - they are never directly operated on and always passed to the node op
135
135
// functions provided via options, so the internal constraint is really just
136
136
// a generic object.
137
- export interface RendererNode {
138
- [ key : string ] : any
139
- }
137
+ export type RendererNode = Record < string , any >
140
138
141
139
export interface RendererElement extends RendererNode { }
142
140
Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ export type VNodeNormalizedChildren =
144
144
export interface VNode <
145
145
HostNode = RendererNode ,
146
146
HostElement = RendererElement ,
147
- ExtraProps = { [ key : string ] : any } ,
147
+ ExtraProps = Record < string , any > ,
148
148
> {
149
149
/**
150
150
* @internal
Original file line number Diff line number Diff line change 1
1
import { makeMap } from './makeMap'
2
2
3
- export const EMPTY_OBJ : { readonly [ key : string ] : any } = __DEV__
3
+ export const EMPTY_OBJ : Readonly < Record < string , any > > = __DEV__
4
4
? Object . freeze ( { } )
5
5
: { }
6
6
export const EMPTY_ARR = __DEV__ ? Object . freeze ( [ ] ) : [ ]
You can’t perform that action at this time.
0 commit comments