Skip to content

Commit

Permalink
Merge pull request #27 from syumai/strict
Browse files Browse the repository at this point in the history
Enable strict mode
  • Loading branch information
syumai authored Jul 8, 2019
2 parents 88cc4e8 + 207e7ce commit d361dba
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tsconfig.json
/tsconfig.json
node_modules
package-lock.json
package.json
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: test

test:
deno run --allow-read dejs_test.ts
deno -c ./testdata/tsconfig.json --allow-read dejs_test.ts
8 changes: 4 additions & 4 deletions dejs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ export async function compile(reader: Reader): Promise<Template> {
continue;
}
if (buf.length > 2) {
await statementBufWrite(buf.shift());
await statementBufWrite(buf.shift() as number);
}
continue;
}

// Finish current ReadMode
if (buf[1] === Codes.Percent && buf[2] === Codes.End) {
statementBufWrite(buf.shift());
statementBufWrite(buf.shift() as number);
buf.splice(0);
// Don't execute if ReadMode is Comment.
if (readMode !== ReadMode.Comment) {
Expand All @@ -157,12 +157,12 @@ export async function compile(reader: Reader): Promise<Template> {
readMode = ReadMode.Normal;
continue;
}
await statementBufWrite(buf.shift());
await statementBufWrite(buf.shift() as number);
}

// Flush buffer
while (buf.length > 0) {
await statementBufWrite(buf.shift());
await statementBufWrite(buf.shift() as number);
}
statements.push(`$$OUTPUT.push(\`${statementBuf.toString()}\`);`);
statementBuf.reset();
Expand Down
9 changes: 9 additions & 0 deletions testdata/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
}
}

0 comments on commit d361dba

Please sign in to comment.