-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
eddie murphy
committed
Dec 7, 2024
1 parent
4b02d1a
commit 2160ce4
Showing
5 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
title: "TypeSctipt类型实战" | ||
date: "2024-11-22 13:04:35" | ||
draft: true | ||
type: posts | ||
tags: | ||
- all | ||
- ts | ||
categories: | ||
- all | ||
--- |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
interface Config { | ||
name: string | ||
age: number | ||
} | ||
|
||
export function mergeConfig(c, k, v) { | ||
c[k] = v | ||
} | ||
|
||
const s1: Config = { | ||
name: 'dd', | ||
age: 1 | ||
} | ||
|
||
mergeConfig(s1, 'name', 11) | ||
mergeConfig(s1, 'nothing', 11) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
interface Config { | ||
name: string | ||
age: number | ||
} | ||
|
||
export function mergeConfig(c, k, v) { | ||
c[k] = v | ||
} | ||
|
||
// function mergeConfig<T, K extends keyof T> (c: T, k: K, v: T[K]) { | ||
// c[k] = v | ||
// } | ||
|
||
// const s1: Config = { | ||
// name: 'dd', | ||
// age: 1 | ||
// } | ||
|
||
// mergeConfig(s1, 'name', 11) | ||
// mergeConfig(s1, 'nothing', 11) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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