toshiki-notebook/assets/application_vitepress-plugin-shiki-twoslash_api_queries.md.2b262fc1.js

18 lines
12 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{_ as o,c as e,o as a,R as t,z as s,a as l}from"./chunks/framework.ade46834.js";const _=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":1694656760000}'),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 &quot;Queries&quot;"></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 &quot;Extract Type `^?`&quot;"></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-_sk8a",id:"tab-lj0Pkk3",checked:"checked"}),s("label",{for:"tab-lj0Pkk3"},"output"),s("input",{type:"radio",name:"group-_sk8a",id:"tab-E-fYv83"}),s("label",{for:"tab-E-fYv83"},"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-jkOFQ",id:"tab-5bHGTJC",checked:"checked"}),s("label",{for:"tab-5bHGTJC"},"output"),s("input",{type:"radio",name:"group-jkOFQ",id:"tab-9gjy67C"}),s("label",{for:"tab-9gjy67C"},"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(b,m,v,g,f,k){return a(),e("div",null,u)}const w=o(n,[["render",h]]);export{_ as __pageData,w as default};