Skip to content

vscode-dotty: Compile typescript with --strict #4113

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

Merged
merged 3 commits into from
Mar 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ object Build {
val coursier = baseDirectory.value / "out/coursier"
val packageJson = baseDirectory.value / "package.json"
if (!coursier.exists || packageJson.lastModified > coursier.lastModified)
runProcess(Seq("npm", "run", "update-all"), wait = true, directory = baseDirectory.value)
runProcess(Seq("npm", "install"), wait = true, directory = baseDirectory.value)
val tsc = baseDirectory.value / "node_modules" / ".bin" / "tsc"
runProcess(Seq(tsc.getAbsolutePath, "--pretty", "--project", baseDirectory.value.getAbsolutePath), wait = true)

Expand Down
6 changes: 3 additions & 3 deletions vscode-dotty/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
},
"scripts": {
"tsc": "./node_modules/.bin/tsc",
"vscode:prepublish": "npm run update-all && ./node_modules/.bin/tsc -p ./",
"vscode:prepublish": "npm install && ./node_modules/.bin/tsc -p ./",
"compile": "./node_modules/.bin/tsc -p ./",
"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",
"test": "node ./node_modules/vscode/bin/test"
"test": "node ./node_modules/vscode/bin/test",
"postinstall": "node ./node_modules/vscode/bin/install && curl -L -o out/coursier https://github.com/coursier/coursier/raw/v1.0.0/coursier"
},
"extensionDependencies": [
"daltonjorge.scala"
Expand Down
14 changes: 6 additions & 8 deletions vscode-dotty/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

import * as fs from 'fs';
import * as path from 'path';
import { spawn } from 'child_process';

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

import { commands, workspace, Disposable, ExtensionContext, Uri } from 'vscode';
import { Executable, LanguageClient, LanguageClientOptions, SettingMonitor, ServerOptions, TransportKind } from 'vscode-languageclient';
import * as lc from 'vscode-languageclient';
import { ExtensionContext } from 'vscode';
import * as vscode from 'vscode';
import { LanguageClient, LanguageClientOptions, ServerOptions } from 'vscode-languageclient';

let extensionContext: ExtensionContext
let outputChannel: vscode.OutputChannel
Expand Down Expand Up @@ -45,7 +43,7 @@ export function activate(context: ExtensionContext) {
})
}

function fetchAndRun(artifact: String) {
function fetchAndRun(artifact: string) {
const coursierPath = path.join(extensionContext.extensionPath, './out/coursier');

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

let classPath = ""

coursierProc.stdout.on('data', (data) => {
coursierProc.stdout.on('data', (data: Buffer) => {
classPath += data.toString().trim()
})
coursierProc.stderr.on('data', (data) => {
coursierProc.stderr.on('data', (data: Buffer) => {
let msg = data.toString()
outputChannel.append(msg)
})

coursierProc.on('close', (code) => {
coursierProc.on('close', (code: number) => {
if (code != 0) {
let msg = "Fetching the language server failed."
outputChannel.append(msg)
Expand Down
18 changes: 8 additions & 10 deletions vscode-dotty/src/passthrough-server.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
'use strict';

import {
IPCMessageReader, IPCMessageWriter,
createConnection, IConnection, TextDocumentSyncKind,
TextDocuments, TextDocument, Diagnostic, DiagnosticSeverity,
InitializeParams, InitializeResult, TextDocumentPositionParams,
CompletionItem, CompletionItemKind
} from 'vscode-languageserver';

import * as net from 'net';

let argv = process.argv.slice(2)
let port = argv.shift()
let argv: string[] = process.argv.slice(2)
const firstArg: string | undefined = argv.shift()
let port: string
if (firstArg === undefined) {
throw new Error('Expected port as the first argument')
} else {
port = firstArg
}

let client = new net.Socket()
client.setEncoding('utf8')
Expand Down
14 changes: 14 additions & 0 deletions vscode-dotty/src/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
declare module 'child-process-promise' {

import {ChildProcess} from "child_process";

interface ChildPromiseResult {
code: number;
}

interface ChildProcessPromise extends Promise<ChildPromiseResult> {
childProcess: ChildProcess;
}

function spawn(command: string, args: string[]): ChildProcessPromise;
}
3 changes: 2 additions & 1 deletion vscode-dotty/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"es6"
],
"sourceMap": true,
"rootDir": "."
"rootDir": ".",
"strict": true
},
"exclude": [
"node_modules",
Expand Down