Skip to main content
VS Code preview Full workbench mockup using this variant's colors and tokenColors.
colors Workbench UI color keys from the theme JSON colors map.
activityBar.activeBackground #644c4c00 activityBar.background #141a24 activityBar.border #111721 activityBar.foreground #9043ee activityBar.inactiveForeground #ffffff40 activityBarBadge.background #9043ee tokenColors TextMate scopes and font styles (syntax highlighting rules).
scope foreground fontStyle comment #637777 italic comment markup.link #637777 — entity.name.type #DCDCAA — entity.other.inherited-class #ABB2BF — keyword
Shiki preview TypeScript sample highlighted with this variant's colors and tokenColors.
activityBarBadge.foreground #ffffff
badge.background #9043ee26
badge.foreground #ffffff
breadcrumb.activeSelectionForeground #e0e0e0
breadcrumb.background #141a24
breadcrumb.focusForeground #e0e0e0
breadcrumb.foreground #cccccccc
button.background #9043ee26
button.foreground #9043ee
button.hoverBackground #9043ee40
button.secondaryBackground #ffffff0c
button.secondaryForeground #ffffff
button.secondaryHoverBackground #ffffff27
checkbox.background #141a24
checkbox.border #00000000
checkbox.foreground #cccccc
debugExceptionWidget.background #11161f
debugExceptionWidget.border #0f141d
debugToolBar.background #11161f
debugToolBar.border #0f141d
diffEditor.border #0000002a
diffEditor.insertedTextBackground #addb671a
diffEditor.insertedTextBorder #ff000000
diffEditor.removedTextBackground #ff587428
dropdown.background #141a24
dropdown.border #00000000
editor.background #1f2937
editor.findMatchBackground #11161f
editor.findMatchBorder #12171f
editor.findMatchHighlightBackground #b2999334
editor.findMatchHighlightBorder #ffffff00
editor.findRangeHighlightBackground #3a3d4166
editor.findRangeHighlightBorder #ffffff00
editor.foldBackground #11161f26
editor.foreground #ABB2BF
editor.hoverHighlightBackground #11161f
editor.inactiveSelectionBackground #11161f80
editor.lineHighlightBackground #99BBFF0A
editor.lineHighlightBorder #11161f34
editor.rangeHighlightBackground #ffffff0b
editor.rangeHighlightBorder #ffffff00
editor.selectionBackground #11161f80
editor.selectionHighlightBackground #11161f
editor.selectionHighlightBorder #121821
editor.wordHighlightBackground #ffffff1c
editor.wordHighlightStrongBackground #11161f
editorBracketMatch.background #11161f
editorBracketMatch.border #11161f
editorCodeLens.foreground #637777
editorCursor.background #000000
editorCursor.foreground #9043ee
editorError.background #11161f00
editorError.border #ffffff00
editorError.foreground #d3423eaf
editorGroup.background #21252B
editorGroup.border #00000056
editorGroup.emptyBackground #1f2937
editorGroupHeader.tabsBackground #19212d
editorGroupHeader.tabsBorder #0000000d
editorGutter.addedBackground #addb67
editorGutter.background #141a2480
editorGutter.commentRangeForeground #637777
editorGutter.deletedBackground #ff5874
editorGutter.foldingControlForeground #637777
editorGutter.modifiedBackground #82aaff
editorHoverWidget.background #141a24
editorHoverWidget.border #141a24
editorIndentGuide.activeBackground #00000028
editorIndentGuide.background #00000028
editorInfo.background #4490BF00
editorInfo.border #4490BF00
editorInfo.foreground #7fdbcaa9
editorLineNumber.activeForeground #c6c6c6
editorLineNumber.foreground #858585
editorLink.activeForeground #82aaff
editorMarkerNavigation.background #11161f
editorMarkerNavigationError.background #ff5874
editorMarkerNavigationInfo.background #7fdbca
editorMarkerNavigationWarning.background #ecc48d
editorOverviewRuler.background #11161f26
editorOverviewRuler.border #11161f26
editorRuler.foreground #00000028
editorSuggestWidget.border #141a24
editorSuggestWidget.foreground #637777
editorSuggestWidget.highlightForeground #7fdbca
editorSuggestWidget.selectedBackground #0e1219a1
editorWarning.background #A9904000
editorWarning.border #ffffff00
editorWarning.foreground #ecc48dab
editorWhitespace.foreground #63777726
editorWidget.background #11161f
editorWidget.foreground #cccccc
editorWidget.resizeBorder #63777700
focusBorder #9043ee81
foreground #cccccc
gitDecoration.addedResourceForeground #addb67cd
gitDecoration.conflictingResourceForeground #9043eedd
gitDecoration.deletedResourceForeground #d3423eed
gitDecoration.ignoredResourceForeground #8c8c8c
gitDecoration.modifiedResourceForeground #ecc48de1
gitDecoration.stageDeletedResourceForeground #d3423ee7
gitDecoration.stageModifiedResourceForeground #ecc48dc3
gitDecoration.submoduleResourceForeground #82aaffc7
gitDecoration.untrackedResourceForeground #addb67cd
icon.foreground #cccccc
input.background #141a24
input.border #00000000
input.foreground #cccccc
input.placeholderForeground #a6a6a6
inputOption.activeBackground #9043ee40
inputOption.activeBorder #007acc00
inputOption.activeForeground #ffffff
list.activeSelectionBackground #1f2937
list.activeSelectionForeground #ffffff
list.dropBackground #383b3d33
list.focusBackground #1f2937
list.focusForeground #cccccc
list.highlightForeground #c792ea
list.hoverBackground #1f293740
list.hoverForeground #cccccc
list.inactiveSelectionBackground #1f2937
list.inactiveSelectionForeground #cccccc
listFilterWidget.background #080c13
listFilterWidget.noMatchesOutline #0000002e
listFilterWidget.outline #00000000
menu.background #11161f
menu.border #0000000d
menu.foreground #cccccc
menu.selectionBackground #9043ee33
menu.selectionBorder #00000000
menu.selectionForeground #ffffff
menu.separatorBackground #1f29375e
menubar.selectionBackground #ffffff0d
menubar.selectionForeground #cccccc
merge.commonContentBackground #282828
merge.commonHeaderBackground #383838
merge.currentContentBackground #27403B
merge.currentHeaderBackground #367366
merge.incomingContentBackground #28384B
merge.incomingHeaderBackground #395F8F
minimap.background #1f2937
minimap.errorHighlight #d3423eaf
minimap.findMatchHighlight #11161f
minimap.selectionHighlight #11161f80
minimap.warningHighlight #ecc48dab
minimapGutter.addedBackground #addb67
minimapGutter.deletedBackground #ff5874
minimapGutter.modifiedBackground #82aaff
notificationCenter.border #11161f
notificationCenterHeader.background #0c0f15
notificationCenterHeader.foreground #cccccc
notifications.background #11161f
notifications.border #00000093
notifications.foreground #cccccc
notificationsErrorIcon.foreground #ff5874
notificationsInfoIcon.foreground #7fdbca
notificationsWarningIcon.foreground #ecc48d
notificationToast.border #0f131b
panel.background #141a24
panel.border #0000000d
panelSection.border #00000026
panelTitle.activeBorder #9043ee
panelTitle.activeForeground #e7e7e7
panelTitle.inactiveForeground #e7e7e799
peekView.border #82aaff
peekViewEditor.background #141a24
peekViewEditor.matchHighlightBackground #ecc48d48
peekViewEditor.matchHighlightBorder #776956
peekViewEditorGutter.background #11161f
peekViewResult.background #11161f
peekViewResult.fileForeground #ffffff
peekViewResult.lineForeground #bbbbbb
peekViewResult.matchHighlightBackground #ecc48d48
peekViewResult.selectionBackground #3399ff33
peekViewResult.selectionForeground #ffffff
peekViewTitle.background #11161f
peekViewTitleDescription.foreground #ccccccb3
peekViewTitleLabel.foreground #ffffff
pickerGroup.border #0000000d
pickerGroup.foreground #637777
progressBar.background #9043ee
scrollbar.shadow #00000040
scrollbarSlider.activeBackground #747D9180
scrollbarSlider.background #4E566680
scrollbarSlider.hoverBackground #5A637580
selection.background #9043ee80
settings.focusedRowBackground #ffffff07
settings.headerForeground #cccccc
sideBar.background #19212d
sideBar.border #111721
sideBar.dropBackground #383b3d33
sideBar.foreground #ccccccc1
sideBarSectionHeader.background #00000026
sideBarSectionHeader.border #0000000d
sideBarSectionHeader.foreground #cccccc
sideBarTitle.foreground #bbbbbb
statusBar.background #141a24
statusBar.border #0000000d
statusBar.debuggingBackground #141a24
statusBar.debuggingForeground #ffffff
statusBar.foreground #ffffff
statusBar.noFolderBackground #11161f
statusBar.noFolderForeground #ffffff
statusBarItem.activeBackground #FFFFFF25
statusBarItem.hoverBackground #ffffff0d
statusBarItem.remoteBackground #9043ee
statusBarItem.remoteForeground #ffffff
tab.activeBackground #9043ee26
tab.activeBorder #181A1F
tab.activeBorderTop #9043ee
tab.border #181A1F
tab.hoverBackground #363f4e
tab.inactiveBackground #1f293780
tab.inactiveForeground #ffffff80
terminal.ansiBlack #000000
terminal.ansiBlue #407dff
terminal.ansiBrightBlack #637777
terminal.ansiBrightBlue #82aaff
terminal.ansiBrightCyan #29b8db99
terminal.ansiBrightGreen #8fb05e
terminal.ansiBrightMagenta #c792ea
terminal.ansiBrightRed #ff5874
terminal.ansiBrightWhite #bbbec4
terminal.ansiBrightYellow #dcdcaa
terminal.ansiCyan #11a8cd
terminal.ansiGreen #addb67
terminal.ansiMagenta #9f60ec
terminal.ansiRed #ff2348
terminal.ansiWhite #ABB2BF
terminal.ansiYellow #ecc48d
terminal.border #00000026
terminal.foreground #cccccc
terminal.selectionBackground #55698612
terminalCursor.background #9043ee
terminalCursor.foreground #ffffff
textLink.foreground #9043ee
titleBar.activeBackground #141a24
titleBar.activeForeground #9DA5B4
titleBar.border #0000000d
titleBar.inactiveBackground #141a24
titleBar.inactiveForeground #9DA5B4
tree.indentGuidesStroke #1f2937
walkThrough.embeddedEditorBackground #00000050
widget.shadow #0000005a #c792ea
keyword.other.special-method #dcdcaa —
keyword.other.unit #7fdbca —
storage.type.annotation, storage.type.primitive #ABB2BF —
storage.modifier.package, storage.modifier.import #ABB2BF —
constant.variable #f78c6c —
constant.character.escape #ABB2BF —
constant.other.color #ABB2BF —
constant.other.symbol #ABB2BF —
variable.interpolation #7fdbca —
variable.parameter #7fdbca —
string > source, string embedded #ABB2BF —
string.regexp source.ruby.embedded #E5C07B —
string.other.link #dcdcaa —
punctuation.definition.method-parameters, punctuation.definition.function-parameters, punctuation.definition.parameters, punctuation.definition.separator, punctuation.definition.seperator, punctuation.definition.array #ABB2BF —
punctuation.definition.heading, punctuation.definition.identity #dcdcaa —
punctuation.definition.bold #f78c6c bold
punctuation.definition.italic #c792ea italic
punctuation.section.embedded #7fdbca —
punctuation.section.method, punctuation.section.class, punctuation.section.inner-class #ABB2BF —
support.function.any-method #dcdcaa —
entity.name.function #82aaff —
entity.name.class, entity.name.type.class #DCDCAA —
entity.name.section #dcdcaa —
entity.other.attribute-name #f78c6c —
entity.other.attribute-name.id #dcdcaa —
meta.method-call, meta.method #f78c6c —
meta.definition.variable #7fdbca —
invalid.deprecated #523D14 —
markup.italic #C678DD italic
markup.heading punctuation.definition.heading #61AFEF —
source.c keyword.operator #C678DD —
source.cpp keyword.operator #C678DD —
source.cs keyword.operator #C678DD —
source.css property-name, source.css property-value #828997 —
source.css property-name.support, source.css property-value.support #ABB2BF —
source.elixir source.embedded.source #ABB2BF —
source.elixir constant.language, source.elixir constant.numeric, source.elixir constant.definition #61AFEF —
source.elixir variable.definition, source.elixir variable.anonymous #C678DD —
source.elixir parameter.variable.function #D19A66 italic
source.elixir quoted #98C379 —
source.elixir keyword.special-method, source.elixir embedded.section, source.elixir embedded.source.empty #E06C75 —
source.elixir readwrite.module punctuation #E06C75 —
source.elixir regexp.section, source.elixir regexp.string #BE5046 —
source.elixir separator, source.elixir keyword.operator #D19A66 —
source.elixir variable.constant #E5C07B —
source.elixir array, source.elixir scope, source.elixir section #828997 —
source.gfm link entity #61AFEF —
source.go storage.type.string #C678DD —
source.ini keyword.other.definition.ini #E06C75 —
source.java storage.modifier.import #E5C07B —
source.java storage.type #E5C07B —
source.java keyword.operator.instanceof #C678DD —
source.java-properties meta.key-pair #E06C75 —
source.java-properties meta.key-pair > punctuation #ABB2BF —
source.js keyword.operator #56B6C2 —
source.js keyword.operator.delete, source.js keyword.operator.in, source.js keyword.operator.of, source.js keyword.operator.instanceof, source.js keyword.operator.new, source.js keyword.operator.typeof, source.js keyword.operator.void #C678DD —
source.ts keyword.operator #56B6C2 —
source.flow keyword.operator #56B6C2 —
source.json meta.structure.dictionary.json > string.quoted.json #E06C75 —
source.json meta.structure.dictionary.json > string.quoted.json > punctuation.string #E06C75 —
source.json meta.structure.dictionary.json > value.json > string.quoted.json, source.json meta.structure.array.json > value.json > string.quoted.json, source.json meta.structure.dictionary.json > value.json > string.quoted.json > punctuation, source.json meta.structure.array.json > value.json > string.quoted.json > punctuation #98C379 —
source.json meta.structure.dictionary.json > constant.language.json, source.json meta.structure.array.json > constant.language.json #56B6C2 —
ng.interpolation.begin, ng.interpolation.end #61AFEF —
ng.interpolation function #E06C75 —
ng.interpolation function.begin, ng.interpolation function.end #61AFEF —
ng.interpolation bool #D19A66 —
ng.interpolation bracket #ABB2BF —
ng.pipe, ng.operator #ABB2BF —
ng.attribute-with-value attribute-name #E5C07B —
ng.attribute-with-value string #C678DD —
ng.attribute-with-value string.begin, ng.attribute-with-value string.end #ABB2BF —
source.ruby constant.other.symbol > punctuation inherit —
source.php class.bracket #ABB2BF —
source.python keyword.operator.logical.python #C678DD —
source.python variable.parameter #7fdbca —
support.type.property-name #ABB2BF —
string.quoted.double punctuation #98C379 —
support.type.property-name.json #E06C75 —
support.type.property-name.json punctuation #E06C75 —
punctuation.separator.key-value.ts, punctuation.separator.key-value.js, punctuation.separator.key-value.tsx #F78C6C —
source.js.embedded.html keyword.operator, source.ts.embedded.html keyword.operator #56B6C2 —
variable.other.readwrite.js, variable.other.readwrite.ts, variable.other.readwrite.tsx #ABB2BF —
support.variable.dom.js, support.variable.dom.ts #E06C75 —
support.variable.property.dom.js, support.variable.property.dom.ts #E06C75 —
meta.template.expression.js punctuation.definition, meta.template.expression.ts punctuation.definition #BE5046 —
source.ts punctuation.definition.typeparameters, source.js punctuation.definition.typeparameters, source.tsx punctuation.definition.typeparameters #ABB2BF —
source.ts punctuation.definition.block, source.js punctuation.definition.block, source.tsx punctuation.definition.block #ABB2BF —
source.ts punctuation.separator.comma, source.js punctuation.separator.comma, source.tsx punctuation.separator.comma #ABB2BF —
support.variable.property.js, support.variable.property.ts, support.variable.property.tsx #E06C75 —
keyword.control.default.js, keyword.control.default.ts, keyword.control.default.tsx #C792EA —
keyword.operator.expression.instanceof.js, keyword.operator.expression.instanceof.ts, keyword.operator.expression.instanceof.tsx #C678DD —
keyword.operator.expression.of.js, keyword.operator.expression.of.ts, keyword.operator.expression.of.tsx #C678DD —
meta.brace.round.js, meta.array-binding-pattern-variable.js, meta.brace.square.js, meta.brace.round.ts, meta.array-binding-pattern-variable.ts, meta.brace.square.ts, meta.brace.round.tsx, meta.array-binding-pattern-variable.tsx, meta.brace.square.tsx #82AAFF —
source.js punctuation.accessor, source.ts punctuation.accessor, source.tsx punctuation.accessor #ABB2BF —
punctuation.terminator.statement.js, punctuation.terminator.statement.ts, punctuation.terminator.statement.tsx #ABB2BF —
meta.array-binding-pattern-variable.js variable.other.readwrite.js, meta.array-binding-pattern-variable.ts variable.other.readwrite.ts, meta.array-binding-pattern-variable.tsx variable.other.readwrite.tsx #D19A66 —
source.js support.variable, source.ts support.variable, source.tsx support.variable #E06C75 —
variable.other.constant.property.js, variable.other.constant.property.ts, variable.other.constant.property.tsx #D19A66 —
keyword.operator.new.ts, keyword.operator.new.j, keyword.operator.new.tsx #C678DD —
source.ts keyword.operator, source.tsx keyword.operator #56B6C2 —
punctuation.separator.parameter.js, punctuation.separator.parameter.ts, punctuation.separator.parameter.tsx #ABB2BF —
constant.language.import-export-all.js, constant.language.import-export-all.ts #E06C75 —
constant.language.import-export-all.jsx, constant.language.import-export-all.tsx #56B6C2 —
keyword.control.as.js, keyword.control.as.ts, keyword.control.as.jsx, keyword.control.as.tsx #ABB2BF —
variable.other.readwrite.alias.js, variable.other.readwrite.alias.ts, variable.other.readwrite.alias.jsx, variable.other.readwrite.alias.tsx #7fdbca —
variable.other.constant.js, variable.other.constant.ts, variable.other.constant.jsx, variable.other.constant.tsx #f78c6c —
meta.export.default.js variable.other.readwrite.js, meta.export.default.ts variable.other.readwrite.ts #DCDCAA —
source.js meta.template.expression.js punctuation.accessor, source.ts meta.template.expression.ts punctuation.accessor, source.tsx meta.template.expression.tsx punctuation.accessor #98C379 —
source.js meta.import-equals.external.js keyword.operator, source.jsx meta.import-equals.external.jsx keyword.operator, source.ts meta.import-equals.external.ts keyword.operator, source.tsx meta.import-equals.external.tsx keyword.operator #ABB2BF —
entity.name.type.module.js,entity.name.type.module.ts,entity.name.type.module.jsx,entity.name.type.module.tsx #98C379 —
meta.class.js,meta.class.ts,meta.class.jsx,meta.class.tsx #ABB2BF —
meta.definition.property.js variable, meta.definition.property.ts variable, meta.definition.property.jsx variable, meta.definition.property.tsx variable #ABB2BF —
meta.type.parameters.js support.type, meta.type.parameters.jsx support.type, meta.type.parameters.ts support.type, meta.type.parameters.tsx support.type #ABB2BF —
source.js meta.tag.js keyword.operator, source.jsx meta.tag.jsx keyword.operator, source.ts meta.tag.ts keyword.operator, source.tsx meta.tag.tsx keyword.operator #ABB2BF —
meta.tag.js punctuation.section.embedded, meta.tag.jsx punctuation.section.embedded, meta.tag.ts punctuation.section.embedded, meta.tag.tsx punctuation.section.embedded #ABB2BF —
meta.array.literal.js variable, meta.array.literal.jsx variable, meta.array.literal.ts variable, meta.array.literal.tsx variable #E5C07B —
support.type.object.module.js, support.type.object.module.jsx, support.type.object.module.ts, support.type.object.module.tsx #E06C75 —
constant.language.json #56B6C2 —
variable.other.constant.object.js, variable.other.constant.object.jsx, variable.other.constant.object.ts, variable.other.constant.object.tsx #D19A66 —
storage.type.property.js, storage.type.property.jsx, storage.type.property.ts, storage.type.property.tsx #56B6C2 —
meta.template.expression.js string.quoted punctuation.definition, meta.template.expression.jsx string.quoted punctuation.definition, meta.template.expression.ts string.quoted punctuation.definition, meta.template.expression.tsx string.quoted punctuation.definition #98C379 —
meta.template.expression.js string.template punctuation.definition.string.template, meta.template.expression.jsx string.template punctuation.definition.string.template, meta.template.expression.ts string.template punctuation.definition.string.template, meta.template.expression.tsx string.template punctuation.definition.string.template #98C379 —
keyword.operator.expression.in.js, keyword.operator.expression.in.jsx, keyword.operator.expression.in.ts, keyword.operator.expression.in.tsx #C678DD —
variable.other.object.js, variable.other.object.ts #ABB2BF —
meta.object-literal.key.js, meta.object-literal.key.ts #F78C6C —
source.python constant.other #ABB2BF —
source.python constant #D19A66 —
constant.character.format.placeholder.other.python storage #D19A66 —
support.variable.magic.python #E06C75 —
meta.function.parameters.python #D19A66 —
punctuation.separator.annotation.python #ABB2BF —
punctuation.separator.parameters.python #ABB2BF —
entity.name.variable.field.cs #E06C75 —
source.cs keyword.operator #ABB2BF —
variable.other.readwrite.cs #ABB2BF —
variable.other.object.cs #ABB2BF —
variable.other.object.property.cs #ABB2BF —
entity.name.variable.property.cs #61AFEF —
keyword.other.unsafe.rust #C678DD —
entity.name.type.rust #56B6C2 —
storage.modifier.lifetime.rust #ABB2BF —
entity.name.lifetime.rust #D19A66 —
storage.type.core.rust #56B6C2 —
meta.attribute.rust #D19A66 —
storage.class.std.rust #56B6C2 —
markup.raw.block.markdown #ABB2BF —
punctuation.definition.variable.shell #E06C75 —
support.constant.property-value.css #ABB2BF —
punctuation.definition.constant.css #D19A66 —
punctuation.separator.key-value.scss #E06C75 —
punctuation.definition.constant.scss #D19A66 —
meta.property-list.scss punctuation.separator.key-value.scss #ABB2BF —
storage.type.primitive.array.java #E5C07B —
entity.name.section.markdown #E06C75 —
punctuation.definition.heading.markdown #E06C75 —
markup.heading.setext #ABB2BF —
punctuation.definition.bold.markdown #D19A66 —
markup.inline.raw.markdown #98C379 —
beginning.punctuation.definition.list.markdown #E06C75 —
markup.quote.markdown #5C6370 italic
punctuation.definition.string.begin.markdown, punctuation.definition.string.end.markdown, punctuation.definition.metadata.markdown #ABB2BF —
punctuation.definition.metadata.markdown #C678DD —
markup.underline.link.markdown, markup.underline.link.image.markdown #C678DD —
string.other.link.title.markdown, string.other.link.description.markdown #61AFEF —
punctuation.separator.variable.ruby #E06C75 —
variable.other.constant.ruby #D19A66 —
keyword.operator.other.ruby #98C379 —
punctuation.definition.variable.php #E06C75 —
export interface User {
id : string ;
name : string ;
role : " admin " | " member " ;
tags : string [] ;
}
/**
* Fetch user data by ID
* @ param id
* @ returns User object or null if ID is invalid
*/
export async function fetchUser ( id : string ) : Promise < User | null> {
if ( ! id ) {
return null ;
}
const response = await fetch( `/api/users/ ${ id } ` , {
method: " GET " ,
headers: { Accept: " application/json " },
} ) ;
if ( ! response.ok ) {
throw new Error( `HTTP ${ response . status } ` ) ;
}
return ( await response. json()) as User ;
}
function greet ( user : User ) : string {
// Simple greeting function that uses the user's name
return `Hello, ${ user . name } !` ;
}
fetchUser.ts
index.ts
README.md
src
components
fetchUser.ts
src
components
fetchUser.ts
fetchUser 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Problems1
Output
Debug Console
Terminal
Ports
~/my-project $ pnpm dev
▲ Next.js ready on http://localhost:3000
✓ compiled client and server successfully in 412ms
wait - compiling /theme/vscode...
main*
Button.tsx
31
~/my-project
$
export interface User {
id : string ;
name : string ;
role : " admin " | " member " ;
tags : string [] ;
}
/**
* Fetch user data by ID
* @ param id
* @ returns User object or null if ID is invalid
*/
export async function fetchUser ( id : string ) : Promise < User | null> {
if ( ! id ) {
return null ;
}
const response = await fetch( `/api/users/ ${ id } ` , {
method: " GET " ,
headers: { Accept: " application/json " },
} ) ;
if ( ! response.ok ) {
throw new Error( `HTTP ${ response . status } ` ) ;
}
return ( await response. json()) as User ;
}
function greet ( user : User ) : string {
// Simple greeting function that uses the user's name
return `Hello, ${ user . name } !` ;
}
blue-dark | Coding Theme