Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript errors in editor.api.d.ts typings #757

Closed
timkendrick opened this issue Mar 14, 2018 · 3 comments
Closed

TypeScript errors in editor.api.d.ts typings #757

timkendrick opened this issue Mar 14, 2018 · 3 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority
Milestone

Comments

@timkendrick
Copy link
Contributor

timkendrick commented Mar 14, 2018

Really excited to be using the new webpack build of monaco-editor! I've been trying to use it as part of a library that emits type declarations, and it looks like the shipped typings are broken – see below for details (and a possible fix?)

monaco-editor version: 0.11.0
Browser: N/A
OS: macOS 10.13.3
Steps or JS usage snippet reproducing the issue:

mkdir temp && cd temp
npm init -y
npm install -D typescript monaco-editor

# Write a simple index file that reexports some of the monaco types
echo "export { Selection } from 'monaco-editor';" > index.ts

# Attempt to compile with declarations
./node_modules/.bin/tsc --declaration index.ts

Compilation fails with following errors:

node_modules/monaco-editor/esm/vs/editor/editor.api.d.ts(766,1): error TS1046: A 'declare' modifier is required for a top level declaration in a .d.ts file.
node_modules/monaco-editor/esm/vs/editor/editor.api.d.ts(5295,43): error TS2503: Cannot find namespace 'monaco'.
node_modules/monaco-editor/esm/vs/editor/editor.api.d.ts(5296,43): error TS2503: Cannot find namespace 'monaco'.

...it seems this is related to this commit that introduces some manual text manipulation to the monaco.d.ts file and saves it as editor.api.d.ts.

I'm not sure exactly what's going on here, but I got the above example to compile properly by ignoring the editor.api.d.ts and doing the following:

# Add "export = monaco;" to the end of monaco.d.ts
echo "export = monaco;" >> node_modules/monaco-editor/monaco.d.ts

# Change the package.json to use the typings in monaco.d.ts, not editor.api.d.ts
sed -i .bak 's/esm\/vs\/editor\/editor.api.d.ts/monaco.d.ts/' node_modules/monaco-editor/package.json

# Now compiles fine!
./node_modules/.bin/tsc --declaration index.ts
@corbinu
Copy link

corbinu commented Mar 14, 2018

I am seeing this exact error

@alexdima alexdima added this to the February 2018 milestone Mar 15, 2018
@alexdima alexdima added bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority labels Mar 15, 2018
@alexdima alexdima self-assigned this Mar 15, 2018
@alexdima
Copy link
Member

Thanks for the heads up. Just published 0.11.1

@timkendrick
Copy link
Contributor Author

Works great, thanks for the speedy fix!

@vscodebot vscodebot bot locked and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority
Projects
None yet
Development

No branches or pull requests

3 participants