Deno’s Built-In TypeScript Support Basics Quiz Quiz

Explore core concepts of Deno’s integrated TypeScript functionality with essential questions on configuration, execution, and language features. This quiz helps reinforce key aspects of working with TypeScript directly in the Deno runtime environment.

  1. Automatic TypeScript Compilation

    When running a TypeScript file, what behavior does Deno provide regarding compilation?

    1. It requires a separate build tool for TypeScript
    2. It automatically compiles TypeScript to JavaScript before execution
    3. It only runs JavaScript files by default
    4. It ignores TypeScript type checks

    Explanation: Deno automatically compiles TypeScript files to JavaScript under the hood before running them, ensuring seamless execution. The option stating that Deno only runs JavaScript by default is incorrect, because Deno supports both JavaScript and TypeScript directly. Saying it ignores type checks is not accurate since Deno performs type checking unless explicitly disabled. A separate build tool is not required because compilation happens transparently in Deno.

  2. Entry Point Support

    Which file extensions can Deno execute as entry points with built-in support for TypeScript?

    1. .ts and .js
    2. .exe and .dll
    3. .css and .json
    4. .py and .rb

    Explanation: Deno accepts both .ts (TypeScript) and .js (JavaScript) files as entry points due to its native TypeScript support. The extensions .css and .json are not executable code. Extensions like .exe, .dll, .py, and .rb correspond to other file or language types unsupported as entry points in this context.

  3. Type Checking Flag

    Which Deno CLI flag disables type checking when running TypeScript files?

    1. --disable-types
    2. --fast-run
    3. --no-check
    4. --skip-ts

    Explanation: The --no-check flag instructs Deno to skip type checking for TypeScript files, potentially speeding up execution. There is no --disable-types or --skip-ts flag in the CLI for this purpose. --fast-run is also not a valid flag related to type checking in Deno.

  4. Configuration File Detection

    What is the default configuration file that Deno recognizes for TypeScript options?

    1. tsoptions.txt
    2. package.json
    3. deno.json or deno.jsonc
    4. config.js

    Explanation: Deno looks for deno.json or deno.jsonc files to read its configuration, including TypeScript options. package.json is commonly used in other environments but not by Deno for built-in configuration. The files tsoptions.txt and config.js are not standard configuration files for Deno.

  5. Third-party Compiler Requirement

    Is a third-party TypeScript compiler required to run TypeScript in Deno?

    1. No, because TypeScript support is built-in
    2. No, but only for JavaScript files
    3. Yes, but only for advanced types
    4. Yes, you must install tsc separately

    Explanation: Deno includes built-in support for compiling and executing TypeScript files, so no external compiler is needed. The idea that tsc must be installed separately does not apply when using Deno. Advanced types do not require a different compiler in this setting. The last option refers to JavaScript files, which are already executable.

  6. Type Checking Behavior

    If you run a TypeScript file in Deno without extra flags, what does Deno do regarding type checking?

    1. It skips all type checking by default
    2. It warns about type definitions only
    3. It converts types to strings
    4. It performs type checking automatically

    Explanation: By default, Deno type-checks TypeScript files before execution to ensure type safety. The claim that it skips all type checking is false unless the no-check flag is used. Converting types to strings does not describe what happens. Only warning about type definitions is insufficient to describe Deno’s default behavior.

  7. Importing TypeScript Modules

    How does Deno handle imported TypeScript modules with a .ts extension?

    1. It imports only JavaScript modules
    2. It resolves and compiles them seamlessly
    3. It requires a change to .js extension
    4. It throws an error for .ts imports

    Explanation: Deno can import other TypeScript modules using the .ts extension and will compile them as needed. Restricting imports to JavaScript modules is incorrect because Deno natively handles TypeScript. It does not throw errors when importing .ts files correctly and does not require changing extensions to .js.

  8. Using TypeScript Language Features

    Which TypeScript-specific feature can you safely use in Deno without additional setup?

    1. XML tags as variables
    2. Type annotations in function parameters
    3. Static constructor methods
    4. Python-style indentation

    Explanation: Type annotations are a key TypeScript feature and are supported natively in Deno without extra steps. Python-style indentation and XML tags as variables do not relate to TypeScript syntax. Static constructor methods are not a TypeScript-specific feature.

  9. Configuring TypeScript Strictness

    Where should you configure strict type checking options for Deno projects?

    1. By writing a .env file
    2. Using a settings.js script
    3. Inside deno.json or deno.jsonc under `compilerOptions`
    4. In the package-lock.json file

    Explanation: TypeScript compiler options, including strictness settings, belong under the `compilerOptions` section of deno.json or deno.jsonc for Deno projects. package-lock.json and .env files are unrelated to TypeScript options. A settings.js script is not used for compiler configuration in this setup.

  10. Default TypeScript Output

    When Deno compiles TypeScript internally, what happens to the generated JavaScript files by default?

    1. They are stored in the system’s temp folder
    2. They are kept in memory, not saved to disk
    3. They overwrite the original TypeScript files
    4. They are always saved next to the original files

    Explanation: Deno keeps the transpiled JavaScript in memory and does not write it to disk unless explicitly requested. Saving output files next to the originals or overwriting them does not occur by default. Although a cache may be used, saying they go to the system’s temp folder is imprecise and misleading.