├── .changeset ├── README.md └── config.json ├── .devcontainer ├── Dockerfile └── devcontainer.json ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── config.yml │ └── critical-issue.md ├── codeql │ └── codeql-configuration.yml ├── dependabot.yml └── workflows │ ├── CI.yml │ ├── close-preview.yml │ ├── codeql.yml │ ├── deploy-preview.yml │ ├── deploy-prod-static.yml │ ├── keepalive.yml │ └── publish-packages.yml ├── .gitignore ├── .npmrc ├── .prettierignore ├── .prettierrc ├── .vscode ├── done.aiff ├── extensions.json ├── launch.json └── settings.template.json ├── LICENSE ├── LICENSE-CODE ├── README.md ├── SECURITY.md ├── dangerfile.ts ├── docs ├── Converting Twoslash Code Samples.md ├── Deprecating a page.md ├── How i18n Works For Site Copy.md ├── New TypeScript Version.md ├── README.md ├── Setup Troubleshooting.md ├── Something Went Wrong.md └── User Flows.md ├── package.json ├── packages ├── ata │ ├── CHANGELOG.md │ ├── README.md │ ├── jest.config.cjs │ ├── package.json │ ├── src │ │ ├── apis.ts │ │ ├── edgeCases.ts │ │ ├── index.ts │ │ └── userFacingTypes.d.ts │ ├── tests │ │ ├── ata.spec.ts │ │ └── edgeCases.spec.ts │ └── tsconfig.json ├── community-meta │ ├── README.md │ ├── generated │ │ └── .gitignore │ ├── package.json │ └── scripts │ │ ├── generateRichMeetupData.js │ │ └── meetups.js ├── create-typescript-playground-plugin │ ├── .npmignore │ ├── CHANGELOG.md │ ├── README.md │ ├── index.js │ ├── package.json │ └── template │ │ ├── .gitignore │ │ ├── .npmignore │ │ ├── CONTRIBUTING.md │ │ ├── README.md │ │ ├── package.json │ │ ├── rollup.config.js │ │ ├── scripts │ │ └── getDTS.js │ │ ├── src │ │ ├── index.ts │ │ └── vendor │ │ │ └── utils.ts │ │ └── tsconfig.json ├── documentation │ ├── .gitignore │ ├── copy │ │ └── en │ │ │ ├── Nightly Builds.md │ │ │ ├── declaration-files │ │ │ ├── By Example.md │ │ │ ├── Consumption.md │ │ │ ├── Deep Dive.md │ │ │ ├── Do's and Don'ts.md │ │ │ ├── Introduction.md │ │ │ ├── Library Structures.md │ │ │ ├── Publishing.md │ │ │ ├── Templates.md │ │ │ └── templates │ │ │ │ ├── global-modifying-module.d.ts.md │ │ │ │ ├── global-plugin.d.ts.md │ │ │ │ ├── global.d.ts.md │ │ │ │ ├── module-class.d.ts.md │ │ │ │ ├── module-function.d.ts.md │ │ │ │ ├── module-plugin.d.ts.md │ │ │ │ └── module.d.ts.md │ │ │ ├── get-started │ │ │ ├── TS for Functional Programmers.md │ │ │ ├── TS for JS Programmers.md │ │ │ ├── TS for OOPers.md │ │ │ └── TS for the New Programmer.md │ │ │ ├── handbook-v1 │ │ │ ├── Basic Types.md │ │ │ ├── Classes.md │ │ │ ├── Functions.md │ │ │ ├── Generics.md │ │ │ ├── Interfaces.md │ │ │ ├── Literal Types.md │ │ │ └── Unions and Intersections.md │ │ │ ├── handbook-v2 │ │ │ ├── Basics.md │ │ │ ├── Classes.md │ │ │ ├── Everyday Types.md │ │ │ ├── Modules.md │ │ │ ├── More on Functions.md │ │ │ ├── Narrowing.md │ │ │ ├── Object Types.md │ │ │ ├── The Handbook.md │ │ │ ├── Type Declarations.md │ │ │ ├── Type Manipulation │ │ │ │ ├── Conditional Types.md │ │ │ │ ├── Generics.md │ │ │ │ ├── Indexed Access Types.md │ │ │ │ ├── Keyof Type Operator.md │ │ │ │ ├── Mapped Types.md │ │ │ │ ├── Template Literal Types.md │ │ │ │ ├── Typeof Type Operator.md │ │ │ │ └── _Creating Types from Types.md │ │ │ └── Understanding Errors.md │ │ │ ├── javascript │ │ │ ├── Creating DTS files From JS.md │ │ │ ├── Intro to JS with TS.md │ │ │ ├── JSDoc Reference.md │ │ │ └── Type Checking JavaScript Files.md │ │ │ ├── modules-reference │ │ │ ├── Introduction.md │ │ │ ├── Reference.md │ │ │ ├── Theory.md │ │ │ ├── appendices │ │ │ │ └── ESM-CJS-Interop.md │ │ │ ├── diagrams │ │ │ │ ├── README │ │ │ │ ├── declaration-files.svg │ │ │ │ ├── esm-cjs-interop.md │ │ │ │ ├── esm-cjs-interop.md-1.svg │ │ │ │ ├── esm-cjs-interop.md-2.svg │ │ │ │ ├── mermaid.config.json │ │ │ │ ├── theory.md │ │ │ │ ├── theory.md-1.svg │ │ │ │ ├── theory.md-2.svg │ │ │ │ ├── theory.md-3.svg │ │ │ │ └── theory.md-4.svg │ │ │ └── guides │ │ │ │ └── Choosing Compiler Options.md │ │ │ ├── project-config │ │ │ ├── Compiler Options in MSBuild.md │ │ │ ├── Compiler Options.md │ │ │ ├── Configuring Watch.md │ │ │ ├── Integrating with Build Tools.md │ │ │ ├── Project References.md │ │ │ └── tsconfig.json.md │ │ │ ├── reference │ │ │ ├── Advanced Types.md │ │ │ ├── Declaration Merging.md │ │ │ ├── Decorators.md │ │ │ ├── Enums.md │ │ │ ├── Iterators and Generators.md │ │ │ ├── JSX.md │ │ │ ├── Mixins.md │ │ │ ├── Namespaces and Modules.md │ │ │ ├── Namespaces.md │ │ │ ├── Symbols.md │ │ │ ├── Triple-Slash Directives.md │ │ │ ├── Type Compatibility.md │ │ │ ├── Type Inference.md │ │ │ ├── Utility Types.md │ │ │ └── Variable Declarations.md │ │ │ ├── release-notes │ │ │ ├── TypeScript 1.1.md │ │ │ ├── TypeScript 1.3.md │ │ │ ├── TypeScript 1.4.md │ │ │ ├── TypeScript 1.5.md │ │ │ ├── TypeScript 1.6.md │ │ │ ├── TypeScript 1.7.md │ │ │ ├── TypeScript 1.8.md │ │ │ ├── TypeScript 2.0.md │ │ │ ├── TypeScript 2.1.md │ │ │ ├── TypeScript 2.2.md │ │ │ ├── TypeScript 2.3.md │ │ │ ├── TypeScript 2.4.md │ │ │ ├── TypeScript 2.5.md │ │ │ ├── TypeScript 2.6.md │ │ │ ├── TypeScript 2.7.md │ │ │ ├── TypeScript 2.8.md │ │ │ ├── TypeScript 2.9.md │ │ │ ├── TypeScript 3.0.md │ │ │ ├── TypeScript 3.1.md │ │ │ ├── TypeScript 3.2.md │ │ │ ├── TypeScript 3.3.md │ │ │ ├── TypeScript 3.4.md │ │ │ ├── TypeScript 3.5.md │ │ │ ├── TypeScript 3.6.md │ │ │ ├── TypeScript 3.7.md │ │ │ ├── TypeScript 3.8.md │ │ │ ├── TypeScript 3.9.md │ │ │ ├── TypeScript 4.0.md │ │ │ ├── TypeScript 4.1.md │ │ │ ├── TypeScript 4.2.md │ │ │ ├── TypeScript 4.3.md │ │ │ ├── TypeScript 4.4.md │ │ │ ├── TypeScript 4.5.md │ │ │ ├── TypeScript 4.6.md │ │ │ ├── TypeScript 4.7.md │ │ │ ├── TypeScript 4.8.md │ │ │ ├── TypeScript 4.9.md │ │ │ ├── TypeScript 5.0.md │ │ │ ├── TypeScript 5.1.md │ │ │ ├── TypeScript 5.2.md │ │ │ ├── TypeScript 5.3.md │ │ │ ├── TypeScript 5.4.md │ │ │ ├── TypeScript 5.5.md │ │ │ ├── TypeScript 5.6.md │ │ │ ├── TypeScript 5.7.md │ │ │ └── TypeScript 5.8.md │ │ │ └── tutorials │ │ │ ├── ASP.NET Core.md │ │ │ ├── Angular.md │ │ │ ├── Babel with TypeScript.md │ │ │ ├── DOM Manipulation.md │ │ │ ├── Gulp.md │ │ │ ├── Migrating from JavaScript.md │ │ │ ├── React.md │ │ │ └── TypeScript Tooling in 5 minutes.md │ ├── package.json │ ├── scripts │ │ ├── generateAttribution.js │ │ ├── generateDocsNavigationPerLanguage.js │ │ ├── generateTypesForFilesInDocs.js │ │ ├── handbookAttribution.json │ │ ├── lintTwoslashErrors.js │ │ └── types │ │ │ └── AllFilenames.d.ts │ └── vendor │ │ └── previousTranslations.json ├── glossary │ ├── .gitignore │ ├── README.md │ ├── copy │ │ └── en │ │ │ ├── declare.md │ │ │ ├── emit.md │ │ │ ├── index-signatures.md │ │ │ ├── interface.md │ │ │ ├── parser.md │ │ │ ├── runtime.md │ │ │ ├── shape.md │ │ │ ├── source-file.md │ │ │ ├── type-system.md │ │ │ └── types-vs-runtime.md │ ├── data │ │ ├── .gitignore │ │ └── _types.ts │ ├── package.json │ ├── scripts │ │ ├── generateMarkdown.ts │ │ └── lint.js │ └── tsconfig.json ├── playground-examples │ ├── .gitignore │ ├── .prettierignore │ ├── .prettierrc │ ├── README.md │ ├── copy │ │ └── en │ │ │ ├── 3-7 │ │ │ ├── Fixits │ │ │ │ ├── Big number literals.ts │ │ │ │ ├── Const to let.ts │ │ │ │ └── Infer From Usage Changes.ts │ │ │ ├── Syntax and Messaging │ │ │ │ ├── Flattened Error Reporting.ts │ │ │ │ ├── Nullish Coalescing.ts │ │ │ │ └── Optional Chaining.ts │ │ │ └── Types and Code Flow │ │ │ │ ├── Assertion Functions.ts │ │ │ │ ├── Recursive Type References.ts │ │ │ │ └── Uncalled Function Checks.ts │ │ │ ├── 3-8 │ │ │ ├── Breaking Changes │ │ │ │ └── Checking Unions with Index Signatures.ts │ │ │ ├── JSDoc Improvements │ │ │ │ └── Accessibility Modifiers.js │ │ │ └── Syntax and Messaging │ │ │ │ ├── Export Modules From.ts │ │ │ │ ├── Private Class Fields.ts │ │ │ │ └── Type Imports.tsx │ │ │ ├── 4-0 │ │ │ ├── New Checks │ │ │ │ └── Class Constructor Code Flow.ts │ │ │ ├── New JS Features │ │ │ │ ├── JSDoc Deprecated.ts │ │ │ │ ├── Logical Operators and Assignment.ts │ │ │ │ └── Nullish Coalescing.ts │ │ │ └── New TS Features │ │ │ │ ├── Named Tuples.ts │ │ │ │ ├── Unknown in Catch.ts │ │ │ │ └── Variadic Tuples.ts │ │ │ ├── 4-1 │ │ │ ├── New JS Features │ │ │ │ ├── New JSX Support.tsx │ │ │ │ └── See in JSDoc.ts │ │ │ └── Template Literals │ │ │ │ ├── Intro to Template Literals.ts │ │ │ │ ├── Mapped Types with Template Literals.ts │ │ │ │ └── String Manipulation with Template Literals.ts │ │ │ ├── 4-2 │ │ │ ├── Fixits │ │ │ │ └── Create Function from Call.ts │ │ │ └── New TS Features │ │ │ │ ├── Abstract Class Constructors.ts │ │ │ │ ├── Rest Elements in Tuple Types.ts │ │ │ │ ├── Smarter Type Alias Preservation.ts │ │ │ │ └── Use Index Accessors for Index Signatures.ts │ │ │ ├── 4-3 │ │ │ └── New TS Features │ │ │ │ ├── No Implicit Class Overrides.ts │ │ │ │ └── Separate Write vs Read on Properties.ts │ │ │ ├── 4-4 │ │ │ ├── New JS Features │ │ │ │ ├── Control Flow Improvements.ts │ │ │ │ └── Errors for High Confidence Errors.ts │ │ │ └── New TS Features │ │ │ │ ├── Exact Optional Properties.ts │ │ │ │ └── Use unknown for Catch Variables.ts │ │ │ ├── 4-7 │ │ │ ├── New JS Features │ │ │ │ ├── Control Flow Improvements.ts │ │ │ │ └── Improved Function Inference.ts │ │ │ └── New TS Features │ │ │ │ ├── Extends Constraints.ts │ │ │ │ └── Instantiation Expressions.ts │ │ │ ├── JavaScript │ │ │ ├── External APIs │ │ │ │ ├── TypeScript with Deno.ts │ │ │ │ ├── TypeScript with Node.js │ │ │ │ ├── TypeScript with React.tsx │ │ │ │ ├── TypeScript with Web.js │ │ │ │ └── TypeScript with WebGL.js │ │ │ ├── Functions with JavaScript │ │ │ │ ├── Function Chaining.ts │ │ │ │ ├── Generic Functions.ts │ │ │ │ └── Typing Functions.ts │ │ │ ├── Helping with JavaScript │ │ │ │ ├── Errors.ts │ │ │ │ └── Quick Fixes.ts │ │ │ ├── JavaScript Essentials │ │ │ │ ├── Code Flow.ts │ │ │ │ ├── Functions.ts │ │ │ │ ├── Hello World.ts │ │ │ │ └── Objects and Arrays.ts │ │ │ ├── Modern JavaScript │ │ │ │ ├── Async Await.ts │ │ │ │ ├── Immutability.ts │ │ │ │ ├── Import Export.ts │ │ │ │ └── JSDoc Support.js │ │ │ ├── README.md │ │ │ └── Working With Classes │ │ │ │ ├── Classes 101.ts │ │ │ │ ├── Generic Classes.ts │ │ │ │ ├── Mixins.ts │ │ │ │ └── This.ts │ │ │ ├── Playground │ │ │ ├── Config │ │ │ │ ├── JavaScript Playgrounds.js │ │ │ │ └── New Compiler Defaults.ts │ │ │ ├── Language │ │ │ │ ├── Automatic Type Acquisition.ts │ │ │ │ └── Fixits.ts │ │ │ └── Tooling │ │ │ │ ├── Mobile Support.ts │ │ │ │ ├── Sharable URLs.ts │ │ │ │ └── TypeScript Versions.ts │ │ │ ├── README.md │ │ │ ├── TypeScript │ │ │ ├── Language Extensions │ │ │ │ ├── Enums.ts │ │ │ │ ├── Nominal Typing.ts │ │ │ │ └── Types vs Interfaces.ts │ │ │ ├── Language │ │ │ │ ├── Soundness.ts │ │ │ │ ├── Structural Typing.ts │ │ │ │ ├── Type Guards.ts │ │ │ │ └── Type Widening and Narrowing.ts │ │ │ ├── Meta-Types │ │ │ │ ├── Conditional Types.ts │ │ │ │ ├── Discriminate Types.ts │ │ │ │ ├── Indexed Types.ts │ │ │ │ └── Mapped Types.ts │ │ │ ├── Primitives │ │ │ │ ├── Any.ts │ │ │ │ ├── Literals.ts │ │ │ │ ├── Union and Intersection Types.ts │ │ │ │ └── Unknown and Never.ts │ │ │ ├── README.md │ │ │ └── Type Primitives │ │ │ │ ├── Built-in Utility Types.ts │ │ │ │ ├── Nullable Types.ts │ │ │ │ └── Tuples.ts │ │ │ └── sections.json │ ├── generated │ │ └── .gitignore │ ├── package.json │ └── scripts │ │ ├── copyFiles.js │ │ └── generateTOC.js ├── playground-handbook │ ├── .gitignore │ ├── README.md │ ├── copy │ │ └── en │ │ │ ├── Compiler Settings.md │ │ │ ├── Examples.md │ │ │ ├── Exporting Your Code.md │ │ │ ├── JS + DTS sidebars.md │ │ │ ├── Localization.md │ │ │ ├── Overview.md │ │ │ ├── Running Code.md │ │ │ ├── Settings Panel.md │ │ │ ├── Twoslash Annotations.md │ │ │ ├── Type Acquisition.md │ │ │ ├── TypeScript Versions.md │ │ │ ├── URL Structure.md │ │ │ ├── Writing DTS Files.md │ │ │ └── Writing JavaScript.md │ ├── package.json │ └── scripts │ │ └── generateJSON.mjs ├── playground-worker │ ├── README.md │ ├── index.ts │ ├── package.json │ ├── tsconfig.json │ └── types.d.ts ├── playground │ ├── .gitignore │ ├── README.md │ ├── package.json │ ├── scripts │ │ └── getListOfPluginsFromNPM.js │ ├── src │ │ ├── ambient.d.ts │ │ ├── createConfigDropdown.ts │ │ ├── createElements.ts │ │ ├── createUI.ts │ │ ├── ds │ │ │ └── createDesignSystem.ts │ │ ├── exporter.ts │ │ ├── getExample.ts │ │ ├── index.ts │ │ ├── localizeWithFallback.ts │ │ ├── monaco │ │ │ └── ExampleHighlight.ts │ │ ├── navigation.ts │ │ ├── pluginUtils.ts │ │ ├── sidebar │ │ │ ├── ast.ts │ │ │ ├── fixtures │ │ │ │ └── npmPlugins.ts │ │ │ ├── plugins.ts │ │ │ ├── runtime.ts │ │ │ ├── settings.ts │ │ │ ├── showDTS.ts │ │ │ ├── showErrors.ts │ │ │ ├── showJS.ts │ │ │ └── showTypes.ts │ │ ├── theme.ts │ │ └── twoslashInlays.ts │ ├── test │ │ └── typeAcquisition.test.tsx │ └── tsconfig.json ├── sandbox │ ├── .gitignore │ ├── CHANGELOG.md │ ├── README.md │ ├── dts.config.js │ ├── package.json │ ├── script │ │ └── downloadReleases.js │ ├── src │ │ ├── ambient.d.ts │ │ ├── compilerOptions.ts │ │ ├── createCompilerHost.ts │ │ ├── getInitialCode.ts │ │ ├── index.ts │ │ ├── monacoTSVersions.ts │ │ ├── theme.ts │ │ ├── tsWorker.ts │ │ ├── twoslashSupport.ts │ │ └── vendor │ │ │ ├── lzstring.min.d.ts │ │ │ └── lzstring.min.js │ ├── test │ │ ├── defaultCompilerOptions.test.ts │ │ ├── twoslashSupport.test.ts │ │ └── typeAcquisition.test.tsx │ ├── tsconfig.json │ └── tsconfig.lib.json ├── ts-twoslasher │ ├── .gitignore │ ├── CHANGELOG.md │ ├── CONTRIBUTING.md │ ├── LICENSE │ ├── README.md │ ├── package.json │ ├── scripts │ │ ├── inline-results.js │ │ └── makeGlobals.js │ ├── src │ │ ├── index.ts │ │ ├── utils.ts │ │ └── validation.ts │ ├── test │ │ ├── .prettierignore │ │ ├── README.md │ │ ├── compiler_options.test.ts │ │ ├── custom_transformers.test.ts │ │ ├── cutting.test.ts │ │ ├── fixtures.test.ts │ │ ├── fixtures │ │ │ ├── compiler_errors.ts │ │ │ ├── compiler_flags.ts │ │ │ ├── completions.ts │ │ │ ├── cuts_out_unnecessary_code.ts │ │ │ ├── declarations.ts │ │ │ ├── errorsWithGenerics.ts │ │ │ ├── highlighting.ts │ │ │ ├── import_files.ts │ │ │ ├── importsModules.ts │ │ │ ├── multiFileErrors.ts │ │ │ ├── query.ts │ │ │ ├── showEmit.ts │ │ │ ├── tests │ │ │ │ ├── arbitraryCommands.ts │ │ │ │ ├── crossExports.ts │ │ │ │ ├── cut_file_errors.ts │ │ │ │ ├── cut_files.ts │ │ │ │ ├── emittedOutFile.ts │ │ │ │ ├── handlesJSON.ts │ │ │ │ ├── hidden_emit.ts │ │ │ │ ├── inlineHighlights.ts │ │ │ │ ├── jsx.ts │ │ │ │ ├── large-cut.ts │ │ │ │ ├── lib.ts │ │ │ │ ├── multiLookups.ts │ │ │ │ ├── preact.tsx │ │ │ │ ├── queriesWithSpaceBefore.ts │ │ │ │ ├── queryHandlesNoToken.ts │ │ │ │ ├── removePrettierIgnore.ts │ │ │ │ ├── showEmit.ts │ │ │ │ ├── showJS.ts │ │ │ │ ├── tsx.ts │ │ │ │ └── twoliner.ts │ │ │ └── throws │ │ │ │ ├── multifile_errors.ts │ │ │ │ ├── unexpected_errors.ts │ │ │ │ ├── unknown_compiler_error.ts │ │ │ │ ├── unknown_compiler_value.ts │ │ │ │ └── unknown_extension.herjk │ │ ├── highlights.test.ts │ │ ├── modules.test.ts │ │ ├── queries.test.ts │ │ ├── results │ │ │ ├── compiler_errors.json │ │ │ ├── compiler_flags.json │ │ │ ├── completions.json │ │ │ ├── cuts_out_unnecessary_code.json │ │ │ ├── declarations.json │ │ │ ├── errorsWithGenerics.json │ │ │ ├── highlighting.json │ │ │ ├── import_files.json │ │ │ ├── importsModules.json │ │ │ ├── multiFileErrors.json │ │ │ ├── multifile_errors.json │ │ │ ├── query.json │ │ │ ├── showEmit.json │ │ │ ├── tests │ │ │ │ ├── arbitraryCommands.json │ │ │ │ ├── crossExports.json │ │ │ │ ├── cut_file_errors.json │ │ │ │ ├── cut_files.json │ │ │ │ ├── emittedOutFile.json │ │ │ │ ├── handlesJSON.json │ │ │ │ ├── hidden_emit.json │ │ │ │ ├── inlineHighlights.json │ │ │ │ ├── jsx.json │ │ │ │ ├── large-cut.json │ │ │ │ ├── lib.json │ │ │ │ ├── multiLookups.json │ │ │ │ ├── noIndexInFiles.json │ │ │ │ ├── preact.json │ │ │ │ ├── queriesWithSpaceBefore.json │ │ │ │ ├── queryHandlesNoToken.json │ │ │ │ ├── removePrettierIgnore.json │ │ │ │ ├── showEmit.json │ │ │ │ ├── showJS.json │ │ │ │ ├── tsx.json │ │ │ │ └── twoliner.json │ │ │ ├── unexpected_errors.json │ │ │ ├── unknown_compiler_error.json │ │ │ ├── unknown_compiler_value.json │ │ │ └── unknown_extension.json │ │ ├── tags.test.ts │ │ └── utils.test.ts │ └── tsconfig.json ├── tsconfig-reference │ ├── .gitignore │ ├── README.md │ ├── copy │ │ └── en │ │ │ ├── categories │ │ │ ├── Additional_Checks_6176.md │ │ │ ├── Advanced_Options_6178.md │ │ │ ├── Backwards_Compatibility_6253.md │ │ │ ├── Basic_Options_6172.md │ │ │ ├── Command_line_Options_6171.md │ │ │ ├── Compiler_Diagnostics_6251.md │ │ │ ├── Completeness_6257.md │ │ │ ├── Editor_Support_6249.md │ │ │ ├── Emit_6246.md │ │ │ ├── Experimental_Options_6177.md │ │ │ ├── Interop_Constraints_6252.md │ │ │ ├── JavaScript_Support_6247.md │ │ │ ├── Language_and_Environment_6254.md │ │ │ ├── Module_Resolution_Options_6174.md │ │ │ ├── Modules_6244.md │ │ │ ├── Output_Formatting_6256.md │ │ │ ├── Project_Files_0.md │ │ │ ├── Projects_6255.md │ │ │ ├── Source_Map_Options_6175.md │ │ │ ├── Strict_Type_Checking_Options_6173.md │ │ │ ├── Type_Checking_6248.md │ │ │ └── Watch_and_Build_Modes_6250.md │ │ │ ├── cli │ │ │ └── help.md │ │ │ ├── intro.md │ │ │ ├── options │ │ │ ├── allowArbitraryExtensions.md │ │ │ ├── allowImportingTsExtensions.md │ │ │ ├── allowJs.md │ │ │ ├── allowSyntheticDefaultImports.md │ │ │ ├── allowUmdGlobalAccess.md │ │ │ ├── allowUnreachableCode.md │ │ │ ├── allowUnusedLabels.md │ │ │ ├── alwaysStrict.md │ │ │ ├── assumeChangesOnlyAffectDirectDependencies.md │ │ │ ├── baseUrl.md │ │ │ ├── charset.md │ │ │ ├── checkJs.md │ │ │ ├── clean.md │ │ │ ├── composite.md │ │ │ ├── customConditions.md │ │ │ ├── declaration.md │ │ │ ├── declarationDir.md │ │ │ ├── declarationMap.md │ │ │ ├── diagnostics.md │ │ │ ├── disableFilenameBasedTypeAcquisition.md │ │ │ ├── disableReferencedProjectLoad.md │ │ │ ├── disableSizeLimit.md │ │ │ ├── disableSolutionSearching.md │ │ │ ├── disableSourceOfProjectReferenceRedirect.md │ │ │ ├── downlevelIteration.md │ │ │ ├── emitBOM.md │ │ │ ├── emitDeclarationOnly.md │ │ │ ├── emitDecoratorMetadata.md │ │ │ ├── enable.md │ │ │ ├── erasableSyntaxOnly.md │ │ │ ├── esModuleInterop.md │ │ │ ├── exactOptionalPropertyTypes.md │ │ │ ├── exclude.md │ │ │ ├── excludeDirectories.md │ │ │ ├── excludeFiles.md │ │ │ ├── experimentalDecorators.md │ │ │ ├── explainFiles.md │ │ │ ├── extendedDiagnostics.md │ │ │ ├── extends.md │ │ │ ├── fallbackPolling.md │ │ │ ├── files.md │ │ │ ├── force.md │ │ │ ├── forceConsistentCasingInFileNames.md │ │ │ ├── generateCpuProfile.md │ │ │ ├── generateTrace.md │ │ │ ├── importHelpers.md │ │ │ ├── importsNotUsedAsValues.md │ │ │ ├── include.md │ │ │ ├── incremental.md │ │ │ ├── inlineSourceMap.md │ │ │ ├── inlineSources.md │ │ │ ├── isolatedDeclarations.md │ │ │ ├── isolatedModules.md │ │ │ ├── jsx.md │ │ │ ├── jsxFactory.md │ │ │ ├── jsxFragmentFactory.md │ │ │ ├── jsxImportSource.md │ │ │ ├── keyofStringsOnly.md │ │ │ ├── lib.md │ │ │ ├── libReplacement.md │ │ │ ├── listEmittedFiles.md │ │ │ ├── listFiles.md │ │ │ ├── locale.md │ │ │ ├── mapRoot.md │ │ │ ├── maxNodeModuleJsDepth.md │ │ │ ├── module.md │ │ │ ├── moduleDetection.md │ │ │ ├── moduleResolution.md │ │ │ ├── moduleSuffixes.md │ │ │ ├── newLine.md │ │ │ ├── noCheck.md │ │ │ ├── noEmit.md │ │ │ ├── noEmitHelpers.md │ │ │ ├── noEmitOnError.md │ │ │ ├── noErrorTruncation.md │ │ │ ├── noFallthroughCasesInSwitch.md │ │ │ ├── noImplicitAny.md │ │ │ ├── noImplicitOverride.md │ │ │ ├── noImplicitReturns.md │ │ │ ├── noImplicitThis.md │ │ │ ├── noImplicitUseStrict.md │ │ │ ├── noLib.md │ │ │ ├── noPropertyAccessFromIndexSignature.md │ │ │ ├── noResolve.md │ │ │ ├── noStrictGenericChecks.md │ │ │ ├── noUncheckedIndexedAccess.md │ │ │ ├── noUncheckedSideEffectImports.md │ │ │ ├── noUnusedLocals.md │ │ │ ├── noUnusedParameters.md │ │ │ ├── out.md │ │ │ ├── outDir.md │ │ │ ├── outFile.md │ │ │ ├── paths.md │ │ │ ├── plugins.md │ │ │ ├── preserveConstEnums.md │ │ │ ├── preserveSymlinks.md │ │ │ ├── preserveValueImports.md │ │ │ ├── preserveWatchOutput.md │ │ │ ├── pretty.md │ │ │ ├── reactNamespace.md │ │ │ ├── references.md │ │ │ ├── removeComments.md │ │ │ ├── resolveJsonModule.md │ │ │ ├── resolvePackageJsonExports.md │ │ │ ├── resolvePackageJsonImports.md │ │ │ ├── rewriteRelativeImportExtensions.md │ │ │ ├── rootDir.md │ │ │ ├── rootDirs.md │ │ │ ├── skipDefaultLibCheck.md │ │ │ ├── skipLibCheck.md │ │ │ ├── sourceMap.md │ │ │ ├── sourceRoot.md │ │ │ ├── stopBuildOnErrors.md │ │ │ ├── strict.md │ │ │ ├── strictBindCallApply.md │ │ │ ├── strictBuiltinIteratorReturn.md │ │ │ ├── strictFunctionTypes.md │ │ │ ├── strictNullChecks.md │ │ │ ├── strictPropertyInitialization.md │ │ │ ├── stripInternal.md │ │ │ ├── suppressExcessPropertyErrors.md │ │ │ ├── suppressImplicitAnyIndexErrors.md │ │ │ ├── synchronousWatchDirectory.md │ │ │ ├── target.md │ │ │ ├── traceResolution.md │ │ │ ├── tsBuildInfoFile.md │ │ │ ├── typeAcquisition.md │ │ │ ├── typeAcquisition │ │ │ │ ├── exclude.md │ │ │ │ └── include.md │ │ │ ├── typeRoots.md │ │ │ ├── types.md │ │ │ ├── useDefineForClassFields.md │ │ │ ├── useUnknownInCatchVariables.md │ │ │ ├── verbatimModuleSyntax.md │ │ │ ├── verbose.md │ │ │ ├── watchDirectory.md │ │ │ └── watchFile.md │ │ │ └── sections │ │ │ ├── Top Level.md │ │ │ ├── buildOptions.md │ │ │ ├── compilerOptions.md │ │ │ ├── typeAcquisition.md │ │ │ └── watchOptions.md │ ├── data │ │ ├── .gitignore │ │ └── _types.ts │ ├── output │ │ ├── .gitignore │ │ └── .gitkeep │ ├── package.json │ ├── scripts │ │ ├── cli │ │ │ ├── generateJSON.ts │ │ │ └── generateMarkdown.ts │ │ ├── lint.js │ │ ├── msbuild │ │ │ ├── Microsoft.TypeScript.targets │ │ │ ├── generateJSON.ts │ │ │ ├── generateMarkdown.ts │ │ │ └── types.d.ts │ │ ├── schema │ │ │ ├── downloadSchemaBase.ts │ │ │ ├── exampleTsconfig.json │ │ │ ├── generateJSON.ts │ │ │ ├── result │ │ │ │ └── schema.json │ │ │ └── vendor │ │ │ │ └── base.json │ │ ├── tsconfig │ │ │ ├── generateJSON.ts │ │ │ └── generateMarkdown.ts │ │ ├── tsconfigRules.ts │ │ └── types.ts │ └── tsconfig.json ├── typescript-vfs │ ├── .gitignore │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── package.json │ ├── scripts │ │ └── makeGlobals.js │ ├── src │ │ └── index.ts │ ├── test │ │ ├── fsbacked.test.ts │ │ └── index.test.ts │ └── tsconfig.json └── typescriptlang-org │ ├── .gitignore │ ├── .prettierrc │ ├── README.md │ ├── _tests │ └── backstop_data │ │ └── bitmaps_reference │ │ ├── backstop_default_Index_0_document_0_phone.png │ │ ├── backstop_default_Index_0_document_1_tablet.png │ │ └── backstop_default_Index_0_document_2_computer.png │ ├── gatsby-config.js │ ├── gatsby-node.js │ ├── gatsby-ssr.js │ ├── lib │ ├── bootup │ │ ├── createPages.ts │ │ ├── ingestion │ │ │ ├── createGlossaryPages.ts │ │ │ ├── createPagesForDocumentation.ts │ │ │ ├── createPlaygroundExamplePages.ts │ │ │ ├── createPlaygroundHandbook.ts │ │ │ ├── createPlaygrounds.ts │ │ │ ├── createRootPagesLocalized.ts │ │ │ ├── createTSConfigReference.ts │ │ │ ├── createTSConfigSingleFlagPages.ts │ │ │ └── languageFilter.ts │ │ └── pathsOnSiteTracker.ts │ ├── themes │ │ ├── themeGen.js │ │ ├── typescript-beta-dark.json │ │ └── typescript-beta-light.json │ └── utils │ │ ├── _invertCodeToHTML.test.ts │ │ ├── invertCodeToHTML.ts │ │ └── recursiveReadDirSync.js │ ├── package.json │ ├── scripts │ ├── backstop │ │ └── makeDarkMode.js │ ├── cacheBustPlayground.mjs │ ├── createLighthouseJSON.js │ ├── downloadPlaygroundAssets.js │ ├── downloadSearchAssets.js │ ├── ensureDepsAreBuilt.js │ ├── getTypeScriptNPMVersions.js │ └── updateIndexTwoslashExamples.js │ ├── src │ ├── __generated__ │ │ └── gatsby-types.ts │ ├── assets │ │ ├── community │ │ │ ├── conferences │ │ │ │ ├── tsconf-2019-logo.png │ │ │ │ ├── tsconf-eu-2020-brief.png │ │ │ │ ├── tsconf-eu-2020-logo.png │ │ │ │ ├── tsconf-it-2019-logo.png │ │ │ │ └── tsconf-jp-logo.png │ │ │ ├── connect-blog-icon.svg │ │ │ ├── connect-bug-icon.svg │ │ │ ├── connect-discord.svg │ │ │ ├── connect-github-icon.png │ │ │ ├── connect-gitter.svg │ │ │ ├── connect-group-icon.svg │ │ │ ├── connect-stackoverflow-icon.svg │ │ │ ├── connect-twitter-icon.svg │ │ │ ├── connect-uservoice-icon.svg │ │ │ ├── definitely_typed_logo.png │ │ │ └── meetup-logos │ │ │ │ ├── boston-ts-club.png │ │ │ │ ├── brazil-ts.jpg │ │ │ │ ├── dublin-ts.jpg │ │ │ │ ├── hamburg-ts.png │ │ │ │ ├── ktug.jpg │ │ │ │ ├── london-ts.jpg │ │ │ │ ├── melbourne.jpg │ │ │ │ ├── milano-ts.jpg │ │ │ │ ├── paris-ts.jpg │ │ │ │ ├── phx-ts.jpg │ │ │ │ ├── san-fran-ts.jpg │ │ │ │ ├── seattle.jpg │ │ │ │ ├── sqvts.jpg │ │ │ │ ├── sydney.jpg │ │ │ │ ├── typescript-jp.jpg │ │ │ │ ├── typescript-nyc.jpg │ │ │ │ ├── warsaw-ts.jpg │ │ │ │ └── wroclaw-ts.jpg │ │ ├── index │ │ │ ├── code-dark.png │ │ │ ├── code-light.png │ │ │ ├── handbook.jpg │ │ │ ├── play-dark.png │ │ │ └── play-light.png │ │ ├── microsoft-logo.png │ │ ├── playground-plugin-preview.png │ │ ├── typescript-handbook.epub │ │ │ └── index.html │ │ ├── typescript-handbook.pdf │ │ │ └── index.html │ │ └── v3.png │ ├── components │ │ ├── HeadSEO.tsx │ │ ├── Intl.tsx │ │ ├── IntlLink.tsx │ │ ├── QuickJump.tsx │ │ ├── ShowExamples.scss │ │ ├── ShowExamples.tsx │ │ ├── SuppressWhenTouch.tsx │ │ ├── TmpLink.tsx │ │ ├── VersionBar.tsx │ │ ├── devNav.tsx │ │ ├── display │ │ │ ├── ButtonGrid.tsx │ │ │ └── GreyButton.tsx │ │ ├── handbook │ │ │ ├── Contributors.tsx │ │ │ └── NextPrev.tsx │ │ ├── index │ │ │ ├── AboveTheFold.tsx │ │ │ ├── AdoptSteps.tsx │ │ │ ├── EditorExamples.tsx │ │ │ ├── MigrationStories.tsx │ │ │ └── twoslash │ │ │ │ ├── Index2Del1TS.ts │ │ │ │ ├── Index2Del2RM.ts │ │ │ │ ├── Index2Del3JS.js │ │ │ │ ├── IndexAdoptGrad1.ts │ │ │ │ ├── IndexAdoptGrad2.ts │ │ │ │ ├── IndexGetStarted1.js │ │ │ │ ├── IndexGetStarted2.js │ │ │ │ ├── IndexGetStarted3.js │ │ │ │ ├── IndexGetStarted4.ts │ │ │ │ ├── JSDoc.js │ │ │ │ ├── TS.ts │ │ │ │ ├── cfa.ts │ │ │ │ ├── generated │ │ │ │ ├── Index2Del1TS.tsx │ │ │ │ ├── Index2Del2RM.tsx │ │ │ │ ├── Index2Del3JS.js.tsx │ │ │ │ ├── IndexAdoptGrad1.tsx │ │ │ │ ├── IndexAdoptGrad2.tsx │ │ │ │ ├── IndexGetStarted1.js.tsx │ │ │ │ ├── IndexGetStarted2.js.tsx │ │ │ │ ├── IndexGetStarted3.js.tsx │ │ │ │ ├── IndexGetStarted4.tsx │ │ │ │ ├── JSDoc.js.tsx │ │ │ │ ├── TS.tsx │ │ │ │ ├── cfa.tsx │ │ │ │ ├── interface.tsx │ │ │ │ ├── react.tsx │ │ │ │ ├── showErrors.tsx │ │ │ │ └── typeDefinitions.tsx │ │ │ │ ├── homepage.json │ │ │ │ ├── interface.ts │ │ │ │ ├── react.tsx │ │ │ │ ├── showErrors.ts │ │ │ │ └── typeDefinitions.tsx │ │ ├── layout.tsx │ │ ├── layout │ │ │ ├── CookieBanner.tsx │ │ │ ├── LanguageRecommendation.tsx │ │ │ ├── Sidebar-keyboard.tsx │ │ │ ├── Sidebar.scss │ │ │ ├── Sidebar.tsx │ │ │ ├── SiteFooter-Customize.tsx │ │ │ ├── SiteFooter.scss │ │ │ ├── SiteFooter.tsx │ │ │ ├── TopNav.scss │ │ │ ├── TopNav.tsx │ │ │ ├── cookie.scss │ │ │ ├── fonts.scss │ │ │ ├── main.scss │ │ │ └── stickyNavigation.ts │ │ ├── svgs │ │ │ └── documentation.tsx │ │ └── workbench │ │ │ └── plugins │ │ │ ├── about.ts │ │ │ ├── assertions.ts │ │ │ ├── debug.ts │ │ │ ├── docs.ts │ │ │ ├── emits.ts │ │ │ └── markdown.ts │ ├── copy │ │ ├── .gitignore │ │ ├── en │ │ │ ├── cheatsheets.ts │ │ │ ├── community.ts │ │ │ ├── documentation.ts │ │ │ ├── dt.ts │ │ │ ├── en.ts │ │ │ ├── footer.ts │ │ │ ├── handbook.ts │ │ │ ├── head-seo.ts │ │ │ ├── index.ts │ │ │ ├── index2.ts │ │ │ ├── nav.ts │ │ │ ├── playground.ts │ │ │ └── tsconfig.ts │ │ └── inYourLanguage.ts │ ├── dom.d.ts │ ├── lib │ │ ├── createInternational.ts │ │ ├── documentationNavigationUtils.ts │ │ ├── hasLocalStorage.ts │ │ ├── isTouchDevice.ts │ │ ├── playgroundURLs.ts │ │ ├── release-plan.json │ │ └── whenEscape.ts │ ├── pages │ │ ├── README.md │ │ ├── branding.scss │ │ ├── branding.tsx │ │ └── dev │ │ │ ├── bug-workbench.tsx │ │ │ ├── dev.scss │ │ │ ├── playground-plugins.tsx │ │ │ ├── sandbox.tsx │ │ │ ├── twoslash.tsx │ │ │ └── typescript-vfs.tsx │ ├── redirects │ │ └── setupRedirects.ts │ ├── style │ │ ├── globals.scss │ │ └── theme.jsonc │ └── templates │ │ ├── documentation.scss │ │ ├── documentation.tsx │ │ ├── glossary.scss │ │ ├── glossary.tsx │ │ ├── markdown-twoslash.scss │ │ ├── markdown.scss │ │ ├── pages │ │ ├── cheatsheets.tsx │ │ ├── community.tsx │ │ ├── css │ │ │ ├── cheatsheets.scss │ │ │ ├── community.scss │ │ │ ├── documentation.scss │ │ │ ├── grid.scss │ │ │ ├── index.scss │ │ │ └── tools.scss │ │ ├── docs │ │ │ ├── handbook │ │ │ │ └── index.tsx │ │ │ └── index.tsx │ │ ├── download.tsx │ │ ├── dt │ │ │ └── search.tsx │ │ ├── empty.tsx │ │ ├── index.tsx │ │ ├── tools.tsx │ │ └── why-create-typescript.tsx │ │ ├── play-example.tsx │ │ ├── play.scss │ │ ├── play.tsx │ │ ├── playgroundHandbook.tsx │ │ ├── scripts │ │ ├── setupLikeDislikeButtons.ts │ │ └── setupSubNavigationSidebar.ts │ │ ├── tsconfig.scss │ │ ├── tsconfigOptionOnePage.tsx │ │ └── tsconfigReference.tsx │ ├── static │ ├── .gitattributes │ ├── License.html │ ├── Web.config │ ├── assets │ │ ├── .gitkeep │ │ └── typescript-cheat-sheets.zip │ ├── branding │ │ ├── palette.png │ │ ├── ts-lettermark-blue.png │ │ ├── ts-lettermark-blue.svg │ │ ├── ts-lettermark-white.png │ │ ├── ts-lettermark-white.svg │ │ ├── ts-logo-128.png │ │ ├── ts-logo-128.svg │ │ ├── ts-logo-256.png │ │ ├── ts-logo-256.svg │ │ ├── ts-logo-512.png │ │ ├── ts-logo-512.svg │ │ ├── ts-logo-round-128.png │ │ ├── ts-logo-round-128.svg │ │ ├── ts-logo-round-256.png │ │ ├── ts-logo-round-256.svg │ │ ├── ts-logo-round-512.png │ │ ├── ts-logo-round-512.svg │ │ ├── ts-logo-single-color-black.svg │ │ ├── ts-logo-single-color-white.svg │ │ └── typescript-design-assets.zip │ ├── css │ │ └── docsearch.css │ ├── favicon.ico │ ├── fonts │ │ ├── CascadiaCode-SemiLight.woff2 │ │ ├── CascadiaMono-SemiLight.woff2 │ │ ├── DankMono-Regular.woff2 │ │ ├── FiraCode-Regular.woff2 │ │ ├── JetBrainsMono-Regular.woff2 │ │ ├── OpenDyslexic-Regular.woff │ │ ├── OpenDyslexicMono-Regular.woff │ │ └── SourceCodePro-Regular.woff2 │ ├── icons │ │ └── ts-logo-512.png │ ├── images │ │ ├── branding │ │ │ ├── logo-grouping.svg │ │ │ ├── logos.png │ │ │ ├── palette-bg.svg │ │ │ ├── palette.svg │ │ │ ├── two-colors.svg │ │ │ └── two-longform.svg │ │ ├── cheatsheets │ │ │ ├── TypeScript Classes.png │ │ │ ├── TypeScript Control Flow Analysis.png │ │ │ ├── TypeScript Interfaces.png │ │ │ └── TypeScript Types.png │ │ ├── docs │ │ │ └── greet_person.png │ │ ├── index │ │ │ ├── get-started-download-blue.svg │ │ │ ├── get-started-download.svg │ │ │ ├── get-started-handbook-blue.svg │ │ │ ├── get-started-handbook.svg │ │ │ ├── get-started-playground-blue.svg │ │ │ ├── get-started-playground.svg │ │ │ ├── stack-overflow.svg │ │ │ ├── state-of-js.svg │ │ │ ├── ts-at-scale.jpg │ │ │ ├── ts-conf-keynote.jpg │ │ │ ├── what-is-new-ts.jpg │ │ │ └── wrong-ts.jpg │ │ ├── tools │ │ │ ├── cheat-sheets.png │ │ │ ├── dt-search.png │ │ │ ├── play.png │ │ │ └── tsconfig-ref.png │ │ └── tutorials │ │ │ └── aspnet │ │ │ ├── choosedependencies.png │ │ │ ├── createwebapp.png │ │ │ ├── debugger.png │ │ │ ├── downloaddependency.png │ │ │ ├── emptytemplate.png │ │ │ ├── namewebapp.png │ │ │ ├── newfolder.png │ │ │ ├── npm.png │ │ │ ├── packagejson.png │ │ │ ├── scripts.png │ │ │ ├── taskrunner.png │ │ │ ├── taskrunnerrefresh.png │ │ │ ├── tsconfig.png │ │ │ ├── tsfile.png │ │ │ ├── tsgif.mov │ │ │ └── workingsite.png │ └── js │ │ ├── docsearch.js │ │ ├── vs.loader.js │ │ └── vs.loader.js.map │ └── tsconfig.json ├── patches ├── gatsby-remark-shiki-twoslash@3.0.38.patch ├── react-intl@3.12.1.patch └── react-server-dom-webpack@0.0.0-experimental-c8b778b7f-20220825.patch ├── pnpm-lock.yaml ├── pnpm-workspace.yaml ├── serve ├── README.md ├── index.js ├── package-lock.json ├── package.json └── public │ └── index.html ├── spellcheck.json ├── test └── fixtures │ └── old-site-map.ts └── watcher.js /.changeset/README.md: -------------------------------------------------------------------------------- 1 | # Changesets 2 | 3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works 4 | with multi-package repos, or single-package repos to help you version and publish your code. You can 5 | find the full documentation for it [in our repository](https://github.com/changesets/changesets) 6 | 7 | We have a quick list of common questions to get you started engaging with this project in 8 | [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) 9 | -------------------------------------------------------------------------------- /.changeset/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json", 3 | "changelog": ["@changesets/changelog-github", { "repo": "microsoft/TypeScript-Website" }], 4 | "commit": false, 5 | "fixed": [], 6 | "linked": [], 7 | "access": "public", 8 | "baseBranch": "v2", 9 | "updateInternalDependencies": "patch", 10 | "ignore": [], 11 | "privatePackages": { 12 | "tag": false, 13 | "version": false 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "TypeScript Website codespace", 3 | "dockerFile": "Dockerfile", 4 | 5 | // Set *default* container specific settings.json values on container create. 6 | "settings": { 7 | "terminal.integrated.shell.linux": "/bin/bash" 8 | }, 9 | 10 | "forwardPorts": [8000], 11 | } 12 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * -text 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: TypeScript Compiler issues 4 | url: https://github.com/microsoft/TypeScript/issues/new/choose 5 | about: File TypeScript issues here 6 | 7 | - name: Chat 8 | url: "https://discord.gg/typescript" 9 | about: Use the TypeScript Community Discord to talk with others about the site 10 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/critical-issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Critical Issue 3 | about: Report a critical issue with the website (for non-critical issues we appreciate PRs) 4 | title: "CRITICAL: " 5 | --- 6 | 12 | 13 | 14 | 15 | **Page URL:** 16 | 17 | **Issue:** 18 | -------------------------------------------------------------------------------- /.github/codeql/codeql-configuration.yml: -------------------------------------------------------------------------------- 1 | name : CodeQL Configuration 2 | 3 | paths: 4 | - './packages' 5 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: 'github-actions' 9 | directory: '/' 10 | schedule: 11 | interval: 'weekly' 12 | groups: 13 | github-actions: 14 | patterns: 15 | - '*' 16 | -------------------------------------------------------------------------------- /.github/workflows/close-preview.yml: -------------------------------------------------------------------------------- 1 | name: Close preview environment 2 | on: 3 | workflow_dispatch: 4 | inputs: 5 | pr: 6 | required: true 7 | type: string 8 | description: PR number 9 | pull_request_target: 10 | types: [closed] 11 | 12 | jobs: 13 | close: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: Azure/static-web-apps-deploy@v1 17 | with: 18 | azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_PREVIEW }} 19 | action: close 20 | app_location: /dev/null 21 | -------------------------------------------------------------------------------- /.github/workflows/keepalive.yml: -------------------------------------------------------------------------------- 1 | name: Keep alive 2 | on: 3 | schedule: 4 | - cron: "0 0 * * *" 5 | 6 | jobs: 7 | keepalive: 8 | runs-on: ubuntu-latest 9 | 10 | permissions: 11 | contents: write 12 | 13 | steps: 14 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 15 | - run: | 16 | if [[ $(git log --format="%H" --since "50 days" | head -c1 | wc -c) == 0 ]]; then 17 | git config user.email "typescriptbot@microsoft.com" 18 | git config user.name "TypeScript Bot" 19 | git commit --allow-empty -m "Automated commit to keep GitHub Actions active" 20 | git push 21 | fi 22 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | shell-emulator=true 2 | publish-branch=v2 3 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | packages/typescriptlang-org/src/**/*.tsx 2 | packages/typescriptlang-org/src/components/index/twoslash/* -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": false, 3 | "singleQuote": false, 4 | "printWidth": 120, 5 | "arrowParens": "avoid" 6 | } 7 | -------------------------------------------------------------------------------- /.vscode/done.aiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/.vscode/done.aiff -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "esbenp.prettier-vscode", 4 | "Orta.vscode-twoslash" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /.vscode/settings.template.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.exclude": { 3 | "**/.rts2_cache*": true, 4 | "**/packages/typescriptlang-org/public/*": true, 5 | "**/packages/typescriptlang-org/.cache/*": true 6 | }, 7 | "typescript.tsdk": "node_modules/typescript/lib", 8 | "deno.enable": false 9 | } 10 | -------------------------------------------------------------------------------- /dangerfile.ts: -------------------------------------------------------------------------------- 1 | // You can test it by running 2 | // pnpm danger pr https://github.com/microsoft/TypeScript-Website/pull/115 3 | 4 | import spellcheck from "danger-plugin-spellcheck" 5 | 6 | // Blocked on PR deploys, see CI.yml 7 | // import lighthouse from "danger-plugin-lighthouse" 8 | 9 | // Spell check all the things 10 | spellcheck({ settings: "microsoft/TypeScript-Website@spellcheck.json" }) 11 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | ## Website Docs 2 | 3 | This is for documentation on how the Website works, not documentation for end-users of the TypeScript Website. You can find those back in the [packages folder](../packages) 4 | -------------------------------------------------------------------------------- /docs/Setup Troubleshooting.md: -------------------------------------------------------------------------------- 1 | ## Getting this Repo Set Up Troubleshooting 2 | 3 | #### Module `x` is not built 4 | 5 | Sometimes, and it's not been tracked down exactly, some dependencies of the site aren't built even though it says they are. In those cases, re-run `pnpm bootstrap` and `pnpm build` to re-build all the internal site deps. 6 | 7 | #### Windows + Watchman 8 | 9 | The Windows support for watchman is a bit meh. It's not likely to get better, given how well WSL works now. So, you _could_ use WSL to work around that. 10 | 11 | Though, for _a lot_ of changes to the site: Watchman is optional. All the watchman script does is run `pnpm run --filter=[xxyy] build` when you save in a package which is not `typescriptlang-org` (the gatsby website). 12 | 13 | To run the site without watchman, use `pnpm run --filter=typescriptlang-org start`. 14 | -------------------------------------------------------------------------------- /packages/ata/jest.config.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: "node", 3 | transform: { 4 | "^.+\\.tsx?$": [ 5 | "esbuild-jest", 6 | { 7 | sourcemap: true, 8 | loaders: { 9 | ".spec.ts": "tsx", 10 | }, 11 | }, 12 | ], 13 | }, 14 | } 15 | -------------------------------------------------------------------------------- /packages/ata/tests/edgeCases.spec.ts: -------------------------------------------------------------------------------- 1 | import { mapModuleNameToModule } from "../src/edgeCases" 2 | 3 | describe(mapModuleNameToModule, () => { 4 | it("gives node for known identifiers", () => { 5 | expect(mapModuleNameToModule("fs")).toEqual("node") 6 | }) 7 | 8 | it("handles the weird node: prefix", () => { 9 | expect(mapModuleNameToModule("node:fs")).toEqual("node") 10 | }) 11 | 12 | it("handles mandatorily-prefixed node: identifiers", () => { 13 | expect(mapModuleNameToModule("node:test")).toEqual("node") 14 | expect(mapModuleNameToModule("test")).toEqual("test") 15 | }) 16 | 17 | it("strips module filepaths", () => { 18 | expect(mapModuleNameToModule("lodash/identity")).toEqual("lodash") 19 | expect(mapModuleNameToModule("@org/lodash/identity")).toEqual("@org/lodash") 20 | }) 21 | }) 22 | -------------------------------------------------------------------------------- /packages/ata/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "ESNext", 4 | "moduleResolution": "node", 5 | "strict": true, 6 | "noUncheckedIndexedAccess": true, 7 | "target": "ES2015", 8 | "declaration": false, 9 | "noEmit": true 10 | } 11 | } -------------------------------------------------------------------------------- /packages/community-meta/generated/.gitignore: -------------------------------------------------------------------------------- 1 | *.json 2 | -------------------------------------------------------------------------------- /packages/community-meta/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "community-meta", 3 | "private": true, 4 | "license": "MIT", 5 | "version": "1.0.0", 6 | "dependencies": { 7 | "moment": "2.24.0", 8 | "moment-timezone": "0.5.28" 9 | }, 10 | "scripts": { 11 | "build": "node scripts/generateRichMeetupData.js" 12 | }, 13 | "devDependencies": { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/create-typescript-playground-plugin/.npmignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | template 3 | 4 | -------------------------------------------------------------------------------- /packages/create-typescript-playground-plugin/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # create-typescript-playground-plugin 2 | 3 | ## 1.3.2 4 | 5 | ### Patch Changes 6 | 7 | - [#3275](https://github.com/microsoft/TypeScript-Website/pull/3275) [`17c8311`](https://github.com/microsoft/TypeScript-Website/commit/17c831175cb9580ee3c489c54774c8b35cd0b221) Thanks [@dependabot](https://github.com/apps/dependabot)! - Update cross-spawn 8 | 9 | ## 1.3.1 10 | 11 | ### Patch Changes 12 | 13 | - 46eba14: Initial bump for changesets 14 | -------------------------------------------------------------------------------- /packages/create-typescript-playground-plugin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "create-typescript-playground-plugin", 3 | "version": "1.3.2", 4 | "bin": "index.js", 5 | "author": "TypeScript team", 6 | "license": "MIT", 7 | "homepage": "https://github.com/microsoft/TypeScript-Website", 8 | "repository": { 9 | "url": "https://github.com/microsoft/TypeScript-Website.git", 10 | "directory": "packages/create-typescript-playground-plugin", 11 | "type": "git" 12 | }, 13 | "bugs": { 14 | "url": "https://github.com/microsoft/TypeScript-Website/issues" 15 | }, 16 | "scripts": {}, 17 | "dependencies": { 18 | "cross-spawn": "^7.0.5", 19 | "gunzip-maybe": "^1.4.1", 20 | "tar-fs": "^2.1.0" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/create-typescript-playground-plugin/template/.npmignore: -------------------------------------------------------------------------------- 1 | src 2 | .gitignore 3 | rollup.config.jss 4 | !dist 5 | scripts 6 | .vscode 7 | yarn* 8 | tsconfig.json 9 | rollup* 10 | -------------------------------------------------------------------------------- /packages/create-typescript-playground-plugin/template/README.md: -------------------------------------------------------------------------------- 1 | ## TypeScript Playground Plugin 2 | 3 | My new plugin for the TypeScript playground. 4 | 5 | ## Running this plugin 6 | 7 | - [Click this link](https://www.typescriptlang.org/play?install-plugin=[name]) to install 8 | 9 | or 10 | 11 | - Open up the TypeScript Playground 12 | - Go the "Plugins" in the sidebar 13 | - Look for "Plugins from npm" 14 | - Add "[name]" 15 | - Reload the browser 16 | 17 | Then it will show up as a tab in the sidebar. 18 | 19 | ## Contributing 20 | 21 | See [CONTRIBUTING.md](./CONTRIBUTING.md) for the full details, however, TLDR: 22 | 23 | ```sh 24 | git clone ... 25 | yarn install 26 | yarn start 27 | ``` 28 | 29 | Then tick the box for starting plugin development inside the TypeScript Playground. 30 | -------------------------------------------------------------------------------- /packages/create-typescript-playground-plugin/template/src/vendor/utils.ts: -------------------------------------------------------------------------------- 1 | /** Get a relative URL for something in your dist folder depending on if you're in dev mode or not */ 2 | export const requireURL = (path: string) => { 3 | // https://unpkg.com/browse/typescript-playground-presentation-mode@0.0.1/dist/x.js => unpkg/browse/typescript-playground-presentation-mode@0.0.1/dist/x 4 | const isDev = document.location.host.includes('localhost') 5 | const prefix = isDev ? 'local/' : 'unpkg/typescript-playground-presentation-mode/dist/' 6 | return prefix + path 7 | } 8 | 9 | /** Use this to make a few dumb element generation funcs */ 10 | export const el = (str: string, el: string, container: Element) => { 11 | const para = document.createElement(el) 12 | para.innerHTML = str 13 | container.appendChild(para) 14 | } 15 | -------------------------------------------------------------------------------- /packages/create-typescript-playground-plugin/template/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "esModuleInterop": true, 4 | "noEmit": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/documentation/.gitignore: -------------------------------------------------------------------------------- 1 | # Handled by @oss-docs/sync 2 | copy/* 3 | !copy/en 4 | -------------------------------------------------------------------------------- /packages/documentation/copy/en/declaration-files/Templates.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Templates 3 | layout: docs 4 | permalink: /docs/handbook/declaration-files/templates.html 5 | oneline: "Different d.ts module template examples" 6 | --- 7 | 8 | [global-modifying-module.d.ts](./templates/global-modifying-module.d.ts.md) 9 | 10 | - [global-plugin.d.ts](/docs/handbook/declaration-files/templates/global-plugin-d-ts.html) 11 | - [global.d.ts](/docs/handbook/declaration-files/templates/global-d-ts.html) 12 | - [module-class.d.ts](/docs/handbook/declaration-files/templates/module-class-d-ts.html) 13 | - [module-function.d.ts](/docs/handbook/declaration-files/templates/module-function-d-ts.html) 14 | - [module-plugin.d.ts](/docs/handbook/declaration-files/templates/module-plugin-d-ts.html) 15 | - [module.d.ts](/docs/handbook/declaration-files/templates/module-d-ts.html) 16 | -------------------------------------------------------------------------------- /packages/documentation/copy/en/modules-reference/diagrams/README: -------------------------------------------------------------------------------- 1 | Some of this content uses mermaid diagrams. We could render them as part of the website build with gatsby-remark-mermaid, but that requires puppeteer/Chromium, which has historically caused a lot of cross-platform build issues. These diagrams should not change often, so I’m just going to store the source here and generate the SVGs manually. 2 | 3 | Example: 4 | 5 | ```sh 6 | npm install -g @mermaid-js/mermaid-cli 7 | cd packages/documentation/copy/en/modules-reference/diagrams 8 | mmdc -c mermaid.config.json -i esm-cjs-interop.md 9 | ``` 10 | 11 | declaration-files.svg is a non-Mermaid replacement for theory.md-4.svg. I made it for a talk one time and it’s better than what Mermaid can do with a flowchart. -------------------------------------------------------------------------------- /packages/documentation/copy/en/modules-reference/diagrams/esm-cjs-interop.md: -------------------------------------------------------------------------------- 1 | ```mermaid 2 | graph TB 3 | subgraph Transpiled[ESM transpiled to CJS] 4 | direction TB 5 | C[Importing module] -- designed based on spec --> D[Imported module] 6 | end 7 | subgraph ESM 8 | direction TB 9 | A[Importing module] -- specified behavior --> B[Imported module] 10 | end 11 | ``` 12 | 13 | ```mermaid 14 | graph TD 15 | subgraph Transpiled[ESM transpiled to CJS] 16 | C[Importing module] -- designed based on spec --> D[Imported module] 17 | end 18 | subgraph CJS[True CJS] 19 | E[Imported module] 20 | end 21 | subgraph ESM 22 | A[Importing module] -- specified behavior --> B[Imported module] 23 | end 24 | A -. unspecified behavior .-> E 25 | C .->|"❓🤷🏻‍♂️❓"| E 26 | ``` -------------------------------------------------------------------------------- /packages/documentation/copy/en/modules-reference/diagrams/mermaid.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "theme": "default", 3 | "themeVariables": { 4 | "fontFamily": "Helvetica, Arial, sans-serif" 5 | } 6 | } -------------------------------------------------------------------------------- /packages/documentation/copy/en/tutorials/Angular.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Angular 3 | layout: docs 4 | permalink: /docs/handbook/angular.html 5 | oneline: Using Angular with TypeScript 6 | deprecated: true 7 | --- 8 | 9 | Angular is a modern framework built entirely in TypeScript, and as a result, using TypeScript with Angular provides a seamless experience. 10 | 11 | The Angular documentation not only supports TypeScript as a first-class citizen, but uses it as its primary language. 12 | With this in mind, [Angular's site](https://angular.io) will always be the most up-to-date reference for using Angular with TypeScript. 13 | 14 | Check out the [quick start guide here](https://angular.io/docs/ts/latest/quickstart.html) to start learning Angular now! 15 | -------------------------------------------------------------------------------- /packages/documentation/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "documentation", 3 | "private": true, 4 | "license": "MIT", 5 | "version": "1.0.0", 6 | "scripts": { 7 | "lint": "node scripts/lintTwoslashErrors.js", 8 | "create-handbook-nav": "node ./scripts/generateTypesForFilesInDocs && node ./scripts/generateDocsNavigationPerLanguage.js", 9 | "bootstrap": "pnpm create-handbook-nav && node ./scripts/generateAttribution.js" 10 | }, 11 | "prettier": { 12 | "semi": true 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/glossary/.gitignore: -------------------------------------------------------------------------------- 1 | output 2 | 3 | # Handled by @oss-docs/sync 4 | copy/* 5 | !copy/en 6 | -------------------------------------------------------------------------------- /packages/glossary/copy/en/declare.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Declare" 3 | tags: typescript types keyword 4 | --- 5 | 6 | The `declare` keyword is used to inform the TypeScript [Type System](#type-system) that a variable exists even if it cannot be found in the current source code. 7 | 8 | ```ts twoslash 9 | // Declare that a ghost exists, and that it has a function called "boo" 10 | declare const ghost: { boo: () => void }; 11 | 12 | ghost.boo(); 13 | ``` 14 | 15 | TypeScript would [emit](#emit) JavaScript code like: 16 | 17 | ```ts twoslash 18 | // @showEmit 19 | // Declare that a ghost exists, and that it has a function called "boo" 20 | declare const ghost: { boo: () => void }; 21 | 22 | ghost.boo(); 23 | ``` 24 | 25 | This code could crash if there isn't other code setting up the `ghost` object elsewhere. 26 | -------------------------------------------------------------------------------- /packages/glossary/copy/en/emit.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Emit" 3 | tags: typescript compiler 4 | --- 5 | -------------------------------------------------------------------------------- /packages/glossary/copy/en/interface.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Interface" 3 | tags: typescript types keyword 4 | --- 5 | 6 | An interface is a way to describe the [Shape](#shape) of a JavaScript object. For example, a dog could be described in the following format: 7 | 8 | ```ts twoslash 9 | interface Dog { 10 | name: string; 11 | dateOfBirth: Date; 12 | markings: string[]; 13 | } 14 | ``` 15 | 16 | This means that only an object with a `name`, `dateOfBirth` and `markings` could be classed as a "Dog" in the [Type System](#type-system). 17 | -------------------------------------------------------------------------------- /packages/glossary/copy/en/parser.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Parser" 3 | tags: typescript compiler 4 | --- 5 | 6 | The parser is a part of the TypeScript compiler which takes the text from a [Source File](#source-file) and converts it into an [Abstract Syntax Tree](#abstract-syntax-tree). 7 | -------------------------------------------------------------------------------- /packages/glossary/copy/en/runtime.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "JavaScript Runtime" 3 | tags: javascript 4 | --- 5 | -------------------------------------------------------------------------------- /packages/glossary/copy/en/shape.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Shape" 3 | tags: typescript javascript 4 | --- 5 | 6 | The term "shape" is used to describe the fields and values on a JavaScript object. For example, you could say that this JavaScript object: 7 | 8 | ```ts 9 | const house = { 10 | name: "Shibden hall", 11 | road: "Lister's Road", 12 | town: "Halifax", 13 | county: "West Yorkshire", 14 | }; 15 | ``` 16 | 17 | has the shape: 18 | 19 | - `name`: `string` 20 | - `road`: `string` 21 | - `town`: `string` 22 | - `country`: `string` 23 | 24 | TypeScript can describe this shape using two different syntaxes: [Interfaces](#interface) and [Types](#type-literal) 25 | 26 | ```ts 27 | interface House { 28 | name: string; 29 | road: string; 30 | town: string; 31 | country: string; 32 | } 33 | 34 | // or 35 | 36 | type House = { 37 | name: string; 38 | road: string; 39 | town: string; 40 | country: string; 41 | }; 42 | ``` 43 | -------------------------------------------------------------------------------- /packages/glossary/copy/en/source-file.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Source File" 3 | tags: typescript compiler 4 | --- 5 | 6 | The representation of text which TypeScript would recognize as JavaScript or TypeScript source code. 7 | -------------------------------------------------------------------------------- /packages/glossary/copy/en/types-vs-runtime.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Types vs Runtime" 3 | tags: typescript javascript type-system 4 | --- 5 | 6 | TypeScript adds a "type layer" on top of JavaScript code. TypeScript does this by adding additional syntax to JavaScript which needs to be removed in order to run inside a JavaScript [runtime](#runtime). 7 | 8 | For example, this is JavaScript code which would run in a JavaScript runtime: 9 | 10 | ```ts 11 | const hello = "Hello world"; 12 | ``` 13 | 14 | This is not: 15 | 16 | ```ts 17 | const hello: string = "Hello world"; 18 | ``` 19 | 20 | The `: string` could be thought of as code which only exists in the "type layer" of TypeScript and not in the "runtime" / "expression" layer of JavaScript code which runs. 21 | 22 | The type layer is 23 | -------------------------------------------------------------------------------- /packages/glossary/data/.gitignore: -------------------------------------------------------------------------------- 1 | *.json 2 | -------------------------------------------------------------------------------- /packages/glossary/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "glossary", 3 | "version": "0.0.1", 4 | "license": "MIT", 5 | "private": true, 6 | "scripts": { 7 | "generate-markdown": "pnpm ts-node --project tsconfig.json scripts/generateMarkdown.ts ", 8 | "build": "pnpm generate-markdown", 9 | "test": "pnpm build && pnpm lint", 10 | "lint": "node scripts/lint.js" 11 | }, 12 | "prettier": { 13 | "printWidth": 100, 14 | "semi": true 15 | }, 16 | "devDependencies": { 17 | "ts-node": "*" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/glossary/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "resolveJsonModule": true, 4 | "allowJs": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/playground-examples/.gitignore: -------------------------------------------------------------------------------- 1 | # Handled by @oss-docs/sync 2 | copy/* 3 | !copy/en 4 | -------------------------------------------------------------------------------- /packages/playground-examples/.prettierignore: -------------------------------------------------------------------------------- 1 | # https://github.com/microsoft/TypeScript-Website/pull/698#discussion_r445111502 2 | copy/en/4-0/New TS Features/Unknown in Catch.ts 3 | copy/en/4-4/New TS Features/Use unknown for Catch Variables.ts -------------------------------------------------------------------------------- /packages/playground-examples/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "endOfLine": "lf", 3 | "semi": true, 4 | "singleQuote": false, 5 | "tabWidth": 2, 6 | "printWidth": 120, 7 | "trailingComma": "es5", 8 | "arrowParens": "avoid" 9 | } 10 | -------------------------------------------------------------------------------- /packages/playground-examples/copy/en/3-7/Fixits/Const to let.ts: -------------------------------------------------------------------------------- 1 | //// { "compiler": { }, "order": 1 } 2 | 3 | // New to 3.7 is the ability to quickly convert 4 | // a const variable to a let when the value 5 | // has been re-assigned. 6 | 7 | // You can try this by highlighting the below error 8 | // and choosing to run the quick-fix. 9 | 10 | const displayName = "Andrew"; 11 | 12 | displayName = "Andrea"; 13 | -------------------------------------------------------------------------------- /packages/playground-examples/copy/en/3-8/Syntax and Messaging/Export Modules From.ts: -------------------------------------------------------------------------------- 1 | //// { "compiler": { "ts": "3.8.3" } } 2 | // TypeScripts ability to re-export got closer to supporting 3 | // the additional cases available in ES2018 4 | // 5 | // JavaScript exports have the ability to elegantly 6 | // re-export a part of a dependency: 7 | 8 | export { ScriptTransformer } from "@jest/transform"; 9 | 10 | // When you wanted to export the full object, that 11 | // becomes a little more verbose in previous versions 12 | // of TypeScript: 13 | 14 | import * as console from "@jest/console"; 15 | import * as reporters from "@jest/reporters"; 16 | 17 | export { console, reporters }; 18 | 19 | // With 3.8, TypeScript supports more of the export 20 | // statement forms in the JavaScript specs, letting 21 | // you write a single line to re-export a module 22 | 23 | export * as jestConsole from "@jest/console"; 24 | export * as jestReporters from "@jest/reporters"; 25 | -------------------------------------------------------------------------------- /packages/playground-examples/copy/en/4-0/New Checks/Class Constructor Code Flow.ts: -------------------------------------------------------------------------------- 1 | //// { "compiler": { "ts": "4.0.2" } } 2 | 3 | // In 4.0, we use control flow analysis to 4 | // infer the potential type of a class property based on 5 | // what values are set during the constructor. 6 | 7 | class UserAccount { 8 | id; // Type is inferred as string | number 9 | constructor(isAdmin: boolean) { 10 | if (isAdmin) { 11 | this.id = "admin"; 12 | } else { 13 | this.id = 0; 14 | } 15 | } 16 | } 17 | 18 | // In previous versions of TypeScript, `id` would 19 | // have been classed as an `any`. 20 | -------------------------------------------------------------------------------- /packages/playground-examples/copy/en/4-0/New JS Features/JSDoc Deprecated.ts: -------------------------------------------------------------------------------- 1 | // In 4.0 the JSDoc tag @deprecated is added to the 2 | // type system. You can use @deprecated anywhere 3 | // you can use JSDoc currently. 4 | 5 | interface AccountInfo { 6 | name: string; 7 | gender: string; 8 | 9 | /** @deprecated use gender field instead */ 10 | sex: "male" | "female"; 11 | } 12 | 13 | declare const userInfo: AccountInfo; 14 | userInfo.sex; 15 | 16 | // TypeScript will offer a non-blocking warning when a 17 | // deprecated property is accessed, and editors like 18 | // vscode will use show the deprecated info in places 19 | // like intellisense, outlines and in your code. 20 | -------------------------------------------------------------------------------- /packages/playground-examples/copy/en/4-1/New JS Features/See in JSDoc.ts: -------------------------------------------------------------------------------- 1 | //// { "compiler": { "ts": "4.1.0-beta" } } 2 | 3 | // With 4.1 the JSDoc parser in TypeScript 4 | // used in both JavaScript and TypeScript files 5 | // supports the @see parameter. 6 | 7 | // You can use the @see to help people quickly 8 | // jump to other related code via clicking 9 | // (cmd/ctrl + clicking) or getting hover info 10 | 11 | /** 12 | * @see hello 13 | */ 14 | const goodbye = "Good"; 15 | 16 | /** 17 | * You say hi, I say low 18 | * 19 | * @see goodbye 20 | */ 21 | const hello = "Hello, hello"; 22 | -------------------------------------------------------------------------------- /packages/playground-examples/copy/en/4-7/New TS Features/Instantiation Expressions.ts: -------------------------------------------------------------------------------- 1 | //// { "compiler": { "ts": "4.7.3" } } 2 | // Prior to TypeScript 4.7, you would have to do call a function 3 | // in order to narrow a generic type to something specific. For 4 | // example, let's take a Map object: 5 | 6 | const map = new Map(); 7 | // ^? 8 | 9 | // This map uses strings for keys, and numbers for values. Until 10 | // we created the map, the values for key (string) and value (number) 11 | // were yet to be defined and could still be anything. 12 | 13 | // Instantiation expressions means that we can create a version of the 14 | // Map function which will always accept only strings for keys and 15 | // numbers for values: 16 | 17 | const MapStrNum = Map; 18 | 19 | const map2 = new MapStrNum() 20 | // ^? 21 | 22 | // This feature allows us to elegantly create a more specific typed 23 | // functions without having to wrap the function in another function. -------------------------------------------------------------------------------- /packages/playground-examples/copy/en/JavaScript/Helping with JavaScript/Quick Fixes.ts: -------------------------------------------------------------------------------- 1 | // TypeScript provides quick-fix recommendations for 2 | // common accidents. Prompts show up in your editor based 3 | // on these recommendations. 4 | 5 | // For example TypeScript can provide quick-fixes 6 | // for typos in your types: 7 | 8 | const eulersNumber = 2.7182818284; 9 | eulersNumber.toStrang(); 10 | // ^______^ - select this to see the light bulb 11 | 12 | class ExampleClass { 13 | method() { 14 | this.notDeclared = 10; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/playground-examples/copy/en/JavaScript/README.md: -------------------------------------------------------------------------------- 1 | ## JavaScript Examples 2 | 3 | These examples are to cover the how TypeScript handles JavaScript. They 4 | can use TypeScript features lightly, but the focus should be to show people 5 | how they can re-use their JavaScript knowledge in TypeScript. 6 | -------------------------------------------------------------------------------- /packages/playground-examples/copy/en/Playground/Language/Fixits.ts: -------------------------------------------------------------------------------- 1 | //// { "compiler": { }, "order": 1 } 2 | 3 | // TypeScript supports a lot of fixits, which are automated 4 | // helpers to refactor your code. For example if you select 5 | // the text in line 7, and click on the light bulb which 6 | // pops up, you'll get offered some fixits. 7 | 8 | function addOne(x: number) { 9 | return x + 1; 10 | } 11 | 12 | // This feature is available as of TypeScript version 3.7, 13 | // which will also include nightly builds. 14 | 15 | // They might not be something you need to use inside the 16 | // playground when you're making code samples, or learning. 17 | 18 | // However, having fixits available means we can document 19 | // them in the playground and that's really valuable: 20 | 21 | // example:big-number-literals 22 | // example:const-to-let 23 | // example:infer-from-usage-changes 24 | -------------------------------------------------------------------------------- /packages/playground-examples/copy/en/Playground/Tooling/Mobile Support.ts: -------------------------------------------------------------------------------- 1 | //// { "order": 99 } 2 | 3 | // Tiny devices may not be very good for writing code, but 4 | // they are good for reading our examples, or giving 5 | // someone's link a quick review and making some minor 6 | // edits. 7 | 8 | // With the new Playground, we've improved the small screen 9 | // experience by: 10 | 11 | // - Removing menu items which aren't related to code. 12 | // - Some minor style improvements. 13 | // - Switch to a single pane editor. This means you 14 | // can't see the transpiled JS. 15 | 16 | // This should make the experience less painful. 17 | -------------------------------------------------------------------------------- /packages/playground-examples/copy/en/TypeScript/README.md: -------------------------------------------------------------------------------- 1 | ## TypeScript Examples 2 | 3 | These examples are to cover the how TypeScript extends JavaScript. 4 | 5 | An example should be based on a single feature or concept in TypeScript, 6 | and provide a few angles in which you can look and play with that feature. 7 | -------------------------------------------------------------------------------- /packages/playground-examples/generated/.gitignore: -------------------------------------------------------------------------------- 1 | *.json 2 | -------------------------------------------------------------------------------- /packages/playground-examples/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "playground-examples", 3 | "private": true, 4 | "license": "MIT", 5 | "version": "1.0.0", 6 | "scripts": { 7 | "bootstrap": "pnpm build", 8 | "build": "node scripts/generateTOC.js && node scripts/copyFiles.js" 9 | }, 10 | "devDependencies": { 11 | "@types/fs-extra": "^11.0.4", 12 | "fs-extra": "^11.2.0", 13 | "json5": "^2.2.3" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/playground-examples/scripts/copyFiles.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 3 | const { execSync } = require("child_process"); 4 | const { existsSync } = require("fs"); 5 | const { join, extname } = require("path"); 6 | const fse = require("fs-extra"); 7 | 8 | const copyDir = join(__dirname, "..", "copy"); 9 | const jsonDir = join(__dirname, "..", "generated"); 10 | const outDir = join(__dirname, "..", "..", "typescriptlang-org", "static", "js", "examples"); 11 | 12 | if (!existsSync(outDir)) execSync(`mkdir ${outDir}`); 13 | 14 | // Move samples 15 | fse.copySync(copyDir, outDir); 16 | 17 | /** 18 | * Filter logic, will be included if return true. However, we must skip the source dir as stated on 19 | * https://github.com/jprichardson/node-fs-extra/issues/741#issuecomment-579629747 20 | */ 21 | 22 | const filterFunc = src => { 23 | return src === jsonDir || extname(src) === ".json"; 24 | }; 25 | 26 | // Move the JSON files which are generated 27 | fse.copySync(jsonDir, outDir, { filter: filterFunc }); 28 | -------------------------------------------------------------------------------- /packages/playground-handbook/.gitignore: -------------------------------------------------------------------------------- 1 | output/* -------------------------------------------------------------------------------- /packages/playground-handbook/README.md: -------------------------------------------------------------------------------- 1 | ### Playground Handbook 2 | 3 | This package is structured similar to the main documentation section of the repo, and handles the content for the Playground documentation. 4 | -------------------------------------------------------------------------------- /packages/playground-handbook/copy/en/Localization.md: -------------------------------------------------------------------------------- 1 | ## Localization 2 | 3 | Like the rest of this website, the TypeScript Playground is localized. As of 2021, the current list of supported languages are: 4 | 5 | - [`es`](/es/play) 6 | - [`fr`](/fr/play) 7 | - [`id`](/id/play) 8 | - [`ja`](/ja/play) 9 | - [`ko`](/ko/play) 10 | - [`pt`](/pt/play) 11 | - [`vo`](/vo/play) 12 | - [`zh`](/zh/play) 13 | 14 | Ideally this helps folks for whom English is a second language! 15 | -------------------------------------------------------------------------------- /packages/playground-handbook/copy/en/Writing DTS Files.md: -------------------------------------------------------------------------------- 1 | ## Writing `.d.ts` Files 2 | 3 | Those of us who have been doing TypeScript for a while will know that feeling when you first realise that you may have wrote a lot of TypeScript in a `.ts` file - but you find yourself having to start looking things up again when you are in a `.d.ts` file. 4 | 5 | There are _a lot_ of similarities between a `.ts` file, but the rules are often subtly different in a `.d.ts` files and having a place where you can share and debug `.d.ts` files becomes extremely useful then. 6 | 7 | The `.d.ts` mode can be turned on by changing the language to "TypeScript Definition" inside the "TS Config" panel. 8 | -------------------------------------------------------------------------------- /packages/playground-handbook/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@typescript/playground-handbook", 3 | "version": "0.0.1", 4 | "license": "MIT", 5 | "private": true, 6 | "scripts": { 7 | "build": "node scripts/generateJSON.mjs" 8 | }, 9 | "devDependencies": { 10 | "typescript": "*" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/playground-worker/README.md: -------------------------------------------------------------------------------- 1 | ### The Playground Worker 2 | 3 | This is a WebWorker function which the Playground uses to wrap the TypeScript Language Service. You can learn about how this works in this PR to monaco-typescript: https://github.com/microsoft/monaco-typescript/pull/65 4 | 5 | The worker is a factory function which returns a subclass for the TSServer to monaco language bindings, this subclass takes into account the `// @filename: abc.ts` syntax which is used all over the place in TypeScript code. 6 | 7 | The code is well commented, so better to just go read that to learn more: [`index.ts`](./index.ts). 8 | -------------------------------------------------------------------------------- /packages/playground-worker/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@typescript/playground-worker", 3 | "version": "0.1.0", 4 | "license": "MIT", 5 | "private": true, 6 | "scripts": { 7 | "build": "esbuild index.ts --outdir=../typescriptlang-org/static/js/playground-worker --format=esm --target=es2020 --bundle" 8 | }, 9 | "dependencies": { 10 | "esbuild": "^0.17.8" 11 | }, 12 | "devDependencies": { 13 | "typescript": "*" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/playground-worker/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": ["index.ts", "index.test.ts"], 3 | "compilerOptions": { 4 | "strict": true, 5 | "target": "ES2020", 6 | "allowJs": false, 7 | "module": "esnext", 8 | "moduleResolution": "node" 9 | } 10 | } -------------------------------------------------------------------------------- /packages/playground/.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | .DS_Store 3 | node_modules 4 | .cache 5 | .rts2_cache_cjs 6 | .rts2_cache_esm 7 | .rts2_cache_umd 8 | dist 9 | output 10 | -------------------------------------------------------------------------------- /packages/playground/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@typescript/playground", 3 | "version": "0.1.2", 4 | "main": "dist/index.js", 5 | "license": "MIT", 6 | "private": true, 7 | "types": "../../typescriptlang-org/static/js/playground/index.d.ts", 8 | "files": [ 9 | "dist" 10 | ], 11 | "scripts": { 12 | "//bootstrap": "node scripts/getListOfPluginsFromNPM.js", 13 | "build-fast-test": "esbuild src/index.ts --outdir=../typescriptlang-org/static/js/playground/2 --format=esm --target=es2020 --bundle", 14 | "build": "tsc", 15 | "test": "jest" 16 | }, 17 | "dependencies": { 18 | "@typescript/playground-worker": "workspace:*", 19 | "@typescript/sandbox": "workspace:*", 20 | "esbuild": "^0.17.8" 21 | }, 22 | "devDependencies": { 23 | "@types/jest": "^29.5.12", 24 | "@types/react": "^18.3.2", 25 | "jest": "^29.5.0", 26 | "monaco-editor": "^0.32.1", 27 | "monaco-typescript": "^3.7.0", 28 | "typescript": "*" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/playground/src/ambient.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'vfile-message' { 2 | export interface VFileMessage {} 3 | } 4 | -------------------------------------------------------------------------------- /packages/playground/src/localizeWithFallback.ts: -------------------------------------------------------------------------------- 1 | /** contains the ts-ignore, and the global window manipulation */ 2 | export const localize = (key: string, fallback: string) => 3 | // @ts-ignore 4 | '__tsLocalize' in window ? window.__tsLocalize(key) : fallback 5 | -------------------------------------------------------------------------------- /packages/playground/src/sidebar/showDTS.ts: -------------------------------------------------------------------------------- 1 | import { PlaygroundPlugin, PluginFactory } from ".." 2 | 3 | export const showDTSPlugin: PluginFactory = (i, utils) => { 4 | let codeElement: HTMLElement 5 | 6 | const plugin: PlaygroundPlugin = { 7 | id: "dts", 8 | displayName: i("play_sidebar_dts"), 9 | willMount: (_, container) => { 10 | const { code } = utils.createDesignSystem(container) 11 | codeElement = code("") 12 | }, 13 | modelChanged: (sandbox, model) => { 14 | sandbox.getDTSForCode().then(dts => { 15 | sandbox.monaco.editor.colorize(dts, "typescript", {}).then(coloredDTS => { 16 | codeElement.innerHTML = coloredDTS 17 | }) 18 | }) 19 | }, 20 | } 21 | 22 | return plugin 23 | } 24 | -------------------------------------------------------------------------------- /packages/playground/src/sidebar/showJS.ts: -------------------------------------------------------------------------------- 1 | import { PlaygroundPlugin, PluginFactory } from ".." 2 | 3 | export const compiledJSPlugin: PluginFactory = (i, utils) => { 4 | let codeElement: HTMLElement 5 | 6 | const plugin: PlaygroundPlugin = { 7 | id: "js", 8 | displayName: i("play_sidebar_js"), 9 | willMount: (_, container) => { 10 | const { code } = utils.createDesignSystem(container) 11 | codeElement = code("") 12 | }, 13 | modelChangedDebounce: (sandbox, model) => { 14 | sandbox.getRunnableJS().then(js => { 15 | sandbox.monaco.editor.colorize(js, "javascript", {}).then(coloredJS => { 16 | codeElement.innerHTML = coloredJS 17 | }) 18 | }) 19 | }, 20 | } 21 | 22 | return plugin 23 | } 24 | -------------------------------------------------------------------------------- /packages/playground/src/theme.ts: -------------------------------------------------------------------------------- 1 | export const setEditorTheme = (theme: 'light' | 'dark' | 'hc', editor: typeof import('monaco-editor').editor) => { 2 | const newTheme = theme ? theme : localStorage ? localStorage.getItem('editor-theme') || 'light' : 'light' 3 | 4 | editor.setTheme(newTheme) 5 | 6 | document 7 | .querySelectorAll('a[id^=theme-]') 8 | .forEach(anchor => 9 | anchor.id === `theme-${newTheme}` 10 | ? anchor.classList.add('current-theme') 11 | : anchor.classList.remove('current-theme') 12 | ) 13 | 14 | localStorage.setItem('editor-theme', newTheme) 15 | 16 | // Sets the theme on the body so CSS can change between themes 17 | document.body.classList.remove('light', 'dark', 'hc') 18 | 19 | // So dark and dark-hc can share CSS 20 | if (newTheme === 'dark-hc') { 21 | document.body.classList.add('dark') 22 | document.body.classList.add('hc') 23 | } else { 24 | document.body.classList.add(newTheme) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /packages/playground/test/typeAcquisition.test.tsx: -------------------------------------------------------------------------------- 1 | 2 | 3 | describe('it', () => { 4 | it('renders without crashing', () => { 5 | }); 6 | }); 7 | -------------------------------------------------------------------------------- /packages/playground/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["src"], 3 | "compilerOptions": { 4 | "outDir": "../typescriptlang-org/static/js/playground", 5 | "jsx": "react", 6 | "target": "ES2016", 7 | "module": "AMD", 8 | "lib": ["dom", "esnext"], 9 | "declaration": true, 10 | "inlineSources": true, 11 | "inlineSourceMap": true, 12 | "rootDir": "./src", 13 | "strict": true, 14 | "moduleResolution": "node", 15 | "esModuleInterop": true, 16 | "skipLibCheck": true, 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/sandbox/.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | .DS_Store 3 | node_modules 4 | .cache 5 | .rts2_cache_cjs 6 | .rts2_cache_esm 7 | .rts2_cache_umd 8 | dist 9 | src/vendor/typescript-vfs.ts 10 | src/vendor/ata 11 | -------------------------------------------------------------------------------- /packages/sandbox/dts.config.js: -------------------------------------------------------------------------------- 1 | const commonjs = require("@rollup/plugin-commonjs"); 2 | 3 | // Modify the default tsdx rollup config 4 | module.exports = { 5 | rollup(config, options) { 6 | // Required to import lzstring 7 | config.plugins.push(commonjs()); 8 | 9 | return config; 10 | }, 11 | }; 12 | -------------------------------------------------------------------------------- /packages/sandbox/src/ambient.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'vfile-message' { 2 | export interface VFileMessage {} 3 | } 4 | -------------------------------------------------------------------------------- /packages/sandbox/src/createCompilerHost.ts: -------------------------------------------------------------------------------- 1 | // A single file version from 2 | // https://stackoverflow.com/questions/53733138/how-do-i-type-check-a-snippet-of-typescript-code-in-memory 3 | 4 | export function createCompilerHost(code: string, path: string) { 5 | const host: import('typescript').CompilerHost = { 6 | fileExists: filePath => filePath === path, 7 | directoryExists: dirPath => dirPath === '/', 8 | getCurrentDirectory: () => '/', 9 | getDirectories: () => [], 10 | getCanonicalFileName: fileName => fileName, 11 | getNewLine: () => '\n', 12 | getDefaultLibFileName: () => '', 13 | getSourceFile: _ => undefined, 14 | readFile: filePath => (filePath === path ? code : undefined), 15 | useCaseSensitiveFileNames: () => true, 16 | writeFile: () => {}, 17 | } 18 | 19 | return host 20 | } 21 | -------------------------------------------------------------------------------- /packages/sandbox/src/monacoTSVersions.ts: -------------------------------------------------------------------------------- 1 | import { supportedReleases, ReleaseVersions } from './release_data' 2 | 3 | /** The versions you can get for the sandbox */ 4 | export type SupportedTSVersions = ReleaseVersions | 'Latest' 5 | 6 | /** 7 | * The versions of monaco-typescript which we can use 8 | * for backwards compatibility with older versions 9 | * of TS in the playground. 10 | */ 11 | export const monacoTSVersions: SupportedTSVersions[] = [...supportedReleases, 'Latest'] 12 | 13 | /** Returns the latest TypeScript version supported by the sandbox */ 14 | export const latestSupportedTypeScriptVersion: string = Object.keys(monacoTSVersions) 15 | .filter(key => key !== 'Nightly' && !key.includes('-')) 16 | .sort() 17 | .pop()! 18 | -------------------------------------------------------------------------------- /packages/sandbox/src/vendor/lzstring.min.d.ts: -------------------------------------------------------------------------------- 1 | export function compressToBase64(input: string): string 2 | export function decompressFromBase64(input: string): string 3 | 4 | export function compressToUTF16(input: string): string 5 | export function decompressFromUTF16(compressed: string): string 6 | 7 | export function compressToUint8Array(uncompressed: string): Uint8Array 8 | export function decompressFromUint8Array(compressed: Uint8Array): string 9 | 10 | export function compressToEncodedURIComponent(input: string): string 11 | export function decompressFromEncodedURIComponent(compressed: string): string 12 | 13 | export function compress(input: string): string 14 | export function decompress(compressed: string): string 15 | -------------------------------------------------------------------------------- /packages/sandbox/test/typeAcquisition.test.tsx: -------------------------------------------------------------------------------- 1 | 2 | 3 | describe('it', () => { 4 | it('renders without crashing', () => { 5 | }); 6 | }); 7 | -------------------------------------------------------------------------------- /packages/sandbox/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["src", "src/vendor/lzstring.min.js"], 3 | 4 | "compilerOptions": { 5 | "outDir": "../typescriptlang-org/static/js/sandbox", 6 | "target": "ES2016", 7 | "module": "AMD", 8 | "lib": ["DOM", "esnext"], 9 | "declaration": true, 10 | "inlineSources": true, 11 | "inlineSourceMap": true, 12 | "rootDir": "./src", 13 | "strict": true, 14 | "allowJs": true, 15 | "moduleResolution": "node", 16 | "esModuleInterop": true, 17 | "skipLibCheck": true 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/sandbox/tsconfig.lib.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./dist", 5 | "module": "esnext", 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | .DS_Store 3 | node_modules 4 | .rts2_cache_cjs 5 | .rts2_cache_esm 6 | .rts2_cache_umd 7 | .rts2_cache_system 8 | dist 9 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ### How to make a change in Twoslash 2 | 3 | It's likely you have a failing twoslash test case, copy that into `test/fixtures/tests/[name].ts` and run 4 | 5 | > `pnpm run --filter=@typescript/twoslash test` 6 | 7 | This will create a Jest snapshot of that test run which you can use as an integration test to ensure your change doesn't get regressed. 8 | 9 | ### Other complex code 10 | 11 | It's a normal Jest project where you can also make unit tests like `test/cutting.test.ts`. 12 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/.prettierignore: -------------------------------------------------------------------------------- 1 | fixtures/**/*.ts 2 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/README.md: -------------------------------------------------------------------------------- 1 | ### Testing 2 | 3 | There are two types of tests: 4 | 5 | - Units which are Jest tests, and not unique to this project 6 | 7 | - Integration tests where you place a fixture code sample in the right folder and get a response JSON result. There are three folders for tests: 8 | - `test/fixtures` - Any test in this file is shown in the README, so they should showcase features - not bugs 9 | - `tests/fixtures/throws` - A test which should correctly raise 10 | - `tests/fixtures/tests` - All other tests, repros etc 11 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/compiler_options.test.ts: -------------------------------------------------------------------------------- 1 | import { twoslasher } from "../src/index" 2 | import { ModuleKind } from "typescript" 3 | 4 | it("emits CommonJS", () => { 5 | const files = ` 6 | // @filename: file-with-export.ts 7 | export const helloWorld = "Example string"; 8 | 9 | // @filename: index.ts 10 | import {helloWorld} from "./file-with-export" 11 | console.log(helloWorld) 12 | ` 13 | const result = twoslasher(files, "ts", { 14 | defaultOptions: { showEmit: true }, 15 | defaultCompilerOptions: { module: ModuleKind.CommonJS } 16 | }) 17 | expect(result.errors).toEqual([]) 18 | expect(result.code!).toContain('require("./file-with-export")') 19 | }) 20 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/compiler_errors.ts: -------------------------------------------------------------------------------- 1 | // @target: ES2015 2 | // @errors: 7006 3 | 4 | function fn(s) { 5 | console.log(s.subtr(3)) 6 | } 7 | 8 | fn(42) 9 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/compiler_flags.ts: -------------------------------------------------------------------------------- 1 | // @noImplicitAny: false 2 | // @target: ES2015 3 | 4 | // This will not throw because of the noImplicitAny 5 | function fn(s) { 6 | console.log(s.subtr(3)) 7 | } 8 | 9 | fn(42); 10 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/completions.ts: -------------------------------------------------------------------------------- 1 | console.log 2 | // ^| 3 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/cuts_out_unnecessary_code.ts: -------------------------------------------------------------------------------- 1 | interface IdLabel { id: number, /* some fields */ } 2 | interface NameLabel { name: string, /* other fields */ } 3 | type NameOrId = T extends number ? IdLabel : NameLabel; 4 | // This comment should not be included 5 | 6 | // ---cut--- 7 | function createLabel(idOrName: T): NameOrId { 8 | throw "unimplemented" 9 | } 10 | 11 | let a = createLabel("typescript"); 12 | // ^? 13 | 14 | let b = createLabel(2.8); 15 | // ^? 16 | 17 | let c = createLabel(Math.random() ? "hello" : 42); 18 | // ^? 19 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/declarations.ts: -------------------------------------------------------------------------------- 1 | // @declaration: true 2 | // @showEmit 3 | // @showEmittedFile: index.d.ts 4 | 5 | /** 6 | * Gets the length of a string 7 | * @param value a string 8 | */ 9 | export function getStringLength(value: string) { 10 | return value.length 11 | } 12 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/errorsWithGenerics.ts: -------------------------------------------------------------------------------- 1 | // @errors: 2322 2 | const a: Record = {} 3 | let b: Record = {} 4 | b = a 5 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/highlighting.ts: -------------------------------------------------------------------------------- 1 | function greet(person: string, date: Date) { 2 | console.log(`Hello ${person}, today is ${date.toDateString()}!`); 3 | } 4 | 5 | greet("Maddison", new Date()); 6 | // ^^^^^^^^^^ 7 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/import_files.ts: -------------------------------------------------------------------------------- 1 | // @filename: file-with-export.ts 2 | export const helloWorld = "Example string"; 3 | 4 | // @filename: index.ts 5 | import {helloWorld} from "./file-with-export" 6 | console.log(helloWorld) 7 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/importsModules.ts: -------------------------------------------------------------------------------- 1 | // @filename: Component.tsx 2 | import React from "react" 3 | 4 | export function Hello() { 5 | return ( 6 |
7 |

Hello World

8 |
9 | ) 10 | } 11 | 12 | // @filename: index.ts 13 | import { Hello } from "./Component" 14 | console.log(Hello) 15 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/multiFileErrors.ts: -------------------------------------------------------------------------------- 1 | // @filename: sum.ts 2 | export function sum(a: number, b: number): number { 3 | return a + b 4 | } 5 | 6 | // @filename: ok.ts 7 | import { sum } from "./sum" 8 | sum(1, 2) 9 | 10 | // @filename: error.ts 11 | // @errors: 2345 12 | import { sum } from "./sum" 13 | sum(4, "woops") 14 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/query.ts: -------------------------------------------------------------------------------- 1 | let foo = "hello there!"; 2 | // ^? 3 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/showEmit.ts: -------------------------------------------------------------------------------- 1 | // @showEmit 2 | // @target: ES5 3 | // @downleveliteration 4 | 5 | // --importHelpers on: Spread helper will be imported from 'tslib' 6 | 7 | export function fn(arr: number[]) { 8 | const arr2 = [1, ...arr] 9 | } 10 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/tests/arbitraryCommands.ts: -------------------------------------------------------------------------------- 1 | // The testing infra has set up `annotate` to be a customTag 2 | 3 | // @annotate - left - You can use JSDoc comments to provide type information to your editor 4 | function compact(arr: string[]) { 5 | if (arr.length > 10) return arr.length 6 | // @annotate - right - You can use JSDoc comments to provide type information to your editor 7 | return arr 8 | } 9 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/tests/crossExports.ts: -------------------------------------------------------------------------------- 1 | // @filename: utilFunctions.js 2 | const getStringLength = str => str.length 3 | module.exports = { 4 | getStringLength, 5 | } 6 | 7 | // @filename: index.ts 8 | import utils from './utilFunctions' 9 | const count = utils.getStringLength('Check JS') 10 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/tests/cut_files.ts: -------------------------------------------------------------------------------- 1 | // Hello should not appear in the staticQuickInfos 2 | const hello = 'world' 3 | // ---cut--- 4 | const bye = 'globe' 5 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/tests/emittedOutFile.ts: -------------------------------------------------------------------------------- 1 | // @filename: projectRoot/index.ts 2 | export * from "./nested/base" 3 | 4 | // @filename: projectRoot/nested/base.ts 5 | export const a = "123" 6 | 7 | // @module: amd 8 | // @outfile: index.js 9 | // @declaration: true 10 | // @showEmit 11 | // @showEmittedFile: index.d.ts 12 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/tests/handlesJSON.ts: -------------------------------------------------------------------------------- 1 | // @errors: 2367 2 | // @resolveJsonModule 3 | // @module: commonjs 4 | // @moduleResolution: node 5 | // @filename: settings.json 6 | { 7 | "repo": "TypeScript", 8 | "dry": false, 9 | "debug": false 10 | } 11 | // @filename: index.ts 12 | import settings from "./settings.json"; 13 | 14 | settings.debug === true; 15 | settings.dry === 2; 16 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/tests/hidden_emit.ts: -------------------------------------------------------------------------------- 1 | // @showEmit 2 | // @removeComments: true 3 | /** The translation of 'Hello world' into Portuguese */ 4 | export declare const helloWorldPTBR = 'Olá Mundo' 5 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/tests/inlineHighlights.ts: -------------------------------------------------------------------------------- 1 | type Result = "pass" | "fail" 2 | // ^^^^^^ 3 | 4 | const hello = "OK" 5 | // ^^ Sure 6 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/tests/jsx.ts: -------------------------------------------------------------------------------- 1 | // @filename: index.tsx 2 | // This doesn't work! 3 | declare module JSX { 4 | interface Element {} 5 | interface IntrinsicElements { 6 | [s: string]: any 7 | } 8 | } 9 | // @showEmit 10 | // @noErrors 11 | // @jsx: preserve 12 | export const helloWorld = () =>

Hello world

13 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/tests/lib.ts: -------------------------------------------------------------------------------- 1 | // @lib: es2015 2 | const map = new Map>() 3 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/tests/multiLookups.ts: -------------------------------------------------------------------------------- 1 | interface Shape {} 2 | declare function getShape(): Shape 3 | 4 | // TODO: Feel up for a challenge, remove the extra comments 5 | // below to get a raised exception from TS 6 | 7 | interface PaintOptions { 8 | shape: Shape 9 | xPos?: number 10 | // // ^ 11 | yPos?: number 12 | // // ^ 13 | } 14 | 15 | // ---cut--- 16 | function paintShape(opts: PaintOptions) { 17 | let xPos = opts.xPos 18 | // ^? 19 | let yPos = opts.yPos 20 | // ^? 21 | // ... 22 | } 23 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/tests/preact.tsx: -------------------------------------------------------------------------------- 1 | // @module: commonjs 2 | // @jsx: react-jsx 3 | // @target: esnext 4 | // @noErrors 5 | 6 | /** @jsxImportSource preact */ 7 | function App() { 8 | return

Hello World

9 | } 10 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/tests/queriesWithSpaceBefore.ts: -------------------------------------------------------------------------------- 1 | const a: string = "242342" 2 | const b = "hello" 3 | if (a === b) { 4 | // ^? 5 | } 6 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/tests/queryHandlesNoToken.ts: -------------------------------------------------------------------------------- 1 | type Either2dOr3d = [number, number, number?] 2 | 3 | function setCoordinate(coord: Either2dOr3d) { 4 | const [x, y, z] = coord 5 | // ^? 6 | 7 | console.log(`Provided coordinates had ${coord.length} dimensions`) 8 | // ^? 9 | } 10 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/tests/removePrettierIgnore.ts: -------------------------------------------------------------------------------- 1 | const myThing = {} 2 | 3 | // prettier-ignore 4 | const anotherThing = {} 5 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/tests/showEmit.ts: -------------------------------------------------------------------------------- 1 | // @experimentalDecorators 2 | // @showEmit 3 | // @showEmittedFile: component.js 4 | 5 | // @filename: service.ts 6 | export class Service {} 7 | 8 | // @filename: component.ts 9 | import type { Service } from "./service" 10 | 11 | declare var decorator: any 12 | 13 | @decorator 14 | class MyComponent { 15 | constructor(public Service: Service) {} 16 | 17 | @decorator 18 | method(x: this) {} 19 | } 20 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/tests/showJS.ts: -------------------------------------------------------------------------------- 1 | // @showEmit 2 | // @removeComments: true 3 | /** The translation of 'Hello world' into Portuguese */ 4 | export const helloWorldPTBR = 'Olá Mundo' 5 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/tests/tsx.ts: -------------------------------------------------------------------------------- 1 | // @filename: index.tsx 2 | // This doesn't work! 3 | declare module JSX { 4 | interface Element {} 5 | interface IntrinsicElements { 6 | [s: string]: any 7 | } 8 | } 9 | // @showEmit 10 | // @noErrors 11 | // @jsx: preserve 12 | export const helloWorld = () =>

Hello world

13 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/tests/twoliner.ts: -------------------------------------------------------------------------------- 1 | // @filename: getStringLength.ts 2 | export const getStringLength = (str: string) => str.length 3 | // @filename: index.ts 4 | import { getStringLength } from './getStringLength' 5 | const b = getStringLength('string') 6 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/throws/multifile_errors.ts: -------------------------------------------------------------------------------- 1 | // @filename: file-one.ts 2 | consol...log 3 | 4 | // @filename: other export.ts 5 | consol...err 6 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/throws/unexpected_errors.ts: -------------------------------------------------------------------------------- 1 | // @target: ES2015 2 | 3 | // Because this example doesn't have an errors 4 | // reference it will throw 5 | 6 | const myVariable = "" 7 | myVariable = 1 8 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/throws/unknown_compiler_error.ts: -------------------------------------------------------------------------------- 1 | // @targets: ES2015 2 | 3 | // Because this example refers to something 4 | // which is neither in the settings, nor 5 | // a compiler flag. The render process will 6 | // throw an error 7 | 8 | export const variable = "NOT OK" 9 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/throws/unknown_compiler_value.ts: -------------------------------------------------------------------------------- 1 | // @target: TS2015 2 | 3 | // Because this example refers to TS2015 4 | // not ES2015 the function with throw 5 | 6 | export const variable = "NOT OK" 7 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/fixtures/throws/unknown_extension.herjk: -------------------------------------------------------------------------------- 1 | // Should throw 2 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/highlights.test.ts: -------------------------------------------------------------------------------- 1 | import { twoslasher } from "../src/index" 2 | 3 | it("supports highlighting something", () => { 4 | const file = ` 5 | const a = "123" 6 | // ^^^^^^^^^ 7 | const b = "345" 8 | ` 9 | const result = twoslasher(file, "ts") 10 | expect(result.highlights.length).toEqual(1) 11 | }) 12 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/modules.test.ts: -------------------------------------------------------------------------------- 1 | import { twoslasher } from "../src/index" 2 | import { createDefaultMapFromNodeModules } from "@typescript/vfs" 3 | 4 | const dt = ` 5 | declare namespace G { 6 | function hasMagic(pattern: string, options?: IOptions): boolean; 7 | } 8 | export = G; 9 | ` 10 | 11 | it("works with a dependency in @types for the project", () => { 12 | const fsMap = createDefaultMapFromNodeModules({}) 13 | fsMap.set("/node_modules/@types/glob/index.d.ts", dt) 14 | 15 | const file = ` 16 | import glob from "glob" 17 | glob.hasMagic("OK") 18 | // ^? 19 | ` 20 | const result = twoslasher(file, "ts", { fsMap }) 21 | expect(result.errors).toEqual([]) 22 | expect(result.queries[0].text!.includes("hasMagic")).toBeTruthy() 23 | }) 24 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/results/declarations.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": "/**\n * Gets the length of a string\n * @param value a string\n */\nexport declare function getStringLength(value: string): number;\n", 3 | "extension": "ts", 4 | "highlights": [], 5 | "queries": [], 6 | "staticQuickInfos": [], 7 | "errors": [], 8 | "playgroundURL": "https://www.typescriptlang.org/play/#code/PTAEAEBMFMGMBsCGAnRAXAlgewHYC5Q1kBXaAKBAgGcALLAdwFEBbDNCscWhlttaSADEM8aAQw4YADwB0kGWipkKAKhVlQK0AHFoiwjWihROAOZoaoLADNQiUFSITTGreAAOKRM1AA3RPCkdg5OZq7AZNBS7ljIaKDWxDiwmLigpnoAyqGmADLQZhYAFP6BYiHIzgCUoADeGqDIesTIOH4BpDIm5jRkAL5kQA", 9 | "tags": [] 10 | } 11 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/results/multifile_errors.json: -------------------------------------------------------------------------------- 1 | 2 | ## Errors were thrown in the sample, but not included in an errors tag 3 | 4 | These errors were not marked as being expected: 2552 2304 1434 1128. 5 | Expected: // @errors: 2552 2304 1434 1128 6 | 7 | Compiler Errors: 8 | 9 | file-one.ts 10 | [2552] 0 - Cannot find name 'consol'. Did you mean 'console'? 11 | [2304] 9 - Cannot find name 'log'. 12 | [1434] 0 - Unexpected keyword or identifier. 13 | [1128] 6 - Declaration or statement expected. 14 | 15 | other export.ts 16 | [2552] 0 - Cannot find name 'consol'. Did you mean 'console'? 17 | [2304] 9 - Cannot find name 'err'. 18 | [1434] 0 - Unexpected keyword or identifier. 19 | [1128] 6 - Declaration or statement expected. -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/results/query.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": "let foo = \"hello there!\";\n", 3 | "extension": "ts", 4 | "highlights": [], 5 | "queries": [ 6 | { 7 | "docs": "", 8 | "kind": "query", 9 | "start": 4, 10 | "length": 15, 11 | "text": "let foo: string", 12 | "offset": 4, 13 | "line": 1 14 | } 15 | ], 16 | "staticQuickInfos": [ 17 | { 18 | "text": "let foo: string", 19 | "docs": "", 20 | "start": 4, 21 | "length": 3, 22 | "line": 0, 23 | "character": 4, 24 | "targetString": "foo" 25 | } 26 | ], 27 | "errors": [], 28 | "playgroundURL": "https://www.typescriptlang.org/play/#code/DYUwLgBAZg9jEF4ICIAWJjHmdAnEAhMgNwBQA9ORBAHoD8pQA", 29 | "tags": [] 30 | } 31 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/results/tests/cut_files.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": "const bye = 'globe'\n", 3 | "extension": "ts", 4 | "highlights": [], 5 | "queries": [], 6 | "staticQuickInfos": [ 7 | { 8 | "text": "const bye: \"globe\"", 9 | "docs": "", 10 | "start": 6, 11 | "length": 3, 12 | "line": 0, 13 | "character": 6, 14 | "targetString": "bye" 15 | } 16 | ], 17 | "errors": [], 18 | "playgroundURL": "https://www.typescriptlang.org/play/#code/PTAEAkFMBtoe1AZwBZwK7QCagHZwC6gCGADiZEQE6gCWOo+ykS+R+NAxgIpqcDWASRwAzOIgBQHODkSEmsBAF5QAcgDucSlhXiQoALSGOafIf2Tps0ACMAns2UqA5vGuQdQA", 19 | "tags": [] 20 | } 21 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/results/tests/emittedOutFile.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": "declare module \"nested/base\" {\n export const a = \"123\";\n}\ndeclare module \"index\" {\n export * from \"nested/base\";\n}\n", 3 | "extension": "ts", 4 | "highlights": [], 5 | "queries": [], 6 | "staticQuickInfos": [], 7 | "errors": [], 8 | "playgroundURL": "https://www.typescriptlang.org/play/#code/PTAEAEDMEsBsFMB2BDAtvAXKADgJwPYBW8AxgC4BK++Zw0iAJvAB4B0ZAzgFAvb65lQAKlCQCqUACJWwRPA5l4DYACNkHeJK5cQEGAhToseIqUrVachUtXr47br36CS+RAtDJQAXikBGACYAZi0dMHBUfAYAVwQsNAYwiHxosn1MUHomNkJuXXAmElhkXGQyaDcsMlxo+CTwDgALfAB3AFFUaDJ6ptaOrsUGADE4DKyWVgYHLiA", 9 | "tags": [] 10 | } 11 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/results/tests/hidden_emit.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": "export {};\n", 3 | "extension": "js", 4 | "highlights": [], 5 | "queries": [], 6 | "staticQuickInfos": [], 7 | "errors": [], 8 | "playgroundURL": "https://www.typescriptlang.org/play/#code/PTAEAEGcAsHsHcCiBbAlgFwFAggJwKbKwBu+AwrMsvgHbqQBco6uArvtgFSegAq0+ZrgCGNSABth6VLBqhYAM1AByABL5x42KHixc4gCbLQqOtoAKe9KwDm7SIM7BM+AB4AHK6AP4AxpIJQX1lIdFABTVgAdT1Dc14AIQAlUABeFQB5cQBD0ABZVhoDWGVMIA", 9 | "tags": [] 10 | } 11 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/results/tests/jsx.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": "export const helloWorld = () =>

Hello world

;\n", 3 | "extension": "jsx", 4 | "highlights": [], 5 | "queries": [], 6 | "staticQuickInfos": [], 7 | "errors": [], 8 | "playgroundURL": "https://www.typescriptlang.org/play/#code/PTAEAEDMEsBsFMB2BDAtvAXKaiAm8APAOgBcBnAgKBFABUALaM0XAe3jMQHITQB3VgCcA1gEJK+AMaxkg+KFStcAVwSgAUgGUAGqADelUNkQl4gyMknyAognQn9AX0PHT5y-ICSJwTjLRJW3h7cn0XIwBtMiwyEl9EAHMAXSxkRABPF2dnGnAyelY+a1RoEmowcERWa0FBITJyiAArCiwABzkyMwA3eEpCNqFeSVZEWNB6eFhYVgB1IVhcUABeUAAKAEoVgD5QAB56AEZtgAkpmf4F3D3gI+3KIA", 9 | "tags": [] 10 | } 11 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/results/tests/removePrettierIgnore.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": "const myThing = {}\n\nconst anotherThing = {}\n", 3 | "extension": "ts", 4 | "highlights": [], 5 | "queries": [], 6 | "staticQuickInfos": [ 7 | { 8 | "text": "const myThing: {}", 9 | "docs": "", 10 | "start": 6, 11 | "length": 7, 12 | "line": 0, 13 | "character": 6, 14 | "targetString": "myThing" 15 | }, 16 | { 17 | "text": "const anotherThing: {}", 18 | "docs": "", 19 | "start": 26, 20 | "length": 12, 21 | "line": 2, 22 | "character": 6, 23 | "targetString": "anotherThing" 24 | } 25 | ], 26 | "errors": [], 27 | "playgroundURL": "https://www.typescriptlang.org/play/#code/MYewdgzgLgBAtgTwCoAsCWYDmMC8MDeAvgFDED0ZMADgE4CmUUadNAtGpmCPcaJLAEMuUFC1QZseIsSA", 28 | "tags": [] 29 | } 30 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/results/tests/showJS.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": "export const helloWorldPTBR = 'Olá Mundo';\n", 3 | "extension": "js", 4 | "highlights": [], 5 | "queries": [], 6 | "staticQuickInfos": [], 7 | "errors": [], 8 | "playgroundURL": "https://www.typescriptlang.org/play/#code/PTAEAEGcAsHsHcCiBbAlgFwFAggJwKbKwBu+AwrMsvgHbqQBco6uArvtgFSegAq0+ZrgCGNSABth6VLBqhYAM1AByABL5x42KHixc4gCbLQqOtoAKe9KwDm7SIM7BM+AB4AHK6ADGsyOlABTVgAdT1Dc14AIQAlUABeFQB5cQBD0ABZVhoDWGVMIA", 9 | "tags": [] 10 | } 11 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/results/tests/tsx.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": "export const helloWorld = () =>

Hello world

;\n", 3 | "extension": "jsx", 4 | "highlights": [], 5 | "queries": [], 6 | "staticQuickInfos": [], 7 | "errors": [], 8 | "playgroundURL": "https://www.typescriptlang.org/play/#code/PTAEAEDMEsBsFMB2BDAtvAXKaiAm8APAOgBcBnAgKBFABUALaM0XAe3jMQHITQB3VgCcA1gEJK+AMaxkg+KFStcAVwSgAUgGUAGqADelUNkQl4gyMknyAognQn9AX0PHT5y-ICSJwTjLRJW3h7cn0XIwBtMiwyEl9EAHMAXSxkRABPF2dnGnAyelY+a1RoEmowcERWa0FBITJyiAArCiwABzkyMwA3eEpCNqFeSVZEWNB6eFhYVgB1IVhcUABeUAAKAEoVgD5QAB56AEZtgAkpmf4F3D3gI+3KIA", 9 | "tags": [] 10 | } 11 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/results/unexpected_errors.json: -------------------------------------------------------------------------------- 1 | 2 | ## Errors were thrown in the sample, but not included in an errors tag 3 | 4 | These errors were not marked as being expected: 2588. 5 | Expected: // @errors: 2588 6 | 7 | Compiler Errors: 8 | 9 | index.ts 10 | [2588] 98 - Cannot assign to 'myVariable' because it is a constant. -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/results/unknown_compiler_error.json: -------------------------------------------------------------------------------- 1 | 2 | ## Invalid inline compiler flag 3 | 4 | There isn't a TypeScript compiler flag called 'targets'. 5 | 6 | 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. -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/results/unknown_compiler_value.json: -------------------------------------------------------------------------------- 1 | 2 | ## Invalid inline compiler value 3 | 4 | Got TS2015 for target but it is not a supported value by the TS compiler. 5 | 6 | Allowed values: es3,es5,es6,es2015,es2016,es2017,es2018,es2019,es2020,es2021,es2022,es2023,es2024,esnext -------------------------------------------------------------------------------- /packages/ts-twoslasher/test/results/unknown_extension.json: -------------------------------------------------------------------------------- 1 | 2 | ## Unknown TypeScript extension given to Twoslash 3 | 4 | Received herjk but Twoslash only accepts: js,javascript,ts,typescript,tsx,jsx,json,jsn 5 | -------------------------------------------------------------------------------- /packages/ts-twoslasher/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["src", "types", "test"], 3 | "exclude": ["test/fixtures"], 4 | "compilerOptions": { 5 | "target": "es5", 6 | "module": "esnext", 7 | "lib": ["dom", "esnext"], 8 | "importHelpers": true, 9 | "declaration": true, 10 | "sourceMap": true, 11 | "rootDir": "./src", 12 | "strict": true, 13 | "noImplicitAny": true, 14 | "strictNullChecks": true, 15 | "strictFunctionTypes": true, 16 | "strictPropertyInitialization": true, 17 | "noImplicitThis": true, 18 | "alwaysStrict": true, 19 | "noUnusedLocals": true, 20 | "noUnusedParameters": true, 21 | "noImplicitReturns": true, 22 | "noFallthroughCasesInSwitch": true, 23 | "moduleResolution": "node", 24 | "baseUrl": "./src", 25 | "paths": { 26 | "*": ["src/*", "node_modules/*"] 27 | }, 28 | "jsx": "react", 29 | "esModuleInterop": true 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Handled by @oss-docs/sync 3 | copy/* 4 | !copy/en 5 | **/*.js -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/categories/Additional_Checks_6176.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Linter Checks" 3 | --- 4 | 5 | A collection of extra checks, which somewhat cross the boundaries of compiler vs linter. You may prefer to use a tool like eslint over these options if you are looking for more in-depth rules. 6 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/categories/Advanced_Options_6178.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Advanced" 3 | --- 4 | 5 | Flags which help with debugging 6 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/categories/Backwards_Compatibility_6253.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Backwards Compatibility" 3 | --- 4 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/categories/Basic_Options_6172.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Project Options" 3 | --- 4 | 5 | These settings are used to define the runtime expectations of your project, how and where you want the JavaScript to be emitted and the level of integration you want with existing JavaScript code. 6 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/categories/Command_line_Options_6171.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Command Line" 3 | --- 4 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/categories/Compiler_Diagnostics_6251.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Compiler Diagnostics" 3 | --- 4 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/categories/Completeness_6257.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Completeness" 3 | --- 4 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/categories/Editor_Support_6249.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Editor Support" 3 | --- 4 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/categories/Emit_6246.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Emit" 3 | --- 4 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/categories/Experimental_Options_6177.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Experimental" 3 | --- 4 | 5 | TypeScript strives to only include features which are confirmed to be added into the JavaScript language. 6 | 7 | There have been cases where a feature is compelling enough to be an exception to that rule, and these live as experimental compiler flags. 8 | It is possible that a version of these features may be different when/if they are added to the JavaScript language, and thus are considered risky. 9 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/categories/Interop_Constraints_6252.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Interop Constraints" 3 | --- 4 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/categories/JavaScript_Support_6247.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "JavaScript Support" 3 | --- 4 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/categories/Language_and_Environment_6254.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Language and Environment" 3 | --- 4 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/categories/Module_Resolution_Options_6174.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Module Resolution" 3 | --- 4 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/categories/Modules_6244.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Modules" 3 | --- 4 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/categories/Output_Formatting_6256.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Output Formatting" 3 | --- 4 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/categories/Project_Files_0.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "File Inclusion" 3 | --- 4 | 5 | These settings help you ensure that TypeScript picks up the right files. 6 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/categories/Projects_6255.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Projects" 3 | --- 4 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/categories/Source_Map_Options_6175.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Source Maps" 3 | --- 4 | 5 | In order to provide rich debugging tools and crash reports which make sense to developers, TypeScript supports 6 | emitting additional files which conform to the JavaScript Source Map standards. 7 | 8 | These are emitted as `.map` files which live alongside the file they represent. 9 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/categories/Strict_Type_Checking_Options_6173.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Strict Checks" 3 | --- 4 | 5 | We recommend using the [compiler option `strict`](#strict) to opt-in to every possible improvement as they are built. 6 | 7 | TypeScript supports a wide spectrum of JavaScript patterns and defaults to allowing for quite a lot of flexibility in accommodating these styles. 8 | Often the safety and potential scalability of a codebase can be at odds with some of these techniques. 9 | 10 | Because of the variety of supported JavaScript, upgrading to a new version of TypeScript can uncover two types of errors: 11 | 12 | - Errors which already exist in your codebase, which TypeScript has uncovered because the language has refined its understanding of JavaScript. 13 | - A new suite of errors which tackle a new problem domain. 14 | 15 | TypeScript will usually add a compiler flag for the latter set of errors, and by default these are not enabled. 16 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/categories/Type_Checking_6248.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Type Checking" 3 | --- 4 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/categories/Watch_and_Build_Modes_6250.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Watch Options" 3 | --- 4 | 5 | TypeScript 3.8 shipped a new strategy for watching directories, which is crucial for efficiently picking up changes to `node_modules`. 6 | 7 | On operating systems like Linux, TypeScript installs directory watchers (as opposed to file watchers) on `node_modules` and many of its subdirectories to detect changes in dependencies. 8 | This is because the number of available file watchers is often eclipsed by the number of files in `node_modules`, whereas there are way fewer directories to track. 9 | 10 | Because every project might work better under different strategies, and this new approach might not work well for your workflows, TypeScript 3.8 introduces a new `watchOptions` field which allows users to tell the compiler/language service which watching strategies should be used to keep track of files and directories. 11 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/cli/help.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Help" 3 | oneline: "Gives local information for help on the CLI." 4 | --- 5 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/allowImportingTsExtensions.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Allow Importing TS Extensions" 3 | oneline: "Allow imports to include TypeScript file extensions." 4 | --- 5 | 6 | `--allowImportingTsExtensions` allows TypeScript files to import each other with a TypeScript-specific extension like `.ts`, `.mts`, or `.tsx`. 7 | 8 | This flag is only allowed when `--noEmit` or `--emitDeclarationOnly` is enabled, since these import paths would not be resolvable at runtime in JavaScript output files. 9 | The expectation here is that your resolver (e.g. your bundler, a runtime, or some other tool) is going to make these imports between `.ts` files work. 10 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/allowUmdGlobalAccess.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Allow Umd Global Access" 3 | oneline: "Allow accessing UMD globals from modules." 4 | --- 5 | 6 | When set to true, `allowUmdGlobalAccess` lets you access UMD exports as globals from inside module files. A module file is a file that has imports and/or exports. Without this flag, using an export from a UMD module requires an import declaration. 7 | 8 | An example use case for this flag would be a web project where you know the particular library (like jQuery or Lodash) will always be available at runtime, but you can’t access it with an import. 9 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/allowUnusedLabels.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Allow Unused Labels" 3 | oneline: "Disable error reporting for unused labels." 4 | --- 5 | 6 | When: 7 | 8 | - `undefined` (default) provide suggestions as warnings to editors 9 | - `true` unused labels are ignored 10 | - `false` raises compiler errors about unused labels 11 | 12 | Labels are very rare in JavaScript and typically indicate an attempt to write an object literal: 13 | 14 | ```ts twoslash 15 | // @errors: 7028 16 | // @allowUnusedLabels: false 17 | function verifyAge(age: number) { 18 | // Forgot 'return' statement 19 | if (age > 18) { 20 | verified: true; 21 | } 22 | } 23 | ``` 24 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/alwaysStrict.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Always Strict" 3 | oneline: "Ensure 'use strict' is always emitted." 4 | --- 5 | 6 | Ensures that your files are parsed in the ECMAScript strict mode, and emit "use strict" for each source file. 7 | 8 | [ECMAScript strict](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Strict_mode) mode was introduced in ES5 and provides behavior tweaks to the runtime of the JavaScript engine to improve performance, and makes a set of errors throw instead of silently ignoring them. 9 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/assumeChangesOnlyAffectDirectDependencies.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Assume Changes Only Affect Direct Dependencies" 3 | oneline: "Have recompiles in projects that use [`incremental`](#incremental) and `watch` mode assume that changes within a file will only affect files directly depending on it." 4 | --- 5 | 6 | When this option is enabled, TypeScript will avoid rechecking/rebuilding all truly possibly-affected files, and only recheck/rebuild files that have changed as well as files that directly import them. 7 | 8 | This can be considered a 'fast & loose' implementation of the watching algorithm, which can drastically reduce incremental rebuild times at the expense of having to run the full build occasionally to get all compiler error messages. 9 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/baseUrl.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Base URL" 3 | oneline: "Specify the base directory to resolve bare specifier module names." 4 | --- 5 | 6 | Sets a base directory from which to resolve bare specifier module names. For example, in the directory structure: 7 | 8 | ``` 9 | project 10 | ├── ex.ts 11 | ├── hello 12 | │ └── world.ts 13 | └── tsconfig.json 14 | ``` 15 | 16 | With `"baseUrl": "./"`, TypeScript will look for files starting at the same folder as the `tsconfig.json`: 17 | 18 | ```ts 19 | import { helloWorld } from "hello/world"; 20 | 21 | console.log(helloWorld); 22 | ``` 23 | 24 | This resolution has higher priority than lookups from `node_modules`. 25 | 26 | This feature was designed for use in conjunction with AMD module loaders in the browser, and is not recommended in any other context. As of TypeScript 4.1, `baseUrl` is no longer required to be set when using [`paths`](#paths). -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/charset.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Charset" 3 | oneline: "No longer supported. In early versions, manually set the text encoding for reading files." 4 | --- 5 | 6 | In prior versions of TypeScript, this controlled what encoding was used when reading text files from disk. 7 | Today, TypeScript assumes UTF-8 encoding, but will correctly detect UTF-16 (BE and LE) or UTF-8 BOMs. 8 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/clean.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Clean" 3 | oneline: "Delete the outputs of all projects." 4 | --- 5 | 6 | Delete the outputs of all projects 7 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/composite.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Composite" 3 | oneline: "Enable constraints that allow a TypeScript project to be used with project references." 4 | --- 5 | 6 | The `composite` option enforces certain constraints which make it possible for build tools (including TypeScript 7 | itself, under `--build` mode) to quickly determine if a project has been built yet. 8 | 9 | When this setting is on: 10 | 11 | - The [`rootDir`](#rootDir) setting, if not explicitly set, defaults to the directory containing the `tsconfig.json` file. 12 | 13 | - All implementation files must be matched by an [`include`](#include) pattern or listed in the [`files`](#files) array. If this constraint is violated, `tsc` will inform you which files weren't specified. 14 | 15 | - [`declaration`](#declaration) defaults to `true` 16 | 17 | You can find documentation on TypeScript projects in [the handbook](https://www.typescriptlang.org/docs/handbook/project-references.html). 18 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/declarationDir.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Declaration Dir" 3 | oneline: "Specify the output directory for generated declaration files." 4 | --- 5 | 6 | Offers a way to configure the root directory for where declaration files are emitted. 7 | 8 | ``` 9 | example 10 | ├── index.ts 11 | ├── package.json 12 | └── tsconfig.json 13 | ``` 14 | 15 | with this `tsconfig.json`: 16 | 17 | ```json tsconfig 18 | { 19 | "compilerOptions": { 20 | "declaration": true, 21 | "declarationDir": "./types" 22 | } 23 | } 24 | ``` 25 | 26 | Would place the d.ts for the `index.ts` in a `types` folder: 27 | 28 | ``` 29 | example 30 | ├── index.js 31 | ├── index.ts 32 | ├── package.json 33 | ├── tsconfig.json 34 | └── types 35 | └── index.d.ts 36 | ``` 37 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/declarationMap.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Declaration Map" 3 | oneline: "Create sourcemaps for d.ts files." 4 | --- 5 | 6 | Generates a source map for `.d.ts` files which map back to the original `.ts` source file. 7 | This will allow editors such as VS Code to go to the original `.ts` file when using features like _Go to Definition_. 8 | 9 | You should strongly consider turning this on if you're using project references. 10 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/diagnostics.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Diagnostics" 3 | oneline: "Output compiler performance information after building." 4 | --- 5 | 6 | Used to output diagnostic information for debugging. This command is a subset of [`extendedDiagnostics`](#extendedDiagnostics) which are more user-facing results, and easier to interpret. 7 | 8 | If you have been asked by a TypeScript compiler engineer to give the results using this flag in a compile, in which there is no harm in using [`extendedDiagnostics`](#extendedDiagnostics) instead. 9 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/disableFilenameBasedTypeAcquisition.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Disable Filename Based Type Acquisition" 3 | oneline: "Disables inference for type acquisition by looking at filenames in a project." 4 | --- 5 | 6 | TypeScript's type acquisition can infer what types should be added based on filenames in a project. This means that having a file like `jquery.js` in your project would automatically download the types for JQuery from DefinitelyTyped. 7 | 8 | You can disable this via `disableFilenameBasedTypeAcquisition`. 9 | 10 | ```json 11 | { 12 | "typeAcquisition": { 13 | "disableFilenameBasedTypeAcquisition": true 14 | } 15 | } 16 | ``` 17 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/disableReferencedProjectLoad.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Disable Referenced Project Load" 3 | oneline: "Reduce the number of projects loaded automatically by TypeScript." 4 | --- 5 | 6 | In multi-project TypeScript programs, TypeScript will load all of the available projects into memory in order to provide accurate results for editor responses which require a full knowledge graph like 'Find All References'. 7 | 8 | If your project is large, you can use the flag `disableReferencedProjectLoad` to disable the automatic loading of all projects. Instead, projects are loaded dynamically as you open files through your editor. 9 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/disableSizeLimit.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Disable Size Limit" 3 | oneline: "Remove the 20mb cap on total source code size for JavaScript files in the TypeScript language server." 4 | --- 5 | 6 | To avoid a possible memory bloat issues when working with very large JavaScript projects, there is an upper limit to the amount of memory TypeScript will allocate. Turning this flag on will remove the limit. 7 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/disableSolutionSearching.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Disable Solution Searching" 3 | oneline: "Opt a project out of multi-project reference checking when editing." 4 | --- 5 | 6 | When working with [composite TypeScript projects](/docs/handbook/project-references.html), this option provides a way to declare that you do not want a project to be included when using features like _find all references_ or _jump to definition_ in an editor. 7 | 8 | This flag is something you can use to increase responsiveness in large composite projects. 9 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/disableSourceOfProjectReferenceRedirect.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Disable Source Project Reference Redirect" 3 | oneline: "Disable preferring source files instead of declaration files when referencing composite projects." 4 | --- 5 | 6 | When working with [composite TypeScript projects](/docs/handbook/project-references.html), this option provides a way to go [back to the pre-3.7](/docs/handbook/release-notes/typescript-3-7.html#build-free-editing-with-project-references) behavior where d.ts files were used to as the boundaries between modules. 7 | In 3.7 the source of truth is now your TypeScript files. 8 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/emitBOM.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Emit BOM" 3 | oneline: "Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files." 4 | --- 5 | 6 | Controls whether TypeScript will emit a [byte order mark (BOM)](https://wikipedia.org/wiki/Byte_order_mark) when writing output files. 7 | Some runtime environments require a BOM to correctly interpret a JavaScript files; others require that it is not present. 8 | The default value of `false` is generally best unless you have a reason to change it. 9 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/emitDeclarationOnly.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Emit Declaration Only" 3 | oneline: "Only output d.ts files and not JavaScript files." 4 | --- 5 | 6 | _Only_ emit `.d.ts` files; do not emit `.js` files. 7 | 8 | This setting is useful in two cases: 9 | 10 | - You are using a transpiler other than TypeScript to generate your JavaScript. 11 | - You are using TypeScript to only generate `d.ts` files for your consumers. 12 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/enable.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Enable" 3 | oneline: "Disable the type acquisition for JavaScript projects." 4 | --- 5 | 6 | Disables automatic type acquisition in JavaScript projects: 7 | 8 | ```json 9 | { 10 | "typeAcquisition": { 11 | "enable": false 12 | } 13 | } 14 | ``` 15 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/exclude.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Exclude" 3 | oneline: "Filters results from the [`include`](#include) option." 4 | --- 5 | 6 | Specifies an array of filenames or patterns that should be skipped when resolving [`include`](#include). 7 | 8 | **Important**: `exclude` _only_ changes which files are included as a result of the [`include`](#include) setting. 9 | A file specified by `exclude` can still become part of your codebase due to an `import` statement in your code, a `types` inclusion, a `/// `s from expanding the number of files TypeScript should add to a project." 4 | --- 5 | 6 | By default, TypeScript will examine the initial set of files for `import` and `(x: T, y: U) => [T, U]; 12 | type B = (x: S, y: S) => [S, S]; 13 | 14 | function f(a: A, b: B) { 15 | b = a; // Ok 16 | a = b; // Error 17 | } 18 | ``` 19 | 20 | This flag can be used to remove that check. 21 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/noUnusedLocals.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "No Unused Locals" 3 | oneline: "Enable error reporting when local variables aren't read." 4 | --- 5 | 6 | Report errors on unused local variables. 7 | 8 | ```ts twoslash 9 | // @noUnusedLocals 10 | // @errors: 6133 11 | const createKeyboard = (modelID: number) => { 12 | const defaultModelID = 23; 13 | return { type: "keyboard", modelID }; 14 | }; 15 | ``` 16 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/noUnusedParameters.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "No Unused Parameters" 3 | oneline: "Raise an error when a function parameter isn't read." 4 | --- 5 | 6 | Report errors on unused parameters in functions. 7 | 8 | ```ts twoslash 9 | // @noUnusedParameters 10 | // @errors: 6133 11 | const createDefaultKeyboard = (modelID: number) => { 12 | const defaultModelID = 23; 13 | return { type: "keyboard", modelID: defaultModelID }; 14 | }; 15 | ``` 16 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/out.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Out" 3 | oneline: "Deprecated setting. Use [`outFile`](#outFile) instead." 4 | --- 5 | 6 | Use [`outFile`](#outFile) instead. 7 | 8 | The `out` option computes the final file location in a way that is not predictable or consistent. 9 | This option is retained for backward compatibility only and is deprecated. 10 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/outDir.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Out Dir" 3 | oneline: "Specify an output folder for all emitted files." 4 | --- 5 | 6 | If specified, `.js` (as well as `.d.ts`, `.js.map`, etc.) files will be emitted into this directory. 7 | The directory structure of the original source files is preserved; see [`rootDir`](#rootDir) if the computed root is not what you intended. 8 | 9 | If not specified, `.js` files will be emitted in the same directory as the `.ts` files they were generated from: 10 | 11 | ```sh 12 | $ tsc 13 | 14 | example 15 | ├── index.js 16 | └── index.ts 17 | ``` 18 | 19 | With a `tsconfig.json` like this: 20 | 21 | ```json tsconfig 22 | { 23 | "compilerOptions": { 24 | "outDir": "dist" 25 | } 26 | } 27 | ``` 28 | 29 | Running `tsc` with these settings moves the files into the specified `dist` folder: 30 | 31 | ```sh 32 | $ tsc 33 | 34 | example 35 | ├── dist 36 | │ └── index.js 37 | ├── index.ts 38 | └── tsconfig.json 39 | ``` 40 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/outFile.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Out File" 3 | oneline: "Specify a file that bundles all outputs into one JavaScript file. If [`declaration`](#declaration) is true, also designates a file that bundles all .d.ts output." 4 | --- 5 | 6 | If specified, all _global_ (non-module) files will be concatenated into the single output file specified. 7 | 8 | If `module` is `system` or `amd`, all module files will also be concatenated into this file after all global content. 9 | 10 | Note: `outFile` cannot be used unless `module` is `None`, `System`, or `AMD`. 11 | This option _cannot_ be used to bundle CommonJS or ES6 modules. 12 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/preserveSymlinks.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Preserve Symlinks" 3 | oneline: "Disable resolving symlinks to their realpath. This correlates to the same flag in node." 4 | --- 5 | 6 | This is to reflect the same flag in Node.js; which does not resolve the real path of symlinks. 7 | 8 | This flag also exhibits the opposite behavior to Webpack’s `resolve.symlinks` option (i.e. setting TypeScript’s `preserveSymlinks` to true parallels setting Webpack’s `resolve.symlinks` to false, and vice-versa). 9 | 10 | With this enabled, references to modules and packages (e.g. `import`s and `/// ` directives) are all resolved relative to the location of the symbolic link file, rather than relative to the path that the symbolic link resolves to. 11 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/preserveWatchOutput.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Preserve Watch Output" 3 | oneline: "Disable wiping the console in watch mode." 4 | --- 5 | 6 | Whether to keep outdated console output in watch mode instead of clearing the screen every time a change happened. 7 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/pretty.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Pretty" 3 | oneline: "Enable color and formatting in TypeScript's output to make compiler errors easier to read." 4 | --- 5 | 6 | Stylize errors and messages using color and context, this is on by default — offers you a chance to have less terse, 7 | single colored messages from the compiler. 8 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/reactNamespace.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "React Namespace" 3 | oneline: "Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit." 4 | --- 5 | 6 | Use [`jsxFactory`](#jsxFactory) instead. Specify the object invoked for `createElement` when targeting `react` for TSX files. 7 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/references.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "References" 3 | oneline: "Specify an array of objects that specify paths for projects. Used in project references." 4 | --- 5 | 6 | Project references are a way to structure your TypeScript programs into smaller pieces. 7 | Using Project References can greatly improve build and editor interaction times, enforce logical separation between components, and organize your code in new and improved ways. 8 | 9 | You can read more about how references works in the [Project References](/docs/handbook/project-references.html) section of the handbook 10 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/resolvePackageJsonExports.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Resolve package.json Exports" 3 | oneline: "Use the package.json 'exports' field when resolving package imports." 4 | --- 5 | 6 | `--resolvePackageJsonExports` forces TypeScript to consult [the `exports` field of `package.json` files](https://nodejs.org/api/packages.html#exports) if it ever reads from a package in `node_modules`. 7 | 8 | This option defaults to `true` under the `node16`, `nodenext`, and `bundler` options for [`--moduleResolution`](#moduleResolution). 9 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/resolvePackageJsonImports.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Resolve package.json Imports" 3 | oneline: "Use the package.json 'imports' field when resolving imports." 4 | --- 5 | 6 | `--resolvePackageJsonImports` forces TypeScript to consult [the `imports` field of `package.json` files](https://nodejs.org/api/packages.html#imports) when performing a lookup that starts with `#` from a file whose ancestor directory contains a `package.json`. 7 | 8 | This option defaults to `true` under the `node16`, `nodenext`, and `bundler` options for [`--moduleResolution`](#moduleResolution). 9 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/rewriteRelativeImportExtensions.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "rewriteRelativeImportExtensions" 3 | oneline: "Rewrite `.ts`, `.tsx`, `.mts`, and `.cts` file extensions in relative import paths to their JavaScript equivalent in output files." 4 | --- 5 | 6 | Rewrite `.ts`, `.tsx`, `.mts`, and `.cts` file extensions in relative import paths to their JavaScript equivalent in output files. 7 | 8 | For more information, see the [TypeScript 5.7 release notes](/docs/handbook/release-notes/typescript-5-7.html#path-rewriting-for-relative-paths). 9 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/skipDefaultLibCheck.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Skip Default Lib Check" 3 | oneline: "Skip type checking .d.ts files that are included with TypeScript." 4 | --- 5 | 6 | Use [`skipLibCheck`](#skipLibCheck) instead. Skip type checking of default library declaration files. 7 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/sourceRoot.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Source Root" 3 | oneline: "Specify the root path for debuggers to find the reference source code." 4 | --- 5 | 6 | Specify the location where a debugger should locate TypeScript files instead of relative source locations. 7 | This string is treated verbatim inside the source-map where you can use a path or a URL: 8 | 9 | ```json tsconfig 10 | { 11 | "compilerOptions": { 12 | "sourceMap": true, 13 | "sourceRoot": "https://my-website.com/debug/source/" 14 | } 15 | } 16 | ``` 17 | 18 | Would declare that `index.js` will have a source file at `https://my-website.com/debug/source/index.ts`. 19 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/stopBuildOnErrors.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "stopBuildOnErrors" 3 | oneline: "Skip building downstream projects on error in upstream project." 4 | --- 5 | Skip building downstream projects on error in upstream project. 6 | 7 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/strict.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Strict" 3 | oneline: "Enable all strict type-checking options." 4 | --- 5 | 6 | The `strict` flag enables a wide range of type checking behavior that results in stronger guarantees of program correctness. 7 | Turning this on is equivalent to enabling all of the _strict mode family_ options, which are outlined below. 8 | You can then turn off individual strict mode family checks as needed. 9 | 10 | Future versions of TypeScript may introduce additional stricter checking under this flag, so upgrades of TypeScript might result in new type errors in your program. 11 | When appropriate and possible, a corresponding flag will be added to disable that behavior. 12 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/strictBuiltinIteratorReturn.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "strictBuiltinIteratorReturn" 3 | oneline: "Built-in iterators are instantiated with a TReturn type of undefined instead of any." 4 | --- 5 | Built-in iterators are instantiated with a `TReturn` type of undefined instead of `any`. 6 | 7 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/strictPropertyInitialization.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Strict Property Initialization" 3 | oneline: "Check for class properties that are declared but not set in the constructor." 4 | --- 5 | 6 | When set to true, TypeScript will raise an error when a class property was declared but not set in the constructor. 7 | 8 | ```ts twoslash 9 | // @errors: 2564 10 | class UserAccount { 11 | name: string; 12 | accountType = "user"; 13 | 14 | email: string; 15 | address: string | undefined; 16 | 17 | constructor(name: string) { 18 | this.name = name; 19 | // Note that this.email is not set 20 | } 21 | } 22 | ``` 23 | 24 | In the above case: 25 | 26 | - `this.name` is set specifically. 27 | - `this.accountType` is set by default. 28 | - `this.email` is not set and raises an error. 29 | - `this.address` is declared as potentially `undefined` which means it does not have to be set. 30 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/suppressExcessPropertyErrors.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Suppress Excess Property Errors" 3 | oneline: "Disable reporting of excess property errors during the creation of object literals." 4 | --- 5 | 6 | This disables reporting of excess property errors, such as the one shown in the following example: 7 | 8 | ```ts twoslash 9 | // @errors: 2322 10 | type Point = { x: number; y: number }; 11 | const p: Point = { x: 1, y: 3, m: 10 }; 12 | ``` 13 | 14 | This flag was added to help people migrate to the stricter checking of new object literals in [TypeScript 1.6](/docs/handbook/release-notes/typescript-1-6.html#stricter-object-literal-assignment-checks). 15 | 16 | We don't recommend using this flag in a modern codebase, you can suppress one-off cases where you need it using `// @ts-ignore`. 17 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/suppressImplicitAnyIndexErrors.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Suppress Implicit Any Index Errors" 3 | oneline: "Suppress [`noImplicitAny`](#noImplicitAny) errors when indexing objects that lack index signatures." 4 | --- 5 | 6 | Turning `suppressImplicitAnyIndexErrors` on suppresses reporting the error about implicit anys when indexing into objects, as shown in the following example: 7 | 8 | ```ts twoslash 9 | // @noImplicitAny: true 10 | // @suppressImplicitAnyIndexErrors: false 11 | // @strict: true 12 | // @errors: 7053 13 | const obj = { x: 10 }; 14 | console.log(obj["foo"]); 15 | ``` 16 | 17 | Using `suppressImplicitAnyIndexErrors` is quite a drastic approach. It is recommended to use a `@ts-ignore` comment instead: 18 | 19 | ```ts twoslash 20 | // @noImplicitAny: true 21 | // @strict: true 22 | const obj = { x: 10 }; 23 | // @ts-ignore 24 | console.log(obj["foo"]); 25 | ``` 26 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/synchronousWatchDirectory.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Synchronous Watch Directory" 3 | oneline: "Synchronously call callbacks and update the state of directory watchers on platforms that don`t support recursive watching natively." 4 | --- 5 | 6 | Synchronously call callbacks and update the state of directory watchers on platforms that don`t support recursive watching natively. Instead of giving a small timeout to allow for potentially multiple edits to occur on a file. 7 | 8 | ```json tsconfig 9 | { 10 | "watchOptions": { 11 | "synchronousWatchDirectory": true 12 | } 13 | } 14 | ``` 15 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/traceResolution.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Trace Resolution" 3 | oneline: "Log paths used during the [`moduleResolution`](#moduleResolution) process." 4 | --- 5 | 6 | When you are trying to debug why a module isn't being included. 7 | You can set `traceResolution` to `true` to have TypeScript print information about its resolution process for each processed file. 8 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/typeAcquisition/exclude.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Exclude" 3 | oneline: "Specify a list of modules which to exclude from type acquisition." 4 | --- 5 | 6 | Offers a config for disabling the type-acquisition for a certain module in JavaScript projects. This can be useful for projects which include other libraries in testing infrastructure which aren't needed in the main application. 7 | 8 | ```json 9 | { 10 | "typeAcquisition": { 11 | "exclude": ["jest", "mocha"] 12 | } 13 | } 14 | ``` 15 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/typeAcquisition/include.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Include" 3 | oneline: "Specify a list of modules which to acquire types for." 4 | --- 5 | 6 | If you have a JavaScript project where TypeScript needs additional guidance to understand global dependencies, or have disabled the built-in inference via [`disableFilenameBasedTypeAcquisition`](#disableFilenameBasedTypeAcquisition). 7 | 8 | You can use `include` to specify which types should be used from DefinitelyTyped: 9 | 10 | ```json 11 | { 12 | "typeAcquisition": { 13 | "include": ["jquery"] 14 | } 15 | } 16 | ``` 17 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/typeRoots.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Type Roots" 3 | oneline: "Specify multiple folders that act like `./node_modules/@types`." 4 | --- 5 | 6 | By default all _visible_ "`@types`" packages are included in your compilation. 7 | Packages in `node_modules/@types` of any enclosing folder are considered _visible_. 8 | For example, that means packages within `./node_modules/@types/`, `../node_modules/@types/`, `../../node_modules/@types/`, and so on. 9 | 10 | If `typeRoots` is specified, _only_ packages under `typeRoots` will be included. For example: 11 | 12 | ```json tsconfig 13 | { 14 | "compilerOptions": { 15 | "typeRoots": ["./typings", "./vendor/types"] 16 | } 17 | } 18 | ``` 19 | 20 | This config file will include _all_ packages under `./typings` and `./vendor/types`, and no packages from `./node_modules/@types`. 21 | All paths are relative to the `tsconfig.json`. 22 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/useDefineForClassFields.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Use Define For Class Fields" 3 | oneline: "Emit ECMAScript-standard-compliant class fields." 4 | --- 5 | 6 | This flag is used as part of migrating to the upcoming standard version of class fields. TypeScript introduced class fields many years before it was ratified in TC39. The latest version of the upcoming specification has a different runtime behavior to TypeScript's implementation but the same syntax. 7 | 8 | This flag switches to the upcoming ECMA runtime behavior. 9 | 10 | You can read more about the transition in [the 3.7 release notes](/docs/handbook/release-notes/typescript-3-7.html#the-usedefineforclassfields-flag-and-the-declare-property-modifier). 11 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/useUnknownInCatchVariables.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Use Unknown In Catch Variables" 3 | oneline: "Default catch clause variables as `unknown` instead of `any`." 4 | --- 5 | 6 | In TypeScript 4.0, support was added to allow changing the type of the variable in a catch clause from `any` to `unknown`. Allowing for code like: 7 | 8 | ```ts twoslash 9 | // @useUnknownInCatchVariables 10 | try { 11 | // ... 12 | } catch (err: unknown) { 13 | // We have to verify err is an 14 | // error before using it as one. 15 | if (err instanceof Error) { 16 | console.log(err.message); 17 | } 18 | } 19 | ``` 20 | 21 | This pattern ensures that error handling code becomes more comprehensive because you cannot guarantee that the object being thrown _is_ a Error subclass ahead of time. With the flag `useUnknownInCatchVariables` enabled, then you do not need the additional syntax (`: unknown`) nor a linter rule to try enforce this behavior. 22 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/verbose.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Verbose" 3 | oneline: "Enable verbose logging." 4 | --- 5 | 6 | Enable verbose logging 7 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/watchDirectory.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Watch Directory" 3 | oneline: "Specify how directories are watched on systems that lack recursive file-watching functionality." 4 | --- 5 | 6 | The strategy for how entire directory trees are watched under systems that lack recursive file-watching functionality. 7 | 8 | - `fixedPollingInterval`: Check every directory for changes several times a second at a fixed interval. 9 | - `dynamicPriorityPolling`: Use a dynamic queue where less-frequently modified directories will be checked less often. 10 | - `useFsEvents` (the default): Attempt to use the operating system/file system's native events for directory changes. 11 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/options/watchFile.md: -------------------------------------------------------------------------------- 1 | --- 2 | display: "Watch File" 3 | oneline: "Specify how the TypeScript watch mode works." 4 | --- 5 | 6 | The strategy for how individual files are watched. 7 | 8 | - `fixedPollingInterval`: Check every file for changes several times a second at a fixed interval. 9 | - `priorityPollingInterval`: Check every file for changes several times a second, but use heuristics to check certain types of files less frequently than others. 10 | - `dynamicPriorityPolling`: Use a dynamic queue where less-frequently modified files will be checked less often. 11 | - `useFsEvents` (the default): Attempt to use the operating system/file system's native events for file changes. 12 | - `useFsEventsOnParentDirectory`: Attempt to use the operating system/file system's native events to listen for changes on a file's parent directory 13 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/sections/Top Level.md: -------------------------------------------------------------------------------- 1 | ### Root Fields 2 | 3 | Starting up are the root options in the TSConfig - these options relate to how your TypeScript or JavaScript project is set up. 4 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/sections/buildOptions.md: -------------------------------------------------------------------------------- 1 | ## Build Options 2 | 3 | Type Acquisition is only important for JavaScript projects. In TypeScript projects you need to include the types in your projects explicitly. However, for JavaScript projects, the TypeScript tooling will download types for your modules in the background and outside of your node_modules folder. 4 | 5 | You may not want this, in which case you can turn off type acquisition by having this `jsconfig.json` in the root of your project: 6 | 7 | ```json 8 | { 9 | "typeAcquisition": { 10 | "enable": false 11 | } 12 | } 13 | ``` 14 | 15 | Common uses for this section of a `jsconfig.json` is to tell TypeScript to download additional definitions for your tooling experience: 16 | 17 | ```json 18 | { 19 | "typeAcquisition": { 20 | "include": ["jquery"] 21 | } 22 | } 23 | ``` 24 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/sections/compilerOptions.md: -------------------------------------------------------------------------------- 1 | ### Compiler Options 2 | 3 | These options make up the bulk of TypeScript's configuration and it covers how the language should work. 4 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/sections/typeAcquisition.md: -------------------------------------------------------------------------------- 1 | ## Type Acquisition 2 | 3 | Type Acquisition is only important for JavaScript projects. In TypeScript projects you need to include the types in your projects explicitly. However, for JavaScript projects, the TypeScript tooling will download types for your modules in the background and outside of your node_modules folder. 4 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/copy/en/sections/watchOptions.md: -------------------------------------------------------------------------------- 1 | ## Watch Options 2 | 3 | You can configure the how TypeScript `--watch` works. This section is mainly for handling case where `fs.watch` and `fs.watchFile` have additional constraints like on Linux. You can read more at [Configuring Watch](/docs/handbook/configuring-watch.html). 4 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/data/.gitignore: -------------------------------------------------------------------------------- 1 | *.json 2 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/output/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitkeep 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/output/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/tsconfig-reference/output/.gitkeep -------------------------------------------------------------------------------- /packages/tsconfig-reference/scripts/schema/exampleTsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./result/schema.json", 3 | "compilerOptions": {} 4 | } 5 | -------------------------------------------------------------------------------- /packages/tsconfig-reference/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "es2020", 4 | "moduleResolution": "node", 5 | "resolveJsonModule": true, 6 | "allowSyntheticDefaultImports": true, 7 | "target": "es2019" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/typescript-vfs/.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | .DS_Store 3 | node_modules 4 | .rts2_cache_cjs 5 | .rts2_cache_esm 6 | .rts2_cache_umd 7 | .rts2_cache_system 8 | dist 9 | -------------------------------------------------------------------------------- /packages/typescript-vfs/scripts/makeGlobals.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 3 | // Creates a web version of tsvfs which sets a global of 'tsvfs'. 4 | 5 | const fs = require("fs") 6 | const path = require("path") 7 | 8 | const esm = fs.readFileSync(path.join(__dirname, "..", "dist", "vfs.esm.js"), "utf8") 9 | const body = esm.replace("export {", "const tsvfs = {") 10 | const suffix = ` 11 | const getGlobal = function () { 12 | if (typeof self !== 'undefined') { return self; } 13 | if (typeof window !== 'undefined') { return window; } 14 | if (typeof global !== 'undefined') { return global; } 15 | throw new Error('unable to locate global object'); 16 | }; 17 | 18 | const globals = getGlobal(); 19 | globals.tsvfs = tsvfs; 20 | ` 21 | 22 | fs.writeFileSync(path.join(__dirname, "..", "dist", "vfs.globals.js"), body + suffix, "utf8") 23 | -------------------------------------------------------------------------------- /packages/typescript-vfs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["src", "types", "test"], 3 | "exclude": ["test"], 4 | 5 | "compilerOptions": { 6 | "target": "ES2015", 7 | "module": "esnext", 8 | "lib": ["esnext"], 9 | "importHelpers": true, 10 | "declaration": true, 11 | "sourceMap": true, 12 | "rootDir": "./src", 13 | "strict": true, 14 | "noImplicitAny": true, 15 | "strictNullChecks": true, 16 | "strictFunctionTypes": true, 17 | "strictPropertyInitialization": true, 18 | "noImplicitThis": true, 19 | "alwaysStrict": true, 20 | "noUnusedLocals": false, 21 | "noUnusedParameters": true, 22 | "noImplicitReturns": true, 23 | "noFallthroughCasesInSwitch": true, 24 | "moduleResolution": "node", 25 | "baseUrl": "./src", 26 | "paths": { 27 | "*": ["src/*", "node_modules/*"] 28 | }, 29 | "jsx": "react", 30 | "esModuleInterop": true 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "endOfLine": "lf", 3 | "semi": false, 4 | "singleQuote": false, 5 | "tabWidth": 2, 6 | "trailingComma": "es5", 7 | "arrowParens": "avoid" 8 | } 9 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/README.md: -------------------------------------------------------------------------------- 1 | ## TypeScript Website 2 | 3 | This a pretty traditional Gatsby site. You can start it up via: 4 | 5 | ```sh 6 | pnpm start 7 | ``` 8 | 9 | Which starts up a dev server. 10 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/_tests/backstop_data/bitmaps_reference/backstop_default_Index_0_document_0_phone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/_tests/backstop_data/bitmaps_reference/backstop_default_Index_0_document_0_phone.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/_tests/backstop_data/bitmaps_reference/backstop_default_Index_0_document_1_tablet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/_tests/backstop_data/bitmaps_reference/backstop_default_Index_0_document_1_tablet.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/_tests/backstop_data/bitmaps_reference/backstop_default_Index_0_document_2_computer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/_tests/backstop_data/bitmaps_reference/backstop_default_Index_0_document_2_computer.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/lib/bootup/ingestion/languageFilter.ts: -------------------------------------------------------------------------------- 1 | export const isMultiLingual = !process.env.NO_TRANSLATIONS 2 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/lib/bootup/pathsOnSiteTracker.ts: -------------------------------------------------------------------------------- 1 | import { existsSync, mkdirSync, writeFileSync } from "fs" 2 | import { join } from "path" 3 | 4 | const paths = [] as string[] 5 | export const addPathToSite = (path: string) => paths.push(path) 6 | 7 | export const writeAllPathsToFixture = () => { 8 | const generated = join(__dirname, "..", "..", "src", "__generated__") 9 | if (!existsSync(generated)) { 10 | mkdirSync(generated) 11 | } 12 | 13 | const allPagesPath = join(generated, "allPages.ts") 14 | writeFileSync( 15 | allPagesPath, 16 | ` 17 | // Generated during bootstapping via pathsOnSiteTracker.ts 18 | 19 | export const allFiles = [${paths 20 | .map(item => '"' + item.replace(/\\/g, "/") + '",') 21 | .join("\n")}]` 22 | ) 23 | } 24 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/scripts/backstop/makeDarkMode.js: -------------------------------------------------------------------------------- 1 | module.exports = async (page, scenario) => { 2 | console.log("SWITCHING TO DARK for " + scenario.label) 3 | 4 | await page.emulateMediaFeatures([ 5 | { 6 | name: "prefers-color-scheme", 7 | value: "dark", 8 | }, 9 | ]) 10 | // await wait() 11 | } 12 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/scripts/updateIndexTwoslashExamples.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 3 | const { join } = require(`path`) 4 | const { readdirSync, readFileSync, lstatSync, writeFileSync } = require("fs") 5 | 6 | // prettier-ignore 7 | const examplesPath = join(__dirname,"..", "src", "components", "index", "generated") 8 | 9 | // Loop through all code sames in src/components/index/twoslash and generate HTML 10 | const go = async () => { 11 | console.log("Parsing index examples ->") 12 | for (const path of readdirSync(examplesPath, "utf-8")) { 13 | const filePath = join(examplesPath, path) 14 | if (lstatSync(filePath).isDirectory()) { 15 | continue 16 | } 17 | 18 | writeFileSync( 19 | filePath, 20 | readFileSync(filePath, "utf8").replace("267F99", "227289") 21 | ) 22 | } 23 | } 24 | 25 | go() 26 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/conferences/tsconf-2019-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/community/conferences/tsconf-2019-logo.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/conferences/tsconf-eu-2020-brief.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/community/conferences/tsconf-eu-2020-brief.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/conferences/tsconf-eu-2020-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/community/conferences/tsconf-eu-2020-logo.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/conferences/tsconf-it-2019-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/community/conferences/tsconf-it-2019-logo.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/conferences/tsconf-jp-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/community/conferences/tsconf-jp-logo.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/connect-blog-icon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/connect-github-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/community/connect-github-icon.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/connect-gitter.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Artboard 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/connect-group-icon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/connect-stackoverflow-icon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/connect-twitter-icon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/connect-uservoice-icon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/definitely_typed_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/community/definitely_typed_logo.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/meetup-logos/boston-ts-club.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/community/meetup-logos/boston-ts-club.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/meetup-logos/brazil-ts.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/community/meetup-logos/brazil-ts.jpg -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/meetup-logos/dublin-ts.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/community/meetup-logos/dublin-ts.jpg -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/meetup-logos/hamburg-ts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/community/meetup-logos/hamburg-ts.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/meetup-logos/ktug.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/community/meetup-logos/ktug.jpg -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/meetup-logos/london-ts.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/community/meetup-logos/london-ts.jpg -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/meetup-logos/melbourne.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/community/meetup-logos/melbourne.jpg -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/meetup-logos/milano-ts.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/community/meetup-logos/milano-ts.jpg -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/meetup-logos/paris-ts.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/community/meetup-logos/paris-ts.jpg -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/meetup-logos/phx-ts.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/community/meetup-logos/phx-ts.jpg -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/meetup-logos/san-fran-ts.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/community/meetup-logos/san-fran-ts.jpg -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/meetup-logos/seattle.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/community/meetup-logos/seattle.jpg -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/meetup-logos/sqvts.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/community/meetup-logos/sqvts.jpg -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/meetup-logos/sydney.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/community/meetup-logos/sydney.jpg -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/meetup-logos/typescript-jp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/community/meetup-logos/typescript-jp.jpg -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/meetup-logos/typescript-nyc.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/community/meetup-logos/typescript-nyc.jpg -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/meetup-logos/warsaw-ts.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/community/meetup-logos/warsaw-ts.jpg -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/community/meetup-logos/wroclaw-ts.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/community/meetup-logos/wroclaw-ts.jpg -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/index/code-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/index/code-dark.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/index/code-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/index/code-light.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/index/handbook.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/index/handbook.jpg -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/index/play-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/index/play-dark.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/index/play-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/index/play-light.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/microsoft-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/microsoft-logo.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/playground-plugin-preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/playground-plugin-preview.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/typescript-handbook.epub/index.html: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/typescript-handbook.pdf/index.html: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/assets/v3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/assets/v3.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/components/Intl.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import { IntlProvider } from 'react-intl'; 3 | 4 | type IntlProps = { 5 | locale: string 6 | children: any 7 | } 8 | 9 | export const Intl = (props: IntlProps) => { 10 | const { children, locale } = props 11 | let messages = require("../copy/en/en").lang 12 | try { 13 | messages = require("../copy/" + locale + "/" + locale).lang 14 | } catch (error) { 15 | // NOOP 16 | } 17 | return ( 18 | 19 | {children} 20 | 21 | ) 22 | } 23 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/components/TmpLink.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | 3 | import { GatsbyLinkProps } from "gatsby"; 4 | 5 | export const Link = (props: GatsbyLinkProps<{}>) => { 6 | return 7 | } 8 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/components/display/ButtonGrid.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import { GreyButton } from "./GreyButton" 3 | 4 | type ButtonProps = Omit 5 | export type GridProps = { 6 | buttons: ButtonProps[] 7 | headline?: true 8 | } 9 | 10 | 11 | /** A pretty grid of grey buttons */ 12 | export const ButtonGrid = (props: GridProps) => ( 13 |
14 | {props.buttons.map(b => 15 | 16 | )} 17 |
18 | ) 19 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/components/display/GreyButton.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import { withPrefix } from "gatsby" 3 | 4 | export type Props = { 5 | href: string 6 | blurb: string 7 | title: string 8 | headline?: true 9 | badge?: string 10 | first?: boolean 11 | last?: boolean 12 | customClass?: string 13 | } 14 | 15 | /** A pretty grey button */ 16 | export const GreyButton = (props: Props) => { 17 | const href = props.href.startsWith("http") 18 | ? props.href 19 | : withPrefix(props.href) 20 | const classes = ["clicky-grey-button"] 21 | 22 | if (props.headline) classes.push("headline") 23 | if (props.first) classes.push("first") 24 | if (props.last) classes.push("last") 25 | if (props.customClass) classes.push(props.customClass) 26 | 27 | return ( 28 |
29 |

{props.blurb}

30 |
{props.title}
31 |
32 | ) 33 | } 34 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/components/index/twoslash/Index2Del1TS.ts: -------------------------------------------------------------------------------- 1 | // twoslash: { themes: ["../../../packages/typescriptlang-org/lib/themes/typescript-beta-light"] } 2 | // @noErrors 3 | type Result = "pass" | "fail" 4 | 5 | function verify(result: Result) { 6 | if (result === "pass") { 7 | console.log("Passed") 8 | } else { 9 | console.log("Failed") 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/components/index/twoslash/Index2Del2RM.ts: -------------------------------------------------------------------------------- 1 | // twoslash: { themes: ["../../../packages/typescriptlang-org/lib/themes/typescript-beta-light"] } 2 | // codefence: {1,3} 3 | type Result = "pass" | "fail" 4 | 5 | function verify(result: Result) { 6 | // ^^^^^^^^ 7 | if (result === "pass") { 8 | console.log("Passed") 9 | } else { 10 | console.log("Failed") 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/components/index/twoslash/Index2Del3JS.js: -------------------------------------------------------------------------------- 1 | // twoslash: { themes: ["../../../packages/typescriptlang-org/lib/themes/typescript-beta-light"], noStaticSemanticInfo: true } 2 | 3 | 4 | 5 | function verify(result) { 6 | if (result === "pass") { 7 | console.log("Passed") 8 | } else { 9 | console.log("Failed") 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/components/index/twoslash/IndexAdoptGrad1.ts: -------------------------------------------------------------------------------- 1 | interface Account { 2 | id: number 3 | displayName: string 4 | version: 1 5 | } 6 | 7 | function welcome(user: Account) { 8 | console.log(user.id) 9 | } -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/components/index/twoslash/IndexAdoptGrad2.ts: -------------------------------------------------------------------------------- 1 | type Result = "pass" | "fail" 2 | 3 | function verify(result: Result) { 4 | if (result === "pass") { 5 | console.log("Passed") 6 | } else { 7 | console.log("Failed") 8 | } 9 | } -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/components/index/twoslash/IndexGetStarted1.js: -------------------------------------------------------------------------------- 1 | // @annotate: left { "arrowRot": "40deg 5px -2px", "textDegree": "3deg", "top": "0.8rem" } - No editor warnings in JavaScript files

This code crashes at runtime! 2 | function compact(arr) { 3 | if (orr.length > 10) 4 | return arr.trim(0, 10) 5 | return arr 6 | } -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/components/index/twoslash/IndexGetStarted2.js: -------------------------------------------------------------------------------- 1 | // @errors: 2304 2 | // @noImplicitAny: false 3 | // @ts-check 4 | // @annotate: left { "arrowRot": "44deg 7px -11px", "textDegree": "-3deg", "top": "1.3rem" } - Adding this to a JS file shows errors in your editor 5 | 6 | function compact(arr) { 7 | // @annotate: right { "arrowRot": "-60deg 1px 2px", "textDegree": "3deg", "top": "5.7rem" } - Discovered a type - the param is arr, not orr! 8 | if (orr.length > 10) 9 | return arr.trim(0, 10) 10 | return arr 11 | } -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/components/index/twoslash/IndexGetStarted3.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | // @errors: 2339 3 | 4 | /** @param {any[]} arr */ 5 | // @annotate: left { "arrowRot": "44deg 4px -12px", "textDegree": "1deg" } - Using JSDoc to give type information 6 | function compact(arr) { 7 | if (arr.length > 10) 8 | return arr.trim(0, 10) 9 | // @annotate: right { "arrowRot": "-64deg 1px 2px", "textDegree": "3deg" } - Now TS has found a bad call. Arrays have slice, not trim. 10 | return arr 11 | } -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/components/index/twoslash/IndexGetStarted4.ts: -------------------------------------------------------------------------------- 1 | // @annotate: left { "arrowRot": "40deg -5px -5px", "textDegree": "-4deg", "top": "0.9rem" } - TypeScript adds natural syntax for providing types 2 | function compact(arr: string[]) { 3 | if (arr.length > 10) 4 | return arr.slice(0, 10) 5 | return arr 6 | } -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/components/index/twoslash/JSDoc.js: -------------------------------------------------------------------------------- 1 | // twoslash: { themes: ["min-dark", "../../../packages/typescriptlang-org/src/components/index/twoslash/homepage"] } 2 | // @errors: 2339 3 | // @ts-check 4 | 5 | /** @param {any[]} arr */ 6 | function compact(arr) { 7 | if (arr.length > 10) return arr.trim(0, 10) 8 | return arr 9 | } 10 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/components/index/twoslash/TS.ts: -------------------------------------------------------------------------------- 1 | // twoslash: { themes: ["min-dark", "../../../packages/typescriptlang-org/src/components/index/twoslash/homepage"] } 2 | function compact(arr: string[]) { 3 | if (arr.length > 10) return arr.slice(0, 10) 4 | return arr 5 | } 6 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/components/index/twoslash/cfa.ts: -------------------------------------------------------------------------------- 1 | // twoslash: { themes: ["min-dark", "../../../packages/typescriptlang-org/lib/themes/typescript-beta-dark"] } 2 | const users = [{ name: "Ahmed" }, { name: "Gemma" }, { name: "Jon" }] 3 | 4 | const jon = users.find(u => u.name === "jon") 5 | 6 | if (jon) { 7 | console.log(jon) 8 | } else { 9 | throw new Error('Could not find user "Jon"') 10 | } 11 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/components/index/twoslash/interface.ts: -------------------------------------------------------------------------------- 1 | // twoslash: { themes: ["min-dark", "../../../packages/typescriptlang-org/src/components/index/twoslash/homepage"] } 2 | declare function getUser(id: number): User 3 | declare function saveUser(id: number, user: User): User 4 | // ---cut--- 5 | interface User { 6 | id: number 7 | firstName: string 8 | lastName: string 9 | role: string 10 | } 11 | 12 | function updateUser(id: number, update: Partial) { 13 | const user = getUser(id) 14 | const newUser = { ...user, ...update } 15 | saveUser(id, newUser) 16 | } 17 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/components/index/twoslash/react.tsx: -------------------------------------------------------------------------------- 1 | // twoslash: { themes: ["min-dark", "../../../packages/typescriptlang-org/src/components/index/twoslash/homepage"] } 2 | import * as React from "react"; 3 | 4 | interface UserThumbnailProps { 5 | img: string; 6 | alt: string; 7 | url: string; 8 | } 9 | 10 | export const UserThumbnail = (props: UserThumbnailProps) => 11 | 12 | {props.alt} 13 | 14 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/components/index/twoslash/showErrors.ts: -------------------------------------------------------------------------------- 1 | // twoslash: { themes: ["min-dark", "../../../packages/typescriptlang-org/src/components/index/twoslash/homepage"] } 2 | // @errors: 2339 3 | const user = { 4 | firstName: "Angela", 5 | lastName: "Davis", 6 | role: "Professor", 7 | } 8 | 9 | console.log(user.name) 10 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/components/index/twoslash/typeDefinitions.tsx: -------------------------------------------------------------------------------- 1 | // twoslash: { themes: ["min-dark", "../../../packages/typescriptlang-org/src/components/index/twoslash/homepage"] } 2 | // @noErrors 3 | // @esModuleInterop 4 | import express from "express" 5 | const app = express() 6 | 7 | app.get("/", function (req, res) { 8 | res.sen 9 | // ^| 10 | }) 11 | 12 | app.listen(3000) 13 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/copy/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Handled by @oss-docs/sync 3 | copy/* 4 | !copy/en 5 | !copy/inYourLanguage.ts 6 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/copy/en/cheatsheets.ts: -------------------------------------------------------------------------------- 1 | export const cheatCopy = { 2 | cht_layout_title: "Cheat Sheets", 3 | cht_layout_description: 4 | "Cheat Sheets covering TypeScript syntax.", 5 | cht_download: "Download Zip", 6 | cht_blurb_1: "Downloadable syntax reference pages for different parts of everyday TypeScript code", 7 | cht_blurb_2: "Learn more about Classes, Interfaces, Types and Control Flow Analysis", 8 | 9 | cht_cfa: "Control Flow Analysis", 10 | cht_interfaces: "Interfaces", 11 | cht_types: "Types", 12 | cht_classes: "Classes", 13 | cht_dl_title: "Download PDFs and PNGs", 14 | cht_dl_subtitle: "To read later or print", 15 | } 16 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/copy/en/dt.ts: -------------------------------------------------------------------------------- 1 | export const dtCopy = { 2 | dt_s_page_title: "Search for typed packages", 3 | dt_s_subtitle: "This page is no longer necessary", 4 | dt_s_read_more: 5 | "The npm and Yarn package registries now include type information for packages. You can read more on: ", 6 | dt_s_read_more_link: 7 | "npm displays packages with bundled TypeScript declarations", 8 | } 9 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/copy/en/en.ts: -------------------------------------------------------------------------------- 1 | import { defineMessages } from "react-intl" 2 | import { navCopy } from "./nav" 3 | import { headCopy } from "./head-seo" 4 | import { docCopy } from "./documentation" 5 | import { indexCopy } from "./index" 6 | import { indexCopy as index2Copy } from "./index2" 7 | import { playCopy } from "./playground" 8 | import { comCopy } from "./community" 9 | import { handbookCopy } from "./handbook" 10 | import { footerCopy } from "./footer" 11 | import { cheatCopy } from "./cheatsheets" 12 | 13 | export const messages = { 14 | ...navCopy, 15 | ...docCopy, 16 | ...headCopy, 17 | ...indexCopy, 18 | ...playCopy, 19 | ...comCopy, 20 | ...handbookCopy, 21 | ...index2Copy, 22 | ...footerCopy, 23 | ...cheatCopy 24 | } 25 | 26 | export const lang = defineMessages(messages) 27 | 28 | export type Copy = typeof lang 29 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/copy/en/footer.ts: -------------------------------------------------------------------------------- 1 | export const footerCopy = { 2 | footer_customize: "Customize", 3 | footer_site_colours: "Site Colours", 4 | footer_code_font: "Code Font", 5 | footer_site_colours_options_system: "System", 6 | footer_site_colours_options_always_light: "Always Light", 7 | footer_site_colours_options_always_dark: "Always Dark", 8 | } -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/copy/en/handbook.ts: -------------------------------------------------------------------------------- 1 | export const handbookCopy = { 2 | handb_prev: "Previous", 3 | handb_next: "Next", 4 | handb_on_this_page: "On this page", 5 | handb_like_dislike_title: "Is this page helpful?", 6 | handb_like_desc: "Yes", 7 | handb_dislike_desc: "No", 8 | handb_thanks: "Thanks for the feedback", 9 | handb_deprecated_title: "This page has been deprecated", 10 | handb_deprecated_subtitle: "This handbook page has been replaced, ", 11 | handb_deprecated_subtitle_link: "go to the new page", 12 | handb_deprecated_subtitle_action: "Go to new page", 13 | handb_experimental_title: "This page contains experimental documentation", 14 | handb_experimental_subtitle: "The contents are about a work in progress topic.", 15 | 16 | } 17 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/copy/en/head-seo.ts: -------------------------------------------------------------------------------- 1 | export const headCopy = { 2 | head_playground_title: 3 | "TS Playground - An online editor for exploring TypeScript and JavaScript", 4 | head_playground_description: 5 | "The Playground lets you write TypeScript or JavaScript online in a safe and sharable way.", 6 | tsconfig_title: "TSConfig Reference - Docs on every TSConfig option", 7 | tsconfig_description: 8 | "From allowJs to useDefineForClassFields the TSConfig reference includes information about all of the active compiler flags setting up a TypeScript project.", 9 | playground_example_prefix: "Playground Example - ", 10 | 11 | head_index_title: "Typed JavaScript at Any Scale", 12 | head_index_description: "Typed JavaScript at Any Scale", 13 | } 14 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/copy/en/index.ts: -------------------------------------------------------------------------------- 1 | export const indexCopy = { 2 | // The index page copy lives at index2.ts 3 | index_releases: "Quarterly Releases", 4 | index_releases_pt1: "Our next release is ", 5 | index_releases_pt2: ", which is planned for ", 6 | index_releases_released: "Released", 7 | index_releases_beta: "Beta", 8 | index_releases_rc: "RC" 9 | } -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/copy/en/nav.ts: -------------------------------------------------------------------------------- 1 | export const navCopy = { 2 | skip_to_content: "Skip to main content", 3 | nav_documentation: "Documentation", 4 | nav_documentation_short: "Docs", 5 | nav_download: "Download", 6 | nav_community: "Community", 7 | nav_playground: "Playground", 8 | nav_playground_short: "Play", 9 | nav_handbook: "Handbook", 10 | nav_tools: "Tools", 11 | nav_search_placeholder: "Search Docs", 12 | nav_search_aria: "Search the TypeScript site", 13 | // let me know if you can't make this work in your lang: 14 | // TypeScript X.Y [stable][between?]Z.Y[beta/rc] 15 | nav_version_stable_prefix: "is now available", 16 | nav_version_between: ", ", 17 | nav_version_beta_prefix: "is currently in beta.", 18 | nav_version_rc_prefix: "has a release candidate to try.", 19 | nav_this_page_in_your_lang: "This page is available in your language", 20 | nav_this_page_in_your_lang_open: "Open", 21 | nav_this_page_in_your_lang_no_more: "Don't show again", 22 | } 23 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/copy/en/tsconfig.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/src/copy/en/tsconfig.ts -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/lib/createInternational.ts: -------------------------------------------------------------------------------- 1 | import { IntlShape } from "react-intl" 2 | 3 | /** 4 | * This will let you define an area for your localization and have typescript 5 | * keep the keys in check 6 | * 7 | * @param intlUseEffect the result of `useIntl()` 8 | */ 9 | export function createInternational( 10 | intlUseEffect: IntlShape 11 | ): (intlKey: keyof NavSection, obj?: any) => string { 12 | return (k, obj) => intlUseEffect.formatMessage({ id: k as string }, obj) 13 | } 14 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/lib/hasLocalStorage.ts: -------------------------------------------------------------------------------- 1 | export const hasLocalStorage = (() => { 2 | try { 3 | return typeof localStorage !== `undefined` 4 | } catch { 5 | return false 6 | } 7 | })(); -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/lib/playgroundURLs.ts: -------------------------------------------------------------------------------- 1 | import { withPrefix } from "gatsby" 2 | 3 | export const getPlaygroundUrls = () => { 4 | // This will get switched out in CI by: 5 | // scripts/cacheBustPlayground.mjs 6 | 7 | // This should always be a single slash string in the codebase: "/" 8 | const commitPrefix = "/" 9 | 10 | return { 11 | sandboxRoot: withPrefix(`/js${commitPrefix}sandbox`), 12 | playgroundRoot: withPrefix(`/js${commitPrefix}playground`), 13 | playgroundWorker: withPrefix(`/js${commitPrefix}playground-worker/index.js`), 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/lib/release-plan.json: -------------------------------------------------------------------------------- 1 | { 2 | "_generated by": "node packages/typescriptlang-org/scripts/getTypeScriptReleaseInfo.js", 3 | "upcoming_version": "4.4", 4 | "iteration_plan_url": "https://github.com/microsoft/TypeScript/issues/44237", 5 | "last_release_date": "2021-05-24T23:00:00.000Z", 6 | "upcoming_beta_date": "2021-06-28T23:00:00.000Z", 7 | "upcoming_rc_date": "2021-08-09T23:00:00.000Z", 8 | "upcoming_release_date": "2021-08-23T23:00:00.000Z" 9 | } 10 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/lib/whenEscape.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Runs the closure when escape is tapped 3 | * @param func closure to run on escape being pressed 4 | */ 5 | export const whenEscape = (func: () => void) => (event: KeyboardEvent) => { 6 | const evt = event || window.event 7 | let isEscape = false 8 | if ("key" in evt) { 9 | isEscape = evt.key === "Escape" || evt.key === "Esc" 10 | } else { 11 | // @ts-ignore - this used to be the case 12 | isEscape = evt.keyCode === 27 13 | } 14 | if (isEscape) { 15 | func() 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/pages/README.md: -------------------------------------------------------------------------------- 1 | ## Default Pages are not really used in this repo 2 | 3 | Only things which are completely unlocalized, like the `/dev/x` pages use this part of Gatsbys. The real pages are 4 | found in [`src/templates/pages`](../templates/pages). 5 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/style/theme.jsonc: -------------------------------------------------------------------------------- 1 | // https://fabricweb.z5.web.core.windows.net/pr-deploy-site/refs/heads/master/theming-designer/index.html 2 | { 3 | "themePrimary": "#187ABF", 4 | "themeLighterAlt": "#f4f9fc", 5 | "themeLighter": "#d3e7f5", 6 | "themeLight": "#aed2ec", 7 | "themeTertiary": "#68aad9", 8 | "themeSecondary": "#2f87c7", 9 | "themeDarkAlt": "#166eac", 10 | "themeDark": "#135d91", 11 | "themeDarker": "#0e446b", 12 | "neutralLighterAlt": "#f8f8f8", 13 | "neutralLighter": "#f4f4f4", 14 | "neutralLight": "#eaeaea", 15 | "neutralQuaternaryAlt": "#dadada", 16 | "neutralQuaternary": "#d0d0d0", 17 | "neutralTertiaryAlt": "#c8c8c8", 18 | "neutralTertiary": "#bab8b7", 19 | "neutralSecondary": "#a3a2a0", 20 | "neutralPrimaryAlt": "#8d8b8a", 21 | "neutralPrimary": "#323130", 22 | "neutralDark": "#605e5d", 23 | "black": "#494847", 24 | "white": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/templates/glossary.scss: -------------------------------------------------------------------------------- 1 | @import "../style/globals.scss"; 2 | 3 | #glossary { 4 | ul.filterable-quicklinks { 5 | display: flex; 6 | flex-direction: row; 7 | align-items: center; 8 | flex-wrap: wrap; 9 | justify-content: center; 10 | 11 | li { 12 | list-style: none; 13 | background-color: #e0e0e0; 14 | padding: 0.3rem 0.3rem; 15 | text-decoration: none; 16 | cursor: pointer; 17 | margin: 0.1rem; 18 | 19 | @media screen and (-ms-high-contrast: active) { 20 | border: 2px solid grey; 21 | } 22 | 23 | &:hover, 24 | &.focus { 25 | background-color: rgb(206, 206, 206); 26 | } 27 | 28 | &:active { 29 | background-color: rgb(173, 173, 173); 30 | } 31 | 32 | a { 33 | text-decoration: none; 34 | color: black; 35 | 36 | &:visited { 37 | color: rgb(80, 80, 80); 38 | } 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/templates/pages/css/grid.scss: -------------------------------------------------------------------------------- 1 | @import "../../../style/globals.scss"; 2 | 3 | .row, 4 | .split-row { 5 | display: flex; 6 | flex-direction: row; 7 | flex-wrap: wrap; 8 | } 9 | 10 | .split-row { 11 | justify-content: center; /* align horizontal */ 12 | align-items: center; /* align vertical */ 13 | 14 | .first { 15 | margin-left: 0; 16 | } 17 | } 18 | 19 | .col1 { 20 | min-width: 250px; 21 | flex: 1; 22 | 23 | padding: 1rem; 24 | } 25 | 26 | .col2 { 27 | flex: 2; 28 | } 29 | 30 | .col1 { 31 | &.first { 32 | margin-left: 20px; 33 | } 34 | 35 | &.last { 36 | margin-right: 0; 37 | } 38 | } 39 | 40 | @media (max-width: $screen-sm) { 41 | // from left to right -> top to down 42 | .container > .row { 43 | flex-direction: column; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/templates/pages/empty.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import { Layout } from "../../components/layout" 3 | import { Intl } from "../../components/Intl" 4 | 5 | type Props = { 6 | pageContext: any 7 | } 8 | 9 | const Index: React.FC = (props) => 10 | 11 |
12 |

This page is intentionally left blank

13 |
14 |
15 | 16 | 17 | export default (props: Props) => 18 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/src/templates/playgroundHandbook.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect } from "react" 2 | import { Layout } from "../components/layout" 3 | 4 | import "./play.scss" 5 | 6 | import { useIntl } from "react-intl"; 7 | import { createInternational } from "../lib/createInternational" 8 | import { headCopy } from "../copy/en/head-seo" 9 | import { Intl } from "../components/Intl" 10 | import { withPrefix } from "gatsby"; 11 | 12 | type Props = { 13 | pageContext: { 14 | lang: string 15 | html: string 16 | name: string 17 | title: string 18 | redirectHref: string 19 | } 20 | } 21 | 22 | const PlaygroundHandbook = (props: Props) => { 23 | return ( 24 |
25 | ) 26 | } 27 | 28 | 29 | 30 | export default (props: Props) => 31 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/.gitattributes: -------------------------------------------------------------------------------- 1 | js/* -diff 2 | css/* -diff 3 | -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/assets/.gitkeep -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/assets/typescript-cheat-sheets.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/assets/typescript-cheat-sheets.zip -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/branding/palette.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/branding/palette.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/branding/ts-lettermark-blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/branding/ts-lettermark-blue.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/branding/ts-lettermark-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/branding/ts-lettermark-white.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/branding/ts-logo-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/branding/ts-logo-128.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/branding/ts-logo-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/branding/ts-logo-256.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/branding/ts-logo-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/branding/ts-logo-512.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/branding/ts-logo-round-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/branding/ts-logo-round-128.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/branding/ts-logo-round-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/branding/ts-logo-round-256.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/branding/ts-logo-round-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/branding/ts-logo-round-512.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/branding/typescript-design-assets.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/branding/typescript-design-assets.zip -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/favicon.ico -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/fonts/CascadiaCode-SemiLight.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/fonts/CascadiaCode-SemiLight.woff2 -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/fonts/CascadiaMono-SemiLight.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/fonts/CascadiaMono-SemiLight.woff2 -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/fonts/DankMono-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/fonts/DankMono-Regular.woff2 -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/fonts/FiraCode-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/fonts/FiraCode-Regular.woff2 -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/fonts/JetBrainsMono-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/fonts/JetBrainsMono-Regular.woff2 -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/fonts/OpenDyslexic-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/fonts/OpenDyslexic-Regular.woff -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/fonts/OpenDyslexicMono-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/fonts/OpenDyslexicMono-Regular.woff -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/fonts/SourceCodePro-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/fonts/SourceCodePro-Regular.woff2 -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/icons/ts-logo-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/icons/ts-logo-512.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/branding/logos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/branding/logos.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/cheatsheets/TypeScript Classes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/cheatsheets/TypeScript Classes.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/cheatsheets/TypeScript Control Flow Analysis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/cheatsheets/TypeScript Control Flow Analysis.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/cheatsheets/TypeScript Interfaces.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/cheatsheets/TypeScript Interfaces.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/cheatsheets/TypeScript Types.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/cheatsheets/TypeScript Types.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/docs/greet_person.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/docs/greet_person.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/index/ts-at-scale.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/index/ts-at-scale.jpg -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/index/ts-conf-keynote.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/index/ts-conf-keynote.jpg -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/index/what-is-new-ts.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/index/what-is-new-ts.jpg -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/index/wrong-ts.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/index/wrong-ts.jpg -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/tools/cheat-sheets.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/tools/cheat-sheets.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/tools/dt-search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/tools/dt-search.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/tools/play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/tools/play.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/tools/tsconfig-ref.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/tools/tsconfig-ref.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/tutorials/aspnet/choosedependencies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/tutorials/aspnet/choosedependencies.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/tutorials/aspnet/createwebapp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/tutorials/aspnet/createwebapp.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/tutorials/aspnet/debugger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/tutorials/aspnet/debugger.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/tutorials/aspnet/downloaddependency.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/tutorials/aspnet/downloaddependency.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/tutorials/aspnet/emptytemplate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/tutorials/aspnet/emptytemplate.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/tutorials/aspnet/namewebapp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/tutorials/aspnet/namewebapp.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/tutorials/aspnet/newfolder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/tutorials/aspnet/newfolder.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/tutorials/aspnet/npm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/tutorials/aspnet/npm.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/tutorials/aspnet/packagejson.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/tutorials/aspnet/packagejson.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/tutorials/aspnet/scripts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/tutorials/aspnet/scripts.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/tutorials/aspnet/taskrunner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/tutorials/aspnet/taskrunner.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/tutorials/aspnet/taskrunnerrefresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/tutorials/aspnet/taskrunnerrefresh.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/tutorials/aspnet/tsconfig.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/tutorials/aspnet/tsconfig.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/tutorials/aspnet/tsfile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/tutorials/aspnet/tsfile.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/tutorials/aspnet/tsgif.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/tutorials/aspnet/tsgif.mov -------------------------------------------------------------------------------- /packages/typescriptlang-org/static/images/tutorials/aspnet/workingsite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/TypeScript-Website/b0e9a5c007b3e953d409f989f6013078bdd363ed/packages/typescriptlang-org/static/images/tutorials/aspnet/workingsite.png -------------------------------------------------------------------------------- /packages/typescriptlang-org/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["./src/**/*"], 3 | "exclude": ["./src/components/index/twoslash/**.*"], 4 | "compilerOptions": { 5 | "target": "esnext", 6 | "module": "commonjs", 7 | "lib": ["dom", "es2017"], 8 | "strict": true, 9 | "esModuleInterop": true, 10 | "noEmit": true, 11 | "jsx": "react", 12 | "skipLibCheck": true, 13 | "noImplicitAny": false, 14 | "resolveJsonModule": true 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - 'packages/*' -------------------------------------------------------------------------------- /serve/README.md: -------------------------------------------------------------------------------- 1 | ## Azure App 2 | 3 | For an App Service App we need an app to host our static content. 4 | 5 | Here is one, it doesn't do much but hosts files inside the public directory. 6 | -------------------------------------------------------------------------------- /serve/index.js: -------------------------------------------------------------------------------- 1 | const handler = require("serve-handler") 2 | const http = require("http") 3 | 4 | const server = http.createServer((request, response) => { 5 | // You pass two more arguments for config and middleware 6 | // More details here: https://github.com/zeit/serve-handler#options 7 | return handler(request, response, { public: "public" }) 8 | }) 9 | 10 | const port = process.env.PORT || 3000 11 | server.listen(port, () => { 12 | console.log("Running at http://localhost:" + port) 13 | }) 14 | -------------------------------------------------------------------------------- /serve/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "node index.js" 4 | }, 5 | "dependencies": { 6 | "serve-handler": "^6.1.2" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /serve/public/index.html: -------------------------------------------------------------------------------- 1 | 2 |

This is a blank file which is overwritten during a deploy

3 | 4 | --------------------------------------------------------------------------------