Code
Hub
Workspaces
Connect
Indexed graphs
Engine
MCP
copy
hub
/
github.com/basarat/typescript-book
/ typeGuard.ts
File
typeGuard.ts
code/types/typeGuard.ts:None–None ·
view source on GitHub ↗
Source
from the content-addressed store, hash-verified
1
export
namespace quick {
2
function
doSomething(x: number | string) {
3
if
(typeof x ===
'string'
) {
// Within the block TypeScript knows that `x` must be a string
4
console.log(x.subtr(1));
// Error, 'subtr' does not exist on `string`
Callers
nothing calls this directly
Calls
1
doStuff
Function · 0.70
Tested by
no test coverage detected