ANSI colors being included in the `tsType` field of some type predicates?
I've been encountering some pretty strange behavior with Deno Doc where generated function doc nodes contain ANSI color sequences like `\u001b[38;5;12m` in their `returnType` fields. I've confirmed this to be occurring in both the WebAssembly build and the Deno CLI version in `--json` mode, as recently as version 0.172.0 / Deno v2.3.1+5044f2f.
```ts
import { doc } from "jsr:@deno/doc@0.172.0";
const specifiers = [
"jsr:@nick/is@0.2.0-rc.6/both",
"jsr:@nick/is@0.2.0-rc.6/either",
"jsr:@nick/is@0.2.0-rc.6/constructor",
];
const result = await doc(specifiers);
console.log(result[specifiers[0]][1].functionDef.returnType);
```
When I run the above code I get the following result. Notice line 7.
```js
{
repr: "",
kind: "fnOrConstructor",
fnOrConstructor: {
constructor: false,
tsType: {
repr: "it is \x1b[0m\x1b[38;5;12mL\x1b[0m & \x1b[0m\x1b[38;5;12mR\x1b[0m",
kind: "typePredicate",
typePredicate: {
asserts: false,
param: { type: "identifier", name: "it" },
type: { repr: "", kind: "intersection", intersection: [Array] }
}
},
params: [
{
kind: "identifier",
name: "it",
optional: false,
tsType: { repr: "unknown", kind: "keyword", keyword: "unknown" }
}
],
typeParams: []
}
}
```
At first I thought it was only occuring on the `isBoth` and `isEither` guards, but I have just confirmed it is happening with other ones as well. The `/constructor` module, third in the `specifiers` array in the above example snippet, generates this doc node structure:
```js
{
repr: "it is \x1b[0m\x1b[38;5;12mConstructor\x1b[0m<\x1b[0m\x1b[38;5;12mT\x1b[0m>",
kind: "typePredicate",
typePredicate: {
asserts: false,
param: { type: "identifier", name: "it" },
type: {
repr: "Constructor",
kind: "typeRef",
typeRef: { typeParams: [ [Object] ], typeName: "Constructor" }
}
}
}
```
0 条评论