Registry / devops / monaco-typescript

monaco-typescript

JSON →
library4.10.0jsnpmunverified

Monaco-typescript v4.10.0 provides TypeScript and JavaScript language support for the Monaco Editor, including syntax highlighting, IntelliSense, diagnostics, and formatting. It is maintained by Microsoft and ships with bundled TypeScript types. The package is primarily used as a bundled dependency of monaco-editor, not installed standalone. It supports single-file scenarios only and does not support cross-file features like project isolation or rename. Release cadence follows monaco-editor releases, approximately quarterly.

npm install monaco-typescript
INSTALL
IMPORT
SIG · MONACO-TYPESCRIPT
M
monaco-typescript
devopsjavascriptv4.10.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

monaco-typescript
import 'monaco-editor/esm/vs/basic-languages/typescript/typescript.contribution';
import * as monacoTypescript from 'monaco-typescript';
monaco-typescript is not directly importable; it's included via monaco-editor's language contributions. Use the monaco-editor package and import language contributions from its ESM paths.
TypeScript language worker
import 'monaco-editor/esm/vs/language/typescript/monaco.contribution';
import { TypeScriptWorker } from 'monaco-typescript';
The TypeScript worker is part of monaco-editor's core, not monaco-typescript. The recommended way is to include the language contribution, which registers the worker automatically.
monaco.languages.typescript
monaco.languages.typescript.typescriptDefaults.setCompilerOptions({ target: monaco.languages.typescript.ScriptTarget.ES2015 });
monaco.languages.typescript.typescriptDefaults.setOptions(...);
Use `typescriptDefaults` and `javascriptDefaults` for setting compiler options. The API is available on the global `monaco` object after importing the language contribution.

Shows how to set up a Monaco editor with TypeScript language support, set compiler options, and add extra type definitions.

import * as monaco from 'monaco-editor'; import 'monaco-editor/esm/vs/language/typescript/monaco.contribution'; const code = `function greet(name: string) { return \`Hello, \${name}!\`; }`; const editor = monaco.editor.create(document.getElementById('container'), { value: code, language: 'typescript', theme: 'vs-dark' }); // Set compiler options monaco.languages.typescript.typescriptDefaults.setCompilerOptions({ target: monaco.languages.typescript.ScriptTarget.ES2015, allowNonTsExtensions: true, moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs }); // Add extra libs or files monaco.languages.typescript.typescriptDefaults.setExtraLibs([ { content: 'declare module "my-module";', filePath: 'file:///node_modules/@types/my-module/index.d.ts' } ]);
Debug
Known issues
gotchamonaco-typescript is not meant to be installed separately; it is bundled with monaco-editor. Installing monaco-typescript alone will not work as expected.
fix
Use monaco-editor as the dependency; it includes monaco-typescript internally.
affects: >=0
gotchaCross-file features like rename, project isolation, and go-to-definition across files are not supported. Only single-file scenarios work.
fix
For cross-file support, consider using the full TypeScript language service in a custom implementation.
affects: >=0
deprecatedImporting from monaco-editor's old paths (e.g., 'monaco-editor/dev/vs/editor/editor.main') is deprecated in favor of ESM imports from 'monaco-editor/esm/...'.
fix
Use ESM imports: import * as monaco from 'monaco-editor' and then import the language contributions from 'monaco-editor/esm/vs/language/typescript/monaco.contribution'.
affects: >=0.30
gotchaTypeScript version used by monaco-editor is fixed; you cannot easily upgrade TypeScript without rebuilding monaco-editor.
fix
If you need a newer TypeScript version, consider using the official TypeScript playground or building monaco-editor from source with a custom TypeScript version.
affects: >=0
Errors
Common errors & fixes
Cannot find module 'monaco-typescript' or its corresponding type declarations.
monaco-typescript is not a standalone installable module; it's bundled with monaco-editor.
fix
Install monaco-editor and import from 'monaco-editor' instead of 'monaco-typescript'.
Monaco editor: Cannot read properties of undefined (reading 'typescriptDefaults')
The TypeScript language contribution was not imported before accessing monaco.languages.typescript.
fix
Import 'monaco-editor/esm/vs/language/typescript/monaco.contribution' before using the API.
TypeScript language features not working (no IntelliSense, no diagnostics)
Missing or incorrect configuration of compiler options or extra libs.
fix
Ensure you set compiler options via typescriptDefaults.setCompilerOptions and provide necessary type definitions via setExtraLibs.
Upgrade
Version history
4.10.0latest on npm
Audit
Dependencies
monaco-editoroptionalmonaco-typescript is typically bundled with monaco-editor and not used standalone. Users should install monaco-editor instead.
Agent activity
9 hits · last 30 days
node
8
Resources
monaco-typescript — npm install monaco-typescript · libregistry