Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit e5acc74

Browse files
keyboardDrummerfelixfbecker
authored andcommitted
feat(typescript): support TypeScript 3.0 (#500)
Closes #495
1 parent 50df375 commit e5acc74

File tree

4 files changed

+37
-36
lines changed

4 files changed

+37
-36
lines changed

package-lock.json

Lines changed: 18 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"rxjs": "^5.5.0",
5252
"semaphore-async-await": "^1.5.1",
5353
"string-similarity": "^1.1.0",
54-
"typescript": "2.8.3",
54+
"typescript": "3.0.1",
5555
"vscode-jsonrpc": "^3.3.1",
5656
"vscode-languageserver": "^4.2.1",
5757
"vscode-languageserver-types": "^3.0.3"
@@ -82,8 +82,8 @@
8282
"sinon": "^5.0.0",
8383
"source-map-support": "^0.5.0",
8484
"temp": "^0.8.3",
85-
"tslint": "^5.8.0",
86-
"tslint-language-service": "^0.9.6",
85+
"tslint": "^5.11.0",
86+
"tslint-language-service": "^0.9.9",
8787
"validate-commit-msg": "^2.12.2"
8888
},
8989
"bin": {

src/test/typescript-service-helpers.ts

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2325,18 +2325,7 @@ export function describeTypeScriptService(
23252325
' readonly COMMENT_NODE: number;',
23262326
' readonly DOCUMENT_FRAGMENT_NODE: number;',
23272327
' readonly DOCUMENT_NODE: number;',
2328-
' readonly DOCUMENT_POSITION_CONTAINED_BY: number;',
2329-
' readonly DOCUMENT_POSITION_CONTAINS: number;',
2330-
' readonly DOCUMENT_POSITION_DISCONNECTED: number;',
2331-
' readonly DOCUMENT_POSITION_FOLLOWING: number;',
2332-
' readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number;',
2333-
' readonly DOCUMENT_POSITION_PRECEDING: number;',
2334-
' readonly DOCUMENT_TYPE_NODE: number;',
2335-
' readonly ELEMENT_NODE: number;',
2336-
' readonly ENTITY_NODE: number;',
2337-
' readonly ENTITY_REFERENCE_NODE: number;',
2338-
' readonly NOTATION_NODE: number;',
2339-
' readonly PROCESSING_INSTRUCTION_NODE: number;',
2328+
' ... 12 more ...;',
23402329
' readonly TEXT_NODE: number;',
23412330
'}',
23422331
].join('\n'),
@@ -2367,11 +2356,11 @@ export function describeTypeScriptService(
23672356
uri: 'git://github.com/Microsoft/TypeScript?v' + ts.version + '#lib/lib.dom.d.ts',
23682357
range: {
23692358
start: {
2370-
line: 9378,
2359+
line: 10275,
23712360
character: 10,
23722361
},
23732362
end: {
2374-
line: 9378,
2363+
line: 10275,
23752364
character: 14,
23762365
},
23772366
},
@@ -2380,11 +2369,11 @@ export function describeTypeScriptService(
23802369
uri: 'git://github.com/Microsoft/TypeScript?v' + ts.version + '#lib/lib.dom.d.ts',
23812370
range: {
23822371
start: {
2383-
line: 9429,
2372+
line: 10326,
23842373
character: 12,
23852374
},
23862375
end: {
2387-
line: 9429,
2376+
line: 10326,
23882377
character: 16,
23892378
},
23902379
},

src/typescript-service.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ export class TypeScriptService {
12521252

12531253
const details = configuration
12541254
.getService()
1255-
.getCompletionEntryDetails(fileName, offset, entryName, undefined, undefined)
1255+
.getCompletionEntryDetails(fileName, offset, entryName, undefined, undefined, undefined)
12561256

12571257
if (details) {
12581258
item.documentation = ts.displayPartsToString(details.documentation)
@@ -1307,9 +1307,9 @@ export class TypeScriptService {
13071307
params.position.character
13081308
)
13091309

1310-
const signatures: ts.SignatureHelpItems = configuration
1310+
const signatures: ts.SignatureHelpItems | undefined = configuration
13111311
.getService()
1312-
.getSignatureHelpItems(filePath, offset)
1312+
.getSignatureHelpItems(filePath, offset, undefined)
13131313
if (!signatures) {
13141314
return { signatures: [], activeParameter: 0, activeSignature: 0 }
13151315
}
@@ -1382,7 +1382,7 @@ export class TypeScriptService {
13821382
return (
13831383
configuration
13841384
.getService()
1385-
.getCodeFixesAtPosition(filePath, start, end, errorCodes, this.settings.format || {}) || []
1385+
.getCodeFixesAtPosition(filePath, start, end, errorCodes, this.settings.format || {}, {}) || []
13861386
)
13871387
})
13881388
.map((action: ts.CodeAction): Operation => ({
@@ -1496,7 +1496,7 @@ export class TypeScriptService {
14961496
}
14971497

14981498
return Observable.from(
1499-
configuration.getService().findRenameLocations(filePath, position, false, true)
1499+
configuration.getService().findRenameLocations(filePath, position, false, true) || []
15001500
).map((location: ts.RenameLocation): [string, TextEdit] => {
15011501
const sourceFile = this._getSourceFile(configuration, location.fileName, span)
15021502
if (!sourceFile) {
@@ -1585,12 +1585,13 @@ export class TypeScriptService {
15851585
const tsDiagnostics = config
15861586
.getService()
15871587
.getSyntacticDiagnostics(fileName)
1588-
.concat(config.getService().getSemanticDiagnostics(fileName))
1588+
.concat(
1589+
config
1590+
.getService()
1591+
.getSemanticDiagnostics(fileName)
1592+
.filter((e): e is ts.DiagnosticWithLocation => !!e.file)
1593+
)
15891594
const diagnostics = iterate(tsDiagnostics)
1590-
// TS can report diagnostics without a file and range in some cases
1591-
// These cannot be represented as LSP Diagnostics since the range and URI is required
1592-
// https://github.com/Microsoft/TypeScript/issues/15666
1593-
.filter(diagnostic => !!diagnostic.file)
15941595
.map(convertTsDiagnostic)
15951596
.toArray()
15961597
this.client.textDocumentPublishDiagnostics({ uri, diagnostics })

0 commit comments

Comments
 (0)