The following code is from the README of the Deno Chalk library. Deno/Typescript will not let it pass:
import chalk from "https://deno.land/x/chalk_deno@v4.1.1-deno/source/index.js";
// Run this in debugger and it's fine but it won't compile:
console.log(chalk.blue("Hello world!"));
console.log(eval("typeof chalk.blue"), "At runtime it's fine!");
Output:
error: TS2339 [ERROR]: Property 'blue' does not exist on type '{ (...arguments_: any[]): string; Chalk: typeof Chalk; }'. console.log(chalk.blue("Hello world!"));
Patched:
Commenting out line 3 and it runs fine! So chalk.blue
is available at runtime but invisible to the compiler??
function At runtime it's fine!