question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] lazily adding extra libs did not trigger re-validation of semantic

See original GitHub issue

Reproducible in vscode.dev or in VS Code Desktop?

  • Not reproducible in vscode.dev or VS Code Desktop

Reproducible in the monaco editor playground?

Monaco Editor Playground Code

monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
    // I don't want to disable semantic validation.
	noSemanticValidation: false,
	noSyntaxValidation: false
});

function addLib() {
    console.log('adding lib...');
    // extra libraries
    var libSource = [
        'declare class Facts {',
        '    /**',
        '     * Returns the next fact',
        '     */',
        '    static next():string',
        '}'
    ].join('\n');
    var libUri = 'ts:filename/facts.d.ts';
    monaco.languages.typescript.typescriptDefaults.addExtraLib(libSource, libUri);
    monaco.editor.createModel(libSource, 'typescript', monaco.Uri.parse(libUri));
}

var jsCode = [
	'"use strict";',
	'',
	'class Chuck {',
	'    greet() {',
	'        return Facts.next();',
	'    }',
	'}'
].join('\n');

monaco.editor.create(document.getElementById('container'), {
	value: jsCode,
	language: 'typescript'
});

// `setEagerModelSync` would not help here.
// monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);

// Simulate adding libs lazily.
setTimeout(addLib, 2000);
// Changing timeout to `0` will make it work.

Actual Behavior

It shows Cannot find name 'Facts' while it shows class Facts above which indicates the lib has been loaded.

And when I make any edits, the error disappears.

image

I tried add monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true) but it didn’t help.

I think a re-validation of semantic should be done automatically after adding libs. Or Monaco should expose an API to do this.

Expected Behavior

Expect the error message disappears after libs loaded.

Additional Context

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
hedietcommented, Feb 3, 2022

Could you please fix npm publish job so that we could test the change asap?

Done.

Repo owners?

Yes

1reaction
mifopencommented, Jan 27, 2022

@alexdima Could you provide your estimates on this? Or maybe any workarounds? We’re heavily relying on this and can’t downgrade as several other bugs were resolved in the new version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Semantic-UI avoid trigger form validation for some click events
My form has some buttons and validation is triggered when any of them is clicked. I need to avoid that from some of...
Read more >
Bug List
Bugzilla – Bug List ... This list is too long for Bugzilla's little mind; ... Code assist to insert method does not work...
Read more >
RELEASE-NOTES - platform/external/e2fsprogs - Git at Google
Fixed e2image -I so it works on image files which are larger than 2GB. Fixed e2fsck's handling of directory inodes with a corrupt...
Read more >
Ember Changelog - GitHub
#19868 [BUGFIX] Fix a bug with the implicit injections deprecation that meant injecting a store to avoid the deprecation did not work.
Read more >
Change log for 4.8.43
Bug 2030698: KubePodCrashLooping may fire when pod is not in ... Add changelog for release 1.2 #148; fix: use pv annotation to trigger...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found