Skip to content

Commit

Permalink
Merge pull request #226 from aryaemami59/fix/typos
Browse files Browse the repository at this point in the history
Fix minor typos
  • Loading branch information
andrewbranch authored Dec 6, 2024
2 parents 2950f9b + c2b596f commit 953e617
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .changeset/kind-eagles-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@arethetypeswrong/core": patch
"@arethetypeswrong/cli": patch
---

Fix minor typos
2 changes: 1 addition & 1 deletion docs/problems/NamedExports.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module.exports = {
import { a } from "./api.cjs";
```

However, TypeScript has no way of knowing, and no way of indicating in a declaration file, whether CommonJS exports are written in a way that will be statically analyzable. It assumes they _will_ be, and so even a completely correct declaration file for `api.cjs` will indicate that `a` can be imported by name. Since there’s no way to make the types more restrictive without making them incomplete, and since the unalyzable export is an inconvenience for all consumers of the JavaScript, the only solution is to fix the JavaScript. If the JavaScript exports can’t be restructured, it’s possible to “hint” the exports to cjs-module-lexer with an assignment that never executes:
However, TypeScript has no way of knowing, and no way of indicating in a declaration file, whether CommonJS exports are written in a way that will be statically analyzable. It assumes they _will_ be, and so even a completely correct declaration file for `api.cjs` will indicate that `a` can be imported by name. Since there’s no way to make the types more restrictive without making them incomplete, and since the unanalyzable export is an inconvenience for all consumers of the JavaScript, the only solution is to fix the JavaScript. If the JavaScript exports can’t be restructured, it’s possible to “hint” the exports to cjs-module-lexer with an assignment that never executes:

```js
module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ In the config file, `format` can be a string value.

```shell
attw --pack . --entrypoints . one two three # Just ".", "./one", "./two", "./three"
attw --pack . --include-entrypoints added # Auto-discovered entyrpoints plus "./added"
attw --pack . --include-entrypoints added # Auto-discovered entrypoints plus "./added"
attw --pack . --exclude-entrypoints styles.css # Auto-discovered entrypoints except "./styles.css"
attw --pack . --entrypoints-legacy # All published code files
```
Expand Down
7 changes: 5 additions & 2 deletions packages/cli/src/getExitCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export function getExitCode(analysis: CheckResult, opts?: RenderOptions): number
const ignoreResolutions = opts?.ignoreResolutions ?? [];
return analysis.problems.some((problem) => {
const notRuleIgnored = !ignoreRules.includes(problemFlags[problem.kind]);
const notResolutionIgnored = "resolutionKind" in problem ? !ignoreResolutions.includes(problem.resolutionKind) : true;
const notResolutionIgnored =
"resolutionKind" in problem ? !ignoreResolutions.includes(problem.resolutionKind) : true;
return notRuleIgnored && notResolutionIgnored;
}) ? 1 : 0;
})
? 1
: 0;
}
2 changes: 1 addition & 1 deletion packages/core/src/internal/multiCompilerHost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export class CompilerHostWrapper {
{ ...this.compilerOptions, ...extraOptions },
)
) {
throw new Error("Cannot override resolution-affecting options for host due to potential cache polution");
throw new Error("Cannot override resolution-affecting options for host due to potential cache pollution");
}
const options = extraOptions ? { ...this.compilerOptions, ...extraOptions } : this.compilerOptions;
return this.getProgram(rootNames, options);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/problems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const problemKindInfo: Record<ProblemKind, ProblemKindInfo> = {
},
FallbackCondition: {
emoji: "🐛",
title: "Resloved through fallback condition",
title: "Resolved through fallback condition",
shortDescription: "Used fallback condition",
description:
"Import resolved to types through a conditional package.json export, but only after failing to resolve through an earlier condition. This behavior is a [TypeScript bug](https://github.com/microsoft/TypeScript/issues/50762). It may misrepresent the runtime behavior of this import and should not be relied upon.",
Expand Down
6 changes: 3 additions & 3 deletions packages/core/test/problems/exportDefaultDisagreement.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe("exportDefaultDisagreement", () => {
parentPath.replaceWith(t.numericLiteral(newValue));
} else {
const line = parentPath.node.loc.start.line;
throw new _babelPluginMacros.MacroError();
}
}
Expand All @@ -119,7 +119,7 @@ describe("exportDefaultDisagreement", () => {
);
});

test("lone deafult export is primitive", () => {
test("lone default export is primitive", () => {
assert(
isOk(
`declare const _default: string;
Expand Down Expand Up @@ -214,7 +214,7 @@ var index_default = { a, b };`,
);
});

test("ignores unalayzable iife", () => {
test("ignores unanalyzable iife", () => {
assert(
isOk(
`export default function foo(): void`,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"lib": ["es2019"],
"module": "nodenext",
"outDir": "dist",
"types": ["node", "ts-expose-internals"],
"types": ["node", "ts-expose-internals"]
},
"references": [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"module": "nodenext",
"outDir": "dist",
"rootDir": "src",
"types": ["ts-expose-internals"],
"types": ["ts-expose-internals"]
},
"include": ["src"]
}
2 changes: 1 addition & 1 deletion tsconfig.check-dts.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"strict": true
},
"include": ["./packages/core/dist"]
}
}

0 comments on commit 953e617

Please sign in to comment.