[ error ] ERROR in C:/Users/pkellner/Documents/svcc-pwa2/svcc-server.ts
1:1 All files must be modules when the '--isolatedModules' flag is provided.
> 1 | const jsonServer = require('json-server');
| ^
2 | const server = jsonServer.create();
3 | const router = jsonServer.router('db.json');
4 | const middlewares = jsonServer.defaults();
[DEBUG] pwa2: server.ts:asyncMiddleware called req.url:/presenter/2019/guinder-bhangoo-46187
It's odd because that file, svcc-server.ts has nothing to do with next but the problem happened when I upgraded my package.json to 9.0.1 and ran the package.
I followed the suggestion of setting --isolatedModules to false, that fixed my svcc-server.ts file to run but then next time I ran my next custom javascript server, it re-wrote my custom --isolatedModules flag (at least it told me, but seems pretty sneaky).
The following changes are being made to your tsconfig.json file:
- compilerOptions.isolatedModules must be true (requirement for babel)
I also ran into trouble with this when upgrading, as we had Jest tests that weren't modules. The isolatedModules setting means every file must be a module (i.e. have at least one export statement in them). You should be able to fix it by adding a simple export default undefined to your svcc-server.ts file if it has no export currently.
Hey! We're really sorry about this -- however, this is a requirement because we use Babel.
If this option is not set, small bugs will appear in your application that would otherwise work in real TypeScript.
You can fix it by exporting something from your custom server, e.g. export default undefined.
You could also exclude this file from type checking in your tsconfig.json, then create a tsconfig.server.json which includes only your server files and extends from tsconfig.json.
I must confirm that this is still an issue.
Following @Timer suggestion of:
You could also exclude this file from type checking in your tsconfig.json, then create a tsconfig.server.json which includes only your server files and extends from tsconfig.json.
Does not fix the problem. Tslint ignores this setting and still shows the error:
Parsing error: If "parserOptions.project" has been set for @typescript-eslint/parser, ...\next.config.js must be included in at least one of the projects provided. eslint
Including or excluding the file in tsconfig.json is completely ignored.
By automatically setting isolatedModules we can't use composite which is required when use ts references, which are themselves useful for monorepo structure.
Any workaround for that?
Any progress on this?
TS 3.8 might help with this isolatedModules issue.
https://devblogs.microsoft.com/typescript/announcing-typescript-3-8/#type-only-imports-exports

fack...
Most helpful comment
Hey! We're really sorry about this -- however, this is a requirement because we use Babel.
If this option is not set, small bugs will appear in your application that would otherwise work in real TypeScript.
You can fix it by exporting something from your custom server, e.g.
export default undefined.You could also exclude this file from type checking in your
tsconfig.json, then create atsconfig.server.jsonwhich includes only your server files and extends fromtsconfig.json.