mirror of
https://github.com/andatoshiki/toshiki-notebook.git
synced 2026-06-06 09:16:45 +00:00
18 lines
12 KiB
JavaScript
18 lines
12 KiB
JavaScript
import{_ as o,c as e,o as a,R as t,z as s,a as l}from"./chunks/framework.ade46834.js";const w=JSON.parse('{"title":"Queries","description":"One of the key features of Twoslash is the ability to use the TypeScript compiler to pull out type information about your code.","frontmatter":{"description":"One of the key features of Twoslash is the ability to use the TypeScript compiler to pull out type information about your code.","title":"Queries"},"headers":[],"relativePath":"application/vitepress-plugin-shiki-twoslash/api/queries.md","filePath":"application/vitepress-plugin-shiki-twoslash/api/queries.md","lastUpdated":1686507725000}'),n={name:"application/vitepress-plugin-shiki-twoslash/api/queries.md"},c=t('<h1 id="queries" tabindex="-1">Queries <a class="header-anchor" href="#queries" aria-label="Permalink to "Queries""></a></h1><p>One of the key features of Twoslash is the ability to use the TypeScript compiler to pull out type information about your code. Twoslash comes with two different ways to query your code: <code>?^</code> and <code>?|</code>.</p><h2 id="extract-type" tabindex="-1">Extract Type <code>^?</code> <a class="header-anchor" href="#extract-type" aria-label="Permalink to "Extract Type `^?`""></a></h2><p>Using <code>^?</code> you can pull out type information about a particular identifier in the line of code above it.</p>',4),r=s("div",{class:"vp-code-group vp-adaptive-theme"},[s("div",{class:"tabs"},[s("input",{type:"radio",name:"group-mAvz1",id:"tab-CsLo9I0",checked:"checked"}),s("label",{for:"tab-CsLo9I0"},"output"),s("input",{type:"radio",name:"group-mAvz1",id:"tab-dtrN4Zg"}),s("label",{for:"tab-dtrN4Zg"},"markdown")]),s("div",{class:"blocks"},[s("div",{class:"language-ts vp-adaptive-theme active line-numbers-mode"},[s("button",{title:"Copy Code",class:"copy"}),s("span",{class:"lang"},"ts"),s("pre",{class:"shiki solarized-dark twoslash lsp",style:{"background-color":"#002B36",color:"#839496"},active:"true"},[s("div",{class:"language-id"},"ts"),s("div",{class:"code-container"},[s("code",null,[s("div",{class:"line"},[s("span",{style:{color:"#93A1A1"}},"const"),s("span",{style:{color:"#839496"}}," "),s("span",{style:{color:"#268BD2"}},[s("data-lsp",{lsp:'const hi: "Hello"'},"hi")]),s("span",{style:{color:"#839496"}}," "),s("span",{style:{color:"#859900"}},"="),s("span",{style:{color:"#839496"}}," "),s("span",{style:{color:"#2AA198"}},"'Hello'")]),s("div",{class:"line"},[s("span",{style:{color:"#93A1A1"}},"const"),s("span",{style:{color:"#839496"}}," "),s("span",{style:{color:"#268BD2"}},[s("data-lsp",{lsp:"const msg: string",style:{"border-bottom":"solid 2px lightgrey"}},"msg")]),s("span",{style:{color:"#839496"}}," "),s("span",{style:{color:"#859900"}},"="),s("span",{style:{color:"#839496"}}," "),s("span",{style:{color:"#268BD2"}},[s("data-lsp",{lsp:'const hi: "Hello"'},"hi")]),s("span",{style:{color:"#839496"}}," "),s("span",{style:{color:"#859900"}},"+"),s("span",{style:{color:"#839496"}}," "),s("span",{style:{color:"#2AA198"}},"', world'")]),s("div",{class:"meta-line"},[s("span",{class:"popover-prefix"}," "),s("span",{class:"popover"},[s("div",{class:"arrow"}),l("const msg: string")])])])])]),s("pre",{class:"shiki solarized-light twoslash lsp",style:{"background-color":"#FDF6E3",color:"#657B83"},active:"true"},[s("div",{class:"language-id"},"ts"),s("div",{class:"code-container"},[s("code",null,[s("div",{class:"line"},[s("span",{style:{color:"#586E75"}},"const"),s("span",{style:{color:"#657B83"}}," "),s("span",{style:{color:"#268BD2"}},[s("data-lsp",{lsp:'const hi: "Hello"'},"hi")]),s("span",{style:{color:"#657B83"}}," "),s("span",{style:{color:"#859900"}},"="),s("span",{style:{color:"#657B83"}}," "),s("span",{style:{color:"#2AA198"}},"'Hello'")]),s("div",{class:"line"},[s("span",{style:{color:"#586E75"}},"const"),s("span",{style:{color:"#657B83"}}," "),s("span",{style:{color:"#268BD2"}},[s("data-lsp",{lsp:"const msg: string",style:{"border-bottom":"solid 2px lightgrey"}},"msg")]),s("span",{style:{color:"#657B83"}}," "),s("span",{style:{color:"#859900"}},"="),s("span",{style:{color:"#657B83"}}," "),s("span",{style:{color:"#268BD2"}},[s("data-lsp",{lsp:'const hi: "Hello"'},"hi")]),s("span",{style:{color:"#657B83"}}," "),s("span",{style:{color:"#859900"}},"+"),s("span",{style:{color:"#657B83"}}," "),s("span",{style:{color:"#2AA198"}},"', world'")]),s("div",{class:"meta-line"},[s("span",{class:"popover-prefix"}," "),s("span",{class:"popover"},[s("div",{class:"arrow"}),l("const msg: string")])])])])]),s("div",{class:"line-numbers-wrapper","aria-hidden":"true"},[s("span",{class:"line-number"},"1"),s("br")])]),s("div",{class:"language-md vp-adaptive-theme line-numbers-mode"},[s("button",{title:"Copy Code",class:"copy"}),s("span",{class:"lang"},"md"),s("pre",{class:"shiki solarized-dark vp-code-dark"},[s("code",null,[s("span",{class:"line"},[s("span",{style:{color:"#839496"}},"```ts twoslash")]),l(`
|
||
`),s("span",{class:"line"},[s("span",{style:{color:"#93A1A1","font-weight":"bold"}},"const"),s("span",{style:{color:"#839496"}}," "),s("span",{style:{color:"#268BD2"}},"hi"),s("span",{style:{color:"#839496"}}," "),s("span",{style:{color:"#859900"}},"="),s("span",{style:{color:"#839496"}}," "),s("span",{style:{color:"#2AA198"}},"'Hello'")]),l(`
|
||
`),s("span",{class:"line"},[s("span",{style:{color:"#93A1A1","font-weight":"bold"}},"const"),s("span",{style:{color:"#839496"}}," "),s("span",{style:{color:"#268BD2"}},"msg"),s("span",{style:{color:"#839496"}}," "),s("span",{style:{color:"#859900"}},"="),s("span",{style:{color:"#839496"}}," "),s("span",{style:{color:"#268BD2"}},"hi"),s("span",{style:{color:"#839496"}}," "),s("span",{style:{color:"#859900"}},"+"),s("span",{style:{color:"#839496"}}," "),s("span",{style:{color:"#2AA198"}},"', world'")]),l(`
|
||
`),s("span",{class:"line"},[s("span",{style:{color:"#586E75","font-style":"italic"}},"// ^?")]),l(`
|
||
`),s("span",{class:"line"},[s("span",{style:{color:"#839496"}},"```")])])]),s("pre",{class:"shiki solarized-light vp-code-light"},[s("code",null,[s("span",{class:"line"},[s("span",{style:{color:"#657B83"}},"```ts twoslash")]),l(`
|
||
`),s("span",{class:"line"},[s("span",{style:{color:"#586E75","font-weight":"bold"}},"const"),s("span",{style:{color:"#657B83"}}," "),s("span",{style:{color:"#268BD2"}},"hi"),s("span",{style:{color:"#657B83"}}," "),s("span",{style:{color:"#859900"}},"="),s("span",{style:{color:"#657B83"}}," "),s("span",{style:{color:"#2AA198"}},"'Hello'")]),l(`
|
||
`),s("span",{class:"line"},[s("span",{style:{color:"#586E75","font-weight":"bold"}},"const"),s("span",{style:{color:"#657B83"}}," "),s("span",{style:{color:"#268BD2"}},"msg"),s("span",{style:{color:"#657B83"}}," "),s("span",{style:{color:"#859900"}},"="),s("span",{style:{color:"#657B83"}}," "),s("span",{style:{color:"#268BD2"}},"hi"),s("span",{style:{color:"#657B83"}}," "),s("span",{style:{color:"#859900"}},"+"),s("span",{style:{color:"#657B83"}}," "),s("span",{style:{color:"#2AA198"}},"', world'")]),l(`
|
||
`),s("span",{class:"line"},[s("span",{style:{color:"#93A1A1","font-style":"italic"}},"// ^?")]),l(`
|
||
`),s("span",{class:"line"},[s("span",{style:{color:"#657B83"}},"```")])])]),s("div",{class:"line-numbers-wrapper","aria-hidden":"true"},[s("span",{class:"line-number"},"1"),s("br"),s("span",{class:"line-number"},"2"),s("br"),s("span",{class:"line-number"},"3"),s("br"),s("span",{class:"line-number"},"4"),s("br"),s("span",{class:"line-number"},"5"),s("br")])])])],-1),i=s("h2",{id:"completions",tabindex:"-1"},[l("Completions "),s("code",null,"^|"),l(),s("a",{class:"header-anchor",href:"#completions","aria-label":'Permalink to "Completions `^|`"'},"")],-1),p=s("p",null,[l("Using "),s("code",null,"^|"),l(" you can pull out information about a what the auto-complete looks like at a particular location.")],-1),d=s("div",{class:"vp-code-group vp-adaptive-theme"},[s("div",{class:"tabs"},[s("input",{type:"radio",name:"group-7KR8y",id:"tab-kAIMnlX",checked:"checked"}),s("label",{for:"tab-kAIMnlX"},"output"),s("input",{type:"radio",name:"group-7KR8y",id:"tab-m1i62L4"}),s("label",{for:"tab-m1i62L4"},"markdown")]),s("div",{class:"blocks"},[s("div",{class:"language-ts vp-adaptive-theme active line-numbers-mode"},[s("button",{title:"Copy Code",class:"copy"}),s("span",{class:"lang"},"ts"),s("pre",{class:"shiki solarized-dark twoslash lsp",style:{"background-color":"#002B36",color:"#839496"},active:"true"},[s("div",{class:"language-id"},"ts"),s("div",{class:"code-container"},[s("code",null,[s("div",{class:"line"},[s("span",{style:{color:"#268BD2"}},[s("data-lsp",{lsp:"var console: Console"},"console")]),s("span",{style:{color:"#839496"}},"."),s("span",{style:{color:"#268BD2"}},[s("data-lsp",{lsp:"any"},"e")])]),s("div",{class:"meta-line"},[l(" "),s("span",{class:"inline-completions"},[s("ul",{class:"dropdown"},[s("li",{class:""},[s("span",null,[s("span",{class:"result-found"},"e"),l("rror")])])])])])])])]),s("pre",{class:"shiki solarized-light twoslash lsp",style:{"background-color":"#FDF6E3",color:"#657B83"},active:"true"},[s("div",{class:"language-id"},"ts"),s("div",{class:"code-container"},[s("code",null,[s("div",{class:"line"},[s("span",{style:{color:"#268BD2"}},[s("data-lsp",{lsp:"var console: Console"},"console")]),s("span",{style:{color:"#657B83"}},"."),s("span",{style:{color:"#268BD2"}},[s("data-lsp",{lsp:"any"},"e")])]),s("div",{class:"meta-line"},[l(" "),s("span",{class:"inline-completions"},[s("ul",{class:"dropdown"},[s("li",{class:""},[s("span",null,[s("span",{class:"result-found"},"e"),l("rror")])])])])])])])]),s("div",{class:"line-numbers-wrapper","aria-hidden":"true"},[s("span",{class:"line-number"},"1"),s("br")])]),s("div",{class:"language-md vp-adaptive-theme line-numbers-mode"},[s("button",{title:"Copy Code",class:"copy"}),s("span",{class:"lang"},"md"),s("pre",{class:"shiki solarized-dark vp-code-dark"},[s("code",null,[s("span",{class:"line"},[s("span",{style:{color:"#839496"}},"```ts twoslash")]),l(`
|
||
`),s("span",{class:"line"},[s("span",{style:{color:"#586E75","font-style":"italic"}},"// @noErrors")]),l(`
|
||
`),s("span",{class:"line"},[s("span",{style:{color:"#268BD2"}},"console"),s("span",{style:{color:"#839496"}},"."),s("span",{style:{color:"#268BD2"}},"e")]),l(`
|
||
`),s("span",{class:"line"},[s("span",{style:{color:"#586E75","font-style":"italic"}},"// ^|")]),l(`
|
||
`),s("span",{class:"line"},[s("span",{style:{color:"#839496"}},"```")])])]),s("pre",{class:"shiki solarized-light vp-code-light"},[s("code",null,[s("span",{class:"line"},[s("span",{style:{color:"#657B83"}},"```ts twoslash")]),l(`
|
||
`),s("span",{class:"line"},[s("span",{style:{color:"#93A1A1","font-style":"italic"}},"// @noErrors")]),l(`
|
||
`),s("span",{class:"line"},[s("span",{style:{color:"#268BD2"}},"console"),s("span",{style:{color:"#657B83"}},"."),s("span",{style:{color:"#268BD2"}},"e")]),l(`
|
||
`),s("span",{class:"line"},[s("span",{style:{color:"#93A1A1","font-style":"italic"}},"// ^|")]),l(`
|
||
`),s("span",{class:"line"},[s("span",{style:{color:"#657B83"}},"```")])])]),s("div",{class:"line-numbers-wrapper","aria-hidden":"true"},[s("span",{class:"line-number"},"1"),s("br"),s("span",{class:"line-number"},"2"),s("br"),s("span",{class:"line-number"},"3"),s("br"),s("span",{class:"line-number"},"4"),s("br"),s("span",{class:"line-number"},"5"),s("br")])])])],-1),y=s("div",{class:"info custom-block"},[s("p",{class:"custom-block-title"},"INFO"),s("p",null,[l("Note that the compiler flag for "),s("a",{href:"./errors#noerrors"},[s("code",null,"// @noErrors")]),l(" is set, because "),s("code",null,"console.e"),l(" is a failing TypeScript code sample but we don't really care about that.")])],-1),u=[c,r,i,p,d,y];function h(m,b,v,g,f,B){return a(),e("div",null,u)}const A=o(n,[["render",h]]);export{w as __pageData,A as default};
|