Closed pkellner closed 5 years ago
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...
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 yourtsconfig.json
, then create atsconfig.server.json
which includes only your server files and extends fromtsconfig.json
.
I have read almost every StackOverFlow articles with the same solution, but every time I use this, I am getting error message
SyntaxError: Unexpected token 'export'
at wrapSafe (internal/modules/cjs/loader.js:979:16)
at Module._compile (internal/modules/cjs/loader.js:1027:27)
at Module.m._compile (/usr/local/lib/node_modules/ts-node/src/index.ts:1056:23)
at Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Object.require.extensions.<computed> [as .ts] (/usr/local/lib/node_modules/ts-node/src/index.ts:1059:12)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at main (/usr/local/lib/node_modules/ts-node/src/bin.ts:198:14)
at Object.<anonymous> (/usr/local/lib/node_modules/ts-node/src/bin.ts:288:3)
Anyone here who has a valid ans?
This makes me totally unable to reuse all my ts packages....
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 yourtsconfig.json
, then create atsconfig.server.json
which includes only your server files and extends fromtsconfig.json
.
Another error appeared: SyntaxError: Unexpected token 'export' When I use 'export default undefined'
Any update on this issue?
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Bug report
When I upgrade my working in 8.1.0 project (I use typescript custom express server.ts), I get an error that says
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).