-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
Unexpected [ts] errors in JavaScript files #54261
Comments
TypeScript powers our javascript language support as well. Please share the text of the code along with screenshots |
I shared screenshots in the first issue message. This errors seems to show in different places, without any logic. while (document.querySelector('.ingredientList').children.length > 0) {
document.querySelector('.ingredientList').removeChild(document.querySelector('.ingredientList').children[0]);
} The word 'document' is underlined, and [ts] errors says: |
I can't repo this. Does this reproduce in the latest VS Code insiders build with all extensions disabled? Also, do the errors go away if you edit the document? (just try adding whitespace somewhere) |
@davidcoleman007 is absolutely right. @mjbvz I have a lot of [ts] errors in JSX syntax but also in normal JavaScript code. The error occurs with all extensions disabled. Sometimes when I close document and open it again errors disappears, sometimes not. |
@davidcoleman007 Our built-in js support only the current ecmascript standard. If you are using proposed syntax like do notation, at the very least you must set @donacellos Please provide a complete example of your code as text |
I too am getting lots of ts errors in my js code. VScode used to be the best editor, now it is a heaping pile of bugs. |
@mjbvz Errors are in almost EVERY code in my projects - missing semicolons on comments, missing while operator in the middle on string etc. When I close VS Code they disappears, as I type new stuff they appear again in completely different places. Now, in macOS Activity Monitor, I saw that Code process takes 100% CPU. Next strange behaviour. @marktellez is right. |
@marktellez The example code you shared is invalid JavaScript. The @donacellos Please provide a complete example of your code as text |
@mjbvz why do i have to disable the entire feature? Can't i just turn off THAT error rule. It's not even typescript. why do I have to deal with ts lint issues in a JS file? I have properly configured my eslint to handle do expressions. TSlint should allow me to do the same, and disable that rule. As a matter of fact, to my previous point, I should be able to opt to not do ANY tslint-ing in my js files, I like the ts intellisense. In fact it's one of the most appealing features of the editor. |
Example of JS export default () => {
if (process.env.NODE_ENV !== 'development' && 'serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/service-worker.js').then((registration) => {
console.log('SW registered: ', registration);
}).catch((registrationError) => {
console.log('SW registration failed: ', registrationError);
});
});
}
}; Example of JSX const App = () => (
<Provider store={store}>
<BrowserRouter>
<Aux>
<Header />
<div className="container">
<Switch>
<Route exact path="/" component={RentalList} />
<Route exact path="/search/:city" component={RentalSearchList} />
<ProtectedRoute exact path="/create" component={RentalCreate} />
<ProtectedRoute exact path="/manage/rentals" component={RentalManage} />
<ProtectedRoute exact path="/manage/bookings" component={BookingManage} />
<LoggedInRoute exact path="/login" component={Login} />
<LoggedInRoute exact path="/register" component={Register} />
<Route exact path="/rentals/:id" component={RentalDetail} />
</Switch>
</div>
</Aux>
</BrowserRouter>
</Provider>
); You are having troubles with [ts] errors in pure JavaScript? Disable whole JavaScript validation feature. Seems legit, great support. |
lol, I was working for MS in Redmond and Intel in Portland writing com, dcom, com+ and for that matter, javascript before you were even born.
```
const Gene = () => ({
value: null,
type: null,
fitness: -1,
})
module.exports = Gene
```
is absolutely valid js and a much more concise example than the mess you show.
I uninstalled (deleted the binary) and redownloaded and reinstalled and reinstalled my plugins and the problem went away. Before I uninstalled and reinstalled my extensions weren’t even showing in the extensions pane.
Perhaps you should take input from users instead of blaming them.
Mark Tellez
Technology Consultant
marktellez.com
codementor.io/marktellez
FREE ReactJS Screencasts: https://www.youtube.com/channel/UCx4a8EMmXx-6RuJlyAKASoQ
… On Jul 21, 2018, at 11:01 AM, Donie ***@***.***> wrote:
@marktellez <https://github.com/marktellez>
Example of JS
export default () => {
if (process.env.NODE_ENV !== 'development' && 'serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/service-worker.js').then((registration) => {
console.log('SW registered: ', registration);
}).catch((registrationError) => {
console.log('SW registration failed: ', registrationError);
});
});
}
};
Example of JSX
const App = () => (
<Provider store={store}>
<BrowserRouter>
<Aux>
<Header />
<div className="container">
<Switch>
<Route exact path="/" component={RentalList} />
<Route exact path="/search/:city" component={RentalSearchList} />
<ProtectedRoute exact path="/create" component={RentalCreate} />
<ProtectedRoute exact path="/manage/rentals" component={RentalManage} />
<ProtectedRoute exact path="/manage/bookings" component={BookingManage} />
<LoggedInRoute exact path="/login" component={Login} />
<LoggedInRoute exact path="/register" component={Register} />
<Route exact path="/rentals/:id" component={RentalDetail} />
</Switch>
</div>
</Aux>
</BrowserRouter>
</Provider>
);
You are having troubles with [ts] errors in pure JavaScript? Disable whole JavaScript validation feature. Seems legit, great support.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#54261 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AVchh_2m7KaTVy8MWRfs2cLfm2gDcidTks5uI1B0gaJpZM4VPBgt>.
|
@davidcoleman007 we cannot provide intellisense if we can’t parse your code. Thats one tradeoff of using experimental language features |
@donacellos And that code in a blank file show errors for you? Can you share the code from your original screenshots too |
Also @marktellez, cut it out. I'm just trying to help you. According to github email notifications at least, the first snippet you posted (and then deleted at some point) was: const Gene = () = ({
value: null,
type: null,
fitness: -1,
})
export default Gene If you are still seeing problems, open a new issue with your code and I'll take a look |
folllowing this convo and I agree that we should keep it professional. We are trying to work towards improving vs code for ourselves and everyone else who uses it. steps off soapbox @mjbvz is there ANY chance that I could disable the ts unused expressions rule some how, and let the intellisense just not work in those blocks, but work for the rest of the file w/o throwing a bunch of red all over the place? or maybe there is some api that allows me to build in the code from babel stage 0/1 into vscode to extend it much the way the community has done for eslint? |
@davidcoleman007 Yes the two settings you want are |
Thank you. I will try this when I get a moment over the next day or 2. |
Just wanted to +1 this issue. I've been seeing it for over a month now and haven't been able to hone in on reliable steps to reproduce. Sometimes restarting vscode fixes it for a short period of time, other times it does not. I've tried disabling all extensions but it still happens. Also, this is a dupe of #53247 which was recently closed (unfortunate) due to lack of STR. Edit: I'm also finding that the file type doesn't matter. Happens with both Javascript and Javascript React. |
@mjbvz Can't you understand that this is not able to reproduce? Errors appear in random places, random files (JavaScript, JavaScript React, even Markdown sometimes) and random code parts. They sometimes disappears after closing document or adding new character to it, sometimes they don't. Sometimes I have to select all code and simply cut&paste it to get rid of these errors. My original screenshoots from first issue message - they do not appear anymore. Now they appear in other places. I think @ehynds talks about the same problems. |
This definitely seems to be related to performance issues (memory leak in |
+1 to the issue. Just created index.js and put there |
My javascript files are covered in [ts] errors because we use experimentalDecorators, which I have enabled for javascript in the settings. I have disabled every typescript and javascript setting I can find and I haven't been able to open a file without getting blasted with a million [ts] errors since 2 or 3 updates ago. No one on my team has been able to get them to go away either. This is a problem on Windows 10 and Mac (idk what versions). After the first update where this was an issue, I downloaded the nightly build, copied over my settings and installed all my plugins, and it worked just fine. Haven't tried a recent nightly build though. If I type
|
@JourdanClark , sorry to disappoint you, but that does nothing at all in my case! As if VS Code just ignores those settings! That stubborn & stupid error is still there ((. But thanks for interesting point about experimental decorators. Got rid of some errors in other files. |
@justintemps Dude, this setting is connected with TSLint extension, this errors appears on default VSCode TS/JS checking. |
Im also seeing TS errors across JS files 🤔 I don't have any TS linting extensions installed. |
@donacellos Please try collecting the TS Server log using VS Code 1.27:
Please share the log file from a session that had the errors in the wrong place
|
This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines. Happy Coding! |
@mjbvz Is there a way to disable javascript validation, but preserve the "showUnused" functionality? VSCode is throwing a [ts] error because of the :: operator, and I want to kill those, but keep the 'fading out' of unused variables (inherited a messy codebase). I tried |
@garretteklof I finally figured out how to disable the [ts] errors. Go to Extension view, search for Edit: Keep in mind that this disables the built in linting. That is fine in my case because I rely on the ESLint plugin to do my linting, but if you don't have something like that set up then you'll probably want to set up ESLint or some other linting tool when you disable what VSCode ships with. |
@JourdanClark thanks a lot for the reply -- that looks like a possible alternative to |
@mjbvz Here is the section of my tsserver.log that mentions the [ts] errors. The code I was working on is for an Udemy class on Gulp. Does this shed any light on the scenario? These errors are causing a lot of visual noise and are crowding out actual errors in the code. I can confirm that when I disable the 'TypeScript and JavaScript Language Features' version 1.0.0 built in extension that the errors go away. However, I really like the JavaScript language features. It would be nice to not pair both languages in the same extension. Below you can see in the image a bunch of [ts] errors. Some are on the 'require' statement and others on the 'require' parameters. On a side note, why did this issue close 5 days ago? I see the latest comment before the closing of this ticket was 13 days ago. That means only 8 days passed before this ticket closed. tsserver.log:
gulpfile.js:
|
The hint to disable "TypeScript and JavaScript Language Features" extension did help in may case as well, but the hint itself is next to something like "To avoid such errors just stop using VS Code and switch to another editor". No go, sorry. And I don't understand why is this issue not the one of high priority ones still. It's ruining VS Code experience completely. Imagine if in PHP files it would pop Symphony or Laravel errors without having latter ones even installed. Nonsense! |
While disabling the "TypeScript and JavaScript Language Features" extension resolved the issue, upgrading to VSCode 1.27.2 also seems to do the trick. |
Nope, 1.27.2 has nothing to do with that. Only disabling the extension helps. |
After upgrading to 1.27.2 and enabling "TypeScript and JavaScript Language Features", I no longer get [ts] errors when using optional chaining, ie
@illusive-man What error are you getting? Can you provide an example of some code that is giving you the error? You have upgraded to 1.27.2, correct (you can check your version by going to Edit: In 1.27.2 (With "TypeScript and JavaScript Language Features" enabled) I am unable to replicate the error you get from |
@JourdanClark @illusive-man @david-middleton-at-resolver , |
@JourdanClark, please, mate - don't tell me how to check software version. It's kinda stupid. If I told you that in 1.27.2 I still have that [ts] error it means that (surprise!) in 1.27.2 I still have that [ts] error. :) @Jikodis, no need to tell that to me, I'm in the same boat! ) |
User.test.js: import mongoose from 'mongoose';
import User from '../../../server/models/User';
require('dotenv').config();
const { MONGO_URL_TEST } = process.env;
describe('slugify', () => {
beforeAll(() = {
mongoose.connect(MONGO_URL_TEST);
});
test('no duplication', () => {
expect.assertions(1);
return User.remove()
.then(() => User.signInOrSignUp({
googleId: 'test1',
email: 'test1@test.ts',
googleToken: { accessToken: 'test1', refreshToken: 'test1' },
displayName: 'Test Name',
avatarUrl: 'test1',
}))
.then((user) => {
// console.log('user created', user);
expect(user.slug).toBe('test-name');
});
});
}); typo in |
I'm on VSC 1.28.1 (macOS 10.13.6).
which finally resolved the nonsensical TS linting suggestions from my es6 projects. |
|
Disabling extensions seems not change anything.
Of course, I have chosen 'JavaScript' language mode.
The text was updated successfully, but these errors were encountered: