This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Module1Mutations { | |
mutationA1(state: Module1State, payload: MutationA1Payload): void | |
mutationA2(state: Module1State, payload: MutationA2Payload): void | |
} | |
export const module1Mutations: MutationTree<Module1State> & Module1Mutations = { | |
mutationA1(state, payload) {}, | |
mutationA2(state, payload) {}, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Module1Actions { | |
actionA1(context: Module1ActionContext, payload: ActionA1Payload): void | |
actionA2(context: Module1ActionContext, payload: ActionA2Payload): void | |
} | |
type Module1ActionContext = { | |
dispatch<K extends keyof Module1Actions>( | |
actionType: K, | |
payload: Parameters<Module1Actions[K]>[1], | |
options?: DispatchOptions, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Color = "red" | "blue"; | |
type Quantity = "one" | "two"; | |
type SeussFish = `${Quantity | Color} fish`; | |
// same as | |
// type SeussFish = "one fish" | "two fish" | |
// | "red fish" | "blue fish"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
computed: { | |
mappedItems() { | |
return this.items.map(item => ({ | |
...item, | |
a: getA(item), | |
b: getB(item), | |
c: getC(item), | |
d: getD(item), | |
e: getE(item), | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
computed: { | |
mappedItems() { | |
return this.items.map(item => ({ | |
...item, | |
a: getA(item), | |
b: getB(item), | |
c: getC(item), | |
d: getD(item), | |
e: getE(item), | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Item.vue | |
...mapGetters('namespace', [ | |
'getA', | |
'getB', | |
'getC', | |
'getD', | |
'getE', | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let fn = (buttonSize: BUTTON_SIZES_UNION) => {}; | |
fn('small'); | |
fn('smal'); // Argument of type '"smal"' is not assignable to parameter of type 'BUTTON_SIZES_UNION' | |
let str: string; | |
fn(str); // Argument of type 'string' is not assignable to parameter of type 'BUTTON_SIZES_UNION'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type BUTTON_SIZES_UNION = "small" | "medium" | "large"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const obj = { buttonSize: BUTTON_SIZES_CONST_ENUM } // ERROR: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. | |
Object.values(BUTTON_SIZES_CONST_ENUM); // ERROR 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment or type query. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const buttonSizeUsage = "medium" /* MEDIUM */; |