代码拉取完成,页面将自动刷新
(self.webpackChunktypescriptlang_org=self.webpackChunktypescriptlang_org||[]).push([[618],{9796:function(e,t,i){"use strict";i.r(t),i.d(t,{default:function(){return R}});var n=i(7575),o=i(7183),a=i.n(o),r=i(2784),s=i(8316),l=i(7480),c=i(8447),p=i(6705),d=i(876),y=i(357),u=i(4345),g="\nThe bug workbench uses <a href='https://www.npmjs.com/package/@typescript/twoslash'>Twoslash</a> to help you create accurate bug reports. \nTwoslash is a markup format for TypeScript files which lets you highlight code, handle-multiple files and\nshow the files the TypeScript compiler creates.\n".trim(),m="\nThe bug workbench lets you make reproductions of bugs which are trivial to verify against many different versions of TypeScript over time.\n".trim(),h="\nA repro can highlight an issue in a few ways:\n<ul>\n <li>Does this code sample fail to compile?</li>\n <li>Is a type wrong at a position in the file?</li>\n <li>Is the .js/.d.ts/.map file wrong?</li>\n</ul>\n".trim(),f='\nTo learn how the tools for making a repro, go to "Docs"\n\n'.trim(),D=function(e,t){return{id:"about",displayName:"About",didMount:function(e,i){var n=t.createDesignSystem(i);n.title("Twoslash Overview"),n.p(g),n.p(m),n.p(h),n.p(f)}}},b=function(e,t){var i;return{id:"results",displayName:"Debug",didMount:function(e,t){i=t},noResults:function(){var e=t.createDesignSystem(i);e.clear(),e.p("No results")},getResults:function(e,n,o){var a=t.createDesignSystem(i);a.clear(),a.p("This tab shows the raw data passed back from Twoslash. This can be useful in debugging if something isn't working as you would expect. That said, if you're struggling with a repro - ask in the <a href='https://discord.gg/typescript'>#compiler-api channel of the TypeScript Discord</a>."),a.subtitle("Output Code as "+n.extension),a.code(n.code),n.staticQuickInfos=["..."],a.subtitle("Twoslash JSON"),a.code(JSON.stringify(n,null," ")),a.subtitle("Virtual File System");var r=Array.from(o.keys()).reverse(),s=[];r.forEach((function(e){e.startsWith("/lib.")?s.push(e.replace("/lib","lib")):(a.p("<strong>"+e+"</strong>"),a.code(o.get(e).trim()))})),a.subtitle("Lib files"),a.p(s.join(", "))}}},v=function(e,t){var i;return{id:"assertions",displayName:"Asserts",didMount:function(e,t){i=t},noResults:function(e,n){var o=t.createDesignSystem(i);o.clear(),o.title("Exception Raised"),o.p("This could be a successful repro of a crashing compiler bug, or potentially an issue in Twoslash."),o.subtitle("Error:"),n.message&&o.p(n.message),n.stack&&o.code(n.stack)},getResults:function(e,n,o,a){var r=t.createDesignSystem(i);r.clear(),n.queries.length>0||a||n.errors.length>0?r.title("Assertions Found"):(r.title("No Assertions"),r.p("Assuming that this repro is for code which compiles but should not."));var s=n.queries.map((function(e){var t="";switch(e.kind){case"query":t=e.text||"No text found for query";break;case"completions":if(e.completions){var i,n=e.completions.map((function(e){return e.name})).join(", "),o=e.completions.filter((function(t){return t.name.startsWith(e.completionsPrefix||"____")})).map((function(e){return e.name})).join(", ");t=(null!==(i=e.completionsPrefix)&&void 0!==i&&i.length?"Filtered Completions: "+o+".\n\n":"")+"All: "+n+"."}else t="Could not get completions"}return{category:3,code:0,file:void 0,length:0,messageText:t||"-",start:0}}));s.length&&(r.subtitle("Queries in Code"),r.listDiags(e.getModel(),s));var l=n.errors.map((function(e){return{category:1,code:e.code,file:void 0,length:0,messageText:e.renderedMessage,start:0}}));l.length&&(r.subtitle("Compiler Errors"),r.listDiags(e.getModel(),l),r.subtitle("If want these errors:"),r.code("// @errors: "+n.errors.map((function(e){return e.code})).join(" "))),a&&(r.subtitle("Output"),r.code(n.code))}}},w=function(e,t){var i,n=function(e,t,i){t.subtitle("Markdown for issue"),t.button({label:"Copy Markdown",onclick:function(){return navigator.clipboard.writeText(o)}}),t.p("");var n=document&&document.location?document.location.href:"",o=("\n```ts repro\n"+i.replace(/</g,"<")+"\n```\n\n[Workbench Repro]("+n+")\n ").trim();t.code(o),t.p("Congrats! These repros make it much easier for us to keep track of bugs on the TypeScript team. You can copy & paste this into an issue or comment on the TypeScript repo to have it get hooked up.")};return{id:"md",displayName:"Export",didMount:function(e,t){i=t},noResults:function(e){var o=t.createDesignSystem(i);o.clear(),n(0,o,e.getText())},getResults:function(e){var o=t.createDesignSystem(i);o.clear(),n(0,o,e.getText())}}},E=JSON.parse('{"Y":[{"id":"files","display":"Files","oneliner":"<p>Include a list of files. This does not support glob patterns, as opposed to <a href=\\"#include\\"><code>include</code></a>.</p>\\n","categoryID":"Top Level","categoryDisplay":"Top Level"},{"id":"extends","display":"Extends","oneliner":"<p>Specify one or more path or node module references to base configuration files from which settings are inherited.</p>\\n","categoryID":"Top Level","categoryDisplay":"Top Level"},{"id":"include","display":"Include","oneliner":"<p>Specify a list of glob patterns that match files to be included in compilation.</p>\\n","categoryID":"Top Level","categoryDisplay":"Top Level"},{"id":"exclude","display":"Exclude","oneliner":"<p>Filters results from the <a href=\\"#include\\"><code>include</code></a> option.</p>\\n","categoryID":"Top Level","categoryDisplay":"Top Level"},{"id":"references","display":"References","oneliner":"<p>Specify an array of objects that specify paths for projects. Used in project references.</p>\\n","categoryID":"Top Level","categoryDisplay":"Top Level"},{"id":"allowUnreachableCode","display":"Allow Unreachable Code","oneliner":"<p>Disable error reporting for unreachable code.</p>\\n","categoryID":"Type_Checking_6248","categoryDisplay":"Type Checking"},{"id":"allowUnusedLabels","display":"Allow Unused Labels","oneliner":"<p>Disable error reporting for unused labels.</p>\\n","categoryID":"Type_Checking_6248","categoryDisplay":"Type Checking"},{"id":"alwaysStrict","display":"Always Strict","oneliner":"<p>Ensure \'use strict\' is always emitted.</p>\\n","categoryID":"Type_Checking_6248","categoryDisplay":"Type Checking"},{"id":"exactOptionalPropertyTypes","display":"exactOptionalPropertyTypes","oneliner":"<p>Interpret optional property types as written, rather than adding <code>undefined</code>.</p>\\n","categoryID":"Type_Checking_6248","categoryDisplay":"Type Checking"},{"id":"noFallthroughCasesInSwitch","display":"No Fallthrough Cases In Switch","oneliner":"<p>Enable error reporting for fallthrough cases in switch statements.</p>\\n","categoryID":"Type_Checking_6248","categoryDisplay":"Type Checking"},{"id":"noImplicitAny","display":"No Implicit Any","oneliner":"<p>Enable error reporting for expressions and declarations with an implied <code>any</code> type.</p>\\n","categoryID":"Type_Checking_6248","categoryDisplay":"Type Checking"},{"id":"noImplicitOverride","display":"noImplicitOverride","oneliner":"<p>Ensure overriding members in derived classes are marked with an override modifier.</p>\\n","categoryID":"Type_Checking_6248","categoryDisplay":"Type Checking"},{"id":"noImplicitReturns","display":"No Implicit Returns","oneliner":"<p>Enable error reporting for codepaths that do not explicitly return in a function.</p>\\n","categoryID":"Type_Checking_6248","categoryDisplay":"Type Checking"},{"id":"noImplicitThis","display":"No Implicit This","oneliner":"<p>Enable error reporting when <code>this</code> is given the type <code>any</code>.</p>\\n","categoryID":"Type_Checking_6248","categoryDisplay":"Type Checking"},{"id":"noPropertyAccessFromIndexSignature","display":"noPropertyAccessFromIndexSignature","oneliner":"<p>Enforces using indexed accessors for keys declared using an indexed type.</p>\\n","categoryID":"Type_Checking_6248","categoryDisplay":"Type Checking"},{"id":"noUncheckedIndexedAccess","display":"noUncheckedIndexedAccess","oneliner":"<p>Add <code>undefined</code> to a type when accessed using an index.</p>\\n","categoryID":"Type_Checking_6248","categoryDisplay":"Type Checking"},{"id":"noUnusedLocals","display":"No Unused Locals","oneliner":"<p>Enable error reporting when local variables aren\'t read.</p>\\n","categoryID":"Type_Checking_6248","categoryDisplay":"Type Checking"},{"id":"noUnusedParameters","display":"No Unused Parameters","oneliner":"<p>Raise an error when a function parameter isn\'t read.</p>\\n","categoryID":"Type_Checking_6248","categoryDisplay":"Type Checking"},{"id":"strict","display":"Strict","oneliner":"<p>Enable all strict type-checking options.</p>\\n","categoryID":"Type_Checking_6248","categoryDisplay":"Type Checking"},{"id":"strictBindCallApply","display":"Strict Bind Call Apply","oneliner":"<p>Check that the arguments for <code>bind</code>, <code>call</code>, and <code>apply</code> methods match the original function.</p>\\n","categoryID":"Type_Checking_6248","categoryDisplay":"Type Checking"},{"id":"strictFunctionTypes","display":"Strict Function Types","oneliner":"<p>When assigning functions, check to ensure parameters and the return values are subtype-compatible.</p>\\n","categoryID":"Type_Checking_6248","categoryDisplay":"Type Checking"},{"id":"strictNullChecks","display":"Strict Null Checks","oneliner":"<p>When type checking, take into account <code>null</code> and <code>undefined</code>.</p>\\n","categoryID":"Type_Checking_6248","categoryDisplay":"Type Checking"},{"id":"strictPropertyInitialization","display":"Strict Property Initialization","oneliner":"<p>Check for class properties that are declared but not set in the constructor.</p>\\n","categoryID":"Type_Checking_6248","categoryDisplay":"Type Checking"},{"id":"useUnknownInCatchVariables","display":"useUnknownInCatchVariables","oneliner":"<p>Default catch clause variables as <code>unknown</code> instead of <code>any</code>.</p>\\n","categoryID":"Type_Checking_6248","categoryDisplay":"Type Checking"},{"id":"allowUmdGlobalAccess","display":"Allow Umd Global Access","oneliner":"<p>Allow accessing UMD globals from modules.</p>\\n","categoryID":"Modules_6244","categoryDisplay":"Modules"},{"id":"baseUrl","display":"Base Url","oneliner":"<p>Specify the base directory to resolve non-relative module names.</p>\\n","categoryID":"Modules_6244","categoryDisplay":"Modules"},{"id":"module","display":"Module","oneliner":"<p>Specify what module code is generated.</p>\\n","categoryID":"Modules_6244","categoryDisplay":"Modules"},{"id":"moduleResolution","display":"Module Resolution","oneliner":"<p>Specify how TypeScript looks up a file from a given module specifier.</p>\\n","categoryID":"Modules_6244","categoryDisplay":"Modules"},{"id":"noResolve","display":"No Resolve","oneliner":"<p>Disallow <code>import</code>s, <code>require</code>s or <code><reference></code>s from expanding the number of files TypeScript should add to a project.</p>\\n","categoryID":"Modules_6244","categoryDisplay":"Modules"},{"id":"paths","display":"Paths","oneliner":"<p>Specify a set of entries that re-map imports to additional lookup locations.</p>\\n","categoryID":"Modules_6244","categoryDisplay":"Modules"},{"id":"resolveJsonModule","display":"Resolve JSON Module","oneliner":"<p>Enable importing .json files.</p>\\n","categoryID":"Modules_6244","categoryDisplay":"Modules"},{"id":"rootDir","display":"Root Dir","oneliner":"<p>Specify the root folder within your source files.</p>\\n","categoryID":"Modules_6244","categoryDisplay":"Modules"},{"id":"rootDirs","display":"Root Dirs","oneliner":"<p>Allow multiple folders to be treated as one when resolving modules.</p>\\n","categoryID":"Modules_6244","categoryDisplay":"Modules"},{"id":"typeRoots","display":"Type Roots","oneliner":"<p>Specify multiple folders that act like <code>./node_modules/@types</code>.</p>\\n","categoryID":"Modules_6244","categoryDisplay":"Modules"},{"id":"types","display":"Types","oneliner":"<p>Specify type package names to be included without being referenced in a source file.</p>\\n","categoryID":"Modules_6244","categoryDisplay":"Modules"},{"id":"declaration","display":"Declaration","oneliner":"<p>Generate .d.ts files from TypeScript and JavaScript files in your project.</p>\\n","categoryID":"Emit_6246","categoryDisplay":"Emit"},{"id":"declarationDir","display":"Declaration Dir","oneliner":"<p>Specify the output directory for generated declaration files.</p>\\n","categoryID":"Emit_6246","categoryDisplay":"Emit"},{"id":"declarationMap","display":"Declaration Map","oneliner":"<p>Create sourcemaps for d.ts files.</p>\\n","categoryID":"Emit_6246","categoryDisplay":"Emit"},{"id":"downlevelIteration","display":"Downlevel Iteration","oneliner":"<p>Emit more compliant, but verbose and less performant JavaScript for iteration.</p>\\n","categoryID":"Emit_6246","categoryDisplay":"Emit"},{"id":"emitBOM","display":"Emit BOM","oneliner":"<p>Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.</p>\\n","categoryID":"Emit_6246","categoryDisplay":"Emit"},{"id":"emitDeclarationOnly","display":"Emit Declaration Only","oneliner":"<p>Only output d.ts files and not JavaScript files.</p>\\n","categoryID":"Emit_6246","categoryDisplay":"Emit"},{"id":"importHelpers","display":"Import Helpers","oneliner":"<p>Allow importing helper functions from tslib once per project, instead of including them per-file.</p>\\n","categoryID":"Emit_6246","categoryDisplay":"Emit"},{"id":"importsNotUsedAsValues","display":"Imports Not Used As Values","oneliner":"<p>Specify emit/checking behavior for imports that are only used for types.</p>\\n","categoryID":"Emit_6246","categoryDisplay":"Emit"},{"id":"inlineSourceMap","display":"Inline Source Map","oneliner":"<p>Include sourcemap files inside the emitted JavaScript.</p>\\n","categoryID":"Emit_6246","categoryDisplay":"Emit"},{"id":"inlineSources","display":"Inline Sources","oneliner":"<p>Include source code in the sourcemaps inside the emitted JavaScript.</p>\\n","categoryID":"Emit_6246","categoryDisplay":"Emit"},{"id":"mapRoot","display":"Map Root","oneliner":"<p>Specify the location where debugger should locate map files instead of generated locations.</p>\\n","categoryID":"Emit_6246","categoryDisplay":"Emit"},{"id":"newLine","display":"New Line","oneliner":"<p>Set the newline character for emitting files.</p>\\n","categoryID":"Emit_6246","categoryDisplay":"Emit"},{"id":"noEmit","display":"No Emit","oneliner":"<p>Disable emitting files from a compilation.</p>\\n","categoryID":"Emit_6246","categoryDisplay":"Emit"},{"id":"noEmitHelpers","display":"No Emit Helpers","oneliner":"<p>Disable generating custom helper functions like <code>__extends</code> in compiled output.</p>\\n","categoryID":"Emit_6246","categoryDisplay":"Emit"},{"id":"noEmitOnError","display":"No Emit On Error","oneliner":"<p>Disable emitting files if any type checking errors are reported.</p>\\n","categoryID":"Emit_6246","categoryDisplay":"Emit"},{"id":"outDir","display":"Out Dir","oneliner":"<p>Specify an output folder for all emitted files.</p>\\n","categoryID":"Emit_6246","categoryDisplay":"Emit"},{"id":"outFile","display":"Out File","oneliner":"<p>Specify a file that bundles all outputs into one JavaScript file. If <a href=\\"#declaration\\"><code>declaration</code></a> is true, also designates a file that bundles all .d.ts output.</p>\\n","categoryID":"Emit_6246","categoryDisplay":"Emit"},{"id":"preserveConstEnums","display":"Preserve Const Enums","oneliner":"<p>Disable erasing <code>const enum</code> declarations in generated code.</p>\\n","categoryID":"Emit_6246","categoryDisplay":"Emit"},{"id":"preserveValueImports","display":"preserveValueImports","oneliner":"<p>Preserve unused imported values in the JavaScript output that would otherwise be removed.</p>\\n","categoryID":"Emit_6246","categoryDisplay":"Emit"},{"id":"removeComments","display":"Remove Comments","oneliner":"<p>Disable emitting comments.</p>\\n","categoryID":"Emit_6246","categoryDisplay":"Emit"},{"id":"sourceMap","display":"Source Map","oneliner":"<p>Create source map files for emitted JavaScript files.</p>\\n","categoryID":"Emit_6246","categoryDisplay":"Emit"},{"id":"sourceRoot","display":"Source Root","oneliner":"<p>Specify the root path for debuggers to find the reference source code.</p>\\n","categoryID":"Emit_6246","categoryDisplay":"Emit"},{"id":"stripInternal","display":"Strip Internal","oneliner":"<p>Disable emitting declarations that have <code>@internal</code> in their JSDoc comments.</p>\\n","categoryID":"Emit_6246","categoryDisplay":"Emit"},{"id":"allowJs","display":"Allow JS","oneliner":"<p>Allow JavaScript files to be a part of your program. Use the <code>checkJS</code> option to get errors from these files.</p>\\n","categoryID":"JavaScript_Support_6247","categoryDisplay":"JavaScript Support"},{"id":"checkJs","display":"Check JS","oneliner":"<p>Enable error reporting in type-checked JavaScript files.</p>\\n","categoryID":"JavaScript_Support_6247","categoryDisplay":"JavaScript Support"},{"id":"maxNodeModuleJsDepth","display":"Max Node Module JS Depth","oneliner":"<p>Specify the maximum folder depth used for checking JavaScript files from <code>node_modules</code>. Only applicable with <a href=\\"#allowJs\\"><code>allowJs</code></a>.</p>\\n","categoryID":"JavaScript_Support_6247","categoryDisplay":"JavaScript Support"},{"id":"disableSizeLimit","display":"Disable Size Limit","oneliner":"<p>Remove the 20mb cap on total source code size for JavaScript files in the TypeScript language server.</p>\\n","categoryID":"Editor_Support_6249","categoryDisplay":"Editor Support"},{"id":"plugins","display":"Plugins","oneliner":"<p>Specify a list of language service plugins to include.</p>\\n","categoryID":"Editor_Support_6249","categoryDisplay":"Editor Support"},{"id":"allowSyntheticDefaultImports","display":"Allow Synthetic Default Imports","oneliner":"<p>Allow \'import x from y\' when a module doesn\'t have a default export.</p>\\n","categoryID":"Interop_Constraints_6252","categoryDisplay":"Interop Constraints"},{"id":"esModuleInterop","display":"ES Module Interop","oneliner":"<p>Emit additional JavaScript to ease support for importing CommonJS modules. This enables <a href=\\"#allowSyntheticDefaultImports\\"><code>allowSyntheticDefaultImports</code></a> for type compatibility.</p>\\n","categoryID":"Interop_Constraints_6252","categoryDisplay":"Interop Constraints"},{"id":"forceConsistentCasingInFileNames","display":"Force Consistent Casing In File Names","oneliner":"<p>Ensure that casing is correct in imports.</p>\\n","categoryID":"Interop_Constraints_6252","categoryDisplay":"Interop Constraints"},{"id":"isolatedModules","display":"Isolated Modules","oneliner":"<p>Ensure that each file can be safely transpiled without relying on other imports.</p>\\n","categoryID":"Interop_Constraints_6252","categoryDisplay":"Interop Constraints"},{"id":"preserveSymlinks","display":"Preserve Symlinks","oneliner":"<p>Disable resolving symlinks to their realpath. This correlates to the same flag in node.</p>\\n","categoryID":"Interop_Constraints_6252","categoryDisplay":"Interop Constraints"},{"id":"charset","display":"Charset","oneliner":"<p>No longer supported. In early versions, manually set the text encoding for reading files.</p>\\n","categoryID":"Backwards_Compatibility_6253","categoryDisplay":"Backwards Compatibility"},{"id":"keyofStringsOnly","display":"Keyof Strings Only","oneliner":"<p>Make keyof only return strings instead of string, numbers or symbols. Legacy option.</p>\\n","categoryID":"Backwards_Compatibility_6253","categoryDisplay":"Backwards Compatibility"},{"id":"noImplicitUseStrict","display":"No Implicit Use Strict","oneliner":"<p>Disable adding \'use strict\' directives in emitted JavaScript files.</p>\\n","categoryID":"Backwards_Compatibility_6253","categoryDisplay":"Backwards Compatibility"},{"id":"noStrictGenericChecks","display":"No Strict Generic Checks","oneliner":"<p>Disable strict checking of generic signatures in function types.</p>\\n","categoryID":"Backwards_Compatibility_6253","categoryDisplay":"Backwards Compatibility"},{"id":"out","display":"Out","oneliner":"<p>Deprecated setting. Use <a href=\\"#outFile\\"><code>outFile</code></a> instead.</p>\\n","categoryID":"Backwards_Compatibility_6253","categoryDisplay":"Backwards Compatibility"},{"id":"suppressExcessPropertyErrors","display":"Suppress Excess Property Errors","oneliner":"<p>Disable reporting of excess property errors during the creation of object literals.</p>\\n","categoryID":"Backwards_Compatibility_6253","categoryDisplay":"Backwards Compatibility"},{"id":"suppressImplicitAnyIndexErrors","display":"Suppress Implicit Any Index Errors","oneliner":"<p>Suppress <a href=\\"#noImplicitAny\\"><code>noImplicitAny</code></a> errors when indexing objects that lack index signatures.</p>\\n","categoryID":"Backwards_Compatibility_6253","categoryDisplay":"Backwards Compatibility"},{"id":"emitDecoratorMetadata","display":"Emit Decorator Metadata","oneliner":"<p>Emit design-type metadata for decorated declarations in source files.</p>\\n","categoryID":"Language_and_Environment_6254","categoryDisplay":"Language and Environment"},{"id":"experimentalDecorators","display":"Experimental Decorators","oneliner":"<p>Enable experimental support for TC39 stage 2 draft decorators.</p>\\n","categoryID":"Language_and_Environment_6254","categoryDisplay":"Language and Environment"},{"id":"jsx","display":"JSX","oneliner":"<p>Specify what JSX code is generated.</p>\\n","categoryID":"Language_and_Environment_6254","categoryDisplay":"Language and Environment"},{"id":"jsxFactory","display":"JSX Factory","oneliner":"<p>Specify the JSX factory function used when targeting React JSX emit, e.g. \'React.createElement\' or \'h\'.</p>\\n","categoryID":"Language_and_Environment_6254","categoryDisplay":"Language and Environment"},{"id":"jsxFragmentFactory","display":"jsxFragmentFactory","oneliner":"<p>Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. \'React.Fragment\' or \'Fragment\'.</p>\\n","categoryID":"Language_and_Environment_6254","categoryDisplay":"Language and Environment"},{"id":"jsxImportSource","display":"jsxImportSource","oneliner":"<p>Specify module specifier used to import the JSX factory functions when using <code>jsx: react-jsx*</code>.</p>\\n","categoryID":"Language_and_Environment_6254","categoryDisplay":"Language and Environment"},{"id":"lib","display":"Lib","oneliner":"<p>Specify a set of bundled library declaration files that describe the target runtime environment.</p>\\n","categoryID":"Language_and_Environment_6254","categoryDisplay":"Language and Environment"},{"id":"noLib","display":"No Lib","oneliner":"<p>Disable including any library files, including the default lib.d.ts.</p>\\n","categoryID":"Language_and_Environment_6254","categoryDisplay":"Language and Environment"},{"id":"reactNamespace","display":"React Namespace","oneliner":"<p>Specify the object invoked for <code>createElement</code>. This only applies when targeting <code>react</code> JSX emit.</p>\\n","categoryID":"Language_and_Environment_6254","categoryDisplay":"Language and Environment"},{"id":"target","display":"Target","oneliner":"<p>Set the JavaScript language version for emitted JavaScript and include compatible library declarations.</p>\\n","categoryID":"Language_and_Environment_6254","categoryDisplay":"Language and Environment"},{"id":"useDefineForClassFields","display":"Use Define For Class Fields","oneliner":"<p>Emit ECMAScript-standard-compliant class fields.</p>\\n","categoryID":"Language_and_Environment_6254","categoryDisplay":"Language and Environment"},{"id":"diagnostics","display":"Diagnostics","oneliner":"<p>Output compiler performance information after building.</p>\\n","categoryID":"Compiler_Diagnostics_6251","categoryDisplay":"Compiler Diagnostics"},{"id":"explainFiles","display":"explainFiles","oneliner":"<p>Print files read during the compilation including why it was included.</p>\\n","categoryID":"Compiler_Diagnostics_6251","categoryDisplay":"Compiler Diagnostics"},{"id":"extendedDiagnostics","display":"Extended Diagnostics","oneliner":"<p>Output more detailed compiler performance information after building.</p>\\n","categoryID":"Compiler_Diagnostics_6251","categoryDisplay":"Compiler Diagnostics"},{"id":"generateCpuProfile","display":"Generate CPU Profile","oneliner":"<p>Emit a v8 CPU profile of the compiler run for debugging.</p>\\n","categoryID":"Compiler_Diagnostics_6251","categoryDisplay":"Compiler Diagnostics"},{"id":"listEmittedFiles","display":"List Emitted Files","oneliner":"<p>Print the names of emitted files after a compilation.</p>\\n","categoryID":"Compiler_Diagnostics_6251","categoryDisplay":"Compiler Diagnostics"},{"id":"listFiles","display":"List Files","oneliner":"<p>Print all of the files read during the compilation.</p>\\n","categoryID":"Compiler_Diagnostics_6251","categoryDisplay":"Compiler Diagnostics"},{"id":"traceResolution","display":"Trace Resolution","oneliner":"<p>Log paths used during the <a href=\\"#moduleResolution\\"><code>moduleResolution</code></a> process.</p>\\n","categoryID":"Compiler_Diagnostics_6251","categoryDisplay":"Compiler Diagnostics"},{"id":"composite","display":"Composite","oneliner":"<p>Enable constraints that allow a TypeScript project to be used with project references.</p>\\n","categoryID":"Projects_6255","categoryDisplay":"Projects"},{"id":"disableReferencedProjectLoad","display":"disableReferencedProjectLoad","oneliner":"<p>Reduce the number of projects loaded automatically by TypeScript.</p>\\n","categoryID":"Projects_6255","categoryDisplay":"Projects"},{"id":"disableSolutionSearching","display":"Disable Solution Searching","oneliner":"<p>Opt a project out of multi-project reference checking when editing.</p>\\n","categoryID":"Projects_6255","categoryDisplay":"Projects"},{"id":"disableSourceOfProjectReferenceRedirect","display":"Disable Source Project Reference Redirect","oneliner":"<p>Disable preferring source files instead of declaration files when referencing composite projects.</p>\\n","categoryID":"Projects_6255","categoryDisplay":"Projects"},{"id":"incremental","display":"Incremental","oneliner":"<p>Save .tsbuildinfo files to allow for incremental compilation of projects.</p>\\n","categoryID":"Projects_6255","categoryDisplay":"Projects"},{"id":"tsBuildInfoFile","display":"TS Build Info File","oneliner":"<p>Specify the folder for .tsbuildinfo incremental compilation files.</p>\\n","categoryID":"Projects_6255","categoryDisplay":"Projects"},{"id":"noErrorTruncation","display":"No Error Truncation","oneliner":"<p>Disable truncating types in error messages.</p>\\n","categoryID":"Output_Formatting_6256","categoryDisplay":"Output Formatting"},{"id":"preserveWatchOutput","display":"Preserve Watch Output","oneliner":"<p>Disable wiping the console in watch mode.</p>\\n","categoryID":"Output_Formatting_6256","categoryDisplay":"Output Formatting"},{"id":"pretty","display":"Pretty","oneliner":"<p>Enable color and formatting in TypeScript\'s output to make compiler errors easier to read.</p>\\n","categoryID":"Output_Formatting_6256","categoryDisplay":"Output Formatting"},{"id":"skipDefaultLibCheck","display":"Skip Default Lib Check","oneliner":"<p>Skip type checking .d.ts files that are included with TypeScript.</p>\\n","categoryID":"Completeness_6257","categoryDisplay":"Completeness"},{"id":"skipLibCheck","display":"Skip Lib Check","oneliner":"<p>Skip type checking all .d.ts files.</p>\\n","categoryID":"Completeness_6257","categoryDisplay":"Completeness"},{"id":"assumeChangesOnlyAffectDirectDependencies","display":"Assume Changes Only Affect Direct Dependencies","oneliner":"<p>Have recompiles in projects that use <a href=\\"#incremental\\"><code>incremental</code></a> and <code>watch</code> mode assume that changes within a file will only affect files directly depending on it.</p>\\n","categoryID":"Watch_and_Build_Modes_6250","categoryDisplay":"Watch Options"},{"id":"watchFile","display":"watchFile","oneliner":"<p>Specify how the TypeScript watch mode works.</p>\\n","categoryID":"watchOptions","categoryDisplay":"watchOptions"},{"id":"watchDirectory","display":"watchDirectory","oneliner":"<p>Specify how directories are watched on systems that lack recursive file-watching functionality.</p>\\n","categoryID":"watchOptions","categoryDisplay":"watchOptions"},{"id":"fallbackPolling","display":"fallbackPolling","oneliner":"<p>Specify what approach the watcher should use if the system runs out of native file watchers.</p>\\n","categoryID":"watchOptions","categoryDisplay":"watchOptions"},{"id":"synchronousWatchDirectory","display":"synchronousWatchDirectory","oneliner":"<p>Synchronously call callbacks and update the state of directory watchers on platforms that don`t support recursive watching natively.</p>\\n","categoryID":"watchOptions","categoryDisplay":"watchOptions"},{"id":"excludeDirectories","display":"excludeDirectories","oneliner":"<p>Remove a list of directories from the watch process.</p>\\n","categoryID":"watchOptions","categoryDisplay":"watchOptions"},{"id":"excludeFiles","display":"excludeFiles","oneliner":"<p>Remove a list of files from the watch mode\'s processing.</p>\\n","categoryID":"watchOptions","categoryDisplay":"watchOptions"},{"id":"enable","display":"enable","oneliner":"<p>Disable the type acquisition for JavaScript projects.</p>\\n","categoryID":"typeAcquisition","categoryDisplay":"typeAcquisition"},{"id":"include","display":"Include","oneliner":"<p>Specify a list of modules which to acquire types for.</p>\\n","categoryID":"typeAcquisition","categoryDisplay":"typeAcquisition"},{"id":"exclude","display":"Exclude","oneliner":"<p>Specify a list of modules which to exclude from type acquisition.</p>\\n","categoryID":"typeAcquisition","categoryDisplay":"typeAcquisition"},{"id":"disableFilenameBasedTypeAcquisition","display":"disableFilenameBasedTypeAcquisition","oneliner":"<p>Disables inference for type acquisition by looking at filenames in a project.</p>\\n","categoryID":"typeAcquisition","categoryDisplay":"typeAcquisition"}]}'),I=[{issue:37231,name:"Incorrect Type Inference Example",blurb:"Using <code>// ^?</code> to highlight how inference gives different results at different locations",code:"// @noImplicitAny: false\n\ntype Entity = {\n someDate: Date | null;\n} & ({ id: string; } | { id: number; })\n\ntype RowRendererMeta<TInput extends {}> = {\n [key in keyof TInput]: { key: key; caption: string; formatter?: (value: TInput[key]) => string; };\n}\ntype RowRenderer<TInput extends {}> = RowRendererMeta<TInput>[keyof RowRendererMeta<TInput>];\n\nconst test: RowRenderer<Entity> = {\n key: 'someDate',\n caption: 'My Date',\n formatter: (value) => value ? value.toString() : '-' // value: any\n// ^?\n}\n\nconst thisIsNotTheIssue: Partial<RowRendererMeta<Entity>> = {\n someDate: {\n key: 'someDate',\n caption: 'My Date',\n formatter: (value) => value ? value.toString() : '-' // value: Date | null\n// ^?\n }\n}"}],_=[{name:"Compiler Options",content:function(e,t,i){i.p("\nYou can set compiler flags via <code>// @[option]</code> comments inside the sample.\n<ul>\n <li>Booleans: <code>// @strict: true</code> or <code>// @strict: false</code>.<br/>You can omit <code>: true</code> to get the same behavior.</li>\n <li>Strings: <code>// @target: ES2015</code></li>\n <li>Numbers: <code>// @target: 4</code></li>\n <li>Lists: <code>// @types: ['jest']</code></li>\n</ul>\n"),i.subtitle("Compiler Option Reference"),E.Y.sort((function(e,t){return e.id.localeCompare(t.id)})).forEach((function(e){["Project_Files_0","Watch_Options_999"].includes(e.categoryID)||i.p("<code>// @"+e.id+"</code><br>"+e.oneliner+".")}))}},{name:"Multi File",content:function(e,t,i){i.p("The code file can be converted into multiple files behind the scenes. This is done by chopping the code sample whenever there is a <code>// @filename: [path]</code>."),i.code('\n// @showEmit\n// @filename: index.ts\nimport {pi} from "./utils"\nconsole.log(pi)\n\n// @filename: utils.ts\nexport const pi = "3.14"\n'.trim());var n=document.createElement("button");n.textContent="See an Example",n.onclick=function(){return e.setText('\n// @filename: service.ts\nexport type Service = {\n id: string\n display: string\n}\n\n// @filename: app.ts\nimport type { Service } from "./service";\n// ^ - this error is OK\n\nconst myServices: Service[] = [\n { id: "launch", display: "Launch" },\n { id: "lunch", disply: "Lunch" },\n// ^ - this error is real but hidden\n// you can see it in \'Assertions\'\n]\n '.trim())},t.appendChild(n)}},{name:"Queries",content:function(e,t,i){i.p("Twoslash supports making queries for what the type is at a particular location of code. It also is a specially crafted comment. "),i.code('\nconst myExample = {\n hello: "world"\n}\n\nmyExample.hello;\n// ^?\n '.trim()),i.p("You can use as many as you want of these, but you can only have one per line.");var n=document.createElement("button");n.textContent="See an Example",n.onclick=function(){return e.setText('\nconst button = document.createElement("button");\nbutton.textContent = "See an Example";\n\nbutton.onclick = () => {\n console.log("Example has been clicked");\n button.disabled = true;\n// ^?\n}\n\ndocument.body.appendChild(button);\n// ^?\n '.trim())},t.appendChild(n),i.p("The repro testing system will use these queries as an indicator of what has changed, so if you highlight a bug in inference then when it is fixed and the type has changed it will be raised.")}},{name:"Emitter",content:function(e,t,i){i.p("\nThere are ways to have your test repro be about the output of running TypeScript. There are two comment types which can be used to highlight these files.\n<br/><br/><code>// @showEmit</code> is a shortcut for showing the <code>.js</code> file for a single file code sample:\n".trim()),i.code('\n// @showEmit\nexport const helloWorld: string = "Hi"\n'.trim()),i.p("The long-form is <code>// @showEmittedFile: [filename]</code> which allows for showing any emitted file"),i.code("\n// @declaration: true\n// @showEmit\n// @showEmittedFile: index.d.ts\n\nexport function getStringLength(value: string) {\n return value.length\n}\n".trim()),i.p("Multi-file seems to be buggy ATM, but this should work eventually:"),i.code('\n// @showEmit\n// @showEmittedFile: b.js\n\n// @filename: a.ts\nexport const helloWorld: string = "Hi"\n\n// @filename: b.ts\nconst abc = ""\n'.trim())}},{name:"Defaults",content:function(e,t,i){I.forEach((function(e){i.p("The twoslash compiler only has a few changes from the default empty TSConfig "),i.code("\n const defaultCompilerOptions: CompilerOptions = {\n strict: true,\n target: ts.ScriptTarget.ES2016,\n allowJs: true\n }\n")})),i.p("You may need to undo <code>strict</code> for some samples, but the others shouldn't affect most code repros.")}},{name:"Examples",content:function(e,t,i){i.p("Note: this section is tricky to document... These bugs may have been fixed since the docs were created. Consider theses as ideas in how to make repros rather than useful bug reproductions."),I.forEach((function(n){i.subtitle(n.name+" <a href='https://github.com/microsoft/TypeScript/issues/"+n.issue+"'>"+n.issue+"</a>"),i.p(n.blurb);var o=document.createElement("button");o.textContent="Show example",o.onclick=function(){return e.setText(n.code)},t.appendChild(o)}))}}],S=function(e,t){return{id:"ref",displayName:"Docs",didMount:function(e,i){var n=t.createDesignSystem(i),o=document.createElement("div"),a=n.createTabBar(),r=[];_.forEach((function(i,s){var l=n.createTabButton(i.name);r.push(l),l.onclick=function(){r.forEach((function(e){return e.classList.remove("active")})),l.classList.add("active");var n=t.createDesignSystem(o);n.clear(),i.content(e,o,n)},a.appendChild(l),0===s&&l.onclick({})})),i.appendChild(a),i.appendChild(o)}}},k=i(3415),C=i(2057),T=i(8639),x=i(2332),M=function(e){var t=(0,y.D)((0,d.Z)()),o=new Map;return(0,r.useEffect)((function(){if(!("playgroundLoaded"in window)){window.playgroundLoaded=!0,window.react=r,window.reactDOM=s,window.i=t;var e=document.createElement("script");e.src=(0,c.withPrefix)("/js/vs.loader.js"),e.async=!0,e.onload=(0,n.Z)(a().mark((function e(){var s,l,d,y,u,g,m,h,f;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=new URLSearchParams(location.search),(l=s.get("ts"))&&(!l||"Nightly"!==l)&&"next"!==l){e.next=10;break}return e.next=5,fetch("https://tswebinfra.blob.core.windows.net/indexes/next.json",{cache:"no-cache"});case 5:return d=e.sent,e.next=8,d.json();case 8:y=e.sent,l=y.version;case 10:u=(0,T.o)(),g=u.sandboxRoot,m=u.playgroundRoot,h=u.playgroundWorker,(f=i.g.require).config({paths:{vs:"https://typescript.azureedge.net/cdn/"+l+"/monaco/dev/vs","typescript-sandbox":g,"typescript-playground":m,unpkg:"https://unpkg.com/",local:"http://localhost:5000"},ignoreDuplicateModules:["vs/editor/editor.main"]}),f(["vs/editor/editor.main","vs/language/typescript/tsWorker","typescript-sandbox/index","typescript-playground/index"],function(){var e=(0,n.Z)(a().mark((function e(n,s,d,y){var u,g,m,f,E,I,_,T,M,R,L,O,j,F;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=i.g.ts,n&&u&&d&&y?null===(g=document.getElementById("loader").parentNode)||void 0===g||g.removeChild(document.getElementById("loader")):(x.error("Errr"),x.error("main",!!n,"ts",!!u,"sandbox",!!d,"playground",!!y)),(m=document.getElementById("playground-container")).style.display="flex",f=Math.max(window.innerHeight,600),m.style.height=f-Math.round(m.getClientRects()[0].top)-18+"px",e.next=9,d.createTypeScriptSandbox({text:localStorage.getItem("sandbox-history")||t("play_default_code_sample"),compilerOptions:{},domID:"monaco-editor-embed",filetype:"ts",acquireTypes:!localStorage.getItem("disable-ata"),supportTwoslashCompilerOptions:!0,monacoSettings:{fontFamily:"var(--code-font)",fontLigatures:!0},customTypeScriptWorkerPath:document.location.origin+h},n,u);case 9:E=e.sent,I={lang:"en",prefix:(0,c.withPrefix)("/"),supportCustomPlugins:!1,plugins:[D,S,v,w,b]},_=y.setupPlayground(E,n,I,t,r),T=_.createUtils(d,r),M=function(e){(0,k.yp)(e,l,!0,u,E.lzstring).then((function(e){o=e,F()}))},E.setDidUpdateCompilerSettings(M),M(E.getCompilerOptions()),R=(0,p.D)((function(){o&&F()}),1e3),E.editor.onDidChangeModelContent(R),L=void 0,O=void 0,j=function(e){return e&&e.stack&&e.message},_.setDidUpdateTab((function(e){!j(L)&&"getResults"in e?e.getResults(E,L,O,E.getText().includes("// @showEmit")):"noResults"in e&&e.noResults(L,L)})),F=function(){var e=E.getText();if(e)try{O=new Map(o);var t=E.filepath.split(".")[1],i=(0,C.k)(e,t,{defaultOptions:{noStaticSemanticInfo:!0,emit:!0,noErrorValidation:!0},tsModule:u,lzstringModule:E.lzstring,fsMap:O});L=i;var n=_.getCurrentPlugin();"getResults"in n&&n.getResults(E,i,O,e.includes("// @showEmit"));var a=i.queries.length+(e.includes("// @showEmit")?1:0)+i.errors.length;T.setNotifications("assertions",a)}catch(l){var r=l;x.log(r),L=r;var s=_.getCurrentPlugin();"noResults"in s&&s.noResults(E,r),T.setNotifications("assertions",1)}},document.documentElement.classList.contains("dark-theme")&&E.monaco.editor.setTheme("sandbox-dark"),E.editor.focus(),E.editor.layout(),R();case 28:case"end":return e.stop()}}),e)})));return function(t,i,n,o){return e.apply(this,arguments)}}());case 14:case"end":return e.stop()}}),e)}))),document.body.appendChild(e)}}),[]),r.createElement(l.A,{title:"Bug Workbench",description:"Create reproductions of issues with TypeScript",lang:"en"},r.createElement("nav",{className:"navbar-sub"},r.createElement("ul",{className:"nav"},r.createElement("li",{className:"name hide-small"},r.createElement("span",null,"Bug Workbench"))),r.createElement("ul",{className:"nav navbar-nav navbar-right hidden-xs"})),r.createElement("div",{className:"raised",style:{paddingTop:"0",marginTop:"0",marginBottom:"3rem",paddingBottom:"1.5rem"}},r.createElement("div",{id:"loader"},r.createElement("div",{className:"lds-grid"},r.createElement("div",null),r.createElement("div",null),r.createElement("div",null),r.createElement("div",null),r.createElement("div",null),r.createElement("div",null),r.createElement("div",null),r.createElement("div",null),r.createElement("div",null)),r.createElement("p",{id:"loading-message",role:"status"},t("play_downloading_typescript"))),r.createElement("div",{id:"playground-container",style:{display:"none"}},r.createElement("div",{id:"editor-container"},r.createElement("div",{id:"editor-toolbar",className:"navbar-sub"},r.createElement("ul",null,r.createElement("li",{id:"versions",className:"dropdown"},r.createElement("a",{href:"#"},t("play_downloading_version"),"... ",r.createElement("span",{className:"caret"})),r.createElement("ul",{className:"dropdown-menu versions"}))),r.createElement("ul",{className:"right"},r.createElement("li",null,r.createElement("a",{id:"sidebar-toggle","aria-label":"Hide Sidebar",href:"#"},"⇥")))),r.createElement("div",{id:"monaco-editor-embed"})))))},R=function(e){return r.createElement(u.R,{locale:"en"},r.createElement(M,e))}}}]);
//# sourceMappingURL=component---src-pages-dev-bug-workbench-tsx-78b3f01d7691b9ef9a0a.js.map
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。