github.com/derat/nup@v0.0.0-20230418113745-15592ba7c620/test/web/ts/ts_test.go (about)

     1  // Copyright 2022 Daniel Erat.
     2  // All rights reserved.
     3  
     4  package web
     5  
     6  import (
     7  	"bytes"
     8  	"os/exec"
     9  	"path/filepath"
    10  	"testing"
    11  )
    12  
    13  const webDir = "../../../web"
    14  
    15  func TestTypeScript(t *testing.T) {
    16  	cmd := exec.Command("tsc",
    17  		"--allowJs",
    18  		"--forceConsistentCasingInFileNames",
    19  		"--noEmit",
    20  		"--noFallthroughCasesInSwitch",
    21  		"--noImplicitAny",
    22  		"--noUnusedLocals",
    23  		"--strict",
    24  		"--target", "es2020",
    25  		filepath.Join(webDir, "index.ts"),
    26  		filepath.Join(webDir, "global.d.ts"),
    27  	)
    28  	if stdout, err := cmd.Output(); err != nil {
    29  		t.Errorf("tsc failed: %v\n%s", err,
    30  			bytes.ReplaceAll(stdout, []byte(webDir+"/"), nil))
    31  	}
    32  }