```
version (none)
typedef int MyInt;
```
sample.d(2): Error: use alias instead of typedef
This is somewhat unexpected and makes impossible having D1 and D2 code versions in the same module.
Comment #1 by bugzilla — 2015-05-08T03:40:52Z
Since D1 supports using 'alias' instead of 'typedef', it seems to be an easy fix to the source code.
The problem with making D2 accept 'typedef' is I'll get pushback from the community.
Comment #2 by public — 2015-05-08T06:31:21Z
`alias` is not a replacement for `typedef`. Cases when we do want to use alias instead are extremely rare. Proper D2 replacement is struct with `alias this` but for D1 version of code I need to keep typedef (https://www.sociomantic.com/blog/2015/04/d1-d2-part-3-magic-module)
Why the pushback if `typedef` remains an error in D2? Only thing I ask about is checking for this error at later stage so that versioned out code is not checked.
Comment #3 by dlang-bugzilla — 2015-05-08T12:39:33Z
Shouldn't it be possible to work around this using string mixins inside e.g. a TypeDef template? Would probably be easier than wrapping every typedef declaration in a version(D1) block, too.
The win32 bindings maintain D1 compatibility using the above approach.
Comment #4 by dlang-bugzilla — 2015-05-08T12:40:02Z
Oh, I see from the blog post that you already did that.
Comment #5 by public — 2015-05-08T13:00:19Z
Hm, I used it the other way around, to hide D2 grammar from D1 compiler. But you are right, it should be applicable both ways. Will try that.
Comment #6 by public — 2015-05-08T20:50:31Z
Yes, that should work at least for now.
Thanks.
Comment #7 by bugzilla — 2015-05-13T06:20:56Z
Sorry, I had misunderstood what you were asking for. I didn't realize you only wanted it inside a version, and that you wanted to create an actual distinct type.
Glad you found a reasonable workaround.