Deno: 1.3.0: TS Compiler: Assertion Failed on a simple import

Created on 15 Aug 2020  路  6Comments  路  Source: denoland/deno

code:

      const [, scriptProd] = await Deno.compile("index.ts", {
        "index.ts": `
        import test from "./test.js"
        `,
        "test.js": "export default 10;",
      }, {
        module: "esnext",
        target: "esnext",
        resolveJsonModule: false,
        experimentalDecorators: true,
        allowUnreachableCode: false,
        jsx: "preserve",
        jsxFactory: "Ogone.r(",
        inlineSourceMap: false,
        inlineSources: false,
        alwaysStrict: false,
        sourceMap: false,
        strictFunctionTypes: true,
        lib: ["dom", "esnext"],
      });

error:

error: Uncaught Error: Error in TS compiler:
Uncaught AssertionError: Assertion failed.
    at assert (tsc/06_util.js:31:13)
    at buildLocalSourceFileCache (tsc/99_main_compiler.js:846:9)
    at runtimeCompile (tsc/99_main_compiler.js:1634:5)
    at tsCompilerOnMessage (tsc/99_main_compiler.js:1808:24)
    at <compiler>:1:12
    at unwrapResponse (rt/10_dispatch_json.js:24:13)
    at sendAsync (rt/10_dispatch_json.js:75:12)
    at async Object.compile (rt/40_compiler_api.js:55:20)
    at async Ogone.getBuild (Env.ts:243:30)
    at async index.ts:75:21

All 6 comments

you need the "allowJs" compiler option

Tested it also with .ts extension
Same result.

Tested it also with .ts extension

tested what with the .ts extension?

await Deno.compile("index.ts", {
        "index.ts": `
        import test from "./test.ts"
        `,
        "test.ts": "export default 10;",
      }, {

@SRNV Ran into this issue when messing with triple-slash reference syntax. The problem is that "./test.ts" and "test.ts" are two separate files according to the compiler. I鈥檓 not sure how pathing works but the error seems to be an unnamed assertion around here: https://github.com/denoland/deno/blob/master/cli/tsc/99_main_compiler.js#L834.

you need the "allowJs" compiler option

@SRNV you need to manually pass allowJs: true option, otherwise .js sources won't be resolved and checked properly.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ry picture ry  路  3Comments

watilde picture watilde  路  3Comments

ry picture ry  路  3Comments

benjamingr picture benjamingr  路  3Comments

motss picture motss  路  3Comments