Skip to content

Commit 46443f1

Browse files
reillylmjakebailey
andauthored
prevent third-party types in twoslash snippets (#3309)
Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
1 parent 8166eaf commit 46443f1

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

packages/documentation/copy/en/javascript/JSDoc Reference.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ function walk(p) {
202202
import types can be used to get the type of a value from a module if you don't know the type, or if it has a large type that is annoying to type:
203203

204204
```js twoslash
205+
// @types: node
205206
// @filename: accounts.d.ts
206207
export const userAccount = {
207208
name: "Name",
@@ -765,6 +766,7 @@ Otherwise, `@example` will be parsed as a new tag.
765766
### Other supported patterns
766767

767768
```js twoslash
769+
// @types: react
768770
class Foo {}
769771
// ---cut---
770772
var someObj = {

packages/typescriptlang-org/gatsby-config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ if (process.env.BOOTSTRAPPING) {
1414

1515
require("./scripts/ensureDepsAreBuilt")
1616

17+
const ts = require("typescript");
18+
1719
// https://github.com/gatsbyjs/gatsby/issues/1457
1820
require("ts-node").register({ files: true })
1921
const { join } = require("path")
@@ -158,6 +160,10 @@ module.exports = {
158160
defaultOptions: {
159161
noErrorValidation: true,
160162
},
163+
defaultCompilerOptions: {
164+
types: [],
165+
target: ts.ScriptTarget.ES2020,
166+
},
161167
},
162168
},
163169
"gatsby-remark-copy-linked-files",

0 commit comments

Comments
 (0)