Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(website): acquired types are shown in the editor but not reflected in linting#11198

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
mdm317 wants to merge3 commits intotypescript-eslint:main
base:main
Choose a base branch
Loading
frommdm317:11120-acquired-types-not-in-linting

Conversation

mdm317
Copy link
Contributor

@mdm317mdm317 commentedMay 9, 2025
edited
Loading

PR Checklist

Overview

I think this issue occurs because of differences in the properties used when creating a ts.Program between Monaco and TypeScript-VFS.

returnvfs.createVirtualTypeScriptEnvironment(

The modules likemonaco, [typescript]
(https://github.com/microsoft/TypeScript), andtypescript-website are scattered, so it’s a bit confusing

1. createts.program by monace

When monaco-editor creating this code will excutelink
private _languageService = ts.createLanguageService(this);

createLanguageService in typescript.link

const rootFileNames = host.getScriptFileNames().slice(); // some codeconst options: CreateProgramOptions = {  rootNames: rootFileNames,  options: newSettings,  host: compilerHost,   oldProgram: program,  projectReferences,};program = createProgram(options);

And filenames output bygetScriptFileNames will be added in the code below.
defaults.addExtraLib(code, path) intypescript-website =>defaults.addExtraLib(code, path) inmonaco

So, when creating a ts.Program, the rootNames array includes some libraries, such as Node or React.

2. createts.program by TypeScript-VFS.

constregisteredFiles=newSet<string>();
constcreateEnv=(
compilerOptions:ts.CompilerOptions,
):tsvfs.VirtualTypeScriptEnvironment=>{
returnvfs.createVirtualTypeScriptEnvironment(
system,
[...registeredFiles],

Unlike case 1 above,We don't pass the name of a node_modules folder in fileNames.

In the sentence above, I modified it so that rootNames are provided when creating thets.Program for both the Editor and Linting

Testing

  1. Click alink that already has code pre-filled.
  2. Enter code in an empty playground

@typescript-eslint
Copy link
Contributor

Thanks for the PR,@mdm317!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently onhttps://opencollective.com/typescript-eslint.

@netlifyNetlify
Copy link

netlifybot commentedMay 9, 2025
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commitf9bd202
🔍 Latest deploy loghttps://app.netlify.com/projects/typescript-eslint/deploys/682da407195f0a00083babd7
😎 Deploy Previewhttps://deploy-preview-11198--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 99 (🟢 up 1 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 98 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to yourNetlify project configuration.

@nx-cloudNx Cloud
Copy link

nx-cloudbot commentedMay 9, 2025
edited
Loading

View yourCI Pipeline Execution ↗ for commitf9bd202.

CommandStatusDurationResult
nx typecheck ast-spec✅ Succeeded<1sView ↗
nx run-many -t build --exclude website website-...✅ Succeeded3sView ↗
nx run-many -t clean --parallel=20✅ Succeeded12sView ↗

☁️Nx Cloud last updated this comment at2025-05-21 16:54:04 UTC

kirkwaiblinger reacted with thumbs up emoji

@kirkwaiblingerkirkwaiblinger changed the titlefix(website): Acquired types are shown in the editor but not reflected in lintingfix(website): acquired types are shown in the editor but not reflected in lintingMay 9, 2025
@codecovCodecov
Copy link

codecovbot commentedMay 19, 2025
edited
Loading

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.92%. Comparing base(e57126a) to head(f9bd202).
Report is 20 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@##             main   #11198   +/-   ##=======================================  Coverage   90.91%   90.92%           =======================================  Files         499      499             Lines       50809    50847   +38       Branches     8369     8384   +15     =======================================+ Hits        46195    46233   +38  Misses       4599     4599             Partials       15       15
FlagCoverage Δ
unittest90.92% <ø> (+<0.01%)⬆️

Flags with carried forward coverage won't be shown.Click here to find out more.

see 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.


system.getScriptFileNames = (): string[] => {
return [...files.keys()]
.filter(fileName => !fileName.startsWith('/lib.'))
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Lib files will be excluded from the Monaco Editor GitHub repository.monaco-editor

  const models = allModels.filter((uri) => !fileNameIsLib(uri)).map((uri) => uri.toString());

system.getScriptFileNames = (): string[] => {
return [...files.keys()]
.filter(fileName => !fileName.startsWith('/lib.'))
.filter(f => !f.endsWith('/.eslintrc') && !f.endsWith('.json'));
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

These files cause an error in the code below.typescript-website

  if (diagnostics.length) {    const compilerHost = createVirtualCompilerHost(sys, compilerOptions, ts)    throw new Error(ts.formatDiagnostics(diagnostics, compilerHost.compilerHost))  }

Comment on lines +110 to +112
registerFile(filePath: string, code: string): void {
compilerHost.createFile(filePath, code);
},
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We have to add library files usingcompilerHost.createFile, because adding them directly to thesystem doesn't make them appear ingetScriptFileNames, and thus they aren't included in therootNames when creating program.typescript-website

export function createVirtualLanguageServiceHost(  sys: System,  rootFiles: string[],  compilerOptions: CompilerOptions,  ts: TS,  customTransformers?: CustomTransformers) {  const fileNames = [...rootFiles]  ...somecode  const languageServiceHost: LanguageServiceHost = {    getScriptFileNames: () => fileNames.slice(),  }  ...somecode}

Comment on lines +169 to +172
const registerFile = (fileName: string, code: string) => {
parser.registerFile(fileName, code);
triggerLintAll();
};
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We need this code to add the library and trigger linting after the parser is created, in case the user starts typing code in an empty playground.

@mdm317mdm317 marked this pull request as ready for reviewMay 21, 2025 16:52
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Bug(website): Acquired types are shown in the editor but not reflected in linting
1 participant
@mdm317

[8]ページ先頭

©2009-2025 Movatter.jp