Assuming you just want the end result you've asked about and aren't specifically trying to use TypeScript's module syntax, you can simplify a bit and then have a couple of options.
The simplification is that you don't need those export module mylib { /* ... */ } wrappers in Foo.ts and Bar.ts, just:
export class Foo
// ...
}
and
export class Bar
// ...
}
Then it becomes a question of how you want those imported from index.ts.
Module namespace object
What you have now in index.ts is actually just fine for one way it could be used: It creates two named exports, Foo and Bar. If you want to write code using those via a mylib object, you can create that on import:
import * as mylib from "../src";
// ^^^^^^^^^^
That import syntax says "Import the module namespace object for the module and assign it to a binding called mylib." If the module namespace object doesn't already exist for that module, it'll be created.
Usage once it's imported is as shown in the question, mylib.Foo etc.
But doing it that way, it's also possible to use import { Foo } from "../src"; and/or import { Bar } from "../src";. Normally that's a good thing, but if you don't want to allow that, you won't want to do individual named exports.
Note that import * as mylib will defeat tree-shaking, if that's important to what you're doing. (Which is part of why import { Foo } and such are normally a good thing.) But it's the person using your library who makes that decision; your library doesn't prevent tree-shaking by itself.
Export an object
If you don't want to do the module namespace object approach above, you could export an object from index.ts:
export const mylib = { Foo, Bar };
...or perhaps export it frozen so properties can't be added, removed, or reassigned:
export const mylib = Object.freeze({ Foo, Bar });
Then import is as you've shown it in the question:
import { mylib } from "../src";
And usage is mylib.Foo etc.
Beware that this defeats tree-shaking, and not just based on how users use it, but at the library level (by not having Foo and Bar exports people could use instead). I wouldn't recommend it.
Both
Finally, you could support both named individual exports and a single named object export. In that case, the exports in index.ts would look like this:
export { Foo, Bar };
export const mylib = Object.freeze({Foo, Bar});
If you do that, you leave it up to people using the code whether to use import { Foo } or import { mylib }. That keeps the library friendly to tree-shaking, while also providing a named export for the library as a whole if that's useful.
modulesyntax, specifically, as opposed to modern standard JavaScript module syntax? (You're mixing the two above currently.)