@typescript/twoslash
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -0,1 +1,13 @@ | ||
## 2.2.0 | ||
- Adds a new parameter to the twoslash config: `customTags`. This can be used to tell twoslash that you want to handle a specific `@tag` in the code sample. It comes out in the `tags` in `TwoSlashReturn`. | ||
Prior to this change, any `// @something` which wasn't already in `ExampleOptions` would be passed to the TS compiler (maybe causing an exception if it's not a compiler option.) Now you can tell twoslash "I want to do something with this tag, let it through" | ||
The use-case I'm thinking of is that shiki-twoslash may want to have it's own commands which sit on-top of twoslash, but I want to make sure that the internals of twoslash are all aligned correctly (think `--cut--` and the complex multi-file LSP logic) under the hood. | ||
## 2.1.0 | ||
All "expected" errors from Twoslash are of the type `TwoslashError` which extends `Error`. This means you can catch the error and check its type, if it's a Twoslash error then it's something you can treat differently. In this case, that's being able to present a UI for those errors in shiki-twoslash as opposed to a critical process-ending exception. | ||
## 2.0.0 | ||
@@ -2,0 +14,0 @@ |
@@ -89,2 +89,11 @@ declare type LZ = typeof import("lz-string"); | ||
}[]; | ||
/** The extracted twoslash commands for any custom tags passed in via customTags */ | ||
tags: { | ||
/** What was the name of the tag */ | ||
name: string; | ||
/** Where was it located in the original source file */ | ||
line: number; | ||
/** What was the text after the `// @tag: ` string (optional because you could do // @tag on it's own line without the ':') */ | ||
annotation?: string; | ||
}[]; | ||
/** Diagnostic error messages which came up when creating the program */ | ||
@@ -122,2 +131,4 @@ errors: { | ||
vfsRoot?: string; | ||
/** A set of known `// @[tags]` tags to extract and not treat as a comment */ | ||
customTags?: string[]; | ||
} | ||
@@ -124,0 +135,0 @@ /** |
@@ -521,2 +521,25 @@ 'use strict'; | ||
return options; | ||
} | ||
function filterCustomTags(codeLines, customTags) { | ||
var tags = []; | ||
for (var _i3 = 0; _i3 < codeLines.length;) { | ||
var match = void 0; | ||
if (match = valuedConfigRegexp.exec(codeLines[_i3])) { | ||
if (customTags.includes(match[1])) { | ||
tags.push({ | ||
name: match[1], | ||
line: _i3, | ||
annotation: codeLines[_i3].split("@" + match[1] + ": ")[1] | ||
}); | ||
codeLines.splice(_i3, 1); | ||
} | ||
} | ||
_i3++; | ||
} | ||
return tags; | ||
} // Keys in this object are used to filter out handbook options | ||
@@ -539,18 +562,18 @@ // before compiler options are set. | ||
for (var _i3 = 0; _i3 < codeLines.length; _i3++) { | ||
for (var _i4 = 0; _i4 < codeLines.length; _i4++) { | ||
var match = void 0; | ||
if (match = booleanConfigRegexp.exec(codeLines[_i3])) { | ||
if (match = booleanConfigRegexp.exec(codeLines[_i4])) { | ||
if (match[1] in options) { | ||
options[match[1]] = true; | ||
log("Setting options." + match[1] + " to true"); | ||
codeLines.splice(_i3, 1); | ||
_i3--; | ||
codeLines.splice(_i4, 1); | ||
_i4--; | ||
} | ||
} else if (match = valuedConfigRegexp.exec(codeLines[_i3])) { | ||
} else if (match = valuedConfigRegexp.exec(codeLines[_i4])) { | ||
if (match[1] in options) { | ||
options[match[1]] = match[2]; | ||
log("Setting options." + match[1] + " to " + match[2]); | ||
codeLines.splice(_i3, 1); | ||
_i3--; | ||
codeLines.splice(_i4, 1); | ||
_i4--; | ||
} | ||
@@ -599,5 +622,6 @@ } | ||
validateInput(code); | ||
code = cleanMarkdownEscaped(code); // This is mutated as the below functions pull out info | ||
code = cleanMarkdownEscaped(code); // NOTE: codeLines is mutated by the below functions: | ||
var codeLines = code.split(/\r\n?|\n/g); | ||
var tags = options.customTags ? filterCustomTags(codeLines, options.customTags) : []; | ||
@@ -963,2 +987,8 @@ var handbookOptions = _extends({}, filterHandbookOptions(codeLines), options.defaultOptions); | ||
}); | ||
tags.forEach(function (q) { | ||
return q.line -= lineOffset; | ||
}); | ||
tags = tags.filter(function (q) { | ||
return q.line > -1; | ||
}); | ||
} | ||
@@ -973,3 +1003,4 @@ | ||
errors: errors, | ||
playgroundURL: playgroundURL | ||
playgroundURL: playgroundURL, | ||
tags: tags | ||
}; | ||
@@ -976,0 +1007,0 @@ } |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@typescript/vfs");function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function n(e){return(n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e,t,n){return(i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct:function(e,t,n){var i=[null];i.push.apply(i,t);var o=new(Function.bind.apply(e,i));return n&&r(o,n.prototype),o}).apply(null,arguments)}function o(e){var t="function"==typeof Map?new Map:void 0;return(o=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,o)}function o(){return i(e,arguments,n(this).constructor)}return o.prototype=Object.create(e.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),r(o,e)})(e)}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function a(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return s(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}function c(e,t){switch(t){case"number":return+e;case"string":return e;case"boolean":return"true"===e.toLowerCase()||0===e.length}throw new p("Unknown primitive value in compiler flag","The only recognized primitives are number, string and boolean. Got "+t+" with "+e+".","This is likely a typo.")}var l=!1;try{l="undefined"!=typeof localStorage}catch(e){}var u="undefined"!=typeof process,f=l&&localStorage.getItem("DEBUG")||u&&process.env.DEBUG?console.log:function(e){return""},p=function(e){var t,n;function i(t,n,r,i){var o,s="\n## "+t+"\n\n"+n+"\n";return r&&(s+="\n"+r),i&&(s+="\n"+i),(o=e.call(this,s)||this).title=void 0,o.description=void 0,o.recommendation=void 0,o.code=void 0,o.title=t,o.description=n,o.recommendation=r,o.code=i,o}return n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,r(t,n),i}(o(Error));function h(e){for(var t=[],n=[],r=0,i=0,o=0,s=function(s){var c=e[s],l=function(){i=r,r+=c.length+1},u=function(t){f("Removing line "+s+" for "+t),o++,e.splice(s,1),s--};if(c.includes("//")){var p=/^\s*\/\/\s*\^+( .+)?$/.exec(c),h=/^\s*\/\/\s*\^\?\s*$/.exec(c),d=/^\s*\/\/ prettier-ignore$/.exec(c),v=/^\s*\/\/\s*\^\|$/.exec(c);if(null!==h){var m=c.indexOf("^");n.push({kind:"query",offset:m,text:void 0,docs:void 0,line:s+o-1}),u("having a query")}else if(null!==p){var g=c.indexOf("^"),y=c.lastIndexOf("^")-g+1,w=i+g,x=p[1]?p[1].trim():"";t.push({kind:"highlight",position:w,length:y,description:x,line:s}),u("having a highlight")}else if(null!==d)u("being a prettier ignore");else if(null!==v){var b=c.indexOf("^");n.push({kind:"completion",offset:b,text:void 0,docs:void 0,line:s+o-1}),u("having a completion query")}else l()}else l();a=s},a=0;a<e.length;a++)s(a);return{highlights:t,queries:n}}function d(e,t,n){var r=n.get(t.toLowerCase());if(f("Get "+e+" mapped option: "+t+" => "+r),void 0===r){var i=Array.from(n.keys());throw new p("Invalid inline compiler value","Got "+t+" for "+e+" but it is not a supported value by the TS compiler.","Allowed values: "+i.join(","))}return r}function v(e,t,n,r){f("Setting "+e+" to "+t);for(var i,o=function(){var r=i.value;if(r.name.toLowerCase()===e.toLowerCase()){switch(r.type){case"number":case"string":case"boolean":n[r.name]=c(t,r.type);break;case"list":var o=r.element.type,s=t.split(",");n[r.name]=s.map("string"==typeof o?function(e){return c(e,o)}:function(e){return d(r.name,e,o)});break;default:n[r.name]=d(r.name,t,r.type)}return{v:void 0}}},s=a(r.optionDeclarations);!(i=s()).done;){var l=o();if("object"==typeof l)return l.v}throw new p("Invalid inline compiler flag","There isn't a TypeScript compiler flag called '"+e+"'.","This is likely a typo, you can check all the compiler flags in the TSConfig reference, or check the additional Twoslash flags in the npm page for @typescript/twoslash.")}var m=/^\/\/\s?@(\w+)$/,g=/^\/\/\s?@(\w+):\s?(.+)$/,y={errors:[],noErrors:!1,showEmit:!1,showEmittedFile:void 0,noStaticSemanticInfo:!1,emit:!1,noErrorValidation:!1};exports.TwoslashError=p,exports.twoslasher=function(n,r,i){var o,s,c;void 0===i&&(i={});var l=null!=(o=i.tsModule)?o:require("typescript"),u=null!=(s=i.lzstringModule)?s:require("lz-string"),d=n,w=function(e){var t={js:"js",javascript:"js",ts:"ts",typescript:"ts",tsx:"tsx",jsx:"jsx",json:"json",jsn:"json"};if(t[e])return t[e];throw new p("Unknown TypeScript extension given to Twoslash","Received "+e+" but Twoslash only accepts: "+Object.keys(t)+" ","")}(r),x="index."+w;f("\n\nLooking at code: \n```"+w+"\n"+n+"\n```\n");var b=t({strict:!0,target:l.ScriptTarget.ES2016,allowJs:!0},null!=(c=i.defaultCompilerOptions)?c:{});!function(e){if(e.includes("// @errors "))throw new p("You have '// @errors ' (with a space)","You want '// @errors: ' (with a colon)","This is a pretty common typo");if(e.includes("// @filename "))throw new p("You have '// @filename ' (with a space)","You want '// @filename: ' (with a colon)","This is a pretty common typo")}(n);var j=(n=function(e){return(e=e.replace(/¨D/g,"$")).replace(/¨T/g,"~")}(n)).split(/\r\n?|\n/g),S=t({},function(e){for(var n=t({},y),r=0;r<e.length;r++){var i=void 0;(i=m.exec(e[r]))?i[1]in n&&(n[i[1]]=!0,f("Setting options."+i[1]+" to true"),e.splice(r,1),r--):(i=g.exec(e[r]))&&i[1]in n&&(n[i[1]]=i[2],f("Setting options."+i[1]+" to "+i[2]),e.splice(r,1),r--)}return"errors"in n&&"string"==typeof n.errors&&(n.errors=n.errors.split(" ").map(Number),f("Setting options.error to ",n.errors)),n}(j),i.defaultOptions),E=function(e,n,r){for(var i=t({},n),o=0;o<e.length;){var s=void 0;if(s=m.exec(e[o]))i[s[1]]=!0,v(s[1],"true",i,r);else{if(!(s=g.exec(e[o]))){o++;continue}if("filename"===s[1]){o++;continue}v(s[1],s[2],i,r)}e.splice(o,1)}return i}(j,b,l);S.showEmittedFile||(S.showEmittedFile=E.jsx&&E.jsx===l.JsxEmit.Preserve?"index.jsx":"index.js");var T=function(){var e=require("path");return(i.vfsRoot||process.cwd()).split(e.sep).join(e.posix.sep)},k=!!i.fsMap,O=k&&i.fsMap?i.fsMap:new Map,F=k?e.createSystem(O):e.createFSBackedSystem(O,T(),l),P=k?"/":T()+"/",q=e.createVirtualTypeScriptEnvironment(F,[],l,E,i.customTransformers),C=q.languageService;n=j.join("\n");for(var A,I=[],M=[],L=[],_=function(e,t,n){for(var r,i=e.split(/\r\n?|\n/g),o=e.includes("@filename: "+t)?"global.ts":t,s=[],c=[],l=a(i);!(r=l()).done;){var u=r.value;u.includes("// @filename: ")?(c.push([n+o,s]),o=u.split("// @filename: ")[1].trim(),s=[]):s.push(u)}return c.push([n+o,s]),c.filter((function(e){return e[1].length>0&&(e[1].length>1||""!==e[1][0])}))}(n,x,P),R=["js","jsx","ts","tsx"],$=_.map((function(e){return e[0]})),D=function(){var e=A.value,t=e[0],n=e[1],r=t.split(".").pop()||"",i=E.resolveJsonModule&&"json"===r;if(!R.includes(r)&&!i)return"continue";var o=n.join("\n");q.createFile(t,o);var s=h(n);L=L.concat(s.highlights);var a=s.queries.map((function(e,n){var r=q.getSourceFile(t),i=l.getPositionOfLineAndCharacter(r,e.line,e.offset);switch(e.kind){case"query":var o=C.getQuickInfoAtPosition(t,i);if(!o||!o.displayParts)throw new p("Invalid QuickInfo query","The request on line "+e.line+" in "+t+" for quickinfo via ^? returned no from the compiler.","This is likely that the x positioning is off.");return{kind:"query",text:o.displayParts.map((function(e){return e.text})).join(""),docs:o.documentation?o.documentation.map((function(e){return e.text})).join("<br/>"):void 0,line:e.line-n,offset:e.offset,file:t};case"completion":var s=C.getCompletionsAtPosition(t,i-1,{});if(!s&&!S.noErrorValidation)throw new p("Invalid completion query","The request on line "+e.line+" in "+t+" for completions via ^| returned no completions from the compiler.","This is likely that the positioning is off.");var a=function(e,t){e=String(e),t=Number(t)>>>0;var n=e.slice(0,t+1).search(/\S+$/),r=e.slice(t).search(/\s/);return r<0?{word:e.slice(n),startPos:n}:{word:e.slice(n,r+t),startPos:n}}(r.text,i-1),c=r.text.slice(a.startPos,i).split(".").pop()||"";return{kind:"completions",completions:(null==s?void 0:s.entries)||[],completionPrefix:c,line:e.line-n,offset:e.offset,file:t}}}));I=I.concat(a);var c=n.join("\n");q.updateFile(t,c)},U=a(_);!(A=U()).done;)D();var N=n.split(/\r\n?|\n/g);h(N),n=N.join("\n"),S.emit&&$.forEach((function(e){var t=e.split(".").pop()||"";R.includes(t)&&C.getEmitOutput(e).outputFiles.forEach((function(e){F.writeFile(e.name,e.text)}))}));var B=[],G=[];$.forEach((function(e){var t=e.split(".").pop()||"";if(R.includes(t)){S.noErrors||(B=B.concat(C.getSemanticDiagnostics(e),C.getSyntacticDiagnostics(e)));var r=q.sys.readFile(e),i=q.getSourceFile(e);if(!i)throw new p("Could not find a TypeScript sourcefile for '"+e+"' in the Twoslash vfs","It's a little hard to provide useful advice on this error. Maybe you imported something which the compiler doesn't think is a source file?","");if(!S.showEmit){for(var o,s=-1==n.indexOf(r)?0:n.indexOf(r),c=n.slice(0,s).split("\n").length-1,u=a(S.noStaticSemanticInfo?[]:function(e,t){var n=[];return function r(i){e.forEachChild(i,(function(i){if(e.isIdentifier(i)){var o=i.getStart(t,!1);n.push({span:e.createTextSpan(o,i.end-o),text:i.getText(t)})}r(i)}))}(t),n}(l,i));!(o=u()).done;){var f=o.value,h=f.span,d=C.getQuickInfoAtPosition(e,h.start);if(d&&d.displayParts){var v=d.displayParts.map((function(e){return e.text})).join(""),m=f.text,g=d.documentation?d.documentation.map((function(e){return e.text})).join("\n"):void 0,y=h.start+s,w=l.createSourceFile("_.ts",n,l.ScriptTarget.ES2015),x=l.getLineAndCharacterOfPosition(w,y);G.push({text:v,docs:g,start:y,length:h.length,line:x.line,character:x.character,targetString:m})}}I.filter((function(t){return t.file===e})).forEach((function(e){var t=l.getPositionOfLineAndCharacter(i,e.line,e.offset)+s;switch(e.kind){case"query":M.push({docs:e.docs,kind:"query",start:t+s,length:e.text.length,text:e.text,offset:e.offset,line:e.line+c+1});break;case"completions":M.push({completions:e.completions,kind:"completions",start:t+s,completionsPrefix:e.completionPrefix,length:1,offset:e.offset,line:e.line+c+1})}}))}}}));var V=B.filter((function(e){return e.file&&$.includes(e.file.fileName)}));!S.noErrorValidation&&V.length&&function(e,t,n,r,i){var o=e.filter((function(e){return!t.errors.includes(e.code)})),s=Array.from(new Set(o.map((function(e){return e.code})))).join(" ");if(o.length){var a=new Set(e.map((function(e){return e.code}))),c="// @errors: "+Array.from(a).join(" "),l=t.errors.length?"\nThe existing annotation specified "+t.errors.join(" "):"\nExpected: "+c,u={},f=[];o.forEach((function(e){var t,n=(null==(t=e.file)?void 0:t.fileName)&&e.file.fileName.replace(i,"");if(n){var r=u[n];r?r.push(e):u[n]=[e]}else f.push(e)}));var h=function(e,t){return e+"\n "+t.map((function(e){return"["+e.code+"] "+e.start+" - "+("string"==typeof e.messageText?e.messageText:e.messageText.messageText)})).join("\n ")},d=[];f.length&&d.push(h("Ambient Errors",f)),Object.keys(u).forEach((function(e){d.push(h(e,u[e]))}));var v=d.join("\n\n"),m=new p("Errors were thrown in the sample, but not included in an errors tag","These errors were not marked as being expected: "+s+". "+l,"Compiler Errors:\n\n"+v);throw m.code="## Code\n\n'''"+n+"\n"+r+"\n'''",m}}(V,S,r,d,P);for(var Q,Y=[],z=a(V);!(Q=z()).done;){var J=Q.value,H=q.sys.readFile(J.file.fileName),K=n.indexOf(H),W=l.flattenDiagnosticMessageText(J.messageText,"\n"),X="err-"+J.code+"-"+J.start+"-"+J.length,Z=l.getLineAndCharacterOfPosition(J.file,J.start);Y.push({category:J.category,code:J.code,length:J.length,start:J.start?J.start+K:void 0,line:Z.line,character:Z.character,renderedMessage:W,id:X})}if(S.showEmit){var ee=S.showEmittedFile||x,te=P+ee.replace(".jsx","").replace(".js","").replace(".d.ts","").replace(".map",""),ne=$.find((function(e){return e===te+".ts"||e===te+".tsx"}));if(!ne&&!E.outFile){var re=$.join(", ");throw new p("Could not find source file to show the emit for","Cannot find the corresponding **source** file "+ee+" for completions via ^| returned no quickinfo from the compiler.","Looked for: "+te+" in the vfs - which contains: "+re)}E.outFile&&(ne=$[0]);var ie=C.getEmitOutput(ne),oe=ie.outputFiles.find((function(e){return e.name===P+S.showEmittedFile||e.name===S.showEmittedFile}));if(!oe){var se=ie.outputFiles.map((function(e){return e.name})).join(", ");throw new p("Cannot find the output file in the Twoslash VFS","Looking for "+S.showEmittedFile+" in the Twoslash vfs after compiling",'Looked for" '+(P+S.showEmittedFile)+" in the vfs - which contains "+se+".")}n=oe.text,r=oe.name.split(".").pop(),L=[],I=[],G=[]}var ae="https://www.typescriptlang.org/play/#code/"+u.compressToEncodedURIComponent(d),ce="// ---cut---\n";if(n.includes(ce)){var le=n.indexOf(ce)+ce.length,ue=n.substr(0,le).split("\n").length-1;n=n.split(ce).pop(),G.forEach((function(e){e.start-=le,e.line-=ue})),G=G.filter((function(e){return e.start>-1})),Y.forEach((function(e){e.start&&(e.start-=le),e.line&&(e.line-=ue)})),Y=Y.filter((function(e){return e.start&&e.start>-1})),L.forEach((function(e){e.position-=le,e.line-=ue})),L=L.filter((function(e){return e.position>-1})),M.forEach((function(e){return e.line-=ue})),M=M.filter((function(e){return e.line>-1}))}return{code:n,extension:r,highlights:L,queries:M,staticQuickInfos:G,errors:Y,playgroundURL:ae}}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@typescript/vfs");function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function n(e){return(n=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e,t,n){return(i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct:function(e,t,n){var i=[null];i.push.apply(i,t);var o=new(Function.bind.apply(e,i));return n&&r(o,n.prototype),o}).apply(null,arguments)}function o(e){var t="function"==typeof Map?new Map:void 0;return(o=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,o)}function o(){return i(e,arguments,n(this).constructor)}return o.prototype=Object.create(e.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),r(o,e)})(e)}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function a(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return s(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}function c(e,t){switch(t){case"number":return+e;case"string":return e;case"boolean":return"true"===e.toLowerCase()||0===e.length}throw new p("Unknown primitive value in compiler flag","The only recognized primitives are number, string and boolean. Got "+t+" with "+e+".","This is likely a typo.")}var l=!1;try{l="undefined"!=typeof localStorage}catch(e){}var u="undefined"!=typeof process,f=l&&localStorage.getItem("DEBUG")||u&&process.env.DEBUG?console.log:function(e){return""},p=function(e){var t,n;function i(t,n,r,i){var o,s="\n## "+t+"\n\n"+n+"\n";return r&&(s+="\n"+r),i&&(s+="\n"+i),(o=e.call(this,s)||this).title=void 0,o.description=void 0,o.recommendation=void 0,o.code=void 0,o.title=t,o.description=n,o.recommendation=r,o.code=i,o}return n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,r(t,n),i}(o(Error));function h(e){for(var t=[],n=[],r=0,i=0,o=0,s=function(s){var c=e[s],l=function(){i=r,r+=c.length+1},u=function(t){f("Removing line "+s+" for "+t),o++,e.splice(s,1),s--};if(c.includes("//")){var p=/^\s*\/\/\s*\^+( .+)?$/.exec(c),h=/^\s*\/\/\s*\^\?\s*$/.exec(c),d=/^\s*\/\/ prettier-ignore$/.exec(c),v=/^\s*\/\/\s*\^\|$/.exec(c);if(null!==h){var m=c.indexOf("^");n.push({kind:"query",offset:m,text:void 0,docs:void 0,line:s+o-1}),u("having a query")}else if(null!==p){var g=c.indexOf("^"),y=c.lastIndexOf("^")-g+1,w=i+g,x=p[1]?p[1].trim():"";t.push({kind:"highlight",position:w,length:y,description:x,line:s}),u("having a highlight")}else if(null!==d)u("being a prettier ignore");else if(null!==v){var b=c.indexOf("^");n.push({kind:"completion",offset:b,text:void 0,docs:void 0,line:s+o-1}),u("having a completion query")}else l()}else l();a=s},a=0;a<e.length;a++)s(a);return{highlights:t,queries:n}}function d(e,t,n){var r=n.get(t.toLowerCase());if(f("Get "+e+" mapped option: "+t+" => "+r),void 0===r){var i=Array.from(n.keys());throw new p("Invalid inline compiler value","Got "+t+" for "+e+" but it is not a supported value by the TS compiler.","Allowed values: "+i.join(","))}return r}function v(e,t,n,r){f("Setting "+e+" to "+t);for(var i,o=function(){var r=i.value;if(r.name.toLowerCase()===e.toLowerCase()){switch(r.type){case"number":case"string":case"boolean":n[r.name]=c(t,r.type);break;case"list":var o=r.element.type,s=t.split(",");n[r.name]=s.map("string"==typeof o?function(e){return c(e,o)}:function(e){return d(r.name,e,o)});break;default:n[r.name]=d(r.name,t,r.type)}return{v:void 0}}},s=a(r.optionDeclarations);!(i=s()).done;){var l=o();if("object"==typeof l)return l.v}throw new p("Invalid inline compiler flag","There isn't a TypeScript compiler flag called '"+e+"'.","This is likely a typo, you can check all the compiler flags in the TSConfig reference, or check the additional Twoslash flags in the npm page for @typescript/twoslash.")}var m=/^\/\/\s?@(\w+)$/,g=/^\/\/\s?@(\w+):\s?(.+)$/,y={errors:[],noErrors:!1,showEmit:!1,showEmittedFile:void 0,noStaticSemanticInfo:!1,emit:!1,noErrorValidation:!1};exports.TwoslashError=p,exports.twoslasher=function(n,r,i){var o,s,c;void 0===i&&(i={});var l=null!=(o=i.tsModule)?o:require("typescript"),u=null!=(s=i.lzstringModule)?s:require("lz-string"),d=n,w=function(e){var t={js:"js",javascript:"js",ts:"ts",typescript:"ts",tsx:"tsx",jsx:"jsx",json:"json",jsn:"json"};if(t[e])return t[e];throw new p("Unknown TypeScript extension given to Twoslash","Received "+e+" but Twoslash only accepts: "+Object.keys(t)+" ","")}(r),x="index."+w;f("\n\nLooking at code: \n```"+w+"\n"+n+"\n```\n");var b=t({strict:!0,target:l.ScriptTarget.ES2016,allowJs:!0},null!=(c=i.defaultCompilerOptions)?c:{});!function(e){if(e.includes("// @errors "))throw new p("You have '// @errors ' (with a space)","You want '// @errors: ' (with a colon)","This is a pretty common typo");if(e.includes("// @filename "))throw new p("You have '// @filename ' (with a space)","You want '// @filename: ' (with a colon)","This is a pretty common typo")}(n);var j=(n=function(e){return(e=e.replace(/¨D/g,"$")).replace(/¨T/g,"~")}(n)).split(/\r\n?|\n/g),E=i.customTags?function(e,t){for(var n=[],r=0;r<e.length;){var i;(i=g.exec(e[r]))&&t.includes(i[1])&&(n.push({name:i[1],line:r,annotation:e[r].split("@"+i[1]+": ")[1]}),e.splice(r,1)),r++}return n}(j,i.customTags):[],S=t({},function(e){for(var n=t({},y),r=0;r<e.length;r++){var i=void 0;(i=m.exec(e[r]))?i[1]in n&&(n[i[1]]=!0,f("Setting options."+i[1]+" to true"),e.splice(r,1),r--):(i=g.exec(e[r]))&&i[1]in n&&(n[i[1]]=i[2],f("Setting options."+i[1]+" to "+i[2]),e.splice(r,1),r--)}return"errors"in n&&"string"==typeof n.errors&&(n.errors=n.errors.split(" ").map(Number),f("Setting options.error to ",n.errors)),n}(j),i.defaultOptions),T=function(e,n,r){for(var i=t({},n),o=0;o<e.length;){var s=void 0;if(s=m.exec(e[o]))i[s[1]]=!0,v(s[1],"true",i,r);else{if(!(s=g.exec(e[o]))){o++;continue}if("filename"===s[1]){o++;continue}v(s[1],s[2],i,r)}e.splice(o,1)}return i}(j,b,l);S.showEmittedFile||(S.showEmittedFile=T.jsx&&T.jsx===l.JsxEmit.Preserve?"index.jsx":"index.js");var k=function(){var e=require("path");return(i.vfsRoot||process.cwd()).split(e.sep).join(e.posix.sep)},O=!!i.fsMap,F=O&&i.fsMap?i.fsMap:new Map,P=O?e.createSystem(F):e.createFSBackedSystem(F,k(),l),q=O?"/":k()+"/",C=e.createVirtualTypeScriptEnvironment(P,[],l,T,i.customTransformers),A=C.languageService;n=j.join("\n");for(var I,M=[],L=[],_=[],R=function(e,t,n){for(var r,i=e.split(/\r\n?|\n/g),o=e.includes("@filename: "+t)?"global.ts":t,s=[],c=[],l=a(i);!(r=l()).done;){var u=r.value;u.includes("// @filename: ")?(c.push([n+o,s]),o=u.split("// @filename: ")[1].trim(),s=[]):s.push(u)}return c.push([n+o,s]),c.filter((function(e){return e[1].length>0&&(e[1].length>1||""!==e[1][0])}))}(n,x,q),$=["js","jsx","ts","tsx"],D=R.map((function(e){return e[0]})),U=function(){var e=I.value,t=e[0],n=e[1],r=t.split(".").pop()||"",i=T.resolveJsonModule&&"json"===r;if(!$.includes(r)&&!i)return"continue";var o=n.join("\n");C.createFile(t,o);var s=h(n);_=_.concat(s.highlights);var a=s.queries.map((function(e,n){var r=C.getSourceFile(t),i=l.getPositionOfLineAndCharacter(r,e.line,e.offset);switch(e.kind){case"query":var o=A.getQuickInfoAtPosition(t,i);if(!o||!o.displayParts)throw new p("Invalid QuickInfo query","The request on line "+e.line+" in "+t+" for quickinfo via ^? returned no from the compiler.","This is likely that the x positioning is off.");return{kind:"query",text:o.displayParts.map((function(e){return e.text})).join(""),docs:o.documentation?o.documentation.map((function(e){return e.text})).join("<br/>"):void 0,line:e.line-n,offset:e.offset,file:t};case"completion":var s=A.getCompletionsAtPosition(t,i-1,{});if(!s&&!S.noErrorValidation)throw new p("Invalid completion query","The request on line "+e.line+" in "+t+" for completions via ^| returned no completions from the compiler.","This is likely that the positioning is off.");var a=function(e,t){e=String(e),t=Number(t)>>>0;var n=e.slice(0,t+1).search(/\S+$/),r=e.slice(t).search(/\s/);return r<0?{word:e.slice(n),startPos:n}:{word:e.slice(n,r+t),startPos:n}}(r.text,i-1),c=r.text.slice(a.startPos,i).split(".").pop()||"";return{kind:"completions",completions:(null==s?void 0:s.entries)||[],completionPrefix:c,line:e.line-n,offset:e.offset,file:t}}}));M=M.concat(a);var c=n.join("\n");C.updateFile(t,c)},N=a(R);!(I=N()).done;)U();var B=n.split(/\r\n?|\n/g);h(B),n=B.join("\n"),S.emit&&D.forEach((function(e){var t=e.split(".").pop()||"";$.includes(t)&&A.getEmitOutput(e).outputFiles.forEach((function(e){P.writeFile(e.name,e.text)}))}));var G=[],V=[];D.forEach((function(e){var t=e.split(".").pop()||"";if($.includes(t)){S.noErrors||(G=G.concat(A.getSemanticDiagnostics(e),A.getSyntacticDiagnostics(e)));var r=C.sys.readFile(e),i=C.getSourceFile(e);if(!i)throw new p("Could not find a TypeScript sourcefile for '"+e+"' in the Twoslash vfs","It's a little hard to provide useful advice on this error. Maybe you imported something which the compiler doesn't think is a source file?","");if(!S.showEmit){for(var o,s=-1==n.indexOf(r)?0:n.indexOf(r),c=n.slice(0,s).split("\n").length-1,u=a(S.noStaticSemanticInfo?[]:function(e,t){var n=[];return function r(i){e.forEachChild(i,(function(i){if(e.isIdentifier(i)){var o=i.getStart(t,!1);n.push({span:e.createTextSpan(o,i.end-o),text:i.getText(t)})}r(i)}))}(t),n}(l,i));!(o=u()).done;){var f=o.value,h=f.span,d=A.getQuickInfoAtPosition(e,h.start);if(d&&d.displayParts){var v=d.displayParts.map((function(e){return e.text})).join(""),m=f.text,g=d.documentation?d.documentation.map((function(e){return e.text})).join("\n"):void 0,y=h.start+s,w=l.createSourceFile("_.ts",n,l.ScriptTarget.ES2015),x=l.getLineAndCharacterOfPosition(w,y);V.push({text:v,docs:g,start:y,length:h.length,line:x.line,character:x.character,targetString:m})}}M.filter((function(t){return t.file===e})).forEach((function(e){var t=l.getPositionOfLineAndCharacter(i,e.line,e.offset)+s;switch(e.kind){case"query":L.push({docs:e.docs,kind:"query",start:t+s,length:e.text.length,text:e.text,offset:e.offset,line:e.line+c+1});break;case"completions":L.push({completions:e.completions,kind:"completions",start:t+s,completionsPrefix:e.completionPrefix,length:1,offset:e.offset,line:e.line+c+1})}}))}}}));var Q=G.filter((function(e){return e.file&&D.includes(e.file.fileName)}));!S.noErrorValidation&&Q.length&&function(e,t,n,r,i){var o=e.filter((function(e){return!t.errors.includes(e.code)})),s=Array.from(new Set(o.map((function(e){return e.code})))).join(" ");if(o.length){var a=new Set(e.map((function(e){return e.code}))),c="// @errors: "+Array.from(a).join(" "),l=t.errors.length?"\nThe existing annotation specified "+t.errors.join(" "):"\nExpected: "+c,u={},f=[];o.forEach((function(e){var t,n=(null==(t=e.file)?void 0:t.fileName)&&e.file.fileName.replace(i,"");if(n){var r=u[n];r?r.push(e):u[n]=[e]}else f.push(e)}));var h=function(e,t){return e+"\n "+t.map((function(e){return"["+e.code+"] "+e.start+" - "+("string"==typeof e.messageText?e.messageText:e.messageText.messageText)})).join("\n ")},d=[];f.length&&d.push(h("Ambient Errors",f)),Object.keys(u).forEach((function(e){d.push(h(e,u[e]))}));var v=d.join("\n\n"),m=new p("Errors were thrown in the sample, but not included in an errors tag","These errors were not marked as being expected: "+s+". "+l,"Compiler Errors:\n\n"+v);throw m.code="## Code\n\n'''"+n+"\n"+r+"\n'''",m}}(Q,S,r,d,q);for(var Y,z=[],J=a(Q);!(Y=J()).done;){var H=Y.value,K=C.sys.readFile(H.file.fileName),W=n.indexOf(K),X=l.flattenDiagnosticMessageText(H.messageText,"\n"),Z="err-"+H.code+"-"+H.start+"-"+H.length,ee=l.getLineAndCharacterOfPosition(H.file,H.start);z.push({category:H.category,code:H.code,length:H.length,start:H.start?H.start+W:void 0,line:ee.line,character:ee.character,renderedMessage:X,id:Z})}if(S.showEmit){var te=S.showEmittedFile||x,ne=q+te.replace(".jsx","").replace(".js","").replace(".d.ts","").replace(".map",""),re=D.find((function(e){return e===ne+".ts"||e===ne+".tsx"}));if(!re&&!T.outFile){var ie=D.join(", ");throw new p("Could not find source file to show the emit for","Cannot find the corresponding **source** file "+te+" for completions via ^| returned no quickinfo from the compiler.","Looked for: "+ne+" in the vfs - which contains: "+ie)}T.outFile&&(re=D[0]);var oe=A.getEmitOutput(re),se=oe.outputFiles.find((function(e){return e.name===q+S.showEmittedFile||e.name===S.showEmittedFile}));if(!se){var ae=oe.outputFiles.map((function(e){return e.name})).join(", ");throw new p("Cannot find the output file in the Twoslash VFS","Looking for "+S.showEmittedFile+" in the Twoslash vfs after compiling",'Looked for" '+(q+S.showEmittedFile)+" in the vfs - which contains "+ae+".")}n=se.text,r=se.name.split(".").pop(),_=[],M=[],V=[]}var ce="https://www.typescriptlang.org/play/#code/"+u.compressToEncodedURIComponent(d),le="// ---cut---\n";if(n.includes(le)){var ue=n.indexOf(le)+le.length,fe=n.substr(0,ue).split("\n").length-1;n=n.split(le).pop(),V.forEach((function(e){e.start-=ue,e.line-=fe})),V=V.filter((function(e){return e.start>-1})),z.forEach((function(e){e.start&&(e.start-=ue),e.line&&(e.line-=fe)})),z=z.filter((function(e){return e.start&&e.start>-1})),_.forEach((function(e){e.position-=ue,e.line-=fe})),_=_.filter((function(e){return e.position>-1})),L.forEach((function(e){return e.line-=fe})),L=L.filter((function(e){return e.line>-1})),E.forEach((function(e){return e.line-=fe})),E=E.filter((function(e){return e.line>-1}))}return{code:n,extension:r,highlights:_,queries:L,staticQuickInfos:V,errors:z,playgroundURL:ce,tags:E}}; | ||
//# sourceMappingURL=twoslash.cjs.production.min.js.map |
@@ -517,2 +517,25 @@ import { createSystem, createFSBackedSystem, createVirtualTypeScriptEnvironment } from '@typescript/vfs'; | ||
return options; | ||
} | ||
function filterCustomTags(codeLines, customTags) { | ||
var tags = []; | ||
for (var _i3 = 0; _i3 < codeLines.length;) { | ||
var match = void 0; | ||
if (match = valuedConfigRegexp.exec(codeLines[_i3])) { | ||
if (customTags.includes(match[1])) { | ||
tags.push({ | ||
name: match[1], | ||
line: _i3, | ||
annotation: codeLines[_i3].split("@" + match[1] + ": ")[1] | ||
}); | ||
codeLines.splice(_i3, 1); | ||
} | ||
} | ||
_i3++; | ||
} | ||
return tags; | ||
} // Keys in this object are used to filter out handbook options | ||
@@ -535,18 +558,18 @@ // before compiler options are set. | ||
for (var _i3 = 0; _i3 < codeLines.length; _i3++) { | ||
for (var _i4 = 0; _i4 < codeLines.length; _i4++) { | ||
var match = void 0; | ||
if (match = booleanConfigRegexp.exec(codeLines[_i3])) { | ||
if (match = booleanConfigRegexp.exec(codeLines[_i4])) { | ||
if (match[1] in options) { | ||
options[match[1]] = true; | ||
log("Setting options." + match[1] + " to true"); | ||
codeLines.splice(_i3, 1); | ||
_i3--; | ||
codeLines.splice(_i4, 1); | ||
_i4--; | ||
} | ||
} else if (match = valuedConfigRegexp.exec(codeLines[_i3])) { | ||
} else if (match = valuedConfigRegexp.exec(codeLines[_i4])) { | ||
if (match[1] in options) { | ||
options[match[1]] = match[2]; | ||
log("Setting options." + match[1] + " to " + match[2]); | ||
codeLines.splice(_i3, 1); | ||
_i3--; | ||
codeLines.splice(_i4, 1); | ||
_i4--; | ||
} | ||
@@ -595,5 +618,6 @@ } | ||
validateInput(code); | ||
code = cleanMarkdownEscaped(code); // This is mutated as the below functions pull out info | ||
code = cleanMarkdownEscaped(code); // NOTE: codeLines is mutated by the below functions: | ||
var codeLines = code.split(/\r\n?|\n/g); | ||
var tags = options.customTags ? filterCustomTags(codeLines, options.customTags) : []; | ||
@@ -959,2 +983,8 @@ var handbookOptions = _extends({}, filterHandbookOptions(codeLines), options.defaultOptions); | ||
}); | ||
tags.forEach(function (q) { | ||
return q.line -= lineOffset; | ||
}); | ||
tags = tags.filter(function (q) { | ||
return q.line > -1; | ||
}); | ||
} | ||
@@ -969,3 +999,4 @@ | ||
errors: errors, | ||
playgroundURL: playgroundURL | ||
playgroundURL: playgroundURL, | ||
tags: tags | ||
}; | ||
@@ -972,0 +1003,0 @@ } |
@@ -527,2 +527,25 @@ | ||
return options; | ||
} | ||
function filterCustomTags(codeLines, customTags) { | ||
var tags = []; | ||
for (var _i3 = 0; _i3 < codeLines.length;) { | ||
var match = void 0; | ||
if (match = valuedConfigRegexp.exec(codeLines[_i3])) { | ||
if (customTags.includes(match[1])) { | ||
tags.push({ | ||
name: match[1], | ||
line: _i3, | ||
annotation: codeLines[_i3].split("@" + match[1] + ": ")[1] | ||
}); | ||
codeLines.splice(_i3, 1); | ||
} | ||
} | ||
_i3++; | ||
} | ||
return tags; | ||
} // Keys in this object are used to filter out handbook options | ||
@@ -545,18 +568,18 @@ // before compiler options are set. | ||
for (var _i3 = 0; _i3 < codeLines.length; _i3++) { | ||
for (var _i4 = 0; _i4 < codeLines.length; _i4++) { | ||
var match = void 0; | ||
if (match = booleanConfigRegexp.exec(codeLines[_i3])) { | ||
if (match = booleanConfigRegexp.exec(codeLines[_i4])) { | ||
if (match[1] in options) { | ||
options[match[1]] = true; | ||
log("Setting options." + match[1] + " to true"); | ||
codeLines.splice(_i3, 1); | ||
_i3--; | ||
codeLines.splice(_i4, 1); | ||
_i4--; | ||
} | ||
} else if (match = valuedConfigRegexp.exec(codeLines[_i3])) { | ||
} else if (match = valuedConfigRegexp.exec(codeLines[_i4])) { | ||
if (match[1] in options) { | ||
options[match[1]] = match[2]; | ||
log("Setting options." + match[1] + " to " + match[2]); | ||
codeLines.splice(_i3, 1); | ||
_i3--; | ||
codeLines.splice(_i4, 1); | ||
_i4--; | ||
} | ||
@@ -605,5 +628,6 @@ } | ||
validateInput(code); | ||
code = cleanMarkdownEscaped(code); // This is mutated as the below functions pull out info | ||
code = cleanMarkdownEscaped(code); // NOTE: codeLines is mutated by the below functions: | ||
var codeLines = code.split(/\r\n?|\n/g); | ||
var tags = options.customTags ? filterCustomTags(codeLines, options.customTags) : []; | ||
@@ -969,2 +993,8 @@ var handbookOptions = _extends({}, filterHandbookOptions(codeLines), options.defaultOptions); | ||
}); | ||
tags.forEach(function (q) { | ||
return q.line -= lineOffset; | ||
}); | ||
tags = tags.filter(function (q) { | ||
return q.line > -1; | ||
}); | ||
} | ||
@@ -979,3 +1009,4 @@ | ||
errors: errors, | ||
playgroundURL: playgroundURL | ||
playgroundURL: playgroundURL, | ||
tags: tags | ||
}; | ||
@@ -982,0 +1013,0 @@ } |
{ | ||
"name": "@typescript/twoslash", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "author": "TypeScript team", |
@@ -169,3 +169,4 @@ # TypeScript TwoSlash | ||
> ], | ||
> "playgroundURL": "https://www.typescriptlang.org/play/#code/PTAEAEBcEMCcHMCmkBcoCiBlATABgIwCsAUCBIrLAPawDOaA7LrgGzHEBmArgHYDGkAJZUeoDjwAUtAJSgA3sVCg+I2lQA2iAHTqq8KVtpcARpFgSAzNOnEAvu3ESALNhtA" | ||
> "playgroundURL": "https://www.typescriptlang.org/play/#code/PTAEAEBcEMCcHMCmkBcoCiBlATABgIwCsAUCBIrLAPawDOaA7LrgGzHEBmArgHYDGkAJZUeoDjwAUtAJSgA3sVCg+I2lQA2iAHTqq8KVtpcARpFgSAzNOnEAvu3ESALNhtA", | ||
> "tags": [] | ||
> } | ||
@@ -209,3 +210,4 @@ > ``` | ||
> "errors": [], | ||
> "playgroundURL": "https://www.typescriptlang.org/play/#code/PTAEAEDsHsEkFsAOAbAlgY1QFwIKQJ4BcoAZgIbIDOApgFAgRZkBOA5tVsQKIDKATAAYAjAFZa9MABUAFqkqgA7qmTJQMLKCzTm0BaABG1dGQCuNUNBKbp1NXCRpMuArRInI6LKmiRSkABSUAJSgAN60oKDoPpTQyNQAdMjQrIEJlCb6WMz+AMxBQbQAvuIkAQAsfEEA3LRAA" | ||
> "playgroundURL": "https://www.typescriptlang.org/play/#code/PTAEAEDsHsEkFsAOAbAlgY1QFwIKQJ4BcoAZgIbIDOApgFAgRZkBOA5tVsQKIDKATAAYAjAFZa9MABUAFqkqgA7qmTJQMLKCzTm0BaABG1dGQCuNUNBKbp1NXCRpMuArRInI6LKmiRSkABSUAJSgAN60oKDoPpTQyNQAdMjQrIEJlCb6WMz+AMxBQbQAvuIkAQAsfEEA3LRAA", | ||
> "tags": [] | ||
> } | ||
@@ -368,3 +370,4 @@ > ``` | ||
> "errors": [], | ||
> "playgroundURL": "https://www.typescriptlang.org/play/#code/MYewdgziA2CmB00QHMBQB6dACHusD0AfVIA" | ||
> "playgroundURL": "https://www.typescriptlang.org/play/#code/MYewdgziA2CmB00QHMBQB6dACHusD0AfVIA", | ||
> "tags": [] | ||
> } | ||
@@ -452,3 +455,4 @@ > ``` | ||
> "errors": [], | ||
> "playgroundURL": "https://www.typescriptlang.org/play/#code/JYOwLgpgTgZghgYwgAgJIBMAycBGEA2yA3ssOgFzIgCuAtnlADTID0AVMgM4D2tKMwAuk7I2LZAF8AUKEixEKAHJw+2PIRIgVESpzBRQAc2btk3MAAtoyAUJFjJUsAE8ADku0B5KBgA8AFWQIAA9IEGEqOgZkAB8ufSMAPmQAXmRAkLCImnprAH40LFwCZEplVWL8AG4pFnF-C2ARBF4+cC4Lbmp8dCpzZDxSEAR8anQIdCla8QBaOYRqMDmZqRhqYbBgbhBkBCgIOEg1AgCg0IhwkRzouL0DEENEgAoyb3KddIBKMq8fdADkkQpMgQchLFBuAB3ZAAInWwFornwEDakHQMKk0ikyLAyDgqV2+0OEGO+CeMJc7k4e2ArjAMM+NTqIIAenkpjiBgS9gcjpUngAmAB0AA5GdNWezsRBcQhuUS+eongBZQ4WIVQODhXhPT7IAowqz4fDcGGlZAAFgF4uZyDZUiAA" | ||
> "playgroundURL": "https://www.typescriptlang.org/play/#code/JYOwLgpgTgZghgYwgAgJIBMAycBGEA2yA3ssOgFzIgCuAtnlADTID0AVMgM4D2tKMwAuk7I2LZAF8AUKEixEKAHJw+2PIRIgVESpzBRQAc2btk3MAAtoyAUJFjJUsAE8ADku0B5KBgA8AFWQIAA9IEGEqOgZkAB8ufSMAPmQAXmRAkLCImnprAH40LFwCZEplVWL8AG4pFnF-C2ARBF4+cC4Lbmp8dCpzZDxSEAR8anQIdCla8QBaOYRqMDmZqRhqYbBgbhBkBCgIOEg1AgCg0IhwkRzouL0DEENEgAoyb3KddIBKMq8fdADkkQpMgQchLFBuAB3ZAAInWwFornwEDakHQMKk0ikyLAyDgqV2+0OEGO+CeMJc7k4e2ArjAMM+NTqIIAenkpjiBgS9gcjpUngAmAB0AA5GdNWezsRBcQhuUS+eongBZQ4WIVQODhXhPT7IAowqz4fDcGGlZAAFgF4uZyDZUiAA", | ||
> "tags": [] | ||
> } | ||
@@ -493,3 +497,4 @@ > ``` | ||
> "errors": [], | ||
> "playgroundURL": "https://www.typescriptlang.org/play/#code/PTAEAEBMFMGMBsCGAnRAXAlgewHYC5Q1kBXaAKBAgGcALLAdwFEBbDNCscWhlttaSADEM8aAQw4YADwB0kGWipkKAKhVlQK0AHFoiwjWihROAOZoaoLADNQiUFSITTGreAAOKRM1AA3RPCkdg5OZq7AZNBS7ljIaKDWxDiwmLigpnoAyqGmADLQZhYAFP6BYiHIzgCUoADeGqDIesTIOH4BpDIm5jRkAL5kQA" | ||
> "playgroundURL": "https://www.typescriptlang.org/play/#code/PTAEAEBMFMGMBsCGAnRAXAlgewHYC5Q1kBXaAKBAgGcALLAdwFEBbDNCscWhlttaSADEM8aAQw4YADwB0kGWipkKAKhVlQK0AHFoiwjWihROAOZoaoLADNQiUFSITTGreAAOKRM1AA3RPCkdg5OZq7AZNBS7ljIaKDWxDiwmLigpnoAyqGmADLQZhYAFP6BYiHIzgCUoADeGqDIesTIOH4BpDIm5jRkAL5kQA", | ||
> "tags": [] | ||
> } | ||
@@ -536,3 +541,4 @@ > ``` | ||
> ], | ||
> "playgroundURL": "https://www.typescriptlang.org/play/#code/PTAEAEFMCdoe2gZwFygEwGY1oFAGM4A7RAF1AENUAlSA6AEwB5ToBLQgcwBpQX2OAfKAC8oAN4BfHABtIZAEbVaCJn049CAVwC28mENGSc8kRRxA" | ||
> "playgroundURL": "https://www.typescriptlang.org/play/#code/PTAEAEFMCdoe2gZwFygEwGY1oFAGM4A7RAF1AENUAlSA6AEwB5ToBLQgcwBpQX2OAfKAC8oAN4BfHABtIZAEbVaCJn049CAVwC28mENGSc8kRRxA", | ||
> "tags": [] | ||
> } | ||
@@ -580,3 +586,4 @@ > ``` | ||
> "errors": [], | ||
> "playgroundURL": "https://www.typescriptlang.org/play/#code/GYVwdgxgLglg9mABAcwE4FN1QBQAd2oDOCAXIoVKjGMgDSIAmAhlOmQCIvoCUiA3gChEiCAmIAbdADpxcZNgAGACXTjZiACR98RBAF96UOMwCeiGIU19mrKUc6sAypWrzuegIQLuAbgF6BATRMHAAiAFkmBgYLBFD6MHQAd0QHdGxuXwEAemzhfILC4QA9UrLygSA" | ||
> "playgroundURL": "https://www.typescriptlang.org/play/#code/GYVwdgxgLglg9mABAcwE4FN1QBQAd2oDOCAXIoVKjGMgDSIAmAhlOmQCIvoCUiA3gChEiCAmIAbdADpxcZNgAGACXTjZiACR98RBAF96UOMwCeiGIU19mrKUc6sAypWrzuegIQLuAbgF6BATRMHAAiAFkmBgYLBFD6MHQAd0QHdGxuXwEAemzhfILC4QA9UrLygSA", | ||
> "tags": [] | ||
> } | ||
@@ -617,3 +624,4 @@ > ``` | ||
> "errors": [], | ||
> "playgroundURL": "https://www.typescriptlang.org/play/#code/PTAEAEDMEsBsFMB2BDAtvAXKGCC0B3aAFwAtd4APABwHsAnIgOiIGcAoS2h0AYxsRZFQJeLFg0A6vVgATUAF5QAIgCiFNFQShBdaIgDmSgNxs2ICDiRpMoPTMrN20VFyEBvEWMnSZAX2x0NKjKjMCWBMRknPRESmx8AjQIjOL6ABSe4lJ0sgCUbEA" | ||
> "playgroundURL": "https://www.typescriptlang.org/play/#code/PTAEAEDMEsBsFMB2BDAtvAXKGCC0B3aAFwAtd4APABwHsAnIgOiIGcAoS2h0AYxsRZFQJeLFg0A6vVgATUAF5QAIgCiFNFQShBdaIgDmSgNxs2ICDiRpMoPTMrN20VFyEBvEWMnSZAX2x0NKjKjMCWBMRknPRESmx8AjQIjOL6ABSe4lJ0sgCUbEA", | ||
> "tags": [] | ||
> } | ||
@@ -670,3 +678,4 @@ > ``` | ||
> "errors": [], | ||
> "playgroundURL": "https://www.typescriptlang.org/play/#code/PTAEAEDMEsBsFMB2BDAtvAXKAwge1QA66JIAuAdKQM4AeAUNIbgE6mgBK8yAxm5M-lAAiZl15C6deDSKtQkAK6Je0YqAAS8WLFwAKAJSgA3nVChRpBc0Shdps6AA8AE2gA3AHz2HTgBYBGD01tXFAAdRZYZ0dgAK8fGNdPe306AF9JEAgYBBR0LGhEZ2lKKgYmOSMNLR1QNPkBVGFyYDwmEkRSCW5iKlwEch0Ac11gnVSgA" | ||
> "playgroundURL": "https://www.typescriptlang.org/play/#code/PTAEAEDMEsBsFMB2BDAtvAXKAwge1QA66JIAuAdKQM4AeAUNIbgE6mgBK8yAxm5M-lAAiZl15C6deDSKtQkAK6Je0YqAAS8WLFwAKAJSgA3nVChRpBc0Shdps6AA8AE2gA3AHz2HTgBYBGD01tXFAAdRZYZ0dgAK8fGNdPe306AF9JEAgYBBR0LGhEZ2lKKgYmOSMNLR1QNPkBVGFyYDwmEkRSCW5iKlwEch0Ac11gnVSgA", | ||
> "tags": [] | ||
> } | ||
@@ -708,3 +717,4 @@ > ``` | ||
> "errors": [], | ||
> "playgroundURL": "https://www.typescriptlang.org/play/#code/DYUwLgBAZg9jEF4ICIAWJjHmdAnEAhMgNwBQA9ORBAHoD8pQA" | ||
> "playgroundURL": "https://www.typescriptlang.org/play/#code/DYUwLgBAZg9jEF4ICIAWJjHmdAnEAhMgNwBQA9ORBAHoD8pQA", | ||
> "tags": [] | ||
> } | ||
@@ -780,3 +790,4 @@ > ``` | ||
> "errors": [], | ||
> "playgroundURL": "https://www.typescriptlang.org/play/#code/PTAEAEGcAsHsHcCiBbAlgFwFAgughgE4DmApugFyiIDKArNmOACYIB2ANiQG4nsYkE86VLFaYGoALSTUyAA6wC6ABK85AyKFGVqcgiTxNQ0NQNDxU7dqABGJULIVKSRgGYFYyUAHJ0kPjbe4iQAHk7ooK4ArqwAxsKikawAFIQElKxRyHYEANoAugCUoADemKCgsaKQEWkATKAAvKC5AIwANKAAdD1p+ZgAvphAA" | ||
> "playgroundURL": "https://www.typescriptlang.org/play/#code/PTAEAEGcAsHsHcCiBbAlgFwFAgughgE4DmApugFyiIDKArNmOACYIB2ANiQG4nsYkE86VLFaYGoALSTUyAA6wC6ABK85AyKFGVqcgiTxNQ0NQNDxU7dqABGJULIVKSRgGYFYyUAHJ0kPjbe4iQAHk7ooK4ArqwAxsKikawAFIQElKxRyHYEANoAugCUoADemKCgsaKQEWkATKAAvKC5AIwANKAAdD1p+ZgAvphAA", | ||
> "tags": [] | ||
> } | ||
@@ -822,2 +833,4 @@ > ``` | ||
vfsRoot?: string | ||
/** A set of known `// @[tags]` tags to extract and not treat as a comment */ | ||
customTags?: string[] | ||
} | ||
@@ -879,2 +892,11 @@ ``` | ||
}[] | ||
/** The extracted twoslash commands for any custom tags passed in via customTags */ | ||
tags: { | ||
/** What was the name of the tag */ | ||
name: string | ||
/** Where was it located in the original source file */ | ||
line: number | ||
/** What was the text after the `// @tag: ` string (optional because you could do // @tag on it's own line without the ':') */ | ||
annotation?: string | ||
}[] | ||
/** Diagnostic error messages which came up when creating the program */ | ||
@@ -881,0 +903,0 @@ errors: { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
346429
2744
926