Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6e920d5

Browse files
committed
strict typedef
1 parentb2deee8 commit6e920d5

11 files changed

+35
-19
lines changed

‎src/commands/session.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { executeCommand } from "../utils/cpUtils";
77
import{DialogType,promptForOpenOutputChannel,promptForSignIn}from"../utils/uiUtils";
88

99
exportasyncfunctiongetSessionList(channel:vscode.OutputChannel):Promise<ISession[]>{
10-
constsignInStatus=leetCodeManager.getUser();
10+
constsignInStatus:string|undefined=leetCodeManager.getUser();
1111
if(!signInStatus){
1212
promptForSignIn();
1313
return[];
@@ -75,7 +75,7 @@ async function parseSessionsToPicks(channel: vscode.OutputChannel): Promise<Arra
7575
exportasyncfunctioncreateSession(channel:vscode.OutputChannel):Promise<void>{
7676
constsession:string|undefined=awaitvscode.window.showInputBox({
7777
prompt:"Enter the new session name.",
78-
validateInput:(s:string)=>s&&s.trim() ?undefined :"Session name must not be empty",
78+
validateInput:(s:string):string|undefined=>s&&s.trim() ?undefined :"Session name must not be empty",
7979
});
8080
if(!session){
8181
return;

‎src/commands/show.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export async function searchProblem(channel: vscode.OutputChannel): Promise<void
3939
asyncfunctionshowProblemInternal(channel:vscode.OutputChannel,id:string):Promise<void>{
4040
try{
4141
constleetCodeConfig:vscode.WorkspaceConfiguration=vscode.workspace.getConfiguration("leetcode");
42-
letdefaultLanguage=leetCodeConfig.get<string>("defaultLanguage");
42+
letdefaultLanguage:string|undefined=leetCodeConfig.get<string>("defaultLanguage");
4343
if(defaultLanguage&&languages.indexOf(defaultLanguage)<0){
4444
defaultLanguage=undefined;
4545
}
@@ -54,7 +54,7 @@ async function showProblemInternal(channel: vscode.OutputChannel, id: string): P
5454
constreg:RegExp=/\*SourceCode:\s*(.*)/;
5555
constmatch:RegExpMatchArray|null=result.match(reg);
5656
if(match&&match.length>=2){
57-
constfilePath=wsl.useWsl() ?wsl.toWinPath(match[1].trim()) :match[1].trim();
57+
constfilePath:string=wsl.useWsl() ?wsl.toWinPath(match[1].trim()) :match[1].trim();
5858

5959
awaitvscode.window.showTextDocument(vscode.Uri.file(filePath),{preview:false});
6060
}else{

‎src/commands/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export async function testSolution(channel: vscode.OutputChannel, uri?: vscode.U
5252
case":direct":
5353
consttestString:string|undefined=awaitvscode.window.showInputBox({
5454
prompt:"Enter the test cases.",
55-
validateInput:(s:string)=>s&&s.trim() ?undefined :"Test case must not be empty.",
55+
validateInput:(s:string):string|undefined=>s&&s.trim() ?undefined :"Test case must not be empty.",
5656
placeHolder:"Example: [1,2,3]\\n4",
5757
ignoreFocusOut:true,
5858
});

‎src/extension.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { leetCodeManager } from "./leetCodeManager";
1010
import{leetCodeStatusBarItem}from"./leetCodeStatusBarItem";
1111
import{isNodeInstalled}from"./utils/nodeUtils";
1212

13-
exportasyncfunctionactivate(context:vscode.ExtensionContext){
13+
exportasyncfunctionactivate(context:vscode.ExtensionContext):Promise<void>{
1414
constchannel:vscode.OutputChannel=vscode.window.createOutputChannel("LeetCode");
1515
if(!awaitisNodeInstalled(channel)){
1616
return;
@@ -37,6 +37,6 @@ export async function activate(context: vscode.ExtensionContext) {
3737
});
3838
}
3939

40-
exportfunctiondeactivate(){
40+
exportfunctiondeactivate():void{
4141
leetCodeStatusBarItem.dispose();
4242
}

‎src/leetCodeExplorer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { ProblemState } from "./shared";
88

99
// tslint:disable:max-classes-per-file
1010
exportclassLeetCodeNode{
11-
constructor(privatedata:list.IProblem,privateisProblemNode=true){}
11+
constructor(privatedata:list.IProblem,privateisProblemNode:boolean=true){}
1212

1313
publicgetlocked():boolean{
1414
returnthis.data.locked;

‎src/leetCodeManager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class LeetCodeManager extends EventEmitter implements ILeetCodeManager {
2929

3030
publicasyncgetLoginStatus(channel:vscode.OutputChannel):Promise<void>{
3131
try{
32-
constresult=awaitexecuteCommand(channel,"node",[leetCodeBinaryPath,"user"]);
32+
constresult:string=awaitexecuteCommand(channel,"node",[leetCodeBinaryPath,"user"]);
3333
this.currentUser=result.slice("You are now login as".length).trim();
3434
this.userStatus=UserStatus.SignedIn;
3535
}catch(error){
@@ -60,7 +60,7 @@ class LeetCodeManager extends EventEmitter implements ILeetCodeManager {
6060
childProc.on("error",reject);
6161
constname:string|undefined=awaitvscode.window.showInputBox({
6262
prompt:"Enter user name.",
63-
validateInput:(s:string)=>s&&s.trim() ?undefined :"User name must not be empty",
63+
validateInput:(s:string):string|undefined=>s&&s.trim() ?undefined :"User name must not be empty",
6464
});
6565
if(!name){
6666
childProc.kill();
@@ -70,7 +70,7 @@ class LeetCodeManager extends EventEmitter implements ILeetCodeManager {
7070
constpwd:string|undefined=awaitvscode.window.showInputBox({
7171
prompt:"Enter password.",
7272
password:true,
73-
validateInput:(s:string)=>s ?undefined :"Password must not be empty",
73+
validateInput:(s:string):string|undefined=>s ?undefined :"Password must not be empty",
7474
});
7575
if(!pwd){
7676
childProc.kill();

‎src/shared.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as path from "path";
44
import*asvscodefrom"vscode";
55
import*aswslfrom"./utils/wslUtils";
66

7-
letbinPath=path.join(__dirname,"..","..","node_modules","leetcode-cli","bin","leetcode");
7+
letbinPath:string=path.join(__dirname,"..","..","node_modules","leetcode-cli","bin","leetcode");
88

99
if(wsl.useWsl()){
1010
binPath=wsl.toWslPath(binPath);
@@ -21,7 +21,7 @@ export enum UserStatus {
2121
SignedOut=2,
2222
}
2323

24-
exportconstlanguages=[
24+
exportconstlanguages:string[]=[
2525
"bash",
2626
"c",
2727
"cpp",

‎src/utils/nodeUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export async function isNodeInstalled(channel: vscode.OutputChannel): Promise<bo
1010
awaitexecuteCommand(channel,"node",["-v"]);
1111
returntrue;
1212
}catch(error){
13-
constchoice=awaitvscode.window.showErrorMessage(
13+
constchoice:vscode.MessageItem|undefined=awaitvscode.window.showErrorMessage(
1414
"LeetCode extension need Node.js installed in environment path",
1515
DialogOptions.open,
1616
);

‎src/utils/uiUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export async function promptForOpenOutputChannel(message: string, type: DialogTy
3636
}
3737

3838
exportasyncfunctionpromptForSignIn():Promise<void>{
39-
constchoice=awaitvscode.window.showInformationMessage(
39+
constchoice:vscode.MessageItem|undefined=awaitvscode.window.showInformationMessage(
4040
"Please sign in to LeetCode.",
4141
DialogOptions.yes,
4242
DialogOptions.no,

‎src/utils/workspaceUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export async function selectWorkspaceFolder(): Promise<string> {
1717
}
1818
}
1919

20-
constworkFolder=folder ?folder.uri.fsPath :path.join(os.homedir(),".leetcode");
20+
constworkFolder:string=folder ?folder.uri.fsPath :path.join(os.homedir(),".leetcode");
2121

2222
returnwsl.useWsl() ?wsl.toWslPath(workFolder) :workFolder;
2323
}

‎tslint.json

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,26 @@
66
"jsRules": {},
77
"rules": {
88
"object-literal-sort-keys":false,
9-
"indent": [true,"spaces"],
9+
"indent": [
10+
true,
11+
"spaces"
12+
],
1013
"no-string-literal":false,
1114
"no-namespace":false,
12-
"max-line-length": [false,120]
15+
"max-line-length": [
16+
false,
17+
120
18+
],
19+
"typedef": [
20+
true,
21+
"call-signature",
22+
"arrow-call-signature",
23+
"parameter",
24+
"arrow-parameter",
25+
"property-declaration",
26+
"variable-declaration",
27+
"member-variable-declaration"
28+
]
1329
},
1430
"rulesDirectory": []
15-
}
31+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp