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 2 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
5 changes: 3 additions & 2 deletions vscode-dotty/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@
"tsc": "./node_modules/.bin/tsc",
"vscode:prepublish": "npm run update-all && ./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"
"update-all": "npm install",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would keep this as it was before, it matches how other vscode extensions do it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why it is done this way? This is exaclty the use case postinstall was made for.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just checked and the default template does use postinstall instead of update-all now actually, so this change is fine but we should get rid of update-all while we're at it.

"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