Closed amcasey closed 5 years ago
Is that the wrong stack trace? The diagnostic "Expected isNewFile for (only) new files" should only happen in mapTextChangesToCodeEdits
, not tryResuseStructureFromOldProgram
.
Quite possibly - I've been looking at several. Let me confirm.
Fixed - sorry about that.
I'm seeing this error from tsserver in my editor (Vim with YCM) (with almost the same stacktrace) when I have import fs = require('fs');
style import in my Node project (target=es2017
, everything else is the default). Switching to const fs = require('fs')
makes the error go away.
I just found out it only happened when I used import = require
style import on a module without type annotations, but this still looks like a bug -- it shouldn't crash the server. tsc
is still able to tell me to try npm install @types/...
, among other errors.
@Hexcles I'm not able to reproduce this crash using that repro in typescript@next
. I'm testing in a directory that consists of just these files:
a.ts:
import fs = require('fs');
tsconfig.json:
{
"compilerOptions": {
"target": "es2017"
}
}
I've also tested with @types/node
installed but still didn't see a crash.
I assume you're also seeing a diagnostic Import assignment cannot be used when targeting ECMAScript modules.
given those compiler options.
Looking at my tsconfig.json
again there's also module: "commonjs"
which prevents the warning about the import assignment.
However, I can't reproduce the issue any more, either. I'm not sure if my tsc
installation was updated recently. Looks like you initially found the issue from telemetry so you might be able to look at stats to see if the problem has indeed disappeared in recent versions.
I get the same error on 3.3.0-dev
(using YouCompleteMe):
Debug Failure. Expected isNewFile for (only) new files. {"isNewFile":false,"hasScriptInfo":false}
Error: Debug Failure. Expected isNewFile for (only) new files. {"isNewFile":false,"hasScriptInfo":false}
at IOSession.Session.mapTextChangeToCodeEdit (/Users/development/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tsserver/lib/node_modules/typescript/lib/tsserver.js:125567:30)
at /Users/development/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tsserver/lib/node_modules/typescript/lib/tsserver.js:125559:73
at Array.map (<anonymous>)
at IOSession.Session.mapTextChangesToCodeEdits (/Users/development/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tsserver/lib/node_modules/typescript/lib/tsserver.js:125559:36)
at IOSession.Session.mapCodeFixAction (/Users/development/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tsserver/lib/node_modules/typescript/lib/tsserver.js:125555:84)
at /Users/development/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tsserver/lib/node_modules/typescript/lib/tsserver.js:125508:96
at Array.map (<anonymous>)
at IOSession.Session.getCodeFixes (/Users/development/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tsserver/lib/node_modules/typescript/lib/tsserver.js:125508:55)
at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (/Users/development/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tsserver/lib/node_modules/typescript/lib/tsserver.js:124313:61)
at /Users/development/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tsserver/lib/node_modules/typescript/lib/tsserver.js:125676:88
at IOSession.Session.executeWithRequestId (/Users/development/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tsserver/lib/node_modules/typescript/lib/tsserver.js:125667:28)
at IOSession.Session.executeCommand (/Users/development/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tsserver/lib/node_modules/typescript/lib/tsserver.js:125676:33)
at IOSession.Session.onMessage (/Users/development/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tsserver/lib/node_modules/typescript/lib/tsserver.js:125698:35)
at Interface.<anonymous> (/Users/development/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/tsserver/lib/node_modules/typescript/lib/tsserver.js:126958:27)
at Interface.emit (events.js:182:13)
at Interface._onLine (readline.js:290:10)
at Interface._normalWrite (readline.js:433:12)
at Socket.ondata (readline.js:149:10)
at Socket.emit (events.js:182:13)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
at Socket.Readable.push (_stream_readable.js:219:10)
at Pipe.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
I don't get the error when there is no import statement, but as soon as I add import React from 'react'
or const react = require('react')
then it errors.
I installed Visual Studio Code and it somehow fixed this issue for me in vim/ycm.
Closing this as it seems fixed in recent build. @amcasey please reopen if this repros in newer builds.
I see recent hits for getEditsForFileRename
, getEditsForRefactor
, and getCodeFixes
in 3.3.0-dev
, 3.3.0-dev.20190101
, and 3.3.0-dev.20190108
.
@amcasey I think https://github.com/Microsoft/TypeScript/pull/26280 should also fix it. So if any reports of this after 3.3.0-dev.20190109
would qualify for reinvestigation.
I currently see this in Atom with atom-typescript:
⇒ tsc --version
Version 3.3.3
@adammenges Can you please share the tssever log of the issue? Thanks.
@adammenges Please provide complete tsserver log for us to be able to investigate this futher. Thanks. We will open this again when we have more information. Thanks
We have occurrences from 3.0.0-dev to 3.2.0-dev. Here's a stack from 3.1.3: