Missing imports/exports for emitter-framework
I am working on some language emitters and ran into an issue trying to use the new emitter-framework. Specifically it looks like there are missing imports/exports that cause compiler errors when trying to build a new emitter using it.
When I followed the example in the documentation I was missing at least the CodeTypeEmitter type and the code tag. I was able to hand hack the index.js and index.ts.d files to export these and everything then worked fine.
I am assuming it is just a missing set of exports in the index.ts file.
This is working for me in a separate project:
import { CodeTypeEmitter, code } from "@typespec/compiler/emitter-framework";
Are you perhaps missing the /emitter-framework suffix in the import?
Looks like the docs don't point this out that emitter-framework exports are separated like that so we should fix that.
Hmm, that is odd. I just copy pasted that import and see the same errors.
I have a public repo that I setup where this reproduces: Github repro (https://github.com/BosqueLanguage/TypeSpecToBosque)
Platform is: Ubuntu: 22.04 Node: 16.14.0 TSC: 4.7.4
TypeSpec NPM package: 0.42.0 (and 0.41.0)
@marron-at-work Ah, thanks for the repro! Try changing "moduleResolution" in tsconfig.json from "node" to "node16". That fixed it for me.
Ah, hmm, it got rid of squiggle in the IDE, but build is still failing. Continuing to look.
Same here but then I updated to TS 5.0 and it now builds too.
😀 Yep, I also just discovered that it was because I had TS 4.8.4 on global path. FWIW, turns out 4.9.x is sufficient and that's what we're on.
Consider putting a "devDependency" on "typescript" in package.json so that build can always use the version you specify.
Note to self, cover this in docs:
- [ ]
/emitter-frameworkin imports - [ ] "node16" moduleResolution in tsconfig.json
- [ ] typescript minimum version 4.9.x
Great, I think this resolves everything for me. It sounds like you have some documentation items open from this so I'll leave it for you close it as needed.
Thanks again!
est: 2