Closed
Description
Search Terms
tsserverlibrary, untitled, isdynamic
Suggestion
Currently I'm trying to write a language service for typescript and I find myself unable to determine whether a file is untitled.
What I've noticed so far is that untitled files send untitled:^Untitled-1
as its filename to the getSymanticDiagnostics
function. This naming convention could change anytime and also it's not consistently containing an URI or a filepath.
Is there some way to check whether a SourceFile
is untitled?
Use Cases
I'm passing the files to a linter. If the file is untitled I'll get an incorrect results if I pass the filename which, at runtime, equals untitled:^Untitled-1
.
Examples
result = engine.executeOnText(file.getFullText(), ...(file.isUntitled ? [] : [file.fileName]));
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.