Skip to main content
Home Theme VS Code Tokyo Righter Theme Even darker variant of Tokyo Night forked from Tokyo Right Theme!
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.background #181818 activityBar.border #00000099 activityBar.foreground #dfdfdf activityBar.inactiveForeground #ffffff66 activityBarBadge.background #3d59a1 activityBarBadge.foreground #ffffff tokenColors TextMate scopes and font styles (syntax highlighting rules).
scope foreground fontStyle comment, meta.var.expr storage.type, keyword.control.flow, keyword.control.return, meta.directive.vue punctuation.separator.key-value.html, meta.directive.vue entity.other.attribute-name.html, tag.decorator.js entity.name.tag.js, tag.decorator.js punctuation.definition.tag.js, storage.modifier — italic keyword.control.flow.block-scalar.literal — comment, comment.block.documentation, punctuation.definition.comment, comment.block.documentation punctuation #545870 — comment.block.documentation variable, comment.block.documentation storage, comment.block.documentation keyword, comment.block.documentation support, comment.block.documentation markup, comment.block.documentation markup.inline.raw.string.markdown, meta.other.type.phpdoc.php keyword.other.type.php, meta.other.type.phpdoc.php support.other.namespace.php, meta.other.type.phpdoc.php punctuation.separator.inheritance.php, meta.other.type.phpdoc.php support.class, keyword.other.phpdoc.php, log.date
Shiki preview TypeScript sample highlighted with this variant's colors and tokenColors.
Tokyo Righter Theme — Tokyo Righter
badge.background #3d59a1
badge.foreground #ffffff
breadcrumb.activeSelectionForeground #dcdddd
breadcrumb.background #1c1f21
breadcrumb.focusForeground #dcdddd
breadcrumb.foreground #dcdddd
button.background #3d59a1dd
button.foreground #ffffff
button.hoverBackground #3d59a1aa
button.secondaryBackground #3a3d41
button.secondaryForeground #ffffff
button.secondaryHoverBackground #45494e
checkbox.background #3c3c3c
checkbox.border #00000000
checkbox.foreground #cccccc
debugExceptionWidget.background #333333
debugExceptionWidget.border #474747
debugToolBar.background #333333
debugToolBar.border #474747
diffEditor.border #444444
diffEditor.insertedTextBackground #41a6b515
diffEditor.removedTextBackground #db4b4b22
dropdown.background #3c3c3c
dropdown.border #00000000
dropdown.foreground #cccccc
editor.background #1E1E1E
editor.findMatchBackground #515c6a
editor.findMatchBorder #74879f
editor.findMatchHighlightBackground #ea5c0055
editor.findMatchHighlightBorder #ffffff00
editor.findRangeHighlightBackground #3a3d4166
editor.findRangeHighlightBorder #ffffff00
editor.foldBackground #264f784d
editor.foreground #a9b1d6
editor.hoverHighlightBackground #264f7840
editor.inactiveSelectionBackground #3a3d41
editor.lineHighlightBackground #ffffff0A
editor.lineHighlightBorder #282828
editor.rangeHighlightBackground #ffffff0b
editor.rangeHighlightBorder #ffffff00
editor.selectionBackground #646f83
editor.selectionHighlightBackground #add6ff26
editor.selectionHighlightBorder #495F77
editor.wordHighlightBackground #575757b8
editor.wordHighlightStrongBackground #004972b8
editorBracketHighlight.foreground1 #698cd6
editorBracketHighlight.foreground2 #68b3de
editorBracketHighlight.foreground3 #9a7ecc
editorBracketHighlight.foreground4 #25aac2
editorBracketHighlight.foreground5 #80a856
editorBracketHighlight.foreground6 #c49a5a
editorBracketHighlight.unexpectedBracket.foreground #db4b4b
editorBracketMatch.background #0064001a
editorBracketMatch.border #888888
editorCodeLens.foreground #999999
editorCursor.background #000000
editorCursor.foreground #ffffff
editorError.background #B73A3400
editorError.border #ffffff00
editorError.foreground #f48771
editorGroup.border #444444
editorGroup.emptyBackground #1f1f24
editorGroupHeader.tabsBackground #26282b
editorGutter.addedBackground #587c0c
editorGutter.background #1e1e1e
editorGutter.commentRangeForeground #c5c5c5
editorGutter.deletedBackground #94151b
editorGutter.foldingControlForeground #c5c5c5
editorGutter.modifiedBackground #0c7d9d
editorHoverWidget.background #252526
editorHoverWidget.border #454545
editorHoverWidget.foreground #cccccc
editorIndentGuide.activeBackground #707070
editorIndentGuide.background #404040
editorInfo.background #4490BF00
editorInfo.border #4490BF00
editorInfo.foreground #75beff
editorLineNumber.activeForeground #dfdfdf
editorLineNumber.foreground #dfdfdf55
editorLink.activeForeground #4e94ce
editorMarkerNavigation.background #2d2d30
editorMarkerNavigationError.background #f48771
editorMarkerNavigationInfo.background #75beff
editorMarkerNavigationWarning.background #cca700
editorOverviewRuler.background #25252500
editorOverviewRuler.border #7f7f7f4d
editorRuler.foreground #5a5a5a
editorSuggestWidget.background #252526
editorSuggestWidget.border #454545
editorSuggestWidget.foreground #d4d4d4
editorSuggestWidget.highlightForeground #0097fb
editorSuggestWidget.selectedBackground #062f4a
editorWarning.background #A9904000
editorWarning.border #ffffff00
editorWarning.foreground #cca700
editorWhitespace.foreground #e3e4e229
editorWidget.background #303030
editorWidget.foreground #cccccc
editorWidget.resizeBorder #5F5F5F
focusBorder #545c7e33
foreground #ffffff
gitDecoration.addedResourceForeground #449dab
gitDecoration.conflictingResourceForeground #bb7a61
gitDecoration.deletedResourceForeground #914c54
gitDecoration.ignoredResourceForeground #515670
gitDecoration.modifiedResourceForeground #6183bb
gitDecoration.stageDeletedResourceForeground #914c54
gitDecoration.stageModifiedResourceForeground #6183bb
gitDecoration.submoduleResourceForeground #8db9e2
gitDecoration.untrackedResourceForeground #449dab
icon.foreground #ffffff
input.background #3c3c3c
input.border #00000000
input.foreground #cccccc
input.placeholderForeground #a6a6a6
inputOption.activeBackground #007fd466
inputOption.activeBorder #007acc00
inputOption.activeForeground #ffffff
list.activeSelectionBackground #3071db34
list.activeSelectionForeground #dfdfdf
list.dropBackground #383b3d
list.focusBackground #5a5e8a8f
list.focusForeground #dfdfdf
list.highlightForeground #e0af68
list.hoverBackground #ffffff11
list.hoverForeground #cccccc
list.inactiveSelectionBackground #37373d
list.inactiveSelectionForeground #cccccc
listFilterWidget.background #3e4145
listFilterWidget.noMatchesOutline #a6333f
listFilterWidget.outline #7b7b7b
menu.background #252526
menu.border #00000085
menu.foreground #cccccc
menu.selectionBackground #094771
menu.selectionBorder #00000000
menu.selectionForeground #ffffff
menu.separatorBackground #bbbbbb
menubar.selectionBackground #ffffff1a
menubar.selectionForeground #cccccc
merge.commonContentBackground #282828
merge.commonHeaderBackground #383838
merge.currentContentBackground #007a7544
merge.currentHeaderBackground #007a75aa
merge.incomingContentBackground #3d59a144
merge.incomingHeaderBackground #3d59a1aa
minimap.background #1E1E1E
minimap.errorHighlight #f48771
minimap.findMatchHighlight #515c6a
minimap.foregroundOpacity #000000ff
minimap.selectionHighlight #646f83
minimap.warningHighlight #cca700
minimapGutter.addedBackground #587c0c
minimapGutter.deletedBackground #94151b
minimapGutter.modifiedBackground #0c7d9d
notificationCenter.border #474747
notificationCenterHeader.background #303031
notificationCenterHeader.foreground #cccccc
notifications.background #252526
notifications.border #303031
notifications.foreground #cccccc
notificationsErrorIcon.foreground #f48771
notificationsInfoIcon.foreground #75beff
notificationsWarningIcon.foreground #cca700
notificationToast.border #474747
panel.background #1e1e1e
panel.border #00000099
panelSection.border #80808059
panelTitle.activeBorder #e7e7e7
panelTitle.activeForeground #e7e7e7
panelTitle.inactiveForeground #e7e7e799
peekView.border #3071db
peekViewEditor.background #292a30
peekViewEditor.matchHighlightBackground #545558
peekViewEditor.matchHighlightBorder #545558
peekViewEditorGutter.background #001f33
peekViewResult.background #2a2c2f
peekViewResult.fileForeground #dfdfdf
peekViewResult.lineForeground #dfdfdf99
peekViewResult.matchHighlightBackground #545558
peekViewResult.selectionBackground #3071db34
peekViewResult.selectionForeground #dfdfdf
peekViewTitle.background #2a2c2f
peekViewTitleDescription.foreground #6699ff
peekViewTitleLabel.foreground #dfdfdf
pickerGroup.border #101014
pickerGroup.foreground #a9b1d6
progressBar.background #db4b4b
scrollbar.shadow #00000099
scrollbarSlider.activeBackground #bfbfbf66
scrollbarSlider.background #79797966
scrollbarSlider.hoverBackground #646464b3
selection.background #515c7e
settings.focusedRowBackground #ffffff07
settings.headerForeground #ffffff
sideBar.background #1e1e1e
sideBar.border #00000099
sideBar.dropBackground #383b3d
sideBar.foreground #cccccc
sideBarSectionHeader.background #00000000
sideBarSectionHeader.border #cccccc33
sideBarSectionHeader.foreground #cccccc
sideBarTitle.foreground #bbbbbb
statusBar.background #1c1f21
statusBar.border #00000099
statusBar.debuggingBackground #1c1f21
statusBar.debuggingBorder #00000099
statusBar.debuggingForeground #dcdddd
statusBar.foreground #dcdddd
statusBar.noFolderBackground #1c1f21
statusBar.noFolderBorder #00000099
statusBar.noFolderForeground #dcdddd
statusBarItem.activeBackground #FFFFFF25
statusBarItem.hoverBackground #ffffff1f
statusBarItem.remoteBackground #7aa2f7
statusBarItem.remoteForeground #ffffff
tab.activeBackground #1f1f24
tab.activeBorder #00000000
tab.activeBorderTop #00000000
tab.activeForeground #ffffff
tab.border #26282b
tab.inactiveBackground #26282b
tab.inactiveForeground #9a9c9d
terminal.ansiBlack #000000
terminal.ansiBlue #7aa2f7
terminal.ansiBrightBlack #363b54
terminal.ansiBrightBlue #7aa2f7
terminal.ansiBrightCyan #7dcfff
terminal.ansiBrightGreen #41a6b5
terminal.ansiBrightMagenta #bb9af7
terminal.ansiBrightRed #f7768e
terminal.ansiBrightWhite #acb0d0
terminal.ansiBrightYellow #e0af68
terminal.ansiCyan #7dcfff
terminal.ansiGreen #41a6b5
terminal.ansiMagenta #bb9af7
terminal.ansiRed #f7768e
terminal.ansiWhite #787c99
terminal.ansiYellow #e0af68
terminal.border #80808059
terminal.foreground #cccccc
terminal.selectionBackground #515c7e30
terminalCursor.background #0087FF
terminalCursor.foreground #ffffff
textLink.foreground #697eea
titleBar.activeBackground #1e1e1e
titleBar.activeForeground #b7b8bb
titleBar.border #26282b
titleBar.inactiveBackground #3c3c3c99
titleBar.inactiveForeground #cccccc99
tree.indentGuidesStroke #585858
walkThrough.embeddedEditorBackground #00000050
widget.shadow #0000005c meta.other.type.phpdoc.php support.class, comment.block.documentation storage.type, comment.block.documentation punctuation.definition.block.tag, comment.block.documentation entity.name.type.instance #646e9c —
variable.other.constant, punctuation.definition.constant, constant.language, constant.numeric, support.constant #ff9e64 —
string, constant.other.symbol, constant.other.key, meta.attribute-selector #9ece6a
constant.other.color, constant.other.color.rgb-value.hex punctuation.definition.constant #9aa5ce —
invalid, invalid.illegal #ff5370 —
invalid.deprecated #bb9af7 —
meta.var.expr storage.type, storage.modifier #9d7cd8 —
punctuation.definition.template-expression, punctuation.section.embedded, meta.embedded.line.tag.smarty, support.constant.handlebars, punctuation.section.tag.twig #7dcfff —
keyword.control.smarty, keyword.control.twig, support.constant.handlebars keyword.control, keyword.operator.comparison.twig, keyword.blade, entity.name.function.blade #0db9d7 —
keyword.operator.spread, keyword.operator.rest #f7768e bold
keyword.operator, keyword.control.as, keyword.other, keyword.operator.bitwise.shift, punctuation, text.html.twig meta.tag.inline.any.html, meta.tag.template.value.twig meta.function.arguments.twig, meta.directive.vue punctuation.separator.key-value.html, punctuation.definition.constant.markdown, punctuation.definition.string, punctuation.support.type.property-name, text.html.vue-html meta.tag, punctuation.definition.keyword, punctuation.terminator.rule, punctuation.definition.entity, punctuation.separator.inheritance.php, keyword.other.template, keyword.other.substitution, entity.name.operator, meta.property-list punctuation.separator.key-value, meta.at-rule.mixin punctuation.separator.key-value, meta.at-rule.function variable.parameter.url #89ddff —
keyword.control.import, keyword.control.export, keyword.control.from, keyword.control.default, meta.import keyword.other #7dcfff —
keyword, keyword.control, keyword.other.important #bb9af7 —
keyword.other.DML #7dcfff —
keyword.operator.logical, storage.type.function, keyword.operator.bitwise, keyword.operator.ternary, keyword.operator.comparison, keyword.operator.relational, keyword.operator.or.regexp #bb9af7 —
entity.name.tag support.class.component, meta.tag #de5971 —
punctuation.definition.tag #ba3c97 —
constant.other.php, variable.other.global.safer, variable.other.global.safer punctuation.definition.variable, variable.other.global, variable.other.global punctuation.definition.variable, constant.other #e0af68 —
variable, support.variable, string constant.other.placeholder, variable.parameter.handlebars #c0caf5 —
variable.other.object #c0caf5 —
meta.array.literal variable #7dcfff —
meta.object-literal.key, string.alias.graphql, string.unquoted.graphql, string.unquoted.alias.graphql, meta.group.braces.curly constant.other.object.key.js string.unquoted.label.js, meta.field.declaration.ts variable.object.property #73daca —
variable.other.property, support.variable.property, support.variable.property.dom, meta.function-call variable.other.object.property #7dcfff —
variable.other.object.property #c0caf5 —
meta.objectliteral meta.object.member meta.objectliteral meta.object.member meta.objectliteral meta.object.member meta.object-literal.key #41a6b5 —
source.cpp meta.block variable.other #f7768e —
support.other.variable #f7768e —
meta.class-method.js entity.name.function.js, entity.name.method.js, variable.function.constructor, keyword.other.special-method, storage.type.cs #7aa2f7 —
entity.name.function, meta.function-call, meta.function-call entity.name.function, variable.function, meta.definition.method entity.name.function, meta.object-literal entity.name.function #7aa2f7 —
variable.parameter.function.language.special, variable.parameter, meta.function.parameters punctuation.definition.variable, meta.function.parameter variable #e0af68 —
keyword.other.type.php, storage.type.php, constant.character, constant.escape, keyword.other.unit #bb9af7 —
meta.definition.variable variable.other.constant, meta.definition.variable variable.other.readwrite, variable.other.declaration #bb9af7 —
entity.other.inherited-class #bb9af7
support.class, support.type, variable.other.readwrite.alias, support.orther.namespace.use.php, meta.use.php, support.other.namespace.php, support.type.sys-types, support.variable.dom, support.constant.math, support.type.object.module, support.constant.json, entity.name.namespace, meta.import.qualifier #0db9d7 —
source.css support.type.property-name, source.sass support.type.property-name, source.scss support.type.property-name, source.less support.type.property-name, source.stylus support.type.property-name, source.postcss support.type.property-name, support.type.property-name.css, support.type.vendored.property-name, support.type.map.key #7aa2f7 —
support.constant.font-name, meta.definition.variable #9ece6a —
entity.other.attribute-name.class, meta.at-rule.mixin.scss entity.name.function.scss #9ece6a —
entity.other.attribute-name.id #fc7b7b —
entity.name.tag.css #0db9d7 —
entity.other.attribute-name.pseudo-class punctuation.definition.entity, entity.other.attribute-name.pseudo-element punctuation.definition.entity, entity.other.attribute-name.class punctuation.definition.entity, entity.name.tag.reference #e0af68 —
meta.property-list #9abdf5 —
meta.property-list meta.at-rule.if, meta.at-rule.return variable.parameter.url, meta.property-list meta.at-rule.else #ff9e64 —
entity.other.attribute-name.parent-selector-suffix punctuation.definition.entity.css #73daca —
meta.property-list meta.property-list #9abdf5 —
meta.at-rule.mixin keyword.control.at-rule.mixin, meta.at-rule.include entity.name.function.scss, meta.at-rule.include keyword.control.at-rule.include #bb9af7 —
keyword.control.at-rule.include punctuation.definition.keyword, keyword.control.at-rule.mixin punctuation.definition.keyword, meta.at-rule.include keyword.control.at-rule.include, keyword.control.at-rule.extend punctuation.definition.keyword, meta.at-rule.extend keyword.control.at-rule.extend, entity.other.attribute-name.placeholder.css punctuation.definition.entity.css, meta.at-rule.media keyword.control.at-rule.media, meta.at-rule.mixin keyword.control.at-rule.mixin, meta.at-rule.function keyword.control.at-rule.function, keyword.control punctuation.definition.keyword #9d7cd8 —
meta.property-list meta.at-rule.include #c0caf5 —
support.constant.property-value #ff9e64 —
entity.name.module.js, variable.import.parameter.js, variable.other.class.js #c0caf5 —
variable.language #f7768e —
variable.other punctuation.definition.variable #c0caf5 —
source.js constant.other.object.key.js string.unquoted.label.js, variable.language.this punctuation.definition.variable, keyword.other.this #f7768e —
entity.other.attribute-name, text.html.basic entity.other.attribute-name.html, text.html.basic entity.other.attribute-name #bb9af7 —
text.html constant.character.entity #0DB9D7 —
entity.other.attribute-name.id.html, meta.directive.vue entity.other.attribute-name.html #bb9af7 —
source.sass keyword.control #7aa2f7 —
entity.other.attribute-name.pseudo-class, entity.other.attribute-name.pseudo-element, entity.other.attribute-name.placeholder, meta.property-list meta.property-value #bb9af7 —
punctuation.definition.group #f7768e —
constant.other.character-class.regexp #bb9af7 —
constant.other.character-class.set.regexp, punctuation.definition.character-class.regexp #e0af68 —
keyword.operator.quantifier.regexp #89ddff —
constant.character.escape.backslash #c0caf5 —
constant.character.escape #89ddff —
tag.decorator.js entity.name.tag.js, tag.decorator.js punctuation.definition.tag.js #7aa2f7 —
keyword.other.unit #f7768e —
source.json meta.structure.dictionary.json support.type.property-name.json #7aa2f7 —
source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json #0db9d7 —
source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json #7dcfff —
source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json #bb9af7 —
source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json #e0af68 —
source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json #0db9d7 —
source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json #73daca —
source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json #f7768e —
source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json #9ece6a —
punctuation.definition.list_item.markdown #9abdf5 —
meta.block, meta.brace, punctuation.definition.block, punctuation.definition.use, punctuation.definition.class, punctuation.definition.begin.bracket, punctuation.definition.end.bracket, punctuation.definition.switch-expression.begin.bracket, punctuation.definition.switch-expression.end.bracket, punctuation.definition.section.switch-block.begin.bracket, punctuation.definition.section.switch-block.end.bracket, punctuation.definition.group.shell, punctuation.definition.parameters, punctuation.definition.arguments, punctuation.definition.dictionary, punctuation.definition.array, punctuation.section #9abdf5 —
meta.jsx.children, meta.embedded.block #c0caf5 —
text.html, text.log #9aa5ce —
text.html.markdown markup.inline.raw.markdown #bb9af7 —
text.html.markdown markup.inline.raw.markdown punctuation.definition.raw.markdown #4E5579 —
heading.1.markdown entity.name, heading.1.markdown punctuation.definition.heading.markdown #89ddff bold
heading.2.markdown entity.name, heading.2.markdown punctuation.definition.heading.markdown #61bdf2 bold
heading.3.markdown entity.name, heading.3.markdown punctuation.definition.heading.markdown #7aa2f7 bold
heading.4.markdown entity.name, heading.4.markdown punctuation.definition.heading.markdown #6d91de bold
heading.5.markdown entity.name, heading.5.markdown punctuation.definition.heading.markdown #9aa5ce bold
heading.6.markdown entity.name, heading.6.markdown punctuation.definition.heading.markdown #747ca1 bold
markup.italic, markup.italic punctuation #c0caf5 italic
markup.bold, markup.bold punctuation #c0caf5 bold
markup.bold markup.italic, markup.bold markup.italic punctuation #c0caf5 bold italic
markup.underline, markup.underline punctuation — underline
markup.quote punctuation.definition.blockquote.markdown #4e5579 —
string.other.link, markup.underline.link, constant.other.reference.link.markdown, string.other.link.description.title.markdown #73daca —
markup.fenced_code.block.markdown, markup.inline.raw.string.markdown, variable.language.fenced.markdown #89ddff —
meta.separator #444b6a bold
token.error-token #db4b4b —
token.debug-token #b267e6 —
entity.tag.apacheconf #f7768e —
meta.preprocessor #73daca —
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 } ! ` ;
}
Tokyo Righter Theme | Coding Theme