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.
When running a TypeScript file, what behavior does Deno provide regarding compilation?
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.
Which file extensions can Deno execute as entry points with built-in support for TypeScript?
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.
Which Deno CLI flag disables type checking when running TypeScript files?
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.
What is the default configuration file that Deno recognizes for TypeScript options?
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.
Is a third-party TypeScript compiler required to run TypeScript in Deno?
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.
If you run a TypeScript file in Deno without extra flags, what does Deno do regarding type checking?
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.
How does Deno handle imported TypeScript modules with a .ts extension?
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.
Which TypeScript-specific feature can you safely use in Deno without additional setup?
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.
Where should you configure strict type checking options for Deno projects?
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.
When Deno compiles TypeScript internally, what happens to the generated JavaScript files by default?
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.