-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Setting custom typescript libraries breaks the standard lib #669
Comments
Workaround: use |
Thanks for the workaround! I ran into the same issue back in September: #579 |
Are there any plans to address this issue in the near future? |
@TyOverby , the workaround to use |
@dennis-yemelyanov: you aren't supposed to literally put | the entire source of lib.d.ts |
Ah I see. Was trying to figure out a way do avoid downloading the source myself, but looks like that's the only option for now. |
This bug cost me several hours of confusion today as I tried to understand why neither I'm trying to build a Typescript editor for editing Node.js modules, so I don't want the DOM or other browser-specific stuff. |
For anyone else still having this issue in 2019, here's a work around I came up with for Webpack: // This require context needs typescript as a dev dependency
// Note this will add all of those files to your build even if you don't use them
const ctx = require.context('typescript/lib', true, /\.d\.ts$/)
// Reduce all the .d.ts files to a filename => content object
const allLibs = ctx.keys().reduce(
(acc, k) => {
acc[k] = ctx(k).default
return acc
},
{}
)
monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
target: monaco.languages.typescript.ScriptTarget.ES5,
allowNonTsExtensions: true,
noLib: true,
})
// Add every lib from the typescript source
Object.entries(allLibs).forEach(([filename, content]) => {
// Potentially exclude some libs here
monaco.languages.typescript.typescriptDefaults.addExtraLib(content, filename)
}) |
I'm currently doing the same kind of project. Be aware that using noLib option will kill the typescript inference capabilities. I just opened an issue for that #1673 |
Let's track in #579 |
monaco-editor version: 0.10.1 (and whatever version is on the monaco playground.
Browser: Firefox | Safari
OS: OSX
Steps or JS usage snippet reproducing the issue:
x.
and notice that Array autocomplete does not show up.var x: number[] = [1,2,3]
.x.
and notice that Array autocomplete does not show up.It looks like the only way to get working standard library features like Array is to not use custom
lib
options.The text was updated successfully, but these errors were encountered: