Skip to content

Instantly share code, notes, and snippets.

@raphaeldealmeida
Last active June 28, 2024 12:49
Show Gist options
  • Save raphaeldealmeida/4b0b84ae082fc28b66a7b69f2647d133 to your computer and use it in GitHub Desktop.
Save raphaeldealmeida/4b0b84ae082fc28b66a7b69f2647d133 to your computer and use it in GitHub Desktop.
Mithril VS Code snippets
{
// Mithril snippets
// Paste in File > Preferences > Configure User Snippets > typescriptreact.json
// ref: https://code.visualstudio.com/docs/editor/userdefinedsnippets
"Mithril component": {
"prefix": ["mcomp"],
"body": [
"import m from \"mithril\"",
"",
"interface T${1:MyComponent}Props {}",
"const $1: m.ClosureComponent<T$1Props> = () => {",
"",
" return {",
" view: () => {",
" return <>",
" $1",
" </>",
" }",
" }",
"}",
"",
"export default $1",
],
"description": "A component Mithril"
}
}
@nandoflorestan
Copy link

User code doesn't care whether it's an interface or a type, this is an implementation detail due to the evolution of the TypeScript language. It's better to keep a T prefix for everything, then you can switch the implementation between types and interfaces freely, without changing user code.

@raphaeldealmeida
Copy link
Author

Ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment