-
-
Notifications
You must be signed in to change notification settings - Fork 543
Description
We tell the typechecker that node builtin modules are available in the REPL without importing, using declare import assert = require('assert');
Implemented in #1500
Unfortunately, swc cannot parse declare import
and it seems this is because it's technically invalid TS. It achieves the desired effect when using the TS compiler -- we use @ts-ignore
to suppress the error -- but I think we'll need to disable it for swc and any third-party transpilers.
We should also consider test coverage of the REPL with swc.
An alternative syntax I considered when writing #1500:
declare const fs: typeof import('fs');
// @ts-ignore
import type * as fs from 'fs';
I decided against it because if you subsequently attempt to const fs = 123;
you get a type error.
Thinking we'll have to keep the syntax as-is, but disable it when in transpileOnly
mode. Implementation notes: since transpileOnly
mode is implied by other options, such as swc
, we must make sure we have the real answer when checking transpileOnly === true
in the REPL.