diff options
author | 2022-11-09 15:40:40 -0800 | |
---|---|---|
committer | 2022-11-09 15:40:40 -0800 | |
commit | f7f1b604443c030afe29d1059b90f72c69afe081 (patch) | |
tree | 8f2397447b2a84dab02850007264b72cc565f5d6 /test/snippets | |
parent | da257336b0b70df8c31da647496899cf70670000 (diff) | |
download | bun-f7f1b604443c030afe29d1059b90f72c69afe081.tar.gz bun-f7f1b604443c030afe29d1059b90f72c69afe081.tar.zst bun-f7f1b604443c030afe29d1059b90f72c69afe081.zip |
Add bun-types, add typechecking, add `child_process` types (#1475)
* Add bun-types to packages
* Improve typing
* Fix types in tests
* Fix dts tests
* Run formatter
* Fix all type errors
* Add strict mode, fix type errors
* Add ffi changes
* Move workflows to root
* Add workflows
* Remove labeler
* Add child_process types
* Fix synthetic defaults issue
* Remove docs
* Move scripts
* Run prettier
* Include examples in typechecking
* captureStackTrace types
* moved captureStackTrace types to globals
* Address reviews
Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
Diffstat (limited to 'test/snippets')
27 files changed, 65 insertions, 45 deletions
diff --git a/test/snippets/bun.lockb b/test/snippets/bun.lockb Binary files differindex cc2676be1..9553d3a11 100755 --- a/test/snippets/bun.lockb +++ b/test/snippets/bun.lockb diff --git a/test/snippets/caught-require.js b/test/snippets/caught-require.js index 6111d2b10..257cce4ec 100644 --- a/test/snippets/caught-require.js +++ b/test/snippets/caught-require.js @@ -9,7 +9,7 @@ try { import("this-package-should-not-exist").then( () => {}, - () => {} + () => {}, ); export async function test() { @@ -24,7 +24,7 @@ export async function test() { import("this-package-should-not-exist").then( () => {}, - () => {} + () => {}, ); return testDone(import.meta.url); diff --git a/test/snippets/code-simplification-neql-define.js b/test/snippets/code-simplification-neql-define.js index ed5c5c395..c7676dc9b 100644 --- a/test/snippets/code-simplification-neql-define.js +++ b/test/snippets/code-simplification-neql-define.js @@ -14,7 +14,7 @@ export var $f332019d = $$m( { "relay-runtime/lib/network/RelayQueryResponseCache.js": ( module, - exports + exports, ) => { var RelayQueryResponseCache = function () { var foo = function RelayQueryResponseCache(_ref) { @@ -26,7 +26,7 @@ export var $f332019d = $$m( false, "RelayQueryResponseCache: Expected the max cache size to be > 0, got " + "`%s`.", - size + size, ) : invariant(false) : void 0; @@ -35,7 +35,7 @@ export var $f332019d = $$m( ? invariant( false, "RelayQueryResponseCache: Expected the max ttl to be > 0, got `%s`.", - ttl + ttl, ) : invariant(false) : void 0; @@ -44,7 +44,7 @@ export var $f332019d = $$m( }; RelayQueryResponseCache(); }, - }["relay-runtime/lib/network/RelayQueryResponseCache.js"] + }["relay-runtime/lib/network/RelayQueryResponseCache.js"], ); export function test() { diff --git a/test/snippets/export.js b/test/snippets/export.js index fe0abfa53..2a757269f 100644 --- a/test/snippets/export.js +++ b/test/snippets/export.js @@ -23,7 +23,7 @@ export function test() { } console.assert( powerLevel.description === "9001", - "Symbol is not exported correctly" + "Symbol is not exported correctly", ); return testDone(import.meta.url); } diff --git a/test/snippets/jsx-entities.jsx b/test/snippets/jsx-entities.jsx index adabace2c..ac5d32225 100644 --- a/test/snippets/jsx-entities.jsx +++ b/test/snippets/jsx-entities.jsx @@ -928,7 +928,7 @@ export function test() { console.assert( elements[rawKey] === key.codePointAt(0), - `${key} is not ${elements[rawKey]}` + `${key} is not ${elements[rawKey]}`, ); } diff --git a/test/snippets/jsx-spacing.js b/test/snippets/jsx-spacing.js index 9b9f28a33..dfdd09560 100644 --- a/test/snippets/jsx-spacing.js +++ b/test/snippets/jsx-spacing.js @@ -3,27 +3,40 @@ exports.__esModule = true; exports.test = void 0; var ReactDOM = require("react-dom/server"); var ReturnDescriptionAsString = function (_a) { - var description = _a.description; - return description; + var description = _a.description; + return description; }; function test() { - var _bun = ReactDOM.renderToString(<ReturnDescriptionAsString description="line1 + var _bun = ReactDOM.renderToString( + <ReturnDescriptionAsString + description="line1 line2 trailing space line4 no trailing space 'single quote' \t\f\v\uF000 `template string` line6 no trailing space line7 trailing newline that ${terminates} the string literal -"></ReturnDescriptionAsString>); - // convert HTML entities to unicode - var el = document.createElement("textarea"); - el.innerHTML = _bun; - var bun = el.value; - var esbuild = "line1\nline2 trailing space \n\nline4 no trailing space 'single quote' \\t\\f\\v\\uF000 `template string`\n\nline6 no trailing space\nline7 trailing newline that ${terminates} the string literal\n"; - console.assert(bun === esbuild, "strings did not match: " + JSON.stringify({ - received: bun, - expected: esbuild - }, null, 2)); - testDone(import.meta.url); +" + ></ReturnDescriptionAsString>, + ); + // convert HTML entities to unicode + var el = document.createElement("textarea"); + el.innerHTML = _bun; + var bun = el.value; + var esbuild = + "line1\nline2 trailing space \n\nline4 no trailing space 'single quote' \\t\\f\\v\\uF000 `template string`\n\nline6 no trailing space\nline7 trailing newline that ${terminates} the string literal\n"; + console.assert( + bun === esbuild, + "strings did not match: " + + JSON.stringify( + { + received: bun, + expected: esbuild, + }, + null, + 2, + ), + ); + testDone(import.meta.url); } exports.test = test; diff --git a/test/snippets/jsx-spacing.jsx b/test/snippets/jsx-spacing.jsx index b6d13f97a..7e83171e6 100644 --- a/test/snippets/jsx-spacing.jsx +++ b/test/snippets/jsx-spacing.jsx @@ -13,7 +13,7 @@ line4 no trailing space 'single quote' \t\f\v\uF000 `template string` line6 no trailing space line7 trailing newline that ${terminates} the string literal " - ></ReturnDescriptionAsString> + ></ReturnDescriptionAsString>, ); // convert HTML entities to unicode @@ -35,8 +35,8 @@ line7 trailing newline that ${terminates} the string literal expected: esbuild, }, null, - 2 - )}` + 2, + )}`, ); testDone(import.meta.url); diff --git a/test/snippets/jsx-top-level.tsx b/test/snippets/jsx-top-level.tsx index 2b49b5959..a3caafccf 100644 --- a/test/snippets/jsx-top-level.tsx +++ b/test/snippets/jsx-top-level.tsx @@ -1,3 +1,4 @@ +// @ts-nocheck const isDropdown = true; const iconName = ""; const adjustedPadding = 5; diff --git a/test/snippets/latin1-chars-in-regexp.js b/test/snippets/latin1-chars-in-regexp.js index e4d613f5e..1a533b1e1 100644 --- a/test/snippets/latin1-chars-in-regexp.js +++ b/test/snippets/latin1-chars-in-regexp.js @@ -15,7 +15,7 @@ export var re_btou = new RegExp( "[\xE0-\xEF][\x80-\xBF]{2}", "[\xF0-\xF7][\x80-\xBF]{3}", ].join("|"), - "g" + "g", ); const encoder = new TextEncoder(); @@ -46,7 +46,7 @@ export function test() { ) { throw new Error( `test failed -${JSON.stringify({ expected, real }, null, 2)}` +${JSON.stringify({ expected, real }, null, 2)}`, ); } @@ -57,12 +57,12 @@ ${JSON.stringify({ expected, real }, null, 2)}` const decoder = new TextDecoder("utf8"); if ( !realLines.every( - (line, i) => decoder.decode(Uint8Array.from(expected[i])) === line + (line, i) => decoder.decode(Uint8Array.from(expected[i])) === line, ) ) { throw new Error( `test failed. Lines did not match. -${JSON.stringify({ expected, real }, null, 2)}` +${JSON.stringify({ expected, real }, null, 2)}`, ); } diff --git a/test/snippets/package-json-exports/_node_modules_copy/inexact/browser/dir/foo.js b/test/snippets/package-json-exports/_node_modules_copy/inexact/browser/dir/foo.js index e54d9d4d6..26ab53d5b 100644 --- a/test/snippets/package-json-exports/_node_modules_copy/inexact/browser/dir/foo.js +++ b/test/snippets/package-json-exports/_node_modules_copy/inexact/browser/dir/foo.js @@ -1 +1 @@ -export const target = 'browser';
\ No newline at end of file +export const target = "browser"; diff --git a/test/snippets/package-json-exports/_node_modules_copy/inexact/browser/foo.js b/test/snippets/package-json-exports/_node_modules_copy/inexact/browser/foo.js index e54d9d4d6..26ab53d5b 100644 --- a/test/snippets/package-json-exports/_node_modules_copy/inexact/browser/foo.js +++ b/test/snippets/package-json-exports/_node_modules_copy/inexact/browser/foo.js @@ -1 +1 @@ -export const target = 'browser';
\ No newline at end of file +export const target = "browser"; diff --git a/test/snippets/package-json-exports/_node_modules_copy/inexact/browser/index.js b/test/snippets/package-json-exports/_node_modules_copy/inexact/browser/index.js index e54d9d4d6..26ab53d5b 100644 --- a/test/snippets/package-json-exports/_node_modules_copy/inexact/browser/index.js +++ b/test/snippets/package-json-exports/_node_modules_copy/inexact/browser/index.js @@ -1 +1 @@ -export const target = 'browser';
\ No newline at end of file +export const target = "browser"; diff --git a/test/snippets/package-json-exports/_node_modules_copy/inexact/default/foo.js b/test/snippets/package-json-exports/_node_modules_copy/inexact/default/foo.js index 8fb5eac0c..826077c96 100644 --- a/test/snippets/package-json-exports/_node_modules_copy/inexact/default/foo.js +++ b/test/snippets/package-json-exports/_node_modules_copy/inexact/default/foo.js @@ -1 +1 @@ -export const target = 'default'; +export const target = "default"; diff --git a/test/snippets/package-json-exports/_node_modules_copy/inexact/node/foo.js b/test/snippets/package-json-exports/_node_modules_copy/inexact/node/foo.js index b9504cdf9..301a88090 100644 --- a/test/snippets/package-json-exports/_node_modules_copy/inexact/node/foo.js +++ b/test/snippets/package-json-exports/_node_modules_copy/inexact/node/foo.js @@ -1 +1 @@ -export const target = 'node';
\ No newline at end of file +export const target = "node"; diff --git a/test/snippets/package-json-exports/_node_modules_copy/js-only-exports/browser/dir/foo.js b/test/snippets/package-json-exports/_node_modules_copy/js-only-exports/browser/dir/foo.js index e54d9d4d6..26ab53d5b 100644 --- a/test/snippets/package-json-exports/_node_modules_copy/js-only-exports/browser/dir/foo.js +++ b/test/snippets/package-json-exports/_node_modules_copy/js-only-exports/browser/dir/foo.js @@ -1 +1 @@ -export const target = 'browser';
\ No newline at end of file +export const target = "browser"; diff --git a/test/snippets/package-json-exports/_node_modules_copy/js-only-exports/browser/foo.js b/test/snippets/package-json-exports/_node_modules_copy/js-only-exports/browser/foo.js index e54d9d4d6..26ab53d5b 100644 --- a/test/snippets/package-json-exports/_node_modules_copy/js-only-exports/browser/foo.js +++ b/test/snippets/package-json-exports/_node_modules_copy/js-only-exports/browser/foo.js @@ -1 +1 @@ -export const target = 'browser';
\ No newline at end of file +export const target = "browser"; diff --git a/test/snippets/package-json-exports/_node_modules_copy/js-only-exports/browser/index.js b/test/snippets/package-json-exports/_node_modules_copy/js-only-exports/browser/index.js index e54d9d4d6..26ab53d5b 100644 --- a/test/snippets/package-json-exports/_node_modules_copy/js-only-exports/browser/index.js +++ b/test/snippets/package-json-exports/_node_modules_copy/js-only-exports/browser/index.js @@ -1 +1 @@ -export const target = 'browser';
\ No newline at end of file +export const target = "browser"; diff --git a/test/snippets/package-json-exports/_node_modules_copy/js-only-exports/default/foo.js b/test/snippets/package-json-exports/_node_modules_copy/js-only-exports/default/foo.js index 8fb5eac0c..826077c96 100644 --- a/test/snippets/package-json-exports/_node_modules_copy/js-only-exports/default/foo.js +++ b/test/snippets/package-json-exports/_node_modules_copy/js-only-exports/default/foo.js @@ -1 +1 @@ -export const target = 'default'; +export const target = "default"; diff --git a/test/snippets/package-json-exports/_node_modules_copy/js-only-exports/node/foo.js b/test/snippets/package-json-exports/_node_modules_copy/js-only-exports/node/foo.js index b9504cdf9..301a88090 100644 --- a/test/snippets/package-json-exports/_node_modules_copy/js-only-exports/node/foo.js +++ b/test/snippets/package-json-exports/_node_modules_copy/js-only-exports/node/foo.js @@ -1 +1 @@ -export const target = 'node';
\ No newline at end of file +export const target = "node"; diff --git a/test/snippets/react-context-value-func.tsx b/test/snippets/react-context-value-func.tsx index 5f38a5d1c..e7ced1292 100644 --- a/test/snippets/react-context-value-func.tsx +++ b/test/snippets/react-context-value-func.tsx @@ -1,3 +1,4 @@ +// @ts-nocheck import React from "react"; const Context = React.createContext({}); diff --git a/test/snippets/simple-lit-example.ts b/test/snippets/simple-lit-example.ts index 34446e418..3c53f03ab 100644 --- a/test/snippets/simple-lit-example.ts +++ b/test/snippets/simple-lit-example.ts @@ -1,3 +1,4 @@ +// @ts-nocheck import { LitElement, html, css } from "lit"; import { customElement, property, eventOptions } from "lit/decorators.js"; @@ -12,7 +13,7 @@ if (document?.readyState === "loading") { () => { loadedResolve(); }, - { once: true } + { once: true }, ); } else { loadedResolve(); diff --git a/test/snippets/spread_with_key.tsx b/test/snippets/spread_with_key.tsx index 9c26ea5ba..d9f842d27 100644 --- a/test/snippets/spread_with_key.tsx +++ b/test/snippets/spread_with_key.tsx @@ -1,3 +1,4 @@ +// @ts-nocheck import React from "react"; export function SpreadWithTheKey({ className }: Props) { diff --git a/test/snippets/styledcomponents-output.js b/test/snippets/styledcomponents-output.js index a79b5e24d..fca6e8407 100644 --- a/test/snippets/styledcomponents-output.js +++ b/test/snippets/styledcomponents-output.js @@ -39,18 +39,18 @@ export function test() { <ErrorScreenRoot id="error-el"> The react child should have this text </ErrorScreenRoot>, - reactEl + reactEl, ); const style = document.querySelector("style[data-styled]"); console.assert(style, "style tag should exist"); console.assert( style.textContent.split("").every((a) => a.codePointAt(0) < 128), - "style tag should not contain invalid unicode codepoints" + "style tag should not contain invalid unicode codepoints", ); console.assert( document.querySelector("#error-el").textContent === - "The react child should have this text" + "The react child should have this text", ); ReactDOM.unmountComponentAtNode(reactEl); diff --git a/test/snippets/template-literal.js b/test/snippets/template-literal.js index ff4e08a4d..a5749a555 100644 --- a/test/snippets/template-literal.js +++ b/test/snippets/template-literal.js @@ -37,14 +37,14 @@ export function test() { for (let foo of [fooNoBracesUT16, fooNoBracesUTF8, fooUTF16, fooUTF8]) { console.assert( foo.includes("before"), - `Expected ${foo} to include "before"` + `Expected ${foo} to include "before"`, ); console.assert(foo.includes("after"), `Expected ${foo} to include "after"`); } console.assert( templateLiteralWhichDefinesAFunction.includes("true"), - "Expected fooFunction to include 'true'" + "Expected fooFunction to include 'true'", ); return testDone(import.meta.url); diff --git a/test/snippets/ts-fallback-rewrite-works.ts b/test/snippets/ts-fallback-rewrite-works.ts index 8e6dabcdb..8054897b8 100644 --- a/test/snippets/ts-fallback-rewrite-works.ts +++ b/test/snippets/ts-fallback-rewrite-works.ts @@ -1,3 +1,4 @@ +// @ts-nocheck // This looks like it does nothing // But if you import /ts-fallback-rewrite-works.js, it should resolve the import to /ts-fallback-rewrite-works.ts export function test() { diff --git a/test/snippets/tsx-fallback-rewrite-works.tsx b/test/snippets/tsx-fallback-rewrite-works.tsx index b18619914..918db3b04 100644 --- a/test/snippets/tsx-fallback-rewrite-works.tsx +++ b/test/snippets/tsx-fallback-rewrite-works.tsx @@ -1,3 +1,4 @@ +// @ts-nocheck // This looks like it does nothing // But if you import /tsx-fallback-rewrite-works.js, it should resolve the import to /tsx-fallback-rewrite-works.tsx export function test() { diff --git a/test/snippets/type-only-imports.ts b/test/snippets/type-only-imports.ts index 447f86793..c43fcf278 100644 --- a/test/snippets/type-only-imports.ts +++ b/test/snippets/type-only-imports.ts @@ -1,3 +1,4 @@ +// @ts-nocheck import type Bacon from "tree"; import type { SilentSymbolCollisionsAreOkayInTypeScript } from "./app"; |