Skip to content

Commit 6ac9bf2

Browse files
authored
Merge pull request #4113 from jendrikw/compile-typescript-with-strict
vscode-dotty: Compile typescript with --strict
2 parents a27bc12 + 385b6ce commit 6ac9bf2

File tree

6 files changed

+34
-23
lines changed

6 files changed

+34
-23
lines changed

project/Build.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ object Build {
915915
val coursier = baseDirectory.value / "out/coursier"
916916
val packageJson = baseDirectory.value / "package.json"
917917
if (!coursier.exists || packageJson.lastModified > coursier.lastModified)
918-
runProcess(Seq("npm", "run", "update-all"), wait = true, directory = baseDirectory.value)
918+
runProcess(Seq("npm", "install"), wait = true, directory = baseDirectory.value)
919919
val tsc = baseDirectory.value / "node_modules" / ".bin" / "tsc"
920920
runProcess(Seq(tsc.getAbsolutePath, "--pretty", "--project", baseDirectory.value.getAbsolutePath), wait = true)
921921

vscode-dotty/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@
4747
},
4848
"scripts": {
4949
"tsc": "./node_modules/.bin/tsc",
50-
"vscode:prepublish": "npm run update-all && ./node_modules/.bin/tsc -p ./",
50+
"vscode:prepublish": "npm install && ./node_modules/.bin/tsc -p ./",
5151
"compile": "./node_modules/.bin/tsc -p ./",
52-
"update-all": "npm install && node ./node_modules/vscode/bin/install && curl -L -o out/coursier https://github.com/coursier/coursier/raw/v1.0.0/coursier",
53-
"test": "node ./node_modules/vscode/bin/test"
52+
"test": "node ./node_modules/vscode/bin/test",
53+
"postinstall": "node ./node_modules/vscode/bin/install && curl -L -o out/coursier https://github.com/coursier/coursier/raw/v1.0.0/coursier"
5454
},
5555
"extensionDependencies": [
5656
"daltonjorge.scala"

vscode-dotty/src/extension.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22

33
import * as fs from 'fs';
44
import * as path from 'path';
5-
import { spawn } from 'child_process';
65

76
import * as cpp from 'child-process-promise';
87

9-
import { commands, workspace, Disposable, ExtensionContext, Uri } from 'vscode';
10-
import { Executable, LanguageClient, LanguageClientOptions, SettingMonitor, ServerOptions, TransportKind } from 'vscode-languageclient';
11-
import * as lc from 'vscode-languageclient';
8+
import { ExtensionContext } from 'vscode';
129
import * as vscode from 'vscode';
10+
import { LanguageClient, LanguageClientOptions, ServerOptions } from 'vscode-languageclient';
1311

1412
let extensionContext: ExtensionContext
1513
let outputChannel: vscode.OutputChannel
@@ -45,7 +43,7 @@ export function activate(context: ExtensionContext) {
4543
})
4644
}
4745

48-
function fetchAndRun(artifact: String) {
46+
function fetchAndRun(artifact: string) {
4947
const coursierPath = path.join(extensionContext.extensionPath, './out/coursier');
5048

5149
vscode.window.withProgress({
@@ -64,15 +62,15 @@ function fetchAndRun(artifact: String) {
6462

6563
let classPath = ""
6664

67-
coursierProc.stdout.on('data', (data) => {
65+
coursierProc.stdout.on('data', (data: Buffer) => {
6866
classPath += data.toString().trim()
6967
})
70-
coursierProc.stderr.on('data', (data) => {
68+
coursierProc.stderr.on('data', (data: Buffer) => {
7169
let msg = data.toString()
7270
outputChannel.append(msg)
7371
})
7472

75-
coursierProc.on('close', (code) => {
73+
coursierProc.on('close', (code: number) => {
7674
if (code != 0) {
7775
let msg = "Fetching the language server failed."
7876
outputChannel.append(msg)

vscode-dotty/src/passthrough-server.ts

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
'use strict';
22

3-
import {
4-
IPCMessageReader, IPCMessageWriter,
5-
createConnection, IConnection, TextDocumentSyncKind,
6-
TextDocuments, TextDocument, Diagnostic, DiagnosticSeverity,
7-
InitializeParams, InitializeResult, TextDocumentPositionParams,
8-
CompletionItem, CompletionItemKind
9-
} from 'vscode-languageserver';
10-
113
import * as net from 'net';
124

13-
let argv = process.argv.slice(2)
14-
let port = argv.shift()
5+
let argv: string[] = process.argv.slice(2)
6+
const firstArg: string | undefined = argv.shift()
7+
let port: string
8+
if (firstArg === undefined) {
9+
throw new Error('Expected port as the first argument')
10+
} else {
11+
port = firstArg
12+
}
1513

1614
let client = new net.Socket()
1715
client.setEncoding('utf8')

vscode-dotty/src/types.d.ts

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
declare module 'child-process-promise' {
2+
3+
import {ChildProcess} from "child_process";
4+
5+
interface ChildPromiseResult {
6+
code: number;
7+
}
8+
9+
interface ChildProcessPromise extends Promise<ChildPromiseResult> {
10+
childProcess: ChildProcess;
11+
}
12+
13+
function spawn(command: string, args: string[]): ChildProcessPromise;
14+
}

vscode-dotty/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"es6"
88
],
99
"sourceMap": true,
10-
"rootDir": "."
10+
"rootDir": ".",
11+
"strict": true
1112
},
1213
"exclude": [
1314
"node_modules",

0 commit comments

Comments
 (0)